reifyui 0.11.1 → 0.13.0

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 (85) hide show
  1. package/README.md +31 -2
  2. package/dist/chart.js +2 -0
  3. package/dist/chart.js.map +1 -1
  4. package/dist/chunk-EL2DHWOH.js +1710 -0
  5. package/dist/chunk-EL2DHWOH.js.map +1 -0
  6. package/dist/chunk-J633KV57.js +41 -0
  7. package/dist/chunk-J633KV57.js.map +1 -0
  8. package/dist/chunk-J7SECRIG.js +295 -0
  9. package/dist/chunk-J7SECRIG.js.map +1 -0
  10. package/dist/chunk-PIRPLH2Z.js +231 -0
  11. package/dist/chunk-PIRPLH2Z.js.map +1 -0
  12. package/dist/chunk-PZ5AY32C.js +10 -0
  13. package/dist/chunk-PZ5AY32C.js.map +1 -0
  14. package/dist/chunk-UKG4Z6QK.js +130 -0
  15. package/dist/chunk-UKG4Z6QK.js.map +1 -0
  16. package/dist/chunk-ZYWE47EO.js +19 -0
  17. package/dist/chunk-ZYWE47EO.js.map +1 -0
  18. package/dist/collab.cjs +169 -0
  19. package/dist/collab.cjs.map +1 -0
  20. package/dist/collab.d.ts +30 -0
  21. package/dist/collab.js +18 -0
  22. package/dist/collab.js.map +1 -0
  23. package/dist/graph.cjs +2244 -0
  24. package/dist/graph.cjs.map +1 -0
  25. package/dist/graph.d.ts +41 -0
  26. package/dist/graph.js +1870 -0
  27. package/dist/graph.js.map +1 -0
  28. package/dist/harness.js +1 -0
  29. package/dist/harness.js.map +1 -1
  30. package/dist/index.cjs +2044 -867
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.d.ts +20 -2
  33. package/dist/index.js +892 -1686
  34. package/dist/index.js.map +1 -1
  35. package/dist/sheet-doc.cjs +235 -0
  36. package/dist/sheet-doc.cjs.map +1 -0
  37. package/dist/sheet-doc.d.ts +16 -0
  38. package/dist/sheet-doc.js +20 -0
  39. package/dist/sheet-doc.js.map +1 -0
  40. package/dist/sheet.cjs +2322 -0
  41. package/dist/sheet.cjs.map +1 -0
  42. package/dist/sheet.d.ts +23 -0
  43. package/dist/sheet.js +237 -0
  44. package/dist/sheet.js.map +1 -0
  45. package/dist/slides.js +2 -0
  46. package/dist/slides.js.map +1 -1
  47. package/package.json +35 -3
  48. package/src/auth/client.js +4 -2
  49. package/src/collab/colors.js +18 -0
  50. package/src/collab/index.d.ts +30 -0
  51. package/src/collab/index.js +8 -0
  52. package/src/collab/keepAlive.js +34 -0
  53. package/src/collab/useLiveDoc.js +76 -0
  54. package/src/components/CascadeMenu.jsx +216 -0
  55. package/src/components/ChatMessages.jsx +30 -9
  56. package/src/components/Chip.jsx +37 -10
  57. package/src/components/Composer.jsx +80 -2
  58. package/src/components/resizable.jsx +82 -12
  59. package/src/graph/ConnectPane.jsx +634 -0
  60. package/src/graph/ConnectToolDetail.jsx +565 -0
  61. package/src/graph/LogsPane.jsx +328 -0
  62. package/src/graph/Skeleton.jsx +13 -0
  63. package/src/graph/draft.js +108 -0
  64. package/src/graph/format.js +37 -0
  65. package/src/graph/index.d.ts +41 -0
  66. package/src/graph/index.js +14 -0
  67. package/src/graph/useGraphCollab.js +299 -0
  68. package/src/graph/vgraph.js +215 -0
  69. package/src/index.d.ts +20 -2
  70. package/src/index.js +6 -1
  71. package/src/mention/MentionInput.jsx +420 -0
  72. package/src/mention/mentionModel.js +177 -0
  73. package/src/sheet/RunStrip.jsx +57 -0
  74. package/src/sheet/SheetGrid.jsx +444 -353
  75. package/src/sheet/doc.d.ts +16 -0
  76. package/src/sheet/index.d.ts +23 -0
  77. package/src/sheet/index.js +10 -0
  78. package/src/sheet/sheetDoc.js +203 -0
  79. package/src/sheet/useSheetCollab.js +102 -0
  80. package/src/sheet/useSheetRun.js +80 -0
  81. package/styles/chat.css +47 -5
  82. package/styles/chip.css +36 -0
  83. package/styles/graph.css +395 -0
  84. package/styles/mention.css +79 -0
  85. package/styles/sheet.css +156 -112
package/dist/index.js CHANGED
@@ -4,6 +4,44 @@ import {
4
4
  readSSEStream,
5
5
  turnsToMessages
6
6
  } from "./chunk-NTIWFHR4.js";
7
+ import {
8
+ MentionInput,
9
+ MentionText,
10
+ Popover,
11
+ SheetGrid,
12
+ sheetToAoA,
13
+ sheetToDelimited
14
+ } from "./chunk-EL2DHWOH.js";
15
+ import {
16
+ Chevron,
17
+ CodeBlock,
18
+ IcCheck,
19
+ IcDoc,
20
+ IcDownload,
21
+ IcEye,
22
+ IcGlobe,
23
+ IcList,
24
+ IcMic,
25
+ IcPanelRight,
26
+ IcPaperclip,
27
+ IcPlug,
28
+ IcScroll,
29
+ IcSearch,
30
+ IcSend,
31
+ IcSkill,
32
+ IcSpawn,
33
+ IcTerminal,
34
+ IcThink,
35
+ IcTool,
36
+ IcX,
37
+ Modal,
38
+ Svg
39
+ } from "./chunk-J7SECRIG.js";
40
+ import {
41
+ useOverlayEscape
42
+ } from "./chunk-J633KV57.js";
43
+ import "./chunk-ZYWE47EO.js";
44
+ import "./chunk-PZ5AY32C.js";
7
45
 
8
46
  // src/state/blocks.js
9
47
  function withText(blocks, d) {
@@ -92,106 +130,6 @@ function createConversationStore(makeInitial) {
92
130
  return { get, set, seed, updateLastAssistant, use };
93
131
  }
94
132
 
95
- // src/components/icons.jsx
96
- import React from "react";
97
- import { jsx, jsxs } from "react/jsx-runtime";
98
- function Svg({ children, s = 16 }) {
99
- return /* @__PURE__ */ jsx(
100
- "svg",
101
- {
102
- width: s,
103
- height: s,
104
- viewBox: "0 0 24 24",
105
- fill: "none",
106
- stroke: "currentColor",
107
- strokeWidth: "1.8",
108
- strokeLinecap: "round",
109
- strokeLinejoin: "round",
110
- children
111
- }
112
- );
113
- }
114
- function Chevron({ dir, size = 16 }) {
115
- const d = dir === "left" ? "M15 18l-6-6 6-6" : dir === "right" ? "M9 18l6-6-6-6" : "M6 9l6 6 6-6";
116
- return /* @__PURE__ */ jsx(
117
- "svg",
118
- {
119
- width: size,
120
- height: size,
121
- viewBox: "0 0 24 24",
122
- fill: "none",
123
- stroke: "currentColor",
124
- strokeWidth: "2",
125
- strokeLinecap: "round",
126
- strokeLinejoin: "round",
127
- children: /* @__PURE__ */ jsx("path", { d })
128
- }
129
- );
130
- }
131
- var IcTool = () => /* @__PURE__ */ jsx(Svg, { s: 17, children: /* @__PURE__ */ jsx("path", { d: "M14.7 6.3a4 4 0 0 1-5.4 5.4L4 17v3h3l5.3-5.3a4 4 0 0 1 5.4-5.4l-2.3 2.3-1.7-1.7 2.3-2.3a4 4 0 0 0-1.6 0Z" }) });
132
- var IcPlug = () => /* @__PURE__ */ jsxs(Svg, { s: 17, children: [
133
- /* @__PURE__ */ jsx("path", { d: "M9 2v6M15 2v6M6 8h12v3a6 6 0 0 1-12 0z" }),
134
- /* @__PURE__ */ jsx("path", { d: "M12 17v5" })
135
- ] });
136
- var IcSkill = () => /* @__PURE__ */ jsxs(Svg, { s: 17, children: [
137
- /* @__PURE__ */ jsx("path", { d: "M9 18h6M10 22h4" }),
138
- /* @__PURE__ */ jsx("path", { d: "M12 2a7 7 0 0 0-4 12.7c.6.5 1 1.3 1 2.1V18h6v-1.2c0-.8.4-1.6 1-2.1A7 7 0 0 0 12 2z" })
139
- ] });
140
- var IcTerminal = () => /* @__PURE__ */ jsxs(Svg, { s: 17, children: [
141
- /* @__PURE__ */ jsx("rect", { x: "3", y: "4", width: "18", height: "16", rx: "2" }),
142
- /* @__PURE__ */ jsx("path", { d: "M7 9l3 3-3 3M13 15h4" })
143
- ] });
144
- var IcDoc = () => /* @__PURE__ */ jsxs(Svg, { s: 17, children: [
145
- /* @__PURE__ */ jsx("path", { d: "M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z" }),
146
- /* @__PURE__ */ jsx("path", { d: "M14 3v6h6M8 13h8M8 17h6" })
147
- ] });
148
- var IcList = () => /* @__PURE__ */ jsx(Svg, { s: 17, children: /* @__PURE__ */ jsx("path", { d: "M8 6h12M8 12h12M8 18h12M3.5 6h.01M3.5 12h.01M3.5 18h.01" }) });
149
- var IcGlobe = () => /* @__PURE__ */ jsxs(Svg, { s: 17, children: [
150
- /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "9" }),
151
- /* @__PURE__ */ jsx("path", { d: "M3 12h18M12 3a15 15 0 0 1 0 18a15 15 0 0 1 0-18z" })
152
- ] });
153
- var IcSearch = () => /* @__PURE__ */ jsxs(Svg, { s: 17, children: [
154
- /* @__PURE__ */ jsx("circle", { cx: "11", cy: "11", r: "7" }),
155
- /* @__PURE__ */ jsx("path", { d: "m21 21-4.3-4.3" })
156
- ] });
157
- var IcScroll = () => /* @__PURE__ */ jsxs(Svg, { s: 17, children: [
158
- /* @__PURE__ */ jsx("path", { d: "M6 3h10a2 2 0 0 1 2 2v12a3 3 0 0 0 3 3H8a2 2 0 0 1-2-2V3z" }),
159
- /* @__PURE__ */ jsx("path", { d: "M6 3a2 2 0 0 0-2 2v2h2M10 8h6M10 12h6" })
160
- ] });
161
- var IcSpawn = () => /* @__PURE__ */ jsxs(Svg, { s: 17, children: [
162
- /* @__PURE__ */ jsx("circle", { cx: "6", cy: "6", r: "3" }),
163
- /* @__PURE__ */ jsx("circle", { cx: "18", cy: "18", r: "3" }),
164
- /* @__PURE__ */ jsx("path", { d: "M6 9v3a3 3 0 0 0 3 3h6" })
165
- ] });
166
- var IcCheck = () => /* @__PURE__ */ jsxs(Svg, { s: 17, children: [
167
- /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "9" }),
168
- /* @__PURE__ */ jsx("path", { d: "m9 12 2 2 4-4" })
169
- ] });
170
- var IcThink = () => /* @__PURE__ */ jsx(Svg, { s: 16, children: /* @__PURE__ */ jsx("path", { d: "M9.5 2a5.5 5.5 0 0 0-3 10.1V15a2 2 0 0 0 2 2h3a2 2 0 0 0 2-2v-2.9A5.5 5.5 0 0 0 9.5 2zM9 20h4M10 22h2" }) });
171
- var IcSend = () => /* @__PURE__ */ jsxs(Svg, { s: 16, children: [
172
- /* @__PURE__ */ jsx("path", { d: "M12 19V5" }),
173
- /* @__PURE__ */ jsx("path", { d: "M5 12l7-7 7 7" })
174
- ] });
175
- var IcX = ({ size = 14 }) => /* @__PURE__ */ jsx(Svg, { s: size, children: /* @__PURE__ */ jsx("path", { d: "M18 6 6 18M6 6l12 12" }) });
176
- var IcMic = ({ size = 15 }) => /* @__PURE__ */ jsxs(Svg, { s: size, children: [
177
- /* @__PURE__ */ jsx("rect", { x: "9", y: "2", width: "6", height: "12", rx: "3" }),
178
- /* @__PURE__ */ jsx("path", { d: "M5 11a7 7 0 0 0 14 0M12 18v4M8 22h8" })
179
- ] });
180
- var IcPaperclip = ({ size = 16 }) => /* @__PURE__ */ jsx(Svg, { s: size, children: /* @__PURE__ */ jsx("path", { d: "M21.4 11.1 12.2 20.3a5.5 5.5 0 0 1-7.8-7.8l9.2-9.2a3.7 3.7 0 0 1 5.2 5.2l-9.2 9.2a1.8 1.8 0 0 1-2.6-2.6l8.5-8.5" }) });
181
- var IcPanelRight = ({ size = 17 }) => /* @__PURE__ */ jsxs(Svg, { s: size, children: [
182
- /* @__PURE__ */ jsx("rect", { x: "3", y: "4", width: "18", height: "16", rx: "2" }),
183
- /* @__PURE__ */ jsx("path", { d: "M15 4v16" })
184
- ] });
185
- var IcDownload = ({ size = 16 }) => /* @__PURE__ */ jsxs(Svg, { s: size, children: [
186
- /* @__PURE__ */ jsx("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
187
- /* @__PURE__ */ jsx("path", { d: "M7 10l5 5 5-5" }),
188
- /* @__PURE__ */ jsx("path", { d: "M12 15V3" })
189
- ] });
190
- var IcEye = ({ size = 15 }) => /* @__PURE__ */ jsxs(Svg, { s: size, children: [
191
- /* @__PURE__ */ jsx("path", { d: "M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7-10-7-10-7z" }),
192
- /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "3" })
193
- ] });
194
-
195
133
  // src/components/toolMeta.js
