reifyui 0.1.0 → 0.3.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.
package/dist/index.cjs CHANGED
@@ -37,6 +37,7 @@ __export(src_exports, {
37
37
  CodeBlock: () => CodeBlock,
38
38
  Composer: () => Composer,
39
39
  DEFAULT_STATUS_LABELS: () => DEFAULT_STATUS_LABELS,
40
+ DialogHost: () => DialogHost,
40
41
  GOOGLE_ENABLED: () => GOOGLE_ENABLED,
41
42
  GoogleButton: () => GoogleButton,
42
43
  IcCheck: () => IcCheck,
@@ -56,6 +57,7 @@ __export(src_exports, {
56
57
  SESSION_EVENT: () => SESSION_EVENT,
57
58
  SheetGrid: () => SheetGrid,
58
59
  Svg: () => Svg,
60
+ TaskList: () => TaskList,
59
61
  ToolGroup: () => ToolGroup,
60
62
  ToolRow: () => ToolRow,
61
63
  UserTurn: () => UserTurn,
@@ -87,7 +89,9 @@ __export(src_exports, {
87
89
  sheetToDelimited: () => sheetToDelimited,
88
90
  summarizeSteps: () => summarizeSteps,
89
91
  switchOrg: () => switchOrg,
92
+ taskStatusGroup: () => taskStatusGroup,
90
93
  toolMeta: () => toolMeta,
94
+ useDialog: () => useDialog,
91
95
  useResizablePane: () => useResizablePane,
92
96
  withReasoning: () => withReasoning,
93
97
  withResult: () => withResult,
@@ -952,6 +956,411 @@ function PaneResizer(props) {
952
956
  );
953
957
  }
954
958
 
959
+ // src/components/TaskList.jsx
960
+ var import_react8 = require("react");
961
+ var import_jsx_runtime7 = require("react/jsx-runtime");
962
+ var STATUS_GROUPS = {
963
+ all: () => true,
964
+ working: (s) => ["running", "starting", "queued", "in_progress"].includes(s),
965
+ done: (s) => ["done", "completed"].includes(s),
966
+ failed: (s) => ["failed", "cancelled", "incomplete", "error"].includes(s)
967
+ };
968
+ function taskStatusGroup(status) {
969
+ const s = String(status || "").toLowerCase();
970
+ for (const k of ["working", "done", "failed"]) if (STATUS_GROUPS[k](s)) return k;
971
+ return "idle";
972
+ }
973
+ function relTime(ts) {
974
+ const n = Number(ts) || 0;
975
+ if (!n) return "";
976
+ const ms = n > 1e12 ? n : n * 1e3;
977
+ const d = Math.max(0, Date.now() - ms) / 1e3;
978
+ if (d < 60) return "just now";
979
+ if (d < 3600) return `${Math.floor(d / 60)}m ago`;
980
+ if (d < 86400) return `${Math.floor(d / 3600)}h ago`;
981
+ return `${Math.floor(d / 86400)}d ago`;
982
+ }
983
+ function TaskList({
984
+ fetchPage,
985
+ selected,
986
+ onSelect,
987
+ onNew,
988
+ onDelete,
989
+ header,
990
+ renderMeta,
991
+ refreshNonce = 0,
992
+ emptyLabel = "No tasks yet",
993
+ newLabel = "New task",
994
+ idKey = "id",
995
+ titleKey = "title",
996
+ statusKey = "status",
997
+ timeKey = "updated_at"
998
+ }) {
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)(() => () => {
1007
+ alive.current = false;
1008
+ }, []);
1009
+ (0, import_react8.useEffect)(() => {
1010
+ let ok = true;
1011
+ Promise.resolve(fetchPage("")).then((r) => {
1012
+ if (!ok) return;
1013
+ setHead(Array.isArray(r?.items) ? r.items : []);
1014
+ setCursor(r?.cursor || "");
1015
+ }).catch(() => {
1016
+ if (ok) setHead((p) => p ?? []);
1017
+ });
1018
+ return () => {
1019
+ ok = false;
1020
+ };
1021
+ }, [fetchPage, refreshNonce]);
1022
+ const loadMore = (0, import_react8.useCallback)(() => {
1023
+ if (!cursor || loadingMore) return;
1024
+ setLoadingMore(true);
1025
+ Promise.resolve(fetchPage(cursor)).then((r) => {
1026
+ if (!alive.current) return;
1027
+ if (Array.isArray(r?.items)) setTail((t) => [...t, ...r.items]);
1028
+ setCursor(r?.cursor || "");
1029
+ }).catch(() => {
1030
+ }).finally(() => {
1031
+ if (alive.current) setLoadingMore(false);
1032
+ });
1033
+ }, [cursor, loadingMore, fetchPage]);
1034
+ const items = (0, import_react8.useMemo)(() => {
1035
+ const h = head || [];
1036
+ const seen = new Set(h.map((x) => x?.[idKey]));
1037
+ return [...h, ...tail.filter((t) => !seen.has(t?.[idKey]))];
1038
+ }, [head, tail, idKey]);
1039
+ const shown = (0, import_react8.useMemo)(() => {
1040
+ const needle = q.trim().toLowerCase();
1041
+ const pass = STATUS_GROUPS[statusFilter] || STATUS_GROUPS.all;
1042
+ return items.filter((it) => {
1043
+ if (!pass(String(it?.[statusKey] || "").toLowerCase())) return false;
1044
+ if (!needle) return true;
1045
+ return String(it?.[titleKey] || "").toLowerCase().includes(needle);
1046
+ });
1047
+ }, [items, q, statusFilter, statusKey, titleKey]);
1048
+ const onScroll = (e) => {
1049
+ const el = e.currentTarget;
1050
+ if (el.scrollTop + el.clientHeight > el.scrollHeight - 140) loadMore();
1051
+ };
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: [
1055
+ "+ ",
1056
+ newLabel
1057
+ ] }) : null,
1058
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "rui-tasks-filters", children: [
1059
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1060
+ "input",
1061
+ {
1062
+ className: "rui-tasks-search",
1063
+ value: q,
1064
+ placeholder: "Filter tasks\u2026",
1065
+ onChange: (e) => setQ(e.target.value),
1066
+ "aria-label": "Filter tasks"
1067
+ }
1068
+ ),
1069
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1070
+ "select",
1071
+ {
1072
+ className: "rui-tasks-status",
1073
+ value: statusFilter,
1074
+ onChange: (e) => setStatusFilter(e.target.value),
1075
+ "aria-label": "Filter by status",
1076
+ 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" })
1081
+ ]
1082
+ }
1083
+ )
1084
+ ] }),
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) => {
1087
+ const id = it?.[idKey];
1088
+ const group = taskStatusGroup(it?.[statusKey]);
1089
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1090
+ "div",
1091
+ {
1092
+ className: `rui-task${id === selected ? " is-selected" : ""}`,
1093
+ onClick: () => onSelect?.(id),
1094
+ role: "button",
1095
+ tabIndex: 0,
1096
+ onKeyDown: (e) => {
1097
+ if (e.key === "Enter" || e.key === " ") onSelect?.(id);
1098
+ },
1099
+ 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
1106
+ ] }) })
1107
+ ] }),
1108
+ onDelete ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1109
+ "button",
1110
+ {
1111
+ type: "button",
1112
+ className: "rui-task-del",
1113
+ "aria-label": "Delete task",
1114
+ onClick: (e) => {
1115
+ e.stopPropagation();
1116
+ onDelete(it);
1117
+ },
1118
+ children: "\xD7"
1119
+ }
1120
+ ) : null
1121
+ ]
1122
+ },
1123
+ id
1124
+ );
1125
+ }),
1126
+ loadingMore ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "rui-tasks-empty", children: "Loading more\u2026" }) : null
1127
+ ] })
1128
+ ] });
1129
+ }
1130
+
1131
+ // src/components/Dialog.jsx
1132
+ var import_react9 = require("react");
1133
+ var import_react_dom = require("react-dom");
1134
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1135
+ var DialogCtx = (0, import_react9.createContext)(null);
1136
+ var LABELS = {
1137
+ en: { confirm: "Confirm", cancel: "Cancel", ok: "OK", create: "Create", required: "Please enter a value" },
1138
+ zh: { confirm: "\u786E\u8BA4", cancel: "\u53D6\u6D88", ok: "\u597D\u7684", create: "\u521B\u5EFA", required: "\u8BF7\u8F93\u5165\u5185\u5BB9" }
1139
+ };
1140
+ var _idSeq = 0;
1141
+ function DialogHost({ children, locale = "en", labels }) {
1142
+ const [stack, setStack] = (0, import_react9.useState)([]);
1143
+ const t = (0, import_react9.useMemo)(
1144
+ () => ({ ...LABELS[locale] || LABELS.en, ...labels || {} }),
1145
+ [locale, labels]
1146
+ );
1147
+ const open = (0, import_react9.useCallback)((spec) => new Promise((resolve) => {
1148
+ setStack((s) => [...s, { id: `dlg_${++_idSeq}`, spec, resolve }]);
1149
+ }), []);
1150
+ const close = (0, import_react9.useCallback)((id, value) => {
1151
+ setStack((s) => {
1152
+ const target = s.find((d) => d.id === id);
1153
+ if (target) target.resolve(value);
1154
+ return s.filter((d) => d.id !== id);
1155
+ });
1156
+ }, []);
1157
+ const ctx = (0, import_react9.useMemo)(() => ({
1158
+ confirm: (opts) => open({ kind: "confirm", ...opts }),
1159
+ prompt: (opts) => open({ kind: "prompt", ...opts }),
1160
+ alert: (opts) => open({ kind: "alert", ...opts }),
1161
+ create: (opts) => open({ kind: "create", ...opts }),
1162
+ labels: t
1163
+ }), [open, t]);
1164
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(DialogCtx.Provider, { value: ctx, children: [
1165
+ 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)) }),
1168
+ document.body
1169
+ )
1170
+ ] });
1171
+ }
1172
+ function useDialog() {
1173
+ const ctx = (0, import_react9.useContext)(DialogCtx);
1174
+ if (!ctx) throw new Error("useDialog() called outside <DialogHost>");
1175
+ return ctx;
1176
+ }
1177
+ var cancelValue = (kind) => kind === "prompt" || kind === "create" ? null : false;
1178
+ function DialogShell({ dialog, isTop, onClose, t }) {
1179
+ 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)(() => {
1193
+ if (!isTop || !ref.current) return;
1194
+ const el = ref.current.querySelector("input, textarea") || ref.current.querySelector(".rui-dlg-primary") || ref.current.querySelector("button");
1195
+ el?.focus();
1196
+ }, [isTop]);
1197
+ const onBackdrop = (e) => {
1198
+ if (e.target === e.currentTarget && isTop) onClose(id, cancelValue(spec.kind));
1199
+ };
1200
+ 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)(
1202
+ "div",
1203
+ {
1204
+ ref,
1205
+ role: "dialog",
1206
+ "aria-modal": "true",
1207
+ "aria-labelledby": spec.title ? titleId : void 0,
1208
+ className: `rui-dlg-card${spec.kind === "create" ? " is-wide" : ""}`,
1209
+ 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 })
1214
+ ]
1215
+ }
1216
+ ) });
1217
+ }
1218
+ function Header({ title, variant, titleId }) {
1219
+ 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 }) });
1221
+ }
1222
+ var Footer = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rui-dlg-f", children });
1223
+ 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 }) })
1228
+ ] });
1229
+ }
1230
+ function ConfirmBody({ spec, onClose, t, titleId }) {
1231
+ 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)(
1238
+ "button",
1239
+ {
1240
+ type: "button",
1241
+ className: `rui-dlg-btn rui-dlg-primary${destructive ? " is-destructive" : ""}`,
1242
+ onClick: () => onClose(true),
1243
+ children: spec.confirmLabel || t.confirm
1244
+ }
1245
+ )
1246
+ ] })
1247
+ ] });
1248
+ }
1249
+ 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)();
1253
+ const Field = spec.multiline ? "textarea" : "input";
1254
+ const submit = () => {
1255
+ const invalid = spec.validate?.(value);
1256
+ if (invalid) {
1257
+ setErr(String(invalid));
1258
+ return;
1259
+ }
1260
+ if (spec.required !== false && !String(value).trim()) {
1261
+ setErr(t.required);
1262
+ return;
1263
+ }
1264
+ onClose(String(value));
1265
+ };
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)(
1272
+ Field,
1273
+ {
1274
+ id: inputId,
1275
+ className: `rui-dlg-input${err ? " is-err" : ""}`,
1276
+ type: spec.multiline ? void 0 : spec.inputType || "text",
1277
+ rows: spec.multiline ? spec.rows || 4 : void 0,
1278
+ value,
1279
+ placeholder: spec.placeholder || "",
1280
+ onChange: (e) => {
1281
+ setValue(e.target.value);
1282
+ if (err) setErr(null);
1283
+ },
1284
+ onKeyDown: (e) => {
1285
+ if (e.key === "Enter" && !e.shiftKey && !spec.multiline) {
1286
+ e.preventDefault();
1287
+ submit();
1288
+ }
1289
+ },
1290
+ autoComplete: "off",
1291
+ spellCheck: "false"
1292
+ }
1293
+ ),
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
1296
+ ] }),
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 })
1300
+ ] })
1301
+ ] });
1302
+ }
1303
+ function CreateBody({ spec, onClose, t, titleId }) {
1304
+ 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)();
1309
+ const sel = types.find((x) => x.kind === kind) || types[0] || {};
1310
+ const submit = () => {
1311
+ if (spec.required !== false && !String(value).trim()) {
1312
+ setErr(t.required);
1313
+ return;
1314
+ }
1315
+ onClose({ kind, name: String(value).trim() });
1316
+ };
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)(
1321
+ "button",
1322
+ {
1323
+ type: "button",
1324
+ className: `rui-dlg-type${ty.kind === kind ? " is-on" : ""}`,
1325
+ onClick: () => setKind(ty.kind),
1326
+ 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 })
1329
+ ]
1330
+ },
1331
+ ty.kind
1332
+ )) }) : 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)(
1335
+ "input",
1336
+ {
1337
+ id: inputId,
1338
+ className: `rui-dlg-input${err ? " is-err" : ""}`,
1339
+ value,
1340
+ placeholder: spec.placeholder || "Untitled",
1341
+ onChange: (e) => {
1342
+ setValue(e.target.value);
1343
+ if (err) setErr(null);
1344
+ },
1345
+ onKeyDown: (e) => {
1346
+ if (e.key === "Enter" && !e.shiftKey) {
1347
+ e.preventDefault();
1348
+ submit();
1349
+ }
1350
+ },
1351
+ autoComplete: "off",
1352
+ spellCheck: "false"
1353
+ }
1354
+ ),
1355
+ err ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rui-dlg-err", children: err }) : null
1356
+ ] }),
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 })
1360
+ ] })
1361
+ ] });
1362
+ }
1363
+
955
1364
  // src/auth/client.js
