reifyui 0.5.1 → 0.6.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 (43) hide show
  1. package/README.md +40 -3
  2. package/dist/{chunk-2LYV4PIX.js → chunk-NTIWFHR4.js} +26 -2
  3. package/dist/chunk-NTIWFHR4.js.map +1 -0
  4. package/dist/harness.cjs +72 -21
  5. package/dist/harness.cjs.map +1 -1
  6. package/dist/harness.d.ts +23 -0
  7. package/dist/harness.js +52 -23
  8. package/dist/harness.js.map +1 -1
  9. package/dist/index.cjs +1125 -296
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.ts +260 -1
  12. package/dist/index.js +1100 -293
  13. package/dist/index.js.map +1 -1
  14. package/package.json +1 -1
  15. package/src/components/Card.jsx +49 -0
  16. package/src/components/Carousel.jsx +73 -0
  17. package/src/components/ChatPanel.jsx +461 -0
  18. package/src/components/Chip.jsx +61 -0
  19. package/src/components/Composer.jsx +20 -1
  20. package/src/components/Dialog.jsx +5 -10
  21. package/src/components/Modal.jsx +75 -0
  22. package/src/components/Popover.jsx +86 -0
  23. package/src/components/SearchField.jsx +30 -0
  24. package/src/components/icons.jsx +9 -0
  25. package/src/components/overlay.js +63 -0
  26. package/src/format.js +10 -0
  27. package/src/harness/attach.js +63 -0
  28. package/src/harness/index.d.ts +23 -0
  29. package/src/harness/index.js +6 -18
  30. package/src/hooks/useTypewriter.js +53 -0
  31. package/src/index.d.ts +260 -1
  32. package/src/index.js +27 -1
  33. package/src/input/dictate.js +60 -0
  34. package/src/state/turns.js +30 -0
  35. package/styles/chat.css +127 -1
  36. package/styles/chip.css +53 -0
  37. package/styles/dialog.css +42 -37
  38. package/styles/library.css +205 -0
  39. package/styles/preview.css +73 -0
  40. package/styles/sheet.css +16 -14
  41. package/styles/themes/dark.css +20 -0
  42. package/styles/themes/light.css +23 -0
  43. package/dist/chunk-2LYV4PIX.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -31,9 +31,13 @@ var src_exports = {};