196
134
  function humanize(s) {
197
135
  return (s || "").replace(/[_\-]+/g, " ").trim().replace(/\b\w/g, (c) => c.toUpperCase());
@@ -332,8 +270,8 @@ function summarizeSteps(steps) {
332
270
  }
333
271
 
334
272
  // src/components/ToolSteps.jsx
335
- import React2, { useEffect, useState } from "react";
336
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
273
+ import React, { useEffect, useState } from "react";
274
+ import { jsx, jsxs } from "react/jsx-runtime";
337
275
  function ToolGroup(props) {
338
276
  const {
339
277
  reasoning,
@@ -351,29 +289,29 @@ function ToolGroup(props) {
351
289
  }, [running]);
352
290
  if (!reasoning && steps.length === 0) return null;
353
291
  const summary = running ? workingLabel : steps.length ? summarizeSteps(steps) : thoughtLabel;
354
- return /* @__PURE__ */ jsxs2("div", { className: "wbx-acts" + (open ? " open" : ""), children: [
355
- /* @__PURE__ */ jsxs2("button", { className: "wbx-acts-sum", onClick: () => setOpen((v) => !v), children: [
356
- /* @__PURE__ */ jsx2(Chevron, { dir: open ? "down" : "right", size: 13 }),
357
- /* @__PURE__ */ jsx2("span", { children: summary })
292
+ return /* @__PURE__ */ jsxs("div", { className: "wbx-acts" + (open ? " open" : ""), children: [
293
+ /* @__PURE__ */ jsxs("button", { className: "wbx-acts-sum", onClick: () => setOpen((v) => !v), children: [
294
+ /* @__PURE__ */ jsx(Chevron, { dir: open ? "down" : "right", size: 13 }),
295
+ /* @__PURE__ */ jsx("span", { children: summary })
358
296
  ] }),
359
- open && /* @__PURE__ */ jsxs2("div", { className: "wbx-acts-body", children: [
360
- reasoning && /* @__PURE__ */ jsxs2("div", { className: "wbx-act", children: [
361
- /* @__PURE__ */ jsx2("span", { className: "wbx-act-ic-t thinking", children: /* @__PURE__ */ jsx2(IcThink, {}) }),
362
- /* @__PURE__ */ jsxs2("div", { className: "wbx-act-main", children: [
363
- /* @__PURE__ */ jsx2("div", { className: "wbx-act-k", children: thinkingLabel }),
364
- /* @__PURE__ */ jsx2("div", { className: "wbx-act-v", children: reasoning })
297
+ open && /* @__PURE__ */ jsxs("div", { className: "wbx-acts-body", children: [
298
+ reasoning && /* @__PURE__ */ jsxs("div", { className: "wbx-act", children: [
299
+ /* @__PURE__ */ jsx("span", { className: "wbx-act-ic-t thinking", children: /* @__PURE__ */ jsx(IcThink, {}) }),
300
+ /* @__PURE__ */ jsxs("div", { className: "wbx-act-main", children: [
301
+ /* @__PURE__ */ jsx("div", { className: "wbx-act-k", children: thinkingLabel }),
302
+ /* @__PURE__ */ jsx("div", { className: "wbx-act-v", children: reasoning })
365
303
  ] })
366
304
  ] }),
367
305
  steps.map((s, j) => {
368
306
  if (renderStep) {
369
307
  const el = renderStep(s, j);
370
- if (el !== void 0) return /* @__PURE__ */ jsx2(React2.Fragment, { children: el }, j);
308
+ if (el !== void 0) return /* @__PURE__ */ jsx(React.Fragment, { children: el }, j);
371
309
  }
372
- return /* @__PURE__ */ jsx2(ToolRow, { step: s }, j);
310
+ return /* @__PURE__ */ jsx(ToolRow, { step: s }, j);
373
311
  }),
374
- !running && /* @__PURE__ */ jsxs2("div", { className: "wbx-act", children: [
375
- /* @__PURE__ */ jsx2("span", { className: "wbx-act-ic-t done", children: /* @__PURE__ */ jsx2(IcCheck, {}) }),
376
- /* @__PURE__ */ jsx2("div", { className: "wbx-act-main", children: /* @__PURE__ */ jsx2("div", { className: "wbx-act-k", children: doneLabel }) })
312
+ !running && /* @__PURE__ */ jsxs("div", { className: "wbx-act", children: [
313
+ /* @__PURE__ */ jsx("span", { className: "wbx-act-ic-t done", children: /* @__PURE__ */ jsx(IcCheck, {}) }),
314
+ /* @__PURE__ */ jsx("div", { className: "wbx-act-main", children: /* @__PURE__ */ jsx("div", { className: "wbx-act-k", children: doneLabel }) })
377
315
  ] })
378
316
  ] })
379
317
  ] });
@@ -384,22 +322,22 @@ function ToolRow(props) {
384
322
  const meta = toolMeta(step.name, step.args);
385
323
  const Icon = meta.Icon;
386
324
  const hasDetail = !!(step.args && step.args !== "{}") || step.result !== void 0;
387
- return /* @__PURE__ */ jsxs2("div", { className: "wbx-act", children: [
388
- /* @__PURE__ */ jsx2("span", { className: "wbx-act-ic-t", children: /* @__PURE__ */ jsx2(Icon, {}) }),
389
- /* @__PURE__ */ jsxs2("div", { className: "wbx-act-main", children: [
390
- /* @__PURE__ */ jsxs2("button", { className: "wbx-act-row" + (open ? " open" : ""), disabled: !hasDetail, onClick: () => setOpen((v) => !v), children: [
391
- /* @__PURE__ */ jsx2("span", { className: "wbx-act-k", children: meta.label }),
392
- meta.chip && /* @__PURE__ */ jsx2("span", { className: "wbx-act-chip", children: meta.chip }),
393
- hasDetail && /* @__PURE__ */ jsx2("span", { className: "wbx-act-exp", children: /* @__PURE__ */ jsx2(Chevron, { dir: open ? "down" : "right", size: 12 }) })
325
+ return /* @__PURE__ */ jsxs("div", { className: "wbx-act", children: [
326
+ /* @__PURE__ */ jsx("span", { className: "wbx-act-ic-t", children: /* @__PURE__ */ jsx(Icon, {}) }),
327
+ /* @__PURE__ */ jsxs("div", { className: "wbx-act-main", children: [
328
+ /* @__PURE__ */ jsxs("button", { className: "wbx-act-row" + (open ? " open" : ""), disabled: !hasDetail, onClick: () => setOpen((v) => !v), children: [
329
+ /* @__PURE__ */ jsx("span", { className: "wbx-act-k", children: meta.label }),
330
+ meta.chip && /* @__PURE__ */ jsx("span", { className: "wbx-act-chip", children: meta.chip }),
331
+ hasDetail && /* @__PURE__ */ jsx("span", { className: "wbx-act-exp", children: /* @__PURE__ */ jsx(Chevron, { dir: open ? "down" : "right", size: 12 }) })
394
332
  ] }),
395
- open && /* @__PURE__ */ jsxs2("div", { className: "wbx-act-detail", children: [
396
- step.args && step.args !== "{}" && /* @__PURE__ */ jsxs2("div", { className: "wbx-act-block", children: [
397
- /* @__PURE__ */ jsx2("div", { className: "wbx-act-block-h", children: requestLabel }),
398
- /* @__PURE__ */ jsx2("pre", { className: "wbx-act-pre", children: prettyJson(step.args) })
333
+ open && /* @__PURE__ */ jsxs("div", { className: "wbx-act-detail", children: [
334
+ step.args && step.args !== "{}" && /* @__PURE__ */ jsxs("div", { className: "wbx-act-block", children: [
335
+ /* @__PURE__ */ jsx("div", { className: "wbx-act-block-h", children: requestLabel }),
336
+ /* @__PURE__ */ jsx("pre", { className: "wbx-act-pre", children: prettyJson(step.args) })
399
337
  ] }),
400
- step.result !== void 0 && /* @__PURE__ */ jsxs2("div", { className: "wbx-act-block", children: [
401
- /* @__PURE__ */ jsx2("div", { className: "wbx-act-block-h", children: resultLabel }),
402
- /* @__PURE__ */ jsx2("pre", { className: "wbx-act-pre", children: String(step.result).slice(0, 4e3) })
338
+ step.result !== void 0 && /* @__PURE__ */ jsxs("div", { className: "wbx-act-block", children: [
339
+ /* @__PURE__ */ jsx("div", { className: "wbx-act-block-h", children: resultLabel }),
340
+ /* @__PURE__ */ jsx("pre", { className: "wbx-act-pre", children: String(step.result).slice(0, 4e3) })
403
341
  ] })
404
342
  ] })
405
343
  ] })
@@ -407,23 +345,30 @@ function ToolRow(props) {
407
345
  }
408
346
 
409
347
  // src/components/ChatMessages.jsx
410
- import React3 from "react";
411
- import { Fragment, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
348
+ import React2 from "react";
349
+ import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
412
350
  var DEFAULT_STATUS_LABELS = {
413
- failed: "\u2715 Failed \u2014 see the output above for the reason",
351
+ failed: "\u2715 Failed. See the output above for the reason",
414
352
  cancelled: "\u25FC Stopped by you",
415
- incomplete: "\u25D4 Hit its step or time limit \u2014 Continue to resume"
353
+ // Claims only what is true of every cause: an incomplete turn may have hit its step or time
354
+ // budget, or been cut mid-flight (a replica restart under a live turn settles as incomplete).
355
+ // Asserting "step or time limit" for all of them sent an operator debugging a limit that was
356
+ // never reached. A host that knows the actual cause says so in its own chrome (statusLabels /
357
+ // assistantFooter).
358
+ incomplete: "\u25D4 Stopped before finishing. Continue to resume"
416
359
  };
417
- var defaultMarkdown = (text) => /* @__PURE__ */ jsx3("div", { style: { whiteSpace: "pre-wrap" }, children: text });
360
+ var defaultMarkdown = (text) => /* @__PURE__ */ jsx2("div", { style: { whiteSpace: "pre-wrap" }, children: text });
361
+ var REDUCED_MOTION = typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
418
362
  var REVEAL_SEC = 3;
419
363
  var MIN_CPS = 10;
420
364
  function TypewriterText(props) {
421
- const { text, active, render } = props;
422
- const [n, setN] = React3.useState(() => text ? text.length : 0);
423
- const textRef = React3.useRef(text);
365
+ const { text, render } = props;
366
+ const active = props.active && !REDUCED_MOTION;
367
+ const [n, setN] = React2.useState(() => text ? text.length : 0);
368
+ const textRef = React2.useRef(text);
424
369
  textRef.current = text;
425
- const accRef = React3.useRef(text ? text.length : 0);
426
- React3.useEffect(() => {
370
+ const accRef = React2.useRef(text ? text.length : 0);
371
+ React2.useEffect(() => {
427
372
  if (!active) {
428
373
  setN(textRef.current ? textRef.current.length : 0);
429
374
  return void 0;
@@ -450,11 +395,15 @@ function TypewriterText(props) {
450
395
  return render(shown);
451
396
  }
452
397
  function UserTurn(props) {
453
- const { msg, children } = props;
454
- return /* @__PURE__ */ jsx3("div", { className: "wbx-turn user", children: /* @__PURE__ */ jsxs3("div", { className: "wbx-bubble-user", children: [
398
+ const { msg, children, label } = props;
399
+ const bubble = /* @__PURE__ */ jsxs2("div", { className: "wbx-bubble-user", children: [
455
400
  children,
456
- msg.text && /* @__PURE__ */ jsx3("div", { className: "wbx-bubble-text", children: msg.text })
457
- ] }) });
401
+ msg.text && /* @__PURE__ */ jsx2("div", { className: "wbx-bubble-text", children: msg.text })
402
+ ] });
403
+ return /* @__PURE__ */ jsx2("div", { className: "wbx-turn user", children: label ? /* @__PURE__ */ jsxs2("div", { className: "wbx-turn-body", children: [
404
+ /* @__PURE__ */ jsx2("div", { className: "wbx-role", children: label }),
405
+ bubble
406
+ ] }) : bubble });
458
407
  }
459
408
  function AssistantTurn(props) {
460
409
  const {
@@ -465,10 +414,12 @@ function AssistantTurn(props) {
465
414
  statusLabels = DEFAULT_STATUS_LABELS,
466
415
  renderStep,
467
416
  toolLabels,
468
- footer
417
+ footer,
418
+ label
469
419
  } = props;
470
- return /* @__PURE__ */ jsxs3("div", { className: "wbx-turn asst", children: [
471
- msg.blocks.map((b, bi) => b.kind === "tools" ? /* @__PURE__ */ jsx3(
420
+ return /* @__PURE__ */ jsxs2("div", { className: "wbx-turn asst", children: [
421
+ label ? /* @__PURE__ */ jsx2("div", { className: "wbx-role", children: label }) : null,
422
+ msg.blocks.map((b, bi) => b.kind === "tools" ? /* @__PURE__ */ jsx2(
472
423
  ToolGroup,
473
424
  {
474
425
  reasoning: b.reasoning,
@@ -478,7 +429,7 @@ function AssistantTurn(props) {
478
429
  ...toolLabels || {}
479
430
  },
480
431
  bi
481
- ) : /* @__PURE__ */ jsx3("div", { className: "wbx-md", children: /* @__PURE__ */ jsx3(
432
+ ) : /* @__PURE__ */ jsx2("div", { className: "wbx-md", children: /* @__PURE__ */ jsx2(
482
433
  TypewriterText,
483
434
  {
484
435
  text: b.text,
@@ -486,16 +437,16 @@ function AssistantTurn(props) {
486
437
  active: msg.status === "running" && bi === msg.blocks.length - 1
487
438
  }
488
439
  ) }, bi)),
489
- msg.status === "running" && /* @__PURE__ */ jsxs3("div", { className: "wbx-working", "aria-label": "Working", children: [
490
- /* @__PURE__ */ jsxs3("span", { className: "wbx-working-dots", children: [
491
- /* @__PURE__ */ jsx3("span", {}),
492
- /* @__PURE__ */ jsx3("span", {}),
493
- /* @__PURE__ */ jsx3("span", {})
440
+ msg.status === "running" && /* @__PURE__ */ jsxs2("div", { className: "wbx-working", "aria-label": "Working", children: [
441
+ /* @__PURE__ */ jsxs2("span", { className: "wbx-working-dots", children: [
442
+ /* @__PURE__ */ jsx2("span", {}),
443
+ /* @__PURE__ */ jsx2("span", {}),
444
+ /* @__PURE__ */ jsx2("span", {})
494
445
  ] }),
495
- /* @__PURE__ */ jsx3("span", { className: "wbx-working-txt", children: workingLabel }),
446
+ /* @__PURE__ */ jsx2("span", { className: "wbx-working-txt", children: workingLabel }),
496
447
  workingExtra
497
448
  ] }),
498
- (msg.status === "failed" || msg.status === "cancelled" || msg.status === "incomplete") && /* @__PURE__ */ jsx3("div", { className: "wbx-turnbadge " + msg.status, role: "status", children: statusLabels[msg.status] }),
449
+ (msg.status === "failed" || msg.status === "cancelled" || msg.status === "incomplete") && /* @__PURE__ */ jsx2("div", { className: "wbx-turnbadge " + msg.status, role: "status", children: statusLabels[msg.status] }),
499
450
  footer
500
451
  ] });
501
452
  }
@@ -507,7 +458,7 @@ var DEFAULT_SKELETON_TURNS = [
507
458
  ];
508
459
  function ChatMessagesSkeleton(props) {
509
460
  const turns = props && props.turns || DEFAULT_SKELETON_TURNS;
510
- return /* @__PURE__ */ jsx3("div", { className: "wbx-skel", "aria-busy": "true", "aria-label": "Loading conversation", children: turns.map((t, i) => t.role === "user" ? /* @__PURE__ */ jsx3("div", { className: "wbx-turn user wbx-skel-turn", "aria-hidden": "true", children: /* @__PURE__ */ jsx3("div", { className: "wbx-bubble-user wbx-skel-lines", style: { width: t.width }, children: t.lines.map((w, j) => /* @__PURE__ */ jsx3("span", { className: "wbx-skel-bar", style: { width: w } }, j)) }) }, i) : /* @__PURE__ */ jsx3("div", { className: "wbx-turn asst wbx-skel-turn", "aria-hidden": "true", children: /* @__PURE__ */ jsx3("div", { className: "wbx-md wbx-skel-lines", children: t.lines.map((w, j) => /* @__PURE__ */ jsx3("span", { className: "wbx-skel-bar", style: { width: w } }, j)) }) }, i)) });
461
+ return /* @__PURE__ */ jsx2("div", { className: "wbx-skel", "aria-busy": "true", "aria-label": "Loading conversation", children: turns.map((t, i) => t.role === "user" ? /* @__PURE__ */ jsx2("div", { className: "wbx-turn user wbx-skel-turn", "aria-hidden": "true", children: /* @__PURE__ */ jsx2("div", { className: "wbx-bubble-user wbx-skel-lines", style: { width: t.width }, children: t.lines.map((w, j) => /* @__PURE__ */ jsx2("span", { className: "wbx-skel-bar", style: { width: w } }, j)) }) }, i) : /* @__PURE__ */ jsx2("div", { className: "wbx-turn asst wbx-skel-turn", "aria-hidden": "true", children: /* @__PURE__ */ jsx2("div", { className: "wbx-md wbx-skel-lines", children: t.lines.map((w, j) => /* @__PURE__ */ jsx2("span", { className: "wbx-skel-bar", style: { width: w } }, j)) }) }, i)) });
511
462
  }
512
463
  function ChatMessages(props) {
513
464
  const {
@@ -520,14 +471,15 @@ function ChatMessages(props) {
520
471
  statusLabels,
521
472
  renderStep,
522
473
  workingLabel,
523
- toolLabels
474
+ toolLabels,
475
+ roleLabel
524
476
  } = props;
525
- return /* @__PURE__ */ jsx3(Fragment, { children: messages.map((m, i) => {
477
+ return /* @__PURE__ */ jsx2(Fragment, { children: messages.map((m, i) => {
526
478
  if (renderMessage) {
527
479
  const el = renderMessage(m, i);
528
- if (el !== void 0) return /* @__PURE__ */ jsx3(React3.Fragment, { children: el }, i);
480
+ if (el !== void 0) return /* @__PURE__ */ jsx2(React2.Fragment, { children: el }, i);
529
481
  }
530
- return m.role === "user" ? /* @__PURE__ */ jsx3(UserTurn, { msg: m, children: userExtras?.(m, i) }, i) : /* @__PURE__ */ jsx3(
482
+ return m.role === "user" ? /* @__PURE__ */ jsx2(UserTurn, { msg: m, label: roleLabel?.(m, i), children: userExtras?.(m, i) }, i) : /* @__PURE__ */ jsx2(
531
483
  AssistantTurn,
532
484
  {
533
485
  msg: m,
@@ -537,6 +489,7 @@ function ChatMessages(props) {
537
489
  statusLabels,
538
490
  renderStep,
539
491
  toolLabels,
492
+ label: roleLabel?.(m, i),
540
493
  footer: assistantFooter?.(m, i)
541
494
  },
542
495
  i
@@ -545,8 +498,8 @@ function ChatMessages(props) {
545
498
  }
546
499
 
547
500
  // src/components/Composer.jsx
548
- import React4, { useEffect as useEffect2, useRef } from "react";
549
- import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
501
+ import React3, { useEffect as useEffect2, useRef, useState as useState2 } from "react";
502
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
550
503
  function Composer(props) {
551
504
  const {
552
505
  value,
@@ -557,6 +510,7 @@ function Composer(props) {
557
510
  placeholder,
558
511
  rows = 1,
559
512
  autoGrow = true,
513
+ inline = false,
560
514
  maxRows = 15,
561
515
  autoFocus,
562
516
  // The composer on a landing page often has an ANIMATING placeholder (a typewriter cycling
@@ -564,6 +518,9 @@ function Composer(props) {
564
518
  // one is given — so the field announces a different name every few seconds.
565
519
  inputAriaLabel,
566
520
  attachments,
521
+ tray,
522
+ onFiles,
523
+ dropTargetRef,
567
524
  accessoriesLeft,
568
525
  accessoriesRight,
569
526
  renderSend,
@@ -572,6 +529,50 @@ function Composer(props) {
572
529
  } = props;
573
530
  const ownRef = useRef(null);
574
531
  const taRef = inputRef || ownRef;
532
+ const rootRef = useRef(null);
533
+ const [dropping, setDropping] = useState2(false);
534
+ useEffect2(() => {
535
+ if (!onFiles || disabled) return void 0;
536
+ const el = dropTargetRef && dropTargetRef.current || rootRef.current;
537
+ if (!el) return void 0;
538
+ let depth = 0;
539
+ const hasFiles = (e) => Array.from(e.dataTransfer && e.dataTransfer.types || []).includes("Files");
540
+ const enter = (e) => {
541
+ if (!hasFiles(e)) return;
542
+ e.preventDefault();
543
+ depth += 1;
544
+ setDropping(true);
545
+ };
546
+ const over = (e) => {
547
+ if (!hasFiles(e)) return;
548
+ e.preventDefault();
549
+ e.dataTransfer.dropEffect = "copy";
550
+ };
551
+ const leave = (e) => {
552
+ if (!hasFiles(e)) return;
553
+ e.preventDefault();
554
+ depth = Math.max(0, depth - 1);
555
+ if (depth === 0) setDropping(false);
556
+ };
557
+ const drop = (e) => {
558
+ if (!hasFiles(e)) return;
559
+ e.preventDefault();
560
+ depth = 0;
561
+ setDropping(false);
562
+ if (e.dataTransfer.files && e.dataTransfer.files.length) onFiles(e.dataTransfer.files);
563
+ };
564
+ el.addEventListener("dragenter", enter);
565
+ el.addEventListener("dragover", over);
566
+ el.addEventListener("dragleave", leave);
567
+ el.addEventListener("drop", drop);
568
+ return () => {
569
+ el.removeEventListener("dragenter", enter);
570
+ el.removeEventListener("dragover", over);
571
+ el.removeEventListener("dragleave", leave);
572
+ el.removeEventListener("drop", drop);
573
+ };
574
+ }, [onFiles, disabled, dropTargetRef]);
575
+ const rootClass = (classNames.root ?? "wbx-composer") + (dropping ? " is-dropping" : "");
575
576
  useEffect2(() => {
576
577
  if (!autoGrow) return;
577
578
  const el = taRef.current;
@@ -583,9 +584,41 @@ function Composer(props) {
583
584
  el.style.height = Math.min(el.scrollHeight, max) + "px";
584
585
  el.style.overflowY = el.scrollHeight > max ? "auto" : "hidden";
585
586
  }, [value, autoGrow, maxRows, taRef]);
586
- return /* @__PURE__ */ jsxs4("div", { className: classNames.root ?? "wbx-composer", children: [
587
+ const sendEl = renderSend ? renderSend() : /* @__PURE__ */ jsx3("button", { type: "button", className: "uic-send", disabled: sendDisabled, onClick: () => onSend(), "aria-label": "Send message", children: /* @__PURE__ */ jsx3(IcSend, {}) });
588
+ if (inline) {
589
+ return /* @__PURE__ */ jsxs3("div", { ref: rootRef, className: rootClass, children: [
590
+ attachments,
591
+ /* @__PURE__ */ jsxs3("div", { className: "uic-composer-line", children: [
592
+ accessoriesLeft,
593
+ /* @__PURE__ */ jsx3(
594
+ "textarea",
595
+ {
596
+ ref: taRef,
597
+ className: classNames.input ?? "wbx-composer-input",
598
+ rows,
599
+ value,
600
+ placeholder,
601
+ "aria-label": inputAriaLabel || placeholder,
602
+ disabled,
603
+ autoFocus,
604
+ onChange: (e) => onChange(e.target.value),
605
+ onKeyDown: (e) => {
606
+ if (e.key === "Enter" && !e.shiftKey) {
607
+ e.preventDefault();
608
+ onSend();
609
+ }
610
+ }
611
+ }
612
+ ),
613
+ accessoriesRight,
614
+ sendEl
615
+ ] }),
616
+ tray ? /* @__PURE__ */ jsx3("div", { className: "uic-composer-tray", children: tray }) : null
617
+ ] });
618
+ }
619
+ return /* @__PURE__ */ jsxs3("div", { ref: rootRef, className: rootClass, children: [
587
620
  attachments,
588
- /* @__PURE__ */ jsx4(
621
+ /* @__PURE__ */ jsx3(
589
622
  "textarea",
590
623
  {
591
624
  ref: taRef,
@@ -604,47 +637,70 @@ function Composer(props) {
604
637
  }
605
638
  }
606
639
  ),
607
- /* @__PURE__ */ jsxs4("div", { className: classNames.row ?? "wbx-composer-row", children: [
640
+ /* @__PURE__ */ jsxs3("div", { className: classNames.row ?? "wbx-composer-row", children: [
608
641
  accessoriesLeft,
609
- /* @__PURE__ */ jsx4("span", { style: { flex: 1 } }),
642
+ /* @__PURE__ */ jsx3("span", { style: { flex: 1 } }),
610
643
  accessoriesRight,
611
- renderSend ? renderSend() : /* @__PURE__ */ jsx4("button", { type: "button", className: "uic-send", disabled: sendDisabled, onClick: () => onSend(), "aria-label": "Send message", children: /* @__PURE__ */ jsx4(IcSend, {}) })
612
- ] })
644
+ renderSend ? renderSend() : /* @__PURE__ */ jsx3("button", { type: "button", className: "uic-send", disabled: sendDisabled, onClick: () => onSend(), "aria-label": "Send message", children: /* @__PURE__ */ jsx3(IcSend, {}) })
645
+ ] }),
646
+ tray ? /* @__PURE__ */ jsx3("div", { className: "uic-composer-tray", children: tray }) : null
613
647
  ] });
614
648
  }
615
649
 
616
650
  // src/components/ChatPanel.jsx
617
- import React6, { useCallback, useEffect as useEffect3, useRef as useRef2, useState as useState2 } from "react";
651
+ import React5, { useCallback, useEffect as useEffect3, useRef as useRef2, useState as useState3 } from "react";
618
652
 
619
653
  // src/components/Chip.jsx
620
- import React5 from "react";
621
- import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
622
- function Chip(props) {
623
- const { label, icon, title, selected = false, onClick, onRemove, removeLabel, className } = props;
654
+ import React4, { forwardRef } from "react";
655
+ import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
656
+ var Chip = forwardRef(function Chip2(props, ref) {
657
+ const {
658
+ label,
659
+ icon,
660
+ title,
661
+ selected = false,
662
+ onClick,
663
+ onRemove,
664
+ removeLabel,
665
+ trailing,
666
+ className,
667
+ slot,
668
+ ...rest
669
+ } = props;
670
+ const isSlot = slot ?? (Boolean(onClick) && !selected);
624
671
  const cls = [
625
672
  "uic-chip",
626
673
  selected ? "is-selected" : "",
627
- onClick && !selected ? "is-open" : "",
674
+ isSlot ? "is-open" : "",
628
675
  className || ""
629
676
  ].filter(Boolean).join(" ");
630
- const body = /* @__PURE__ */ jsxs5(Fragment2, { children: [
631
- icon ? /* @__PURE__ */ jsx5("span", { className: "uic-chip-ic", "aria-hidden": "true", children: icon }) : null,
632
- /* @__PURE__ */ jsx5("span", { className: "uic-chip-l", children: label })
677
+ const body = /* @__PURE__ */ jsxs4(Fragment2, { children: [
678
+ icon ? /* @__PURE__ */ jsx4("span", { className: "uic-chip-ic", "aria-hidden": "true", children: icon }) : null,
679
+ /* @__PURE__ */ jsx4("span", { className: "uic-chip-l", children: label })
633
680
  ] });
681
+ const trail = trailing ? /* @__PURE__ */ jsx4("span", { className: "uic-chip-tr", children: trailing }) : null;
634
682
  if (onClick && onRemove) {
635
- return /* @__PURE__ */ jsxs5("span", { className: cls, title, children: [
636
- /* @__PURE__ */ jsx5("button", { type: "button", className: "uic-chip-press", onClick, children: body }),
637
- /* @__PURE__ */ jsx5("button", { type: "button", className: "uic-chip-x", "aria-label": removeLabel, onClick: onRemove, children: /* @__PURE__ */ jsx5(IcX, { size: 12 }) })
683
+ return /* @__PURE__ */ jsxs4("span", { ref, className: cls, title, children: [
684
+ /* @__PURE__ */ jsx4("button", { type: "button", className: "uic-chip-press", onClick, ...rest, children: body }),
685
+ trail,
686
+ /* @__PURE__ */ jsx4("button", { type: "button", className: "uic-chip-x", "aria-label": removeLabel, onClick: onRemove, children: /* @__PURE__ */ jsx4(IcX, { size: 12 }) })
638
687
  ] });
639
688
  }
640
689
  if (onClick) {
641
- return /* @__PURE__ */ jsx5("button", { type: "button", className: cls, title, onClick, children: body });
690
+ if (trailing) {
691
+ return /* @__PURE__ */ jsxs4("span", { ref, className: cls, title, children: [
692
+ /* @__PURE__ */ jsx4("button", { type: "button", className: "uic-chip-press", onClick, ...rest, children: body }),
693
+ trail
694
+ ] });
695
+ }
696
+ return /* @__PURE__ */ jsx4("button", { ref, type: "button", className: cls, title, onClick, ...rest, children: body });
642
697
  }
643
- return /* @__PURE__ */ jsxs5("span", { className: cls, title, children: [
698
+ return /* @__PURE__ */ jsxs4("span", { ref, className: cls, title, ...rest, children: [
644
699
  body,
645
- onRemove ? /* @__PURE__ */ jsx5("button", { type: "button", className: "uic-chip-x", "aria-label": removeLabel, onClick: onRemove, children: /* @__PURE__ */ jsx5(IcX, { size: 12 }) }) : null
700
+ trail,
701
+ onRemove ? /* @__PURE__ */ jsx4("button", { type: "button", className: "uic-chip-x", "aria-label": removeLabel, onClick: onRemove, children: /* @__PURE__ */ jsx4(IcX, { size: 12 }) }) : null
646
702
  ] });
647
- }
703
+ });
648
704
 
649
705
  // src/format.js
650
706
  function bytesLabel(n) {
@@ -655,7 +711,7 @@ function bytesLabel(n) {
655
711
  }
656
712
 
657
713
  // src/components/ChatPanel.jsx
658
- import { Fragment as Fragment3, jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
714
+ import { Fragment as Fragment3, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
659
715
  var POLL_MS = 3e3;
660
716
  var RETRY_MS = 2e4;
661
717
  var PIN_PX = 80;
@@ -693,14 +749,14 @@ function ChatPanel(props) {
693
749
  toolLabels,
694
750
  classNames = {}
695
751
  } = props;
696
- const [messages, setMessages] = useState2([]);
697
- const [draft, setDraft] = useState2("");
698
- const [busy, setBusy] = useState2(false);
699
- const [connecting, setConnecting] = useState2(false);
700
- const [histLoading, setHistLoading] = useState2(true);
701
- const [staged, setStaged] = useState2([]);
702
- const [attachErr, setAttachErr] = useState2("");
703
- const [listening2, setListening] = useState2(false);
752
+ const [messages, setMessages] = useState3([]);
753
+ const [draft, setDraft] = useState3("");
754
+ const [busy, setBusy] = useState3(false);
755
+ const [connecting, setConnecting] = useState3(false);
756
+ const [histLoading, setHistLoading] = useState3(true);
757
+ const [staged, setStaged] = useState3([]);
758
+ const [attachErr, setAttachErr] = useState3("");
759
+ const [listening, setListening] = useState3(false);
704
760
  const pendingRef = useRef2(null);
705
761
  const seededRef = useRef2(false);
706
762
  const adoptedRef = useRef2(null);
@@ -783,7 +839,7 @@ function ChatPanel(props) {
783
839
  function send() {
784
840
  const t = draft.trim();
785
841
  if (!t || sendBlocked) return;
786
- if (listening2) {
842
+ if (listening) {
787
843
  dictation?.stop();
788
844
  setListening(false);
789
845
  }
@@ -869,7 +925,7 @@ function ChatPanel(props) {
869
925
  }
870
926
  function toggleDictation() {
871
927
  if (!dictation) return;
872
- if (listening2) {
928
+ if (listening) {
873
929
  dictation.stop();
874
930
  setListening(false);
875
931
  return;
@@ -882,7 +938,7 @@ function ChatPanel(props) {
882
938
  });
883
939
  }
884
940
  const rootCls = ["uic-chat", collapsed ? "is-collapsed" : "", classNames.root || ""].filter(Boolean).join(" ");
885
- const toggle = onToggleCollapse ? /* @__PURE__ */ jsx6(
941
+ const toggle = onToggleCollapse ? /* @__PURE__ */ jsx5(
886
942
  "button",
887
943
  {
888
944
  type: "button",
@@ -891,15 +947,15 @@ function ChatPanel(props) {
891
947
  title: collapsed ? "Show the conversation" : "Hide the conversation",
892
948
  "aria-label": collapsed ? "Show the conversation" : "Hide the conversation",
893
949
  "aria-expanded": !collapsed,
894
- children: /* @__PURE__ */ jsx6(IcPanelRight, {})
950
+ children: /* @__PURE__ */ jsx5(IcPanelRight, {})
895
951
  }
896
952
  ) : null;
897
953
  if (collapsed) {
898
- return /* @__PURE__ */ jsx6("aside", { className: rootCls, children: /* @__PURE__ */ jsx6("div", { className: "uic-chat-h", children: toggle }) });
954
+ return /* @__PURE__ */ jsx5("aside", { className: rootCls, children: /* @__PURE__ */ jsx5("div", { className: "uic-chat-h", children: toggle }) });
899
955
  }
900
956
  const empty = messages.length === 0;
901
- const attachControl = attachments ? /* @__PURE__ */ jsxs6(Fragment3, { children: [
902
- /* @__PURE__ */ jsx6(
957
+ const attachControl = attachments ? /* @__PURE__ */ jsxs5(Fragment3, { children: [
958
+ /* @__PURE__ */ jsx5(
903
959
  "input",
904
960
  {
905
961
  ref: fileRef,
@@ -913,7 +969,7 @@ function ChatPanel(props) {
913
969
  }
914
970
  }
915
971
  ),
916
- /* @__PURE__ */ jsx6(
972
+ /* @__PURE__ */ jsx5(
917
973
  "button",
918
974
  {
919
975
  type: "button",
@@ -921,35 +977,35 @@ function ChatPanel(props) {
921
977
  "aria-label": "Attach a file",
922
978
  disabled: busy,
923
979
  onClick: () => fileRef.current?.click(),
924
- children: /* @__PURE__ */ jsx6(IcPaperclip, {})
980
+ children: /* @__PURE__ */ jsx5(IcPaperclip, {})
925
981
  }
926
982
  )
927
983
  ] }) : null;
928
- const micControl = dictation ? /* @__PURE__ */ jsx6(
984
+ const micControl = dictation ? /* @__PURE__ */ jsx5(
929
985
  "button",
930
986
  {
931
987
  type: "button",
932
- className: "uic-chat-icon" + (listening2 ? " is-on" : ""),
933
- "aria-label": listening2 ? "Stop dictating" : "Dictate",
934
- "aria-pressed": listening2,
988
+ className: "uic-chat-icon" + (listening ? " is-on" : ""),
989
+ "aria-label": listening ? "Stop dictating" : "Dictate",
990
+ "aria-pressed": listening,
935
991
  disabled: busy,
936
992
  onClick: toggleDictation,
937
- children: /* @__PURE__ */ jsx6(IcMic, {})
993
+ children: /* @__PURE__ */ jsx5(IcMic, {})
938
994
  }
939
995
  ) : null;
940
- const defaultBusyState = /* @__PURE__ */ jsxs6("div", { className: "uic-chat-empty", children: [
941
- /* @__PURE__ */ jsx6("span", { className: "uic-chat-pulse", "aria-hidden": "true" }),
942
- /* @__PURE__ */ jsx6("div", { className: "uic-chat-empty-t", children: workingLabel })
996
+ const defaultBusyState = /* @__PURE__ */ jsxs5("div", { className: "uic-chat-empty", children: [
997
+ /* @__PURE__ */ jsx5("span", { className: "uic-chat-pulse", "aria-hidden": "true" }),
998
+ /* @__PURE__ */ jsx5("div", { className: "uic-chat-empty-t", children: workingLabel })
943
999
  ] });
944
- return /* @__PURE__ */ jsxs6("aside", { className: rootCls, style: width ? { flex: `0 0 ${width}px` } : void 0, children: [
945
- /* @__PURE__ */ jsxs6("div", { className: "uic-chat-h", children: [
1000
+ return /* @__PURE__ */ jsxs5("aside", { className: rootCls, style: width ? { flex: `0 0 ${width}px` } : void 0, children: [
1001
+ /* @__PURE__ */ jsxs5("div", { className: "uic-chat-h", children: [
946
1002
  toggle,
947
- title ? /* @__PURE__ */ jsx6("span", { className: "uic-chat-title", title, children: title }) : null,
1003
+ title ? /* @__PURE__ */ jsx5("span", { className: "uic-chat-title", title, children: title }) : null,
948
1004
  headerRight,
949
- connecting ? /* @__PURE__ */ jsx6("span", { className: "uic-chat-conn", children: connectingLabel }) : null
1005
+ connecting ? /* @__PURE__ */ jsx5("span", { className: "uic-chat-conn", children: connectingLabel }) : null
950
1006
  ] }),
951
- /* @__PURE__ */ jsxs6("div", { className: "uic-chat-body", ref: bodyRef, onScroll: onBodyScroll, role: "log", "aria-live": "polite", children: [
952
- histLoading ? /* @__PURE__ */ jsx6(ChatMessagesSkeleton, {}) : empty && externalBusy ? busyState === void 0 ? defaultBusyState : busyState : empty ? emptyState : /* @__PURE__ */ jsx6(
1007
+ /* @__PURE__ */ jsxs5("div", { className: "uic-chat-body", ref: bodyRef, onScroll: onBodyScroll, role: "log", "aria-live": "polite", children: [
1008
+ histLoading ? /* @__PURE__ */ jsx5(ChatMessagesSkeleton, {}) : empty && externalBusy ? busyState === void 0 ? defaultBusyState : busyState : empty ? emptyState : /* @__PURE__ */ jsx5(
953
1009
  ChatMessages,
954
1010
  {
955
1011
  messages,
@@ -958,19 +1014,19 @@ function ChatPanel(props) {
958
1014
  const own = userExtras?.(m, i);
959
1015
  if (own !== void 0) return own;
960
1016
  if (!m.files?.length) return void 0;
961
- return /* @__PURE__ */ jsx6("span", { className: "uic-chat-msg-files", children: m.files.map((n) => /* @__PURE__ */ jsx6(Chip, { icon: /* @__PURE__ */ jsx6(IcPaperclip, { size: 11 }), label: n, title: n }, n)) });
1017
+ return /* @__PURE__ */ jsx5("span", { className: "uic-chat-msg-files", children: m.files.map((n) => /* @__PURE__ */ jsx5(Chip, { icon: /* @__PURE__ */ jsx5(IcPaperclip, { size: 11 }), label: n, title: n }, n)) });
962
1018
  },
963
1019
  workingLabel,
964
1020
  toolLabels: { workingLabel, ...toolLabels || {} },
965
1021
  statusLabels
966
1022
  }
967
1023
  ),
968
- connecting ? /* @__PURE__ */ jsxs6("div", { className: "uic-chat-note", role: "status", children: [
969
- /* @__PURE__ */ jsx6("span", { className: "uic-chat-dot", "aria-hidden": "true" }),
1024
+ connecting ? /* @__PURE__ */ jsxs5("div", { className: "uic-chat-note", role: "status", children: [
1025
+ /* @__PURE__ */ jsx5("span", { className: "uic-chat-dot", "aria-hidden": "true" }),
970
1026
  connectingNote
971
1027
  ] }) : null
972
1028
  ] }),
973
- /* @__PURE__ */ jsx6(
1029
+ /* @__PURE__ */ jsx5(
974
1030
  Composer,
975
1031
  {
976
1032
  value: draft,
@@ -982,26 +1038,26 @@ function ChatPanel(props) {
982
1038
  rows: 2,
983
1039
  autoGrow: false,
984
1040
  classNames: { root: "uic-chat-cmp", input: "uic-chat-cmp-input", row: "uic-chat-cmp-row" },
985
- attachments: staged.length > 0 || attachErr ? /* @__PURE__ */ jsxs6("div", { className: "uic-chat-files", children: [
986
- staged.map((f, i) => /* @__PURE__ */ jsx6(
1041
+ attachments: staged.length > 0 || attachErr ? /* @__PURE__ */ jsxs5("div", { className: "uic-chat-files", children: [
1042
+ staged.map((f, i) => /* @__PURE__ */ jsx5(
987
1043
  Chip,
988
1044
  {
989
- icon: /* @__PURE__ */ jsx6(IcPaperclip, { size: 11 }),
1045
+ icon: /* @__PURE__ */ jsx5(IcPaperclip, { size: 11 }),
990
1046
  title: f.name,
991
- label: /* @__PURE__ */ jsxs6(Fragment3, { children: [
992
- /* @__PURE__ */ jsx6("span", { className: "uic-chip-t", children: f.name }),
993
- /* @__PURE__ */ jsx6("span", { className: "uic-chip-meta", children: f.pending ? "\u2026" : bytesLabel(f.size) })
1047
+ label: /* @__PURE__ */ jsxs5(Fragment3, { children: [
1048
+ /* @__PURE__ */ jsx5("span", { className: "uic-chip-t", children: f.name }),
1049
+ /* @__PURE__ */ jsx5("span", { className: "uic-chip-meta", children: f.pending ? "\u2026" : bytesLabel(f.size) })
994
1050
  ] }),
995
1051
  onRemove: () => setStaged((c) => c.filter((_, j) => j !== i)),
996
1052
  removeLabel: `Remove ${f.name}`
997
1053
  },
998
1054
  `${f.name}-${i}`
999
1055
  )),
1000
- attachErr ? /* @__PURE__ */ jsx6("span", { className: "uic-chat-file-err", children: attachErr }) : null
1056
+ attachErr ? /* @__PURE__ */ jsx5("span", { className: "uic-chat-file-err", children: attachErr }) : null
1001
1057
  ] }) : null,
1002
1058
  accessoriesLeft: attachControl,
1003
1059
  accessoriesRight: micControl,
1004
- renderSend: () => /* @__PURE__ */ jsx6(
1060
+ renderSend: () => /* @__PURE__ */ jsx5(
1005
1061
  "button",
1006
1062
  {
1007
1063
  type: "button",
@@ -1009,7 +1065,7 @@ function ChatPanel(props) {
1009
1065
  onClick: send,
1010
1066
  disabled: sendBlocked || !draft.trim(),
1011
1067
  "aria-label": "Send message",
1012
- children: /* @__PURE__ */ jsx6(IcSend, {})
1068
+ children: /* @__PURE__ */ jsx5(IcSend, {})
1013
1069
  }
1014
1070
  )
1015
1071
  }
@@ -1066,109 +1122,9 @@ function createDictation({ lang } = {}) {
1066
1122
  };
1067
1123
  }
1068
1124
 
1069
- // src/components/CodeBlock.jsx
1070
- import React7 from "react";
1071
- import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
1072
- var _hljsPromise = null;
1073
- function loadHljs() {
1074
- if (!_hljsPromise) {
1075
- _hljsPromise = import("highlight.js/lib/core").then((m) => m.default || m);
1076
- }
1077
- return _hljsPromise;
1078
- }
1079
- var GRAMMARS = {
1080
- javascript: () => import("highlight.js/lib/languages/javascript"),
1081
- typescript: () => import("highlight.js/lib/languages/typescript"),
1082
- python: () => import("highlight.js/lib/languages/python"),
1083
- json: () => import("highlight.js/lib/languages/json"),
1084
- bash: () => import("highlight.js/lib/languages/bash"),
1085
- sql: () => import("highlight.js/lib/languages/sql"),
1086
- java: () => import("highlight.js/lib/languages/java"),
1087
- go: () => import("highlight.js/lib/languages/go"),
1088
- rust: () => import("highlight.js/lib/languages/rust"),
1089
- xml: () => import("highlight.js/lib/languages/xml"),
1090
- css: () => import("highlight.js/lib/languages/css"),
1091
- yaml: () => import("highlight.js/lib/languages/yaml"),
1092
- groovy: () => import("highlight.js/lib/languages/groovy")
1093
- };
1094
- var ALIASES = {
1095
- js: "javascript",
1096
- jsx: "javascript",
1097
- mjs: "javascript",
1098
- cjs: "javascript",
1099
- node: "javascript",
1100
- ts: "typescript",
1101
- tsx: "typescript",
1102
- py: "python",
1103
- python3: "python",
1104
- sh: "bash",
1105
- shell: "bash",
1106
- zsh: "bash",
1107
- console: "bash",
1108
- html: "xml",
1109
- xhtml: "xml",
1110
- svg: "xml",
1111
- yml: "yaml",
1112
- golang: "go",
1113
- rs: "rust",
1114
- jsonc: "json",
1115
- postgres: "sql",
1116
- postgresql: "sql",
1117
- mysql: "sql",
1118
- plsql: "sql",
1119
- gremlin: "groovy"
1120
- };
1121
- function canonicalLang(tag) {
1122
- const t = String(tag || "").toLowerCase();
1123
- if (!t) return null;
1124
- const name = ALIASES[t] || t;
1125
- return GRAMMARS[name] ? name : null;
1126
- }
1127
- var _ready = /* @__PURE__ */ new Map();
1128
- function ensureLanguage(name) {
1129
- if (!_ready.has(name)) {
1130
- const p = Promise.all([loadHljs(), GRAMMARS[name]()]).then(([hljs, mod2]) => {
1131
- if (!hljs.getLanguage(name)) hljs.registerLanguage(name, mod2.default || mod2);
1132
- return hljs;
1133
- }).catch(() => null);
1134
- _ready.set(name, p);
1135
- }
1136
- return _ready.get(name);
1137
- }
1138
- function CodeBlock(props) {
1139
- const { code, language, className } = props;
1140
- const src = String(code || "");
1141
- const lang = canonicalLang(language);
1142
- const [hl, setHl] = React7.useState(null);
1143
- React7.useEffect(() => {
1144
- if (!lang || !src) return void 0;
1145
- let cancelled = false;
1146
- const timer = setTimeout(() => {
1147
- ensureLanguage(lang).then((hljs) => {
1148
- if (!hljs || cancelled) return;
1149
- try {
1150
- const out = hljs.highlight(src, { language: lang, ignoreIllegals: true });
1151
- if (!cancelled) setHl({ src, html: out.value });
1152
- } catch {
1153
- }
1154
- });
1155
- }, 200);
1156
- return () => {
1157
- cancelled = true;
1158
- clearTimeout(timer);
1159
- };
1160
- }, [src, lang]);
1161
- const html = hl && hl.src === src ? hl.html : null;
1162
- const label = String(language || "").toLowerCase();
1163
- return /* @__PURE__ */ jsxs7("pre", { className: "wbx-code" + (className ? " " + className : ""), children: [
1164
- label ? /* @__PURE__ */ jsx7("span", { className: "wbx-code-lang", "aria-hidden": "true", children: label }) : null,
1165
- html != null ? /* @__PURE__ */ jsx7("code", { className: "hljs language-" + label, dangerouslySetInnerHTML: { __html: html } }) : /* @__PURE__ */ jsx7("code", { className: label ? "language-" + label : void 0, children: src })
1166
- ] });
1167
- }
1168
-
1169
1125
  // src/components/resizable.jsx
1170
- import React8, { useCallback as useCallback2, useRef as useRef3, useState as useState3 } from "react";
1171
- import { jsx as jsx8 } from "react/jsx-runtime";
1126
+ import React6, { useCallback as useCallback2, useRef as useRef3, useState as useState4 } from "react";
1127
+ import { jsx as jsx6 } from "react/jsx-runtime";
1172
1128
  function useResizablePane(opts = {}) {
1173
1129
  const {
1174
1130
  initial = 380,
@@ -1178,16 +1134,22 @@ function useResizablePane(opts = {}) {
1178
1134
  maxFraction = null,
1179
1135
  // viewport-width fraction cap, e.g. 0.6 for 60vw (null = none)
1180
1136
  fromRight = false,
1181
- // divider sits on the pane's LEFT edge (dragging right shrinks)
1182
- storageKey = null
1183
- // persist the chosen width per user (localStorage)
1137
+ // divider sits on the pane's LEFT/TOP edge (dragging toward it shrinks)
1138
+ storageKey = null,
1139
+ // persist the chosen size per user (localStorage)
1140
+ axis = "x"
1141
+ // 'x' = width (col-resize), 'y' = height (row-resize)
1184
1142
  } = opts;
1143
+ const vertical = axis === "y";
1144
+ const coord = (e) => vertical ? e.clientY : e.clientX;
1145
+ const viewportExtent = () => typeof window === "undefined" ? 0 : vertical ? window.innerHeight : window.innerWidth;
1146
+ const cursor = vertical ? "row-resize" : "col-resize";
1185
1147
  const clamp2 = useCallback2((x) => {
1186
1148
  let hi = max ?? Infinity;
1187
- if (maxFraction && typeof window !== "undefined") hi = Math.min(hi, Math.round(window.innerWidth * maxFraction));
1149
+ if (maxFraction && typeof window !== "undefined") hi = Math.min(hi, Math.round(viewportExtent() * maxFraction));
1188
1150
  return Math.min(hi, Math.max(min, x));
1189
- }, [min, max, maxFraction]);
1190
- const [width, setWidth] = useState3(() => {
1151
+ }, [min, max, maxFraction, vertical]);
1152
+ const [width, setWidth] = useState4(() => {
1191
1153
  if (storageKey && typeof window !== "undefined") {
1192
1154
  try {
1193
1155
  const n = parseInt(window.localStorage.getItem(storageKey) || "", 10);
@@ -1208,9 +1170,9 @@ function useResizablePane(opts = {}) {
1208
1170
  }, [storageKey]);
1209
1171
  const onMouseDown = useCallback2((e) => {
1210
1172
  e.preventDefault();
1211
- const sx = e.clientX, base = widthRef.current, dir = fromRight ? -1 : 1;
1173
+ const sx = coord(e), base = widthRef.current, dir = fromRight ? -1 : 1;
1212
1174
  document.body.classList.add("uic-resizing");
1213
- const move = (ev) => setWidth(clamp2(base + dir * (ev.clientX - sx)));
1175
+ const move = (ev) => setWidth(clamp2(base + dir * (coord(ev) - sx)));
1214
1176
  const up = () => {
1215
1177
  window.removeEventListener("mousemove", move);
1216
1178
  window.removeEventListener("mouseup", up);
@@ -1220,8 +1182,35 @@ function useResizablePane(opts = {}) {
1220
1182
  };
1221
1183
  window.addEventListener("mousemove", move);
1222
1184
  window.addEventListener("mouseup", up);
1223
- document.body.style.cursor = "col-resize";
1224
- }, [clamp2, fromRight, persist]);
1185
+ document.body.style.cursor = cursor;
1186
+ }, [clamp2, fromRight, persist, vertical]);
1187
+ const onPointerDown = useCallback2((e) => {
1188
+ if (e.pointerType === "mouse") return;
1189
+ e.preventDefault();
1190
+ const sx = coord(e), base = widthRef.current, dir = fromRight ? -1 : 1;
1191
+ const el = e.currentTarget;
1192
+ document.body.classList.add("uic-resizing");
1193
+ try {
1194
+ el.setPointerCapture(e.pointerId);
1195
+ } catch {
1196
+ }
1197
+ const move = (ev) => setWidth(clamp2(base + dir * (coord(ev) - sx)));
1198
+ const up = () => {
1199
+ el.removeEventListener("pointermove", move);
1200
+ el.removeEventListener("pointerup", up);
1201
+ el.removeEventListener("pointercancel", up);
1202
+ document.body.classList.remove("uic-resizing");
1203
+ persist(widthRef.current);
1204
+ };
1205
+ el.addEventListener("pointermove", move);
1206
+ el.addEventListener("pointerup", up);
1207
+ el.addEventListener("pointercancel", up);
1208
+ }, [clamp2, fromRight, persist, vertical]);
1209
+ const nudge = useCallback2((delta) => {
1210
+ const w = clamp2(widthRef.current + delta);
1211
+ setWidth(w);
1212
+ persist(w);
1213
+ }, [clamp2, persist]);
1225
1214
  const reset = useCallback2(() => {
1226
1215
  setWidth(initial);
1227
1216
  if (storageKey) {
@@ -1231,26 +1220,49 @@ function useResizablePane(opts = {}) {
1231
1220
  }
1232
1221
  }
1233
1222
  }, [initial, storageKey]);
1234
- return { width, onMouseDown, reset };
1223
+ let maxResolved = max ?? null;
1224
+ if (maxFraction && typeof window !== "undefined") {
1225
+ const frac = Math.round(viewportExtent() * maxFraction);
1226
+ maxResolved = maxResolved == null ? frac : Math.min(maxResolved, frac);
1227
+ }
1228
+ return { width, onMouseDown, onPointerDown, nudge, reset, min, max: maxResolved, fromRight, axis };
1235
1229
  }
1236
1230
  function PaneResizer(props) {
1237
1231
  const { pane, className, title = "Drag to resize (double-click to reset)" } = props;
1238
- return /* @__PURE__ */ jsx8(
1232
+ const vertical = pane.axis === "y";
1233
+ const onKeyDown = (e) => {
1234
+ const keys = vertical ? ["ArrowUp", "ArrowDown"] : ["ArrowLeft", "ArrowRight"];
1235
+ if (!keys.includes(e.key)) return;
1236
+ if (!pane.nudge) return;
1237
+ e.preventDefault();
1238
+ const step = e.shiftKey ? 96 : 24;
1239
+ const forward = e.key === "ArrowRight" || e.key === "ArrowDown";
1240
+ const dir = (forward ? 1 : -1) * (pane.fromRight ? -1 : 1);
1241
+ pane.nudge(dir * step);
1242
+ };
1243
+ return /* @__PURE__ */ jsx6(
1239
1244
  "div",
1240
1245
  {
1241
- className: className ?? "uic-vresize",
1246
+ className: className ?? (vertical ? "uic-hresize" : "uic-vresize"),
1242
1247
  role: "separator",
1243
- "aria-orientation": "vertical",
1248
+ "aria-orientation": vertical ? "horizontal" : "vertical",
1249
+ "aria-label": title,
1250
+ "aria-valuenow": Math.round(pane.width),
1251
+ "aria-valuemin": pane.min != null ? Math.round(pane.min) : void 0,
1252
+ "aria-valuemax": pane.max != null ? Math.round(pane.max) : void 0,
1253
+ tabIndex: 0,
1244
1254
  title,
1245
1255
  onMouseDown: pane.onMouseDown,
1256
+ onPointerDown: pane.onPointerDown,
1257
+ onKeyDown,
1246
1258
  onDoubleClick: pane.reset
1247
1259
  }
1248
1260
  );
1249
1261
  }
1250
1262
 
1251
1263
  // src/components/TaskList.jsx
1252
- import { useCallback as useCallback3, useEffect as useEffect4, useMemo, useRef as useRef4, useState as useState4 } from "react";
1253
- import { Fragment as Fragment4, jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
1264
+ import { useCallback as useCallback3, useEffect as useEffect4, useMemo, useRef as useRef4, useState as useState5 } from "react";
1265
+ import { Fragment as Fragment4, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
1254
1266
  var STATUS_GROUPS = {
1255
1267
  all: () => true,
1256
1268
  working: (s) => ["running", "starting", "queued", "in_progress"].includes(s),
@@ -1288,12 +1300,12 @@ function TaskList({
1288
1300
  statusKey = "status",
1289
1301
  timeKey = "updated_at"
1290
1302
  }) {
1291
- const [head, setHead] = useState4(null);
1292
- const [tail, setTail] = useState4([]);
1293
- const [cursor, setCursor] = useState4("");
1294
- const [loadingMore, setLoadingMore] = useState4(false);
1295
- const [q, setQ] = useState4("");
1296
- const [statusFilter, setStatusFilter] = useState4("all");
1303
+ const [head, setHead] = useState5(null);
1304
+ const [tail, setTail] = useState5([]);
1305
+ const [cursor, setCursor] = useState5("");
1306
+ const [loadingMore, setLoadingMore] = useState5(false);
1307
+ const [q, setQ] = useState5("");
1308
+ const [statusFilter, setStatusFilter] = useState5("all");
1297
1309
  const alive = useRef4(true);
1298
1310
  useEffect4(() => () => {
1299
1311
  alive.current = false;
@@ -1341,14 +1353,14 @@ function TaskList({
1341
1353
  const el = e.currentTarget;
1342
1354
  if (el.scrollTop + el.clientHeight > el.scrollHeight - 140) loadMore();
1343
1355
  };
1344
- return /* @__PURE__ */ jsxs8("div", { className: "rui-tasks", children: [
1345
- header ? /* @__PURE__ */ jsx9("div", { className: "rui-tasks-header", children: header }) : null,
1346
- onNew ? /* @__PURE__ */ jsxs8("button", { type: "button", className: "rui-tasks-new", onClick: onNew, children: [
1356
+ return /* @__PURE__ */ jsxs6("div", { className: "rui-tasks", children: [
1357
+ header ? /* @__PURE__ */ jsx7("div", { className: "rui-tasks-header", children: header }) : null,
1358
+ onNew ? /* @__PURE__ */ jsxs6("button", { type: "button", className: "rui-tasks-new", onClick: onNew, children: [
1347
1359
  "+ ",
1348
1360
  newLabel
1349
1361
  ] }) : null,
1350
- /* @__PURE__ */ jsxs8("div", { className: "rui-tasks-filters", children: [
1351
- /* @__PURE__ */ jsx9(
1362
+ /* @__PURE__ */ jsxs6("div", { className: "rui-tasks-filters", children: [
1363
+ /* @__PURE__ */ jsx7(
1352
1364
  "input",
1353
1365
  {
1354
1366
  className: "rui-tasks-search",
@@ -1358,7 +1370,7 @@ function TaskList({
1358
1370
  "aria-label": "Filter tasks"
1359
1371
  }
1360
1372
  ),
1361
- /* @__PURE__ */ jsxs8(
1373
+ /* @__PURE__ */ jsxs6(
1362
1374
  "select",
1363
1375
  {
1364
1376
  className: "rui-tasks-status",
@@ -1366,19 +1378,19 @@ function TaskList({
1366
1378
  onChange: (e) => setStatusFilter(e.target.value),
1367
1379
  "aria-label": "Filter by status",
1368
1380
  children: [
1369
- /* @__PURE__ */ jsx9("option", { value: "all", children: "All" }),
1370
- /* @__PURE__ */ jsx9("option", { value: "working", children: "Working" }),
1371
- /* @__PURE__ */ jsx9("option", { value: "done", children: "Done" }),
1372
- /* @__PURE__ */ jsx9("option", { value: "failed", children: "Failed" })
1381
+ /* @__PURE__ */ jsx7("option", { value: "all", children: "All" }),
1382
+ /* @__PURE__ */ jsx7("option", { value: "working", children: "Working" }),
1383
+ /* @__PURE__ */ jsx7("option", { value: "done", children: "Done" }),
1384
+ /* @__PURE__ */ jsx7("option", { value: "failed", children: "Failed" })
1373
1385
  ]
1374
1386
  }
1375
1387
  )
1376
1388
  ] }),
1377
- /* @__PURE__ */ jsxs8("div", { className: "rui-tasks-list", onScroll, children: [
1378
- head === null ? /* @__PURE__ */ jsx9("div", { className: "rui-tasks-empty", children: "Loading\u2026" }) : shown.length === 0 ? /* @__PURE__ */ jsx9("div", { className: "rui-tasks-empty", children: items.length ? "No matching tasks" : emptyLabel }) : shown.map((it) => {
1389
+ /* @__PURE__ */ jsxs6("div", { className: "rui-tasks-list", onScroll, children: [
1390
+ head === null ? /* @__PURE__ */ jsx7("div", { className: "rui-tasks-empty", children: "Loading\u2026" }) : shown.length === 0 ? /* @__PURE__ */ jsx7("div", { className: "rui-tasks-empty", children: items.length ? "No matching tasks" : emptyLabel }) : shown.map((it) => {
1379
1391
  const id = it?.[idKey];
1380
1392
  const group = taskStatusGroup(it?.[statusKey]);
1381
- return /* @__PURE__ */ jsxs8(
1393
+ return /* @__PURE__ */ jsxs6(
1382
1394
  "div",
1383
1395
  {
1384
1396
  className: `rui-task${id === selected ? " is-selected" : ""}`,
@@ -1389,15 +1401,15 @@ function TaskList({
1389
1401
  if (e.key === "Enter" || e.key === " ") onSelect?.(id);
1390
1402
  },
1391
1403
  children: [
1392
- /* @__PURE__ */ jsxs8("div", { className: "rui-task-main", children: [
1393
- /* @__PURE__ */ jsx9("div", { className: "rui-task-title", children: it?.[titleKey] || "Untitled task" }),
1394
- /* @__PURE__ */ jsx9("div", { className: "rui-task-meta", children: renderMeta ? renderMeta(it) : /* @__PURE__ */ jsxs8(Fragment4, { children: [
1395
- /* @__PURE__ */ jsx9("span", { className: `rui-task-dot is-${group}` }),
1396
- /* @__PURE__ */ jsx9("span", { className: "rui-task-status", children: it?.[statusKey] || "" }),
1397
- it?.[timeKey] ? /* @__PURE__ */ jsx9("span", { className: "rui-task-time", children: relTime(it[timeKey]) }) : null
1404
+ /* @__PURE__ */ jsxs6("div", { className: "rui-task-main", children: [
1405
+ /* @__PURE__ */ jsx7("div", { className: "rui-task-title", children: it?.[titleKey] || "Untitled task" }),
1406
+ /* @__PURE__ */ jsx7("div", { className: "rui-task-meta", children: renderMeta ? renderMeta(it) : /* @__PURE__ */ jsxs6(Fragment4, { children: [
1407
+ /* @__PURE__ */ jsx7("span", { className: `rui-task-dot is-${group}` }),
1408
+ /* @__PURE__ */ jsx7("span", { className: "rui-task-status", children: it?.[statusKey] || "" }),
1409
+ it?.[timeKey] ? /* @__PURE__ */ jsx7("span", { className: "rui-task-time", children: relTime(it[timeKey]) }) : null
1398
1410
  ] }) })
1399
1411
  ] }),
1400
- onDelete ? /* @__PURE__ */ jsx9(
1412
+ onDelete ? /* @__PURE__ */ jsx7(
1401
1413
  "button",
1402
1414
  {
1403
1415
  type: "button",
@@ -1415,7 +1427,7 @@ function TaskList({
1415
1427
  id
1416
1428
  );
1417
1429
  }),
1418
- loadingMore ? /* @__PURE__ */ jsx9("div", { className: "rui-tasks-empty", children: "Loading more\u2026" }) : null
1430
+ loadingMore ? /* @__PURE__ */ jsx7("div", { className: "rui-tasks-empty", children: "Loading more\u2026" }) : null
1419
1431
  ] })
1420
1432
  ] });
1421
1433
  }
@@ -1425,53 +1437,14 @@ import {
1425
1437
  createContext,
1426
1438
  useCallback as useCallback4,
1427
1439
  useContext,
1428
- useEffect as useEffect6,
1440
+ useEffect as useEffect5,
1429
1441
  useId,
1430
1442
  useMemo as useMemo2,
1431
1443
  useRef as useRef5,
1432
- useState as useState5
1444
+ useState as useState6
1433
1445
  } from "react";
1434
1446
  import { createPortal } from "react-dom";
1435
-
1436
- // src/components/overlay.js
1437
- import { useEffect as useEffect5 } from "react";
1438
- var stack = [];
1439
- var listening = false;
1440
- function onKey(e) {
1441
- if (e.key !== "Escape") return;
1442
- const top = stack[stack.length - 1];
1443
- if (!top) return;
1444
- e.preventDefault();
1445
- top.onEscape?.();
1446
- }
1447
- function listen() {
1448
- if (listening || typeof document === "undefined") return;
1449
- document.addEventListener("keydown", onKey);
1450
- listening = true;
1451
- }
1452
- function unlisten() {
1453
- if (!listening || stack.length) return;
1454
- document.removeEventListener("keydown", onKey);
1455
- listening = false;
1456
- }
1457
- function pushOverlay(entry) {
1458
- stack.push(entry);
1459
- listen();
1460
- return () => {
1461
- const i = stack.indexOf(entry);
1462
- if (i >= 0) stack.splice(i, 1);
1463
- unlisten();
1464
- };
1465
- }
1466
- function useOverlayEscape(active, onEscape) {
1467
- useEffect5(() => {
1468
- if (!active) return void 0;
1469
- return pushOverlay({ onEscape });
1470
- }, [active, onEscape]);
1471
- }
1472
-
1473
- // src/components/Dialog.jsx
1474
- import { Fragment as Fragment5, jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
1447
+ import { Fragment as Fragment5, jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
1475
1448
  var DialogCtx = createContext(null);
1476
1449
  var LABELS = {
1477
1450
  en: { confirm: "Confirm", cancel: "Cancel", ok: "OK", create: "Create", required: "Please enter a value" },
@@ -1479,7 +1452,7 @@ var LABELS = {
1479
1452
  };
1480
1453
  var _idSeq = 0;
1481
1454
  function DialogHost({ children, locale = "en", labels }) {
1482
- const [stack2, setStack] = useState5([]);
1455
+ const [stack, setStack] = useState6([]);
1483
1456
  const t = useMemo2(
1484
1457
  () => ({ ...LABELS[locale] || LABELS.en, ...labels || {} }),
1485
1458
  [locale, labels]
@@ -1501,10 +1474,10 @@ function DialogHost({ children, locale = "en", labels }) {
1501
1474
  create: (opts) => open({ kind: "create", ...opts }),
1502
1475
  labels: t
1503
1476
  }), [open, t]);
1504
- return /* @__PURE__ */ jsxs9(DialogCtx.Provider, { value: ctx, children: [
1477
+ return /* @__PURE__ */ jsxs7(DialogCtx.Provider, { value: ctx, children: [
1505
1478
  children,
1506
- stack2.length > 0 && typeof document !== "undefined" && createPortal(
1507
- /* @__PURE__ */ jsx10("div", { className: "rui-dlg-root", role: "presentation", children: stack2.map((d, i) => /* @__PURE__ */ jsx10(DialogShell, { dialog: d, isTop: i === stack2.length - 1, onClose: close, t }, d.id)) }),
1479
+ stack.length > 0 && typeof document !== "undefined" && createPortal(
1480
+ /* @__PURE__ */ jsx8("div", { className: "rui-dlg-root", role: "presentation", children: stack.map((d, i) => /* @__PURE__ */ jsx8(DialogShell, { dialog: d, isTop: i === stack.length - 1, onClose: close, t }, d.id)) }),
1508
1481
  document.body
1509
1482
  )
1510
1483
  ] });
@@ -1521,7 +1494,7 @@ function DialogShell({ dialog, isTop, onClose, t }) {
1521
1494
  const titleId = useId();
1522
1495
  const escape = useCallback4(() => onClose(id, cancelValue(spec.kind)), [id, onClose, spec.kind]);
1523
1496
  useOverlayEscape(isTop, escape);
1524
- useEffect6(() => {
1497
+ useEffect5(() => {
1525
1498
  if (!isTop || !ref.current) return;
1526
1499
  const el = ref.current.querySelector("input, textarea") || ref.current.querySelector(".rui-dlg-primary") || ref.current.querySelector("button");
1527
1500
  el?.focus();
@@ -1530,7 +1503,7 @@ function DialogShell({ dialog, isTop, onClose, t }) {
1530
1503
  if (e.target === e.currentTarget && isTop) onClose(id, cancelValue(spec.kind));
1531
1504
  };
1532
1505
  const done = (v) => onClose(id, v);
1533
- return /* @__PURE__ */ jsx10("div", { className: "rui-dlg-backdrop", onClick: onBackdrop, children: /* @__PURE__ */ jsxs9(
1506
+ return /* @__PURE__ */ jsx8("div", { className: "rui-dlg-backdrop", onClick: onBackdrop, children: /* @__PURE__ */ jsxs7(
1534
1507
  "div",
1535
1508
  {
1536
1509
  ref,
@@ -1539,34 +1512,34 @@ function DialogShell({ dialog, isTop, onClose, t }) {
1539
1512
  "aria-labelledby": spec.title ? titleId : void 0,
1540
1513
  className: `rui-dlg-card${spec.kind === "create" ? " is-wide" : ""}`,
1541
1514
  children: [
1542
- spec.kind === "alert" && /* @__PURE__ */ jsx10(AlertBody, { spec, onClose: done, t, titleId }),
1543
- spec.kind === "confirm" && /* @__PURE__ */ jsx10(ConfirmBody, { spec, onClose: done, t, titleId }),
1544
- spec.kind === "prompt" && /* @__PURE__ */ jsx10(PromptBody, { spec, onClose: done, t, titleId }),
1545
- spec.kind === "create" && /* @__PURE__ */ jsx10(CreateBody, { spec, onClose: done, t, titleId })
1515
+ spec.kind === "alert" && /* @__PURE__ */ jsx8(AlertBody, { spec, onClose: done, t, titleId }),
1516
+ spec.kind === "confirm" && /* @__PURE__ */ jsx8(ConfirmBody, { spec, onClose: done, t, titleId }),
1517
+ spec.kind === "prompt" && /* @__PURE__ */ jsx8(PromptBody, { spec, onClose: done, t, titleId }),
1518
+ spec.kind === "create" && /* @__PURE__ */ jsx8(CreateBody, { spec, onClose: done, t, titleId })
1546
1519
  ]
1547
1520
  }
1548
1521
  ) });
1549
1522
  }
1550
1523
  function Header({ title, variant, titleId }) {
1551
1524
  if (!title) return null;
1552
- return /* @__PURE__ */ jsx10("div", { className: `rui-dlg-h${variant ? ` is-${variant}` : ""}`, children: /* @__PURE__ */ jsx10("div", { className: "rui-dlg-title", id: titleId, children: title }) });
1525
+ return /* @__PURE__ */ jsx8("div", { className: `rui-dlg-h${variant ? ` is-${variant}` : ""}`, children: /* @__PURE__ */ jsx8("div", { className: "rui-dlg-title", id: titleId, children: title }) });
1553
1526
  }
1554
- var Footer = ({ children }) => /* @__PURE__ */ jsx10("div", { className: "rui-dlg-f", children });
1527
+ var Footer = ({ children }) => /* @__PURE__ */ jsx8("div", { className: "rui-dlg-f", children });
1555
1528
  function AlertBody({ spec, onClose, t, titleId }) {
1556
- return /* @__PURE__ */ jsxs9(Fragment5, { children: [
1557
- /* @__PURE__ */ jsx10(Header, { title: spec.title, variant: spec.variant, titleId }),
1558
- /* @__PURE__ */ jsx10("div", { className: "rui-dlg-b", children: spec.message ? /* @__PURE__ */ jsx10("div", { className: "rui-dlg-msg", children: spec.message }) : null }),
1559
- /* @__PURE__ */ jsx10(Footer, { children: /* @__PURE__ */ jsx10("button", { type: "button", className: "rui-dlg-btn rui-dlg-primary", onClick: () => onClose(true), children: spec.confirmLabel || t.ok }) })
1529
+ return /* @__PURE__ */ jsxs7(Fragment5, { children: [
1530
+ /* @__PURE__ */ jsx8(Header, { title: spec.title, variant: spec.variant, titleId }),
1531
+ /* @__PURE__ */ jsx8("div", { className: "rui-dlg-b", children: spec.message ? /* @__PURE__ */ jsx8("div", { className: "rui-dlg-msg", children: spec.message }) : null }),
1532
+ /* @__PURE__ */ jsx8(Footer, { children: /* @__PURE__ */ jsx8("button", { type: "button", className: "rui-dlg-btn rui-dlg-primary", onClick: () => onClose(true), children: spec.confirmLabel || t.ok }) })
1560
1533
  ] });
1561
1534
  }
1562
1535
  function ConfirmBody({ spec, onClose, t, titleId }) {
1563
1536
  const destructive = !!spec.destructive;
1564
- return /* @__PURE__ */ jsxs9(Fragment5, { children: [
1565
- /* @__PURE__ */ jsx10(Header, { title: spec.title, variant: destructive ? "destructive" : spec.variant, titleId }),
1566
- /* @__PURE__ */ jsx10("div", { className: "rui-dlg-b", children: spec.message ? /* @__PURE__ */ jsx10("div", { className: "rui-dlg-msg", children: spec.message }) : null }),
1567
- /* @__PURE__ */ jsxs9(Footer, { children: [
1568
- /* @__PURE__ */ jsx10("button", { type: "button", className: "rui-dlg-btn rui-dlg-secondary", onClick: () => onClose(false), children: spec.cancelLabel || t.cancel }),
1569
- /* @__PURE__ */ jsx10(
1537
+ return /* @__PURE__ */ jsxs7(Fragment5, { children: [
1538
+ /* @__PURE__ */ jsx8(Header, { title: spec.title, variant: destructive ? "destructive" : spec.variant, titleId }),
1539
+ /* @__PURE__ */ jsx8("div", { className: "rui-dlg-b", children: spec.message ? /* @__PURE__ */ jsx8("div", { className: "rui-dlg-msg", children: spec.message }) : null }),
1540
+ /* @__PURE__ */ jsxs7(Footer, { children: [
1541
+ /* @__PURE__ */ jsx8("button", { type: "button", className: "rui-dlg-btn rui-dlg-secondary", onClick: () => onClose(false), children: spec.cancelLabel || t.cancel }),
1542
+ /* @__PURE__ */ jsx8(
1570
1543
  "button",
1571
1544
  {
1572
1545
  type: "button",
@@ -1579,8 +1552,8 @@ function ConfirmBody({ spec, onClose, t, titleId }) {
1579
1552
  ] });
1580
1553
  }
1581
1554
  function PromptBody({ spec, onClose, t, titleId }) {
1582
- const [value, setValue] = useState5(spec.defaultValue ?? "");
1583
- const [err, setErr] = useState5(null);
1555
+ const [value, setValue] = useState6(spec.defaultValue ?? "");
1556
+ const [err, setErr] = useState6(null);
1584
1557
  const inputId = useId();
1585
1558
  const Field2 = spec.multiline ? "textarea" : "input";
1586
1559
  const submit = () => {
@@ -1595,12 +1568,12 @@ function PromptBody({ spec, onClose, t, titleId }) {
1595
1568
  }
1596
1569
  onClose(String(value));
1597
1570
  };
1598
- return /* @__PURE__ */ jsxs9(Fragment5, { children: [
1599
- /* @__PURE__ */ jsx10(Header, { title: spec.title, variant: spec.variant, titleId }),
1600
- /* @__PURE__ */ jsxs9("div", { className: "rui-dlg-b", children: [
1601
- spec.message ? /* @__PURE__ */ jsx10("div", { className: "rui-dlg-msg", children: spec.message }) : null,
1602
- spec.label ? /* @__PURE__ */ jsx10("label", { className: "rui-dlg-label", htmlFor: inputId, children: spec.label }) : null,
1603
- /* @__PURE__ */ jsx10(
1571
+ return /* @__PURE__ */ jsxs7(Fragment5, { children: [
1572
+ /* @__PURE__ */ jsx8(Header, { title: spec.title, variant: spec.variant, titleId }),
1573
+ /* @__PURE__ */ jsxs7("div", { className: "rui-dlg-b", children: [
1574
+ spec.message ? /* @__PURE__ */ jsx8("div", { className: "rui-dlg-msg", children: spec.message }) : null,
1575
+ spec.label ? /* @__PURE__ */ jsx8("label", { className: "rui-dlg-label", htmlFor: inputId, children: spec.label }) : null,
1576
+ /* @__PURE__ */ jsx8(
1604
1577
  Field2,
1605
1578
  {
1606
1579
  id: inputId,
@@ -1623,20 +1596,20 @@ function PromptBody({ spec, onClose, t, titleId }) {
1623
1596
  spellCheck: "false"
1624
1597
  }
1625
1598
  ),
1626
- err ? /* @__PURE__ */ jsx10("div", { className: "rui-dlg-err", children: err }) : null,
1627
- !err && spec.help ? /* @__PURE__ */ jsx10("div", { className: "rui-dlg-help", children: spec.help }) : null
1599
+ err ? /* @__PURE__ */ jsx8("div", { className: "rui-dlg-err", children: err }) : null,
1600
+ !err && spec.help ? /* @__PURE__ */ jsx8("div", { className: "rui-dlg-help", children: spec.help }) : null
1628
1601
  ] }),
1629
- /* @__PURE__ */ jsxs9(Footer, { children: [
1630
- /* @__PURE__ */ jsx10("button", { type: "button", className: "rui-dlg-btn rui-dlg-secondary", onClick: () => onClose(null), children: spec.cancelLabel || t.cancel }),
1631
- /* @__PURE__ */ jsx10("button", { type: "button", className: "rui-dlg-btn rui-dlg-primary", onClick: submit, children: spec.confirmLabel || t.confirm })
1602
+ /* @__PURE__ */ jsxs7(Footer, { children: [
1603
+ /* @__PURE__ */ jsx8("button", { type: "button", className: "rui-dlg-btn rui-dlg-secondary", onClick: () => onClose(null), children: spec.cancelLabel || t.cancel }),
1604
+ /* @__PURE__ */ jsx8("button", { type: "button", className: "rui-dlg-btn rui-dlg-primary", onClick: submit, children: spec.confirmLabel || t.confirm })
1632
1605
  ] })
1633
1606
  ] });
1634
1607
  }
1635
1608
  function CreateBody({ spec, onClose, t, titleId }) {
1636
1609
  const types = spec.types || [];
1637
- const [kind, setKind] = useState5(spec.defaultKind || types[0]?.kind || "");
1638
- const [value, setValue] = useState5(spec.defaultValue ?? "");
1639
- const [err, setErr] = useState5(null);
1610
+ const [kind, setKind] = useState6(spec.defaultKind || types[0]?.kind || "");
1611
+ const [value, setValue] = useState6(spec.defaultValue ?? "");
1612
+ const [err, setErr] = useState6(null);
1640
1613
  const inputId = useId();
1641
1614
  const sel = types.find((x) => x.kind === kind) || types[0] || {};
1642
1615
  const submit = () => {
@@ -1646,24 +1619,24 @@ function CreateBody({ spec, onClose, t, titleId }) {
1646
1619
  }
1647
1620
  onClose({ kind, name: String(value).trim() });
1648
1621
  };
1649
- return /* @__PURE__ */ jsxs9(Fragment5, { children: [
1650
- /* @__PURE__ */ jsx10(Header, { title: spec.title, titleId }),
1651
- /* @__PURE__ */ jsxs9("div", { className: "rui-dlg-b", children: [
1652
- types.length > 0 ? /* @__PURE__ */ jsx10("div", { className: "rui-dlg-typegrid", children: types.map((ty) => /* @__PURE__ */ jsxs9(
1622
+ return /* @__PURE__ */ jsxs7(Fragment5, { children: [
1623
+ /* @__PURE__ */ jsx8(Header, { title: spec.title, titleId }),
1624
+ /* @__PURE__ */ jsxs7("div", { className: "rui-dlg-b", children: [
1625
+ types.length > 0 ? /* @__PURE__ */ jsx8("div", { className: "rui-dlg-typegrid", children: types.map((ty) => /* @__PURE__ */ jsxs7(
1653
1626
  "button",
1654
1627
  {
1655
1628
  type: "button",
1656
1629
  className: `rui-dlg-type${ty.kind === kind ? " is-on" : ""}`,
1657
1630
  onClick: () => setKind(ty.kind),
1658
1631
  children: [
1659
- ty.icon ? /* @__PURE__ */ jsx10("span", { className: "rui-dlg-type-ic", style: ty.color ? { color: ty.color, background: `${ty.color}1f` } : void 0, children: ty.icon }) : null,
1660
- /* @__PURE__ */ jsx10("span", { className: "rui-dlg-type-lbl", children: ty.label })
1632
+ ty.icon ? /* @__PURE__ */ jsx8("span", { className: "rui-dlg-type-ic", style: ty.color ? { color: ty.color, background: `${ty.color}1f` } : void 0, children: ty.icon }) : null,
1633
+ /* @__PURE__ */ jsx8("span", { className: "rui-dlg-type-lbl", children: ty.label })
1661
1634
  ]
1662
1635
  },
1663
1636
  ty.kind
1664
1637
  )) }) : null,
1665
- /* @__PURE__ */ jsx10("label", { className: "rui-dlg-label", htmlFor: inputId, children: spec.label || `${sel.label || "Item"} name` }),
1666
- /* @__PURE__ */ jsx10(
1638
+ /* @__PURE__ */ jsx8("label", { className: "rui-dlg-label", htmlFor: inputId, children: spec.label || `${sel.label || "Item"} name` }),
1639
+ /* @__PURE__ */ jsx8(
1667
1640
  "input",
1668
1641
  {
1669
1642
  id: inputId,
@@ -1684,26 +1657,27 @@ function CreateBody({ spec, onClose, t, titleId }) {
1684
1657
  spellCheck: "false"
1685
1658
  }
1686
1659
  ),
1687
- err ? /* @__PURE__ */ jsx10("div", { className: "rui-dlg-err", children: err }) : null
1660
+ err ? /* @__PURE__ */ jsx8("div", { className: "rui-dlg-err", children: err }) : null
1688
1661
  ] }),
1689
- /* @__PURE__ */ jsxs9(Footer, { children: [
1690
- /* @__PURE__ */ jsx10("button", { type: "button", className: "rui-dlg-btn rui-dlg-secondary", onClick: () => onClose(null), children: spec.cancelLabel || t.cancel }),
1691
- /* @__PURE__ */ jsx10("button", { type: "button", className: "rui-dlg-btn rui-dlg-primary", onClick: submit, children: spec.confirmLabel || t.create })
1662
+ /* @__PURE__ */ jsxs7(Footer, { children: [
1663
+ /* @__PURE__ */ jsx8("button", { type: "button", className: "rui-dlg-btn rui-dlg-secondary", onClick: () => onClose(null), children: spec.cancelLabel || t.cancel }),
1664
+ /* @__PURE__ */ jsx8("button", { type: "button", className: "rui-dlg-btn rui-dlg-primary", onClick: submit, children: spec.confirmLabel || t.create })
1692
1665
  ] })
1693
1666
  ] });
1694
1667
  }
1695
1668
 
1696
1669
  // src/auth/client.js
1697
1670
  var _cfg = {
1698
- engine: "",
1699
- // REQUIRED: your auth backend base URL, set via configureAuth
1671
+ // Same-origin. A product that forgets to configure gets the working default rather than the
1672
+ // engine's Azure FQDN, which no browser may call — its ingress admits only the VM that fronts
1673
+ // these apps, so a direct call 403s and reads as "Failed to fetch".
1674
+ engine: "/engine",
1700
1675
  product: "",
1701
1676
  loginHash: "#/login"
1702
1677
  };
1703
1678
  function configureAuth(cfg) {
1704
1679
  Object.assign(_cfg, cfg);
1705
1680
  if (!_cfg.product) throw new Error("configureAuth: product is required");
1706
- if (!_cfg.engine) throw new Error("configureAuth: engine (auth backend base URL) is required");
1707
1681
  }
1708
1682
  function authConfig() {
1709
1683
  return { ..._cfg };
@@ -1842,18 +1816,18 @@ async function fetchBalance() {
1842
1816
  }
1843
1817
 
1844
1818
  // src/auth/AuthForm.jsx
1845
- import { useState as useState7 } from "react";
1819
+ import { useState as useState8 } from "react";
1846
1820
 
1847
1821
  // src/auth/GoogleButton.jsx
1848
- import { useEffect as useEffect7, useRef as useRef6, useState as useState6 } from "react";
1849
- import { Fragment as Fragment6, jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
1822
+ import { useEffect as useEffect6, useRef as useRef6, useState as useState7 } from "react";
1823
+ import { Fragment as Fragment6, jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
1850
1824
  var CLIENT_ID = "247853836408-ojk91u8901hdlbkevid4fohmrfdot17l.apps.googleusercontent.com";
1851
1825
  function GoogleButton({ onCredential, onError }) {
1852
1826
  const ref = useRef6(null);
1853
- const [failed, setFailed] = useState6(false);
1827
+ const [failed, setFailed] = useState7(false);
1854
1828
  const cb = useRef6({ onCredential, onError });
1855
1829
  cb.current = { onCredential, onError };
1856
- useEffect7(() => {
1830
+ useEffect6(() => {
1857
1831
  if (!CLIENT_ID || !ref.current) return void 0;
1858
1832
  const SRC = "https://accounts.google.com/gsi/client";
1859
1833
  let done = false;
@@ -1904,24 +1878,24 @@ function GoogleButton({ onCredential, onError }) {
1904
1878
  };
1905
1879
  }, []);
1906
1880
  if (!CLIENT_ID || failed) return null;
1907
- return /* @__PURE__ */ jsxs10(Fragment6, { children: [
1908
- /* @__PURE__ */ jsx11("div", { className: "auth-or", children: /* @__PURE__ */ jsx11("span", { children: "or" }) }),
1909
- /* @__PURE__ */ jsx11("div", { ref, className: "auth-gwrap" })
1881
+ return /* @__PURE__ */ jsxs8(Fragment6, { children: [
1882
+ /* @__PURE__ */ jsx9("div", { className: "auth-or", children: /* @__PURE__ */ jsx9("span", { children: "or" }) }),
1883
+ /* @__PURE__ */ jsx9("div", { ref, className: "auth-gwrap" })
1910
1884
  ] });
1911
1885
  }
1912
1886
  var GOOGLE_ENABLED = !!CLIENT_ID;
1913
1887
 
1914
1888
  // src/auth/AuthForm.jsx
1915
- import { Fragment as Fragment7, jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
1889
+ import { Fragment as Fragment7, jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
1916
1890
  function AuthForm({ onDone, subtitle: subtitle2, brand = null, productName = "" }) {
1917
- const [mode, setMode] = useState7("signin");
1918
- const [email, setEmail] = useState7("");
1919
- const [password, setPassword] = useState7("");
1920
- const [name, setName] = useState7("");
1921
- const [err, setErr] = useState7("");
1922
- const [busy, setBusy] = useState7(false);
1923
- const [choices, setChoices] = useState7(null);
1924
- const [resetSent, setResetSent] = useState7(false);
1891
+ const [mode, setMode] = useState8("signin");
1892
+ const [email, setEmail] = useState8("");
1893
+ const [password, setPassword] = useState8("");
1894
+ const [name, setName] = useState8("");
1895
+ const [err, setErr] = useState8("");
1896
+ const [busy, setBusy] = useState8(false);
1897
+ const [choices, setChoices] = useState8(null);
1898
+ const [resetSent, setResetSent] = useState8(false);
1925
1899
  async function enter(orgId) {
1926
1900
  const session = await switchOrg(orgId);
1927
1901
  onDone(session);
@@ -1962,10 +1936,10 @@ function AuthForm({ onDone, subtitle: subtitle2, brand = null, productName = ""
1962
1936
  }
1963
1937
  }
1964
1938
  if (choices) {
1965
- return /* @__PURE__ */ jsxs11("div", { children: [
1966
- /* @__PURE__ */ jsx12("div", { className: "logo", children: brand }),
1967
- /* @__PURE__ */ jsx12("h1", { children: "Choose workspace" }),
1968
- /* @__PURE__ */ jsx12("div", { className: "org-list", children: choices.map((o) => /* @__PURE__ */ jsx12(
1939
+ return /* @__PURE__ */ jsxs9("div", { children: [
1940
+ /* @__PURE__ */ jsx10("div", { className: "logo", children: brand }),
1941
+ /* @__PURE__ */ jsx10("h1", { children: "Choose workspace" }),
1942
+ /* @__PURE__ */ jsx10("div", { className: "org-list", children: choices.map((o) => /* @__PURE__ */ jsx10(
1969
1943
  "button",
1970
1944
  {
1971
1945
  type: "button",
@@ -1983,20 +1957,20 @@ function AuthForm({ onDone, subtitle: subtitle2, brand = null, productName = ""
1983
1957
  },
1984
1958
  o.id
1985
1959
  )) }),
1986
- err && /* @__PURE__ */ jsx12("div", { className: "auth-err", children: err })
1960
+ err && /* @__PURE__ */ jsx10("div", { className: "auth-err", children: err })
1987
1961
  ] });
1988
1962
  }
1989
- return /* @__PURE__ */ jsxs11("form", { onSubmit: submit, children: [
1990
- /* @__PURE__ */ jsx12("div", { className: "logo", children: brand }),
1991
- /* @__PURE__ */ jsx12("h1", { children: mode === "register" ? "Create your account" : mode === "forgot" ? "Reset password" : "Sign in" }),
1992
- /* @__PURE__ */ jsx12("p", { className: "sub", children: mode === "register" ? "Get started in seconds." : mode === "forgot" ? "We will email you a reset link." : subtitle2 || "Welcome back." }),
1993
- mode === "forgot" ? resetSent ? /* @__PURE__ */ jsxs11(Fragment7, { children: [
1994
- /* @__PURE__ */ jsxs11("div", { className: "auth-note", children: [
1963
+ return /* @__PURE__ */ jsxs9("form", { onSubmit: submit, children: [
1964
+ /* @__PURE__ */ jsx10("div", { className: "logo", children: brand }),
1965
+ /* @__PURE__ */ jsx10("h1", { children: mode === "register" ? "Create your account" : mode === "forgot" ? "Reset password" : "Sign in" }),
1966
+ /* @__PURE__ */ jsx10("p", { className: "sub", children: mode === "register" ? "Get started in seconds." : mode === "forgot" ? "We will email you a reset link." : subtitle2 || "Welcome back." }),
1967
+ mode === "forgot" ? resetSent ? /* @__PURE__ */ jsxs9(Fragment7, { children: [
1968
+ /* @__PURE__ */ jsxs9("div", { className: "auth-note", children: [
1995
1969
  "If an account exists for ",
1996
- /* @__PURE__ */ jsx12("b", { children: email.trim() }),
1970
+ /* @__PURE__ */ jsx10("b", { children: email.trim() }),
1997
1971
  ", a password reset link is on its way. It is valid for 1 hour."
1998
1972
  ] }),
1999
- /* @__PURE__ */ jsx12(
1973
+ /* @__PURE__ */ jsx10(
2000
1974
  "button",
2001
1975
  {
2002
1976
  type: "button",
@@ -2010,36 +1984,36 @@ function AuthForm({ onDone, subtitle: subtitle2, brand = null, productName = ""
2010
1984
  children: "Back to sign in"
2011
1985
  }
2012
1986
  )
2013
- ] }) : /* @__PURE__ */ jsxs11(Fragment7, { children: [
2014
- /* @__PURE__ */ jsxs11("div", { className: "field", children: [
2015
- /* @__PURE__ */ jsx12("label", { children: "Email" }),
2016
- /* @__PURE__ */ jsx12("input", { className: "input", type: "email", value: email, onChange: (e) => setEmail(e.target.value), autoFocus: true, required: true, autoComplete: "email" })
1987
+ ] }) : /* @__PURE__ */ jsxs9(Fragment7, { children: [
1988
+ /* @__PURE__ */ jsxs9("div", { className: "field", children: [
1989
+ /* @__PURE__ */ jsx10("label", { children: "Email" }),
1990
+ /* @__PURE__ */ jsx10("input", { className: "input", type: "email", value: email, onChange: (e) => setEmail(e.target.value), autoFocus: true, required: true, autoComplete: "email" })
2017
1991
  ] }),
2018
- err && /* @__PURE__ */ jsx12("div", { className: "auth-err", children: err }),
2019
- /* @__PURE__ */ jsx12("button", { type: "submit", className: "btn primary lg", style: { width: "100%", marginTop: 8 }, disabled: busy, children: busy ? "Please wait..." : "Send reset link" }),
2020
- /* @__PURE__ */ jsx12("p", { className: "auth-switch", children: /* @__PURE__ */ jsx12("button", { type: "button", onClick: () => {
1992
+ err && /* @__PURE__ */ jsx10("div", { className: "auth-err", children: err }),
1993
+ /* @__PURE__ */ jsx10("button", { type: "submit", className: "btn primary lg", style: { width: "100%", marginTop: 8 }, disabled: busy, children: busy ? "Please wait..." : "Send reset link" }),
1994
+ /* @__PURE__ */ jsx10("p", { className: "auth-switch", children: /* @__PURE__ */ jsx10("button", { type: "button", onClick: () => {
2021
1995
  setErr("");
2022
1996
  setMode("signin");
2023
1997
  }, children: "Back to sign in" }) })
2024
- ] }) : /* @__PURE__ */ jsxs11(Fragment7, { children: [
2025
- mode === "register" && /* @__PURE__ */ jsxs11("div", { className: "field", children: [
2026
- /* @__PURE__ */ jsx12("label", { children: "Name" }),
2027
- /* @__PURE__ */ jsx12("input", { className: "input", value: name, onChange: (e) => setName(e.target.value), autoComplete: "name", placeholder: "Jane Doe" })
1998
+ ] }) : /* @__PURE__ */ jsxs9(Fragment7, { children: [
1999
+ mode === "register" && /* @__PURE__ */ jsxs9("div", { className: "field", children: [
2000
+ /* @__PURE__ */ jsx10("label", { children: "Name" }),
2001
+ /* @__PURE__ */ jsx10("input", { className: "input", value: name, onChange: (e) => setName(e.target.value), autoComplete: "name", placeholder: "Jane Doe" })
2028
2002
  ] }),
2029
- /* @__PURE__ */ jsxs11("div", { className: "field", children: [
2030
- /* @__PURE__ */ jsx12("label", { children: "Email" }),
2031
- /* @__PURE__ */ jsx12("input", { className: "input", type: "email", value: email, onChange: (e) => setEmail(e.target.value), autoFocus: true, required: true, autoComplete: "email" })
2003
+ /* @__PURE__ */ jsxs9("div", { className: "field", children: [
2004
+ /* @__PURE__ */ jsx10("label", { children: "Email" }),
2005
+ /* @__PURE__ */ jsx10("input", { className: "input", type: "email", value: email, onChange: (e) => setEmail(e.target.value), autoFocus: true, required: true, autoComplete: "email" })
2032
2006
  ] }),
2033
- /* @__PURE__ */ jsxs11("div", { className: "field", children: [
2034
- /* @__PURE__ */ jsxs11("div", { className: "field-row", children: [
2035
- /* @__PURE__ */ jsx12("label", { children: "Password" }),
2036
- mode === "signin" && /* @__PURE__ */ jsx12("button", { type: "button", className: "link-sm", onClick: () => {
2007
+ /* @__PURE__ */ jsxs9("div", { className: "field", children: [
2008
+ /* @__PURE__ */ jsxs9("div", { className: "field-row", children: [
2009
+ /* @__PURE__ */ jsx10("label", { children: "Password" }),
2010
+ mode === "signin" && /* @__PURE__ */ jsx10("button", { type: "button", className: "link-sm", onClick: () => {
2037
2011
  setErr("");
2038
2012
  setResetSent(false);
2039
2013
  setMode("forgot");
2040
2014
  }, children: "Forgot password?" })
2041
2015
  ] }),
2042
- /* @__PURE__ */ jsx12(
2016
+ /* @__PURE__ */ jsx10(
2043
2017
  "input",
2044
2018
  {
2045
2019
  className: "input",
@@ -2052,13 +2026,13 @@ function AuthForm({ onDone, subtitle: subtitle2, brand = null, productName = ""
2052
2026
  }
2053
2027
  )
2054
2028
  ] }),
2055
- err && /* @__PURE__ */ jsx12("div", { className: "auth-err", children: err }),
2056
- /* @__PURE__ */ jsx12("button", { type: "submit", className: "btn primary lg", style: { width: "100%", marginTop: 8 }, disabled: busy, children: busy ? "Please wait..." : mode === "register" ? "Create account" : "Sign in" }),
2057
- GOOGLE_ENABLED && /* @__PURE__ */ jsx12(GoogleButton, { onCredential: onGoogle, onError: setErr }),
2058
- /* @__PURE__ */ jsxs11("p", { className: "auth-switch", children: [
2029
+ err && /* @__PURE__ */ jsx10("div", { className: "auth-err", children: err }),
2030
+ /* @__PURE__ */ jsx10("button", { type: "submit", className: "btn primary lg", style: { width: "100%", marginTop: 8 }, disabled: busy, children: busy ? "Please wait..." : mode === "register" ? "Create account" : "Sign in" }),
2031
+ GOOGLE_ENABLED && /* @__PURE__ */ jsx10(GoogleButton, { onCredential: onGoogle, onError: setErr }),
2032
+ /* @__PURE__ */ jsxs9("p", { className: "auth-switch", children: [
2059
2033
  mode === "register" ? "Already have an account?" : `New to ${productName || "the product"}?`,
2060
2034
  " ",
2061
- /* @__PURE__ */ jsx12("button", { type: "button", onClick: () => {
2035
+ /* @__PURE__ */ jsx10("button", { type: "button", onClick: () => {
2062
2036
  setErr("");
2063
2037
  setMode(mode === "register" ? "signin" : "register");
2064
2038
  }, children: mode === "register" ? "Sign in" : "Create one" })
@@ -2067,837 +2041,9 @@ function AuthForm({ onDone, subtitle: subtitle2, brand = null, productName = ""
2067
2041
  ] });
2068
2042
  }
2069
2043
 
2070
- // src/sheet/SheetGrid.jsx
2071
- import { useEffect as useEffect8, useRef as useRef7, useState as useState8 } from "react";
2072
- import { createPortal as createPortal2 } from "react-dom";
2073
- import { Fragment as Fragment8, jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
2074
- var cellKey = (rowId, colId) => `${rowId}:${colId}`;
2075
- var uid = (p) => `${p}_${Math.random().toString(36).slice(2, 10)}`;
2076
- var DEFAULT_COLUMN_TYPES = [
2077
- { type: "text", label: "Text" },
2078
- { type: "number", label: "Number" },
2079
- { type: "select", label: "Select" },
2080
- { type: "tags", label: "Tags" },
2081
- { type: "checkbox", label: "Checkbox" },
2082
- { type: "date", label: "Date" },
2083
- { type: "url", label: "Link" },
2084
- { type: "resource", label: "Resource" },
2085
- {
2086
- type: "compute",
2087
- label: "Computed",
2088
- computed: true,
2089
- configKey: "compute",
2090
- badge: (col) => col.compute?.kind
2091
- }
2092
- ];
2093
- var COMPUTE_KINDS = [
2094
- { kind: "prompt", label: "AI prompt" },
2095
- { kind: "harness", label: "Agent (harness)" },
2096
- { kind: "workflow", label: "Workflow" },
2097
- { kind: "image", label: "Generate image" }
2098
- ];
2099
- var RESOURCE_KINDS = ["image", "sheet", "slides", "workflow", "graph"];
2100
- var RESOURCE_ICON = { image: "\u{1F5BC}", sheet: "\u25A6", slides: "\u25A4", workflow: "\u2699", graph: "\u25C9" };
2101
- function PopPortal({ anchor, width = 250, estHeight = 300, className, children, onClose }) {
2102
- const boxRef = useRef7(null);
2103
- useEffect8(() => {
2104
- if (!onClose) return void 0;
2105
- const close = () => onClose();
2106
- const onDown = (e) => {
2107
- if (boxRef.current && boxRef.current.contains(e.target)) return;
2108
- if (anchor && e.clientX >= anchor.left && e.clientX <= anchor.right && e.clientY >= anchor.top && e.clientY <= anchor.bottom) return;
2109
- onClose();
2110
- };
2111
- window.addEventListener("mousedown", onDown);
2112
- window.addEventListener("scroll", close, true);
2113
- window.addEventListener("resize", close);
2114
- return () => {
2115
- window.removeEventListener("mousedown", onDown);
2116
- window.removeEventListener("scroll", close, true);
2117
- window.removeEventListener("resize", close);
2118
- };
2119
- }, [onClose, anchor]);
2120
- if (!anchor) return null;
2121
- const left = Math.max(8, Math.min(anchor.right - width, window.innerWidth - width - 8));
2122
- let top = anchor.bottom + 6;
2123
- if (top + estHeight > window.innerHeight - 8) top = Math.max(8, anchor.top - estHeight - 6);
2124
- return createPortal2(
2125
- /* @__PURE__ */ jsx13("div", { ref: boxRef, className, style: { position: "fixed", top, left, width, zIndex: 1e3 }, children }),
2126
- document.body
2127
- );
2128
- }
2129
- var PILL_FALLBACKS = ["#E0E7FF", "#FCE7F3", "#D1FAE5", "#FEF3C7", "#E0F2FE", "#F3E8FF", "#FFE4E6"];
2130
- function normOptions(options) {
2131
- return (options || []).map((o, i) => {
2132
- if (typeof o === "string") return { label: o, color: PILL_FALLBACKS[i % PILL_FALLBACKS.length] };
2133
- return { label: o.label ?? String(o.value ?? ""), color: o.color || PILL_FALLBACKS[i % PILL_FALLBACKS.length] };
2134
- });
2135
- }
2136
- function pillColor(label, options) {
2137
- const opts = normOptions(options);
2138
- const hit = opts.find((o) => o.label === label);
2139
- if (hit) return hit.color;
2140
- let h = 0;
2141
- for (const ch of String(label)) h = h * 31 + ch.charCodeAt(0) >>> 0;
2142
- return PILL_FALLBACKS[h % PILL_FALLBACKS.length];
2143
- }
2144
- function RefImage({ refVal, fetchBlobUrl }) {
2145
- const [src, setSrc] = useState8(/^https?:\/\//i.test(refVal.url || "") ? refVal.url : null);
2146
- useEffect8(() => {
2147
- let dead = false;
2148
- let obj = null;
2149
- if (!src && refVal.url && fetchBlobUrl) {
2150
- fetchBlobUrl(refVal.url).then((u) => {
2151
- if (!dead) {
2152
- obj = u;
2153
- setSrc(u);
2154
- }
2155
- });
2156
- }
2157
- return () => {
2158
- dead = true;
2159
- if (obj) URL.revokeObjectURL(obj);
2160
- };
2161
- }, [refVal.url]);
2162
- if (!src) return /* @__PURE__ */ jsxs12("span", { className: "shg-refchip", children: [
2163
- RESOURCE_ICON.image,
2164
- " ",
2165
- refVal.name || "image"
2166
- ] });
2167
- return /* @__PURE__ */ jsx13("img", { className: "shg-refimg", src, alt: refVal.name || "", title: refVal.name || "" });
2168
- }
2169
- function ResourceChip({ refVal, onOpen }) {
2170
- const icon = RESOURCE_ICON[refVal.kind] || "\u25C7";
2171
- return /* @__PURE__ */ jsxs12(
2172
- "button",
2173
- {
2174
- className: "shg-refchip shg-refchip-btn",
2175
- title: `Open ${refVal.kind}`,
2176
- onClick: (e) => {
2177
- e.stopPropagation();
2178
- onOpen && onOpen(refVal);
2179
- },
2180
- children: [
2181
- /* @__PURE__ */ jsx13("span", { className: "shg-refchip-ic", children: icon }),
2182
- /* @__PURE__ */ jsx13("span", { className: "shg-refchip-name", children: refVal.name || refVal.id || refVal.kind })
2183
- ]
2184
- }
2185
- );
2186
- }
2187
- function StatusDot({ status }) {
2188
- if (!status || status === "empty") return null;
2189
- return /* @__PURE__ */ jsx13("span", { className: `shg-dot shg-dot-${status}`, title: status });
2190
- }
2191
- function CellValue({ cell, col, fetchBlobUrl, onOpenResource }) {
2192
- const v = cell?.value;
2193
- if (v === void 0 || v === null || v === "") return /* @__PURE__ */ jsx13("span", { className: "shg-val-txt" });
2194
- if (v && typeof v === "object" && !Array.isArray(v) && v.kind) {
2195
- if (v.kind === "image") return /* @__PURE__ */ jsx13(RefImage, { refVal: v, fetchBlobUrl });
2196
- return /* @__PURE__ */ jsx13(ResourceChip, { refVal: v, onOpen: onOpenResource });
2197
- }
2198
- switch (col.type) {
2199
- case "select":
2200
- return /* @__PURE__ */ jsx13("span", { className: "shg-pill", style: { background: pillColor(String(v), col.options) }, children: String(v) });
2201
- case "tags": {
2202
- const tags = Array.isArray(v) ? v : String(v).split(",").map((s) => s.trim()).filter(Boolean);
2203
- return /* @__PURE__ */ jsx13("span", { className: "shg-pills", children: tags.map((t) => /* @__PURE__ */ jsx13("span", { className: "shg-pill", style: { background: pillColor(t, col.options) }, children: t }, t)) });
2204
- }
2205
- case "checkbox":
2206
- return /* @__PURE__ */ jsx13("span", { className: "shg-check" + (v ? " on" : ""), children: v ? "\u2713" : "" });
2207
- case "url": {
2208
- const href = /^https?:\/\//i.test(String(v)) ? String(v) : `https://${v}`;
2209
- return /* @__PURE__ */ jsx13("a", { className: "shg-link", href, target: "_blank", rel: "noreferrer", onClick: (e) => e.stopPropagation(), children: String(v) });
2210
- }
2211
- case "number":
2212
- return /* @__PURE__ */ jsx13("span", { className: "shg-val-txt shg-num", children: String(v) });
2213
- default:
2214
- return /* @__PURE__ */ jsx13("span", { className: "shg-val-txt", children: typeof v === "object" ? JSON.stringify(v) : String(v) });
2215
- }
2216
- }
2217
- function SheetGrid({
2218
- sheet,
2219
- onChange,
2220
- onRunCell,
2221
- onRunColumn,
2222
- readOnly = false,
2223
- fetchBlobUrl,
2224
- onOpenResource,
2225
- peerMarks,
2226
- onActiveCell,
2227
- columnTypes = DEFAULT_COLUMN_TYPES,
2228
- renderCell,
2229
- renderColumnConfig
2230
- }) {
2231
- const columns = sheet?.columns || [];
2232
- const rows = sheet?.rows || [];
2233
- const cells = sheet?.cells || {};
2234
- const [editing, setEditing] = useState8(null);
2235
- const [draft, setDraft] = useState8("");
2236
- const [menuCol, setMenuCol] = useState8(null);
2237
- const [sizeDraft, setSizeDraft] = useState8({});
2238
- const [dnd, setDnd] = useState8(null);
2239
- const [dropAt, setDropAt] = useState8(null);
2240
- const inputRef = useRef7(null);
2241
- const dragRef = useRef7(null);
2242
- const descOf = (type) => columnTypes.find((t) => t.type === type) || { type, label: type };
2243
- const isComputed = (col) => !!descOf(col?.type).computed;
2244
- const isEditable = (col) => {
2245
- const d = descOf(col?.type);
2246
- return d.editable ?? !d.computed;
2247
- };
2248
- const startResize = (e, kind, id, start) => {
2249
- if (readOnly) return;
2250
- e.preventDefault();
2251
- e.stopPropagation();
2252
- const origin = kind === "col" ? e.clientX : e.clientY;
2253
- dragRef.current = { kind, id, start, origin, last: start };
2254
- const onMove = (ev) => {
2255
- const d = dragRef.current;
2256
- if (!d) return;
2257
- const delta = (d.kind === "col" ? ev.clientX : ev.clientY) - d.origin;
2258
- const next = Math.max(d.kind === "col" ? 90 : 26, d.start + delta);
2259
- d.last = next;
2260
- setSizeDraft((sd) => ({ ...sd, [d.kind]: { ...sd[d.kind] || {}, [d.id]: next } }));
2261
- };
2262
- const onUp = () => {
2263
- const d = dragRef.current;
2264
- dragRef.current = null;
2265
- window.removeEventListener("mousemove", onMove);
2266
- window.removeEventListener("mouseup", onUp);
2267
- document.body.style.cursor = "";
2268
- if (!d) return;
2269
- setSizeDraft({});
2270
- mutate((n) => {
2271
- if (d.kind === "col") {
2272
- const c = n.columns.find((x) => x.id === d.id);
2273
- if (c) c.width = Math.round(d.last);
2274
- } else {
2275
- const r = n.rows.find((x) => x.id === d.id);
2276
- if (r) r.height = Math.round(d.last);
2277
- }
2278
- });
2279
- };
2280
- window.addEventListener("mousemove", onMove);
2281
- window.addEventListener("mouseup", onUp);
2282
- document.body.style.cursor = kind === "col" ? "col-resize" : "row-resize";
2283
- };
2284
- const colWidth = (col) => sizeDraft.col && sizeDraft.col[col.id] || col.width || void 0;
2285
- const reorder = (kind, fromId, toId, after) => mutate((n) => {
2286
- const arr = kind === "col" ? n.columns : n.rows;
2287
- const i = arr.findIndex((x) => x.id === fromId);
2288
- if (i < 0 || fromId === toId) return;
2289
- const [item] = arr.splice(i, 1);
2290
- let j = arr.findIndex((x) => x.id === toId);
2291
- if (j < 0) {
2292
- arr.splice(i, 0, item);
2293
- return;
2294
- }
2295
- if (after) j += 1;
2296
- arr.splice(j, 0, item);
2297
- });
2298
- const dndProps = (kind, id) => readOnly ? {} : {
2299
- draggable: true,
2300
- onDragStart: (e) => {
2301
- if (e.target.closest && e.target.closest(".shg-resize-col, .shg-resize-row, input, button")) {
2302
- e.preventDefault();
2303
- return;
2304
- }
2305
- e.dataTransfer.effectAllowed = "move";
2306
- e.dataTransfer.setData("text/plain", `${kind}:${id}`);
2307
- setDnd({ kind, id });
2308
- },
2309
- onDragOver: (e) => {
2310
- if (!dnd || dnd.kind !== kind || dnd.id === id) return;
2311
- e.preventDefault();
2312
- const r = e.currentTarget.getBoundingClientRect();
2313
- const after = kind === "col" ? e.clientX > r.x + r.width / 2 : e.clientY > r.y + r.height / 2;
2314
- setDropAt((d) => d && d.id === id && d.after === after ? d : { kind, id, after });
2315
- },
2316
- onDrop: (e) => {
2317
- e.preventDefault();
2318
- if (dnd && dnd.kind === kind && dnd.id !== id) {
2319
- const r = e.currentTarget.getBoundingClientRect();
2320
- const after = kind === "col" ? e.clientX > r.x + r.width / 2 : e.clientY > r.y + r.height / 2;
2321
- reorder(kind, dnd.id, id, after);
2322
- }
2323
- setDnd(null);
2324
- setDropAt(null);
2325
- },
2326
- onDragEnd: () => {
2327
- setDnd(null);
2328
- setDropAt(null);
2329
- }
2330
- };
2331
- const dndClass = (kind, id) => {
2332
- let cls = "";
2333
- if (dnd && dnd.kind === kind && dnd.id === id) cls += " shg-dragging";
2334
- if (dropAt && dropAt.kind === kind && dropAt.id === id) {
2335
- cls += dropAt.after ? kind === "col" ? " shg-drop-after" : " shg-drop-below" : kind === "col" ? " shg-drop-before" : " shg-drop-above";
2336
- }
2337
- return cls;
2338
- };
2339
- const numW = Math.max(48, 30 + String(rows.length || 1).length * 9);
2340
- const numStyle = { width: numW, minWidth: numW, maxWidth: numW };
2341
- const rowHeight = (row) => sizeDraft.row && sizeDraft.row[row.id] || row.height || void 0;
2342
- useEffect8(() => {
2343
- if (editing && inputRef.current) inputRef.current.focus();
2344
- }, [editing]);
2345
- const mutate = (fn) => {
2346
- if (readOnly || !onChange) return;
2347
- const next = JSON.parse(JSON.stringify(sheet));
2348
- fn(next);
2349
- onChange(next);
2350
- };
2351
- const setCell = (rowId, colId, value) => mutate((n) => {
2352
- n.cells = n.cells || {};
2353
- const k = cellKey(rowId, colId);
2354
- const col = (n.columns || []).find((c) => c.id === colId);
2355
- const prev = n.cells[k];
2356
- n.cells[k] = isComputed(col) && prev ? { ...prev, value } : { value };
2357
- });
2358
- const openEdit = (rowId, col, anchorEl) => {
2359
- if (readOnly) return;
2360
- if (!isEditable(col)) return;
2361
- if (col.type === "checkbox") {
2362
- const cur = cells[cellKey(rowId, col.id)];
2363
- setCell(rowId, col.id, !(cur && cur.value));
2364
- return;
2365
- }
2366
- const c = cells[cellKey(rowId, col.id)];
2367
- const v = c?.value;
2368
- if (col.type === "tags") setDraft(Array.isArray(v) ? v.join(", ") : v || "");
2369
- else if (col.type === "resource") setDraft(v && typeof v === "object" ? v : { kind: "sheet", name: "", id: "", url: "" });
2370
- else setDraft(v == null ? "" : String(v));
2371
- setEditing({ rowId, colId: col.id, type: col.type, rect: anchorEl?.getBoundingClientRect?.() || null });
2372
- onActiveCell && onActiveCell(cellKey(rowId, col.id));
2373
- };
2374
- const commitEdit = () => {
2375
- onActiveCell && onActiveCell(null);
2376
- if (!editing) return;
2377
- const { rowId, colId, type } = editing;
2378
- let value = draft;
2379
- if (type === "number") value = draft === "" ? null : Number(draft);
2380
- else if (type === "tags") value = draft ? draft.split(",").map((s) => s.trim()).filter(Boolean) : [];
2381
- setCell(rowId, colId, value);
2382
- setEditing(null);
2383
- };
2384
- const addColumn = () => mutate((n) => {
2385
- n.columns.push({ id: uid("col"), name: `Column ${n.columns.length + 1}`, type: "text" });
2386
- });
2387
- const addRow = () => mutate((n) => {
2388
- n.rows.push({ id: uid("row") });
2389
- });
2390
- const deleteColumn = (colId) => mutate((n) => {
2391
- n.columns = n.columns.filter((c) => c.id !== colId);
2392
- for (const k of Object.keys(n.cells || {})) if (k.endsWith(`:${colId}`)) delete n.cells[k];
2393
- });
2394
- const deleteRow = (rowId) => mutate((n) => {
2395
- n.rows = n.rows.filter((r) => r.id !== rowId);
2396
- for (const k of Object.keys(n.cells || {})) if (k.startsWith(`${rowId}:`)) delete n.cells[k];
2397
- });
2398
- const renameColumn = (colId, name) => mutate((n) => {
2399
- const c = n.columns.find((x) => x.id === colId);
2400
- if (c) c.name = name;
2401
- });
2402
- const configureColumn = (colId, patch) => mutate((n) => {
2403
- const c = n.columns.find((x) => x.id === colId);
2404
- if (!c) return;
2405
- Object.assign(c, patch);
2406
- if (patch.type) {
2407
- for (const d of columnTypes) if (d.configKey && d.type !== patch.type) delete c[d.configKey];
2408
- }
2409
- });
2410
- const renderEditor = (col) => {
2411
- if (col.type === "resource") {
2412
- const d = typeof draft === "object" && draft ? draft : { kind: "sheet" };
2413
- const set = (k, v) => setDraft({ ...d, [k]: v });
2414
- return /* @__PURE__ */ jsx13(
2415
- PopPortal,
2416
- {
2417
- anchor: editing.rect,
2418
- width: 240,
2419
- estHeight: 230,
2420
- className: "shg-select-pop shg-ref-pop",
2421
- onClose: () => setEditing(null),
2422
- children: /* @__PURE__ */ jsxs12("div", { onClick: (e) => e.stopPropagation(), children: [
2423
- /* @__PURE__ */ jsx13("select", { className: "shg-menu-input", value: d.kind || "sheet", onChange: (e) => set("kind", e.target.value), children: RESOURCE_KINDS.map((k) => /* @__PURE__ */ jsx13("option", { value: k, children: k }, k)) }),
2424
- /* @__PURE__ */ jsx13("input", { className: "shg-menu-input", placeholder: "Name", value: d.name || "", onChange: (e) => set("name", e.target.value) }),
2425
- /* @__PURE__ */ jsx13("input", { className: "shg-menu-input", placeholder: "Resource id (e.g. sheet.\u2026)", value: d.id || "", onChange: (e) => set("id", e.target.value) }),
2426
- /* @__PURE__ */ jsx13("input", { className: "shg-menu-input", placeholder: "or URL", value: d.url || "", onChange: (e) => set("url", e.target.value) }),
2427
- /* @__PURE__ */ jsxs12("div", { className: "shg-menu-actions", children: [
2428
- /* @__PURE__ */ jsx13("button", { className: "shg-pop-clear", onClick: () => {
2429
- setCell(editing.rowId, editing.colId, null);
2430
- setEditing(null);
2431
- }, children: "Clear" }),
2432
- /* @__PURE__ */ jsx13("button", { className: "shg-menu-apply", onClick: () => {
2433
- setCell(editing.rowId, editing.colId, d);
2434
- setEditing(null);
2435
- }, children: "Set" })
2436
- ] })
2437
- ] })
2438
- }
2439
- );
2440
- }
2441
- if (col.type === "select") {
2442
- const opts = normOptions(col.options);
2443
- return /* @__PURE__ */ jsxs12(
2444
- PopPortal,
2445
- {
2446
- anchor: editing.rect,
2447
- width: 190,
2448
- estHeight: 40 + opts.length * 30,
2449
- className: "shg-select-pop",
2450
- onClose: () => setEditing(null),
2451
- children: [
2452
- opts.length === 0 && /* @__PURE__ */ jsx13("div", { className: "shg-pop-note", children: "No options yet \u2014 add them in the column menu." }),
2453
- opts.map((o) => /* @__PURE__ */ jsx13(
2454
- "button",
2455
- {
2456
- className: "shg-pill shg-pill-btn",
2457
- style: { background: o.color },
2458
- onClick: (e) => {
2459
- e.stopPropagation();
2460
- setCell(editing.rowId, editing.colId, o.label);
2461
- setEditing(null);
2462
- },
2463
- children: o.label
2464
- },
2465
- o.label
2466
- )),
2467
- /* @__PURE__ */ jsx13(
2468
- "button",
2469
- {
2470
- className: "shg-pop-clear",
2471
- onClick: (e) => {
2472
- e.stopPropagation();
2473
- setCell(editing.rowId, editing.colId, null);
2474
- setEditing(null);
2475
- },
2476
- children: "Clear"
2477
- }
2478
- )
2479
- ]
2480
- }
2481
- );
2482
- }
2483
- const inputType = col.type === "date" ? "date" : col.type === "number" ? "number" : "text";
2484
- return /* @__PURE__ */ jsx13(
2485
- "input",
2486
- {
2487
- ref: inputRef,
2488
- className: "shg-input",
2489
- type: inputType,
2490
- value: draft,
2491
- placeholder: col.type === "tags" ? "tag, tag, \u2026" : "",
2492
- onChange: (e) => setDraft(e.target.value),
2493
- onBlur: commitEdit,
2494
- onKeyDown: (e) => {
2495
- if (e.key === "Enter") commitEdit();
2496
- if (e.key === "Escape") setEditing(null);
2497
- }
2498
- }
2499
- );
2500
- };
2501
- return /* @__PURE__ */ jsx13("div", { className: "shg", children: /* @__PURE__ */ jsx13("div", { className: "shg-scroll", children: /* @__PURE__ */ jsxs12("table", { className: "shg-table", children: [
2502
- /* @__PURE__ */ jsx13("thead", { children: /* @__PURE__ */ jsxs12("tr", { children: [
2503
- /* @__PURE__ */ jsx13("th", { className: "shg-corner", style: numStyle }),
2504
- columns.map((col) => /* @__PURE__ */ jsxs12(
2505
- "th",
2506
- {
2507
- className: "shg-col" + (isComputed(col) ? " shg-col-compute" : "") + dndClass("col", col.id),
2508
- style: colWidth(col) ? { width: colWidth(col), minWidth: colWidth(col), maxWidth: colWidth(col) } : void 0,
2509
- ...dndProps("col", col.id),
2510
- children: [
2511
- !readOnly && /* @__PURE__ */ jsx13("span", { className: "shg-resize-col", onMouseDown: (e) => startResize(e, "col", col.id, colWidth(col) || e.currentTarget.closest("th").offsetWidth) }),
2512
- /* @__PURE__ */ jsx13("div", { className: "shg-col-h", children: /* @__PURE__ */ jsx13(
2513
- ColumnHeader,
2514
- {
2515
- col,
2516
- columns,
2517
- readOnly,
2518
- desc: descOf(col.type),
2519
- columnTypes,
2520
- renderColumnConfig,
2521
- menuOpen: menuCol?.id === col.id,
2522
- menuAnchor: menuCol?.id === col.id ? menuCol.rect : null,
2523
- onMenu: (e) => setMenuCol(menuCol?.id === col.id ? null : { id: col.id, rect: e.currentTarget.getBoundingClientRect() }),
2524
- onCloseMenu: () => setMenuCol(null),
2525
- onRename: renameColumn,
2526
- onConfigure: configureColumn,
2527
- onDelete: () => {
2528
- setMenuCol(null);
2529
- deleteColumn(col.id);
2530
- },
2531
- onRun: isComputed(col) && onRunColumn ? () => onRunColumn(col.id) : null
2532
- }
2533
- ) })
2534
- ]
2535
- },
2536
- col.id
2537
- )),
2538
- !readOnly && /* @__PURE__ */ jsx13("th", { className: "shg-add-col", children: /* @__PURE__ */ jsx13("button", { className: "shg-add", onClick: addColumn, title: "Add column", children: "+" }) })
2539
- ] }) }),
2540
- /* @__PURE__ */ jsxs12("tbody", { children: [
2541
- rows.map((row, ri) => /* @__PURE__ */ jsxs12(
2542
- "tr",
2543
- {
2544
- "data-row-id": row.id,
2545
- style: {
2546
- ...rowHeight(row) ? { height: rowHeight(row) } : null,
2547
- "--shg-clamp": Math.max(1, Math.floor(((rowHeight(row) || 34) - 10) / 18))
2548
- },
2549
- children: [
2550
- /* @__PURE__ */ jsxs12(
2551
- "td",
2552
- {
2553
- className: "shg-rownum" + dndClass("row", row.id),
2554
- style: numStyle,
2555
- title: "Drag to reorder",
2556
- ...dndProps("row", row.id),
2557
- children: [
2558
- /* @__PURE__ */ jsx13("span", { children: ri + 1 }),
2559
- !readOnly && /* @__PURE__ */ jsx13("button", { className: "shg-rowdel", onClick: () => deleteRow(row.id), title: "Delete row", children: "\xD7" }),
2560
- !readOnly && /* @__PURE__ */ jsx13("span", { className: "shg-resize-row", onMouseDown: (e) => startResize(e, "row", row.id, rowHeight(row) || e.currentTarget.closest("tr").offsetHeight) })
2561
- ]
2562
- }
2563
- ),
2564
- columns.map((col) => {
2565
- const c = cells[cellKey(row.id, col.id)] || {};
2566
- const computed = isComputed(col);
2567
- const isEditing = editing && editing.rowId === row.id && editing.colId === col.id;
2568
- const peer = peerMarks && peerMarks[cellKey(row.id, col.id)];
2569
- const custom = renderCell && renderCell({
2570
- cell: c,
2571
- column: col,
2572
- row,
2573
- rowIndex: ri,
2574
- sheet,
2575
- computed,
2576
- width: colWidth(col),
2577
- height: rowHeight(row),
2578
- editing: !!isEditing,
2579
- readOnly,
2580
- setCell: (v) => setCell(row.id, col.id, v),
2581
- runCell: onRunCell && !readOnly ? () => onRunCell(row.id, col.id) : null
2582
- });
2583
- return /* @__PURE__ */ jsxs12(
2584
- "td",
2585
- {
2586
- "data-col-id": col.id,
2587
- className: "shg-cell" + (computed ? " shg-cell-compute" : "") + (c.status && computed ? ` shg-cell-${c.status}` : "") + (peer ? " shg-cell-peer" : ""),
2588
- style: peer ? { boxShadow: `inset 0 0 0 2px ${peer.color}` } : void 0,
2589
- onClick: (e) => {
2590
- if (!isEditing) openEdit(row.id, col, e.currentTarget);
2591
- },
2592
- title: c.error || "",
2593
- children: [
2594
- !readOnly && /* @__PURE__ */ jsxs12(Fragment8, { children: [
2595
- /* @__PURE__ */ jsx13(
2596
- "span",
2597
- {
2598
- className: "shg-resize-col shg-resize-in-cell",
2599
- onClick: (e) => e.stopPropagation(),
2600
- onMouseDown: (e) => startResize(
2601
- e,
2602
- "col",
2603
- col.id,
2604
- colWidth(col) || e.currentTarget.closest("td").offsetWidth
2605
- )
2606
- }
2607
- ),
2608
- /* @__PURE__ */ jsx13(
2609
- "span",
2610
- {
2611
- className: "shg-resize-row shg-resize-in-cell",
2612
- onClick: (e) => e.stopPropagation(),
2613
- onMouseDown: (e) => startResize(
2614
- e,
2615
- "row",
2616
- row.id,
2617
- rowHeight(row) || e.currentTarget.closest("tr").offsetHeight
2618
- )
2619
- }
2620
- )
2621
- ] }),
2622
- peer && /* @__PURE__ */ jsx13("span", { className: "shg-peer-flag", style: { background: peer.color }, children: peer.name }),
2623
- isEditing ? renderEditor(col) : /* @__PURE__ */ jsx13("div", { className: "shg-val", children: custom !== void 0 ? custom : /* @__PURE__ */ jsxs12(Fragment8, { children: [
2624
- computed && /* @__PURE__ */ jsx13(StatusDot, { status: c.status }),
2625
- /* @__PURE__ */ jsx13(CellValue, { cell: c, col, fetchBlobUrl, onOpenResource }),
2626
- computed && !readOnly && onRunCell && /* @__PURE__ */ jsx13(
2627
- "button",
2628
- {
2629
- className: "shg-runcell",
2630
- title: "Run this cell",
2631
- onClick: (e) => {
2632
- e.stopPropagation();
2633
- onRunCell(row.id, col.id);
2634
- },
2635
- children: "\u25B6"
2636
- }
2637
- )
2638
- ] }) })
2639
- ]
2640
- },
2641
- col.id
2642
- );
2643
- }),
2644
- !readOnly && /* @__PURE__ */ jsx13("td", { className: "shg-pad" })
2645
- ]
2646
- },
2647
- row.id
2648
- )),
2649
- !readOnly && /* @__PURE__ */ jsxs12("tr", { className: "shg-ghost-row", onClick: addRow, children: [
2650
- /* @__PURE__ */ jsx13("td", { className: "shg-rownum shg-ghost-num", style: numStyle, children: "+" }),
2651
- /* @__PURE__ */ jsx13("td", { className: "shg-ghost-cell", colSpan: columns.length + 1, children: "New row" })
2652
- ] })
2653
- ] })
2654
- ] }) }) });
2655
- }
2656
- function ColumnHeader({
2657
- col,
2658
- columns,
2659
- readOnly,
2660
- desc,
2661
- columnTypes,
2662
- renderColumnConfig,
2663
- menuOpen,
2664
- menuAnchor,
2665
- onMenu,
2666
- onCloseMenu,
2667
- onRename,
2668
- onConfigure,
2669
- onDelete,
2670
- onRun
2671
- }) {
2672
- const [editing, setEditing] = useState8(false);
2673
- const [name, setName] = useState8(col.name);
2674
- useEffect8(() => setName(col.name), [col.name]);
2675
- const badge = desc.badge ? desc.badge(col) : void 0;
2676
- return /* @__PURE__ */ jsxs12("div", { className: "shg-colhdr", children: [
2677
- /* @__PURE__ */ jsxs12("div", { className: "shg-colhdr-main", children: [
2678
- editing && !readOnly ? /* @__PURE__ */ jsx13(
2679
- "input",
2680
- {
2681
- className: "shg-colname-input",
2682
- value: name,
2683
- autoFocus: true,
2684
- onChange: (e) => setName(e.target.value),
2685
- onBlur: () => {
2686
- setEditing(false);
2687
- if (name.trim() && name !== col.name) onRename(col.id, name.trim());
2688
- },
2689
- onKeyDown: (e) => {
2690
- if (e.key === "Enter") e.target.blur();
2691
- }
2692
- }
2693
- ) : /* @__PURE__ */ jsx13("span", { className: "shg-colname", onDoubleClick: () => !readOnly && setEditing(true), title: col.name, children: col.name }),
2694
- /* @__PURE__ */ jsxs12("span", { className: "shg-coltype" + (desc.computed ? " compute" : ""), children: [
2695
- desc.label || col.type,
2696
- badge ? ` \xB7 ${badge}` : ""
2697
- ] })
2698
- ] }),
2699
- !readOnly && /* @__PURE__ */ jsxs12("div", { className: "shg-colhdr-tools", children: [
2700
- onRun && /* @__PURE__ */ jsx13("button", { className: "shg-colrun", onClick: onRun, title: "Run this column", children: "\u25B6 Run" }),
2701
- /* @__PURE__ */ jsx13("button", { className: "shg-colmenu-btn", onClick: (e) => onMenu(e), title: "Column settings", children: "\u22EF" })
2702
- ] }),
2703
- menuOpen && !readOnly && /* @__PURE__ */ jsx13(
2704
- ColumnMenu,
2705
- {
2706
- col,
2707
- columns,
2708
- anchor: menuAnchor,
2709
- columnTypes,
2710
- renderColumnConfig,
2711
- onApply: (patch) => {
2712
- onConfigure(col.id, patch);
2713
- onCloseMenu();
2714
- },
2715
- onDelete,
2716
- onClose: onCloseMenu
2717
- }
2718
- )
2719
- ] });
2720
- }
2721
- function ColumnMenu({ col, columns, anchor, columnTypes, renderColumnConfig, onApply, onDelete, onClose }) {
2722
- const [type, setType] = useState8(col.type || "text");
2723
- const [optText, setOptText] = useState8(
2724
- normOptions(col.options).map((o) => o.label).join("\n")
2725
- );
2726
- const comp = col.compute || {};
2727
- const [kind, setKind] = useState8(comp.kind || "prompt");
2728
- const [prompt, setPrompt] = useState8(comp.prompt || "");
2729
- const [harnessId, setHarnessId] = useState8(comp.harness_id || "");
2730
- const [wfSlug, setWfSlug] = useState8(comp.workflow_slug || "");
2731
- const [outKey, setOutKey] = useState8(comp.output_key || "");
2732
- const [deps, setDeps] = useState8(new Set(comp.deps || []));
2733
- const others = columns.filter((c) => c.id !== col.id);
2734
- const toggleDep = (id) => setDeps((s) => {
2735
- const n = new Set(s);
2736
- if (n.has(id)) n.delete(id);
2737
- else n.add(id);
2738
- return n;
2739
- });
2740
- const apply = () => {
2741
- const patch = { type };
2742
- if (type === "select" || type === "tags") {
2743
- patch.options = optText.split("\n").map((s) => s.trim()).filter(Boolean);
2744
- }
2745
- if (type === "compute") {
2746
- const compute = { kind, deps: [...deps] };
2747
- if (kind === "prompt") compute.prompt = prompt;
2748
- if (kind === "harness") {
2749
- compute.harness_id = harnessId;
2750
- compute.prompt = prompt;
2751
- }
2752
- if (kind === "workflow") {
2753
- compute.workflow_slug = wfSlug;
2754
- compute.output_key = outKey;
2755
- }
2756
- patch.compute = compute;
2757
- }
2758
- onApply(patch);
2759
- };
2760
- const custom = renderColumnConfig && renderColumnConfig({
2761
- column: col,
2762
- columns,
2763
- type,
2764
- applyPatch: (patch) => onApply({ type, ...patch }),
2765
- deleteColumn: onDelete,
2766
- close: onClose
2767
- });
2768
- const desc = columnTypes.find((t) => t.type === type) || {};
2769
- return /* @__PURE__ */ jsx13(
2770
- PopPortal,
2771
- {
2772
- anchor,
2773
- width: desc.configWidth || 250,
2774
- estHeight: desc.configHeight || 340,
2775
- className: "shg-menu",
2776
- onClose,
2777
- children: /* @__PURE__ */ jsxs12("div", { onClick: (e) => e.stopPropagation(), children: [
2778
- /* @__PURE__ */ jsxs12("label", { className: "shg-menu-lbl", children: [
2779
- "Type",
2780
- /* @__PURE__ */ jsx13("select", { className: "shg-menu-input", value: type, onChange: (e) => setType(e.target.value), children: columnTypes.map((t) => /* @__PURE__ */ jsx13("option", { value: t.type, children: t.label }, t.type)) })
2781
- ] }),
2782
- (type === "select" || type === "tags") && /* @__PURE__ */ jsxs12("label", { className: "shg-menu-lbl", children: [
2783
- "Options (one per line)",
2784
- /* @__PURE__ */ jsx13(
2785
- "textarea",
2786
- {
2787
- className: "shg-menu-input",
2788
- rows: 3,
2789
- value: optText,
2790
- onChange: (e) => setOptText(e.target.value),
2791
- placeholder: "Todo\nDoing\nDone"
2792
- }
2793
- )
2794
- ] }),
2795
- custom !== void 0 ? custom : /* @__PURE__ */ jsxs12(Fragment8, { children: [
2796
- type === "compute" && /* @__PURE__ */ jsxs12(Fragment8, { children: [
2797
- /* @__PURE__ */ jsxs12("label", { className: "shg-menu-lbl", children: [
2798
- "Runs",
2799
- /* @__PURE__ */ jsx13("select", { className: "shg-menu-input", value: kind, onChange: (e) => setKind(e.target.value), children: COMPUTE_KINDS.map((k) => /* @__PURE__ */ jsx13("option", { value: k.kind, children: k.label }, k.kind)) })
2800
- ] }),
2801
- (kind === "prompt" || kind === "harness") && /* @__PURE__ */ jsxs12("label", { className: "shg-menu-lbl", children: [
2802
- "Prompt \u2014 reference columns as ",
2803
- "{{Name}}",
2804
- /* @__PURE__ */ jsx13(
2805
- "textarea",
2806
- {
2807
- className: "shg-menu-input",
2808
- rows: 3,
2809
- value: prompt,
2810
- onChange: (e) => setPrompt(e.target.value),
2811
- placeholder: "Summarize {{Company}} in one line"
2812
- }
2813
- )
2814
- ] }),
2815
- kind === "harness" && /* @__PURE__ */ jsxs12("label", { className: "shg-menu-lbl", children: [
2816
- "Agent id",
2817
- /* @__PURE__ */ jsx13("input", { className: "shg-menu-input", value: harnessId, onChange: (e) => setHarnessId(e.target.value), placeholder: "chrn_\u2026" })
2818
- ] }),
2819
- kind === "workflow" && /* @__PURE__ */ jsxs12(Fragment8, { children: [
2820
- /* @__PURE__ */ jsxs12("label", { className: "shg-menu-lbl", children: [
2821
- "Workflow id",
2822
- /* @__PURE__ */ jsx13("input", { className: "shg-menu-input", value: wfSlug, onChange: (e) => setWfSlug(e.target.value), placeholder: "my-workflow" })
2823
- ] }),
2824
- /* @__PURE__ */ jsxs12("label", { className: "shg-menu-lbl", children: [
2825
- "Output key (optional)",
2826
- /* @__PURE__ */ jsx13("input", { className: "shg-menu-input", value: outKey, onChange: (e) => setOutKey(e.target.value), placeholder: "summary" })
2827
- ] })
2828
- ] }),
2829
- others.length > 0 && /* @__PURE__ */ jsxs12("div", { className: "shg-menu-lbl", children: [
2830
- "Reads columns",
2831
- /* @__PURE__ */ jsx13("div", { className: "shg-menu-deps", children: others.map((c) => /* @__PURE__ */ jsxs12("label", { className: "shg-menu-dep", children: [
2832
- /* @__PURE__ */ jsx13("input", { type: "checkbox", checked: deps.has(c.id), onChange: () => toggleDep(c.id) }),
2833
- " ",
2834
- c.name
2835
- ] }, c.id)) })
2836
- ] })
2837
- ] }),
2838
- /* @__PURE__ */ jsxs12("div", { className: "shg-menu-actions", children: [
2839
- /* @__PURE__ */ jsx13("button", { className: "shg-menu-del", onClick: onDelete, children: "Delete column" }),
2840
- /* @__PURE__ */ jsx13("button", { className: "shg-menu-apply", onClick: apply, children: "Apply" })
2841
- ] })
2842
- ] })
2843
- ] })
2844
- }
2845
- );
2846
- }
2847
- function fitRowHeights(container, { rowIds, min = 34, max = 320, padding = 12 } = {}) {
2848
- if (!container) return {};
2849
- const out = {};
2850
- const rows = container.querySelectorAll("tr[data-row-id]");
2851
- for (const tr of rows) {
2852
- const id = tr.getAttribute("data-row-id");
2853
- if (rowIds && !rowIds.includes(id)) continue;
2854
- let tallest = 0;
2855
- for (const cell of tr.querySelectorAll("td[data-col-id] .shg-val")) {
2856
- tallest = Math.max(tallest, cell.scrollHeight);
2857
- }
2858
- if (tallest) out[id] = Math.min(max, Math.max(min, Math.round(tallest + padding)));
2859
- }
2860
- return out;
2861
- }
2862
- function defaultCellText(cell) {
2863
- const v = cell?.value;
2864
- if (v == null) return "";
2865
- if (Array.isArray(v)) return v.join(", ");
2866
- if (typeof v === "object") return JSON.stringify(v);
2867
- return String(v);
2868
- }
2869
- function sheetToDelimited(sheet, sep = ",", { cellText = defaultCellText } = {}) {
2870
- const cols = sheet?.columns || [];
2871
- const rows = sheet?.rows || [];
2872
- const cells = sheet?.cells || {};
2873
- const esc = (s) => {
2874
- if (sep === "," && /[",\n]/.test(s)) return `"${s.replace(/"/g, '""')}"`;
2875
- return s;
2876
- };
2877
- const header = cols.map((c) => esc(c.name)).join(sep);
2878
- const body = rows.map((r) => cols.map((c) => esc(String(cellText(cells[cellKey(r.id, c.id)], c) ?? ""))).join(sep));
2879
- return [header, ...body].join("\n");
2880
- }
2881
- function defaultCellValue(cell) {
2882
- const v = cell?.value;
2883
- if (v == null) return "";
2884
- if (Array.isArray(v)) return v.join(", ");
2885
- if (typeof v === "object") return JSON.stringify(v);
2886
- return v;
2887
- }
2888
- function sheetToAoA(sheet, { cellText = defaultCellValue } = {}) {
2889
- const cols = sheet?.columns || [];
2890
- const rows = sheet?.rows || [];
2891
- const cells = sheet?.cells || {};
2892
- return [
2893
- cols.map((c) => c.name),
2894
- ...rows.map((r) => cols.map((c) => cellText(cells[cellKey(r.id, c.id)], c) ?? ""))
2895
- ];
2896
- }
2897
-
2898
2044
  // src/components/FileTypeIcon.jsx
2899
- import { useEffect as useEffect9, useState as useState9 } from "react";
2900
- import { jsx as jsx14 } from "react/jsx-runtime";
2045
+ import { useEffect as useEffect7, useState as useState9 } from "react";
2046
+ import { jsx as jsx11 } from "react/jsx-runtime";
2901
2047
  function extOf(name) {
2902
2048
  const m = String(name || "").toLowerCase().match(/\.([a-z0-9]+)$/);
2903
2049
  return m ? m[1] : "";
@@ -2907,7 +2053,7 @@ var tried = false;
2907
2053
  function FileTypeIcon({ name, size = 36 }) {
2908
2054
  const [, force] = useState9(0);
2909
2055
  const ext = extOf(name);
2910
- useEffect9(() => {
2056
+ useEffect7(() => {
2911
2057
  if (tried || mod) return;
2912
2058
  tried = true;
2913
2059
  import("react-file-icon").then((m) => {
@@ -2918,15 +2064,15 @@ function FileTypeIcon({ name, size = 36 }) {
2918
2064
  }, []);
2919
2065
  const box = { width: size, height: Math.round(size * 1.16), display: "inline-block", flex: "0 0 auto" };
2920
2066
  if (!mod) {
2921
- return /* @__PURE__ */ jsx14("span", { className: "uic-fileglyph", style: box, "aria-hidden": "true", children: /* @__PURE__ */ jsx14("span", { className: "uic-fileglyph-ext", children: (ext || "file").slice(0, 4) }) });
2067
+ return /* @__PURE__ */ jsx11("span", { className: "uic-fileglyph", style: box, "aria-hidden": "true", children: /* @__PURE__ */ jsx11("span", { className: "uic-fileglyph-ext", children: (ext || "file").slice(0, 4) }) });
2922
2068
  }
2923
2069
  const { FileIcon, defaultStyles } = mod;
2924
2070
  const style = defaultStyles?.[ext] || {};
2925
- return /* @__PURE__ */ jsx14("span", { style: box, children: /* @__PURE__ */ jsx14(FileIcon, { extension: ext || void 0, ...style }) });
2071
+ return /* @__PURE__ */ jsx11("span", { style: box, children: /* @__PURE__ */ jsx11(FileIcon, { extension: ext || void 0, ...style }) });
2926
2072
  }
2927
2073
 
2928
2074
  // src/components/FileCard.jsx
2929
- import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
2075
+ import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
2930
2076
  function subtitle(name, origin, bytes) {
2931
2077
  const parts = [(extOf(name) || "file").toUpperCase()];
2932
2078
  if (origin) parts.push(origin);
@@ -2944,7 +2090,7 @@ function FileCard({ name, origin = "output", bytes, onPreview, onDownload, class
2944
2090
  e.stopPropagation();
2945
2091
  onPreview();
2946
2092
  } : void 0;
2947
- return /* @__PURE__ */ jsxs13(
2093
+ return /* @__PURE__ */ jsxs10(
2948
2094
  "div",
2949
2095
  {
2950
2096
  className: "uic-filecard" + (open ? " is-clickable" : "") + (className ? " " + className : ""),
@@ -2959,12 +2105,12 @@ function FileCard({ name, origin = "output", bytes, onPreview, onDownload, class
2959
2105
  } : void 0,
2960
2106
  title: name,
2961
2107
  children: [
2962
- /* @__PURE__ */ jsx15("span", { className: "uic-filecard-ic", children: /* @__PURE__ */ jsx15(FileTypeIcon, { name, size: 32 }) }),
2963
- /* @__PURE__ */ jsxs13("span", { className: "uic-filecard-meta", children: [
2964
- /* @__PURE__ */ jsx15("span", { className: "uic-filecard-name", children: name }),
2965
- /* @__PURE__ */ jsx15("span", { className: "uic-filecard-sub", children: subtitle(name, origin, bytes) })
2108
+ /* @__PURE__ */ jsx12("span", { className: "uic-filecard-ic", children: /* @__PURE__ */ jsx12(FileTypeIcon, { name, size: 32 }) }),
2109
+ /* @__PURE__ */ jsxs10("span", { className: "uic-filecard-meta", children: [
2110
+ /* @__PURE__ */ jsx12("span", { className: "uic-filecard-name", children: name }),
2111
+ /* @__PURE__ */ jsx12("span", { className: "uic-filecard-sub", children: subtitle(name, origin, bytes) })
2966
2112
  ] }),
2967
- onDownload && /* @__PURE__ */ jsx15(
2113
+ onDownload && /* @__PURE__ */ jsx12(
2968
2114
  "button",
2969
2115
  {
2970
2116
  type: "button",
@@ -2975,18 +2121,18 @@ function FileCard({ name, origin = "output", bytes, onPreview, onDownload, class
2975
2121
  e.stopPropagation();
2976
2122
  onDownload();
2977
2123
  },
2978
- children: /* @__PURE__ */ jsx15(IcDownload, { size: 18 })
2124
+ children: /* @__PURE__ */ jsx12(IcDownload, { size: 18 })
2979
2125
  }
2980
2126
  ),
2981
- onPreview && /* @__PURE__ */ jsx15("button", { type: "button", className: "uic-filecard-open", "aria-label": `Preview ${name}`, onClick: open, children: "Preview" })
2127
+ onPreview && /* @__PURE__ */ jsx12("button", { type: "button", className: "uic-filecard-open", "aria-label": `Preview ${name}`, onClick: open, children: "Preview" })
2982
2128
  ]
2983
2129
  }
2984
2130
  );
2985
2131
  }
2986
2132
 
2987
2133
  // src/components/FilePreview.jsx
2988
- import { useEffect as useEffect10, useState as useState10 } from "react";
2989
- import { jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
2134
+ import { useEffect as useEffect8, useState as useState10 } from "react";
2135
+ import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
2990
2136
  var LANG = {
2991
2137
  js: "javascript",
2992
2138
  mjs: "javascript",
@@ -3062,11 +2208,11 @@ function delimitedToRows(text, sep) {
3062
2208
  });
3063
2209
  }
3064
2210
  function Grid({ rows }) {
3065
- if (!rows?.length) return /* @__PURE__ */ jsx16("div", { className: "uic-fp-empty", children: "This file is empty." });
2211
+ if (!rows?.length) return /* @__PURE__ */ jsx13("div", { className: "uic-fp-empty", children: "This file is empty." });
3066
2212
  const [head, ...body] = rows;
3067
- return /* @__PURE__ */ jsx16("div", { className: "uic-fp-sheet", children: /* @__PURE__ */ jsxs14("table", { children: [
3068
- /* @__PURE__ */ jsx16("thead", { children: /* @__PURE__ */ jsx16("tr", { children: head.map((c, i) => /* @__PURE__ */ jsx16("th", { children: c }, i)) }) }),
3069
- /* @__PURE__ */ jsx16("tbody", { children: body.map((r, i) => /* @__PURE__ */ jsx16("tr", { children: r.map((c, j) => /* @__PURE__ */ jsx16("td", { children: c }, j)) }, i)) })
2213
+ return /* @__PURE__ */ jsx13("div", { className: "uic-fp-sheet", children: /* @__PURE__ */ jsxs11("table", { children: [
2214
+ /* @__PURE__ */ jsx13("thead", { children: /* @__PURE__ */ jsx13("tr", { children: head.map((c, i) => /* @__PURE__ */ jsx13("th", { children: c }, i)) }) }),
2215
+ /* @__PURE__ */ jsx13("tbody", { children: body.map((r, i) => /* @__PURE__ */ jsx13("tr", { children: r.map((c, j) => /* @__PURE__ */ jsx13("td", { children: c }, j)) }, i)) })
3070
2216
  ] }) });
3071
2217
  }
3072
2218
  var defaultDownload = (url, name) => {
@@ -3091,7 +2237,7 @@ function FilePreview({
3091
2237
  const { url, name } = file || {};
3092
2238
  const [st, setSt] = useState10({ kind: "loading" });
3093
2239
  const [tab, setTab] = useState10(0);
3094
- useEffect10(() => {
2240
+ useEffect8(() => {
3095
2241
  if (!url) return void 0;
3096
2242
  let alive = true;
3097
2243
  let obj;
@@ -3153,11 +2299,11 @@ function FilePreview({
3153
2299
  };
3154
2300
  }, [url, name, fetchFile, officePdfUrl, parseWorkbook]);
3155
2301
  const download = () => onDownload ? onDownload(url, name) : defaultDownload(url, name);
3156
- return /* @__PURE__ */ jsxs14("aside", { className: "uic-fp", "aria-label": title || `Preview of ${name}`, children: [
3157
- /* @__PURE__ */ jsxs14("header", { className: "uic-fp-head", children: [
3158
- /* @__PURE__ */ jsx16("span", { className: "uic-fp-ic", children: /* @__PURE__ */ jsx16(FileTypeIcon, { name, size: 20 }) }),
3159
- /* @__PURE__ */ jsx16("span", { className: "uic-fp-name", title: name, children: name }),
3160
- /* @__PURE__ */ jsx16(
2302
+ return /* @__PURE__ */ jsxs11("aside", { className: "uic-fp", "aria-label": title || `Preview of ${name}`, children: [
2303
+ /* @__PURE__ */ jsxs11("header", { className: "uic-fp-head", children: [
2304
+ /* @__PURE__ */ jsx13("span", { className: "uic-fp-ic", children: /* @__PURE__ */ jsx13(FileTypeIcon, { name, size: 20 }) }),
2305
+ /* @__PURE__ */ jsx13("span", { className: "uic-fp-name", title: name, children: name }),
2306
+ /* @__PURE__ */ jsx13(
3161
2307
  "button",
3162
2308
  {
3163
2309
  type: "button",
@@ -3165,10 +2311,10 @@ function FilePreview({
3165
2311
  "aria-label": `Download ${name}`,
3166
2312
  title: "Download",
3167
2313
  onClick: download,
3168
- children: /* @__PURE__ */ jsx16(IcDownload, {})
2314
+ children: /* @__PURE__ */ jsx13(IcDownload, {})
3169
2315
  }
3170
2316
  ),
3171
- onClose && /* @__PURE__ */ jsx16(
2317
+ onClose && /* @__PURE__ */ jsx13(
3172
2318
  "button",
3173
2319
  {
3174
2320
  type: "button",
@@ -3176,22 +2322,22 @@ function FilePreview({
3176
2322
  "aria-label": "Close preview",
3177
2323
  title: "Close",
3178
2324
  onClick: onClose,
3179
- children: /* @__PURE__ */ jsx16(IcX, { size: 18 })
2325
+ children: /* @__PURE__ */ jsx13(IcX, { size: 18 })
3180
2326
  }
3181
2327
  )
3182
2328
  ] }),
3183
- /* @__PURE__ */ jsxs14("div", { className: "uic-fp-body", children: [
3184
- st.kind === "loading" && /* @__PURE__ */ jsx16("div", { className: "uic-fp-pad", children: /* @__PURE__ */ jsx16("span", { className: "uic-skel uic-fp-skel" }) }),
3185
- st.kind === "image" && st.objUrl && /* @__PURE__ */ jsx16("div", { className: "uic-fp-center", children: /* @__PURE__ */ jsx16("img", { className: "uic-fp-img", src: st.objUrl, alt: name }) }),
3186
- st.kind === "pdf" && st.objUrl && /* @__PURE__ */ jsx16("iframe", { className: "uic-fp-frame", src: st.objUrl, title: name }),
3187
- st.kind === "video" && st.objUrl && /* @__PURE__ */ jsx16("div", { className: "uic-fp-center", children: /* @__PURE__ */ jsx16("video", { className: "uic-fp-media", src: st.objUrl, controls: true }) }),
3188
- st.kind === "audio" && st.objUrl && /* @__PURE__ */ jsx16("div", { className: "uic-fp-center", children: /* @__PURE__ */ jsx16("audio", { src: st.objUrl, controls: true }) }),
3189
- st.kind === "markdown" && /* @__PURE__ */ jsx16("div", { className: "uic-fp-doc", children: renderMarkdown ? renderMarkdown(st.text || "") : /* @__PURE__ */ jsx16("pre", { className: "uic-fp-pre", children: st.text }) }),
3190
- st.kind === "code" && /* @__PURE__ */ jsx16(CodeBlock, { code: st.text || "", lang: LANG[extOf(name)] || "plaintext" }),
3191
- st.kind === "csv" && /* @__PURE__ */ jsx16(Grid, { rows: st.rows }),
3192
- st.kind === "sheet" && st.sheets && /* @__PURE__ */ jsxs14("div", { className: "uic-fp-xlsx", children: [
3193
- st.sheets[tab]?.filled ? /* @__PURE__ */ jsx16(Grid, { rows: st.sheets[tab].rows }) : /* @__PURE__ */ jsx16("div", { className: "uic-fp-empty", children: "This sheet is empty." }),
3194
- /* @__PURE__ */ jsx16("div", { className: "uic-fp-tabs", children: st.sheets.map((s, i) => /* @__PURE__ */ jsx16(
2329
+ /* @__PURE__ */ jsxs11("div", { className: "uic-fp-body", children: [
2330
+ st.kind === "loading" && /* @__PURE__ */ jsx13("div", { className: "uic-fp-pad", children: /* @__PURE__ */ jsx13("span", { className: "uic-skel uic-fp-skel" }) }),
2331
+ st.kind === "image" && st.objUrl && /* @__PURE__ */ jsx13("div", { className: "uic-fp-center", children: /* @__PURE__ */ jsx13("img", { className: "uic-fp-img", src: st.objUrl, alt: name }) }),
2332
+ st.kind === "pdf" && st.objUrl && /* @__PURE__ */ jsx13("iframe", { className: "uic-fp-frame", src: st.objUrl, title: name }),
2333
+ st.kind === "video" && st.objUrl && /* @__PURE__ */ jsx13("div", { className: "uic-fp-center", children: /* @__PURE__ */ jsx13("video", { className: "uic-fp-media", src: st.objUrl, controls: true }) }),
2334
+ st.kind === "audio" && st.objUrl && /* @__PURE__ */ jsx13("div", { className: "uic-fp-center", children: /* @__PURE__ */ jsx13("audio", { src: st.objUrl, controls: true }) }),
2335
+ st.kind === "markdown" && /* @__PURE__ */ jsx13("div", { className: "uic-fp-doc", children: renderMarkdown ? renderMarkdown(st.text || "") : /* @__PURE__ */ jsx13("pre", { className: "uic-fp-pre", children: st.text }) }),
2336
+ st.kind === "code" && /* @__PURE__ */ jsx13(CodeBlock, { code: st.text || "", lang: LANG[extOf(name)] || "plaintext" }),
2337
+ st.kind === "csv" && /* @__PURE__ */ jsx13(Grid, { rows: st.rows }),
2338
+ st.kind === "sheet" && st.sheets && /* @__PURE__ */ jsxs11("div", { className: "uic-fp-xlsx", children: [
2339
+ st.sheets[tab]?.filled ? /* @__PURE__ */ jsx13(Grid, { rows: st.sheets[tab].rows }) : /* @__PURE__ */ jsx13("div", { className: "uic-fp-empty", children: "This sheet is empty." }),
2340
+ /* @__PURE__ */ jsx13("div", { className: "uic-fp-tabs", children: st.sheets.map((s, i) => /* @__PURE__ */ jsx13(
3195
2341
  "button",
3196
2342
  {
3197
2343
  type: "button",
@@ -3203,10 +2349,10 @@ function FilePreview({
3203
2349
  s.name + i
3204
2350
  )) })
3205
2351
  ] }),
3206
- st.kind === "binary" && /* @__PURE__ */ jsx16("div", { className: "uic-fp-center", children: /* @__PURE__ */ jsxs14("div", { className: "uic-fp-fallback", children: [
3207
- /* @__PURE__ */ jsx16(FileTypeIcon, { name, size: 56 }),
3208
- /* @__PURE__ */ jsx16("p", { children: st.error || "No inline preview for this file type." }),
3209
- /* @__PURE__ */ jsx16("button", { type: "button", className: "uic-fp-dl", onClick: download, children: "Download" })
2352
+ st.kind === "binary" && /* @__PURE__ */ jsx13("div", { className: "uic-fp-center", children: /* @__PURE__ */ jsxs11("div", { className: "uic-fp-fallback", children: [
2353
+ /* @__PURE__ */ jsx13(FileTypeIcon, { name, size: 56 }),
2354
+ /* @__PURE__ */ jsx13("p", { children: st.error || "No inline preview for this file type." }),
2355
+ /* @__PURE__ */ jsx13("button", { type: "button", className: "uic-fp-dl", onClick: download, children: "Download" })
3210
2356
  ] }) })
3211
2357
  ] })
3212
2358
  ] });
@@ -3214,29 +2360,29 @@ function FilePreview({
3214
2360
 
3215
2361
  // src/components/form.jsx
3216
2362
  import { useId as useId2 } from "react";
3217
- import { jsx as jsx17, jsxs as jsxs15 } from "react/jsx-runtime";
2363
+ import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
3218
2364
  function Field({ label, hint, error, htmlFor, required, children, className = "" }) {
3219
- return /* @__PURE__ */ jsxs15("div", { className: "uic-field" + (error ? " is-error" : "") + (className ? " " + className : ""), children: [
3220
- label && /* @__PURE__ */ jsxs15("label", { className: "uic-field-label", htmlFor, children: [
2365
+ return /* @__PURE__ */ jsxs12("div", { className: "uic-field" + (error ? " is-error" : "") + (className ? " " + className : ""), children: [
2366
+ label && /* @__PURE__ */ jsxs12("label", { className: "uic-field-label", htmlFor, children: [
3221
2367
  label,
3222
- required && /* @__PURE__ */ jsx17("span", { className: "uic-field-req", "aria-hidden": "true", children: "*" })
2368
+ required && /* @__PURE__ */ jsx14("span", { className: "uic-field-req", "aria-hidden": "true", children: "*" })
3223
2369
  ] }),
3224
2370
  children,
3225
- error ? /* @__PURE__ */ jsx17("p", { className: "uic-field-err", children: error }) : hint ? /* @__PURE__ */ jsx17("p", { className: "uic-field-hint", children: hint }) : null
2371
+ error ? /* @__PURE__ */ jsx14("p", { className: "uic-field-err", children: error }) : hint ? /* @__PURE__ */ jsx14("p", { className: "uic-field-hint", children: hint }) : null
3226
2372
  ] });
3227
2373
  }
3228
2374
  function withField(Control) {
3229
2375
  return function Fielded({ label, hint, error, required, id, className, ...rest }) {
3230
2376
  const auto = useId2();
3231
2377
  const inputId = id || auto;
3232
- return /* @__PURE__ */ jsx17(Field, { label, hint, error, required, htmlFor: inputId, className, children: /* @__PURE__ */ jsx17(Control, { id: inputId, invalid: !!error, required, ...rest }) });
2378
+ return /* @__PURE__ */ jsx14(Field, { label, hint, error, required, htmlFor: inputId, className, children: /* @__PURE__ */ jsx14(Control, { id: inputId, invalid: !!error, required, ...rest }) });
3233
2379
  };
3234
2380
  }
3235
2381
  function BareInput({ invalid, ...rest }) {
3236
- return /* @__PURE__ */ jsx17("input", { className: "uic-input" + (invalid ? " is-error" : ""), "aria-invalid": invalid || void 0, ...rest });
2382
+ return /* @__PURE__ */ jsx14("input", { className: "uic-input" + (invalid ? " is-error" : ""), "aria-invalid": invalid || void 0, ...rest });
3237
2383
  }
3238
2384
  function BareTextarea({ invalid, rows = 4, ...rest }) {
3239
- return /* @__PURE__ */ jsx17(
2385
+ return /* @__PURE__ */ jsx14(
3240
2386
  "textarea",
3241
2387
  {
3242
2388
  className: "uic-input uic-textarea" + (invalid ? " is-error" : ""),
@@ -3247,42 +2393,42 @@ function BareTextarea({ invalid, rows = 4, ...rest }) {
3247
2393
  );
3248
2394
  }
3249
2395
  function BareSelect({ invalid, options = [], placeholder, ...rest }) {
3250
- return /* @__PURE__ */ jsxs15("span", { className: "uic-select-wrap", children: [
3251
- /* @__PURE__ */ jsxs15(
2396
+ return /* @__PURE__ */ jsxs12("span", { className: "uic-select-wrap", children: [
2397
+ /* @__PURE__ */ jsxs12(
3252
2398
  "select",
3253
2399
  {
3254
2400
  className: "uic-input uic-select" + (invalid ? " is-error" : ""),
3255
2401
  "aria-invalid": invalid || void 0,
3256
2402
  ...rest,
3257
2403
  children: [
3258
- placeholder && /* @__PURE__ */ jsx17("option", { value: "", children: placeholder }),
2404
+ placeholder && /* @__PURE__ */ jsx14("option", { value: "", children: placeholder }),
3259
2405
  options.map((o) => {
3260
2406
  const opt = typeof o === "string" ? { value: o, label: o } : o;
3261
- return /* @__PURE__ */ jsx17("option", { value: opt.value, disabled: opt.disabled, children: opt.label }, opt.value);
2407
+ return /* @__PURE__ */ jsx14("option", { value: opt.value, disabled: opt.disabled, children: opt.label }, opt.value);
3262
2408
  })
3263
2409
  ]
3264
2410
  }
3265
2411
  ),
3266
- /* @__PURE__ */ jsx17("span", { className: "uic-select-chev", "aria-hidden": "true", children: /* @__PURE__ */ jsx17(Chevron, { dir: "down", size: 14 }) })
2412
+ /* @__PURE__ */ jsx14("span", { className: "uic-select-chev", "aria-hidden": "true", children: /* @__PURE__ */ jsx14(Chevron, { dir: "down", size: 14 }) })
3267
2413
  ] });
3268
2414
  }
3269
2415
  var Input = withField(BareInput);
3270
2416
  var Textarea = withField(BareTextarea);
3271
2417
  var Select = withField(BareSelect);
3272
2418
  function FormActions({ children, align = "end", className = "" }) {
3273
- return /* @__PURE__ */ jsx17("div", { className: `uic-form-actions is-${align}${className ? " " + className : ""}`, children });
2419
+ return /* @__PURE__ */ jsx14("div", { className: `uic-form-actions is-${align}${className ? " " + className : ""}`, children });
3274
2420
  }
3275
2421
  function Button({ variant = "default", size = "md", type = "button", className = "", ...rest }) {
3276
- return /* @__PURE__ */ jsx17("button", { type, className: `uic-btn is-${variant} is-${size}${className ? " " + className : ""}`, ...rest });
2422
+ return /* @__PURE__ */ jsx14("button", { type, className: `uic-btn is-${variant} is-${size}${className ? " " + className : ""}`, ...rest });
3277
2423
  }
3278
2424
 
3279
2425
  // src/components/Carousel.jsx
3280
- import React9, { useCallback as useCallback5, useEffect as useEffect11, useRef as useRef8, useState as useState11 } from "react";
3281
- import { jsx as jsx18, jsxs as jsxs16 } from "react/jsx-runtime";
2426
+ import React7, { useCallback as useCallback5, useEffect as useEffect9, useRef as useRef7, useState as useState11 } from "react";
2427
+ import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
3282
2428
  var EDGE = 2;
3283
2429
  function Carousel(props) {
3284
2430
  const { label, step, children, classNames = {} } = props;
3285
- const ref = useRef8(null);
2431
+ const ref = useRef7(null);
3286
2432
  const [edges, setEdges] = useState11({ start: true, end: true, overflow: false });
3287
2433
  const measure = useCallback5(() => {
3288
2434
  const el = ref.current;
@@ -3294,7 +2440,7 @@ function Carousel(props) {
3294
2440
  end: el.scrollLeft >= el.scrollWidth - el.clientWidth - EDGE
3295
2441
  });
3296
2442
  }, []);
3297
- useEffect11(() => {
2443
+ useEffect9(() => {
3298
2444
  const el = ref.current;
3299
2445
  if (!el) return void 0;
3300
2446
  measure();
@@ -3308,8 +2454,8 @@ function Carousel(props) {
3308
2454
  if (!el) return;
3309
2455
  el.scrollBy({ left: dir * (step || Math.round(el.clientWidth * 0.9)), behavior: "smooth" });
3310
2456
  };
3311
- return /* @__PURE__ */ jsxs16("div", { className: ["uic-carousel-wrap", classNames.root || ""].filter(Boolean).join(" "), children: [
3312
- edges.overflow ? /* @__PURE__ */ jsx18(
2457
+ return /* @__PURE__ */ jsxs13("div", { className: ["uic-carousel-wrap", classNames.root || ""].filter(Boolean).join(" "), children: [
2458
+ edges.overflow ? /* @__PURE__ */ jsx15(
3313
2459
  "button",
3314
2460
  {
3315
2461
  type: "button",
@@ -3317,10 +2463,10 @@ function Carousel(props) {
3317
2463
  onClick: () => scroll(-1),
3318
2464
  disabled: edges.start,
3319
2465
  "aria-label": `Scroll ${label} left`,
3320
- children: /* @__PURE__ */ jsx18(Chevron, { dir: "left" })
2466
+ children: /* @__PURE__ */ jsx15(Chevron, { dir: "left" })
3321
2467
  }
3322
2468
  ) : null,
3323
- /* @__PURE__ */ jsx18(
2469
+ /* @__PURE__ */ jsx15(
3324
2470
  "div",
3325
2471
  {
3326
2472
  className: ["uic-carousel", classNames.viewport || ""].filter(Boolean).join(" "),
@@ -3331,7 +2477,7 @@ function Carousel(props) {
3331
2477
  children
3332
2478
  }
3333
2479
  ),
3334
- edges.overflow ? /* @__PURE__ */ jsx18(
2480
+ edges.overflow ? /* @__PURE__ */ jsx15(
3335
2481
  "button",
3336
2482
  {
3337
2483
  type: "button",
@@ -3339,42 +2485,42 @@ function Carousel(props) {
3339
2485
  onClick: () => scroll(1),
3340
2486
  disabled: edges.end,
3341
2487
  "aria-label": `Scroll ${label} right`,
3342
- children: /* @__PURE__ */ jsx18(Chevron, { dir: "right" })
2488
+ children: /* @__PURE__ */ jsx15(Chevron, { dir: "right" })
3343
2489
  }
3344
2490
  ) : null
3345
2491
  ] });
3346
2492
  }
3347
2493
 
3348
2494
  // src/components/Card.jsx
3349
- import React10 from "react";
3350
- import { jsx as jsx19, jsxs as jsxs17 } from "react/jsx-runtime";
2495
+ import React8 from "react";
2496
+ import { jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
3351
2497
  function Card(props) {
3352
2498
  const { art, title, subtitle: subtitle2, onClick, selected = false, overlay, actions, classNames = {} } = props;
3353
- const foot = /* @__PURE__ */ jsxs17("span", { className: "uic-card-foot", children: [
3354
- /* @__PURE__ */ jsx19("span", { className: "uic-card-name", children: title }),
3355
- subtitle2 ? /* @__PURE__ */ jsx19("span", { className: "uic-card-sub", children: subtitle2 }) : null
2499
+ const foot = /* @__PURE__ */ jsxs14("span", { className: "uic-card-foot", children: [
2500
+ /* @__PURE__ */ jsx16("span", { className: "uic-card-name", children: title }),
2501
+ subtitle2 ? /* @__PURE__ */ jsx16("span", { className: "uic-card-sub", children: subtitle2 }) : null
3356
2502
  ] });
3357
- return /* @__PURE__ */ jsxs17("div", { className: ["uic-card", selected ? "is-selected" : "", classNames.root || ""].filter(Boolean).join(" "), children: [
3358
- onClick ? /* @__PURE__ */ jsxs17("button", { type: "button", className: "uic-card-main", onClick, "aria-pressed": selected || void 0, children: [
3359
- /* @__PURE__ */ jsx19("span", { className: "uic-card-art", children: art }),
2503
+ return /* @__PURE__ */ jsxs14("div", { className: ["uic-card", selected ? "is-selected" : "", classNames.root || ""].filter(Boolean).join(" "), children: [
2504
+ onClick ? /* @__PURE__ */ jsxs14("button", { type: "button", className: "uic-card-main", onClick, "aria-pressed": selected || void 0, children: [
2505
+ /* @__PURE__ */ jsx16("span", { className: "uic-card-art", children: art }),
3360
2506
  foot
3361
- ] }) : /* @__PURE__ */ jsxs17("div", { className: "uic-card-main", children: [
3362
- /* @__PURE__ */ jsx19("span", { className: "uic-card-art", children: art }),
2507
+ ] }) : /* @__PURE__ */ jsxs14("div", { className: "uic-card-main", children: [
2508
+ /* @__PURE__ */ jsx16("span", { className: "uic-card-art", children: art }),
3363
2509
  foot
3364
2510
  ] }),
3365
- overlay ? /* @__PURE__ */ jsx19("div", { className: "uic-card-overlay", children: overlay }) : null,
3366
- actions ? /* @__PURE__ */ jsx19("div", { className: "uic-card-actions", children: actions }) : null
2511
+ overlay ? /* @__PURE__ */ jsx16("div", { className: "uic-card-overlay", children: overlay }) : null,
2512
+ actions ? /* @__PURE__ */ jsx16("div", { className: "uic-card-actions", children: actions }) : null
3367
2513
  ] });
3368
2514
  }
3369
2515
 
3370
2516
  // src/components/SearchField.jsx
3371
- import React11 from "react";
3372
- import { jsx as jsx20, jsxs as jsxs18 } from "react/jsx-runtime";
2517
+ import React9 from "react";
2518
+ import { jsx as jsx17, jsxs as jsxs15 } from "react/jsx-runtime";
3373
2519
  function SearchField(props) {
3374
2520
  const { value, onChange, placeholder, clearLabel = "Clear search", className } = props;
3375
- return /* @__PURE__ */ jsxs18("label", { className: ["uic-search", className || ""].filter(Boolean).join(" "), children: [
3376
- /* @__PURE__ */ jsx20("span", { className: "uic-search-ic", "aria-hidden": "true", children: /* @__PURE__ */ jsx20(IcSearch, {}) }),
3377
- /* @__PURE__ */ jsx20(
2521
+ return /* @__PURE__ */ jsxs15("label", { className: ["uic-search", className || ""].filter(Boolean).join(" "), children: [
2522
+ /* @__PURE__ */ jsx17("span", { className: "uic-search-ic", "aria-hidden": "true", children: /* @__PURE__ */ jsx17(IcSearch, {}) }),
2523
+ /* @__PURE__ */ jsx17(
3378
2524
  "input",
3379
2525
  {
3380
2526
  type: "search",
@@ -3384,161 +2530,219 @@ function SearchField(props) {
3384
2530
  onChange: (e) => onChange(e.target.value)
3385
2531
  }
3386
2532
  ),
3387
- value ? /* @__PURE__ */ jsx20("button", { type: "button", className: "uic-search-x", "aria-label": clearLabel, onClick: () => onChange(""), children: /* @__PURE__ */ jsx20(IcX, { size: 12 }) }) : null
2533
+ value ? /* @__PURE__ */ jsx17("button", { type: "button", className: "uic-search-x", "aria-label": clearLabel, onClick: () => onChange(""), children: /* @__PURE__ */ jsx17(IcX, { size: 12 }) }) : null
3388
2534
  ] });
3389
2535
  }
3390
2536
 
3391
- // src/components/Popover.jsx
3392
- import React12, { useCallback as useCallback6, useEffect as useEffect12, useRef as useRef9, useState as useState12 } from "react";
3393
- import { createPortal as createPortal3 } from "react-dom";
3394
- import { jsx as jsx21 } from "react/jsx-runtime";
3395
- var GAP = 6;
3396
- var MARGIN = 8;
3397
- function Popover(props) {
2537
+ // src/components/CascadeMenu.jsx
2538
+ import React10, { Fragment as Fragment8, useCallback as useCallback6, useEffect as useEffect10, useMemo as useMemo3, useRef as useRef8, useState as useState12 } from "react";
2539
+ import { jsx as jsx18, jsxs as jsxs16 } from "react/jsx-runtime";
2540
+ var Tick = () => /* @__PURE__ */ jsx18(Svg, { s: 14, children: /* @__PURE__ */ jsx18("path", { d: "M20 6 9 17l-5-5" }) });
2541
+ var FILTER_PAST = 8;
2542
+ var itemsOf = (groups) => groups.flatMap((g) => g.items);
2543
+ function CascadeMenu(props) {
3398
2544
  const {
3399
2545
  open,
3400
2546
  anchorRef,
3401
2547
  onClose,
3402
- width = 280,
3403
- minHeight = 140,
3404
- placement = "auto",
3405
- children,
2548
+ label,
2549
+ groups = [],
2550
+ optionsOf,
2551
+ onPick,
2552
+ filter = "auto",
2553
+ filterPlaceholder = "Filter",
2554
+ emptyText = "Nothing matches.",
2555
+ noOptionsText = "Nothing to choose here.",
2556
+ optionsLabel = "Options",
2557
+ backLabel = "Back",
2558
+ optionsFooter,
2559
+ width = 520,
2560
+ stackBelow = 560,
3406
2561
  className,
3407
- label
2562
+ value
3408
2563
  } = props;
3409
- const popRef = useRef9(null);
3410
- const [pos, setPos] = useState12(null);
3411
- useEffect12(() => {
3412
- if (!open) {
3413
- setPos(null);
3414
- return void 0;
3415
- }
3416
- const place = () => {
3417
- const el = anchorRef?.current;
3418
- if (!el) return;
3419
- const r = el.getBoundingClientRect();
3420
- const vw = window.innerWidth;
3421
- const vh = window.innerHeight;
3422
- const w = Math.min(width, vw - MARGIN * 2);
3423
- const below = vh - r.bottom - GAP - MARGIN;
3424
- const above = r.top - GAP - MARGIN;
3425
- const up = placement === "above" || placement === "auto" && below < minHeight && above > below;
3426
- const maxHeight = Math.max(minHeight, Math.floor(up ? above : below));
3427
- const left = Math.max(MARGIN, Math.min(r.left, vw - w - MARGIN));
3428
- setPos(up ? { left, bottom: Math.round(vh - r.top + GAP), width: w, maxHeight } : { left, top: Math.round(r.bottom + GAP), width: w, maxHeight });
3429
- };
3430
- place();
3431
- window.addEventListener("resize", place);
3432
- window.addEventListener("scroll", place, true);
3433
- return () => {
3434
- window.removeEventListener("resize", place);
3435
- window.removeEventListener("scroll", place, true);
3436
- };
3437
- }, [open, anchorRef, width, minHeight, placement]);
3438
- useEffect12(() => {
2564
+ const rootRef = useRef8(null);
2565
+ const [q, setQ] = useState12("");
2566
+ const [activeId, setActiveId] = useState12(null);
2567
+ const [stage, setStage] = useState12("items");
2568
+ const [stacked, setStacked] = useState12(false);
2569
+ const visible = useMemo3(() => {
2570
+ const needle = q.trim().toLowerCase();
2571
+ if (!needle) return groups.filter((g) => g.items.length > 0);
2572
+ return groups.map((g) => ({ ...g, items: g.items.filter((it) => String(it.label).toLowerCase().includes(needle)) })).filter((g) => g.items.length > 0);
2573
+ }, [groups, q]);
2574
+ const flat = useMemo3(() => itemsOf(visible), [visible]);
2575
+ const active = flat.find((it) => it.id === activeId) || flat[0] || null;
2576
+ const options = useMemo3(() => active && optionsOf ? optionsOf(active) : [], [active, optionsOf]);
2577
+ const showFilter = filter === true || filter === "auto" && itemsOf(groups).length > FILTER_PAST;
2578
+ useEffect10(() => {
3439
2579
  if (!open) return void 0;
3440
- const onDown = (e) => {
3441
- if (popRef.current?.contains(e.target)) return;
3442
- if (anchorRef?.current?.contains(e.target)) return;
3443
- onClose?.();
3444
- };
3445
- document.addEventListener("pointerdown", onDown);
3446
- return () => document.removeEventListener("pointerdown", onDown);
3447
- }, [open, anchorRef, onClose]);
3448
- const escape = useCallback6(() => onClose?.(), [onClose]);
3449
- useOverlayEscape(open, escape);
3450
- if (!open || !pos || typeof document === "undefined") return null;
3451
- return createPortal3(
3452
- /* @__PURE__ */ jsx21(
3453
- "div",
3454
- {
3455
- ref: popRef,
3456
- className: ["uic-pop", className || ""].filter(Boolean).join(" "),
3457
- style: pos,
3458
- role: "dialog",
3459
- "aria-label": label,
3460
- children
3461
- }
3462
- ),
3463
- document.body
3464
- );
3465
- }
3466
-
3467
- // src/components/Modal.jsx
3468
- import React13, { useCallback as useCallback7, useEffect as useEffect13, useId as useId3 } from "react";
3469
- import { createPortal as createPortal4 } from "react-dom";
3470
- import { jsx as jsx22, jsxs as jsxs19 } from "react/jsx-runtime";
3471
- function Modal(props) {
3472
- const {
3473
- open,
3474
- onClose,
3475
- title,
3476
- description,
3477
- actions,
3478
- size = "md",
3479
- width,
3480
- labelledBy,
3481
- children,
3482
- classNames = {}
3483
- } = props;
3484
- const titleId = useId3();
3485
- const escape = useCallback7(() => onClose?.(), [onClose]);
3486
- useOverlayEscape(open, escape);
3487
- useEffect13(() => {
3488
- if (!open || typeof document === "undefined") return void 0;
3489
- const prev = document.body.style.overflow;
3490
- document.body.style.overflow = "hidden";
2580
+ setQ("");
2581
+ setActiveId(value?.item ?? null);
2582
+ setStage("items");
2583
+ const measure = () => setStacked(window.innerWidth < stackBelow);
2584
+ measure();
2585
+ window.addEventListener("resize", measure);
2586
+ const raf = requestAnimationFrame(() => {
2587
+ const first = rootRef.current?.querySelector("input, button:not(:disabled)");
2588
+ first?.focus({ preventScroll: true });
2589
+ });
2590
+ const anchor = anchorRef?.current;
3491
2591
  return () => {
3492
- document.body.style.overflow = prev;
2592
+ window.removeEventListener("resize", measure);
2593
+ cancelAnimationFrame(raf);
2594
+ anchor?.focus?.({ preventScroll: true });
3493
2595
  };
3494
- }, [open]);
3495
- if (!open || typeof document === "undefined") return null;
3496
- const onBackdrop = (e) => {
3497
- if (e.target === e.currentTarget) onClose?.();
3498
- };
3499
- return createPortal4(
3500
- /* @__PURE__ */ jsx22(
3501
- "div",
3502
- {
3503
- className: ["uic-modal-backdrop", classNames.backdrop || ""].filter(Boolean).join(" "),
3504
- onMouseDown: onBackdrop,
3505
- children: /* @__PURE__ */ jsxs19(
3506
- "div",
3507
- {
3508
- className: ["uic-modal", `is-${size}`, classNames.root || ""].filter(Boolean).join(" "),
3509
- style: width ? { width } : void 0,
3510
- role: "dialog",
3511
- "aria-modal": "true",
3512
- "aria-labelledby": labelledBy || (title ? titleId : void 0),
3513
- children: [
3514
- title || actions ? /* @__PURE__ */ jsxs19("div", { className: "uic-modal-h", children: [
3515
- /* @__PURE__ */ jsxs19("div", { className: "uic-modal-title", children: [
3516
- title ? /* @__PURE__ */ jsx22("h3", { id: titleId, children: title }) : null,
3517
- description ? /* @__PURE__ */ jsx22("p", { children: description }) : null
3518
- ] }),
3519
- actions,
3520
- /* @__PURE__ */ jsx22("button", { type: "button", className: "uic-modal-x", "aria-label": "Close", onClick: onClose, children: /* @__PURE__ */ jsx22(IcX, { size: 18 }) })
3521
- ] }) : null,
3522
- /* @__PURE__ */ jsx22("div", { className: ["uic-modal-b", classNames.body || ""].filter(Boolean).join(" "), children })
3523
- ]
3524
- }
3525
- )
2596
+ }, [open, stackBelow]);
2597
+ const focusIn = useCallback6((col, index = 0) => {
2598
+ const list = rootRef.current?.querySelectorAll(`.uic-cascade-${col} .uic-pop-item:not(:disabled)`);
2599
+ if (!list || !list.length) return false;
2600
+ const i = Math.max(0, Math.min(index, list.length - 1));
2601
+ list[i].focus({ preventScroll: true });
2602
+ return true;
2603
+ }, []);
2604
+ const enterOptions = useCallback6(() => {
2605
+ if (stacked) {
2606
+ setStage("options");
2607
+ requestAnimationFrame(() => focusIn("options"));
2608
+ } else focusIn("options");
2609
+ }, [stacked, focusIn]);
2610
+ const onKey = (e) => {
2611
+ const el = document.activeElement;
2612
+ const col = el?.closest?.(".uic-cascade-col");
2613
+ const inItems = col?.classList.contains("uic-cascade-items");
2614
+ const inOptions = col?.classList.contains("uic-cascade-options");
2615
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
2616
+ if (!col) return;
2617
+ const list = Array.from(col.querySelectorAll(".uic-pop-item:not(:disabled)"));
2618
+ const i = list.indexOf(el);
2619
+ const next = i < 0 ? 0 : i + (e.key === "ArrowDown" ? 1 : -1);
2620
+ if (next < 0) {
2621
+ col.querySelector("input")?.focus();
2622
+ e.preventDefault();
2623
+ return;
3526
2624
  }
3527
- ),
3528
- document.body
2625
+ if (next >= list.length) return;
2626
+ e.preventDefault();
2627
+ list[next].focus({ preventScroll: true });
2628
+ } else if (e.key === "ArrowRight" && inItems) {
2629
+ e.preventDefault();
2630
+ enterOptions();
2631
+ } else if (e.key === "ArrowLeft" && inOptions) {
2632
+ e.preventDefault();
2633
+ if (stacked) {
2634
+ setStage("items");
2635
+ requestAnimationFrame(() => focusIn("items", flat.indexOf(active)));
2636
+ } else focusIn("items", flat.indexOf(active));
2637
+ } else if (e.key === "Enter" && el?.tagName === "INPUT") {
2638
+ e.preventDefault();
2639
+ enterOptions();
2640
+ }
2641
+ };
2642
+ const showItems = !stacked || stage === "items";
2643
+ const showOptions = !stacked || stage === "options";
2644
+ return /* @__PURE__ */ jsx18(
2645
+ Popover,
2646
+ {
2647
+ open,
2648
+ anchorRef,
2649
+ onClose,
2650
+ label,
2651
+ width: stacked ? 320 : width,
2652
+ minHeight: 260,
2653
+ className: ["uic-cascade-pop", className || ""].filter(Boolean).join(" "),
2654
+ children: /* @__PURE__ */ jsxs16("div", { ref: rootRef, className: "uic-cascade" + (stacked ? " is-stacked" : ""), onKeyDown: onKey, children: [
2655
+ showItems && /* @__PURE__ */ jsxs16("div", { className: "uic-cascade-col uic-cascade-items", children: [
2656
+ showFilter ? /* @__PURE__ */ jsx18(SearchField, { className: "uic-cascade-filter", value: q, onChange: setQ, placeholder: filterPlaceholder }) : null,
2657
+ /* @__PURE__ */ jsxs16("div", { className: "uic-pop-list", children: [
2658
+ visible.map((g, gi) => /* @__PURE__ */ jsxs16(Fragment8, { children: [
2659
+ g.label ? /* @__PURE__ */ jsx18("div", { className: "uic-cascade-group", children: g.label }) : null,
2660
+ g.items.map((it) => {
2661
+ const on = active?.id === it.id;
2662
+ return /* @__PURE__ */ jsxs16(
2663
+ "button",
2664
+ {
2665
+ type: "button",
2666
+ className: "uic-pop-item uic-cascade-item" + (on ? " is-active" : ""),
2667
+ "aria-expanded": on,
2668
+ "aria-haspopup": "true",
2669
+ onFocus: () => setActiveId(it.id),
2670
+ onClick: () => {
2671
+ setActiveId(it.id);
2672
+ enterOptions();
2673
+ },
2674
+ children: [
2675
+ it.icon ? /* @__PURE__ */ jsx18("span", { className: "uic-cascade-ic", "aria-hidden": "true", children: it.icon }) : null,
2676
+ /* @__PURE__ */ jsx18("span", { className: "uic-chip-t", children: it.label }),
2677
+ it.note ? /* @__PURE__ */ jsx18("span", { className: "uic-cascade-note", children: it.note }) : null,
2678
+ /* @__PURE__ */ jsx18("span", { className: "uic-cascade-chev", "aria-hidden": "true", children: /* @__PURE__ */ jsx18(Chevron, { dir: "right", size: 14 }) })
2679
+ ]
2680
+ },
2681
+ it.id
2682
+ );
2683
+ })
2684
+ ] }, g.label || gi)),
2685
+ flat.length === 0 ? /* @__PURE__ */ jsx18("div", { className: "uic-pop-note", children: emptyText }) : null
2686
+ ] })
2687
+ ] }),
2688
+ showOptions && /* @__PURE__ */ jsxs16("div", { className: "uic-cascade-col uic-cascade-options", role: "group", "aria-label": optionsLabel, children: [
2689
+ /* @__PURE__ */ jsxs16("div", { className: "uic-cascade-head", children: [
2690
+ stacked ? /* @__PURE__ */ jsx18(
2691
+ "button",
2692
+ {
2693
+ type: "button",
2694
+ className: "uic-cascade-back",
2695
+ "aria-label": backLabel,
2696
+ onClick: () => {
2697
+ setStage("items");
2698
+ requestAnimationFrame(() => focusIn("items", flat.indexOf(active)));
2699
+ },
2700
+ children: /* @__PURE__ */ jsx18(Chevron, { dir: "left", size: 14 })
2701
+ }
2702
+ ) : null,
2703
+ active?.icon ? /* @__PURE__ */ jsx18("span", { className: "uic-cascade-ic", "aria-hidden": "true", children: active.icon }) : null,
2704
+ /* @__PURE__ */ jsx18("span", { className: "uic-chip-t", children: active ? active.label : "" })
2705
+ ] }),
2706
+ /* @__PURE__ */ jsxs16("div", { className: "uic-pop-list", children: [
2707
+ options.map((o) => {
2708
+ const on = !!value && active?.id === value.item && o.id === value.option;
2709
+ return /* @__PURE__ */ jsxs16(
2710
+ "button",
2711
+ {
2712
+ type: "button",
2713
+ className: "uic-pop-item uic-cascade-opt" + (on ? " is-on" : "") + (o.badge ? " has-badge" : ""),
2714
+ "aria-current": on ? "true" : void 0,
2715
+ disabled: !!o.disabled,
2716
+ onClick: () => onPick?.(active, o),
2717
+ children: [
2718
+ value ? /* @__PURE__ */ jsx18("span", { className: "uic-pop-check", "aria-hidden": "true", children: on ? /* @__PURE__ */ jsx18(Tick, {}) : null }) : null,
2719
+ /* @__PURE__ */ jsx18("span", { className: "uic-chip-t", children: o.label }),
2720
+ o.note ? /* @__PURE__ */ jsx18("span", { className: "uic-cascade-note", children: o.note }) : null,
2721
+ o.badge || null
2722
+ ]
2723
+ },
2724
+ o.id
2725
+ );
2726
+ }),
2727
+ active && options.length === 0 ? /* @__PURE__ */ jsx18("div", { className: "uic-pop-note", children: noOptionsText }) : null
2728
+ ] }),
2729
+ optionsFooter || null
2730
+ ] })
2731
+ ] })
2732
+ }
3529
2733
  );
3530
2734
  }
3531
2735
 
3532
2736
  // src/hooks/useTypewriter.js
3533
- import { useEffect as useEffect14, useRef as useRef10, useState as useState13 } from "react";
2737
+ import { useEffect as useEffect11, useRef as useRef9, useState as useState13 } from "react";
3534
2738
  var CHAR_MS = 26;
3535
2739
  var HOLD_MS = 2600;
3536
2740
  function useTypewriter(phrases, { active = true } = {}) {
3537
2741
  const list = phrases && phrases.length ? phrases : [""];
3538
2742
  const [text, setText] = useState13(list[0]);
3539
- const listRef = useRef10(list);
2743
+ const listRef = useRef9(list);
3540
2744
  listRef.current = list;
3541
- useEffect14(() => {
2745
+ useEffect11(() => {
3542
2746
  if (!active) return void 0;
3543
2747
  if (typeof window === "undefined") return void 0;
3544
2748
  if (window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches) {
@@ -3569,7 +2773,7 @@ function useTypewriter(phrases, { active = true } = {}) {
3569
2773
  }
3570
2774
 
3571
2775
  // src/components/Panel.jsx
3572
- import { jsx as jsx23, jsxs as jsxs20 } from "react/jsx-runtime";
2776
+ import { jsx as jsx19, jsxs as jsxs17 } from "react/jsx-runtime";
3573
2777
  function Panel(props) {
3574
2778
  const {
3575
2779
  title,
@@ -3591,43 +2795,43 @@ function Panel(props) {
3591
2795
  classNames = {},
3592
2796
  children
3593
2797
  } = props;
3594
- const body = loading ? /* @__PURE__ */ jsxs20("div", { className: "uic-panel-load", children: [
3595
- /* @__PURE__ */ jsx23("span", { className: "uic-panel-load-bar" }),
3596
- /* @__PURE__ */ jsx23("span", { className: "uic-panel-load-bar" }),
3597
- /* @__PURE__ */ jsx23("span", { className: "uic-panel-load-bar" }),
3598
- /* @__PURE__ */ jsx23("span", { className: "uic-sr", children: loadingLabel })
3599
- ] }) : error ? /* @__PURE__ */ jsxs20("div", { className: "uic-panel-fail", children: [
3600
- /* @__PURE__ */ jsx23("p", { className: "uic-panel-fail-t", children: errorTitle }),
3601
- /* @__PURE__ */ jsx23("pre", { className: "uic-panel-fail-m", children: error }),
3602
- errorDetail ? /* @__PURE__ */ jsxs20("details", { className: "uic-panel-fail-d", children: [
3603
- /* @__PURE__ */ jsx23("summary", { children: detailLabel }),
3604
- /* @__PURE__ */ jsx23("div", { className: "uic-panel-fail-dd", children: errorDetail })
2798
+ const body = loading ? /* @__PURE__ */ jsxs17("div", { className: "uic-panel-load", children: [
2799
+ /* @__PURE__ */ jsx19("span", { className: "uic-panel-load-bar" }),
2800
+ /* @__PURE__ */ jsx19("span", { className: "uic-panel-load-bar" }),
2801
+ /* @__PURE__ */ jsx19("span", { className: "uic-panel-load-bar" }),
2802
+ /* @__PURE__ */ jsx19("span", { className: "uic-sr", children: loadingLabel })
2803
+ ] }) : error ? /* @__PURE__ */ jsxs17("div", { className: "uic-panel-fail", children: [
2804
+ /* @__PURE__ */ jsx19("p", { className: "uic-panel-fail-t", children: errorTitle }),
2805
+ /* @__PURE__ */ jsx19("pre", { className: "uic-panel-fail-m", children: error }),
2806
+ errorDetail ? /* @__PURE__ */ jsxs17("details", { className: "uic-panel-fail-d", children: [
2807
+ /* @__PURE__ */ jsx19("summary", { children: detailLabel }),
2808
+ /* @__PURE__ */ jsx19("div", { className: "uic-panel-fail-dd", children: errorDetail })
3605
2809
  ] }) : null,
3606
- onRetry ? /* @__PURE__ */ jsx23("div", { className: "uic-panel-fail-act", children: /* @__PURE__ */ jsx23(Button, { size: "sm", onClick: onRetry, children: retryLabel }) }) : null
2810
+ onRetry ? /* @__PURE__ */ jsx19("div", { className: "uic-panel-fail-act", children: /* @__PURE__ */ jsx19(Button, { size: "sm", onClick: onRetry, children: retryLabel }) }) : null
3607
2811
  ] }) : children;
3608
- return /* @__PURE__ */ jsxs20(
2812
+ return /* @__PURE__ */ jsxs17(
3609
2813
  "section",
3610
2814
  {
3611
2815
  className: ["uic-panel", className, classNames.root || ""].filter(Boolean).join(" "),
3612
2816
  "aria-busy": loading || busy || void 0,
3613
2817
  children: [
3614
- /* @__PURE__ */ jsxs20("header", { className: ["uic-panel-head", classNames.head || ""].filter(Boolean).join(" "), children: [
3615
- /* @__PURE__ */ jsxs20("div", { className: "uic-panel-titles", children: [
3616
- title ? /* @__PURE__ */ jsx23(Heading, { className: "uic-panel-title", children: title }) : null,
3617
- meta ? /* @__PURE__ */ jsx23("p", { className: "uic-panel-meta", children: meta }) : null
2818
+ /* @__PURE__ */ jsxs17("header", { className: ["uic-panel-head", classNames.head || ""].filter(Boolean).join(" "), children: [
2819
+ /* @__PURE__ */ jsxs17("div", { className: "uic-panel-titles", children: [
2820
+ title ? /* @__PURE__ */ jsx19(Heading, { className: "uic-panel-title", children: title }) : null,
2821
+ meta ? /* @__PURE__ */ jsx19("p", { className: "uic-panel-meta", children: meta }) : null
3618
2822
  ] }),
3619
- actions ? /* @__PURE__ */ jsx23("div", { className: "uic-panel-acts", children: actions }) : null
2823
+ actions ? /* @__PURE__ */ jsx19("div", { className: "uic-panel-acts", children: actions }) : null
3620
2824
  ] }),
3621
- busy ? /* @__PURE__ */ jsx23("div", { className: "uic-panel-busy", role: "status", "aria-label": busyLabel }) : null,
3622
- /* @__PURE__ */ jsx23("div", { className: ["uic-panel-body", classNames.body || ""].filter(Boolean).join(" "), children: body }),
3623
- footer ? /* @__PURE__ */ jsx23("footer", { className: "uic-panel-foot", children: footer }) : null
2825
+ busy ? /* @__PURE__ */ jsx19("div", { className: "uic-panel-busy", role: "status", "aria-label": busyLabel }) : null,
2826
+ /* @__PURE__ */ jsx19("div", { className: ["uic-panel-body", classNames.body || ""].filter(Boolean).join(" "), children: body }),
2827
+ footer ? /* @__PURE__ */ jsx19("footer", { className: "uic-panel-foot", children: footer }) : null
3624
2828
  ]
3625
2829
  }
3626
2830
  );
3627
2831
  }
3628
2832
 
3629
2833
  // src/grid/PanelGrid.jsx
3630
- import React14, { useCallback as useCallback8, useEffect as useEffect15, useLayoutEffect, useMemo as useMemo3, useRef as useRef11, useState as useState14 } from "react";
2834
+ import React11, { useCallback as useCallback7, useEffect as useEffect12, useLayoutEffect, useMemo as useMemo4, useRef as useRef10, useState as useState14 } from "react";
3631
2835
 
3632
2836
  // src/grid/layout.js
3633
2837
  function sortLayout(layout2) {
@@ -3700,9 +2904,9 @@ function sameLayout(a, b) {
3700
2904
  }
3701
2905
 
3702
2906
  // src/grid/PanelGrid.jsx
3703
- import { jsx as jsx24, jsxs as jsxs21 } from "react/jsx-runtime";
2907
+ import { jsx as jsx20, jsxs as jsxs18 } from "react/jsx-runtime";
3704
2908
  function useMeasuredWidth() {
3705
- const ref = useRef11(null);
2909
+ const ref = useRef10(null);
3706
2910
  const [width, setWidth] = useState14(0);
3707
2911
  useLayoutEffect(() => {
3708
2912
  const el = ref.current;
@@ -3732,8 +2936,8 @@ function PanelGrid(props) {
3732
2936
  } = props;
3733
2937
  const [wrapRef, width] = useMeasuredWidth();
3734
2938
  const [drag, setDrag] = useState14(null);
3735
- const dragRef = useRef11(null);
3736
- const swallowClick = useRef11(false);
2939
+ const dragRef = useRef10(null);
2940
+ const swallowClick = useRef10(false);
3737
2941
  const stacked = width > 0 && width < stackAt;
3738
2942
  const arrangeable = editable && !stacked;
3739
2943
  const live = drag ? drag.preview : layout2;
@@ -3741,7 +2945,7 @@ function PanelGrid(props) {
3741
2945
  const cellW = colW + gap;
3742
2946
  const cellH = rowHeight + gap;
3743
2947
  const rowsToPx = (h) => h * rowHeight + (h - 1) * gap;
3744
- const stack2 = useMemo3(() => {
2948
+ const stack = useMemo4(() => {
3745
2949
  if (!stacked) return null;
3746
2950
  const tops = /* @__PURE__ */ new Map();
3747
2951
  let y = 0;
@@ -3752,12 +2956,12 @@ function PanelGrid(props) {
3752
2956
  return { tops, height: Math.max(0, y - gap) };
3753
2957
  }, [stacked, live, rowHeight, gap]);
3754
2958
  const rows = layoutRows(live);
3755
- const height = stacked ? stack2.height : rows ? rowsToPx(rows) : 0;
3756
- const commit = useCallback8((next) => {
2959
+ const height = stacked ? stack.height : rows ? rowsToPx(rows) : 0;
2960
+ const commit = useCallback7((next) => {
3757
2961
  if (onLayoutChange && !sameLayout(next, layout2)) onLayoutChange(next);
3758
2962
  }, [onLayoutChange, layout2]);
3759
- const detach = useRef11(null);
3760
- useEffect15(() => () => detach.current?.(), []);
2963
+ const detach = useRef10(null);
2964
+ useEffect12(() => () => detach.current?.(), []);
3761
2965
  const start = (id, mode) => (e) => {
3762
2966
  if (!arrangeable || e.button !== 0) return;
3763
2967
  const item = layout2.find((it) => it.i === id);
@@ -3788,7 +2992,7 @@ function PanelGrid(props) {
3788
2992
  if (d && commitIt) commit(d.preview);
3789
2993
  };
3790
2994
  const onUp = end(true);
3791
- const onKey2 = (ev) => {
2995
+ const onKey = (ev) => {
3792
2996
  if (ev.key === "Escape") end(false)();
3793
2997
  };
3794
2998
  function off() {
@@ -3796,13 +3000,13 @@ function PanelGrid(props) {
3796
3000
  window.removeEventListener("pointermove", onMove);
3797
3001
  window.removeEventListener("pointerup", onUp);
3798
3002
  window.removeEventListener("pointercancel", onUp);
3799
- window.removeEventListener("keydown", onKey2);
3003
+ window.removeEventListener("keydown", onKey);
3800
3004
  }
3801
3005
  detach.current = off;
3802
3006
  window.addEventListener("pointermove", onMove);
3803
3007
  window.addEventListener("pointerup", onUp);
3804
3008
  window.addEventListener("pointercancel", onUp);
3805
- window.addEventListener("keydown", onKey2);
3009
+ window.addEventListener("keydown", onKey);
3806
3010
  };
3807
3011
  const onClickCapture = (e) => {
3808
3012
  if (!swallowClick.current) return;
@@ -3818,11 +3022,11 @@ function PanelGrid(props) {
3818
3022
  e.preventDefault();
3819
3023
  commit(e.shiftKey ? nudgeItem(layout2, id, step[0], step[1], cols) : resizeItem(layout2, id, item.w + step[0], item.h + step[1], cols));
3820
3024
  };
3821
- const boxOf = (it) => stacked ? { left: 0, top: stack2.tops.get(it.i), width, height: rowsToPx(it.h || 1) } : { left: it.x * cellW, top: it.y * cellH, width: it.w * colW + (it.w - 1) * gap, height: rowsToPx(it.h) };
3025
+ const boxOf = (it) => stacked ? { left: 0, top: stack.tops.get(it.i), width, height: rowsToPx(it.h || 1) } : { left: it.x * cellW, top: it.y * cellH, width: it.w * colW + (it.w - 1) * gap, height: rowsToPx(it.h) };
3822
3026
  const byId = new Map(live.map((it) => [it.i, it]));
3823
3027
  const ghost = drag && drag.mode === "move" && byId.has(drag.id) ? boxOf(byId.get(drag.id)) : null;
3824
3028
  const cls = ["uic-pg", arrangeable ? "is-editable" : "", stacked ? "is-stacked" : "", className].filter(Boolean).join(" ");
3825
- return /* @__PURE__ */ jsxs21(
3029
+ return /* @__PURE__ */ jsxs18(
3826
3030
  "div",
3827
3031
  {
3828
3032
  ref: wrapRef,
@@ -3833,15 +3037,15 @@ function PanelGrid(props) {
3833
3037
  swallowClick.current = false;
3834
3038
  },
3835
3039
  children: [
3836
- ghost ? /* @__PURE__ */ jsx24("div", { className: "uic-pg-ghost", "aria-hidden": "true", style: ghost }) : null,
3837
- width > 0 && React14.Children.map(children, (child) => {
3838
- if (!React14.isValidElement(child) || child.key == null) return null;
3040
+ ghost ? /* @__PURE__ */ jsx20("div", { className: "uic-pg-ghost", "aria-hidden": "true", style: ghost }) : null,
3041
+ width > 0 && React11.Children.map(children, (child) => {
3042
+ if (!React11.isValidElement(child) || child.key == null) return null;
3839
3043
  const id = String(child.key).replace(/^\.\$/, "");
3840
3044
  const it = byId.get(id);
3841
3045
  if (!it) return null;
3842
3046
  const moving = drag && drag.id === id;
3843
3047
  const offset = moving && drag.mode === "move" ? { transform: `translate(${drag.dx}px, ${drag.dy}px)` } : null;
3844
- return /* @__PURE__ */ jsxs21(
3048
+ return /* @__PURE__ */ jsxs18(
3845
3049
  "div",
3846
3050
  {
3847
3051
  className: "uic-pg-item" + (moving ? " is-moving" : ""),
@@ -3849,7 +3053,7 @@ function PanelGrid(props) {
3849
3053
  onPointerDown: arrangeable ? start(id, "move") : void 0,
3850
3054
  children: [
3851
3055
  child,
3852
- arrangeable && !it.static ? /* @__PURE__ */ jsx24(
3056
+ arrangeable && !it.static ? /* @__PURE__ */ jsx20(
3853
3057
  "button",
3854
3058
  {
3855
3059
  type: "button",
@@ -3857,7 +3061,7 @@ function PanelGrid(props) {
3857
3061
  "aria-label": resizeLabel ? resizeLabel(id) : "Resize panel. Arrow keys resize it; shift with arrow keys moves it past its neighbours.",
3858
3062
  onPointerDown: start(id, "resize"),
3859
3063
  onKeyDown: onHandleKey(id),
3860
- children: /* @__PURE__ */ jsx24("svg", { width: "10", height: "10", viewBox: "0 0 10 10", "aria-hidden": "true", children: /* @__PURE__ */ jsx24("path", { d: "M9 1v8H1", fill: "none", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round" }) })
3064
+ children: /* @__PURE__ */ jsx20("svg", { width: "10", height: "10", viewBox: "0 0 10 10", "aria-hidden": "true", children: /* @__PURE__ */ jsx20("path", { d: "M9 1v8H1", fill: "none", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round" }) })
3861
3065
  }
3862
3066
  ) : null
3863
3067
  ]
@@ -3874,8 +3078,8 @@ function packLayout(layout2, cols = 12) {
3874
3078
  }
3875
3079
 
3876
3080
  // src/timeline/Timeline.jsx
3877
- import { useCallback as useCallback9, useEffect as useEffect16, useLayoutEffect as useLayoutEffect2, useMemo as useMemo4, useRef as useRef12, useState as useState15 } from "react";
3878
- import { Fragment as Fragment9, jsx as jsx25, jsxs as jsxs22 } from "react/jsx-runtime";
3081
+ import { useCallback as useCallback8, useEffect as useEffect13, useLayoutEffect as useLayoutEffect2, useMemo as useMemo5, useRef as useRef11, useState as useState15 } from "react";
3082
+ import { Fragment as Fragment9, jsx as jsx21, jsxs as jsxs19 } from "react/jsx-runtime";
3879
3083
  var TL_MIN_PPS = 4;
3880
3084
  var TL_MAX_PPS = 400;
3881
3085
  var TL_DEFAULT_PPS = 26;
@@ -3964,8 +3168,8 @@ function Timeline({
3964
3168
  emptyLabel = "Nothing here yet.",
3965
3169
  className = ""
3966
3170
  }) {
3967
- const scroller = useRef12(null);
3968
- const innerRef = useRef12(null);
3171
+ const scroller = useRef11(null);
3172
+ const innerRef = useRef11(null);
3969
3173
  const [pps, setPps] = useState15(() => {
3970
3174
  if (zoomStorageKey && typeof window !== "undefined") {
3971
3175
  const n = parseFloat(window.localStorage.getItem(zoomStorageKey) || "");
@@ -3974,11 +3178,11 @@ function Timeline({
3974
3178
  return TL_DEFAULT_PPS;
3975
3179
  });
3976
3180
  const [snapping, setSnapping] = useState15(() => snapStorageKey && typeof window !== "undefined" ? window.localStorage.getItem(snapStorageKey) !== "0" : true);
3977
- const gesture = useRef12(null);
3181
+ const gesture = useRef11(null);
3978
3182
  const [drag, setDrag] = useState15(null);
3979
- const anchor = useRef12(null);
3183
+ const anchor = useRef11(null);
3980
3184
  const [dropAt, setDropAt] = useState15(null);
3981
- const rows = useMemo4(
3185
+ const rows = useMemo5(
3982
3186
  () => tracks.map((t) => ({
3983
3187
  ...t,
3984
3188
  sequential: t.sequential !== false,
@@ -3986,12 +3190,12 @@ function Timeline({
3986
3190
  })),
3987
3191
  [tracks, pps]
3988
3192
  );
3989
- const contentSeconds = useMemo4(() => {
3193
+ const contentSeconds = useMemo5(() => {
3990
3194
  let end = 0;
3991
3195
  for (const t of rows) for (const l of t.laid) end = Math.max(end, l.t0 + l.w / pps);
3992
3196
  return end;
3993
3197
  }, [rows, pps]);
3994
- const snapTimes = useMemo4(() => {
3198
+ const snapTimes = useMemo5(() => {
3995
3199
  const out = [0, currentTime];
3996
3200
  for (const t of rows) for (const l of t.laid) {
3997
3201
  out.push(l.t0);
@@ -3999,7 +3203,7 @@ function Timeline({
3999
3203
  }
4000
3204
  return out;
4001
3205
  }, [rows, pps, currentTime]);
4002
- const setZoom = useCallback9((next, clientX) => {
3206
+ const setZoom = useCallback8((next, clientX) => {
4003
3207
  const v = clamp(next, TL_MIN_PPS, TL_MAX_PPS);
4004
3208
  const el = scroller.current;
4005
3209
  if (el) {
@@ -4015,20 +3219,20 @@ function Timeline({
4015
3219
  }
4016
3220
  }
4017
3221
  }, [pps, zoomStorageKey]);
4018
- const fitPps = useCallback9((seconds) => {
3222
+ const fitPps = useCallback8((seconds) => {
4019
3223
  const el = scroller.current;
4020
3224
  if (!el || !(seconds > 0)) return null;
4021
3225
  const room = el.clientWidth - TL_HEAD_W - 56;
4022
3226
  return room > 0 ? clamp(room / seconds, TL_MIN_PPS, TL_MAX_PPS) : null;
4023
3227
  }, []);
4024
- const fit = useCallback9(() => {
3228
+ const fit = useCallback8(() => {
4025
3229
  const v = fitPps(contentSeconds);
4026
3230
  if (v !== null) {
4027
3231
  setPps(v);
4028
3232
  if (scroller.current) scroller.current.scrollLeft = 0;
4029
3233
  }
4030
3234
  }, [fitPps, contentSeconds]);
4031
- const fitted = useRef12(false);
3235
+ const fitted = useRef11(false);
4032
3236
  useLayoutEffect2(() => {
4033
3237
  if (fitted.current || !(contentSeconds > 0)) return;
4034
3238
  if (zoomStorageKey && typeof window !== "undefined" && window.localStorage.getItem(zoomStorageKey)) {
@@ -4047,7 +3251,7 @@ function Timeline({
4047
3251
  anchor.current = null;
4048
3252
  scroller.current.scrollLeft = Math.max(0, TL_HEAD_W + a.t * pps - a.vx);
4049
3253
  }, [pps]);
4050
- useEffect16(() => {
3254
+ useEffect13(() => {
4051
3255
  const el = scroller.current;
4052
3256
  if (!el) return void 0;
4053
3257
  const onWheel = (e) => {
@@ -4058,12 +3262,12 @@ function Timeline({
4058
3262
  el.addEventListener("wheel", onWheel, { passive: false });
4059
3263
  return () => el.removeEventListener("wheel", onWheel);
4060
3264
  }, [pps, setZoom]);
4061
- const timeAt = useCallback9((clientX) => {
3265
+ const timeAt = useCallback8((clientX) => {
4062
3266
  const el = innerRef.current;
4063
3267
  if (!el) return 0;
4064
3268
  return Math.max(0, (clientX - el.getBoundingClientRect().left - TL_HEAD_W) / pps);
4065
3269
  }, [pps]);
4066
- const beginGesture = useCallback9((e, spec) => {
3270
+ const beginGesture = useCallback8((e, spec) => {
4067
3271
  e.preventDefault();
4068
3272
  e.stopPropagation();
4069
3273
  gesture.current = { ...spec, startX: e.clientX, active: false, value: null };
@@ -4097,12 +3301,12 @@ function Timeline({
4097
3301
  window.addEventListener("pointermove", move);
4098
3302
  window.addEventListener("pointerup", up);
4099
3303
  }, [timeAt, snapping, snapTimes, pps, onSeek]);
4100
- const onScrub = useCallback9((e) => {
3304
+ const onScrub = useCallback8((e) => {
4101
3305
  if (!onSeek) return;
4102
3306
  onSeek(timeAt(e.clientX));
4103
3307
  beginGesture(e, { kind: "scrub" });
4104
3308
  }, [onSeek, timeAt, beginGesture]);
4105
- const splitTarget = useMemo4(() => {
3309
+ const splitTarget = useMemo5(() => {
4106
3310
  if (!onSplit) return null;
4107
3311
  for (const track of rows) {
4108
3312
  for (const l of track.laid) {
@@ -4114,17 +3318,17 @@ function Timeline({
4114
3318
  }
4115
3319
  return null;
4116
3320
  }, [rows, currentTime, onSplit]);
4117
- const doSplit = useCallback9(() => {
3321
+ const doSplit = useCallback8(() => {
4118
3322
  if (!splitTarget) return;
4119
3323
  onSplit(splitTarget.l.clip, currentTime - splitTarget.l.t0, splitTarget.track);
4120
3324
  }, [splitTarget, currentTime, onSplit]);
4121
- const selected = useMemo4(() => {
3325
+ const selected = useMemo5(() => {
4122
3326
  for (const track of rows) for (const l of track.laid) {
4123
3327
  if (l.clip.id === selectedClipId) return { track, l };
4124
3328
  }
4125
3329
  return null;
4126
3330
  }, [rows, selectedClipId]);
4127
- const onKeyDown = useCallback9((e) => {
3331
+ const onKeyDown = useCallback8((e) => {
4128
3332
  const tag = e.target?.tagName;
4129
3333
  if (tag === "INPUT" || tag === "TEXTAREA" || e.target?.isContentEditable) return;
4130
3334
  if (e.key === "+" || e.key === "=") {
@@ -4141,7 +3345,7 @@ function Timeline({
4141
3345
  onDeleteClip(selected.l.clip, selected.track);
4142
3346
  }
4143
3347
  }, [pps, setZoom, doSplit, selected, onDeleteClip]);
4144
- const toggleSnap = useCallback9(() => {
3348
+ const toggleSnap = useCallback8(() => {
4145
3349
  setSnapping((v) => {
4146
3350
  const next = !v;
4147
3351
  if (snapStorageKey && typeof window !== "undefined") {
@@ -4158,9 +3362,9 @@ function Timeline({
4158
3362
  const laneW = Math.max(contentSeconds * pps + 140, 320);
4159
3363
  const ticks = [];
4160
3364
  for (let t = 0; t <= contentSeconds + major; t += major) ticks.push(t);
4161
- return /* @__PURE__ */ jsxs22("div", { className: `rui-tl ${className}`, onKeyDown, tabIndex: 0, children: [
4162
- /* @__PURE__ */ jsxs22("div", { className: "rui-tl-bar", children: [
4163
- onSplit && /* @__PURE__ */ jsxs22(
3365
+ return /* @__PURE__ */ jsxs19("div", { className: `rui-tl ${className}`, onKeyDown, tabIndex: 0, children: [
3366
+ /* @__PURE__ */ jsxs19("div", { className: "rui-tl-bar", children: [
3367
+ onSplit && /* @__PURE__ */ jsxs19(
4164
3368
  "button",
4165
3369
  {
4166
3370
  type: "button",
@@ -4169,7 +3373,7 @@ function Timeline({
4169
3373
  disabled: !splitTarget,
4170
3374
  title: splitTarget ? "Split at the playhead (B)" : "Move the playhead inside a clip to split it",
4171
3375
  children: [
4172
- /* @__PURE__ */ jsxs22(
3376
+ /* @__PURE__ */ jsxs19(
4173
3377
  "svg",
4174
3378
  {
4175
3379
  width: "13",
@@ -4181,19 +3385,19 @@ function Timeline({
4181
3385
  strokeLinecap: "round",
4182
3386
  "aria-hidden": "true",
4183
3387
  children: [
4184
- /* @__PURE__ */ jsx25("circle", { cx: "6", cy: "6", r: "3" }),
4185
- /* @__PURE__ */ jsx25("circle", { cx: "6", cy: "18", r: "3" }),
4186
- /* @__PURE__ */ jsx25("line", { x1: "20", y1: "4", x2: "8.12", y2: "15.88" }),
4187
- /* @__PURE__ */ jsx25("line", { x1: "14.47", y1: "14.48", x2: "20", y2: "20" }),
4188
- /* @__PURE__ */ jsx25("line", { x1: "8.12", y1: "8.12", x2: "12", y2: "12" })
3388
+ /* @__PURE__ */ jsx21("circle", { cx: "6", cy: "6", r: "3" }),
3389
+ /* @__PURE__ */ jsx21("circle", { cx: "6", cy: "18", r: "3" }),
3390
+ /* @__PURE__ */ jsx21("line", { x1: "20", y1: "4", x2: "8.12", y2: "15.88" }),
3391
+ /* @__PURE__ */ jsx21("line", { x1: "14.47", y1: "14.48", x2: "20", y2: "20" }),
3392
+ /* @__PURE__ */ jsx21("line", { x1: "8.12", y1: "8.12", x2: "12", y2: "12" })
4189
3393
  ]
4190
3394
  }
4191
3395
  ),
4192
- /* @__PURE__ */ jsx25("span", { children: "Split" })
3396
+ /* @__PURE__ */ jsx21("span", { children: "Split" })
4193
3397
  ]
4194
3398
  }
4195
3399
  ),
4196
- onDeleteClip && /* @__PURE__ */ jsx25(
3400
+ onDeleteClip && /* @__PURE__ */ jsx21(
4197
3401
  "button",
4198
3402
  {
4199
3403
  type: "button",
@@ -4204,7 +3408,7 @@ function Timeline({
4204
3408
  children: "Remove"
4205
3409
  }
4206
3410
  ),
4207
- /* @__PURE__ */ jsx25(
3411
+ /* @__PURE__ */ jsx21(
4208
3412
  "button",
4209
3413
  {
4210
3414
  type: "button",
@@ -4215,9 +3419,9 @@ function Timeline({
4215
3419
  children: "Snap"
4216
3420
  }
4217
3421
  ),
4218
- /* @__PURE__ */ jsx25("span", { className: "rui-tl-time", "aria-label": "Playhead position", children: exactLabel(currentTime) }),
4219
- /* @__PURE__ */ jsx25("span", { className: "rui-tl-spacer" }),
4220
- /* @__PURE__ */ jsx25(
3422
+ /* @__PURE__ */ jsx21("span", { className: "rui-tl-time", "aria-label": "Playhead position", children: exactLabel(currentTime) }),
3423
+ /* @__PURE__ */ jsx21("span", { className: "rui-tl-spacer" }),
3424
+ /* @__PURE__ */ jsx21(
4221
3425
  "button",
4222
3426
  {
4223
3427
  type: "button",
@@ -4229,7 +3433,7 @@ function Timeline({
4229
3433
  children: "\u2212"
4230
3434
  }
4231
3435
  ),
4232
- /* @__PURE__ */ jsx25(
3436
+ /* @__PURE__ */ jsx21(
4233
3437
  "button",
4234
3438
  {
4235
3439
  type: "button",
@@ -4241,7 +3445,7 @@ function Timeline({
4241
3445
  children: "+"
4242
3446
  }
4243
3447
  ),
4244
- /* @__PURE__ */ jsx25(
3448
+ /* @__PURE__ */ jsx21(
4245
3449
  "button",
4246
3450
  {
4247
3451
  type: "button",
@@ -4253,10 +3457,10 @@ function Timeline({
4253
3457
  }
4254
3458
  )
4255
3459
  ] }),
4256
- /* @__PURE__ */ jsx25("div", { className: "rui-tl-scroll", ref: scroller, children: /* @__PURE__ */ jsxs22("div", { className: "rui-tl-inner", ref: innerRef, style: { width: TL_HEAD_W + laneW }, children: [
4257
- /* @__PURE__ */ jsxs22("div", { className: "rui-tl-row rui-tl-rulerrow", children: [
4258
- /* @__PURE__ */ jsx25("div", { className: "rui-tl-head rui-tl-rulerhead", "aria-hidden": "true" }),
4259
- /* @__PURE__ */ jsx25(
3460
+ /* @__PURE__ */ jsx21("div", { className: "rui-tl-scroll", ref: scroller, children: /* @__PURE__ */ jsxs19("div", { className: "rui-tl-inner", ref: innerRef, style: { width: TL_HEAD_W + laneW }, children: [
3461
+ /* @__PURE__ */ jsxs19("div", { className: "rui-tl-row rui-tl-rulerrow", children: [
3462
+ /* @__PURE__ */ jsx21("div", { className: "rui-tl-head rui-tl-rulerhead", "aria-hidden": "true" }),
3463
+ /* @__PURE__ */ jsx21(
4260
3464
  "div",
4261
3465
  {
4262
3466
  className: "rui-tl-ruler",
@@ -4285,17 +3489,17 @@ function Timeline({
4285
3489
  onSeek(currentTime + step);
4286
3490
  }
4287
3491
  } : void 0,
4288
- children: ticks.map((t) => /* @__PURE__ */ jsx25("span", { className: "rui-tl-ticklbl", style: { left: t * pps }, children: tickLabel(t, major) }, t))
3492
+ children: ticks.map((t) => /* @__PURE__ */ jsx21("span", { className: "rui-tl-ticklbl", style: { left: t * pps }, children: tickLabel(t, major) }, t))
4289
3493
  }
4290
3494
  )
4291
3495
  ] }),
4292
- rows.length === 0 && /* @__PURE__ */ jsx25("p", { className: "rui-tl-empty", children: emptyLabel }),
4293
- rows.map((track) => /* @__PURE__ */ jsxs22("div", { className: "rui-tl-row", children: [
4294
- /* @__PURE__ */ jsxs22("div", { className: "rui-tl-head", title: track.title || track.label, children: [
3496
+ rows.length === 0 && /* @__PURE__ */ jsx21("p", { className: "rui-tl-empty", children: emptyLabel }),
3497
+ rows.map((track) => /* @__PURE__ */ jsxs19("div", { className: "rui-tl-row", children: [
3498
+ /* @__PURE__ */ jsxs19("div", { className: "rui-tl-head", title: track.title || track.label, children: [
4295
3499
  track.icon,
4296
- /* @__PURE__ */ jsx25("span", { className: "rui-tl-headlbl", children: track.label })
3500
+ /* @__PURE__ */ jsx21("span", { className: "rui-tl-headlbl", children: track.label })
4297
3501
  ] }),
4298
- /* @__PURE__ */ jsxs22(
3502
+ /* @__PURE__ */ jsxs19(
4299
3503
  "div",
4300
3504
  {
4301
3505
  className: "rui-tl-lane" + (dropAt?.trackId === track.id ? " is-dropping" : ""),
@@ -4326,8 +3530,8 @@ function Timeline({
4326
3530
  onDropClip(payload, { trackId: track.id, seconds: t, index });
4327
3531
  } : void 0,
4328
3532
  children: [
4329
- track.laid.length === 0 && track.emptyLabel && /* @__PURE__ */ jsx25("p", { className: "rui-tl-laneempty", children: track.emptyLabel }),
4330
- track.laid.map((l) => /* @__PURE__ */ jsx25(
3533
+ track.laid.length === 0 && track.emptyLabel && /* @__PURE__ */ jsx21("p", { className: "rui-tl-laneempty", children: track.emptyLabel }),
3534
+ track.laid.map((l) => /* @__PURE__ */ jsx21(
4331
3535
  Clip,
4332
3536
  {
4333
3537
  l,
@@ -4343,7 +3547,7 @@ function Timeline({
4343
3547
  },
4344
3548
  l.clip.id ?? l.i
4345
3549
  )),
4346
- dropAt?.trackId === track.id && /* @__PURE__ */ jsx25(
3550
+ dropAt?.trackId === track.id && /* @__PURE__ */ jsx21(
4347
3551
  "span",
4348
3552
  {
4349
3553
  className: "rui-tl-dropmark",
@@ -4351,7 +3555,7 @@ function Timeline({
4351
3555
  "aria-hidden": "true"
4352
3556
  }
4353
3557
  ),
4354
- laneAppend && /* @__PURE__ */ jsx25(
3558
+ laneAppend && /* @__PURE__ */ jsx21(
4355
3559
  "span",
4356
3560
  {
4357
3561
  className: "rui-tl-append",
@@ -4363,9 +3567,9 @@ function Timeline({
4363
3567
  }
4364
3568
  )
4365
3569
  ] }, track.id)),
4366
- onDropClip && newLaneLabel && /* @__PURE__ */ jsxs22("div", { className: "rui-tl-row", children: [
4367
- /* @__PURE__ */ jsx25("div", { className: "rui-tl-head rui-tl-newhead", "aria-hidden": "true" }),
4368
- /* @__PURE__ */ jsx25(
3570
+ onDropClip && newLaneLabel && /* @__PURE__ */ jsxs19("div", { className: "rui-tl-row", children: [
3571
+ /* @__PURE__ */ jsx21("div", { className: "rui-tl-head rui-tl-newhead", "aria-hidden": "true" }),
3572
+ /* @__PURE__ */ jsx21(
4369
3573
  "div",
4370
3574
  {
4371
3575
  className: "rui-tl-newlane" + (dropAt?.trackId === null ? " is-dropping" : ""),
@@ -4387,11 +3591,11 @@ function Timeline({
4387
3591
  e.preventDefault();
4388
3592
  onDropClip(payload, { trackId: null, seconds: timeAt(e.clientX), index: 0 });
4389
3593
  },
4390
- children: /* @__PURE__ */ jsx25("span", { className: "rui-tl-newlbl", children: newLaneLabel })
3594
+ children: /* @__PURE__ */ jsx21("span", { className: "rui-tl-newlbl", children: newLaneLabel })
4391
3595
  }
4392
3596
  )
4393
3597
  ] }),
4394
- drag?.guide != null && /* @__PURE__ */ jsx25(
3598
+ drag?.guide != null && /* @__PURE__ */ jsx21(
4395
3599
  "div",
4396
3600
  {
4397
3601
  className: "rui-tl-guide",
@@ -4399,16 +3603,16 @@ function Timeline({
4399
3603
  "aria-hidden": "true"
4400
3604
  }
4401
3605
  ),
4402
- Number.isFinite(currentTime) && /* @__PURE__ */ jsx25(
3606
+ Number.isFinite(currentTime) && /* @__PURE__ */ jsx21(
4403
3607
  "div",
4404
3608
  {
4405
3609
  className: "rui-tl-playhead",
4406
3610
  style: { left: TL_HEAD_W + currentTime * pps },
4407
3611
  "aria-hidden": "true",
4408
- children: /* @__PURE__ */ jsx25("span", { className: "rui-tl-playhead-grip" })
3612
+ children: /* @__PURE__ */ jsx21("span", { className: "rui-tl-playhead-grip" })
4409
3613
  }
4410
3614
  ),
4411
- drag?.annotation && /* @__PURE__ */ jsx25("div", { className: "rui-tl-annot", style: { left: TL_HEAD_W + (drag.annotAt || 0) * pps }, children: drag.annotation })
3615
+ drag?.annotation && /* @__PURE__ */ jsx21("div", { className: "rui-tl-annot", style: { left: TL_HEAD_W + (drag.annotAt || 0) * pps }, children: drag.annotation })
4412
3616
  ] }) })
4413
3617
  ] });
4414
3618
  }
@@ -4484,7 +3688,7 @@ function Clip({
4484
3688
  click: onSelect
4485
3689
  });
4486
3690
  };
4487
- return /* @__PURE__ */ jsxs22(
3691
+ return /* @__PURE__ */ jsxs19(
4488
3692
  "article",
4489
3693
  {
4490
3694
  className: "rui-tl-clip" + (clip.state ? ` is-${clip.state}` : "") + (known ? "" : " is-unmeasured") + (selected ? " is-selected" : "") + (live ? " is-live" : ""),
@@ -4499,10 +3703,10 @@ function Clip({
4499
3703
  }
4500
3704
  },
4501
3705
  children: [
4502
- clip.poster ? /* @__PURE__ */ jsx25("span", { className: "rui-tl-strip", style: {
3706
+ clip.poster ? /* @__PURE__ */ jsx21("span", { className: "rui-tl-strip", style: {
4503
3707
  backgroundImage: `url("${String(clip.poster).replace(/"/g, '\\"')}")`,
4504
3708
  backgroundSize: `${tileW}px 100%`
4505
- } }) : clip.video ? /* @__PURE__ */ jsx25(
3709
+ } }) : clip.video ? /* @__PURE__ */ jsx21(
4506
3710
  "video",
4507
3711
  {
4508
3712
  className: "rui-tl-frame",
@@ -4513,12 +3717,12 @@ function Clip({
4513
3717
  tabIndex: -1,
4514
3718
  "aria-hidden": "true"
4515
3719
  }
4516
- ) : /* @__PURE__ */ jsx25("span", { className: "rui-tl-blank", "aria-hidden": "true", children: clip.glyph }),
4517
- clip.badge && /* @__PURE__ */ jsx25("span", { className: "rui-tl-badge", children: clip.badge }),
4518
- known && width > 46 && /* @__PURE__ */ jsx25("span", { className: "rui-tl-dur", children: durationLabel(clip.duration) }),
4519
- clip.label && width > 104 && /* @__PURE__ */ jsx25("span", { className: "rui-tl-name", children: clip.label }),
4520
- onTrim && known && /* @__PURE__ */ jsxs22(Fragment9, { children: [
4521
- /* @__PURE__ */ jsx25(
3720
+ ) : /* @__PURE__ */ jsx21("span", { className: "rui-tl-blank", "aria-hidden": "true", children: clip.glyph }),
3721
+ clip.badge && /* @__PURE__ */ jsx21("span", { className: "rui-tl-badge", children: clip.badge }),
3722
+ known && width > 46 && /* @__PURE__ */ jsx21("span", { className: "rui-tl-dur", children: durationLabel(clip.duration) }),
3723
+ clip.label && width > 104 && /* @__PURE__ */ jsx21("span", { className: "rui-tl-name", children: clip.label }),
3724
+ onTrim && known && /* @__PURE__ */ jsxs19(Fragment9, { children: [
3725
+ /* @__PURE__ */ jsx21(
4522
3726
  "span",
4523
3727
  {
4524
3728
  className: "rui-tl-trim l",
@@ -4527,7 +3731,7 @@ function Clip({
4527
3731
  "aria-label": `Trim the start of ${clip.label || "this clip"}`
4528
3732
  }
4529
3733
  ),
4530
- /* @__PURE__ */ jsx25(
3734
+ /* @__PURE__ */ jsx21(
4531
3735
  "span",
4532
3736
  {
4533
3737
  className: "rui-tl-trim r",
@@ -4547,6 +3751,7 @@ export {
4547
3751
  Button,
4548
3752
  Card,
4549
3753
  Carousel,
3754
+ CascadeMenu,
4550
3755
  ChatMessages,
4551
3756
  ChatMessagesSkeleton,
4552
3757
  ChatPanel,
@@ -4583,6 +3788,8 @@ export {
4583
3788
  IcTool,
4584
3789
  IcX,
4585
3790
  Input,
3791
+ MentionInput,
3792
+ MentionText,
4586
3793
  Modal,
4587
3794
  PaneResizer,
4588
3795
  Panel,
@@ -4615,7 +3822,6 @@ export {
4615
3822
  createResponsesDispatcher,
4616
3823
  extOf,
4617
3824
  fetchBalance,
4618
- fitRowHeights,
4619
3825
  getSession,
4620
3826
  getToken,
4621
3827
  googleSignIn,