956
1365
  var _cfg = {
957
1366
  engine: "",
@@ -1101,18 +1510,18 @@ async function fetchBalance() {
1101
1510
  }
1102
1511
 
1103
1512
  // src/auth/AuthForm.jsx
1104
- var import_react9 = require("react");
1513
+ var import_react11 = require("react");
1105
1514
 
1106
1515
  // src/auth/GoogleButton.jsx
1107
- var import_react8 = require("react");
1108
- var import_jsx_runtime7 = require("react/jsx-runtime");
1516
+ var import_react10 = require("react");
1517
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1109
1518
  var CLIENT_ID = "247853836408-ojk91u8901hdlbkevid4fohmrfdot17l.apps.googleusercontent.com";
1110
1519
  function GoogleButton({ onCredential, onError }) {
1111
- const ref = (0, import_react8.useRef)(null);
1112
- const [failed, setFailed] = (0, import_react8.useState)(false);
1113
- const cb = (0, import_react8.useRef)({ 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 });
1114
1523
  cb.current = { onCredential, onError };
1115
- (0, import_react8.useEffect)(() => {
1524
+ (0, import_react10.useEffect)(() => {
1116
1525
  if (!CLIENT_ID || !ref.current) return void 0;
1117
1526
  const SRC = "https://accounts.google.com/gsi/client";
1118
1527
  let done = false;
@@ -1163,24 +1572,24 @@ function GoogleButton({ onCredential, onError }) {
1163
1572
  };
1164
1573
  }, []);
1165
1574
  if (!CLIENT_ID || failed) return null;
1166
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
1167
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "auth-or", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: "or" }) }),
1168
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { ref, className: "auth-gwrap" })
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" })
1169
1578
  ] });