31
31
  __export(src_exports, {
32
32
  AssistantTurn: () => AssistantTurn,
33
33
  AuthForm: () => AuthForm,
34
+ Card: () => Card,
35
+ Carousel: () => Carousel,
34
36
  ChatMessages: () => ChatMessages,
35
37
  ChatMessagesSkeleton: () => ChatMessagesSkeleton,
38
+ ChatPanel: () => ChatPanel,
36
39
  Chevron: () => Chevron,
40
+ Chip: () => Chip,
37
41
  CodeBlock: () => CodeBlock,
38
42
  Composer: () => Composer,
39
43
  DEFAULT_STATUS_LABELS: () => DEFAULT_STATUS_LABELS,
@@ -44,6 +48,9 @@ __export(src_exports, {
44
48
  IcDoc: () => IcDoc,
45
49
  IcGlobe: () => IcGlobe,
46
50
  IcList: () => IcList,
51
+ IcMic: () => IcMic,
52
+ IcPanelRight: () => IcPanelRight,
53
+ IcPaperclip: () => IcPaperclip,
47
54
  IcPlug: () => IcPlug,
48
55
  IcScroll: () => IcScroll,
49
56
  IcSearch: () => IcSearch,
@@ -53,8 +60,12 @@ __export(src_exports, {
53
60
  IcTerminal: () => IcTerminal,
54
61
  IcThink: () => IcThink,
55
62
  IcTool: () => IcTool,
63
+ IcX: () => IcX,
64
+ Modal: () => Modal,
56
65
  PaneResizer: () => PaneResizer,
66
+ Popover: () => Popover,
57
67
  SESSION_EVENT: () => SESSION_EVENT,
68
+ SearchField: () => SearchField,
58
69
  SheetGrid: () => SheetGrid,
59
70
  Svg: () => Svg,
60
71
  TaskList: () => TaskList,
@@ -65,9 +76,11 @@ __export(src_exports, {
65
76
  authConfig: () => authConfig,
66
77
  authFetch: () => authFetch,
67
78
  baseName: () => baseName,
79
+ bytesLabel: () => bytesLabel,
68
80
  clearSession: () => clearSession,
69
81
  configureAuth: () => configureAuth,
70
82
  createConversationStore: () => createConversationStore,
83
+ createDictation: () => createDictation,
71
84
  createResponsesDispatcher: () => createResponsesDispatcher,
72
85
  fetchBalance: () => fetchBalance,
73
86
  getSession: () => getSession,
@@ -91,8 +104,10 @@ __export(src_exports, {
91
104
  switchOrg: () => switchOrg,
92
105
  taskStatusGroup: () => taskStatusGroup,
93
106
  toolMeta: () => toolMeta,
107
+ turnsToMessages: () => turnsToMessages,
94
108
  useDialog: () => useDialog,
95
109
  useResizablePane: () => useResizablePane,
110
+ useTypewriter: () => useTypewriter,
96
111
  withReasoning: () => withReasoning,
97
112
  withResult: () => withResult,
98
113
  withStep: () => withStep,
@@ -278,6 +293,29 @@ function createConversationStore(makeInitial) {
278
293
  return { get, set, seed, updateLastAssistant, use };
279
294
  }
280
295
 
296
+ // src/state/turns.js
297
+ var TURN_STATUS = {
298
+ failed: "failed",
299
+ error: "failed",
300
+ cancelled: "cancelled",
301
+ incomplete: "incomplete",
302
+ max_turns: "incomplete",
303
+ timeout: "incomplete"
304
+ };
305
+ function turnsToMessages(turns) {
306
+ const out = [];
307
+ for (const t of turns || []) {
308
+ if (t.user) out.push({ role: "user", text: t.user });
309
+ const steps = (t.tools || []).map((x) => ({ name: x.name, args: x.arguments, result: x.result }));
310
+ const blocks = [];
311
+ if (steps.length) blocks.push({ kind: "tools", reasoning: "", steps });
312
+ if (t.assistant) blocks.push({ kind: "text", text: t.assistant });
313
+ const status = TURN_STATUS[t.status] || "done";
314
+ if (blocks.length || status !== "done") out.push({ role: "assistant", blocks, status });
315
+ }
316
+ return out;
317
+ }
318
+
281
319
  // src/components/icons.jsx
282
320
  var import_react2 = __toESM(require("react"), 1);
283
321
  var import_jsx_runtime = require("react/jsx-runtime");
@@ -358,6 +396,16 @@ var IcSend = () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Svg, { s: 16, ch
358
396
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 19V5" }),
359
397
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M5 12l7-7 7 7" })
360
398
  ] });
399
+ var IcX = ({ size = 14 }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Svg, { s: size, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M18 6 6 18M6 6l12 12" }) });
400
+ var IcMic = ({ size = 15 }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Svg, { s: size, children: [
401
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "9", y: "2", width: "6", height: "12", rx: "3" }),
402
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M5 11a7 7 0 0 0 14 0M12 18v4M8 22h8" })
403
+ ] });
404
+ var IcPaperclip = ({ size = 16 }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Svg, { s: size, children: /* @__PURE__ */ (0, import_jsx_runtime.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" }) });
405
+ var IcPanelRight = ({ size = 17 }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Svg, { s: size, children: [
406
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "3", y: "4", width: "18", height: "16", rx: "2" }),
407
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M15 4v16" })
408
+ ] });
361
409
 
362
410
  // src/components/toolMeta.js
363
411
  function humanize(s) {
@@ -725,6 +773,11 @@ function Composer(props) {
725
773
  rows = 1,
726
774
  autoGrow = true,
727
775
  maxRows = 15,
776
+ autoFocus,
777
+ // The composer on a landing page often has an ANIMATING placeholder (a typewriter cycling
778
+ // through example prompts), and a placeholder is the textarea's only accessible name unless
779
+ // one is given — so the field announces a different name every few seconds.
780
+ inputAriaLabel,
728
781
  attachments,
729
782
  accessoriesLeft,
730
783
  accessoriesRight,
@@ -756,12 +809,13 @@ function Composer(props) {
756
809
  value,
757
810
  disabled,
758
811
  rows,
812
+ autoFocus,
813
+ "aria-label": inputAriaLabel,
759
814
  onChange: (e) => onChange(e.target.value),
760
815
  onKeyDown: (e) => {
761
- if (e.key === "Enter" && !e.shiftKey) {
762
- e.preventDefault();
763
- onSend();
764
- }
816
+ if (e.key !== "Enter" || e.shiftKey) return;
817
+ e.preventDefault();
818
+ if (!sendDisabled) onSend();
765
819
  }
766
820
  }
767
821
  ),
@@ -774,9 +828,462 @@ function Composer(props) {
774
828
  ] });
775
829
  }
776
830
 
777
- // src/components/CodeBlock.jsx
831
+ // src/components/ChatPanel.jsx
832
+ var import_react7 = __toESM(require("react"), 1);
833
+
834
+ // src/components/Chip.jsx
778
835
  var import_react6 = __toESM(require("react"), 1);
779
836
  var import_jsx_runtime5 = require("react/jsx-runtime");
837
+ function Chip(props) {
838
+ const { label, icon, title, selected = false, onClick, onRemove, removeLabel, className } = props;
839
+ const cls = [
840
+ "uic-chip",
841
+ selected ? "is-selected" : "",
842
+ onClick && !selected ? "is-open" : "",
843
+ className || ""
844
+ ].filter(Boolean).join(" ");
845
+ const body = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
846
+ icon ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "uic-chip-ic", "aria-hidden": "true", children: icon }) : null,
847
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "uic-chip-l", children: label })
848
+ ] });
849
+ if (onClick && onRemove) {
850
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: cls, title, children: [
851
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "uic-chip-press", onClick, children: body }),
852
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "uic-chip-x", "aria-label": removeLabel, onClick: onRemove, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(IcX, { size: 12 }) })
853
+ ] });
854
+ }
855
+ if (onClick) {
856
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: cls, title, onClick, children: body });
857
+ }
858
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: cls, title, children: [
859
+ body,
860
+ onRemove ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "uic-chip-x", "aria-label": removeLabel, onClick: onRemove, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(IcX, { size: 12 }) }) : null
861
+ ] });
862
+ }
863
+
864
+ // src/format.js
865
+ function bytesLabel(n) {
866
+ if (n == null) return "";
867
+ if (n < 1024) return `${n} B`;
868
+ if (n < 1048576) return `${Math.round(n / 1024)} KB`;
869
+ return `${(n / 1048576).toFixed(1)} MB`;
870
+ }
871
+
872
+ // src/components/ChatPanel.jsx
873
+ var import_jsx_runtime6 = require("react/jsx-runtime");
874
+ var POLL_MS = 3e3;
875
+ var RETRY_MS = 2e4;
876
+ var PIN_PX = 80;
877
+ var PANEL_STATUS_LABELS = {
878
+ failed: "This turn failed. Please try again.",
879
+ cancelled: "Stopped",
880
+ incomplete: "The turn hit its limit. Send a follow up to continue."
881
+ };
882
+ function ChatPanel(props) {
883
+ const {
884
+ sessionId,
885
+ runTurn,
886
+ loadHistory,
887
+ onSessionStarted,
888
+ onChanged,
889
+ seed = "",
890
+ onSeedConsumed,
891
+ externalBusy = false,
892
+ attachments = null,
893
+ dictation = null,
894
+ title = "",
895
+ headerRight = null,
896
+ collapsed = false,
897
+ onToggleCollapse,
898
+ width,
899
+ placeholder = "Message",
900
+ emptyState = null,
901
+ busyState,
902
+ connectingLabel = "connecting",
903
+ connectingNote = "Still connecting. Your message will be sent as soon as it is online.",
904
+ workingLabel = "Working\u2026",
905
+ statusLabels = PANEL_STATUS_LABELS,
906
+ renderMarkdown,
907
+ userExtras,
908
+ toolLabels,
909
+ classNames = {}
910
+ } = props;
911
+ const [messages, setMessages] = (0, import_react7.useState)([]);
912
+ const [draft, setDraft] = (0, import_react7.useState)("");
913
+ const [busy, setBusy] = (0, import_react7.useState)(false);
914
+ const [connecting, setConnecting] = (0, import_react7.useState)(false);
915
+ const [histLoading, setHistLoading] = (0, import_react7.useState)(true);
916
+ const [staged, setStaged] = (0, import_react7.useState)([]);
917
+ const [attachErr, setAttachErr] = (0, import_react7.useState)("");
918
+ const [listening2, setListening] = (0, import_react7.useState)(false);
919
+ const pendingRef = (0, import_react7.useRef)(null);
920
+ const seededRef = (0, import_react7.useRef)(false);
921
+ const adoptedRef = (0, import_react7.useRef)(null);
922
+ const bodyRef = (0, import_react7.useRef)(null);
923
+ const fileRef = (0, import_react7.useRef)(null);
924
+ const pinnedRef = (0, import_react7.useRef)(true);
925
+ const prevExternalBusyRef = (0, import_react7.useRef)(false);
926
+ const prevIdRef = (0, import_react7.useRef)(sessionId);
927
+ const api = (0, import_react7.useRef)(null);
928
+ api.current = { runTurn, loadHistory, onSessionStarted, onChanged, onSeedConsumed };
929
+ (0, import_react7.useEffect)(() => () => dictation?.stop(), [dictation]);
930
+ function updateLastAsst(fn) {
931
+ setMessages((m) => {
932
+ const out = m.slice();
933
+ for (let i = out.length - 1; i >= 0; i -= 1) {
934
+ if (out[i].role === "assistant") {
935
+ out[i] = fn({ ...out[i] });
936
+ break;
937
+ }
938
+ }
939
+ return out;
940
+ });
941
+ }
942
+ function dropRunningAsst() {
943
+ setMessages((m) => m.length && m[m.length - 1].role === "assistant" && m[m.length - 1].status === "running" ? m.slice(0, -1) : m);
944
+ }
945
+ const onBodyScroll = () => {
946
+ const el = bodyRef.current;
947
+ if (el) pinnedRef.current = el.scrollHeight - el.scrollTop - el.clientHeight <= PIN_PX;
948
+ };
949
+ (0, import_react7.useEffect)(() => {
950
+ const el = bodyRef.current;
951
+ if (el && pinnedRef.current) el.scrollTo({ top: el.scrollHeight });
952
+ }, [messages, connecting, histLoading]);
953
+ const deliver = (0, import_react7.useCallback)(async (text, files = []) => {
954
+ setBusy(true);
955
+ setMessages((m) => [...m, { role: "assistant", blocks: [], status: "running" }]);
956
+ try {
957
+ const out = await api.current.runTurn({
958
+ sessionId,
959
+ text,
960
+ attachments: files,
961
+ handlers: {
962
+ onSession: (sid) => {
963
+ if (sid && sid !== sessionId) adoptedRef.current = sid;
964
+ api.current.onSessionStarted?.(sid);
965
+ },
966
+ onReasoningDelta: (d) => updateLastAsst((a) => ({ ...a, blocks: withReasoning(a.blocks, d) })),
967
+ onToolCall: (name, args, callId) => updateLastAsst((a) => ({ ...a, blocks: withStep(a.blocks, { name, args, callId }) })),
968
+ onToolResult: (callId, output) => updateLastAsst((a) => ({ ...a, blocks: withResult(a.blocks, callId, output) })),
969
+ onTextDelta: (d) => updateLastAsst((a) => ({ ...a, blocks: withText(a.blocks, d) })),
970
+ onDone: (status) => updateLastAsst((a) => ({ ...a, status: status === "completed" ? "done" : status })),
971
+ onError: () => updateLastAsst((a) => ({
972
+ ...a,
973
+ blocks: a.blocks.length ? a.blocks : withText([], "Something went wrong. Please try again."),
974
+ status: "failed"
975
+ }))
976
+ }
977
+ }) || {};
978
+ if (out.connecting) {
979
+ dropRunningAsst();
980
+ pendingRef.current = { text, files };
981
+ setConnecting(true);
982
+ return;
983
+ }
984
+ pendingRef.current = null;
985
+ setConnecting(false);
986
+ updateLastAsst((a) => a.status === "running" ? { ...a, status: "done" } : a);
987
+ api.current.onChanged?.();
988
+ } catch {
989
+ dropRunningAsst();
990
+ pendingRef.current = { text, files };
991
+ setConnecting(true);
992
+ } finally {
993
+ setBusy(false);
994
+ }
995
+ }, [sessionId]);
996
+ const preparing = staged.some((f) => f.pending);
997
+ const sendBlocked = busy || histLoading || preparing;
998
+ function send() {
999
+ const t = draft.trim();
1000
+ if (!t || sendBlocked) return;
1001
+ if (listening2) {
1002
+ dictation?.stop();
1003
+ setListening(false);
1004
+ }
1005
+ const files = staged;
1006
+ setMessages((m) => [...m, { role: "user", text: t, files: files.map((f) => f.name) }]);
1007
+ setDraft("");
1008
+ setStaged([]);
1009
+ setAttachErr("");
1010
+ deliver(t, files);
1011
+ }
1012
+ (0, import_react7.useEffect)(() => {
1013
+ const adopted = adoptedRef.current;
1014
+ adoptedRef.current = null;
1015
+ if (adopted && adopted === sessionId) {
1016
+ prevIdRef.current = sessionId;
1017
+ return void 0;
1018
+ }
1019
+ if (prevIdRef.current !== sessionId) {
1020
+ prevIdRef.current = sessionId;
1021
+ setMessages([]);
1022
+ setHistLoading(true);
1023
+ setStaged([]);
1024
+ setAttachErr("");
1025
+ seededRef.current = false;
1026
+ }
1027
+ if (seed) api.current.onSeedConsumed?.();
1028
+ let dead = false;
1029
+ Promise.resolve(api.current.loadHistory(sessionId)).then((hist) => {
1030
+ if (dead) return;
1031
+ if (hist?.length) setMessages(hist);
1032
+ setHistLoading(false);
1033
+ if (seed && !seededRef.current && !hist?.length) {
1034
+ seededRef.current = true;
1035
+ setMessages([{ role: "user", text: seed }]);
1036
+ deliver(seed);
1037
+ }
1038
+ }).catch(() => {
1039
+ if (!dead) setHistLoading(false);
1040
+ });
1041
+ return () => {
1042
+ dead = true;
1043
+ };
1044
+ }, [sessionId]);
1045
+ (0, import_react7.useEffect)(() => {
1046
+ if (!connecting) return void 0;
1047
+ const iv = window.setInterval(() => {
1048
+ const p = pendingRef.current;
1049
+ if (p && !busy) deliver(p.text, p.files);
1050
+ }, RETRY_MS);
1051
+ return () => window.clearInterval(iv);
1052
+ }, [connecting, busy, deliver]);
1053
+ (0, import_react7.useEffect)(() => {
1054
+ let dead = false;
1055
+ let poll;
1056
+ const reload = () => Promise.resolve(api.current.loadHistory(sessionId)).then((hist) => {
1057
+ if (!dead && hist?.length && !busy && !pendingRef.current) setMessages(hist);
1058
+ }).catch(() => {
1059
+ });
1060
+ if (externalBusy && messages.length === 0 && !busy) poll = window.setInterval(reload, POLL_MS);
1061
+ if (prevExternalBusyRef.current && !externalBusy) {
1062
+ reload();
1063
+ api.current.onChanged?.();
1064
+ }
1065
+ prevExternalBusyRef.current = externalBusy;
1066
+ return () => {
1067
+ dead = true;
1068
+ if (poll) window.clearInterval(poll);
1069
+ };
1070
+ }, [externalBusy, messages.length, busy, sessionId]);
1071
+ function pick(list) {
1072
+ if (!attachments?.prepare) return;
1073
+ setAttachErr("");
1074
+ for (const file of list) {
1075
+ const entry = { name: file.name, size: file.size, pending: true };
1076
+ setStaged((cur) => [...cur, entry]);
1077
+ Promise.resolve(attachments.prepare(file)).then((ready) => {
1078
+ setStaged((cur) => cur.map((s) => s === entry ? { name: entry.name, size: entry.size, ...ready } : s));
1079
+ }).catch((e) => {
1080
+ setStaged((cur) => cur.filter((s) => s !== entry));
1081
+ setAttachErr(e?.message || `${file.name} could not be attached.`);
1082
+ });
1083
+ }
1084
+ }
1085
+ function toggleDictation() {
1086
+ if (!dictation) return;
1087
+ if (listening2) {
1088
+ dictation.stop();
1089
+ setListening(false);
1090
+ return;
1091
+ }
1092
+ setListening(true);
1093
+ dictation.start({
1094
+ onText: (text) => setDraft((cur) => cur ? `${cur.replace(/\s+$/, "")} ${text}` : text),
1095
+ onEnd: () => setListening(false),
1096
+ onError: () => setListening(false)
1097
+ });
1098
+ }
1099
+ const rootCls = ["uic-chat", collapsed ? "is-collapsed" : "", classNames.root || ""].filter(Boolean).join(" ");
1100
+ const toggle = onToggleCollapse ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1101
+ "button",
1102
+ {
1103
+ type: "button",
1104
+ className: "uic-panel-toggle",
1105
+ onClick: onToggleCollapse,
1106
+ title: collapsed ? "Show the conversation" : "Hide the conversation",
1107
+ "aria-label": collapsed ? "Show the conversation" : "Hide the conversation",
1108
+ "aria-expanded": !collapsed,
1109
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(IcPanelRight, {})
1110
+ }
1111
+ ) : null;
1112
+ if (collapsed) {
1113
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("aside", { className: rootCls, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "uic-chat-h", children: toggle }) });
1114
+ }
1115
+ const empty = messages.length === 0;
1116
+ const attachControl = attachments ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
1117
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1118
+ "input",
1119
+ {
1120
+ ref: fileRef,
1121
+ type: "file",
1122
+ hidden: true,
1123
+ accept: attachments.accept,
1124
+ multiple: attachments.multiple !== false,
1125
+ onChange: (e) => {
1126
+ pick([...e.target.files]);
1127
+ e.target.value = "";
1128
+ }
1129
+ }
1130
+ ),
1131
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1132
+ "button",
1133
+ {
1134
+ type: "button",
1135
+ className: "uic-chat-icon",
1136
+ "aria-label": "Attach a file",
1137
+ disabled: busy,
1138
+ onClick: () => fileRef.current?.click(),
1139
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(IcPaperclip, {})
1140
+ }
1141
+ )
1142
+ ] }) : null;
1143
+ const micControl = dictation ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1144
+ "button",
1145
+ {
1146
+ type: "button",
1147
+ className: "uic-chat-icon" + (listening2 ? " is-on" : ""),
1148
+ "aria-label": listening2 ? "Stop dictating" : "Dictate",
1149
+ "aria-pressed": listening2,
1150
+ disabled: busy,
1151
+ onClick: toggleDictation,
1152
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(IcMic, {})
1153
+ }
1154
+ ) : null;
1155
+ const defaultBusyState = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "uic-chat-empty", children: [
1156
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "uic-chat-pulse", "aria-hidden": "true" }),
1157
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "uic-chat-empty-t", children: workingLabel })
1158
+ ] });
1159
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("aside", { className: rootCls, style: width ? { flex: `0 0 ${width}px` } : void 0, children: [
1160
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "uic-chat-h", children: [
1161
+ toggle,
1162
+ title ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "uic-chat-title", title, children: title }) : null,
1163
+ headerRight,
1164
+ connecting ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "uic-chat-conn", children: connectingLabel }) : null
1165
+ ] }),
1166
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "uic-chat-body", ref: bodyRef, onScroll: onBodyScroll, role: "log", "aria-live": "polite", children: [
1167
+ histLoading ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ChatMessagesSkeleton, {}) : empty && externalBusy ? busyState === void 0 ? defaultBusyState : busyState : empty ? emptyState : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1168
+ ChatMessages,
1169
+ {
1170
+ messages,
1171
+ renderMarkdown,
1172
+ userExtras: (m, i) => {
1173
+ const own = userExtras?.(m, i);
1174
+ if (own !== void 0) return own;
1175
+ if (!m.files?.length) return void 0;
1176
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "uic-chat-msg-files", children: m.files.map((n) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Chip, { icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(IcPaperclip, { size: 11 }), label: n, title: n }, n)) });
1177
+ },
1178
+ workingLabel,
1179
+ toolLabels: { workingLabel, ...toolLabels || {} },
1180
+ statusLabels
1181
+ }
1182
+ ),
1183
+ connecting ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "uic-chat-note", role: "status", children: [
1184
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "uic-chat-dot", "aria-hidden": "true" }),
1185
+ connectingNote
1186
+ ] }) : null
1187
+ ] }),
1188
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1189
+ Composer,
1190
+ {
1191
+ value: draft,
1192
+ onChange: setDraft,
1193
+ onSend: send,
1194
+ disabled: histLoading,
1195
+ sendDisabled: sendBlocked || !draft.trim(),
1196
+ placeholder,
1197
+ rows: 2,
1198
+ autoGrow: false,
1199
+ classNames: { root: "uic-chat-cmp", input: "uic-chat-cmp-input", row: "uic-chat-cmp-row" },
1200
+ attachments: staged.length > 0 || attachErr ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "uic-chat-files", children: [
1201
+ staged.map((f, i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1202
+ Chip,
1203
+ {
1204
+ icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(IcPaperclip, { size: 11 }),
1205
+ title: f.name,
1206
+ label: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
1207
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "uic-chip-t", children: f.name }),
1208
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "uic-chip-meta", children: f.pending ? "\u2026" : bytesLabel(f.size) })
1209
+ ] }),
1210
+ onRemove: () => setStaged((c) => c.filter((_, j) => j !== i)),
1211
+ removeLabel: `Remove ${f.name}`
1212
+ },
1213
+ `${f.name}-${i}`
1214
+ )),
1215
+ attachErr ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "uic-chat-file-err", children: attachErr }) : null
1216
+ ] }) : null,
1217
+ accessoriesLeft: attachControl,
1218
+ accessoriesRight: micControl,
1219
+ renderSend: () => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1220
+ "button",
1221
+ {
1222
+ type: "button",
1223
+ className: "uic-chat-send",
1224
+ onClick: send,
1225
+ disabled: sendBlocked || !draft.trim(),
1226
+ "aria-label": "Send message",
1227
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(IcSend, {})
1228
+ }
1229
+ )
1230
+ }
1231
+ )
1232
+ ] });
1233
+ }
1234
+
1235
+ // src/input/dictate.js
1236
+ var Impl = typeof window !== "undefined" ? window.SpeechRecognition || window.webkitSpeechRecognition : null;
1237
+ function createDictation({ lang } = {}) {
1238
+ if (!Impl) return null;
1239
+ let rec = null;
1240
+ return {
1241
+ /** onText fires once per finished phrase, so the draft grows as you speak rather than being
1242
+ * rewritten from scratch on every interim guess. */
1243
+ start({ onText, onEnd, onError }) {
1244
+ this.stop();
1245
+ rec = new Impl();
1246
+ rec.lang = lang || navigator.language || "en-US";
1247
+ rec.continuous = true;
1248
+ rec.interimResults = false;
1249
+ rec.onresult = (e) => {
1250
+ for (let i = e.resultIndex; i < e.results.length; i += 1) {
1251
+ if (!e.results[i].isFinal) continue;
1252
+ const text = String(e.results[i][0]?.transcript || "").trim();
1253
+ if (text) onText?.(text);
1254
+ }
1255
+ };
1256
+ rec.onerror = (e) => {
1257
+ rec = null;
1258
+ if (e.error === "no-speech" || e.error === "aborted") onEnd?.();
1259
+ else onError?.(e.error || "Dictation stopped.");
1260
+ };
1261
+ rec.onend = () => {
1262
+ rec = null;
1263
+ onEnd?.();
1264
+ };
1265
+ try {
1266
+ rec.start();
1267
+ } catch (e) {
1268
+ rec = null;
1269
+ onError?.(e?.message || "Dictation could not start.");
1270
+ }
1271
+ },
1272
+ stop() {
1273
+ if (!rec) return;
1274
+ const r = rec;
1275
+ rec = null;
1276
+ try {
1277
+ r.stop();
1278
+ } catch {
1279
+ }
1280
+ }
1281
+ };
1282
+ }
1283
+
1284
+ // src/components/CodeBlock.jsx
1285
+ var import_react8 = __toESM(require("react"), 1);
1286
+ var import_jsx_runtime7 = require("react/jsx-runtime");
780
1287
  var _hljsPromise = null;
781
1288
  function loadHljs() {
782
1289
  if (!_hljsPromise) {
@@ -847,8 +1354,8 @@ function CodeBlock(props) {
847
1354
  const { code, language, className } = props;
848
1355
  const src = String(code || "");
849
1356
  const lang = canonicalLang(language);
850
- const [hl, setHl] = import_react6.default.useState(null);
851
- import_react6.default.useEffect(() => {
1357
+ const [hl, setHl] = import_react8.default.useState(null);
1358
+ import_react8.default.useEffect(() => {
852
1359
  if (!lang || !src) return void 0;
853
1360
  let cancelled = false;
854
1361
  const timer = setTimeout(() => {
@@ -868,15 +1375,15 @@ function CodeBlock(props) {
868
1375
  }, [src, lang]);
869
1376
  const html = hl && hl.src === src ? hl.html : null;
870
1377
  const label = String(language || "").toLowerCase();
871
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("pre", { className: "wbx-code" + (className ? " " + className : ""), children: [
872
- label ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wbx-code-lang", "aria-hidden": "true", children: label }) : null,
873
- html != null ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("code", { className: "hljs language-" + label, dangerouslySetInnerHTML: { __html: html } }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("code", { className: label ? "language-" + label : void 0, children: src })
1378
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("pre", { className: "wbx-code" + (className ? " " + className : ""), children: [
1379
+ label ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "wbx-code-lang", "aria-hidden": "true", children: label }) : null,
1380
+ html != null ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", { className: "hljs language-" + label, dangerouslySetInnerHTML: { __html: html } }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", { className: label ? "language-" + label : void 0, children: src })
874
1381
  ] });
875
1382
  }
876
1383
 
877
1384
  // src/components/resizable.jsx
878
- var import_react7 = __toESM(require("react"), 1);
879
- var import_jsx_runtime6 = require("react/jsx-runtime");
1385
+ var import_react9 = __toESM(require("react"), 1);
1386
+ var import_jsx_runtime8 = require("react/jsx-runtime");
880
1387
  function useResizablePane(opts = {}) {
881
1388
  const {
882
1389
  initial = 380,
@@ -890,12 +1397,12 @@ function useResizablePane(opts = {}) {
890
1397
  storageKey = null
891
1398
  // persist the chosen width per user (localStorage)
892
1399
  } = opts;
893
- const clamp = (0, import_react7.useCallback)((x) => {
1400
+ const clamp = (0, import_react9.useCallback)((x) => {
894
1401
  let hi = max ?? Infinity;
895
1402
  if (maxFraction && typeof window !== "undefined") hi = Math.min(hi, Math.round(window.innerWidth * maxFraction));
896
1403
  return Math.min(hi, Math.max(min, x));
897
1404
  }, [min, max, maxFraction]);
898
- const [width, setWidth] = (0, import_react7.useState)(() => {
1405
+ const [width, setWidth] = (0, import_react9.useState)(() => {
899
1406
  if (storageKey && typeof window !== "undefined") {
900
1407
  try {
901
1408
  const n = parseInt(window.localStorage.getItem(storageKey) || "", 10);
@@ -905,16 +1412,16 @@ function useResizablePane(opts = {}) {
905
1412
  }
906
1413
  return initial;
907
1414
  });
908
- const widthRef = (0, import_react7.useRef)(width);
1415
+ const widthRef = (0, import_react9.useRef)(width);
909
1416
  widthRef.current = width;
910
- const persist = (0, import_react7.useCallback)((w) => {
1417
+ const persist = (0, import_react9.useCallback)((w) => {
911
1418
  if (!storageKey) return;
912
1419
  try {
913
1420
  window.localStorage.setItem(storageKey, String(w));
914
1421
  } catch {
915
1422
  }
916
1423
  }, [storageKey]);
917
- const onMouseDown = (0, import_react7.useCallback)((e) => {
1424
+ const onMouseDown = (0, import_react9.useCallback)((e) => {
918
1425
  e.preventDefault();
919
1426
  const sx = e.clientX, base = widthRef.current, dir = fromRight ? -1 : 1;
920
1427
  document.body.classList.add("uic-resizing");
@@ -930,7 +1437,7 @@ function useResizablePane(opts = {}) {
930
1437
  window.addEventListener("mouseup", up);
931
1438
  document.body.style.cursor = "col-resize";
932
1439
  }, [clamp, fromRight, persist]);
933
- const reset = (0, import_react7.useCallback)(() => {
1440
+ const reset = (0, import_react9.useCallback)(() => {
934
1441
  setWidth(initial);
935
1442
  if (storageKey) {
936
1443
  try {
@@ -943,7 +1450,7 @@ function useResizablePane(opts = {}) {
943
1450
  }
944
1451
  function PaneResizer(props) {
945
1452
  const { pane, className, title = "Drag to resize (double-click to reset)" } = props;
946
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1453
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
947
1454
  "div",
948
1455
  {
949
1456
  className: className ?? "uic-vresize",
@@ -957,8 +1464,8 @@ function PaneResizer(props) {
957
1464
  }
958
1465
 
959
1466
  // src/components/TaskList.jsx
960
- var import_react8 = require("react");
961
- var import_jsx_runtime7 = require("react/jsx-runtime");
1467
+ var import_react10 = require("react");
1468
+ var import_jsx_runtime9 = require("react/jsx-runtime");
962
1469
  var STATUS_GROUPS = {
963
1470
  all: () => true,
964
1471
  working: (s) => ["running", "starting", "queued", "in_progress"].includes(s),
@@ -996,17 +1503,17 @@ function TaskList({
996
1503
  statusKey = "status",
997
1504
  timeKey = "updated_at"
998
1505
  }) {
999
- const [head, setHead] = (0, import_react8.useState)(null);
1000
- const [tail, setTail] = (0, import_react8.useState)([]);
1001
- const [cursor, setCursor] = (0, import_react8.useState)("");
1002
- const [loadingMore, setLoadingMore] = (0, import_react8.useState)(false);
1003
- const [q, setQ] = (0, import_react8.useState)("");
1004
- const [statusFilter, setStatusFilter] = (0, import_react8.useState)("all");
1005
- const alive = (0, import_react8.useRef)(true);
1006
- (0, import_react8.useEffect)(() => () => {
1506
+ const [head, setHead] = (0, import_react10.useState)(null);
1507
+ const [tail, setTail] = (0, import_react10.useState)([]);
1508
+ const [cursor, setCursor] = (0, import_react10.useState)("");
1509
+ const [loadingMore, setLoadingMore] = (0, import_react10.useState)(false);
1510
+ const [q, setQ] = (0, import_react10.useState)("");
1511
+ const [statusFilter, setStatusFilter] = (0, import_react10.useState)("all");
1512
+ const alive = (0, import_react10.useRef)(true);
1513
+ (0, import_react10.useEffect)(() => () => {
1007
1514
  alive.current = false;
1008
1515
  }, []);
1009
- (0, import_react8.useEffect)(() => {
1516
+ (0, import_react10.useEffect)(() => {
1010
1517
  let ok = true;
1011
1518
  Promise.resolve(fetchPage("")).then((r) => {
1012
1519
  if (!ok) return;
@@ -1019,7 +1526,7 @@ function TaskList({
1019
1526
  ok = false;
1020
1527
  };
1021
1528
  }, [fetchPage, refreshNonce]);
1022
- const loadMore = (0, import_react8.useCallback)(() => {
1529
+ const loadMore = (0, import_react10.useCallback)(() => {
1023
1530
  if (!cursor || loadingMore) return;
1024
1531
  setLoadingMore(true);
1025
1532
  Promise.resolve(fetchPage(cursor)).then((r) => {
@@ -1031,12 +1538,12 @@ function TaskList({
1031
1538
  if (alive.current) setLoadingMore(false);
1032
1539
  });
1033
1540
  }, [cursor, loadingMore, fetchPage]);
1034
- const items = (0, import_react8.useMemo)(() => {
1541
+ const items = (0, import_react10.useMemo)(() => {
1035
1542
  const h = head || [];
1036
1543
  const seen = new Set(h.map((x) => x?.[idKey]));
1037
1544
  return [...h, ...tail.filter((t) => !seen.has(t?.[idKey]))];
1038
1545
  }, [head, tail, idKey]);
1039
- const shown = (0, import_react8.useMemo)(() => {
1546
+ const shown = (0, import_react10.useMemo)(() => {
1040
1547
  const needle = q.trim().toLowerCase();
1041
1548
  const pass = STATUS_GROUPS[statusFilter] || STATUS_GROUPS.all;
1042
1549
  return items.filter((it) => {
@@ -1049,14 +1556,14 @@ function TaskList({
1049
1556
  const el = e.currentTarget;
1050
1557
  if (el.scrollTop + el.clientHeight > el.scrollHeight - 140) loadMore();
1051
1558
  };
1052
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "rui-tasks", children: [
1053
- header ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "rui-tasks-header", children: header }) : null,
1054
- onNew ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("button", { type: "button", className: "rui-tasks-new", onClick: onNew, children: [
1559
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "rui-tasks", children: [
1560
+ header ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "rui-tasks-header", children: header }) : null,
1561
+ onNew ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("button", { type: "button", className: "rui-tasks-new", onClick: onNew, children: [
1055
1562
  "+ ",
1056
1563
  newLabel
1057
1564
  ] }) : null,
1058
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "rui-tasks-filters", children: [
1059
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1565
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "rui-tasks-filters", children: [
1566
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1060
1567
  "input",
1061
1568
  {
1062
1569
  className: "rui-tasks-search",
@@ -1066,7 +1573,7 @@ function TaskList({
1066
1573
  "aria-label": "Filter tasks"
1067
1574
  }
1068
1575
  ),
1069
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1576
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1070
1577
  "select",
1071
1578
  {
1072
1579
  className: "rui-tasks-status",
@@ -1074,19 +1581,19 @@ function TaskList({
1074
1581
  onChange: (e) => setStatusFilter(e.target.value),
1075
1582
  "aria-label": "Filter by status",
1076
1583
  children: [
1077
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: "all", children: "All" }),
1078
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: "working", children: "Working" }),
1079
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: "done", children: "Done" }),
1080
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: "failed", children: "Failed" })
1584
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "all", children: "All" }),
1585
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "working", children: "Working" }),
1586
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "done", children: "Done" }),
1587
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "failed", children: "Failed" })
1081
1588
  ]
1082
1589
  }
1083
1590
  )
1084
1591
  ] }),
1085
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "rui-tasks-list", onScroll, children: [
1086
- head === null ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "rui-tasks-empty", children: "Loading\u2026" }) : shown.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "rui-tasks-empty", children: items.length ? "No matching tasks" : emptyLabel }) : shown.map((it) => {
1592
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "rui-tasks-list", onScroll, children: [
1593
+ head === null ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "rui-tasks-empty", children: "Loading\u2026" }) : shown.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "rui-tasks-empty", children: items.length ? "No matching tasks" : emptyLabel }) : shown.map((it) => {
1087
1594
  const id = it?.[idKey];
1088
1595
  const group = taskStatusGroup(it?.[statusKey]);
1089
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1596
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1090
1597
  "div",
1091
1598
  {
1092
1599
  className: `rui-task${id === selected ? " is-selected" : ""}`,
@@ -1097,15 +1604,15 @@ function TaskList({
1097
1604
  if (e.key === "Enter" || e.key === " ") onSelect?.(id);
1098
1605
  },
1099
1606
  children: [
1100
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "rui-task-main", children: [
1101
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "rui-task-title", children: it?.[titleKey] || "Untitled task" }),
1102
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "rui-task-meta", children: renderMeta ? renderMeta(it) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
1103
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: `rui-task-dot is-${group}` }),
1104
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "rui-task-status", children: it?.[statusKey] || "" }),
1105
- it?.[timeKey] ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "rui-task-time", children: relTime(it[timeKey]) }) : null
1607
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "rui-task-main", children: [
1608
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "rui-task-title", children: it?.[titleKey] || "Untitled task" }),
1609
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "rui-task-meta", children: renderMeta ? renderMeta(it) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
1610
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: `rui-task-dot is-${group}` }),
1611
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "rui-task-status", children: it?.[statusKey] || "" }),
1612
+ it?.[timeKey] ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "rui-task-time", children: relTime(it[timeKey]) }) : null
1106
1613
  ] }) })
1107
1614
  ] }),
1108
- onDelete ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1615
+ onDelete ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1109
1616
  "button",
1110
1617
  {
1111
1618
  type: "button",
@@ -1123,73 +1630,104 @@ function TaskList({
1123
1630
  id
1124
1631
  );
1125
1632
  }),
1126
- loadingMore ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "rui-tasks-empty", children: "Loading more\u2026" }) : null
1633
+ loadingMore ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "rui-tasks-empty", children: "Loading more\u2026" }) : null
1127
1634
  ] })
1128
1635
  ] });
1129
1636
  }
1130
1637
 
1131
1638
  // src/components/Dialog.jsx
1132
- var import_react9 = require("react");
1639
+ var import_react12 = require("react");
1133
1640
  var import_react_dom = require("react-dom");
1134
- var import_jsx_runtime8 = require("react/jsx-runtime");
1135
- var DialogCtx = (0, import_react9.createContext)(null);
1641
+
1642
+ // src/components/overlay.js
1643
+ var import_react11 = require("react");
1644
+ var stack = [];
1645
+ var listening = false;
1646
+ function onKey(e) {
1647
+ if (e.key !== "Escape") return;
1648
+ const top = stack[stack.length - 1];
1649
+ if (!top) return;
1650
+ e.preventDefault();
1651
+ top.onEscape?.();
1652
+ }
1653
+ function listen() {
1654
+ if (listening || typeof document === "undefined") return;
1655
+ document.addEventListener("keydown", onKey);
1656
+ listening = true;
1657
+ }
1658
+ function unlisten() {
1659
+ if (!listening || stack.length) return;
1660
+ document.removeEventListener("keydown", onKey);
1661
+ listening = false;
1662
+ }
1663
+ function pushOverlay(entry) {
1664
+ stack.push(entry);
1665
+ listen();
1666
+ return () => {
1667
+ const i = stack.indexOf(entry);
1668
+ if (i >= 0) stack.splice(i, 1);
1669
+ unlisten();
1670
+ };
1671
+ }
1672
+ function useOverlayEscape(active, onEscape) {
1673
+ (0, import_react11.useEffect)(() => {
1674
+ if (!active) return void 0;
1675
+ return pushOverlay({ onEscape });
1676
+ }, [active, onEscape]);
1677
+ }
1678
+
1679
+ // src/components/Dialog.jsx
1680
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1681
+ var DialogCtx = (0, import_react12.createContext)(null);
1136
1682
  var LABELS = {
1137
1683
  en: { confirm: "Confirm", cancel: "Cancel", ok: "OK", create: "Create", required: "Please enter a value" },
1138
1684
  zh: { confirm: "\u786E\u8BA4", cancel: "\u53D6\u6D88", ok: "\u597D\u7684", create: "\u521B\u5EFA", required: "\u8BF7\u8F93\u5165\u5185\u5BB9" }
1139
1685
  };
1140
1686
  var _idSeq = 0;
1141
1687
  function DialogHost({ children, locale = "en", labels }) {
1142
- const [stack, setStack] = (0, import_react9.useState)([]);
1143
- const t = (0, import_react9.useMemo)(
1688
+ const [stack2, setStack] = (0, import_react12.useState)([]);
1689
+ const t = (0, import_react12.useMemo)(
1144
1690
  () => ({ ...LABELS[locale] || LABELS.en, ...labels || {} }),
1145
1691
  [locale, labels]
1146
1692
  );
1147
- const open = (0, import_react9.useCallback)((spec) => new Promise((resolve) => {
1693
+ const open = (0, import_react12.useCallback)((spec) => new Promise((resolve) => {
1148
1694
  setStack((s) => [...s, { id: `dlg_${++_idSeq}`, spec, resolve }]);
1149
1695
  }), []);
1150
- const close = (0, import_react9.useCallback)((id, value) => {
1696
+ const close = (0, import_react12.useCallback)((id, value) => {
1151
1697
  setStack((s) => {
1152
1698
  const target = s.find((d) => d.id === id);
1153
1699
  if (target) target.resolve(value);
1154
1700
  return s.filter((d) => d.id !== id);
1155
1701
  });
1156
1702
  }, []);
1157
- const ctx = (0, import_react9.useMemo)(() => ({
1703
+ const ctx = (0, import_react12.useMemo)(() => ({
1158
1704
  confirm: (opts) => open({ kind: "confirm", ...opts }),
1159
1705
  prompt: (opts) => open({ kind: "prompt", ...opts }),
1160
1706
  alert: (opts) => open({ kind: "alert", ...opts }),
1161
1707
  create: (opts) => open({ kind: "create", ...opts }),
1162
1708
  labels: t
1163
1709
  }), [open, t]);
1164
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(DialogCtx.Provider, { value: ctx, children: [
1710
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(DialogCtx.Provider, { value: ctx, children: [
1165
1711
  children,
1166
- stack.length > 0 && typeof document !== "undefined" && (0, import_react_dom.createPortal)(
1167
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rui-dlg-root", role: "presentation", children: stack.map((d, i) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogShell, { dialog: d, isTop: i === stack.length - 1, onClose: close, t }, d.id)) }),
1712
+ stack2.length > 0 && typeof document !== "undefined" && (0, import_react_dom.createPortal)(
1713
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "rui-dlg-root", role: "presentation", children: stack2.map((d, i) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(DialogShell, { dialog: d, isTop: i === stack2.length - 1, onClose: close, t }, d.id)) }),
1168
1714
  document.body
1169
1715
  )
1170
1716
  ] });
1171
1717
  }
1172
1718
  function useDialog() {
1173
- const ctx = (0, import_react9.useContext)(DialogCtx);
1719
+ const ctx = (0, import_react12.useContext)(DialogCtx);
1174
1720
  if (!ctx) throw new Error("useDialog() called outside <DialogHost>");
1175
1721
  return ctx;
1176
1722
  }
1177
1723
  var cancelValue = (kind) => kind === "prompt" || kind === "create" ? null : false;
1178
1724
  function DialogShell({ dialog, isTop, onClose, t }) {
1179
1725
  const { id, spec } = dialog;
1180
- const ref = (0, import_react9.useRef)(null);
1181
- const titleId = (0, import_react9.useId)();
1182
- (0, import_react9.useEffect)(() => {
1183
- if (!isTop) return void 0;
1184
- const onKey = (e) => {
1185
- if (e.key !== "Escape") return;
1186
- e.preventDefault();
1187
- onClose(id, cancelValue(spec.kind));
1188
- };
1189
- document.addEventListener("keydown", onKey);
1190
- return () => document.removeEventListener("keydown", onKey);
1191
- }, [id, isTop, onClose, spec.kind]);
1192
- (0, import_react9.useEffect)(() => {
1726
+ const ref = (0, import_react12.useRef)(null);
1727
+ const titleId = (0, import_react12.useId)();
1728
+ const escape = (0, import_react12.useCallback)(() => onClose(id, cancelValue(spec.kind)), [id, onClose, spec.kind]);
1729
+ useOverlayEscape(isTop, escape);
1730
+ (0, import_react12.useEffect)(() => {
1193
1731
  if (!isTop || !ref.current) return;
1194
1732
  const el = ref.current.querySelector("input, textarea") || ref.current.querySelector(".rui-dlg-primary") || ref.current.querySelector("button");
1195
1733
  el?.focus();
@@ -1198,7 +1736,7 @@ function DialogShell({ dialog, isTop, onClose, t }) {
1198
1736
  if (e.target === e.currentTarget && isTop) onClose(id, cancelValue(spec.kind));
1199
1737
  };
1200
1738
  const done = (v) => onClose(id, v);
1201
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rui-dlg-backdrop", onClick: onBackdrop, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1739
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "rui-dlg-backdrop", onClick: onBackdrop, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1202
1740
  "div",
1203
1741
  {
1204
1742
  ref,
@@ -1207,34 +1745,34 @@ function DialogShell({ dialog, isTop, onClose, t }) {
1207
1745
  "aria-labelledby": spec.title ? titleId : void 0,
1208
1746
  className: `rui-dlg-card${spec.kind === "create" ? " is-wide" : ""}`,
1209
1747
  children: [
1210
- spec.kind === "alert" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AlertBody, { spec, onClose: done, t, titleId }),
1211
- spec.kind === "confirm" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ConfirmBody, { spec, onClose: done, t, titleId }),
1212
- spec.kind === "prompt" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(PromptBody, { spec, onClose: done, t, titleId }),
1213
- spec.kind === "create" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CreateBody, { spec, onClose: done, t, titleId })
1748
+ spec.kind === "alert" && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(AlertBody, { spec, onClose: done, t, titleId }),
1749
+ spec.kind === "confirm" && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ConfirmBody, { spec, onClose: done, t, titleId }),
1750
+ spec.kind === "prompt" && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PromptBody, { spec, onClose: done, t, titleId }),
1751
+ spec.kind === "create" && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CreateBody, { spec, onClose: done, t, titleId })
1214
1752
  ]
1215
1753
  }
1216
1754
  ) });
1217
1755
  }
1218
1756
  function Header({ title, variant, titleId }) {
1219
1757
  if (!title) return null;
1220
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `rui-dlg-h${variant ? ` is-${variant}` : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rui-dlg-title", id: titleId, children: title }) });
1758
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: `rui-dlg-h${variant ? ` is-${variant}` : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "rui-dlg-title", id: titleId, children: title }) });
1221
1759
  }
1222
- var Footer = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rui-dlg-f", children });
1760
+ var Footer = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "rui-dlg-f", children });
1223
1761
  function AlertBody({ spec, onClose, t, titleId }) {
1224
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
1225
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Header, { title: spec.title, variant: spec.variant, titleId }),
1226
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rui-dlg-b", children: spec.message ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rui-dlg-msg", children: spec.message }) : null }),
1227
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Footer, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", className: "rui-dlg-btn rui-dlg-primary", onClick: () => onClose(true), children: spec.confirmLabel || t.ok }) })
1762
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
1763
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Header, { title: spec.title, variant: spec.variant, titleId }),
1764
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "rui-dlg-b", children: spec.message ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "rui-dlg-msg", children: spec.message }) : null }),
1765
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Footer, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", className: "rui-dlg-btn rui-dlg-primary", onClick: () => onClose(true), children: spec.confirmLabel || t.ok }) })
1228
1766
  ] });