1170
1579
  }
1171
1580
  var GOOGLE_ENABLED = !!CLIENT_ID;
1172
1581
 
1173
1582
  // src/auth/AuthForm.jsx
1174
- var import_jsx_runtime8 = require("react/jsx-runtime");
1583
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1175
1584
  function AuthForm({ onDone, subtitle, brand = null, productName = "" }) {
1176
- const [mode, setMode] = (0, import_react9.useState)("signin");
1177
- const [email, setEmail] = (0, import_react9.useState)("");
1178
- const [password, setPassword] = (0, import_react9.useState)("");
1179
- const [name, setName] = (0, import_react9.useState)("");
1180
- const [err, setErr] = (0, import_react9.useState)("");
1181
- const [busy, setBusy] = (0, import_react9.useState)(false);
1182
- const [choices, setChoices] = (0, import_react9.useState)(null);
1183
- const [resetSent, setResetSent] = (0, import_react9.useState)(false);
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);
1184
1593
  async function enter(orgId) {
1185
1594
  const session = await switchOrg(orgId);
1186
1595
  onDone(session);
@@ -1221,10 +1630,10 @@ function AuthForm({ onDone, subtitle, brand = null, productName = "" }) {
1221
1630
  }
1222
1631
  }
1223
1632
  if (choices) {
1224
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
1225
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "logo", children: brand }),
1226
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h1", { children: "Choose workspace" }),
1227
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "org-list", children: choices.map((o) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
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)(
1228
1637
  "button",
1229
1638
  {
1230
1639
  type: "button",
@@ -1242,20 +1651,20 @@ function AuthForm({ onDone, subtitle, brand = null, productName = "" }) {
1242
1651
  },
1243
1652
  o.id
1244
1653
  )) }),
1245
- err && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "auth-err", children: err })
1654
+ err && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "auth-err", children: err })
1246
1655
  ] });
1247
1656
  }
1248
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("form", { onSubmit: submit, children: [
1249
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "logo", children: brand }),
1250
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h1", { children: mode === "register" ? "Create your account" : mode === "forgot" ? "Reset password" : "Sign in" }),
1251
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "sub", children: mode === "register" ? "Get started in seconds." : mode === "forgot" ? "We will email you a reset link." : subtitle || "Welcome back." }),
1252
- mode === "forgot" ? resetSent ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
1253
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "auth-note", children: [
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: [
1254
1663
  "If an account exists for ",
1255
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("b", { children: email.trim() }),
1664
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("b", { children: email.trim() }),
1256
1665
  ", a password reset link is on its way. It is valid for 1 hour."
1257
1666
  ] }),
1258
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1667
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1259
1668
  "button",