1229
1767
  }
1230
1768
  function ConfirmBody({ spec, onClose, t, titleId }) {
1231
1769
  const destructive = !!spec.destructive;
1232
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
1233
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Header, { title: spec.title, variant: destructive ? "destructive" : spec.variant, titleId }),
1234
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rui-dlg-b", children: spec.message ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rui-dlg-msg", children: spec.message }) : null }),
1235
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Footer, { children: [
1236
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", className: "rui-dlg-btn rui-dlg-secondary", onClick: () => onClose(false), children: spec.cancelLabel || t.cancel }),
1237
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1770
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
1771
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Header, { title: spec.title, variant: destructive ? "destructive" : spec.variant, titleId }),
1772
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "rui-dlg-b", children: spec.message ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "rui-dlg-msg", children: spec.message }) : null }),
1773
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Footer, { children: [
1774
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", className: "rui-dlg-btn rui-dlg-secondary", onClick: () => onClose(false), children: spec.cancelLabel || t.cancel }),
1775
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1238
1776
  "button",
1239
1777
  {
1240
1778
  type: "button",
@@ -1247,9 +1785,9 @@ function ConfirmBody({ spec, onClose, t, titleId }) {
1247
1785
  ] });
1248
1786
  }
1249
1787
  function PromptBody({ spec, onClose, t, titleId }) {
1250
- const [value, setValue] = (0, import_react9.useState)(spec.defaultValue ?? "");
1251
- const [err, setErr] = (0, import_react9.useState)(null);
1252
- const inputId = (0, import_react9.useId)();
1788
+ const [value, setValue] = (0, import_react12.useState)(spec.defaultValue ?? "");
1789
+ const [err, setErr] = (0, import_react12.useState)(null);
1790
+ const inputId = (0, import_react12.useId)();
1253
1791
  const Field = spec.multiline ? "textarea" : "input";
1254
1792
  const submit = () => {
1255
1793
  const invalid = spec.validate?.(value);
@@ -1263,12 +1801,12 @@ function PromptBody({ spec, onClose, t, titleId }) {
1263
1801
  }
1264
1802
  onClose(String(value));
1265
1803
  };
1266
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
1267
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Header, { title: spec.title, variant: spec.variant, titleId }),
1268
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "rui-dlg-b", children: [
1269
- spec.message ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rui-dlg-msg", children: spec.message }) : null,
1270
- spec.label ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { className: "rui-dlg-label", htmlFor: inputId, children: spec.label }) : null,
1271
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1804
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
1805
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Header, { title: spec.title, variant: spec.variant, titleId }),
1806
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "rui-dlg-b", children: [
1807
+ spec.message ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "rui-dlg-msg", children: spec.message }) : null,
1808
+ spec.label ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("label", { className: "rui-dlg-label", htmlFor: inputId, children: spec.label }) : null,
1809
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1272
1810
  Field,
1273
1811
  {
1274
1812
  id: inputId,
@@ -1291,21 +1829,21 @@ function PromptBody({ spec, onClose, t, titleId }) {
1291
1829
  spellCheck: "false"
1292
1830
  }
1293
1831
  ),
1294
- err ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rui-dlg-err", children: err }) : null,
1295
- !err && spec.help ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rui-dlg-help", children: spec.help }) : null
1832
+ err ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "rui-dlg-err", children: err }) : null,
1833
+ !err && spec.help ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "rui-dlg-help", children: spec.help }) : null
1296
1834
  ] }),
1297
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Footer, { children: [
1298
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", className: "rui-dlg-btn rui-dlg-secondary", onClick: () => onClose(null), children: spec.cancelLabel || t.cancel }),
1299
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", className: "rui-dlg-btn rui-dlg-primary", onClick: submit, children: spec.confirmLabel || t.confirm })
1835
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Footer, { children: [
1836
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", className: "rui-dlg-btn rui-dlg-secondary", onClick: () => onClose(null), children: spec.cancelLabel || t.cancel }),
1837
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", className: "rui-dlg-btn rui-dlg-primary", onClick: submit, children: spec.confirmLabel || t.confirm })
1300
1838
  ] })
1301
1839
  ] });
1302
1840
  }
1303
1841
  function CreateBody({ spec, onClose, t, titleId }) {
1304
1842
  const types = spec.types || [];
1305
- const [kind, setKind] = (0, import_react9.useState)(spec.defaultKind || types[0]?.kind || "");
1306
- const [value, setValue] = (0, import_react9.useState)(spec.defaultValue ?? "");
1307
- const [err, setErr] = (0, import_react9.useState)(null);
1308
- const inputId = (0, import_react9.useId)();
1843
+ const [kind, setKind] = (0, import_react12.useState)(spec.defaultKind || types[0]?.kind || "");
1844
+ const [value, setValue] = (0, import_react12.useState)(spec.defaultValue ?? "");
1845
+ const [err, setErr] = (0, import_react12.useState)(null);
1846
+ const inputId = (0, import_react12.useId)();
1309
1847
  const sel = types.find((x) => x.kind === kind) || types[0] || {};
1310
1848
  const submit = () => {
1311
1849
  if (spec.required !== false && !String(value).trim()) {
@@ -1314,24 +1852,24 @@ function CreateBody({ spec, onClose, t, titleId }) {
1314
1852
  }
1315
1853
  onClose({ kind, name: String(value).trim() });
1316
1854
  };
1317
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
1318
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Header, { title: spec.title, titleId }),
1319
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "rui-dlg-b", children: [
1320
- types.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rui-dlg-typegrid", children: types.map((ty) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1855
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
1856
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Header, { title: spec.title, titleId }),
1857
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "rui-dlg-b", children: [
1858
+ types.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "rui-dlg-typegrid", children: types.map((ty) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1321
1859
  "button",
1322
1860
  {
1323
1861
  type: "button",
1324
1862
  className: `rui-dlg-type${ty.kind === kind ? " is-on" : ""}`,
1325
1863
  onClick: () => setKind(ty.kind),
1326
1864
  children: [
1327
- ty.icon ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "rui-dlg-type-ic", style: ty.color ? { color: ty.color, background: `${ty.color}1f` } : void 0, children: ty.icon }) : null,
1328
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "rui-dlg-type-lbl", children: ty.label })
1865
+ ty.icon ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "rui-dlg-type-ic", style: ty.color ? { color: ty.color, background: `${ty.color}1f` } : void 0, children: ty.icon }) : null,
1866
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "rui-dlg-type-lbl", children: ty.label })
1329
1867
  ]
1330
1868
  },
1331
1869
  ty.kind
1332
1870
  )) }) : null,
1333
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { className: "rui-dlg-label", htmlFor: inputId, children: spec.label || `${sel.label || "Item"} name` }),
1334
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1871
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("label", { className: "rui-dlg-label", htmlFor: inputId, children: spec.label || `${sel.label || "Item"} name` }),
1872
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1335
1873
  "input",
1336
1874
  {
1337
1875
  id: inputId,
@@ -1352,11 +1890,11 @@ function CreateBody({ spec, onClose, t, titleId }) {
1352
1890
  spellCheck: "false"
1353
1891
  }
1354
1892
  ),
1355
- err ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rui-dlg-err", children: err }) : null
1893
+ err ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "rui-dlg-err", children: err }) : null
1356
1894
  ] }),
1357
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Footer, { children: [
1358
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", className: "rui-dlg-btn rui-dlg-secondary", onClick: () => onClose(null), children: spec.cancelLabel || t.cancel }),
1359
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", className: "rui-dlg-btn rui-dlg-primary", onClick: submit, children: spec.confirmLabel || t.create })
1895
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Footer, { children: [
1896
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", className: "rui-dlg-btn rui-dlg-secondary", onClick: () => onClose(null), children: spec.cancelLabel || t.cancel }),
1897
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", className: "rui-dlg-btn rui-dlg-primary", onClick: submit, children: spec.confirmLabel || t.create })
1360
1898
  ] })
1361
1899
  ] });
1362
1900
  }
@@ -1510,18 +2048,18 @@ async function fetchBalance() {
1510
2048
  }
1511
2049
 
1512
2050
  // src/auth/AuthForm.jsx
1513
- var import_react11 = require("react");
2051
+ var import_react14 = require("react");
1514
2052
 
1515
2053
  // src/auth/GoogleButton.jsx
1516
- var import_react10 = require("react");
1517
- var import_jsx_runtime9 = require("react/jsx-runtime");
2054
+ var import_react13 = require("react");
2055
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1518
2056
  var CLIENT_ID = "247853836408-ojk91u8901hdlbkevid4fohmrfdot17l.apps.googleusercontent.com";
1519
2057
  function GoogleButton({ onCredential, onError }) {
1520
- const ref = (0, import_react10.useRef)(null);
1521
- const [failed, setFailed] = (0, import_react10.useState)(false);
1522
- const cb = (0, import_react10.useRef)({ onCredential, onError });
2058
+ const ref = (0, import_react13.useRef)(null);
2059
+ const [failed, setFailed] = (0, import_react13.useState)(false);
2060
+ const cb = (0, import_react13.useRef)({ onCredential, onError });
1523
2061
  cb.current = { onCredential, onError };
1524
- (0, import_react10.useEffect)(() => {
2062
+ (0, import_react13.useEffect)(() => {
1525
2063
  if (!CLIENT_ID || !ref.current) return void 0;
1526
2064
  const SRC = "https://accounts.google.com/gsi/client";
1527
2065
  let done = false;
@@ -1572,24 +2110,24 @@ function GoogleButton({ onCredential, onError }) {
1572
2110
  };
1573
2111
  }, []);
1574
2112
  if (!CLIENT_ID || failed) return null;
1575
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
1576
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "auth-or", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: "or" }) }),
1577
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { ref, className: "auth-gwrap" })
2113
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
2114
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "auth-or", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { children: "or" }) }),
2115
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { ref, className: "auth-gwrap" })
1578
2116
  ] });
1579
2117
  }
1580
2118
  var GOOGLE_ENABLED = !!CLIENT_ID;
1581
2119
 
1582
2120
  // src/auth/AuthForm.jsx
1583
- var import_jsx_runtime10 = require("react/jsx-runtime");
2121
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1584
2122
  function AuthForm({ onDone, subtitle, brand = null, productName = "" }) {
1585
- const [mode, setMode] = (0, import_react11.useState)("signin");
1586
- const [email, setEmail] = (0, import_react11.useState)("");
1587
- const [password, setPassword] = (0, import_react11.useState)("");
1588
- const [name, setName] = (0, import_react11.useState)("");
1589
- const [err, setErr] = (0, import_react11.useState)("");
1590
- const [busy, setBusy] = (0, import_react11.useState)(false);
1591
- const [choices, setChoices] = (0, import_react11.useState)(null);
1592
- const [resetSent, setResetSent] = (0, import_react11.useState)(false);
2123
+ const [mode, setMode] = (0, import_react14.useState)("signin");
2124
+ const [email, setEmail] = (0, import_react14.useState)("");
2125
+ const [password, setPassword] = (0, import_react14.useState)("");
2126
+ const [name, setName] = (0, import_react14.useState)("");
2127
+ const [err, setErr] = (0, import_react14.useState)("");
2128
+ const [busy, setBusy] = (0, import_react14.useState)(false);
2129
+ const [choices, setChoices] = (0, import_react14.useState)(null);
2130
+ const [resetSent, setResetSent] = (0, import_react14.useState)(false);
1593
2131
  async function enter(orgId) {
1594
2132
  const session = await switchOrg(orgId);
1595
2133
  onDone(session);
@@ -1630,10 +2168,10 @@ function AuthForm({ onDone, subtitle, brand = null, productName = "" }) {
1630
2168
  }
1631
2169
  }
1632
2170
  if (choices) {
1633
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { children: [
1634
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "logo", children: brand }),
1635
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h1", { children: "Choose workspace" }),
1636
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "org-list", children: choices.map((o) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2171
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { children: [
2172
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "logo", children: brand }),
2173
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h1", { children: "Choose workspace" }),
2174
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "org-list", children: choices.map((o) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1637
2175
  "button",
1638
2176
  {
1639
2177
  type: "button",
@@ -1651,20 +2189,20 @@ function AuthForm({ onDone, subtitle, brand = null, productName = "" }) {
1651
2189
  },
1652
2190
  o.id
1653
2191
  )) }),
1654
- err && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "auth-err", children: err })
2192
+ err && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "auth-err", children: err })
1655
2193
  ] });
1656
2194
  }
1657
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("form", { onSubmit: submit, children: [
1658
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "logo", children: brand }),
1659
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h1", { children: mode === "register" ? "Create your account" : mode === "forgot" ? "Reset password" : "Sign in" }),
1660
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "sub", children: mode === "register" ? "Get started in seconds." : mode === "forgot" ? "We will email you a reset link." : subtitle || "Welcome back." }),
1661
- mode === "forgot" ? resetSent ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
1662
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "auth-note", children: [
2195
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("form", { onSubmit: submit, children: [
2196
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "logo", children: brand }),
2197
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h1", { children: mode === "register" ? "Create your account" : mode === "forgot" ? "Reset password" : "Sign in" }),
2198
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "sub", children: mode === "register" ? "Get started in seconds." : mode === "forgot" ? "We will email you a reset link." : subtitle || "Welcome back." }),
2199
+ mode === "forgot" ? resetSent ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
2200
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "auth-note", children: [
1663
2201
  "If an account exists for ",
1664
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("b", { children: email.trim() }),
2202
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("b", { children: email.trim() }),
1665
2203
  ", a password reset link is on its way. It is valid for 1 hour."
1666
2204
  ] }),
1667
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2205
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1668
2206
  "button",
1669
2207
  {
1670
2208
  type: "button",
@@ -1678,36 +2216,36 @@ function AuthForm({ onDone, subtitle, brand = null, productName = "" }) {
1678
2216
  children: "Back to sign in"
1679
2217
  }
1680
2218
  )
1681
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
1682
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "field", children: [
1683
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("label", { children: "Email" }),
1684
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("input", { className: "input", type: "email", value: email, onChange: (e) => setEmail(e.target.value), autoFocus: true, required: true, autoComplete: "email" })
2219
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
2220
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "field", children: [
2221
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("label", { children: "Email" }),
2222
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("input", { className: "input", type: "email", value: email, onChange: (e) => setEmail(e.target.value), autoFocus: true, required: true, autoComplete: "email" })
1685
2223
  ] }),
1686
- err && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "auth-err", children: err }),
1687
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "submit", className: "btn primary lg", style: { width: "100%", marginTop: 8 }, disabled: busy, children: busy ? "Please wait..." : "Send reset link" }),
1688
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "auth-switch", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", onClick: () => {
2224
+ err && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "auth-err", children: err }),
2225
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "submit", className: "btn primary lg", style: { width: "100%", marginTop: 8 }, disabled: busy, children: busy ? "Please wait..." : "Send reset link" }),
2226
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "auth-switch", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", onClick: () => {
1689
2227
  setErr("");
1690
2228
  setMode("signin");
1691
2229
  }, children: "Back to sign in" }) })
1692
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
1693
- mode === "register" && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "field", children: [
1694
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("label", { children: "Name" }),
1695
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("input", { className: "input", value: name, onChange: (e) => setName(e.target.value), autoComplete: "name", placeholder: "Jane Doe" })
2230
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
2231
+ mode === "register" && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "field", children: [
2232
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("label", { children: "Name" }),
2233
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("input", { className: "input", value: name, onChange: (e) => setName(e.target.value), autoComplete: "name", placeholder: "Jane Doe" })
1696
2234
  ] }),
1697
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "field", children: [
1698
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("label", { children: "Email" }),
1699
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("input", { className: "input", type: "email", value: email, onChange: (e) => setEmail(e.target.value), autoFocus: true, required: true, autoComplete: "email" })
2235
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "field", children: [
2236
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("label", { children: "Email" }),
2237
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("input", { className: "input", type: "email", value: email, onChange: (e) => setEmail(e.target.value), autoFocus: true, required: true, autoComplete: "email" })
1700
2238
  ] }),
1701
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "field", children: [
1702
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "field-row", children: [
1703
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("label", { children: "Password" }),
1704
- mode === "signin" && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", className: "link-sm", onClick: () => {
2239
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "field", children: [
2240
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "field-row", children: [
2241
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("label", { children: "Password" }),
2242
+ mode === "signin" && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: "link-sm", onClick: () => {
1705
2243
  setErr("");
1706
2244
  setResetSent(false);
1707
2245
  setMode("forgot");
1708
2246
  }, children: "Forgot password?" })
1709
2247
  ] }),
1710
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2248
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1711
2249
  "input",
1712
2250
  {
1713
2251
  className: "input",
@@ -1720,13 +2258,13 @@ function AuthForm({ onDone, subtitle, brand = null, productName = "" }) {
1720
2258
  }
1721
2259
  )
1722
2260
  ] }),
1723
- err && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "auth-err", children: err }),
1724
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "submit", className: "btn primary lg", style: { width: "100%", marginTop: 8 }, disabled: busy, children: busy ? "Please wait..." : mode === "register" ? "Create account" : "Sign in" }),
1725
- GOOGLE_ENABLED && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(GoogleButton, { onCredential: onGoogle, onError: setErr }),
1726
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", { className: "auth-switch", children: [
2261
+ err && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "auth-err", children: err }),
2262
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "submit", className: "btn primary lg", style: { width: "100%", marginTop: 8 }, disabled: busy, children: busy ? "Please wait..." : mode === "register" ? "Create account" : "Sign in" }),
2263
+ GOOGLE_ENABLED && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(GoogleButton, { onCredential: onGoogle, onError: setErr }),
2264
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { className: "auth-switch", children: [
1727
2265
  mode === "register" ? "Already have an account?" : `New to ${productName || "the product"}?`,
1728
2266
  " ",
1729
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", onClick: () => {
2267
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", onClick: () => {
1730
2268
  setErr("");
1731
2269
  setMode(mode === "register" ? "signin" : "register");
1732
2270
  }, children: mode === "register" ? "Sign in" : "Create one" })
@@ -1736,9 +2274,9 @@ function AuthForm({ onDone, subtitle, brand = null, productName = "" }) {
1736
2274
  }
1737
2275
 
1738
2276
  // src/sheet/SheetGrid.jsx
1739
- var import_react12 = require("react");
2277
+ var import_react15 = require("react");
1740
2278
  var import_react_dom2 = require("react-dom");
1741
- var import_jsx_runtime11 = require("react/jsx-runtime");
2279
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1742
2280
  var cellKey = (rowId, colId) => `${rowId}:${colId}`;
1743
2281
  var uid = (p) => `${p}_${Math.random().toString(36).slice(2, 10)}`;