1260
1669
  {
1261
1670
  type: "button",
@@ -1269,36 +1678,36 @@ function AuthForm({ onDone, subtitle, brand = null, productName = "" }) {
1269
1678
  children: "Back to sign in"
1270
1679
  }
1271
1680
  )
1272
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
1273
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "field", children: [
1274
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { children: "Email" }),
1275
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("input", { className: "input", type: "email", value: email, onChange: (e) => setEmail(e.target.value), autoFocus: true, required: true, autoComplete: "email" })
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" })
1276
1685
  ] }),
1277
- err && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "auth-err", children: err }),
1278
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "submit", className: "btn primary lg", style: { width: "100%", marginTop: 8 }, disabled: busy, children: busy ? "Please wait..." : "Send reset link" }),
1279
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "auth-switch", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", onClick: () => {
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: () => {
1280
1689
  setErr("");
1281
1690
  setMode("signin");
1282
1691
  }, children: "Back to sign in" }) })
1283
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
1284
- mode === "register" && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "field", children: [
1285
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { children: "Name" }),
1286
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("input", { className: "input", value: name, onChange: (e) => setName(e.target.value), autoComplete: "name", placeholder: "Jane Doe" })
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" })
1287
1696
  ] }),
1288
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "field", children: [
1289
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { children: "Email" }),
1290
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("input", { className: "input", type: "email", value: email, onChange: (e) => setEmail(e.target.value), autoFocus: true, required: true, autoComplete: "email" })
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" })
1291
1700
  ] }),
1292
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "field", children: [
1293
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "field-row", children: [
1294
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { children: "Password" }),
1295
- mode === "signin" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", className: "link-sm", onClick: () => {
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: () => {
1296
1705
  setErr("");
1297
1706
  setResetSent(false);
1298
1707
  setMode("forgot");
1299
1708
  }, children: "Forgot password?" })
1300
1709
  ] }),
1301
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1710
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1302
1711
  "input",
1303
1712
  {
1304
1713
  className: "input",
@@ -1311,13 +1720,13 @@ function AuthForm({ onDone, subtitle, brand = null, productName = "" }) {
1311
1720
  }
1312
1721
  )
1313
1722
  ] }),
1314
- err && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "auth-err", children: err }),
1315
- /* @__PURE__ */ (0, import_jsx_runtime8.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" }),
1316
- GOOGLE_ENABLED && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(GoogleButton, { onCredential: onGoogle, onError: setErr }),
1317
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("p", { className: "auth-switch", children: [
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: [
1318
1727
  mode === "register" ? "Already have an account?" : `New to ${productName || "the product"}?`,
1319
1728
  " ",
1320
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", onClick: () => {
1729
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", onClick: () => {
1321
1730
  setErr("");
1322
1731
  setMode(mode === "register" ? "signin" : "register");
1323
1732
  }, children: mode === "register" ? "Sign in" : "Create one" })
@@ -1327,9 +1736,9 @@ function AuthForm({ onDone, subtitle, brand = null, productName = "" }) {
1327
1736
  }
1328
1737
 
1329
1738
  // src/sheet/SheetGrid.jsx
1330
- var import_react10 = require("react");
1331
- var import_react_dom = require("react-dom");
1332
- var import_jsx_runtime9 = require("react/jsx-runtime");
1739
+ var import_react12 = require("react");
1740
+ var import_react_dom2 = require("react-dom");
1741
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1333
1742
  var cellKey = (rowId, colId) => `${rowId}:${colId}`;
1334
1743
  var uid = (p) => `${p}_${Math.random().toString(36).slice(2, 10)}`;
1335
1744
  var TYPE_LABEL = {
@@ -1353,7 +1762,7 @@ var COMPUTE_KINDS = [
1353
1762
  var RESOURCE_KINDS = ["image", "sheet", "slides", "workflow", "graph"];
1354
1763
  var RESOURCE_ICON = { image: "\u{1F5BC}", sheet: "\u25A6", slides: "\u25A4", workflow: "\u2699", graph: "\u25C9" };
1355
1764
  function PopPortal({ anchor, width = 250, estHeight = 300, className, children, onClose }) {
1356
- (0, import_react10.useEffect)(() => {
1765
+ (0, import_react12.useEffect)(() => {
1357
1766
  if (!onClose) return void 0;
1358
1767
  const close = () => onClose();
1359
1768
  window.addEventListener("scroll", close, true);
@@ -1367,8 +1776,8 @@ function PopPortal({ anchor, width = 250, estHeight = 300, className, children,
1367
1776
  const left = Math.max(8, Math.min(anchor.right - width, window.innerWidth - width - 8));
1368
1777
  let top = anchor.bottom + 6;
1369
1778
  if (top + estHeight > window.innerHeight - 8) top = Math.max(8, anchor.top - estHeight - 6);
1370
- return (0, import_react_dom.createPortal)(
1371
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className, style: { position: "fixed", top, left, width, zIndex: 1e3 }, children }),
1779
+ return (0, import_react_dom2.createPortal)(
1780
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className, style: { position: "fixed", top, left, width, zIndex: 1e3 }, children }),
1372
1781
  document.body
1373
1782
  );
1374
1783
  }
@@ -1388,8 +1797,8 @@ function pillColor(label, options) {
1388
1797
  return PILL_FALLBACKS[h % PILL_FALLBACKS.length];
1389
1798
  }
1390
1799
  function RefImage({ refVal, fetchBlobUrl }) {
1391
- const [src, setSrc] = (0, import_react10.useState)(/^https?:\/\//i.test(refVal.url || "") ? refVal.url : null);
1392
- (0, import_react10.useEffect)(() => {
1800
+ const [src, setSrc] = (0, import_react12.useState)(/^https?:\/\//i.test(refVal.url || "") ? refVal.url : null);
1801
+ (0, import_react12.useEffect)(() => {
1393
1802
  let dead = false;
1394
1803
  let obj = null;
1395
1804
  if (!src && refVal.url && fetchBlobUrl) {
@@ -1405,16 +1814,16 @@ function RefImage({ refVal, fetchBlobUrl }) {
1405
1814
  if (obj) URL.revokeObjectURL(obj);
1406
1815
  };
1407
1816
  }, [refVal.url]);
1408
- if (!src) return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "shg-refchip", children: [
1817
+ if (!src) return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "shg-refchip", children: [
1409
1818
  RESOURCE_ICON.image,
1410
1819
  " ",
1411
1820
  refVal.name || "image"
1412
1821
  ] });
1413
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("img", { className: "shg-refimg", src, alt: refVal.name || "", title: refVal.name || "" });
1822
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("img", { className: "shg-refimg", src, alt: refVal.name || "", title: refVal.name || "" });
1414
1823
  }
1415
1824
  function ResourceChip({ refVal, onOpen }) {
1416
1825
  const icon = RESOURCE_ICON[refVal.kind] || "\u25C7";
1417
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1826
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1418
1827
  "button",
1419
1828
  {
1420
1829
  className: "shg-refchip shg-refchip-btn",
@@ -1424,54 +1833,54 @@ function ResourceChip({ refVal, onOpen }) {
1424
1833
  onOpen && onOpen(refVal);
1425
1834
  },
1426
1835
  children: [
1427
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "shg-refchip-ic", children: icon }),
1428
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "shg-refchip-name", children: refVal.name || refVal.id || refVal.kind })
1836
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "shg-refchip-ic", children: icon }),
1837
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "shg-refchip-name", children: refVal.name || refVal.id || refVal.kind })
1429
1838
  ]
1430
1839
  }
1431
1840
  );
1432
1841
  }
1433
1842
  function StatusDot({ status }) {
1434
1843
  if (!status || status === "empty") return null;
1435
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: `shg-dot shg-dot-${status}`, title: status });
1844
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: `shg-dot shg-dot-${status}`, title: status });
1436
1845
  }