1744
2282
  var DEFAULT_COLUMN_TYPES = [
@@ -1767,8 +2305,8 @@ var COMPUTE_KINDS = [
1767
2305
  var RESOURCE_KINDS = ["image", "sheet", "slides", "workflow", "graph"];
1768
2306
  var RESOURCE_ICON = { image: "\u{1F5BC}", sheet: "\u25A6", slides: "\u25A4", workflow: "\u2699", graph: "\u25C9" };
1769
2307
  function PopPortal({ anchor, width = 250, estHeight = 300, className, children, onClose }) {
1770
- const boxRef = (0, import_react12.useRef)(null);
1771
- (0, import_react12.useEffect)(() => {
2308
+ const boxRef = (0, import_react15.useRef)(null);
2309
+ (0, import_react15.useEffect)(() => {
1772
2310
  if (!onClose) return void 0;
1773
2311
  const close = () => onClose();
1774
2312
  const onDown = (e) => {
@@ -1790,7 +2328,7 @@ function PopPortal({ anchor, width = 250, estHeight = 300, className, children,
1790
2328
  let top = anchor.bottom + 6;
1791
2329
  if (top + estHeight > window.innerHeight - 8) top = Math.max(8, anchor.top - estHeight - 6);
1792
2330
  return (0, import_react_dom2.createPortal)(
1793
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { ref: boxRef, className, style: { position: "fixed", top, left, width, zIndex: 1e3 }, children }),
2331
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { ref: boxRef, className, style: { position: "fixed", top, left, width, zIndex: 1e3 }, children }),
1794
2332
  document.body
1795
2333
  );
1796
2334
  }
@@ -1810,8 +2348,8 @@ function pillColor(label, options) {
1810
2348
  return PILL_FALLBACKS[h % PILL_FALLBACKS.length];
1811
2349
  }
1812
2350
  function RefImage({ refVal, fetchBlobUrl }) {
1813
- const [src, setSrc] = (0, import_react12.useState)(/^https?:\/\//i.test(refVal.url || "") ? refVal.url : null);
1814
- (0, import_react12.useEffect)(() => {
2351
+ const [src, setSrc] = (0, import_react15.useState)(/^https?:\/\//i.test(refVal.url || "") ? refVal.url : null);
2352
+ (0, import_react15.useEffect)(() => {
1815
2353
  let dead = false;
1816
2354
  let obj = null;
1817
2355
  if (!src && refVal.url && fetchBlobUrl) {
@@ -1827,16 +2365,16 @@ function RefImage({ refVal, fetchBlobUrl }) {
1827
2365
  if (obj) URL.revokeObjectURL(obj);
1828
2366
  };
1829
2367
  }, [refVal.url]);
1830
- if (!src) return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "shg-refchip", children: [
2368
+ if (!src) return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: "shg-refchip", children: [
1831
2369
  RESOURCE_ICON.image,
1832
2370
  " ",
1833
2371
  refVal.name || "image"
1834
2372
  ] });
1835
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("img", { className: "shg-refimg", src, alt: refVal.name || "", title: refVal.name || "" });
2373
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("img", { className: "shg-refimg", src, alt: refVal.name || "", title: refVal.name || "" });
1836
2374
  }
1837
2375
  function ResourceChip({ refVal, onOpen }) {
1838
2376
  const icon = RESOURCE_ICON[refVal.kind] || "\u25C7";
1839
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
2377
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1840
2378
  "button",
1841
2379
  {
1842
2380
  className: "shg-refchip shg-refchip-btn",
@@ -1846,40 +2384,40 @@ function ResourceChip({ refVal, onOpen }) {
1846
2384
  onOpen && onOpen(refVal);
1847
2385
  },
1848
2386
  children: [
1849
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "shg-refchip-ic", children: icon }),
1850
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "shg-refchip-name", children: refVal.name || refVal.id || refVal.kind })
2387
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "shg-refchip-ic", children: icon }),
2388
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "shg-refchip-name", children: refVal.name || refVal.id || refVal.kind })
1851
2389
  ]
1852
2390
  }
1853
2391
  );
1854
2392
  }
1855
2393
  function StatusDot({ status }) {
1856
2394
  if (!status || status === "empty") return null;
1857
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: `shg-dot shg-dot-${status}`, title: status });
2395
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: `shg-dot shg-dot-${status}`, title: status });
1858
2396
  }
1859
2397
  function CellValue({ cell, col, fetchBlobUrl, onOpenResource }) {
1860
2398
  const v = cell?.value;
1861
- if (v === void 0 || v === null || v === "") return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "shg-val-txt" });
2399
+ if (v === void 0 || v === null || v === "") return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "shg-val-txt" });
1862
2400
  if (v && typeof v === "object" && !Array.isArray(v) && v.kind) {
1863
- if (v.kind === "image") return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(RefImage, { refVal: v, fetchBlobUrl });
1864
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ResourceChip, { refVal: v, onOpen: onOpenResource });
2401
+ if (v.kind === "image") return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(RefImage, { refVal: v, fetchBlobUrl });
2402
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ResourceChip, { refVal: v, onOpen: onOpenResource });
1865
2403
  }
1866
2404
  switch (col.type) {
1867
2405
  case "select":
1868
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "shg-pill", style: { background: pillColor(String(v), col.options) }, children: String(v) });
2406
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "shg-pill", style: { background: pillColor(String(v), col.options) }, children: String(v) });
1869
2407
  case "tags": {
1870
2408
  const tags = Array.isArray(v) ? v : String(v).split(",").map((s) => s.trim()).filter(Boolean);
1871
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "shg-pills", children: tags.map((t) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "shg-pill", style: { background: pillColor(t, col.options) }, children: t }, t)) });
2409
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "shg-pills", children: tags.map((t) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "shg-pill", style: { background: pillColor(t, col.options) }, children: t }, t)) });
1872
2410
  }
1873
2411
  case "checkbox":
1874
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "shg-check" + (v ? " on" : ""), children: v ? "\u2713" : "" });
2412
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "shg-check" + (v ? " on" : ""), children: v ? "\u2713" : "" });
1875
2413
  case "url": {
1876
2414
  const href = /^https?:\/\//i.test(String(v)) ? String(v) : `https://${v}`;
1877
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("a", { className: "shg-link", href, target: "_blank", rel: "noreferrer", onClick: (e) => e.stopPropagation(), children: String(v) });
2415
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("a", { className: "shg-link", href, target: "_blank", rel: "noreferrer", onClick: (e) => e.stopPropagation(), children: String(v) });
1878
2416
  }
1879
2417
  case "number":
1880
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "shg-val-txt shg-num", children: String(v) });
2418
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "shg-val-txt shg-num", children: String(v) });
1881
2419
  default:
1882
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "shg-val-txt", children: typeof v === "object" ? JSON.stringify(v) : String(v) });
2420
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "shg-val-txt", children: typeof v === "object" ? JSON.stringify(v) : String(v) });
1883
2421
  }
1884
2422
  }
1885
2423
  function SheetGrid({
@@ -1899,14 +2437,14 @@ function SheetGrid({
1899
2437
  const columns = sheet?.columns || [];
1900
2438
  const rows = sheet?.rows || [];
1901
2439
  const cells = sheet?.cells || {};
1902
- const [editing, setEditing] = (0, import_react12.useState)(null);
1903
- const [draft, setDraft] = (0, import_react12.useState)("");
1904
- const [menuCol, setMenuCol] = (0, import_react12.useState)(null);
1905
- const [sizeDraft, setSizeDraft] = (0, import_react12.useState)({});
1906
- const [dnd, setDnd] = (0, import_react12.useState)(null);
1907
- const [dropAt, setDropAt] = (0, import_react12.useState)(null);
1908
- const inputRef = (0, import_react12.useRef)(null);
1909
- const dragRef = (0, import_react12.useRef)(null);
2440
+ const [editing, setEditing] = (0, import_react15.useState)(null);
2441
+ const [draft, setDraft] = (0, import_react15.useState)("");
2442
+ const [menuCol, setMenuCol] = (0, import_react15.useState)(null);
2443
+ const [sizeDraft, setSizeDraft] = (0, import_react15.useState)({});
2444
+ const [dnd, setDnd] = (0, import_react15.useState)(null);
2445
+ const [dropAt, setDropAt] = (0, import_react15.useState)(null);
2446
+ const inputRef = (0, import_react15.useRef)(null);
2447
+ const dragRef = (0, import_react15.useRef)(null);
1910
2448
  const descOf = (type) => columnTypes.find((t) => t.type === type) || { type, label: type };
1911
2449
  const isComputed = (col) => !!descOf(col?.type).computed;
1912
2450
  const isEditable = (col) => {
@@ -2007,7 +2545,7 @@ function SheetGrid({
2007
2545
  const numW = Math.max(40, 24 + String(rows.length || 1).length * 9);
2008
2546
  const numStyle = { width: numW, minWidth: numW, maxWidth: numW };
2009
2547
  const rowHeight = (row) => sizeDraft.row && sizeDraft.row[row.id] || row.height || void 0;
2010
- (0, import_react12.useEffect)(() => {
2548
+ (0, import_react15.useEffect)(() => {
2011
2549
  if (editing && inputRef.current) inputRef.current.focus();
2012
2550
  }, [editing]);
2013
2551
  const mutate = (fn) => {
@@ -2079,7 +2617,7 @@ function SheetGrid({
2079
2617
  if (col.type === "resource") {
2080
2618
  const d = typeof draft === "object" && draft ? draft : { kind: "sheet" };
2081
2619
  const set = (k, v) => setDraft({ ...d, [k]: v });
2082
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2620
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2083
2621
  PopPortal,
2084
2622
  {
2085
2623
  anchor: editing.rect,
@@ -2087,17 +2625,17 @@ function SheetGrid({
2087
2625
  estHeight: 230,
2088
2626
  className: "shg-select-pop shg-ref-pop",
2089
2627
  onClose: () => setEditing(null),
2090
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { onClick: (e) => e.stopPropagation(), children: [
2091
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("select", { className: "shg-menu-input", value: d.kind || "sheet", onChange: (e) => set("kind", e.target.value), children: RESOURCE_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("option", { value: k, children: k }, k)) }),
2092
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { className: "shg-menu-input", placeholder: "Name", value: d.name || "", onChange: (e) => set("name", e.target.value) }),
2093
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { className: "shg-menu-input", placeholder: "Resource id (e.g. sheet.\u2026)", value: d.id || "", onChange: (e) => set("id", e.target.value) }),
2094
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { className: "shg-menu-input", placeholder: "or URL", value: d.url || "", onChange: (e) => set("url", e.target.value) }),
2095
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "shg-menu-actions", children: [
2096
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "shg-pop-clear", onClick: () => {
2628
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { onClick: (e) => e.stopPropagation(), children: [
2629
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("select", { className: "shg-menu-input", value: d.kind || "sheet", onChange: (e) => set("kind", e.target.value), children: RESOURCE_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: k, children: k }, k)) }),
2630
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { className: "shg-menu-input", placeholder: "Name", value: d.name || "", onChange: (e) => set("name", e.target.value) }),
2631
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { className: "shg-menu-input", placeholder: "Resource id (e.g. sheet.\u2026)", value: d.id || "", onChange: (e) => set("id", e.target.value) }),
2632
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { className: "shg-menu-input", placeholder: "or URL", value: d.url || "", onChange: (e) => set("url", e.target.value) }),
2633
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "shg-menu-actions", children: [
2634
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { className: "shg-pop-clear", onClick: () => {
2097
2635
  setCell(editing.rowId, editing.colId, null);
2098
2636
  setEditing(null);
2099
2637
  }, children: "Clear" }),
2100
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "shg-menu-apply", onClick: () => {
2638
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { className: "shg-menu-apply", onClick: () => {
2101
2639
  setCell(editing.rowId, editing.colId, d);
2102
2640
  setEditing(null);
2103
2641
  }, children: "Set" })
@@ -2108,7 +2646,7 @@ function SheetGrid({
2108
2646
  }
2109
2647
  if (col.type === "select") {
2110
2648
  const opts = normOptions(col.options);
2111
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
2649
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2112
2650
  PopPortal,
2113
2651
  {
2114
2652
  anchor: editing.rect,
@@ -2117,8 +2655,8 @@ function SheetGrid({
2117
2655
  className: "shg-select-pop",
2118
2656
  onClose: () => setEditing(null),
2119
2657
  children: [
2120
- opts.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "shg-pop-note", children: "No options yet \u2014 add them in the column menu." }),
2121
- opts.map((o) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2658
+ opts.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "shg-pop-note", children: "No options yet \u2014 add them in the column menu." }),
2659
+ opts.map((o) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2122
2660
  "button",
2123
2661
  {
2124
2662
  className: "shg-pill shg-pill-btn",
@@ -2132,7 +2670,7 @@ function SheetGrid({
2132
2670
  },
2133
2671
  o.label
2134
2672
  )),
2135
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2673
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2136
2674
  "button",
2137
2675
  {
2138
2676
  className: "shg-pop-clear",
@@ -2149,7 +2687,7 @@ function SheetGrid({
2149
2687
  );
2150
2688
  }
2151
2689
  const inputType = col.type === "date" ? "date" : col.type === "number" ? "number" : "text";
2152
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2690
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2153
2691
  "input",
2154
2692
  {
2155
2693
  ref: inputRef,
@@ -2166,18 +2704,18 @@ function SheetGrid({
2166
2704
  }
2167
2705
  );
2168
2706
  };
2169
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "shg", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "shg-scroll", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("table", { className: "shg-table", children: [
2170
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("tr", { children: [
2171
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("th", { className: "shg-corner", style: numStyle }),
2172
- columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
2707
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "shg", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "shg-scroll", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("table", { className: "shg-table", children: [
2708
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("tr", { children: [
2709
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("th", { className: "shg-corner", style: numStyle }),
2710
+ columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2173
2711
  "th",
2174
2712
  {
2175
2713
  className: "shg-col" + (isComputed(col) ? " shg-col-compute" : "") + dndClass("col", col.id),
2176
2714
  style: colWidth(col) ? { width: colWidth(col), minWidth: colWidth(col), maxWidth: colWidth(col) } : void 0,
2177
2715
  ...dndProps("col", col.id),
2178
2716
  children: [
2179
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "shg-resize-col", onMouseDown: (e) => startResize(e, "col", col.id, colWidth(col) || e.currentTarget.closest("th").offsetWidth) }),
2180
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "shg-col-h", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2717
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "shg-resize-col", onMouseDown: (e) => startResize(e, "col", col.id, colWidth(col) || e.currentTarget.closest("th").offsetWidth) }),
2718
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "shg-col-h", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2181
2719
  ColumnHeader,
2182
2720
  {
2183
2721
  col,
@@ -2203,10 +2741,10 @@ function SheetGrid({
2203
2741
  },
2204
2742
  col.id
2205
2743
  )),
2206
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("th", { className: "shg-add-col", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "shg-add", onClick: addColumn, title: "Add column", children: "+" }) })
2744
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("th", { className: "shg-add-col", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { className: "shg-add", onClick: addColumn, title: "Add column", children: "+" }) })
2207
2745
  ] }) }),
2208
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("tbody", { children: [
2209
- rows.map((row, ri) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
2746
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("tbody", { children: [
2747
+ rows.map((row, ri) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2210
2748
  "tr",
2211
2749
  {
2212
2750
  style: {
@@ -2214,7 +2752,7 @@ function SheetGrid({
2214
2752
  "--shg-clamp": Math.max(1, Math.floor(((rowHeight(row) || 34) - 10) / 18))
2215
2753
  },
2216
2754
  children: [
2217
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
2755
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2218
2756
  "td",
2219
2757
  {
2220
2758
  className: "shg-rownum" + dndClass("row", row.id),
@@ -2222,9 +2760,9 @@ function SheetGrid({
2222
2760
  title: "Drag to reorder",
2223
2761
  ...dndProps("row", row.id),
2224
2762
  children: [
2225
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { children: ri + 1 }),
2226
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "shg-rowdel", onClick: () => deleteRow(row.id), title: "Delete row", children: "\xD7" }),
2227
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "shg-resize-row", onMouseDown: (e) => startResize(e, "row", row.id, rowHeight(row) || e.currentTarget.closest("tr").offsetHeight) })
2763
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: ri + 1 }),
2764
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { className: "shg-rowdel", onClick: () => deleteRow(row.id), title: "Delete row", children: "\xD7" }),
2765
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "shg-resize-row", onMouseDown: (e) => startResize(e, "row", row.id, rowHeight(row) || e.currentTarget.closest("tr").offsetHeight) })
2228
2766
  ]
2229
2767
  }
2230
2768
  ),
@@ -2247,7 +2785,7 @@ function SheetGrid({
2247
2785
  setCell: (v) => setCell(row.id, col.id, v),
2248
2786
  runCell: onRunCell && !readOnly ? () => onRunCell(row.id, col.id) : null
2249
2787
  });
2250
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
2788
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2251
2789
  "td",
2252
2790
  {
2253
2791
  className: "shg-cell" + (computed ? " shg-cell-compute" : "") + (c.status && computed ? ` shg-cell-${c.status}` : "") + (peer ? " shg-cell-peer" : ""),
@@ -2257,16 +2795,16 @@ function SheetGrid({
2257
2795
  },
2258
2796
  title: c.error || "",
2259
2797
  children: [
2260
- peer && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "shg-peer-flag", style: { background: peer.color }, children: peer.name }),
2261
- isEditing ? renderEditor(col) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2798
+ peer && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "shg-peer-flag", style: { background: peer.color }, children: peer.name }),
2799
+ isEditing ? renderEditor(col) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2262
2800
  "div",
2263
2801
  {
2264
2802
  className: "shg-val",
2265
2803
  style: { maxWidth: colWidth(col) ? colWidth(col) - 20 : 400 },
2266
- children: custom !== void 0 ? custom : /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
2267
- computed && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(StatusDot, { status: c.status }),
2268
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CellValue, { cell: c, col, fetchBlobUrl, onOpenResource }),
2269
- computed && !readOnly && onRunCell && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2804
+ children: custom !== void 0 ? custom : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
2805
+ computed && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(StatusDot, { status: c.status }),
2806
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(CellValue, { cell: c, col, fetchBlobUrl, onOpenResource }),
2807
+ computed && !readOnly && onRunCell && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2270
2808
  "button",
2271
2809
  {
2272
2810
  className: "shg-runcell",
@@ -2286,14 +2824,14 @@ function SheetGrid({
2286
2824
  col.id
2287
2825
  );
2288
2826
  }),
2289
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("td", { className: "shg-pad" })
2827
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("td", { className: "shg-pad" })
2290
2828
  ]
2291
2829
  },
2292
2830
  row.id
2293
2831
  )),
2294
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("tr", { className: "shg-ghost-row", onClick: addRow, children: [
2295
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("td", { className: "shg-rownum shg-ghost-num", style: numStyle, children: "+" }),
2296
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("td", { className: "shg-ghost-cell", colSpan: columns.length + 1, children: "New row" })
2832
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("tr", { className: "shg-ghost-row", onClick: addRow, children: [
2833
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("td", { className: "shg-rownum shg-ghost-num", style: numStyle, children: "+" }),
2834
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("td", { className: "shg-ghost-cell", colSpan: columns.length + 1, children: "New row" })
2297
2835
  ] })
2298
2836
  ] })
2299
2837
  ] }) }) });
@@ -2314,13 +2852,13 @@ function ColumnHeader({
2314
2852
  onDelete,
2315
2853
  onRun
2316
2854
  }) {
2317
- const [editing, setEditing] = (0, import_react12.useState)(false);
2318
- const [name, setName] = (0, import_react12.useState)(col.name);
2319
- (0, import_react12.useEffect)(() => setName(col.name), [col.name]);
2855
+ const [editing, setEditing] = (0, import_react15.useState)(false);
2856
+ const [name, setName] = (0, import_react15.useState)(col.name);
2857
+ (0, import_react15.useEffect)(() => setName(col.name), [col.name]);
2320
2858
  const badge = desc.badge ? desc.badge(col) : void 0;
2321
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "shg-colhdr", children: [
2322
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "shg-colhdr-main", children: [
2323
- editing && !readOnly ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2859
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "shg-colhdr", children: [
2860
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "shg-colhdr-main", children: [
2861
+ editing && !readOnly ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2324
2862
  "input",
2325
2863
  {
2326
2864
  className: "shg-colname-input",
@@ -2335,17 +2873,17 @@ function ColumnHeader({
2335
2873
  if (e.key === "Enter") e.target.blur();
2336
2874
  }
2337
2875
  }
2338
- ) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "shg-colname", onDoubleClick: () => !readOnly && setEditing(true), title: col.name, children: col.name }),
2339
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "shg-coltype" + (desc.computed ? " compute" : ""), children: [
2876
+ ) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "shg-colname", onDoubleClick: () => !readOnly && setEditing(true), title: col.name, children: col.name }),
2877
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: "shg-coltype" + (desc.computed ? " compute" : ""), children: [
2340
2878
  desc.label || col.type,
2341
2879
  badge ? ` \xB7 ${badge}` : ""
2342
2880
  ] })
2343
2881
  ] }),
2344
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "shg-colhdr-tools", children: [
2345
- onRun && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "shg-colrun", onClick: onRun, title: "Run this column", children: "\u25B6 Run" }),
2346
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "shg-colmenu-btn", onClick: (e) => onMenu(e), title: "Column settings", children: "\u22EF" })
2882
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "shg-colhdr-tools", children: [
2883
+ onRun && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { className: "shg-colrun", onClick: onRun, title: "Run this column", children: "\u25B6 Run" }),
2884
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { className: "shg-colmenu-btn", onClick: (e) => onMenu(e), title: "Column settings", children: "\u22EF" })
2347
2885
  ] }),
2348
- menuOpen && !readOnly && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2886
+ menuOpen && !readOnly && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2349
2887
  ColumnMenu,
2350
2888
  {
2351
2889
  col,
@@ -2364,17 +2902,17 @@ function ColumnHeader({
2364
2902
  ] });
2365
2903
  }
2366
2904
  function ColumnMenu({ col, columns, anchor, columnTypes, renderColumnConfig, onApply, onDelete, onClose }) {
2367
- const [type, setType] = (0, import_react12.useState)(col.type || "text");
2368
- const [optText, setOptText] = (0, import_react12.useState)(
2905
+ const [type, setType] = (0, import_react15.useState)(col.type || "text");
2906
+ const [optText, setOptText] = (0, import_react15.useState)(
2369
2907
  normOptions(col.options).map((o) => o.label).join("\n")
2370
2908
  );
2371
2909
  const comp = col.compute || {};
2372
- const [kind, setKind] = (0, import_react12.useState)(comp.kind || "prompt");
2373
- const [prompt, setPrompt] = (0, import_react12.useState)(comp.prompt || "");
2374
- const [harnessId, setHarnessId] = (0, import_react12.useState)(comp.harness_id || "");
2375
- const [wfSlug, setWfSlug] = (0, import_react12.useState)(comp.workflow_slug || "");
2376
- const [outKey, setOutKey] = (0, import_react12.useState)(comp.output_key || "");
2377
- const [deps, setDeps] = (0, import_react12.useState)(new Set(comp.deps || []));
2910
+ const [kind, setKind] = (0, import_react15.useState)(comp.kind || "prompt");
2911
+ const [prompt, setPrompt] = (0, import_react15.useState)(comp.prompt || "");
2912
+ const [harnessId, setHarnessId] = (0, import_react15.useState)(comp.harness_id || "");
2913
+ const [wfSlug, setWfSlug] = (0, import_react15.useState)(comp.workflow_slug || "");
2914
+ const [outKey, setOutKey] = (0, import_react15.useState)(comp.output_key || "");
2915
+ const [deps, setDeps] = (0, import_react15.useState)(new Set(comp.deps || []));
2378
2916
  const others = columns.filter((c) => c.id !== col.id);
2379
2917
  const toggleDep = (id) => setDeps((s) => {
2380
2918
  const n = new Set(s);
@@ -2411,7 +2949,7 @@ function ColumnMenu({ col, columns, anchor, columnTypes, renderColumnConfig, onA
2411
2949
  close: onClose
2412
2950
  });
2413
2951
  const desc = columnTypes.find((t) => t.type === type) || {};
2414
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2952
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2415
2953
  PopPortal,
2416
2954
  {
2417
2955
  anchor,
@@ -2419,14 +2957,14 @@ function ColumnMenu({ col, columns, anchor, columnTypes, renderColumnConfig, onA
2419
2957
  estHeight: desc.configHeight || 340,
2420
2958
  className: "shg-menu",
2421
2959
  onClose,
2422
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { onClick: (e) => e.stopPropagation(), children: [
2423
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-lbl", children: [
2960
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { onClick: (e) => e.stopPropagation(), children: [
2961
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "shg-menu-lbl", children: [
2424
2962
  "Type",
2425
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("select", { className: "shg-menu-input", value: type, onChange: (e) => setType(e.target.value), children: columnTypes.map((t) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("option", { value: t.type, children: t.label }, t.type)) })
2963
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("select", { className: "shg-menu-input", value: type, onChange: (e) => setType(e.target.value), children: columnTypes.map((t) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: t.type, children: t.label }, t.type)) })
2426
2964
  ] }),
2427
- (type === "select" || type === "tags") && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-lbl", children: [
2965
+ (type === "select" || type === "tags") && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "shg-menu-lbl", children: [
2428
2966
  "Options (one per line)",
2429
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2967
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2430
2968
  "textarea",
2431
2969
  {
2432
2970
  className: "shg-menu-input",
@@ -2437,16 +2975,16 @@ function ColumnMenu({ col, columns, anchor, columnTypes, renderColumnConfig, onA
2437
2975
  }
2438
2976
  )
2439
2977
  ] }),
2440
- custom !== void 0 ? custom : /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
2441
- type === "compute" && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
2442
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-lbl", children: [
2978
+ custom !== void 0 ? custom : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
2979
+ type === "compute" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
2980
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "shg-menu-lbl", children: [
2443
2981
  "Runs",
2444
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("select", { className: "shg-menu-input", value: kind, onChange: (e) => setKind(e.target.value), children: COMPUTE_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("option", { value: k.kind, children: k.label }, k.kind)) })
2982
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("select", { className: "shg-menu-input", value: kind, onChange: (e) => setKind(e.target.value), children: COMPUTE_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: k.kind, children: k.label }, k.kind)) })
2445
2983
  ] }),
2446
- (kind === "prompt" || kind === "harness") && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-lbl", children: [
2984
+ (kind === "prompt" || kind === "harness") && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "shg-menu-lbl", children: [
2447
2985
  "Prompt \u2014 reference columns as ",
2448
2986
  "{{Name}}",
2449
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2987
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2450
2988
  "textarea",
2451
2989
  {
2452
2990
  className: "shg-menu-input",
@@ -2457,32 +2995,32 @@ function ColumnMenu({ col, columns, anchor, columnTypes, renderColumnConfig, onA
2457
2995
  }
2458
2996
  )
2459
2997
  ] }),
2460
- kind === "harness" && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-lbl", children: [
2998
+ kind === "harness" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "shg-menu-lbl", children: [
2461
2999
  "Agent id",
2462
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { className: "shg-menu-input", value: harnessId, onChange: (e) => setHarnessId(e.target.value), placeholder: "chrn_\u2026" })
3000
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { className: "shg-menu-input", value: harnessId, onChange: (e) => setHarnessId(e.target.value), placeholder: "chrn_\u2026" })
2463
3001
  ] }),
2464
- kind === "workflow" && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
2465
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-lbl", children: [
3002
+ kind === "workflow" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
3003
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "shg-menu-lbl", children: [
2466
3004
  "Workflow id",
2467
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { className: "shg-menu-input", value: wfSlug, onChange: (e) => setWfSlug(e.target.value), placeholder: "my-workflow" })
3005
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { className: "shg-menu-input", value: wfSlug, onChange: (e) => setWfSlug(e.target.value), placeholder: "my-workflow" })
2468
3006
  ] }),
2469
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-lbl", children: [
3007
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "shg-menu-lbl", children: [
2470
3008
  "Output key (optional)",
2471
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { className: "shg-menu-input", value: outKey, onChange: (e) => setOutKey(e.target.value), placeholder: "summary" })
3009
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { className: "shg-menu-input", value: outKey, onChange: (e) => setOutKey(e.target.value), placeholder: "summary" })
2472
3010
  ] })