1437
1846
  function CellValue({ cell, col, fetchBlobUrl, onOpenResource }) {
1438
1847
  const v = cell?.value;
1439
- if (v === void 0 || v === null || v === "") return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "shg-val-txt" });
1848
+ if (v === void 0 || v === null || v === "") return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "shg-val-txt" });
1440
1849
  if (v && typeof v === "object" && !Array.isArray(v) && v.kind) {
1441
- if (v.kind === "image") return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(RefImage, { refVal: v, fetchBlobUrl });
1442
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ResourceChip, { refVal: v, onOpen: onOpenResource });
1850
+ if (v.kind === "image") return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(RefImage, { refVal: v, fetchBlobUrl });
1851
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ResourceChip, { refVal: v, onOpen: onOpenResource });
1443
1852
  }
1444
1853
  switch (col.type) {
1445
1854
  case "select":
1446
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "shg-pill", style: { background: pillColor(String(v), col.options) }, children: String(v) });
1855
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "shg-pill", style: { background: pillColor(String(v), col.options) }, children: String(v) });
1447
1856
  case "tags": {
1448
1857
  const tags = Array.isArray(v) ? v : String(v).split(",").map((s) => s.trim()).filter(Boolean);
1449
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "shg-pills", children: tags.map((t) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "shg-pill", style: { background: pillColor(t, col.options) }, children: t }, t)) });
1858
+ 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)) });
1450
1859
  }
1451
1860
  case "checkbox":
1452
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "shg-check" + (v ? " on" : ""), children: v ? "\u2713" : "" });
1861
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "shg-check" + (v ? " on" : ""), children: v ? "\u2713" : "" });
1453
1862
  case "url": {
1454
1863
  const href = /^https?:\/\//i.test(String(v)) ? String(v) : `https://${v}`;
1455
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("a", { className: "shg-link", href, target: "_blank", rel: "noreferrer", onClick: (e) => e.stopPropagation(), children: String(v) });
1864
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("a", { className: "shg-link", href, target: "_blank", rel: "noreferrer", onClick: (e) => e.stopPropagation(), children: String(v) });
1456
1865
  }
1457
1866
  case "number":
1458
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "shg-val-txt shg-num", children: String(v) });
1867
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "shg-val-txt shg-num", children: String(v) });
1459
1868
  default:
1460
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "shg-val-txt", children: typeof v === "object" ? JSON.stringify(v) : String(v) });
1869
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "shg-val-txt", children: typeof v === "object" ? JSON.stringify(v) : String(v) });
1461
1870
  }
1462
1871
  }