2473
3011
  ] }),
2474
- others.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "shg-menu-lbl", children: [
3012
+ others.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "shg-menu-lbl", children: [
2475
3013
  "Reads columns",
2476
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "shg-menu-deps", children: others.map((c) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-dep", children: [
2477
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { type: "checkbox", checked: deps.has(c.id), onChange: () => toggleDep(c.id) }),
3014
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "shg-menu-deps", children: others.map((c) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "shg-menu-dep", children: [
3015
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { type: "checkbox", checked: deps.has(c.id), onChange: () => toggleDep(c.id) }),
2478
3016
  " ",
2479
3017
  c.name
2480
3018
  ] }, c.id)) })
2481
3019
  ] })
2482
3020
  ] }),
2483
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "shg-menu-actions", children: [
2484
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "shg-menu-del", onClick: onDelete, children: "Delete column" }),
2485
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "shg-menu-apply", onClick: apply, children: "Apply" })
3021
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "shg-menu-actions", children: [
3022
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { className: "shg-menu-del", onClick: onDelete, children: "Delete column" }),
3023
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { className: "shg-menu-apply", onClick: apply, children: "Apply" })
2486
3024
  ] })
2487
3025
  ] })
2488
3026
  ] })
@@ -2524,4 +3062,295 @@ function sheetToAoA(sheet, { cellText = defaultCellValue } = {}) {
2524
3062
  ...rows.map((r) => cols.map((c) => cellText(cells[cellKey(r.id, c.id)], c) ?? ""))
2525
3063
  ];
2526
3064
  }
3065
+
3066
+ // src/components/Carousel.jsx
3067
+ var import_react16 = __toESM(require("react"), 1);
3068
+ var import_jsx_runtime14 = require("react/jsx-runtime");
3069
+ function Carousel(props) {
3070
+ const { label, step, children, classNames = {} } = props;
3071
+ const ref = (0, import_react16.useRef)(null);
3072
+ const [edges, setEdges] = (0, import_react16.useState)({ start: true, end: true, overflow: false });
3073
+ const measure = (0, import_react16.useCallback)(() => {
3074
+ const el = ref.current;
3075
+ if (!el) return;
3076
+ const overflow = el.scrollWidth - el.clientWidth > 1;
3077
+ setEdges({
3078
+ overflow,
3079
+ start: el.scrollLeft <= 1,
3080
+ end: el.scrollLeft >= el.scrollWidth - el.clientWidth - 1
3081
+ });
3082
+ }, []);
3083
+ (0, import_react16.useEffect)(() => {
3084
+ const el = ref.current;
3085
+ if (!el) return void 0;
3086
+ measure();
3087
+ const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(measure) : null;
3088
+ ro?.observe(el);
3089
+ for (const child of el.children) ro?.observe(child);
3090
+ return () => ro?.disconnect();
3091
+ }, [measure, children]);
3092
+ const scroll = (dir) => {
3093
+ const el = ref.current;
3094
+ if (!el) return;
3095
+ el.scrollBy({ left: dir * (step || Math.round(el.clientWidth * 0.9)), behavior: "smooth" });
3096
+ };
3097
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: ["uic-carousel-wrap", classNames.root || ""].filter(Boolean).join(" "), children: [
3098
+ edges.overflow ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3099
+ "button",
3100
+ {
3101
+ type: "button",
3102
+ className: ["uic-carousel-nav is-left", classNames.button || ""].filter(Boolean).join(" "),
3103
+ onClick: () => scroll(-1),
3104
+ disabled: edges.start,
3105
+ "aria-label": `Scroll ${label} left`,
3106
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Chevron, { dir: "left" })
3107
+ }
3108
+ ) : null,
3109
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3110
+ "div",
3111
+ {
3112
+ className: ["uic-carousel", classNames.viewport || ""].filter(Boolean).join(" "),
3113
+ ref,
3114
+ onScroll: measure,
3115
+ role: "group",
3116
+ "aria-label": label,
3117
+ children
3118
+ }
3119
+ ),
3120
+ edges.overflow ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3121
+ "button",
3122
+ {
3123
+ type: "button",
3124
+ className: ["uic-carousel-nav is-right", classNames.button || ""].filter(Boolean).join(" "),
3125
+ onClick: () => scroll(1),
3126
+ disabled: edges.end,
3127
+ "aria-label": `Scroll ${label} right`,
3128
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Chevron, { dir: "right" })
3129
+ }
3130
+ ) : null
3131
+ ] });
3132
+ }
3133
+
3134
+ // src/components/Card.jsx
3135
+ var import_react17 = __toESM(require("react"), 1);
3136
+ var import_jsx_runtime15 = require("react/jsx-runtime");
3137
+ function Card(props) {
3138
+ const { art, title, subtitle, onClick, selected = false, overlay, actions, classNames = {} } = props;
3139
+ const foot = /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "uic-card-foot", children: [
3140
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "uic-card-name", children: title }),
3141
+ subtitle ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "uic-card-sub", children: subtitle }) : null
3142
+ ] });
3143
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: ["uic-card", selected ? "is-selected" : "", classNames.root || ""].filter(Boolean).join(" "), children: [
3144
+ onClick ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("button", { type: "button", className: "uic-card-main", onClick, "aria-pressed": selected || void 0, children: [
3145
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "uic-card-art", children: art }),
3146
+ foot
3147
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "uic-card-main", children: [
3148
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "uic-card-art", children: art }),
3149
+ foot
3150
+ ] }),
3151
+ overlay ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "uic-card-overlay", children: overlay }) : null,
3152
+ actions ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "uic-card-actions", children: actions }) : null
3153
+ ] });
3154
+ }
3155
+
3156
+ // src/components/SearchField.jsx
3157
+ var import_react18 = __toESM(require("react"), 1);
3158
+ var import_jsx_runtime16 = require("react/jsx-runtime");
3159
+ function SearchField(props) {
3160
+ const { value, onChange, placeholder, clearLabel = "Clear search", className } = props;
3161
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: ["uic-search", className || ""].filter(Boolean).join(" "), children: [
3162
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "uic-search-ic", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(IcSearch, {}) }),
3163
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3164
+ "input",
3165
+ {
3166
+ type: "search",
3167
+ value,
3168
+ placeholder,
3169
+ "aria-label": placeholder,
3170
+ onChange: (e) => onChange(e.target.value)
3171
+ }
3172
+ ),
3173
+ value ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: "uic-search-x", "aria-label": clearLabel, onClick: () => onChange(""), children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(IcX, { size: 12 }) }) : null
3174
+ ] });
3175
+ }
3176
+
3177
+ // src/components/Popover.jsx
3178
+ var import_react19 = __toESM(require("react"), 1);
3179
+ var import_react_dom3 = require("react-dom");
3180
+ var import_jsx_runtime17 = require("react/jsx-runtime");
3181
+ var GAP = 6;
3182
+ var MARGIN = 8;
3183
+ function Popover(props) {
3184
+ const {
3185
+ open,
3186
+ anchorRef,
3187
+ onClose,
3188
+ width = 280,
3189
+ minHeight = 140,
3190
+ placement = "auto",
3191
+ children,
3192
+ className,
3193
+ label
3194
+ } = props;
3195
+ const popRef = (0, import_react19.useRef)(null);
3196
+ const [pos, setPos] = (0, import_react19.useState)(null);
3197
+ (0, import_react19.useEffect)(() => {
3198
+ if (!open) {
3199
+ setPos(null);
3200
+ return void 0;
3201
+ }
3202
+ const place = () => {
3203
+ const el = anchorRef?.current;
3204
+ if (!el) return;
3205
+ const r = el.getBoundingClientRect();
3206
+ const vw = window.innerWidth;
3207
+ const vh = window.innerHeight;
3208
+ const w = Math.min(width, vw - MARGIN * 2);
3209
+ const below = vh - r.bottom - GAP - MARGIN;
3210
+ const above = r.top - GAP - MARGIN;
3211
+ const up = placement === "above" || placement === "auto" && below < minHeight && above > below;
3212
+ const maxHeight = Math.max(minHeight, Math.floor(up ? above : below));
3213
+ const left = Math.max(MARGIN, Math.min(r.left, vw - w - MARGIN));
3214
+ setPos(up ? { left, bottom: Math.round(vh - r.top + GAP), width: w, maxHeight } : { left, top: Math.round(r.bottom + GAP), width: w, maxHeight });
3215
+ };
3216
+ place();
3217
+ window.addEventListener("resize", place);
3218
+ window.addEventListener("scroll", place, true);
3219
+ return () => {
3220
+ window.removeEventListener("resize", place);
3221
+ window.removeEventListener("scroll", place, true);
3222
+ };
3223
+ }, [open, anchorRef, width, minHeight, placement]);
3224
+ (0, import_react19.useEffect)(() => {
3225
+ if (!open) return void 0;
3226
+ const onDown = (e) => {
3227
+ if (popRef.current?.contains(e.target)) return;
3228
+ if (anchorRef?.current?.contains(e.target)) return;
3229
+ onClose?.();
3230
+ };
3231
+ document.addEventListener("pointerdown", onDown);
3232
+ return () => document.removeEventListener("pointerdown", onDown);
3233
+ }, [open, anchorRef, onClose]);
3234
+ const escape = (0, import_react19.useCallback)(() => onClose?.(), [onClose]);
3235
+ useOverlayEscape(open, escape);
3236
+ if (!open || !pos || typeof document === "undefined") return null;
3237
+ return (0, import_react_dom3.createPortal)(
3238
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
3239
+ "div",
3240
+ {
3241
+ ref: popRef,
3242
+ className: ["uic-pop", className || ""].filter(Boolean).join(" "),
3243
+ style: pos,
3244
+ role: "dialog",
3245
+ "aria-label": label,
3246
+ children
3247
+ }
3248
+ ),
3249
+ document.body
3250
+ );
3251
+ }
3252
+
3253
+ // src/components/Modal.jsx
3254
+ var import_react20 = __toESM(require("react"), 1);
3255
+ var import_react_dom4 = require("react-dom");
3256
+ var import_jsx_runtime18 = require("react/jsx-runtime");
3257
+ function Modal(props) {
3258
+ const {
3259
+ open,
3260
+ onClose,
3261
+ title,
3262
+ description,
3263
+ actions,
3264
+ size = "md",
3265
+ width,
3266
+ labelledBy,
3267
+ children,
3268
+ classNames = {}
3269
+ } = props;
3270
+ const titleId = (0, import_react20.useId)();
3271
+ const escape = (0, import_react20.useCallback)(() => onClose?.(), [onClose]);
3272
+ useOverlayEscape(open, escape);
3273
+ (0, import_react20.useEffect)(() => {
3274
+ if (!open || typeof document === "undefined") return void 0;
3275
+ const prev = document.body.style.overflow;
3276
+ document.body.style.overflow = "hidden";
3277
+ return () => {
3278
+ document.body.style.overflow = prev;
3279
+ };
3280
+ }, [open]);
3281
+ if (!open || typeof document === "undefined") return null;
3282
+ const onBackdrop = (e) => {
3283
+ if (e.target === e.currentTarget) onClose?.();
3284
+ };
3285
+ return (0, import_react_dom4.createPortal)(
3286
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3287
+ "div",
3288
+ {
3289
+ className: ["uic-modal-backdrop", classNames.backdrop || ""].filter(Boolean).join(" "),
3290
+ onMouseDown: onBackdrop,
3291
+ children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
3292
+ "div",
3293
+ {
3294
+ className: ["uic-modal", `is-${size}`, classNames.root || ""].filter(Boolean).join(" "),
3295
+ style: width ? { width } : void 0,
3296
+ role: "dialog",
3297
+ "aria-modal": "true",
3298
+ "aria-labelledby": labelledBy || (title ? titleId : void 0),
3299
+ children: [
3300
+ title || actions ? /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "uic-modal-h", children: [
3301
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "uic-modal-title", children: [
3302
+ title ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("h3", { id: titleId, children: title }) : null,
3303
+ description ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { children: description }) : null
3304
+ ] }),
3305
+ actions,
3306
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: "uic-modal-x", "aria-label": "Close", onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(IcX, { size: 18 }) })
3307
+ ] }) : null,
3308
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: ["uic-modal-b", classNames.body || ""].filter(Boolean).join(" "), children })
3309
+ ]
3310
+ }
3311
+ )
3312
+ }
3313
+ ),
3314
+ document.body
3315
+ );
3316
+ }
3317
+
3318
+ // src/hooks/useTypewriter.js
3319
+ var import_react21 = require("react");
3320
+ var CHAR_MS = 26;
3321
+ var HOLD_MS = 2600;
3322
+ function useTypewriter(phrases, { active = true } = {}) {
3323
+ const list = phrases && phrases.length ? phrases : [""];
3324
+ const [text, setText] = (0, import_react21.useState)(list[0]);
3325
+ const listRef = (0, import_react21.useRef)(list);
3326
+ listRef.current = list;
3327
+ (0, import_react21.useEffect)(() => {
3328
+ if (!active) return void 0;
3329
+ if (typeof window === "undefined") return void 0;
3330
+ if (window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches) {
3331
+ setText(listRef.current[0]);
3332
+ return void 0;
3333
+ }
3334
+ let i = 0;
3335
+ let pos = 0;
3336
+ let timer;
3337
+ const tick = () => {
3338
+ const cur = listRef.current[i % listRef.current.length];
3339
+ if (pos <= cur.length) {
3340
+ setText(cur.slice(0, pos));
3341
+ pos += 1;
3342
+ timer = window.setTimeout(tick, CHAR_MS);
3343
+ } else {
3344
+ timer = window.setTimeout(() => {
3345
+ i += 1;
3346
+ pos = 0;
3347
+ tick();
3348
+ }, HOLD_MS);
3349
+ }
3350
+ };
3351
+ tick();
3352
+ return () => window.clearTimeout(timer);
3353
+ }, [active]);
3354
+ return text;
3355
+ }
2527
3356
  //# sourceMappingURL=index.cjs.map