1463
1872
  function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false, fetchBlobUrl, onOpenResource, peerMarks, onActiveCell }) {
1464
1873
  const columns = sheet?.columns || [];
1465
1874
  const rows = sheet?.rows || [];
1466
1875
  const cells = sheet?.cells || {};
1467
- const [editing, setEditing] = (0, import_react10.useState)(null);
1468
- const [draft, setDraft] = (0, import_react10.useState)("");
1469
- const [menuCol, setMenuCol] = (0, import_react10.useState)(null);
1470
- const [sizeDraft, setSizeDraft] = (0, import_react10.useState)({});
1471
- const [dnd, setDnd] = (0, import_react10.useState)(null);
1472
- const [dropAt, setDropAt] = (0, import_react10.useState)(null);
1473
- const inputRef = (0, import_react10.useRef)(null);
1474
- const dragRef = (0, import_react10.useRef)(null);
1876
+ const [editing, setEditing] = (0, import_react12.useState)(null);
1877
+ const [draft, setDraft] = (0, import_react12.useState)("");
1878
+ const [menuCol, setMenuCol] = (0, import_react12.useState)(null);
1879
+ const [sizeDraft, setSizeDraft] = (0, import_react12.useState)({});
1880
+ const [dnd, setDnd] = (0, import_react12.useState)(null);
1881
+ const [dropAt, setDropAt] = (0, import_react12.useState)(null);
1882
+ const inputRef = (0, import_react12.useRef)(null);
1883
+ const dragRef = (0, import_react12.useRef)(null);
1475
1884
  const startResize = (e, kind, id, start) => {
1476
1885
  if (readOnly) return;
1477
1886
  e.preventDefault();
@@ -1566,7 +1975,7 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
1566
1975
  const numW = Math.max(40, 24 + String(rows.length || 1).length * 9);
1567
1976
  const numStyle = { width: numW, minWidth: numW, maxWidth: numW };
1568
1977
  const rowHeight = (row) => sizeDraft.row && sizeDraft.row[row.id] || row.height || void 0;
1569
- (0, import_react10.useEffect)(() => {
1978
+ (0, import_react12.useEffect)(() => {
1570
1979
  if (editing && inputRef.current) inputRef.current.focus();
1571
1980
  }, [editing]);
1572
1981
  const mutate = (fn) => {
@@ -1633,7 +2042,7 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
1633
2042
  if (col.type === "resource") {
1634
2043
  const d = typeof draft === "object" && draft ? draft : { kind: "sheet" };
1635
2044
  const set = (k, v) => setDraft({ ...d, [k]: v });
1636
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2045
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1637
2046
  PopPortal,
1638
2047
  {
1639
2048
  anchor: editing.rect,
@@ -1641,17 +2050,17 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
1641
2050
  estHeight: 230,
1642
2051
  className: "shg-select-pop shg-ref-pop",
1643
2052
  onClose: () => setEditing(null),
1644
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { onClick: (e) => e.stopPropagation(), children: [
1645
- /* @__PURE__ */ (0, import_jsx_runtime9.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_runtime9.jsx)("option", { value: k, children: k }, k)) }),
1646
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("input", { className: "shg-menu-input", placeholder: "Name", value: d.name || "", onChange: (e) => set("name", e.target.value) }),
1647
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("input", { className: "shg-menu-input", placeholder: "Resource id (e.g. sheet.\u2026)", value: d.id || "", onChange: (e) => set("id", e.target.value) }),
1648
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("input", { className: "shg-menu-input", placeholder: "or URL", value: d.url || "", onChange: (e) => set("url", e.target.value) }),
1649
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "shg-menu-actions", children: [
1650
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { className: "shg-pop-clear", onClick: () => {
2053
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { onClick: (e) => e.stopPropagation(), children: [
2054
+ /* @__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)) }),
2055
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { className: "shg-menu-input", placeholder: "Name", value: d.name || "", onChange: (e) => set("name", e.target.value) }),
2056
+ /* @__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) }),
2057
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { className: "shg-menu-input", placeholder: "or URL", value: d.url || "", onChange: (e) => set("url", e.target.value) }),
2058
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "shg-menu-actions", children: [
2059
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "shg-pop-clear", onClick: () => {
1651
2060
  setCell(editing.rowId, editing.colId, null);
1652
2061
  setEditing(null);
1653
2062
  }, children: "Clear" }),
1654
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { className: "shg-menu-apply", onClick: () => {
2063
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "shg-menu-apply", onClick: () => {
1655
2064
  setCell(editing.rowId, editing.colId, d);
1656
2065
  setEditing(null);
1657
2066
  }, children: "Set" })
@@ -1662,7 +2071,7 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
1662
2071
  }
1663
2072
  if (col.type === "select") {
1664
2073
  const opts = normOptions(col.options);
1665
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2074
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1666
2075
  PopPortal,
1667
2076
  {
1668
2077
  anchor: editing.rect,
@@ -1671,8 +2080,8 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
1671
2080
  className: "shg-select-pop",
1672
2081
  onClose: () => setEditing(null),
1673
2082
  children: [
1674
- opts.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "shg-pop-note", children: "No options yet \u2014 add them in the column menu." }),
1675
- opts.map((o) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2083
+ 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." }),
2084
+ opts.map((o) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1676
2085
  "button",
1677
2086
  {
1678
2087
  className: "shg-pill shg-pill-btn",
@@ -1686,7 +2095,7 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
1686
2095
  },
1687
2096
  o.label
1688
2097
  )),
1689
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2098
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1690
2099
  "button",
1691
2100
  {
1692
2101
  className: "shg-pop-clear",
@@ -1703,7 +2112,7 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
1703
2112
  );
1704
2113
  }
1705
2114
  const inputType = col.type === "date" ? "date" : col.type === "number" ? "number" : "text";
1706
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2115
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1707
2116
  "input",
1708
2117
  {
1709
2118
  ref: inputRef,
@@ -1720,18 +2129,18 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
1720
2129
  }
1721
2130
  );
1722
2131
  };
1723
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "shg", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "shg-scroll", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("table", { className: "shg-table", children: [
1724
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("tr", { children: [
1725
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("th", { className: "shg-corner", style: numStyle }),
1726
- columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2132
+ 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: [
2133
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("tr", { children: [
2134
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("th", { className: "shg-corner", style: numStyle }),
2135
+ columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1727
2136
  "th",
1728
2137
  {
1729
2138
  className: "shg-col" + (col.type === "compute" ? " shg-col-compute" : "") + dndClass("col", col.id),
1730
2139
  style: colWidth(col) ? { width: colWidth(col), minWidth: colWidth(col), maxWidth: colWidth(col) } : void 0,
1731
2140
  ...dndProps("col", col.id),
1732
2141
  children: [
1733
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "shg-resize-col", onMouseDown: (e) => startResize(e, "col", col.id, colWidth(col) || e.currentTarget.closest("th").offsetWidth) }),
1734
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "shg-col-h", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2142
+ !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) }),
2143
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "shg-col-h", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1735
2144
  ColumnHeader,
1736
2145
  {
1737
2146
  col,
@@ -1754,10 +2163,10 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
1754
2163
  },
1755
2164
  col.id
1756
2165
  )),
1757
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("th", { className: "shg-add-col", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { className: "shg-add", onClick: addColumn, title: "Add column", children: "+" }) })
2166
+ !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: "+" }) })
1758
2167
  ] }) }),
1759
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("tbody", { children: [
1760
- rows.map((row, ri) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2168
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("tbody", { children: [
2169
+ rows.map((row, ri) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1761
2170
  "tr",
1762
2171
  {
1763
2172
  style: {
@@ -1765,7 +2174,7 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
1765
2174
  "--shg-clamp": Math.max(1, Math.floor(((rowHeight(row) || 34) - 10) / 18))
1766
2175
  },
1767
2176
  children: [
1768
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2177
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1769
2178
  "td",
1770
2179
  {
1771
2180
  className: "shg-rownum" + dndClass("row", row.id),
@@ -1773,9 +2182,9 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
1773
2182
  title: "Drag to reorder",
1774
2183
  ...dndProps("row", row.id),
1775
2184
  children: [
1776
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: ri + 1 }),
1777
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { className: "shg-rowdel", onClick: () => deleteRow(row.id), title: "Delete row", children: "\xD7" }),
1778
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "shg-resize-row", onMouseDown: (e) => startResize(e, "row", row.id, rowHeight(row) || e.currentTarget.closest("tr").offsetHeight) })
2185
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { children: ri + 1 }),
2186
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "shg-rowdel", onClick: () => deleteRow(row.id), title: "Delete row", children: "\xD7" }),
2187
+ !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) })
1779
2188
  ]
1780
2189
  }
1781
2190
  ),
@@ -1783,7 +2192,7 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
1783
2192
  const c = cells[cellKey(row.id, col.id)] || {};
1784
2193
  const isEditing = editing && editing.rowId === row.id && editing.colId === col.id;
1785
2194
  const peer = peerMarks && peerMarks[cellKey(row.id, col.id)];
1786
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2195
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1787
2196
  "td",
1788
2197
  {
1789
2198
  className: "shg-cell" + (col.type === "compute" ? " shg-cell-compute" : "") + (c.status && col.type === "compute" ? ` shg-cell-${c.status}` : "") + (peer ? " shg-cell-peer" : ""),
@@ -1793,16 +2202,16 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
1793
2202
  },
1794
2203
  title: c.error || "",
1795
2204
  children: [
1796
- peer && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "shg-peer-flag", style: { background: peer.color }, children: peer.name }),
1797
- isEditing ? renderEditor(col) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2205
+ peer && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "shg-peer-flag", style: { background: peer.color }, children: peer.name }),
2206
+ isEditing ? renderEditor(col) : /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1798
2207
  "div",
1799
2208
  {
1800
2209
  className: "shg-val",
1801
2210
  style: { maxWidth: colWidth(col) ? colWidth(col) - 20 : 400 },
1802
2211
  children: [
1803
- col.type === "compute" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(StatusDot, { status: c.status }),
1804
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CellValue, { cell: c, col, fetchBlobUrl, onOpenResource }),
1805
- col.type === "compute" && !readOnly && onRunCell && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2212
+ col.type === "compute" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(StatusDot, { status: c.status }),
2213
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CellValue, { cell: c, col, fetchBlobUrl, onOpenResource }),
2214
+ col.type === "compute" && !readOnly && onRunCell && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1806
2215
  "button",
1807
2216
  {
1808
2217
  className: "shg-runcell",
@@ -1822,25 +2231,25 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
1822
2231
  col.id
1823
2232
  );
1824
2233
  }),
1825
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("td", { className: "shg-pad" })
2234
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("td", { className: "shg-pad" })
1826
2235
  ]
1827
2236
  },
1828
2237
  row.id
1829
2238
  )),
1830
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("tr", { className: "shg-ghost-row", onClick: addRow, children: [
1831
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("td", { className: "shg-rownum shg-ghost-num", style: numStyle, children: "+" }),
1832
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("td", { className: "shg-ghost-cell", colSpan: columns.length + 1, children: "New row" })
2239
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("tr", { className: "shg-ghost-row", onClick: addRow, children: [
2240
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("td", { className: "shg-rownum shg-ghost-num", style: numStyle, children: "+" }),
2241
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("td", { className: "shg-ghost-cell", colSpan: columns.length + 1, children: "New row" })
1833
2242
  ] })
1834
2243
  ] })
1835
2244
  ] }) }) });
1836
2245
  }
1837
2246
  function ColumnHeader({ col, columns, readOnly, menuOpen, menuAnchor, onMenu, onCloseMenu, onRename, onConfigure, onDelete, onRun }) {
1838
- const [editing, setEditing] = (0, import_react10.useState)(false);
1839
- const [name, setName] = (0, import_react10.useState)(col.name);
1840
- (0, import_react10.useEffect)(() => setName(col.name), [col.name]);
1841
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "shg-colhdr", children: [
1842
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "shg-colhdr-main", children: [
1843
- editing && !readOnly ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2247
+ const [editing, setEditing] = (0, import_react12.useState)(false);
2248
+ const [name, setName] = (0, import_react12.useState)(col.name);
2249
+ (0, import_react12.useEffect)(() => setName(col.name), [col.name]);
2250
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "shg-colhdr", children: [
2251
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "shg-colhdr-main", children: [
2252
+ editing && !readOnly ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1844
2253
  "input",
1845
2254
  {
1846
2255
  className: "shg-colname-input",
@@ -1855,17 +2264,17 @@ function ColumnHeader({ col, columns, readOnly, menuOpen, menuAnchor, onMenu, on
1855
2264
  if (e.key === "Enter") e.target.blur();
1856
2265
  }
1857
2266
  }
1858
- ) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "shg-colname", onDoubleClick: () => !readOnly && setEditing(true), title: col.name, children: col.name }),
1859
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "shg-coltype" + (col.type === "compute" ? " compute" : ""), children: [
2267
+ ) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "shg-colname", onDoubleClick: () => !readOnly && setEditing(true), title: col.name, children: col.name }),
2268
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "shg-coltype" + (col.type === "compute" ? " compute" : ""), children: [
1860
2269
  TYPE_LABEL[col.type] || col.type,
1861
2270
  col.type === "compute" && col.compute?.kind ? ` \xB7 ${col.compute.kind}` : ""
1862
2271
  ] })
1863
2272
  ] }),
1864
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "shg-colhdr-tools", children: [
1865
- onRun && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { className: "shg-colrun", onClick: onRun, title: "Run this column", children: "\u25B6 Run" }),
1866
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { className: "shg-colmenu-btn", onClick: (e) => onMenu(e), title: "Column settings", children: "\u22EF" })
2273
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "shg-colhdr-tools", children: [
2274
+ onRun && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "shg-colrun", onClick: onRun, title: "Run this column", children: "\u25B6 Run" }),
2275
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "shg-colmenu-btn", onClick: (e) => onMenu(e), title: "Column settings", children: "\u22EF" })
1867
2276
  ] }),
1868
- menuOpen && !readOnly && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2277
+ menuOpen && !readOnly && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1869
2278
  ColumnMenu,
1870
2279
  {
1871
2280
  col,
@@ -1882,19 +2291,19 @@ function ColumnHeader({ col, columns, readOnly, menuOpen, menuAnchor, onMenu, on
1882
2291
  ] });
1883
2292
  }
1884
2293
  function ColumnMenu({ col, columns, anchor, onApply, onDelete, onClose }) {
1885
- const [type, setType] = (0, import_react10.useState)(col.type || "text");
1886
- const [optText, setOptText] = (0, import_react10.useState)(
2294
+ const [type, setType] = (0, import_react12.useState)(col.type || "text");
2295
+ const [optText, setOptText] = (0, import_react12.useState)(
1887
2296
  normOptions(col.options).map((o) => o.label).join("\n")
1888
2297
  );
1889
2298
  const comp = col.compute || {};
1890
- const [kind, setKind] = (0, import_react10.useState)(comp.kind || "prompt");
1891
- const [prompt, setPrompt] = (0, import_react10.useState)(comp.prompt || "");
1892
- const [harnessId, setHarnessId] = (0, import_react10.useState)(comp.harness_id || "");
1893
- const [wfSlug, setWfSlug] = (0, import_react10.useState)(comp.workflow_slug || "");
1894
- const [outKey, setOutKey] = (0, import_react10.useState)(comp.output_key || "");
1895
- const [deps, setDeps] = (0, import_react10.useState)(new Set(comp.deps || []));
1896
- const ref = (0, import_react10.useRef)(null);
1897
- (0, import_react10.useEffect)(() => {
2299
+ const [kind, setKind] = (0, import_react12.useState)(comp.kind || "prompt");
2300
+ const [prompt, setPrompt] = (0, import_react12.useState)(comp.prompt || "");
2301
+ const [harnessId, setHarnessId] = (0, import_react12.useState)(comp.harness_id || "");
2302
+ const [wfSlug, setWfSlug] = (0, import_react12.useState)(comp.workflow_slug || "");
2303
+ const [outKey, setOutKey] = (0, import_react12.useState)(comp.output_key || "");
2304
+ const [deps, setDeps] = (0, import_react12.useState)(new Set(comp.deps || []));
2305
+ const ref = (0, import_react12.useRef)(null);
2306
+ (0, import_react12.useEffect)(() => {
1898
2307
  const onDown = (e) => {
1899
2308
  if (ref.current && !ref.current.contains(e.target)) onClose();
1900
2309
  };
@@ -1928,17 +2337,17 @@ function ColumnMenu({ col, columns, anchor, onApply, onDelete, onClose }) {
1928
2337
  }
1929
2338
  onApply(patch);
1930
2339
  };
1931
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PopPortal, { anchor, width: 250, estHeight: 340, className: "shg-menu", onClose, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { ref, onClick: (e) => e.stopPropagation(), children: [
1932
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("label", { className: "shg-menu-lbl", children: [
2340
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PopPortal, { anchor, width: 250, estHeight: 340, className: "shg-menu", onClose, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { ref, onClick: (e) => e.stopPropagation(), children: [
2341
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-lbl", children: [
1933
2342
  "Type",
1934
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("select", { className: "shg-menu-input", value: type, onChange: (e) => setType(e.target.value), children: [
1935
- MANUAL_TYPES.map((t) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: t, children: TYPE_LABEL[t] }, t)),
1936
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "compute", children: "Computed" })
2343
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("select", { className: "shg-menu-input", value: type, onChange: (e) => setType(e.target.value), children: [
2344
+ MANUAL_TYPES.map((t) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("option", { value: t, children: TYPE_LABEL[t] }, t)),
2345
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("option", { value: "compute", children: "Computed" })
1937
2346
  ] })
1938
2347
  ] }),
1939
- (type === "select" || type === "tags") && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("label", { className: "shg-menu-lbl", children: [
2348
+ (type === "select" || type === "tags") && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-lbl", children: [
1940
2349
  "Options (one per line)",
1941
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2350
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1942
2351
  "textarea",
1943
2352
  {
1944
2353
  className: "shg-menu-input",
@@ -1949,15 +2358,15 @@ function ColumnMenu({ col, columns, anchor, onApply, onDelete, onClose }) {
1949
2358
  }
1950
2359
  )
1951
2360
  ] }),
1952
- type === "compute" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
1953
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("label", { className: "shg-menu-lbl", children: [
2361
+ type === "compute" && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
2362
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-lbl", children: [
1954
2363
  "Runs",
1955
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("select", { className: "shg-menu-input", value: kind, onChange: (e) => setKind(e.target.value), children: COMPUTE_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: k.kind, children: k.label }, k.kind)) })
2364
+ /* @__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)) })
1956
2365
  ] }),
1957
- (kind === "prompt" || kind === "harness") && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("label", { className: "shg-menu-lbl", children: [
2366
+ (kind === "prompt" || kind === "harness") && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-lbl", children: [
1958
2367
  "Prompt \u2014 reference columns as ",
1959
2368
  "{{Name}}",
1960
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2369
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1961
2370
  "textarea",
1962
2371
  {
1963
2372
  className: "shg-menu-input",
@@ -1968,32 +2377,32 @@ function ColumnMenu({ col, columns, anchor, onApply, onDelete, onClose }) {
1968
2377
  }
1969
2378
  )
1970
2379
  ] }),
1971
- kind === "harness" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("label", { className: "shg-menu-lbl", children: [
2380
+ kind === "harness" && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-lbl", children: [
1972
2381
  "Agent id",
1973
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("input", { className: "shg-menu-input", value: harnessId, onChange: (e) => setHarnessId(e.target.value), placeholder: "chrn_\u2026" })
2382
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { className: "shg-menu-input", value: harnessId, onChange: (e) => setHarnessId(e.target.value), placeholder: "chrn_\u2026" })
1974
2383
  ] }),
1975
- kind === "workflow" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
1976
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("label", { className: "shg-menu-lbl", children: [
2384
+ kind === "workflow" && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
2385
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-lbl", children: [
1977
2386
  "Workflow id",
1978
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("input", { className: "shg-menu-input", value: wfSlug, onChange: (e) => setWfSlug(e.target.value), placeholder: "my-workflow" })
2387
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { className: "shg-menu-input", value: wfSlug, onChange: (e) => setWfSlug(e.target.value), placeholder: "my-workflow" })
1979
2388
  ] }),
1980
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("label", { className: "shg-menu-lbl", children: [
2389
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-lbl", children: [
1981
2390
  "Output key (optional)",
1982
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("input", { className: "shg-menu-input", value: outKey, onChange: (e) => setOutKey(e.target.value), placeholder: "summary" })
2391
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { className: "shg-menu-input", value: outKey, onChange: (e) => setOutKey(e.target.value), placeholder: "summary" })
1983
2392
  ] })
1984
2393
  ] }),
1985
- others.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "shg-menu-lbl", children: [
2394
+ others.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "shg-menu-lbl", children: [
1986
2395
  "Reads columns",
1987
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "shg-menu-deps", children: others.map((c) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("label", { className: "shg-menu-dep", children: [
1988
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("input", { type: "checkbox", checked: deps.has(c.id), onChange: () => toggleDep(c.id) }),
2396
+ /* @__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: [
2397
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { type: "checkbox", checked: deps.has(c.id), onChange: () => toggleDep(c.id) }),
1989
2398
  " ",
1990
2399
  c.name
1991
2400
  ] }, c.id)) })
1992
2401
  ] })
1993
2402
  ] }),
1994
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "shg-menu-actions", children: [
1995
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { className: "shg-menu-del", onClick: onDelete, children: "Delete column" }),
1996
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { className: "shg-menu-apply", onClick: apply, children: "Apply" })
2403
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "shg-menu-actions", children: [
2404
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "shg-menu-del", onClick: onDelete, children: "Delete column" }),
2405
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "shg-menu-apply", onClick: apply, children: "Apply" })
1997
2406
  ] })
1998
2407
  ] }) });
1999
2408
  }