@ai-matrx/records-ui 0.93.146 → 0.93.153

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/pickers.cjs CHANGED
@@ -42,15 +42,15 @@ __export(pickers_exports, {
42
42
  module.exports = __toCommonJS(pickers_exports);
43
43
 
44
44
  // src/TablePickers.tsx
45
- var import_react28 = require("react");
46
- var import_react29 = require("@ai-matrx/records/react");
47
- var import_design_system15 = require("@ai-matrx/design-system");
45
+ var import_react30 = require("react");
46
+ var import_react31 = require("@ai-matrx/records/react");
47
+ var import_design_system16 = require("@ai-matrx/design-system");
48
48
 
49
49
  // src/editors.tsx
50
- var import_react22 = require("react");
50
+ var import_react24 = require("react");
51
51
  var import_records10 = require("@ai-matrx/records");
52
- var import_react23 = require("@ai-matrx/records/react");
53
- var import_design_system13 = require("@ai-matrx/design-system");
52
+ var import_react25 = require("@ai-matrx/records/react");
53
+ var import_design_system14 = require("@ai-matrx/design-system");
54
54
 
55
55
  // src/dates.ts
56
56
  var import_field_formats = require("@ai-matrx/design-system/field-formats");
@@ -109,7 +109,7 @@ function newerKindValue(field, value, opts = {}) {
109
109
  }
110
110
  case "created_by":
111
111
  case "modified_by":
112
- return (0, import_records.isPersonStamp)(value) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PersonStampChip, { name: value.name }) : void 0;
112
+ return (0, import_records.isPersonStamp)(value) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PersonStampChip, { stamp: value }) : void 0;
113
113
  case "address":
114
114
  return (0, import_records.isAddressValue)(value) || typeof value === "string" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AddressLink, { value }) : void 0;
115
115
  case "barcode":
@@ -125,10 +125,12 @@ function newerKindValue(field, value, opts = {}) {
125
125
  return void 0;
126
126
  }
127
127
  }
128
- function PersonStampChip({ name }) {
129
- const words = name && name.trim() !== "" ? name : import_records.NOT_A_MEMBER_WORDS;
130
- const initial = name && name.trim() !== "" ? name.trim()[0].toUpperCase() : "?";
131
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "inline-flex min-w-0 items-center gap-1.5", "data-records-person-stamp": "", children: [
128
+ function PersonStampChip({ stamp }) {
129
+ const words = (0, import_records.personStampText)(stamp) ?? import_records.NOT_A_MEMBER_WORDS;
130
+ const tier = stamp.actor ?? "user";
131
+ const name = tier === "user" ? stamp.name : null;
132
+ const initial = tier === "system" ? "\u2699" : tier === "agent" ? "\u2726" : name && name.trim() !== "" ? name.trim()[0].toUpperCase() : "?";
133
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "inline-flex min-w-0 items-center gap-1.5", "data-records-person-stamp": tier, children: [
132
134
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
133
135
  "span",
134
136
  {
@@ -137,7 +139,7 @@ function PersonStampChip({ name }) {
137
139
  children: initial
138
140
  }
139
141
  ),
140
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: (0, import_design_system.cn)("truncate", name ? "" : "italic text-muted-foreground"), children: words })
142
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: (0, import_design_system.cn)("truncate", tier === "user" && !name ? "italic text-muted-foreground" : ""), children: words })
141
143
  ] });
142
144
  }
143
145
  function AddressLink({ value }) {
@@ -162,12 +164,13 @@ function AddressLink({ value }) {
162
164
  );
163
165
  }
164
166
  var STATUS_GROUP_MARK = { todo: "\u25CB", in_progress: "\u25D0", done: "\u25CF" };
165
- function statusMarkOf(field, value) {
167
+ function statusMarkOf(field, value, document2) {
166
168
  if ((0, import_records.newerKindOf)(field) !== "status" || typeof value !== "string") return null;
167
- const group = (0, import_records.statusGroupOf)(field, value);
169
+ const chosen = document2?.["_choices"]?.[field.key];
170
+ const key = chosen && typeof chosen === "object" && typeof chosen.key === "string" ? chosen.key : value;
171
+ const group = (0, import_records.statusGroupOf)(field, key);
168
172
  return { mark: STATUS_GROUP_MARK[group], group, words: import_records.STATUS_GROUP_WORDS[group] };
169
173
  }
170
- var SAFE_HREF = /^(https?:\/\/|mailto:)/i;
171
174
  function inline(text, key) {
172
175
  const out = [];
173
176
  let at = 0;
@@ -194,9 +197,9 @@ function marks(text, key) {
194
197
  if (tok.startsWith("**") || tok.startsWith("__")) out.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: tok.slice(2, -2) }, k));
195
198
  else if (tok.startsWith("[")) {
196
199
  const link = /^\[([^\]]+)\]\(([^)\s]+)\)$/.exec(tok);
197
- const href = link?.[2] ?? "";
200
+ const href = (0, import_records.safeLinkHref)(link?.[2] ?? "");
198
201
  out.push(
199
- SAFE_HREF.test(href) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href, target: "_blank", rel: "noopener noreferrer", className: "text-primary underline-offset-2 hover:underline", onClick: own, children: link?.[1] }, k) : link?.[1] ?? tok
202
+ href ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href, target: "_blank", rel: "noopener noreferrer", className: "text-primary underline-offset-2 hover:underline", onClick: own, children: link?.[1] }, k) : link?.[1] ?? tok
200
203
  );
201
204
  } else out.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("em", { children: tok.slice(1, -1) }, k));
202
205
  last = at + tok.length;
@@ -630,7 +633,12 @@ var TITLE = {
630
633
  already_exists: "That already exists",
631
634
  not_supported: "That cannot be done here",
632
635
  store_limit: "This has got as big as it can",
633
- store_not_served: "This organization does not keep its data here",
636
+ // 🚨 NOT "THE SWITCH IS OFF" (lane 7 W1 fix round 1). PGRST202 / PGRST205 land here, and the
637
+ // commonest cause is a door this screen asks for that the database it talks to does not serve
638
+ // YET — a release in flight. Telling the person her organization has its store switched off was
639
+ // false (the switch is answered by its own door, `platform.unified_data_store_on`). Honest:
640
+ // nothing happened, and it is ours, and it passes.
641
+ store_not_served: "This isn't available right now",
634
642
  unreachable: "We could not reach your data",
635
643
  needs_approval: "This is waiting on someone's approval",
636
644
  stale_read: "Your view of this is a moment behind",
@@ -648,7 +656,7 @@ var REMEDY = {
648
656
  already_exists: "Use a different name.",
649
657
  not_supported: "There is another way to do this \u2014 ask, and we will point you at it.",
650
658
  store_limit: "Split it up, or ask us to raise the ceiling for your organization.",
651
- store_not_served: "An administrator of this organization turns the record store on from the data settings screen.",
659
+ store_not_served: "Nothing was changed. Try again in a few minutes.",
652
660
  // 🚨 NOTHING WAS WRITTEN AND NOTHING WAS REFUSED (lane TAILS-6). The call
653
661
  // never arrived, so "try again" is the honest instruction rather than a
654
662
  // consolation — and saying nothing changed is the half a person actually
@@ -1147,8 +1155,8 @@ function RelationPicker({ field, value, onChange, disabled, id, className, allow
1147
1155
  }
1148
1156
 
1149
1157
  // src/gridAttachments.tsx
1150
- var import_react11 = require("react");
1151
- var import_react12 = require("@ai-matrx/records/react");
1158
+ var import_react12 = require("react");
1159
+ var import_react13 = require("@ai-matrx/records/react");
1152
1160
  var import_design_system7 = require("@ai-matrx/design-system");
1153
1161
 
1154
1162
  // src/host.tsx
@@ -1226,14 +1234,15 @@ function useRecordsUi() {
1226
1234
  }
1227
1235
 
1228
1236
  // src/labels.tsx
1229
- var import_react8 = require("react");
1230
- var import_react9 = require("@ai-matrx/records/react");
1237
+ var import_react9 = require("react");
1238
+ var import_react10 = require("@ai-matrx/records/react");
1231
1239
  var import_records5 = require("@ai-matrx/records");
1232
1240
  var import_uuid2 = require("@ai-matrx/kit/uuid");
1233
1241
 
1234
1242
  // src/signature.tsx
1235
1243
  var import_react7 = require("react");
1236
1244
  var import_design_system5 = require("@ai-matrx/design-system");
1245
+ var import_react8 = require("@ai-matrx/records/react");
1237
1246
  var import_jsx_runtime6 = require("react/jsx-runtime");
1238
1247
  var DRAWN = /^data:image\/(png|jpeg);base64,[A-Za-z0-9+/=]{64,}$/;
1239
1248
  function drawnSignatureOf(value) {
@@ -1244,18 +1253,105 @@ function signatureWords(value) {
1244
1253
  if (value === null || value === void 0 || value === "") return null;
1245
1254
  return drawnSignatureOf(value) ? SIGNED_WORD : String(value);
1246
1255
  }
1247
- function SignatureValue({ value, inCell }) {
1256
+ function signatureFileOf(source) {
1257
+ if (!source || typeof source !== "object") return null;
1258
+ const src = source;
1259
+ const id = src["signature_file_id"];
1260
+ return src["kind"] === "signature" && typeof id === "string" && id !== "" ? id : null;
1261
+ }
1262
+ function signatureFileIn(document2, key) {
1263
+ const values = document2?.["_values"];
1264
+ const src = values?.[key]?.src;
1265
+ if (typeof src === "string") {
1266
+ const sources = document2?.["_sources"];
1267
+ return signatureFileOf(sources?.[src]);
1268
+ }
1269
+ return signatureFileOf(src);
1270
+ }
1271
+ var SOURCES = /* @__PURE__ */ new WeakMap();
1272
+ var FILES = /* @__PURE__ */ new WeakMap();
1273
+ function signatureFilesOf(client, recordId) {
1274
+ let held = SOURCES.get(client);
1275
+ if (!held) SOURCES.set(client, held = /* @__PURE__ */ new Map());
1276
+ let asked2 = held.get(recordId);
1277
+ if (!asked2) {
1278
+ asked2 = client.recordValuesVersioned({ record_id: recordId }).then((answered) => {
1279
+ if (!answered.ok) return {};
1280
+ return Object.fromEntries(answered.data.map((v) => [v.field_key, signatureFileOf(v.source)]));
1281
+ });
1282
+ held.set(recordId, asked2);
1283
+ }
1284
+ return asked2;
1285
+ }
1286
+ function drawingOf(client, fileId) {
1287
+ let held = FILES.get(client);
1288
+ if (!held) FILES.set(client, held = /* @__PURE__ */ new Map());
1289
+ let asked2 = held.get(fileId);
1290
+ if (!asked2) {
1291
+ asked2 = client.recordRead({ record_id: fileId }).then((answered) => {
1292
+ if (!answered.ok) return { src: null, hostFileId: null };
1293
+ const doc = answered.data.document ?? {};
1294
+ const content = drawnSignatureOf(doc["content"]);
1295
+ const hostFileId = typeof doc["file_id"] === "string" && doc["file_id"] !== "" ? doc["file_id"] : null;
1296
+ return { src: content, hostFileId };
1297
+ });
1298
+ held.set(fileId, asked2);
1299
+ }
1300
+ return asked2;
1301
+ }
1302
+ function DrawnImage({ src, inCell }) {
1303
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1304
+ "img",
1305
+ {
1306
+ src,
1307
+ alt: SIGNED_WORD,
1308
+ "data-records-signature": "",
1309
+ className: (0, import_design_system5.cn)("max-w-[12rem] object-contain object-left dark:invert", inCell ? "h-7" : "h-12")
1310
+ }
1311
+ );
1312
+ }
1313
+ function SignatureDrawing({
1314
+ recordId,
1315
+ fieldKey,
1316
+ fileId: knownFile,
1317
+ value,
1318
+ inCell
1319
+ }) {
1320
+ const client = (0, import_react8.useOptionalRecordsClient)();
1321
+ const host = useRecordsUi();
1322
+ const [drawing, setDrawing] = (0, import_react7.useState)(null);
1323
+ (0, import_react7.useEffect)(() => {
1324
+ let cancelled = false;
1325
+ setDrawing(null);
1326
+ if (!client) return;
1327
+ void (async () => {
1328
+ const fileId = knownFile ?? (recordId && fieldKey ? (await signatureFilesOf(client, recordId))[fieldKey] ?? null : null);
1329
+ if (!fileId || cancelled) return;
1330
+ const read = await drawingOf(client, fileId);
1331
+ if (!cancelled) setDrawing(read);
1332
+ })();
1333
+ return () => {
1334
+ cancelled = true;
1335
+ };
1336
+ }, [client, recordId, fieldKey, knownFile]);
1337
+ if (drawing?.src) return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DrawnImage, { src: drawing.src, inCell });
1338
+ if (drawing?.hostFileId && host.fileImage) {
1339
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: (0, import_design_system5.cn)("inline-block max-w-[12rem] dark:invert", inCell ? "h-7" : "h-12"), "data-records-signature": "", children: host.fileImage({ fileId: drawing.hostFileId, alt: SIGNED_WORD }) });
1340
+ }
1341
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "font-serif italic", children: String(value) });
1342
+ }
1343
+ function SignatureValue({
1344
+ value,
1345
+ inCell,
1346
+ recordId,
1347
+ fieldKey,
1348
+ document: document2
1349
+ }) {
1248
1350
  const drawn = drawnSignatureOf(value);
1249
- if (drawn) {
1250
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1251
- "img",
1252
- {
1253
- src: drawn,
1254
- alt: SIGNED_WORD,
1255
- "data-records-signature": "",
1256
- className: (0, import_design_system5.cn)("max-w-[12rem] object-contain object-left dark:invert", inCell ? "h-7" : "h-12")
1257
- }
1258
- );
1351
+ if (drawn) return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DrawnImage, { src: drawn, inCell });
1352
+ const fileId = fieldKey ? signatureFileIn(document2, fieldKey) : null;
1353
+ if (value === SIGNED_WORD && (fileId || recordId && fieldKey)) {
1354
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SignatureDrawing, { recordId: recordId ?? null, fieldKey: fieldKey ?? null, fileId, value, inCell });
1259
1355
  }
1260
1356
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "font-serif italic", children: String(value) });
1261
1357
  }
@@ -1415,7 +1511,7 @@ function encodeAt(canvas, type, maxWidth, quality) {
1415
1511
 
1416
1512
  // src/labels.tsx
1417
1513
  var import_jsx_runtime7 = require("react/jsx-runtime");
1418
- var LabelContext = (0, import_react8.createContext)({
1514
+ var LabelContext = (0, import_react9.createContext)({
1419
1515
  // With no provider the resolver is ABSENT, not silently empty: a caller gets
1420
1516
  // null and says "Loading…" forever, which is visible. The mount always
1421
1517
  // provides one, so this is only ever a bare unit test.
@@ -1443,15 +1539,15 @@ function pointsAtRecords(field) {
1443
1539
  return field.type === "list" || field.type === "relation";
1444
1540
  }
1445
1541
  function RecordLabelProvider({ children }) {
1446
- const client = (0, import_react9.useRecordsClient)();
1447
- const [names, setNames] = (0, import_react8.useState)({});
1448
- const [archivedRefs, setArchivedRefs] = (0, import_react8.useState)({});
1449
- const [settled, setSettled] = (0, import_react8.useState)({});
1450
- const [waitingLines, setWaitingLines] = (0, import_react8.useState)({});
1451
- const asked2 = (0, import_react8.useRef)(/* @__PURE__ */ new Set());
1452
- const chased = (0, import_react8.useRef)(/* @__PURE__ */ new Set());
1453
- const timers = (0, import_react8.useRef)(/* @__PURE__ */ new Map());
1454
- const startWaitClock = (0, import_react8.useCallback)((field, target) => {
1542
+ const client = (0, import_react10.useRecordsClient)();
1543
+ const [names, setNames] = (0, import_react9.useState)({});
1544
+ const [archivedRefs, setArchivedRefs] = (0, import_react9.useState)({});
1545
+ const [settled, setSettled] = (0, import_react9.useState)({});
1546
+ const [waitingLines, setWaitingLines] = (0, import_react9.useState)({});
1547
+ const asked2 = (0, import_react9.useRef)(/* @__PURE__ */ new Set());
1548
+ const chased = (0, import_react9.useRef)(/* @__PURE__ */ new Set());
1549
+ const timers = (0, import_react9.useRef)(/* @__PURE__ */ new Map());
1550
+ const startWaitClock = (0, import_react9.useCallback)((field, target) => {
1455
1551
  if (timers.current.has(field.id)) return;
1456
1552
  timers.current.set(
1457
1553
  field.id,
@@ -1463,7 +1559,7 @@ function RecordLabelProvider({ children }) {
1463
1559
  }, SAY_WHAT_YOU_ARE_WAITING_FOR_AFTER_MS)
1464
1560
  );
1465
1561
  }, []);
1466
- const stopWaitClock = (0, import_react8.useCallback)((fieldId) => {
1562
+ const stopWaitClock = (0, import_react9.useCallback)((fieldId) => {
1467
1563
  const timer = timers.current.get(fieldId);
1468
1564
  if (timer) {
1469
1565
  clearTimeout(timer);
@@ -1476,14 +1572,14 @@ function RecordLabelProvider({ children }) {
1476
1572
  return next;
1477
1573
  });
1478
1574
  }, []);
1479
- (0, import_react8.useEffect)(
1575
+ (0, import_react9.useEffect)(
1480
1576
  () => () => {
1481
1577
  for (const timer of timers.current.values()) clearTimeout(timer);
1482
1578
  timers.current.clear();
1483
1579
  },
1484
1580
  []
1485
1581
  );
1486
- const want = (0, import_react8.useCallback)(
1582
+ const want = (0, import_react9.useCallback)(
1487
1583
  (field) => {
1488
1584
  if (!pointsAtRecords(field)) return;
1489
1585
  if (asked2.current.has(field.id)) return;
@@ -1518,9 +1614,9 @@ function RecordLabelProvider({ children }) {
1518
1614
  },
1519
1615
  [client, startWaitClock, stopWaitClock]
1520
1616
  );
1521
- const queued = (0, import_react8.useRef)(/* @__PURE__ */ new Map());
1522
- const flushing = (0, import_react8.useRef)(null);
1523
- const flush = (0, import_react8.useCallback)(() => {
1617
+ const queued = (0, import_react9.useRef)(/* @__PURE__ */ new Map());
1618
+ const flushing = (0, import_react9.useRef)(null);
1619
+ const flush = (0, import_react9.useCallback)(() => {
1524
1620
  flushing.current = null;
1525
1621
  const batch = [...queued.current.values()];
1526
1622
  queued.current.clear();
@@ -1547,7 +1643,7 @@ function RecordLabelProvider({ children }) {
1547
1643
  for (const { field } of batch) stopWaitClock(field.id);
1548
1644
  })();
1549
1645
  }, [client, stopWaitClock]);
1550
- const chase = (0, import_react8.useCallback)(
1646
+ const chase = (0, import_react9.useCallback)(
1551
1647
  (field, id) => {
1552
1648
  const key = `${field.id}:${id}`;
1553
1649
  if (chased.current.has(key)) return;
@@ -1560,14 +1656,14 @@ function RecordLabelProvider({ children }) {
1560
1656
  },
1561
1657
  [flush, startWaitClock]
1562
1658
  );
1563
- (0, import_react8.useEffect)(
1659
+ (0, import_react9.useEffect)(
1564
1660
  () => () => {
1565
1661
  if (flushing.current !== null) clearTimeout(flushing.current);
1566
1662
  },
1567
1663
  []
1568
1664
  );
1569
- const rereadFor = (0, import_react8.useRef)(/* @__PURE__ */ new Set());
1570
- const lookupWords = (0, import_react8.useCallback)(
1665
+ const rereadFor = (0, import_react9.useRef)(/* @__PURE__ */ new Set());
1666
+ const lookupWords = (0, import_react9.useCallback)(
1571
1667
  (field, id) => {
1572
1668
  if (field.type === "list" && !isId(id)) {
1573
1669
  const named = names[choiceKeyName(field.id, id)];
@@ -1587,7 +1683,7 @@ function RecordLabelProvider({ children }) {
1587
1683
  },
1588
1684
  [names, settled, chase, want]
1589
1685
  );
1590
- const lookup = (0, import_react8.useMemo)(
1686
+ const lookup = (0, import_react9.useMemo)(
1591
1687
  () => {
1592
1688
  const answer = ((field, id) => lookupWords(field, id));
1593
1689
  answer.archived = (field, id) => archivedRefs[`${field.id}:${id}`] === true;
@@ -1595,20 +1691,20 @@ function RecordLabelProvider({ children }) {
1595
1691
  },
1596
1692
  [lookupWords, archivedRefs]
1597
1693
  );
1598
- const waiting = (0, import_react8.useCallback)((field) => waitingLines[field.id] ?? null, [waitingLines]);
1599
- const value = (0, import_react8.useMemo)(() => ({ lookup, want, waiting }), [lookup, want, waiting]);
1694
+ const waiting = (0, import_react9.useCallback)((field) => waitingLines[field.id] ?? null, [waitingLines]);
1695
+ const value = (0, import_react9.useMemo)(() => ({ lookup, want, waiting }), [lookup, want, waiting]);
1600
1696
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(LabelContext.Provider, { value, children });
1601
1697
  }
1602
1698
  function useRecordLabels(fields) {
1603
- const { lookup, want } = (0, import_react8.useContext)(LabelContext);
1604
- (0, import_react8.useEffect)(() => {
1699
+ const { lookup, want } = (0, import_react9.useContext)(LabelContext);
1700
+ (0, import_react9.useEffect)(() => {
1605
1701
  for (const field of fields ?? []) want(field);
1606
1702
  }, [fields, want]);
1607
1703
  return lookup;
1608
1704
  }
1609
1705
 
1610
1706
  // src/FilePicker.tsx
1611
- var import_react10 = require("react");
1707
+ var import_react11 = require("react");
1612
1708
  var import_design_system6 = require("@ai-matrx/design-system");
1613
1709
  var import_jsx_runtime8 = require("react/jsx-runtime");
1614
1710
  function FilePicker({
@@ -1622,17 +1718,17 @@ function FilePicker({
1622
1718
  chosenName,
1623
1719
  className
1624
1720
  }) {
1625
- const inputId = (0, import_react10.useId)();
1626
- const input = (0, import_react10.useRef)(null);
1627
- const [over, setOver] = (0, import_react10.useState)(false);
1628
- const take = (0, import_react10.useCallback)(
1721
+ const inputId = (0, import_react11.useId)();
1722
+ const input = (0, import_react11.useRef)(null);
1723
+ const [over, setOver] = (0, import_react11.useState)(false);
1724
+ const take = (0, import_react11.useCallback)(
1629
1725
  (file) => {
1630
1726
  if (!file || disabled) return;
1631
1727
  onFile(file);
1632
1728
  },
1633
1729
  [disabled, onFile]
1634
1730
  );
1635
- const onDrop = (0, import_react10.useCallback)(
1731
+ const onDrop = (0, import_react11.useCallback)(
1636
1732
  (e) => {
1637
1733
  e.preventDefault();
1638
1734
  setOver(false);
@@ -1725,10 +1821,10 @@ function rememberHostFileIds(ids) {
1725
1821
  var FILE_CHIP_UNREAD = "File";
1726
1822
  var FILE_CHIP_NO_PAGE = "This screen has no way to open files yet.";
1727
1823
  function AttachmentChip({ id, onRemove }) {
1728
- const client = (0, import_react12.useOptionalRecordsClient)();
1824
+ const client = (0, import_react13.useOptionalRecordsClient)();
1729
1825
  const host = useRecordsUi();
1730
- const [read, setRead] = (0, import_react11.useState)(null);
1731
- (0, import_react11.useEffect)(() => {
1826
+ const [read, setRead] = (0, import_react12.useState)(null);
1827
+ (0, import_react12.useEffect)(() => {
1732
1828
  let cancelled = false;
1733
1829
  if (!client) {
1734
1830
  setRead({ name: null, fileId: null, why: null });
@@ -1803,9 +1899,9 @@ function AttachmentControl({
1803
1899
  onClose
1804
1900
  }) {
1805
1901
  const host = useRecordsUi();
1806
- const [busy, setBusy] = (0, import_react11.useState)(false);
1807
- const [why, setWhy] = (0, import_react11.useState)(null);
1808
- const latest = (0, import_react11.useRef)(value);
1902
+ const [busy, setBusy] = (0, import_react12.useState)(false);
1903
+ const [why, setWhy] = (0, import_react12.useState)(null);
1904
+ const latest = (0, import_react12.useRef)(value);
1809
1905
  latest.current = value;
1810
1906
  const multiple = Boolean(field.multi);
1811
1907
  const pick = async () => {
@@ -1826,8 +1922,8 @@ function AttachmentControl({
1826
1922
  setBusy(false);
1827
1923
  onClose?.();
1828
1924
  };
1829
- const opened = (0, import_react11.useRef)(false);
1830
- (0, import_react11.useEffect)(() => {
1925
+ const opened = (0, import_react12.useRef)(false);
1926
+ (0, import_react12.useEffect)(() => {
1831
1927
  if (!autoOpen || opened.current || !host.pickFiles) return;
1832
1928
  opened.current = true;
1833
1929
  void pick();
@@ -1870,11 +1966,99 @@ function AttachmentControl({
1870
1966
  }
1871
1967
 
1872
1968
  // src/EntityReferenceControl.tsx
1873
- var import_react13 = require("react");
1969
+ var import_react15 = require("react");
1874
1970
  var import_records6 = require("@ai-matrx/records");
1875
- var import_react14 = require("@ai-matrx/records/react");
1971
+ var import_react16 = require("@ai-matrx/records/react");
1972
+ var import_design_system9 = require("@ai-matrx/design-system");
1973
+
1974
+ // src/PickOne.tsx
1975
+ var import_react14 = require("react");
1876
1976
  var import_design_system8 = require("@ai-matrx/design-system");
1877
1977
  var import_jsx_runtime10 = require("react/jsx-runtime");
1978
+ var PICK_ONE_SEARCH_AFTER = 7;
1979
+ var EMPTY = "__records_pick_one_empty__";
1980
+ var inner = (v) => v === "" ? EMPTY : v;
1981
+ var outer = (v) => v === EMPTY ? "" : v;
1982
+ function PickOne({
1983
+ value,
1984
+ onChange,
1985
+ options,
1986
+ label,
1987
+ placeholder,
1988
+ id,
1989
+ className,
1990
+ disabled,
1991
+ attrs
1992
+ }) {
1993
+ const [open, setOpen] = (0, import_react14.useState)(false);
1994
+ const [search, setSearch] = (0, import_react14.useState)("");
1995
+ const current = options.find((o) => o.value === value);
1996
+ if (options.length > PICK_ONE_SEARCH_AFTER) {
1997
+ const q = search.trim().toLowerCase();
1998
+ const shown2 = q === "" ? options : options.filter((o) => o.label.toLowerCase().includes(q));
1999
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: (0, import_design_system8.cn)("inline-flex min-w-0", className), "data-records-pick-one": "search", "data-pick-value": value, ...attrs ?? {}, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2000
+ PickOrAdd,
2001
+ {
2002
+ triggerLabel: label,
2003
+ triggerText: current?.label ?? placeholder ?? "",
2004
+ triggerId: id,
2005
+ open: open && !disabled,
2006
+ onOpenChange: (next) => {
2007
+ setOpen(next);
2008
+ if (!next) setSearch("");
2009
+ },
2010
+ search,
2011
+ onSearch: setSearch,
2012
+ items: shown2.map((o) => ({
2013
+ id: inner(o.value),
2014
+ label: o.label,
2015
+ detail: o.group,
2016
+ picked: o.value === value,
2017
+ attrs: { "data-pick-value": o.value, ...o.group ? { "data-pick-group": o.group } : {} }
2018
+ })),
2019
+ onPick: (picked) => {
2020
+ onChange(outer(picked));
2021
+ setOpen(false);
2022
+ setSearch("");
2023
+ },
2024
+ empty: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "p-2 text-xs text-muted-foreground", children: "No match" })
2025
+ }
2026
+ ) });
2027
+ }
2028
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_design_system8.Select, { value: current ? inner(current.value) : "", onValueChange: (v) => onChange(outer(v)), disabled: disabled ?? false, children: [
2029
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2030
+ import_design_system8.SelectTrigger,
2031
+ {
2032
+ id,
2033
+ size: "sm",
2034
+ "aria-label": label,
2035
+ className: (0, import_design_system8.cn)("h-7 w-auto min-w-[7rem] text-xs", className),
2036
+ "data-records-pick-one": "list",
2037
+ "data-pick-value": value,
2038
+ ...attrs ?? {},
2039
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_design_system8.SelectValue, { placeholder })
2040
+ }
2041
+ ),
2042
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_design_system8.SelectContent, { children: groupsOf(options).map(
2043
+ ([group, items]) => group ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_design_system8.SelectGroup, { children: [
2044
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_design_system8.SelectLabel, { children: group }),
2045
+ items.map((o) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_design_system8.SelectItem, { value: inner(o.value), "data-pick-value": o.value, "data-pick-group": group, children: o.label }, inner(o.value)))
2046
+ ] }, group) : items.map((o) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_design_system8.SelectItem, { value: inner(o.value), "data-pick-value": o.value, children: o.label }, inner(o.value)))
2047
+ ) })
2048
+ ] });
2049
+ }
2050
+ function groupsOf(options) {
2051
+ const out = [];
2052
+ for (const o of options) {
2053
+ const last = out[out.length - 1];
2054
+ if (last && last[0] === o.group) last[1].push(o);
2055
+ else out.push([o.group, [o]]);
2056
+ }
2057
+ return out;
2058
+ }
2059
+
2060
+ // src/EntityReferenceControl.tsx
2061
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1878
2062
  var WITHHELD_ENTITY_LABEL = "Something you have not been given access to";
1879
2063
  var ENTITY_REFERENCE_EMPTY = "Nothing is pointed at yet.";
1880
2064
  function entityReferenceText(value) {
@@ -1888,20 +2072,20 @@ function allowedKindsOf(field) {
1888
2072
  return kinds.map((k) => String(k).trim().toLowerCase()).filter(Boolean);
1889
2073
  }
1890
2074
  function EntityReferenceControl(props) {
1891
- const client = (0, import_react14.useOptionalRecordsClient)();
1892
- return client ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(WithWords, { ...props }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Chips, { ...props, words: null, picker: null });
2075
+ const client = (0, import_react16.useOptionalRecordsClient)();
2076
+ return client ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(WithWords, { ...props }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Chips, { ...props, words: null, picker: null });
1893
2077
  }
1894
2078
  function WithWords(props) {
1895
- const refs = (0, import_react13.useMemo)(() => (0, import_records6.entityRefsOf)(props.value), [props.value]);
1896
- const [known, setKnown] = (0, import_react13.useState)([]);
2079
+ const refs = (0, import_react15.useMemo)(() => (0, import_records6.entityRefsOf)(props.value), [props.value]);
2080
+ const [known, setKnown] = (0, import_react15.useState)([]);
1897
2081
  const withKnown = refs.map((r) => r.label === null ? known.find((k) => k.token === r.token && k.id === r.id) ?? r : r);
1898
- const unlabelled = (0, import_react13.useMemo)(
2082
+ const unlabelled = (0, import_react15.useMemo)(
1899
2083
  () => withKnown.filter((r) => r.label === null).map((r) => ({ token: r.token, id: r.id })),
1900
2084
  // eslint-disable-next-line react-hooks/exhaustive-deps
1901
2085
  [JSON.stringify(withKnown)]
1902
2086
  );
1903
- const words = (0, import_react14.useEntityReferenceWords)(unlabelled);
1904
- const picker = props.disabled ? null : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2087
+ const words = (0, import_react16.useEntityReferenceWords)(unlabelled);
2088
+ const picker = props.disabled ? null : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1905
2089
  EntityReferencePicker,
1906
2090
  {
1907
2091
  field: props.field,
@@ -1914,7 +2098,7 @@ function WithWords(props) {
1914
2098
  }
1915
2099
  }
1916
2100
  );
1917
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Chips, { ...props, value: withKnown, words, picker });
2101
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Chips, { ...props, value: withKnown, words, picker });
1918
2102
  }
1919
2103
  function EntityReferencePicker({
1920
2104
  field,
@@ -1922,13 +2106,13 @@ function EntityReferencePicker({
1922
2106
  onPick
1923
2107
  }) {
1924
2108
  const allowed = allowedKindsOf(field);
1925
- const kinds = (0, import_react14.useEntityReferenceKinds)();
2109
+ const kinds = (0, import_react16.useEntityReferenceKinds)();
1926
2110
  const labelOfKind = (token) => kinds.data?.find((k) => k.token === token)?.label ?? token.replace(/_/g, " ");
1927
- const [open, setOpen] = (0, import_react13.useState)(false);
1928
- const [search, setSearch] = (0, import_react13.useState)("");
1929
- const [only, setOnly] = (0, import_react13.useState)(null);
2111
+ const [open, setOpen] = (0, import_react15.useState)(false);
2112
+ const [search, setSearch] = (0, import_react15.useState)("");
2113
+ const [only, setOnly] = (0, import_react15.useState)(null);
1930
2114
  const tokens = only ? [only] : allowed;
1931
- const found = (0, import_react14.useEntityReferenceSearch)(tokens, search, open);
2115
+ const found = (0, import_react16.useEntityReferenceSearch)(tokens, search, open);
1932
2116
  const multi = Boolean(field.multi);
1933
2117
  const items = (found.data ?? []).map((r) => ({
1934
2118
  id: `${r.token}:${r.id}`,
@@ -1937,8 +2121,8 @@ function EntityReferencePicker({
1937
2121
  picked: refs.some((x) => x.token === r.token && x.id === r.id),
1938
2122
  attrs: { "data-entity-reference-candidate": `${r.token}:${r.id}` }
1939
2123
  }));
1940
- const kindChoice = allowed.length > 1 ? allowed.length <= 4 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "mb-1 flex flex-wrap gap-1", role: "group", "aria-label": `Which kind \u2014 ${field.label}`, children: [null, ...allowed].map((token) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1941
- import_design_system8.Button,
2124
+ const kindChoice = allowed.length > 1 ? allowed.length <= 4 ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "mb-1 flex flex-wrap gap-1", role: "group", "aria-label": `Which kind \u2014 ${field.label}`, children: [null, ...allowed].map((token) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2125
+ import_design_system9.Button,
1942
2126
  {
1943
2127
  type: "button",
1944
2128
  size: "sm",
@@ -1949,26 +2133,23 @@ function EntityReferencePicker({
1949
2133
  children: token ? labelOfKind(token) : "Any"
1950
2134
  },
1951
2135
  token ?? "any"
1952
- )) }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1953
- "select",
2136
+ )) }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2137
+ PickOne,
1954
2138
  {
1955
- className: "mb-1 h-7 w-full rounded border border-border bg-background px-1 text-xs",
1956
- "aria-label": `Which kind \u2014 ${field.label}`,
2139
+ label: `Which kind \u2014 ${field.label}`,
2140
+ className: "mb-1 w-full",
1957
2141
  value: only ?? "",
1958
- onChange: (e) => setOnly(e.target.value || null),
1959
- children: [
1960
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("option", { value: "", children: "Any kind" }),
1961
- allowed.map((token) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("option", { value: token, children: labelOfKind(token) }, token))
1962
- ]
2142
+ onChange: (picked) => setOnly(picked || null),
2143
+ options: [{ value: "", label: "Any kind" }, ...allowed.map((token) => ({ value: token, label: labelOfKind(token) }))]
1963
2144
  }
1964
2145
  ) : null;
1965
- const notice = /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
2146
+ const notice = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
1966
2147
  kindChoice,
1967
- found.error ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(RefusalLine, { error: found.error, className: "px-2 py-1 text-[11px]" }) : null,
1968
- found.loading && !found.data ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "px-2 py-1 text-[11px] text-muted-foreground", children: "Searching\u2026" }) : null
2148
+ found.error ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(RefusalLine, { error: found.error, className: "px-2 py-1 text-[11px]" }) : null,
2149
+ found.loading && !found.data ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "px-2 py-1 text-[11px] text-muted-foreground", children: "Searching\u2026" }) : null
1969
2150
  ] });
1970
2151
  const kindWords = allowed.length === 1 ? labelOfKind(allowed[0]).toLowerCase() : "thing";
1971
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2152
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1972
2153
  PickOrAdd,
1973
2154
  {
1974
2155
  triggerLabel: `Pick for ${field.label}`,
@@ -1982,7 +2163,7 @@ function EntityReferencePicker({
1982
2163
  onSearch: setSearch,
1983
2164
  items,
1984
2165
  notice,
1985
- empty: found.loading ? null : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "px-2 py-1 text-[11px] text-muted-foreground", children: search.trim() ? `No ${kindWords} you can open is called \u201C${search.trim()}\u201D.` : `There is no ${kindWords} you can open yet.` }),
2166
+ empty: found.loading ? null : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "px-2 py-1 text-[11px] text-muted-foreground", children: search.trim() ? `No ${kindWords} you can open is called \u201C${search.trim()}\u201D.` : `There is no ${kindWords} you can open yet.` }),
1986
2167
  onPick: (key) => {
1987
2168
  const r = (found.data ?? []).find((x) => `${x.token}:${x.id}` === key);
1988
2169
  if (!r) return;
@@ -2002,7 +2183,7 @@ function Chips({
2002
2183
  words,
2003
2184
  picker
2004
2185
  }) {
2005
- const refs = (0, import_react13.useMemo)(() => (0, import_records6.entityRefsOf)(value), [value]);
2186
+ const refs = (0, import_react15.useMemo)(() => (0, import_records6.entityRefsOf)(value), [value]);
2006
2187
  const labelOf = (token, refId, own3) => {
2007
2188
  if (own3) return own3;
2008
2189
  const read = words?.data?.find((w) => w.token === token && w.id === refId)?.label;
@@ -2012,13 +2193,13 @@ function Chips({
2012
2193
  return WITHHELD_ENTITY_LABEL;
2013
2194
  };
2014
2195
  const multi = Boolean(field.multi);
2015
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { id, className: (0, import_design_system8.cn)("flex flex-wrap items-center gap-1", className), "aria-label": `What ${field.label} points at`, children: [
2016
- refs.length === 0 && !picker ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "text-[11px] text-muted-foreground", children: ENTITY_REFERENCE_EMPTY }) : null,
2196
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { id, className: (0, import_design_system9.cn)("flex flex-wrap items-center gap-1", className), "aria-label": `What ${field.label} points at`, children: [
2197
+ refs.length === 0 && !picker ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "text-[11px] text-muted-foreground", children: ENTITY_REFERENCE_EMPTY }) : null,
2017
2198
  refs.map((r) => {
2018
2199
  const label = labelOf(r.token, r.id, r.label);
2019
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_design_system8.Badge, { variant: "secondary", className: "gap-1 text-[11px]", "data-entity-reference-chip": `${r.token}:${r.id}`, children: [
2200
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_design_system9.Badge, { variant: "secondary", className: "gap-1 text-[11px]", "data-entity-reference-chip": `${r.token}:${r.id}`, children: [
2020
2201
  label,
2021
- disabled ? null : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2202
+ disabled ? null : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2022
2203
  "button",
2023
2204
  {
2024
2205
  type: "button",
@@ -2038,11 +2219,11 @@ function Chips({
2038
2219
  }
2039
2220
 
2040
2221
  // src/PersonPicker.tsx
2041
- var import_react15 = require("react");
2222
+ var import_react17 = require("react");
2042
2223
  var import_records7 = require("@ai-matrx/records");
2043
- var import_react16 = require("@ai-matrx/records/react");
2044
- var import_design_system9 = require("@ai-matrx/design-system");
2045
- var import_jsx_runtime11 = require("react/jsx-runtime");
2224
+ var import_react18 = require("@ai-matrx/records/react");
2225
+ var import_design_system10 = require("@ai-matrx/design-system");
2226
+ var import_jsx_runtime12 = require("react/jsx-runtime");
2046
2227
  function personFromRow(row) {
2047
2228
  const data = row.document ?? {};
2048
2229
  const userId = data["user_id"];
@@ -2073,27 +2254,27 @@ async function personRecordForMember(client, personTableId, people, member) {
2073
2254
  return written;
2074
2255
  }
2075
2256
  function PersonPicker({ field, value, onChange, disabled, id, className, autoOpen, onClose, initialSearch }) {
2076
- const client = (0, import_react16.useOptionalRecordsClient)();
2257
+ const client = (0, import_react18.useOptionalRecordsClient)();
2077
2258
  const host = useRecordsUi();
2078
- const [members, setMembers] = (0, import_react15.useState)(null);
2079
- const [people, setPeople] = (0, import_react15.useState)([]);
2080
- const [error, setError] = (0, import_react15.useState)(null);
2081
- const [search, setSearch] = (0, import_react15.useState)(initialSearch ?? "");
2082
- const [open, setOpenState] = (0, import_react15.useState)(autoOpen === true);
2083
- const onCloseRef = (0, import_react15.useRef)(onClose);
2259
+ const [members, setMembers] = (0, import_react17.useState)(null);
2260
+ const [people, setPeople] = (0, import_react17.useState)([]);
2261
+ const [error, setError] = (0, import_react17.useState)(null);
2262
+ const [search, setSearch] = (0, import_react17.useState)(initialSearch ?? "");
2263
+ const [open, setOpenState] = (0, import_react17.useState)(autoOpen === true);
2264
+ const onCloseRef = (0, import_react17.useRef)(onClose);
2084
2265
  onCloseRef.current = onClose;
2085
- const setOpen = (0, import_react15.useCallback)((next) => {
2266
+ const setOpen = (0, import_react17.useCallback)((next) => {
2086
2267
  setOpenState(next);
2087
2268
  if (!next) onCloseRef.current?.();
2088
2269
  }, []);
2089
- const [busy, setBusy] = (0, import_react15.useState)(false);
2270
+ const [busy, setBusy] = (0, import_react17.useState)(false);
2090
2271
  const membersPort = host.members;
2091
2272
  const personTable = field.relation_target;
2092
- const picked = (0, import_react15.useMemo)(
2273
+ const picked = (0, import_react17.useMemo)(
2093
2274
  () => Array.isArray(value) ? value.map(String) : value === null || value === void 0 ? [] : [String(value)],
2094
2275
  [value]
2095
2276
  );
2096
- const load = (0, import_react15.useCallback)(async () => {
2277
+ const load = (0, import_react17.useCallback)(async () => {
2097
2278
  if (!membersPort || !client) return;
2098
2279
  const [roster, records] = await Promise.all([
2099
2280
  membersPort(),
@@ -2106,11 +2287,11 @@ function PersonPicker({ field, value, onChange, disabled, id, className, autoOpe
2106
2287
  }
2107
2288
  setPeople(records ? records.data.rows.map(personFromRow).filter((p) => p.userId !== null) : []);
2108
2289
  }, [membersPort, client, personTable]);
2109
- (0, import_react15.useEffect)(() => {
2290
+ (0, import_react17.useEffect)(() => {
2110
2291
  if (!open) return;
2111
2292
  void load();
2112
2293
  }, [open, load]);
2113
- (0, import_react15.useEffect)(() => {
2294
+ (0, import_react17.useEffect)(() => {
2114
2295
  if (picked.length === 0 || !personTable || people.length > 0 || !client) return;
2115
2296
  let cancelled = false;
2116
2297
  void client.list({ table_id: personTable, limit: 500 }).then((result) => {
@@ -2131,12 +2312,12 @@ function PersonPicker({ field, value, onChange, disabled, id, className, autoOpe
2131
2312
  },
2132
2313
  onClose: () => setOpen(false)
2133
2314
  });
2134
- const pickRef = (0, import_react15.useRef)(null);
2315
+ const pickRef = (0, import_react17.useRef)(null);
2135
2316
  if (!membersPort || !client) {
2136
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: (0, import_design_system9.cn)("text-xs text-muted-foreground", className), children: NO_MEMBERS_REASON });
2317
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: (0, import_design_system10.cn)("text-xs text-muted-foreground", className), children: NO_MEMBERS_REASON });
2137
2318
  }
2138
2319
  if (!personTable) {
2139
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("p", { className: (0, import_design_system9.cn)("text-xs text-muted-foreground", className), children: [
2320
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { className: (0, import_design_system10.cn)("text-xs text-muted-foreground", className), children: [
2140
2321
  fieldName(field),
2141
2322
  " is a person field, but it does not say which Table the people are records of yet, so there is nothing to pick from. A table admin sets its target in the field editor."
2142
2323
  ] });
@@ -2179,8 +2360,8 @@ function PersonPicker({ field, value, onChange, disabled, id, className, autoOpe
2179
2360
  const pickedUserIds = new Set(
2180
2361
  picked.map((recordId) => people.find((p) => p.id === recordId)?.userId).filter(Boolean)
2181
2362
  );
2182
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: (0, import_design_system9.cn)("flex flex-wrap items-center gap-1", className), children: [
2183
- picked.map((recordId) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2363
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: (0, import_design_system10.cn)("flex flex-wrap items-center gap-1", className), children: [
2364
+ picked.map((recordId) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2184
2365
  RecordChip,
2185
2366
  {
2186
2367
  title: nameOfRecord(recordId),
@@ -2188,9 +2369,9 @@ function PersonPicker({ field, value, onChange, disabled, id, className, autoOpe
2188
2369
  },
2189
2370
  recordId
2190
2371
  )),
2191
- disabled ? null : /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_design_system9.Popover, { open, onOpenChange: setOpen, children: [
2192
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_design_system9.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2193
- import_design_system9.Button,
2372
+ disabled ? null : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_design_system10.Popover, { open, onOpenChange: setOpen, children: [
2373
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_design_system10.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2374
+ import_design_system10.Button,
2194
2375
  {
2195
2376
  id,
2196
2377
  type: "button",
@@ -2200,8 +2381,8 @@ function PersonPicker({ field, value, onChange, disabled, id, className, autoOpe
2200
2381
  children: picked.length === 0 ? "Pick a person" : "Change"
2201
2382
  }
2202
2383
  ) }),
2203
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
2204
- import_design_system9.PopoverContent,
2384
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
2385
+ import_design_system10.PopoverContent,
2205
2386
  {
2206
2387
  sizing: "content",
2207
2388
  className: "p-1",
@@ -2209,8 +2390,8 @@ function PersonPicker({ field, value, onChange, disabled, id, className, autoOpe
2209
2390
  "data-matrx-cell-editor": "",
2210
2391
  onKeyDown: (event) => event.stopPropagation(),
2211
2392
  children: [
2212
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2213
- import_design_system9.BasicInput,
2393
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2394
+ import_design_system10.BasicInput,
2214
2395
  {
2215
2396
  value: search,
2216
2397
  onChange: (e) => setSearch(e.target.value),
@@ -2222,31 +2403,31 @@ function PersonPicker({ field, value, onChange, disabled, id, className, autoOpe
2222
2403
  className: "mb-1 h-7 text-xs"
2223
2404
  }
2224
2405
  ),
2225
- error ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(RefusalLine, { error, className: "p-2" }) : null,
2226
- members === null ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "p-2 text-xs text-muted-foreground", children: "Reading the members\u2026" }) : null,
2227
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_design_system9.ScrollArea, { className: "max-h-56", children: [
2228
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("ul", { role: "listbox", "aria-label": `People for ${fieldName(field)}`, children: visible.map((member, index) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
2406
+ error ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(RefusalLine, { error, className: "p-2" }) : null,
2407
+ members === null ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "p-2 text-xs text-muted-foreground", children: "Reading the members\u2026" }) : null,
2408
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_design_system10.ScrollArea, { className: "max-h-56", children: [
2409
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("ul", { role: "listbox", "aria-label": `People for ${fieldName(field)}`, children: visible.map((member, index) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
2229
2410
  "button",
2230
2411
  {
2231
2412
  type: "button",
2232
2413
  disabled: busy,
2233
2414
  "data-pick-highlighted": index === keys.highlight ? "" : void 0,
2234
2415
  onClick: () => void pick(member),
2235
- className: (0, import_design_system9.cn)(
2416
+ className: (0, import_design_system10.cn)(
2236
2417
  "w-full truncate rounded px-2 py-1 text-left text-xs hover:bg-muted",
2237
2418
  pickedUserIds.has(member.userId) ? "bg-accent text-accent-foreground" : "",
2238
2419
  index === keys.highlight ? "ring-1 ring-ring" : ""
2239
2420
  ),
2240
2421
  children: [
2241
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { children: memberName(member) }),
2242
- member.email && member.email !== memberName(member) ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "ml-1.5 opacity-60", children: [
2422
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: memberName(member) }),
2423
+ member.email && member.email !== memberName(member) ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: "ml-1.5 opacity-60", children: [
2243
2424
  "\xB7 ",
2244
2425
  member.email
2245
2426
  ] }) : null
2246
2427
  ]
2247
2428
  }
2248
2429
  ) }, member.userId)) }),
2249
- members !== null && visible.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "p-2 text-xs text-muted-foreground", children: members.length === 0 ? "This organization has no other members yet, so there is nobody to assign." : "Nobody in this organization matches." }) : null
2430
+ members !== null && visible.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "p-2 text-xs text-muted-foreground", children: members.length === 0 ? "This organization has no other members yet, so there is nobody to assign." : "Nobody in this organization matches." }) : null
2250
2431
  ] })
2251
2432
  ]
2252
2433
  }
@@ -2318,16 +2499,16 @@ function currencyCodeFor(unit) {
2318
2499
  }
2319
2500
 
2320
2501
  // src/formatControls.tsx
2321
- var import_react18 = require("react");
2322
- var import_design_system11 = require("@ai-matrx/design-system");
2502
+ var import_react20 = require("react");
2503
+ var import_design_system12 = require("@ai-matrx/design-system");
2323
2504
  var import_field_formats4 = require("@ai-matrx/design-system/field-formats");
2324
2505
 
2325
2506
  // src/formattedValue.tsx
2326
- var import_react17 = require("react");
2507
+ var import_react19 = require("react");
2327
2508
  var import_data_table2 = require("@ai-matrx/design-system/data-table");
2328
2509
  var import_field_formats3 = require("@ai-matrx/design-system/field-formats");
2329
- var import_design_system10 = require("@ai-matrx/design-system");
2330
- var import_jsx_runtime12 = require("react/jsx-runtime");
2510
+ var import_design_system11 = require("@ai-matrx/design-system");
2511
+ var import_jsx_runtime13 = require("react/jsx-runtime");
2331
2512
  var LINK = "inline-flex min-w-0 items-center gap-1 text-primary hover:underline";
2332
2513
  var own2 = (event) => event.stopPropagation();
2333
2514
  function numberOf(value) {
@@ -2345,11 +2526,11 @@ function RatingStars({
2345
2526
  label,
2346
2527
  selectFirst
2347
2528
  }) {
2348
- const armed = (0, import_react17.useRef)(true);
2529
+ const armed = (0, import_react19.useRef)(true);
2349
2530
  const score = numberOf(value) ?? 0;
2350
2531
  const shown2 = Math.round(score);
2351
2532
  const said = `${shown2} out of ${max}`;
2352
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2533
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2353
2534
  "span",
2354
2535
  {
2355
2536
  "data-records-rating": "",
@@ -2361,8 +2542,8 @@ function RatingStars({
2361
2542
  children: Array.from({ length: max }, (_, i) => {
2362
2543
  const n = i + 1;
2363
2544
  const lit = n <= shown2;
2364
- const star = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { "aria-hidden": true, className: (0, import_design_system10.cn)("text-sm leading-none", lit ? "text-amber-400" : "text-muted-foreground/40"), children: "\u2605" });
2365
- return onRate ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2545
+ const star = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { "aria-hidden": true, className: (0, import_design_system11.cn)("text-sm leading-none", lit ? "text-amber-400" : "text-muted-foreground/40"), children: "\u2605" });
2546
+ return onRate ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2366
2547
  "button",
2367
2548
  {
2368
2549
  type: "button",
@@ -2387,7 +2568,7 @@ function RatingStars({
2387
2568
  children: star
2388
2569
  },
2389
2570
  n
2390
- ) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: star }, n);
2571
+ ) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: star }, n);
2391
2572
  })
2392
2573
  }
2393
2574
  );
@@ -2395,13 +2576,13 @@ function RatingStars({
2395
2576
  function rich(id, text, raw, format) {
2396
2577
  switch (id) {
2397
2578
  case "email":
2398
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("a", { href: `mailto:${text}`, className: LINK, onClick: own2, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "truncate", children: text }) });
2579
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("a", { href: `mailto:${text}`, className: LINK, onClick: own2, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "truncate", children: text }) });
2399
2580
  case "url":
2400
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("a", { href: text.includes("://") ? text : `https://${text}`, target: "_blank", rel: "noopener noreferrer", className: LINK, onClick: own2, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "truncate", children: text }) });
2581
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("a", { href: text.includes("://") ? text : `https://${text}`, target: "_blank", rel: "noopener noreferrer", className: LINK, onClick: own2, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "truncate", children: text }) });
2401
2582
  case "phone":
2402
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("a", { href: `tel:${text.replace(/[^\d+]/g, "")}`, className: LINK, onClick: own2, title: text, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "truncate tabular-nums", children: formatPhone(text) }) });
2583
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("a", { href: `tel:${text.replace(/[^\d+]/g, "")}`, className: LINK, onClick: own2, title: text, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "truncate tabular-nums", children: formatPhone(text) }) });
2403
2584
  case "address":
2404
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2585
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2405
2586
  "a",
2406
2587
  {
2407
2588
  href: `https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(text)}`,
@@ -2410,7 +2591,7 @@ function rich(id, text, raw, format) {
2410
2591
  className: LINK,
2411
2592
  title: "Open in maps",
2412
2593
  onClick: own2,
2413
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "truncate", children: text })
2594
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "truncate", children: text })
2414
2595
  }
2415
2596
  );
2416
2597
  case "progress": {
@@ -2418,8 +2599,8 @@ function rich(id, text, raw, format) {
2418
2599
  if (n === null) return void 0;
2419
2600
  const pct = format.options?.percentScale === "fraction" ? n * 100 : n;
2420
2601
  const clamped = Math.max(0, Math.min(100, pct));
2421
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: "inline-flex w-full min-w-0 items-center gap-2", title: text, children: [
2422
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2602
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: "inline-flex w-full min-w-0 items-center gap-2", title: text, children: [
2603
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2423
2604
  "span",
2424
2605
  {
2425
2606
  role: "progressbar",
@@ -2427,24 +2608,24 @@ function rich(id, text, raw, format) {
2427
2608
  "aria-valuemax": 100,
2428
2609
  "aria-valuenow": Math.round(clamped),
2429
2610
  className: "h-1.5 min-w-8 flex-1 overflow-hidden rounded-full bg-muted",
2430
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: (0, import_design_system10.cn)("block h-full rounded-full", pct >= 100 ? "bg-emerald-500" : "bg-primary"), style: { width: `${clamped}%` } })
2611
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: (0, import_design_system11.cn)("block h-full rounded-full", pct >= 100 ? "bg-emerald-500" : "bg-primary"), style: { width: `${clamped}%` } })
2431
2612
  }
2432
2613
  ),
2433
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: text })
2614
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: text })
2434
2615
  ] });
2435
2616
  }
2436
2617
  case "color":
2437
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: "inline-flex items-center gap-1.5", children: [
2438
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "h-4 w-4 shrink-0 rounded border border-border", style: { backgroundColor: text } }),
2439
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("code", { className: "font-mono text-xs", children: text })
2618
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: "inline-flex items-center gap-1.5", children: [
2619
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "h-4 w-4 shrink-0 rounded border border-border", style: { backgroundColor: text } }),
2620
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("code", { className: "font-mono text-xs", children: text })
2440
2621
  ] });
2441
2622
  case "tags": {
2442
2623
  const items = Array.isArray(raw) ? raw.map(String) : text.split(",").map((s) => s.trim()).filter(Boolean);
2443
2624
  if (items.length === 0) return void 0;
2444
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "flex flex-wrap items-center gap-1", children: items.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "inline-flex items-center rounded-md border border-border bg-muted px-1.5 py-0.5 text-xs", children: item }, `${item}-${i}`)) });
2625
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "flex flex-wrap items-center gap-1", children: items.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "inline-flex items-center rounded-md border border-border bg-muted px-1.5 py-0.5 text-xs", children: item }, `${item}-${i}`)) });
2445
2626
  }
2446
2627
  case "rating":
2447
- return numberOf(raw) === null ? void 0 : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(RatingStars, { value: raw, max: format.options?.ratingMax ?? 5 });
2628
+ return numberOf(raw) === null ? void 0 : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(RatingStars, { value: raw, max: format.options?.ratingMax ?? 5 });
2448
2629
  default:
2449
2630
  return void 0;
2450
2631
  }
@@ -2459,11 +2640,11 @@ function FormattedValue({
2459
2640
  const score = numberOf(value);
2460
2641
  const max = format.options?.ratingMax ?? 5;
2461
2642
  if (def?.id === "rating" && onRate && (value === null || value === void 0 || value === "" || score !== null && score >= 0 && score <= max)) {
2462
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(RatingStars, { value, max: format.options?.ratingMax ?? 5, onRate, selectFirst });
2643
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(RatingStars, { value, max: format.options?.ratingMax ?? 5, onRate, selectFirst });
2463
2644
  }
2464
2645
  const result = (0, import_field_formats3.formatFieldValue)(value, format);
2465
- if (!result.ok || result.empty || !def?.rich) return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_data_table2.FormattedCell, { result });
2466
- return rich(def.id, result.text, value, format) ?? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_data_table2.FormattedCell, { result });
2646
+ if (!result.ok || result.empty || !def?.rich) return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_data_table2.FormattedCell, { result });
2647
+ return rich(def.id, result.text, value, format) ?? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_data_table2.FormattedCell, { result });
2467
2648
  }
2468
2649
  function formatPhone(raw) {
2469
2650
  const text = raw.trim();
@@ -2487,7 +2668,7 @@ function linkChipText(raw) {
2487
2668
  }
2488
2669
 
2489
2670
  // src/formatControls.tsx
2490
- var import_jsx_runtime13 = require("react/jsx-runtime");
2671
+ var import_jsx_runtime14 = require("react/jsx-runtime");
2491
2672
  var TYPED_NUMBERS = /* @__PURE__ */ new Set(["currency", "percent", "progress", "decimal", "duration", "file_size", "integer"]);
2492
2673
  function scaled(format) {
2493
2674
  return (format.id === "percent" || format.id === "progress") && format.options?.percentScale === "fraction";
@@ -2504,14 +2685,14 @@ function keptValue(format, raw) {
2504
2685
  return parsed;
2505
2686
  }
2506
2687
  function NumberInFormat({ format, value, onChange, disabled, id }) {
2507
- const [text, setText] = (0, import_react18.useState)(() => typedText(format, value));
2508
- const lastSent = (0, import_react18.useRef)(void 0);
2509
- (0, import_react18.useEffect)(() => {
2688
+ const [text, setText] = (0, import_react20.useState)(() => typedText(format, value));
2689
+ const lastSent = (0, import_react20.useRef)(void 0);
2690
+ (0, import_react20.useEffect)(() => {
2510
2691
  if (value === lastSent.current) return;
2511
2692
  setText(typedText(format, value));
2512
2693
  }, [value, format]);
2513
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2514
- import_design_system11.BasicInput,
2694
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2695
+ import_design_system12.BasicInput,
2515
2696
  {
2516
2697
  id,
2517
2698
  inputMode: "decimal",
@@ -2535,17 +2716,17 @@ function formatControl(args) {
2535
2716
  const text = value === null || value === void 0 ? "" : String(value);
2536
2717
  const commit = (raw) => onChange(raw === "" ? null : (0, import_field_formats4.parseFieldInput)(raw, format));
2537
2718
  if (def.id === "rating") {
2538
- return disabled ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(RatingStars, { value, max: format.options?.ratingMax ?? 5, label }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { id, className: "inline-flex", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(RatingStars, { value, max: format.options?.ratingMax ?? 5, label, onRate: (n) => onChange(n) }) });
2719
+ return disabled ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(RatingStars, { value, max: format.options?.ratingMax ?? 5, label }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { id, className: "inline-flex", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(RatingStars, { value, max: format.options?.ratingMax ?? 5, label, onRate: (n) => onChange(n) }) });
2539
2720
  }
2540
- if (TYPED_NUMBERS.has(def.id)) return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(NumberInFormat, { ...args });
2721
+ if (TYPED_NUMBERS.has(def.id)) return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(NumberInFormat, { ...args });
2541
2722
  switch (def.editor) {
2542
2723
  // A TIME OF DAY is not this file's: `FieldControl` draws the typed box and its helper
2543
2724
  // (`TypedWordsControl`), never the browser's time control (grids review 3, 2026-09-30).
2544
2725
  case "email":
2545
2726
  case "url":
2546
2727
  case "tel":
2547
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2548
- import_design_system11.BasicInput,
2728
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2729
+ import_design_system12.BasicInput,
2549
2730
  {
2550
2731
  id,
2551
2732
  type: def.editor,
@@ -2556,9 +2737,9 @@ function formatControl(args) {
2556
2737
  }
2557
2738
  );
2558
2739
  case "color":
2559
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: "flex items-center gap-2", children: [
2560
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2561
- import_design_system11.BasicInput,
2740
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "flex items-center gap-2", children: [
2741
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2742
+ import_design_system12.BasicInput,
2562
2743
  {
2563
2744
  id: `${id}-swatch`,
2564
2745
  type: "color",
@@ -2569,20 +2750,20 @@ function formatControl(args) {
2569
2750
  onChange: (e) => commit(e.target.value)
2570
2751
  }
2571
2752
  ),
2572
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_design_system11.BasicInput, { id, value: text, placeholder: "#3b82f6", disabled, onChange: (e) => commit(e.target.value) })
2753
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_design_system12.BasicInput, { id, value: text, placeholder: "#3b82f6", disabled, onChange: (e) => commit(e.target.value) })
2573
2754
  ] });
2574
2755
  case "textarea":
2575
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_design_system11.BasicTextarea, { id, rows: 4, value: text, disabled, onChange: (e) => commit(e.target.value) });
2756
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_design_system12.BasicTextarea, { id, rows: 4, value: text, disabled, onChange: (e) => commit(e.target.value) });
2576
2757
  default:
2577
2758
  return null;
2578
2759
  }
2579
2760
  }
2580
2761
 
2581
2762
  // src/typedDateHelper.tsx
2582
- var import_react19 = require("react");
2583
- var import_design_system12 = require("@ai-matrx/design-system");
2763
+ var import_react21 = require("react");
2764
+ var import_design_system13 = require("@ai-matrx/design-system");
2584
2765
  var import_records9 = require("@ai-matrx/records");
2585
- var import_jsx_runtime14 = require("react/jsx-runtime");
2766
+ var import_jsx_runtime15 = require("react/jsx-runtime");
2586
2767
  var WEEK = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
2587
2768
  var MONTHS = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
2588
2769
  function pad(n) {
@@ -2611,23 +2792,23 @@ function wordsFor(kind, day, time) {
2611
2792
  }
2612
2793
  var keepFocus = { onMouseDown: (e) => e.preventDefault(), tabIndex: -1 };
2613
2794
  function CalendarGlyph() {
2614
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", width: "14", height: "14", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
2615
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: "3", y: "4", width: "18", height: "18", rx: "2" }),
2616
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M16 2v4M8 2v4M3 10h18" })
2795
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", width: "14", height: "14", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
2796
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("rect", { x: "3", y: "4", width: "18", height: "18", rx: "2" }),
2797
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: "M16 2v4M8 2v4M3 10h18" })
2617
2798
  ] });
2618
2799
  }
2619
2800
  function ClockGlyph() {
2620
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", width: "14", height: "14", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
2621
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
2622
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M12 6v6l4 2" })
2801
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", width: "14", height: "14", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
2802
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
2803
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: "M12 6v6l4 2" })
2623
2804
  ] });
2624
2805
  }
2625
2806
  function TypedDateHelper({ kind, text, onText, label }) {
2626
- const [open, setOpen] = (0, import_react19.useState)(false);
2807
+ const [open, setOpen] = (0, import_react21.useState)(false);
2627
2808
  const held = readBox(text, kind);
2628
2809
  const today = /* @__PURE__ */ new Date();
2629
2810
  const start = held.day ? new Date(Number(held.day.slice(0, 4)), Number(held.day.slice(5, 7)) - 1, 1) : new Date(today.getFullYear(), today.getMonth(), 1);
2630
- const [month, setMonth] = (0, import_react19.useState)(null);
2811
+ const [month, setMonth] = (0, import_react21.useState)(null);
2631
2812
  const shown2 = month ?? { y: start.getFullYear(), m: start.getMonth() };
2632
2813
  const first = new Date(shown2.y, shown2.m, 1).getDay();
2633
2814
  const days = new Date(shown2.y, shown2.m + 1, 0).getDate();
@@ -2648,8 +2829,8 @@ function TypedDateHelper({ kind, text, onText, label }) {
2648
2829
  const at = new Date(shown2.y, shown2.m + by, 1);
2649
2830
  setMonth({ y: at.getFullYear(), m: at.getMonth() });
2650
2831
  };
2651
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_design_system12.Popover, { open, onOpenChange: setOpen, children: [
2652
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_design_system12.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2832
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_design_system13.Popover, { open, onOpenChange: setOpen, children: [
2833
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_design_system13.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2653
2834
  "button",
2654
2835
  {
2655
2836
  type: "button",
@@ -2658,11 +2839,11 @@ function TypedDateHelper({ kind, text, onText, label }) {
2658
2839
  "aria-label": kind === "time" ? `Pick a time for ${label}` : `Pick a date for ${label}`,
2659
2840
  title: kind === "time" ? "Pick a time" : "Pick a date",
2660
2841
  className: "inline-flex h-7 w-7 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground",
2661
- children: kind === "time" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ClockGlyph, {}) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CalendarGlyph, {})
2842
+ children: kind === "time" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ClockGlyph, {}) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(CalendarGlyph, {})
2662
2843
  }
2663
2844
  ) }),
2664
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2665
- import_design_system12.PopoverContent,
2845
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2846
+ import_design_system13.PopoverContent,
2666
2847
  {
2667
2848
  sizing: "content",
2668
2849
  align: "start",
@@ -2671,29 +2852,29 @@ function TypedDateHelper({ kind, text, onText, label }) {
2671
2852
  "data-records-date-helper-panel": "",
2672
2853
  onOpenAutoFocus: (e) => e.preventDefault(),
2673
2854
  onCloseAutoFocus: (e) => e.preventDefault(),
2674
- children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex gap-2", children: [
2675
- kind === "time" ? null : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex flex-col gap-1", role: "grid", "aria-label": `${MONTHS[shown2.m]} ${shown2.y}`, children: [
2676
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center justify-between text-xs font-medium", children: [
2677
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", ...keepFocus, "aria-label": "Previous month", className: "rounded px-1.5 hover:bg-muted", onClick: () => turn(-1), children: "\u2039" }),
2678
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { children: [
2855
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex gap-2", children: [
2856
+ kind === "time" ? null : /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-col gap-1", role: "grid", "aria-label": `${MONTHS[shown2.m]} ${shown2.y}`, children: [
2857
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center justify-between text-xs font-medium", children: [
2858
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", ...keepFocus, "aria-label": "Previous month", className: "rounded px-1.5 hover:bg-muted", onClick: () => turn(-1), children: "\u2039" }),
2859
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { children: [
2679
2860
  MONTHS[shown2.m],
2680
2861
  " ",
2681
2862
  shown2.y
2682
2863
  ] }),
2683
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", ...keepFocus, "aria-label": "Next month", className: "rounded px-1.5 hover:bg-muted", onClick: () => turn(1), children: "\u203A" })
2864
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", ...keepFocus, "aria-label": "Next month", className: "rounded px-1.5 hover:bg-muted", onClick: () => turn(1), children: "\u203A" })
2684
2865
  ] }),
2685
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "grid grid-cols-7 gap-0.5 text-center text-[11px]", children: [
2686
- WEEK.map((w) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "text-muted-foreground", children: w }, w)),
2866
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "grid grid-cols-7 gap-0.5 text-center text-[11px]", children: [
2867
+ WEEK.map((w) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-muted-foreground", children: w }, w)),
2687
2868
  cells.map((d, i) => {
2688
- if (d === null) return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", {}, `blank-${i}`);
2869
+ if (d === null) return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", {}, `blank-${i}`);
2689
2870
  const key = `${shown2.y}-${pad(shown2.m + 1)}-${pad(d)}`;
2690
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2871
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2691
2872
  "button",
2692
2873
  {
2693
2874
  type: "button",
2694
2875
  ...keepFocus,
2695
2876
  "data-records-date-helper-day": key,
2696
- className: (0, import_design_system12.cn)(
2877
+ className: (0, import_design_system13.cn)(
2697
2878
  "h-6 w-6 rounded tabular-nums hover:bg-muted",
2698
2879
  key === held.day ? "bg-primary text-primary-foreground hover:bg-primary" : "",
2699
2880
  key === todayKey && key !== held.day ? "ring-1 ring-ring" : ""
@@ -2706,13 +2887,13 @@ function TypedDateHelper({ kind, text, onText, label }) {
2706
2887
  })
2707
2888
  ] })
2708
2889
  ] }),
2709
- kind === "date" ? null : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "flex max-h-48 flex-col overflow-y-auto pr-1 text-[11px]", "aria-label": "Times", children: times.map((t) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2890
+ kind === "date" ? null : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "flex max-h-48 flex-col overflow-y-auto pr-1 text-[11px]", "aria-label": "Times", children: times.map((t) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2710
2891
  "button",
2711
2892
  {
2712
2893
  type: "button",
2713
2894
  ...keepFocus,
2714
2895
  "data-records-date-helper-time": `${pad(t.h)}:${pad(t.m)}`,
2715
- className: (0, import_design_system12.cn)(
2896
+ className: (0, import_design_system13.cn)(
2716
2897
  "whitespace-nowrap rounded px-2 py-0.5 text-left tabular-nums hover:bg-muted",
2717
2898
  held.time && held.time.h === t.h && held.time.m === t.m ? "bg-primary text-primary-foreground" : ""
2718
2899
  ),
@@ -2728,8 +2909,8 @@ function TypedDateHelper({ kind, text, onText, label }) {
2728
2909
  }
2729
2910
 
2730
2911
  // src/choiceNudge.ts
2731
- var import_react20 = require("react");
2732
- var import_react21 = require("@ai-matrx/records/react");
2912
+ var import_react22 = require("react");
2913
+ var import_react23 = require("@ai-matrx/records/react");
2733
2914
  var asked = /* @__PURE__ */ new WeakMap();
2734
2915
  function choiceNudgeOf(client) {
2735
2916
  let answer = asked.get(client);
@@ -2743,9 +2924,9 @@ function choiceNudgeOf(client) {
2743
2924
  return answer;
2744
2925
  }
2745
2926
  function useChoiceNudge(enabled = true) {
2746
- const client = (0, import_react21.useOptionalRecordsClient)();
2747
- const [nudge, setNudge] = (0, import_react20.useState)(null);
2748
- (0, import_react20.useEffect)(() => {
2927
+ const client = (0, import_react23.useOptionalRecordsClient)();
2928
+ const [nudge, setNudge] = (0, import_react22.useState)(null);
2929
+ (0, import_react22.useEffect)(() => {
2749
2930
  if (!enabled || !client) return;
2750
2931
  let live = true;
2751
2932
  void choiceNudgeOf(client).then((answer) => {
@@ -2813,7 +2994,7 @@ function choiceChipLookOf(field, ...words) {
2813
2994
  }
2814
2995
 
2815
2996
  // src/editors.tsx
2816
- var import_jsx_runtime15 = require("react/jsx-runtime");
2997
+ var import_jsx_runtime16 = require("react/jsx-runtime");
2817
2998
  var CHOICE_EDITOR_ADDS_WHAT_IS_TYPED = true;
2818
2999
  function isChoiceAddition(value) {
2819
3000
  return typeof value === "object" && value !== null && value.addingChoices === true;
@@ -2843,12 +3024,12 @@ function ChoiceAskButtons({
2843
3024
  onCancel,
2844
3025
  busy
2845
3026
  }) {
2846
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { "data-records-choice-ask": "", role: "group", "aria-label": choiceAskSentence(field, words), className: "flex flex-col gap-1", children: [
2847
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-[11px] leading-snug", children: choiceAskSentence(field, words) }),
2848
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "flex flex-wrap items-center gap-1", children: [
2849
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_design_system13.Button, { type: "button", size: "sm", className: "h-6 px-2 text-xs", disabled: busy ?? false, onClick: onAdd, children: "Add" }),
2850
- keepOffered ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_design_system13.Button, { type: "button", size: "sm", variant: "outline", className: "h-6 px-2 text-xs", disabled: busy ?? false, onClick: onKeep, children: "Keep as typed" }) : null,
2851
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_design_system13.Button, { type: "button", size: "sm", variant: "ghost", className: "h-6 px-2 text-xs", disabled: busy ?? false, onClick: onCancel, children: "Cancel" })
3027
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { "data-records-choice-ask": "", role: "group", "aria-label": choiceAskSentence(field, words), className: "flex flex-col gap-1", children: [
3028
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-[11px] leading-snug", children: choiceAskSentence(field, words) }),
3029
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { className: "flex flex-wrap items-center gap-1", children: [
3030
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_design_system14.Button, { type: "button", size: "sm", className: "h-6 px-2 text-xs", disabled: busy ?? false, onClick: onAdd, children: "Add" }),
3031
+ keepOffered ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_design_system14.Button, { type: "button", size: "sm", variant: "outline", className: "h-6 px-2 text-xs", disabled: busy ?? false, onClick: onKeep, children: "Keep as typed" }) : null,
3032
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_design_system14.Button, { type: "button", size: "sm", variant: "ghost", className: "h-6 px-2 text-xs", disabled: busy ?? false, onClick: onCancel, children: "Cancel" })
2852
3033
  ] })
2853
3034
  ] });
2854
3035
  }
@@ -2931,12 +3112,12 @@ function openingText(field, value) {
2931
3112
  return format ? typedText(format, value) : String(value);
2932
3113
  }
2933
3114
  function TypedTextControl({ field, value, onChange, disabled, id, onCommit, onCancel }) {
2934
- const client = (0, import_react23.useOptionalRecordsClient)();
3115
+ const client = (0, import_react25.useOptionalRecordsClient)();
2935
3116
  const kind = String(editorKindFor(field));
2936
3117
  const needsChoices = kind === "select" || kind === "multi_select";
2937
3118
  const nudge = useChoiceNudge(needsChoices);
2938
- const [choices, setChoices] = (0, import_react22.useState)(null);
2939
- (0, import_react22.useEffect)(() => {
3119
+ const [choices, setChoices] = (0, import_react24.useState)(null);
3120
+ (0, import_react24.useEffect)(() => {
2940
3121
  if (!needsChoices || !client) return;
2941
3122
  let cancelled = false;
2942
3123
  void client.fieldOptions({ field_id: field.id }).then((result) => {
@@ -2946,7 +3127,7 @@ function TypedTextControl({ field, value, onChange, disabled, id, onCommit, onCa
2946
3127
  cancelled = true;
2947
3128
  };
2948
3129
  }, [client, field.id, needsChoices]);
2949
- (0, import_react22.useEffect)(() => {
3130
+ (0, import_react24.useEffect)(() => {
2950
3131
  if (choices && nudge && value.judged === null) onChange({ ...value, judged: judgeTyped(field, value.text, choices, nudge) });
2951
3132
  }, [choices, nudge, value, field, onChange]);
2952
3133
  const judged = value.judged;
@@ -2958,8 +3139,8 @@ function TypedTextControl({ field, value, onChange, disabled, id, onCommit, onCa
2958
3139
  judged: judgeTyped(field, text, needsChoices ? choices : void 0, needsChoices ? nudge : void 0),
2959
3140
  ...value.openedAs !== void 0 ? { openedAs: value.openedAs } : {}
2960
3141
  });
2961
- const box = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2962
- import_design_system13.BasicInput,
3142
+ const box = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3143
+ import_design_system14.BasicInput,
2963
3144
  {
2964
3145
  id,
2965
3146
  value: value.text,
@@ -2970,16 +3151,16 @@ function TypedTextControl({ field, value, onChange, disabled, id, onCommit, onCa
2970
3151
  onChange: (e) => retype(e.target.value)
2971
3152
  }
2972
3153
  );
2973
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "flex flex-col gap-0.5", children: [
2974
- helper && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "flex min-w-0 items-center gap-0.5", children: [
3154
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { className: "flex flex-col gap-0.5", children: [
3155
+ helper && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { className: "flex min-w-0 items-center gap-0.5", children: [
2975
3156
  box,
2976
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(TypedDateHelper, { kind: helper, text: value.text, onText: retype, label: fieldName(field) })
3157
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TypedDateHelper, { kind: helper, text: value.text, onText: retype, label: fieldName(field) })
2977
3158
  ] }) : box,
2978
- judged === null ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "text-[10px] text-muted-foreground", children: [
3159
+ judged === null ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { className: "text-[10px] text-muted-foreground", children: [
2979
3160
  "Reading ",
2980
3161
  fieldName(field),
2981
3162
  "'s choices\u2026"
2982
- ] }) : "ask" in judged ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3163
+ ] }) : "ask" in judged ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2983
3164
  ChoiceAskButtons,
2984
3165
  {
2985
3166
  field,
@@ -2995,10 +3176,10 @@ function TypedTextControl({ field, value, onChange, disabled, id, onCommit, onCa
2995
3176
  },
2996
3177
  onCancel: () => onCancel?.()
2997
3178
  }
2998
- ) : "refusal" in judged ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "flex flex-col gap-1", children: [
2999
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { "data-records-typed-refusal": "", role: "status", className: "text-[11px] leading-snug text-amber-700 dark:text-amber-400", children: judged.refusal }),
3000
- judged.cancelOnly && onCancel ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { "data-records-choice-ask": "", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_design_system13.Button, { type: "button", size: "sm", variant: "ghost", className: "h-6 px-2 text-xs", onClick: () => onCancel(), children: "Cancel" }) }) : null
3001
- ] }) : judged.value === null || judged.value === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { "data-records-typed-reads-as": "", className: "text-[10px] text-muted-foreground", children: [
3179
+ ) : "refusal" in judged ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { className: "flex flex-col gap-1", children: [
3180
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { "data-records-typed-refusal": "", role: "status", className: "text-[11px] leading-snug text-amber-700 dark:text-amber-400", children: judged.refusal }),
3181
+ judged.cancelOnly && onCancel ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { "data-records-choice-ask": "", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_design_system14.Button, { type: "button", size: "sm", variant: "ghost", className: "h-6 px-2 text-xs", onClick: () => onCancel(), children: "Cancel" }) }) : null
3182
+ ] }) : judged.value === null || judged.value === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { "data-records-typed-reads-as": "", className: "text-[10px] text-muted-foreground", children: [
3002
3183
  isChoiceAddition(judged.value) ? `Adds ${quoted(judged.value.add)} to the choices for ${fieldName(field)}. ` : null,
3003
3184
  "Reads as",
3004
3185
  " ",
@@ -3009,7 +3190,7 @@ function TypedTextControl({ field, value, onChange, disabled, id, onCommit, onCa
3009
3190
  }).join(", ")
3010
3191
  ) : (() => {
3011
3192
  const shown2 = format ?? (kind === "datetime" ? { id: carriesTimeOfDay(field, judged.value) ? "datetime" : "date" } : void 0);
3012
- return shown2 ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(FormattedValue, { value: judged.value, format: shown2 }) : String(judged.value);
3193
+ return shown2 ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(FormattedValue, { value: judged.value, format: shown2 }) : String(judged.value);
3013
3194
  })()
3014
3195
  ] })
3015
3196
  ] });
@@ -3022,13 +3203,13 @@ function FieldControl({ field, value, onChange, disabled, id, autoOpen, onClose,
3022
3203
  const host = useRecordsUi();
3023
3204
  const kind = editorKindFor(field);
3024
3205
  const inputId = id ?? `field-${field.key}`;
3025
- const ownDetails = (0, import_react23.useOptionalRecordsClient)() === null;
3026
- if (isTypedDraft(value)) return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(TypedTextControl, { field, value, onChange, disabled, id: inputId, onCommit, onCancel });
3027
- if (isSignatureField(field)) return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(SignaturePad, { id: inputId, value, onChange, disabled });
3206
+ const ownDetails = (0, import_react25.useOptionalRecordsClient)() === null;
3207
+ if (isTypedDraft(value)) return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TypedTextControl, { field, value, onChange, disabled, id: inputId, onCommit, onCancel });
3208
+ if (isSignatureField(field)) return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SignaturePad, { id: inputId, value, onChange, disabled });
3028
3209
  const newerControl = newerKindControl({ field, value, onChange, disabled, id: inputId });
3029
3210
  if (newerControl !== void 0) return newerControl;
3030
3211
  const format = formatForField(field);
3031
- if (format && format.id === "time") return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(TypedWordsControl, { field, value, onChange, disabled, id: inputId });
3212
+ if (format && format.id === "time") return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TypedWordsControl, { field, value, onChange, disabled, id: inputId });
3032
3213
  if (format && !FORMAT_BLIND_KINDS.has(String(kind))) {
3033
3214
  const own3 = formatControl({ format, value, onChange, disabled, id: inputId, label: fieldName(field), ownDetails });
3034
3215
  if (own3) return own3;
@@ -3037,18 +3218,18 @@ function FieldControl({ field, value, onChange, disabled, id, autoOpen, onClose,
3037
3218
  case "formula":
3038
3219
  case "lookup":
3039
3220
  case "rollup":
3040
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { id: inputId, className: "rounded border border-dashed px-2 py-1.5 text-xs text-muted-foreground", children: [
3221
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { id: inputId, className: "rounded border border-dashed px-2 py-1.5 text-xs text-muted-foreground", children: [
3041
3222
  value === null || value === void 0 ? "\u2014" : String(value),
3042
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "ml-2 italic", children: [
3223
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { className: "ml-2 italic", children: [
3043
3224
  fieldName(field),
3044
3225
  " is worked out by the system, so it cannot be typed in"
3045
3226
  ] })
3046
3227
  ] });
3047
3228
  case "json":
3048
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(JsonControl, { field, value, onChange, disabled, id: inputId });
3229
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(JsonControl, { field, value, onChange, disabled, id: inputId });
3049
3230
  case "long_text":
3050
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3051
- import_design_system13.BasicTextarea,
3231
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3232
+ import_design_system14.BasicTextarea,
3052
3233
  {
3053
3234
  id: inputId,
3054
3235
  rows: 3,
@@ -3060,8 +3241,8 @@ function FieldControl({ field, value, onChange, disabled, id, autoOpen, onClose,
3060
3241
  case "number":
3061
3242
  case "currency":
3062
3243
  case "percent":
3063
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3064
- import_design_system13.BasicInput,
3244
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3245
+ import_design_system14.BasicInput,
3065
3246
  {
3066
3247
  id: inputId,
3067
3248
  type: "number",
@@ -3073,12 +3254,12 @@ function FieldControl({ field, value, onChange, disabled, id, autoOpen, onClose,
3073
3254
  }
3074
3255
  );
3075
3256
  case "datetime":
3076
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(TypedWordsControl, { field, value, onChange, disabled, id: inputId });
3257
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TypedWordsControl, { field, value, onChange, disabled, id: inputId });
3077
3258
  case "email":
3078
3259
  case "phone":
3079
3260
  case "url":
3080
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3081
- import_design_system13.BasicInput,
3261
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3262
+ import_design_system14.BasicInput,
3082
3263
  {
3083
3264
  id: inputId,
3084
3265
  type: kind === "email" ? "email" : kind === "phone" ? "tel" : "url",
@@ -3089,25 +3270,25 @@ function FieldControl({ field, value, onChange, disabled, id, autoOpen, onClose,
3089
3270
  }
3090
3271
  );
3091
3272
  case "checkbox":
3092
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(CheckboxControl, { field, value, onChange, disabled, id: inputId });
3273
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(CheckboxControl, { field, value, onChange, disabled, id: inputId });
3093
3274
  case "select":
3094
3275
  case "multi_select":
3095
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(OptionControl, { field, value, onChange, disabled, id: inputId, autoOpen, onClose, addsChoices, initialSearch, asForm });
3276
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(OptionControl, { field, value, onChange, disabled, id: inputId, autoOpen, onClose, addsChoices, initialSearch, asForm });
3096
3277
  case "member":
3097
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(PersonPicker, { field, value, onChange, disabled, id: inputId, autoOpen, onClose, initialSearch });
3278
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(PersonPicker, { field, value, onChange, disabled, id: inputId, autoOpen, onClose, initialSearch });
3098
3279
  case "entity_reference":
3099
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(EntityReferenceControl, { field, value, onChange, disabled, id: inputId });
3280
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(EntityReferenceControl, { field, value, onChange, disabled, id: inputId });
3100
3281
  case "attachment":
3101
3282
  if (hostTakesFiles(host)) {
3102
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(AttachmentControl, { field, value, onChange, disabled, id: inputId, autoOpen, onClose });
3283
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(AttachmentControl, { field, value, onChange, disabled, id: inputId, autoOpen, onClose });
3103
3284
  }
3104
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(RelationPicker, { field, value, onChange, disabled, id: inputId });
3285
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(RelationPicker, { field, value, onChange, disabled, id: inputId });
3105
3286
  case "relation":
3106
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(RelationPicker, { field, value, onChange, disabled, id: inputId });
3287
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(RelationPicker, { field, value, onChange, disabled, id: inputId });
3107
3288
  default:
3108
3289
  if (typeof value === "boolean" || field.config?.["kind"] === "boolean") {
3109
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3110
- import_design_system13.Checkbox,
3290
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3291
+ import_design_system14.Checkbox,
3111
3292
  {
3112
3293
  id: inputId,
3113
3294
  checked: value === true,
@@ -3116,8 +3297,8 @@ function FieldControl({ field, value, onChange, disabled, id, autoOpen, onClose,
3116
3297
  }
3117
3298
  );
3118
3299
  }
3119
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3120
- import_design_system13.BasicInput,
3300
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3301
+ import_design_system14.BasicInput,
3121
3302
  {
3122
3303
  id: inputId,
3123
3304
  ...ownDetails && isPersonsName(field) ? { autoComplete: "name" } : {},
@@ -3129,10 +3310,10 @@ function FieldControl({ field, value, onChange, disabled, id, autoOpen, onClose,
3129
3310
  }
3130
3311
  }
3131
3312
  function TypedWordsControl({ field, value, onChange, disabled, id }) {
3132
- const [text, setText] = (0, import_react22.useState)(() => openingText(field, value));
3133
- const [refusal2, setRefusal] = (0, import_react22.useState)(null);
3134
- const sent = (0, import_react22.useRef)(value);
3135
- (0, import_react22.useEffect)(() => {
3313
+ const [text, setText] = (0, import_react24.useState)(() => openingText(field, value));
3314
+ const [refusal2, setRefusal] = (0, import_react24.useState)(null);
3315
+ const sent = (0, import_react24.useRef)(value);
3316
+ (0, import_react24.useEffect)(() => {
3136
3317
  if (value === sent.current) return;
3137
3318
  sent.current = value;
3138
3319
  setText(openingText(field, value));
@@ -3150,10 +3331,10 @@ function TypedWordsControl({ field, value, onChange, disabled, id }) {
3150
3331
  setRefusal(judged.refusal);
3151
3332
  }
3152
3333
  };
3153
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "flex flex-col gap-0.5", children: [
3154
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "flex min-w-0 items-center gap-0.5", children: [
3155
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3156
- import_design_system13.BasicInput,
3334
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { className: "flex flex-col gap-0.5", children: [
3335
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { className: "flex min-w-0 items-center gap-0.5", children: [
3336
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3337
+ import_design_system14.BasicInput,
3157
3338
  {
3158
3339
  id,
3159
3340
  value: text,
@@ -3169,16 +3350,16 @@ function TypedWordsControl({ field, value, onChange, disabled, id }) {
3169
3350
  }
3170
3351
  }
3171
3352
  ),
3172
- helper && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(TypedDateHelper, { kind: helper, text, onText: retype, label: fieldName(field) }) : null
3353
+ helper && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TypedDateHelper, { kind: helper, text, onText: retype, label: fieldName(field) }) : null
3173
3354
  ] }),
3174
- refusal2 ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { "data-records-typed-refusal": "", role: "status", className: "text-[11px] leading-snug text-amber-700 dark:text-amber-400", children: refusal2 }) : null
3355
+ refusal2 ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { "data-records-typed-refusal": "", role: "status", className: "text-[11px] leading-snug text-amber-700 dark:text-amber-400", children: refusal2 }) : null
3175
3356
  ] });
3176
3357
  }
3177
3358
  function CheckboxControl({ field, value, onChange, disabled, id }) {
3178
3359
  const unanswered = value === null || value === void 0;
3179
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center gap-2", children: [
3180
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3181
- import_design_system13.Checkbox,
3360
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center gap-2", children: [
3361
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3362
+ import_design_system14.Checkbox,
3182
3363
  {
3183
3364
  id,
3184
3365
  checked: value === true,
@@ -3187,10 +3368,10 @@ function CheckboxControl({ field, value, onChange, disabled, id }) {
3187
3368
  onCheckedChange: (next) => onChange(next === true)
3188
3369
  }
3189
3370
  ),
3190
- unanswered ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-xs italic text-muted-foreground", children: "not answered yet" }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
3191
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-xs text-muted-foreground", children: value === true ? "Yes" : "No" }),
3192
- field.required ? null : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3193
- import_design_system13.Button,
3371
+ unanswered ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-xs italic text-muted-foreground", children: "not answered yet" }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
3372
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-xs text-muted-foreground", children: value === true ? "Yes" : "No" }),
3373
+ field.required ? null : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3374
+ import_design_system14.Button,
3194
3375
  {
3195
3376
  size: "sm",
3196
3377
  variant: "ghost",
@@ -3205,11 +3386,11 @@ function CheckboxControl({ field, value, onChange, disabled, id }) {
3205
3386
  }
3206
3387
  function JsonControl({ field, value, onChange, disabled, id }) {
3207
3388
  const initial = value === null || value === void 0 ? "" : typeof value === "string" ? value : JSON.stringify(value, null, 2);
3208
- const [text, setText] = (0, import_react22.useState)(initial);
3209
- const [broken, setBroken] = (0, import_react22.useState)(null);
3210
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-col gap-1", children: [
3211
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3212
- import_design_system13.BasicTextarea,
3389
+ const [text, setText] = (0, import_react24.useState)(initial);
3390
+ const [broken, setBroken] = (0, import_react24.useState)(null);
3391
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-col gap-1", children: [
3392
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3393
+ import_design_system14.BasicTextarea,
3213
3394
  {
3214
3395
  id,
3215
3396
  rows: 4,
@@ -3242,7 +3423,7 @@ function JsonControl({ field, value, onChange, disabled, id }) {
3242
3423
  ),
3243
3424
  broken ? (
3244
3425
  // The typed text is still in the box: the notice owns the two doors out.
3245
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3426
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3246
3427
  RefusalNotice,
3247
3428
  {
3248
3429
  error: broken,
@@ -3266,11 +3447,11 @@ function inTheStoresOrder(options) {
3266
3447
  return [...options].sort((a, b) => position(a) - position(b) || made(a).localeCompare(made(b)));
3267
3448
  }
3268
3449
  function OptionControl({ field, value, onChange, disabled, id, autoOpen, onClose, addsChoices, initialSearch, asForm }) {
3269
- const client = (0, import_react23.useOptionalRecordsClient)();
3270
- const [options, setOptions] = (0, import_react22.useState)(null);
3271
- const [refusal2, setRefusal] = (0, import_react22.useState)(null);
3272
- const [reread, setReread] = (0, import_react22.useState)(0);
3273
- (0, import_react22.useEffect)(() => {
3450
+ const client = (0, import_react25.useOptionalRecordsClient)();
3451
+ const [options, setOptions] = (0, import_react24.useState)(null);
3452
+ const [refusal2, setRefusal] = (0, import_react24.useState)(null);
3453
+ const [reread, setReread] = (0, import_react24.useState)(0);
3454
+ (0, import_react24.useEffect)(() => {
3274
3455
  if (!client) return;
3275
3456
  let cancelled = false;
3276
3457
  void client.fieldOptions({ field_id: field.id }).then((result) => {
@@ -3284,12 +3465,12 @@ function OptionControl({ field, value, onChange, disabled, id, autoOpen, onClose
3284
3465
  }, [client, field.id, reread]);
3285
3466
  const handed = publicChoicesOf(field);
3286
3467
  if (!client && handed.length > 0) {
3287
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChoiceAnswer, { field, choices: handed, value, onChange, disabled, id });
3468
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ChoiceAnswer, { field, choices: handed, value, onChange, disabled, id });
3288
3469
  }
3289
3470
  if (!client) {
3290
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-col gap-1", children: [
3291
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3292
- import_design_system13.BasicInput,
3471
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-col gap-1", children: [
3472
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3473
+ import_design_system14.BasicInput,
3293
3474
  {
3294
3475
  id,
3295
3476
  value: value === null || value === void 0 ? "" : String(value),
@@ -3297,15 +3478,15 @@ function OptionControl({ field, value, onChange, disabled, id, autoOpen, onClose
3297
3478
  onChange: (e) => onChange(e.target.value === "" ? null : e.target.value)
3298
3479
  }
3299
3480
  ),
3300
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-xs text-muted-foreground", children: "This is normally picked from a list. A page answered without an account cannot read that list, so type your answer and whoever receives it will match it up." })
3481
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-xs text-muted-foreground", children: "This is normally picked from a list. A page answered without an account cannot read that list, so type your answer and whoever receives it will match it up." })
3301
3482
  ] });
3302
3483
  }
3303
3484
  if (refusal2)
3304
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(RefusalLine, { error: refusal2 }) });
3305
- if (!options) return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { id, className: "text-xs text-muted-foreground", children: "Reading this field's choices\u2026" });
3485
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(RefusalLine, { error: refusal2 }) });
3486
+ if (!options) return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { id, className: "text-xs text-muted-foreground", children: "Reading this field's choices\u2026" });
3306
3487
  if (asForm && options.length > 0) {
3307
3488
  const titled = (option) => recordName(option.data, null, "Unnamed choice");
3308
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3489
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3309
3490
  ChoiceAnswer,
3310
3491
  {
3311
3492
  field,
@@ -3322,7 +3503,7 @@ function OptionControl({ field, value, onChange, disabled, id, autoOpen, onClose
3322
3503
  );
3323
3504
  }
3324
3505
  if (CHOICE_EDITOR_ADDS_WHAT_IS_TYPED) {
3325
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3506
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3326
3507
  OpenChoicePicker,
3327
3508
  {
3328
3509
  field,
@@ -3341,14 +3522,14 @@ function OptionControl({ field, value, onChange, disabled, id, autoOpen, onClose
3341
3522
  );
3342
3523
  }
3343
3524
  if (options.length === 0) {
3344
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { id, className: "text-xs text-muted-foreground", children: field.options_table_id ? `${fieldName(field)} takes its choices from a Table that has no records yet \u2014 add the choices there and they appear here.` : `${fieldName(field)} does not name the Table its choices come from yet, so there is nothing to choose. A table admin sets it in the field editor.` });
3525
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { id, className: "text-xs text-muted-foreground", children: field.options_table_id ? `${fieldName(field)} takes its choices from a Table that has no records yet \u2014 add the choices there and they appear here.` : `${fieldName(field)} does not name the Table its choices come from yet, so there is nothing to choose. A table admin sets it in the field editor.` });
3345
3526
  }
3346
3527
  const titleOf = (option) => recordName(option.data, null, "Unnamed choice");
3347
3528
  if (field.multi) {
3348
3529
  const chosen = options.filter((option) => (0, import_records10.choiceValuesOf)(value).some((v) => (0, import_records10.isTheChosen)(option, v)));
3349
3530
  const picked = new Set(chosen.map((option) => (0, import_records10.optionKey)(option)));
3350
- const toggles = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { id: autoOpen ? void 0 : id, className: "flex flex-wrap gap-1", children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3351
- import_design_system13.Button,
3531
+ const toggles = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { id: autoOpen ? void 0 : id, className: "flex flex-wrap gap-1", children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3532
+ import_design_system14.Button,
3352
3533
  {
3353
3534
  type: "button",
3354
3535
  size: "sm",
@@ -3365,23 +3546,23 @@ function OptionControl({ field, value, onChange, disabled, id, autoOpen, onClose
3365
3546
  option.id
3366
3547
  )) });
3367
3548
  if (!autoOpen) return toggles;
3368
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
3369
- import_design_system13.Popover,
3549
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
3550
+ import_design_system14.Popover,
3370
3551
  {
3371
3552
  defaultOpen: true,
3372
3553
  onOpenChange: (open) => {
3373
3554
  if (!open) onClose?.();
3374
3555
  },
3375
3556
  children: [
3376
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_design_system13.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_design_system13.Button, { id, type: "button", size: "sm", variant: "outline", className: "h-6 max-w-full truncate", children: chosen.length === 0 ? "Choose" : chosen.map(titleOf).join(", ") }) }),
3377
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_design_system13.PopoverContent, { sizing: "content", className: "max-w-[20rem] p-2", align: "start", children: toggles })
3557
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_design_system14.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_design_system14.Button, { id, type: "button", size: "sm", variant: "outline", className: "h-6 max-w-full truncate", children: chosen.length === 0 ? "Choose" : chosen.map(titleOf).join(", ") }) }),
3558
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_design_system14.PopoverContent, { sizing: "content", className: "max-w-[20rem] p-2", align: "start", children: toggles })
3378
3559
  ]
3379
3560
  }
3380
3561
  );
3381
3562
  }
3382
3563
  const current = options.find((option) => (0, import_records10.isTheChosen)(option, value));
3383
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
3384
- import_design_system13.Select,
3564
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
3565
+ import_design_system14.Select,
3385
3566
  {
3386
3567
  value: current ? (0, import_records10.optionKey)(current) : "",
3387
3568
  disabled: disabled ?? false,
@@ -3394,8 +3575,8 @@ function OptionControl({ field, value, onChange, disabled, id, autoOpen, onClose
3394
3575
  }
3395
3576
  } : {},
3396
3577
  children: [
3397
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_design_system13.SelectTrigger, { id, size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_design_system13.SelectValue, { placeholder: "Choose" }) }),
3398
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_design_system13.SelectContent, { children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_design_system13.SelectItem, { value: (0, import_records10.optionKey)(option), children: titleOf(option) }, option.id)) })
3578
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_design_system14.SelectTrigger, { id, size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_design_system14.SelectValue, { placeholder: "Choose" }) }),
3579
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_design_system14.SelectContent, { children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_design_system14.SelectItem, { value: (0, import_records10.optionKey)(option), children: titleOf(option) }, option.id)) })
3399
3580
  ]
3400
3581
  }
3401
3582
  );
@@ -3414,18 +3595,18 @@ function OpenChoicePicker({
3414
3595
  allowOther = true,
3415
3596
  onChoicesChanged
3416
3597
  }) {
3417
- const client = (0, import_react23.useOptionalRecordsClient)();
3598
+ const client = (0, import_react25.useOptionalRecordsClient)();
3418
3599
  const nudge = useChoiceNudge();
3419
- const [open, setOpenState] = (0, import_react22.useState)(autoOpen === true);
3420
- const onCloseRef = (0, import_react22.useRef)(onClose);
3600
+ const [open, setOpenState] = (0, import_react24.useState)(autoOpen === true);
3601
+ const onCloseRef = (0, import_react24.useRef)(onClose);
3421
3602
  onCloseRef.current = onClose;
3422
- const setOpen = (0, import_react22.useCallback)((next) => {
3603
+ const setOpen = (0, import_react24.useCallback)((next) => {
3423
3604
  setOpenState(next);
3424
3605
  if (!next) onCloseRef.current?.();
3425
3606
  }, []);
3426
- const [search, setSearch] = (0, import_react22.useState)(initialSearch ?? "");
3427
- const [adding, setAdding] = (0, import_react22.useState)(false);
3428
- const [addRefused, setAddRefused] = (0, import_react22.useState)(null);
3607
+ const [search, setSearch] = (0, import_react24.useState)(initialSearch ?? "");
3608
+ const [adding, setAdding] = (0, import_react24.useState)(false);
3609
+ const [addRefused, setAddRefused] = (0, import_react24.useState)(null);
3429
3610
  const titleOf = (option) => recordName(option.data, null, "Unnamed choice");
3430
3611
  const held = withoutAddition(value);
3431
3612
  const current = (0, import_records10.choiceValuesOf)(held.value);
@@ -3477,7 +3658,7 @@ function OpenChoicePicker({
3477
3658
  });
3478
3659
  };
3479
3660
  const offList = q !== "" && decided.decision !== "chosen" && decided.decision !== "empty";
3480
- const foot = offList && decided.decision === "ask" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3661
+ const foot = offList && decided.decision === "ask" ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3481
3662
  ChoiceAskButtons,
3482
3663
  {
3483
3664
  field,
@@ -3494,14 +3675,14 @@ function OpenChoicePicker({
3494
3675
  }
3495
3676
  ) : null;
3496
3677
  const add = offList && decided.decision === "add" ? { label: `Add \u201C${q}\u201D to the choices`, onAdd: addTyped, disabled: adding } : offList && decided.decision === "keep_as_typed" ? { label: `Keep \u201C${q}\u201D as typed`, onAdd: () => choose(q) } : null;
3497
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { id, className: "flex flex-wrap items-center gap-1", children: [
3678
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { id, className: "flex flex-wrap items-center gap-1", children: [
3498
3679
  pickedWords.map((word, i) => {
3499
3680
  const chip = chipOf(options.find((o) => (0, import_records10.isTheChosen)(o, current[i])), word);
3500
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_design_system13.Badge, { variant: "outline", className: (0, import_design_system13.cn)("text-[11px]", chip.className), "data-records-choice-chip": "", children: word }, word);
3681
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_design_system14.Badge, { variant: "outline", className: (0, import_design_system14.cn)("text-[11px]", chip.className), "data-records-choice-chip": "", children: word }, word);
3501
3682
  }),
3502
3683
  disabled ? null : (
3503
3684
  // THE ONE "PICK OR ADD" BUILDER (PickOrAdd.tsx) — the relation picker draws the same one.
3504
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3685
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3505
3686
  PickOrAdd,
3506
3687
  {
3507
3688
  triggerLabel: `Pick for ${fieldName(field)}`,
@@ -3523,15 +3704,15 @@ function OpenChoicePicker({
3523
3704
  const option = options.find((o) => o.id === optionId);
3524
3705
  if (option) choose((0, import_records10.optionKey)(option));
3525
3706
  },
3526
- empty: q === "" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "p-2 text-xs text-muted-foreground", children: "No choices yet \u2014 type one to add it." }) : null,
3707
+ empty: q === "" ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "p-2 text-xs text-muted-foreground", children: "No choices yet \u2014 type one to add it." }) : null,
3527
3708
  add,
3528
3709
  foot,
3529
3710
  ...offList && decided.decision === "ask" && !adding ? { onEnterWithNoMatch: addTyped } : {},
3530
- footNote: addRefused ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(RefusalLine, { error: addRefused }) : offList && decided.decision === "not_a_choice" ? (
3711
+ footNote: addRefused ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(RefusalLine, { error: addRefused }) : offList && decided.decision === "not_a_choice" ? (
3531
3712
  // never_add on a column that takes only its choices: said, never a silent nothing.
3532
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
3533
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { "data-records-typed-refusal": "", className: "p-2 text-xs text-muted-foreground", children: notAChoiceSentence(field, [q]) }),
3534
- autoOpen ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { "data-records-choice-ask": "", className: "px-2 pb-1", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_design_system13.Button, { type: "button", size: "sm", variant: "ghost", className: "h-6 px-2 text-xs", onClick: () => setOpen(false), children: "Cancel" }) }) : null
3713
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
3714
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { "data-records-typed-refusal": "", className: "p-2 text-xs text-muted-foreground", children: notAChoiceSentence(field, [q]) }),
3715
+ autoOpen ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { "data-records-choice-ask": "", className: "px-2 pb-1", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_design_system14.Button, { type: "button", size: "sm", variant: "ghost", className: "h-6 px-2 text-xs", onClick: () => setOpen(false), children: "Cancel" }) }) : null
3535
3716
  ] })
3536
3717
  ) : null
3537
3718
  }
@@ -3550,9 +3731,9 @@ function RecordChip({
3550
3731
  // name. So it caps at its container and ends in an ellipsis with the whole name in
3551
3732
  // its tooltip, rather than being cut mid-word by whatever box it landed in
3552
3733
  // (lane FIX-14, 2026-09-22).
3553
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_design_system13.Badge, { variant: "secondary", className: (0, import_design_system13.cn)("max-w-full gap-1 text-[11px]", className), title, children: [
3554
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "min-w-0 truncate", children: title }),
3555
- onRemove ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", onClick: onRemove, "aria-label": `Remove ${title}`, className: "shrink-0 opacity-60 hover:opacity-100", children: "\xD7" }) : null
3734
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_design_system14.Badge, { variant: "secondary", className: (0, import_design_system14.cn)("max-w-full gap-1 text-[11px]", className), title, children: [
3735
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "min-w-0 truncate", children: title }),
3736
+ onRemove ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", onClick: onRemove, "aria-label": `Remove ${title}`, className: "shrink-0 opacity-60 hover:opacity-100", children: "\xD7" }) : null
3556
3737
  ] })
3557
3738
  );
3558
3739
  }
@@ -3564,7 +3745,8 @@ function publicChoicesOf(field) {
3564
3745
  return typeof o.key === "string" && typeof o.label === "string" ? [{ key: o.key, label: o.label }] : [];
3565
3746
  });
3566
3747
  }
3567
- var FORM_PILL_LIMIT = 4;
3748
+ var FORM_SEARCH_AFTER = 8;
3749
+ var CHOICE_LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
3568
3750
  function ChoiceAnswer({
3569
3751
  field,
3570
3752
  choices,
@@ -3574,7 +3756,7 @@ function ChoiceAnswer({
3574
3756
  id,
3575
3757
  isChosen
3576
3758
  }) {
3577
- const [search, setSearch] = (0, import_react22.useState)("");
3759
+ const [search, setSearch] = (0, import_react24.useState)("");
3578
3760
  const held = field.multi ? (0, import_records10.choiceValuesOf)(value) : value === null || value === void 0 || value === "" ? [] : [value];
3579
3761
  const on = (choice) => held.some((v) => isChosen ? isChosen(choice, v) : String(v) === choice.key || String(v) === choice.label);
3580
3762
  const press = (choice) => {
@@ -3585,71 +3767,90 @@ function ChoiceAnswer({
3585
3767
  const keys = choices.filter((c) => c.key === choice.key ? !on(c) : on(c)).map((c) => c.key);
3586
3768
  onChange(keys.length === 0 ? null : keys);
3587
3769
  };
3588
- const pill = (choice) => {
3770
+ const lettered = choices.length <= CHOICE_LETTERS.length;
3771
+ const option = (choice) => {
3589
3772
  const chosen = on(choice);
3590
- const look = choiceChipLookOf(field, choice.key, choice.label);
3591
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
3773
+ const letter = lettered ? CHOICE_LETTERS[choices.indexOf(choice)] : null;
3774
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
3592
3775
  "button",
3593
3776
  {
3594
3777
  type: "button",
3595
3778
  role: field.multi ? "checkbox" : "radio",
3596
3779
  "aria-checked": chosen,
3780
+ "aria-label": choice.label,
3597
3781
  disabled,
3598
3782
  onClick: () => press(choice),
3599
- "data-records-choice-chip": "",
3600
3783
  "data-records-choice-answer": choice.key,
3601
- className: (0, import_design_system13.cn)(
3602
- "inline-flex min-h-11 max-w-full items-center gap-1 rounded-md border px-3 text-sm font-medium sm:min-h-8 sm:px-2.5 sm:text-xs",
3603
- look.className,
3604
- chosen ? "ring-2 ring-ring ring-offset-1" : "opacity-80 hover:opacity-100"
3784
+ className: (0, import_design_system14.cn)(
3785
+ "flex min-h-11 w-full items-center gap-3 rounded-md border px-3 py-2 text-left text-base font-medium text-foreground transition-colors sm:min-h-10 sm:text-sm",
3786
+ chosen ? "border-primary bg-primary/10" : "border-primary/30 bg-primary/[0.03] hover:bg-primary/10"
3605
3787
  ),
3606
3788
  children: [
3607
- chosen ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { "aria-hidden": "true", children: "\u2713" }) : null,
3608
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "truncate", children: choice.label })
3789
+ letter ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3790
+ "kbd",
3791
+ {
3792
+ "aria-hidden": "true",
3793
+ className: (0, import_design_system14.cn)(
3794
+ "inline-flex h-6 w-6 shrink-0 items-center justify-center rounded border font-sans text-xs font-semibold",
3795
+ chosen ? "border-primary bg-primary text-primary-foreground" : "border-primary/40 text-primary"
3796
+ ),
3797
+ children: letter
3798
+ }
3799
+ ) : null,
3800
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "min-w-0 flex-1 break-words", children: choice.label }),
3801
+ chosen ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { "aria-hidden": "true", className: "shrink-0 text-primary", children: "\u2713" }) : null
3609
3802
  ]
3610
3803
  },
3611
3804
  choice.key
3612
3805
  );
3613
3806
  };
3614
- const group = { role: field.multi ? "group" : "radiogroup", "aria-label": fieldName(field) };
3615
- if (choices.length <= FORM_PILL_LIMIT) {
3616
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { id, className: "flex flex-wrap gap-1.5", ...group, children: choices.map(pill) });
3807
+ const onKeyDown = (event) => {
3808
+ if (!lettered || disabled || event.metaKey || event.ctrlKey || event.altKey) return;
3809
+ if (event.target.tagName === "INPUT") return;
3810
+ const at = CHOICE_LETTERS.indexOf(event.key.toUpperCase());
3811
+ if (event.key.length !== 1 || at < 0 || at >= choices.length) return;
3812
+ event.preventDefault();
3813
+ press(choices[at]);
3814
+ };
3815
+ const group = { role: field.multi ? "group" : "radiogroup", "aria-label": fieldName(field), onKeyDown };
3816
+ if (choices.length <= FORM_SEARCH_AFTER) {
3817
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { id, className: "flex w-full flex-col gap-2", ...group, children: choices.map(option) });
3617
3818
  }
3618
3819
  const q = search.trim().toLowerCase();
3619
3820
  const shown2 = q === "" ? choices : choices.filter((c) => c.label.toLowerCase().includes(q));
3620
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { id, className: "flex flex-col gap-1.5", children: [
3621
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3622
- import_design_system13.BasicInput,
3821
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { id, className: "flex w-full flex-col gap-2", onKeyDown, children: [
3822
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3823
+ import_design_system14.BasicInput,
3623
3824
  {
3624
3825
  value: search,
3625
3826
  onChange: (e) => setSearch(e.target.value),
3626
3827
  placeholder: "Search",
3627
3828
  "aria-label": `Search \u2014 ${fieldName(field)}`,
3628
3829
  autoComplete: "off",
3629
- className: "h-11 text-base sm:h-8 sm:text-xs"
3830
+ className: "h-11 text-base sm:h-9 sm:text-sm"
3630
3831
  }
3631
3832
  ),
3632
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex max-h-56 flex-wrap content-start gap-1.5 overflow-y-auto", ...group, children: [
3633
- shown2.map(pill),
3634
- shown2.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-xs text-muted-foreground", children: "No match" }) : null
3833
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex max-h-80 w-full flex-col gap-2 overflow-y-auto", role: group.role, "aria-label": group["aria-label"], children: [
3834
+ shown2.map(option),
3835
+ shown2.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-xs text-muted-foreground", children: "No match" }) : null
3635
3836
  ] })
3636
3837
  ] });
3637
3838
  }
3638
3839
 
3639
3840
  // src/RecordsMount.tsx
3640
- var import_react24 = require("react");
3641
- var import_react25 = require("@ai-matrx/records/react");
3642
- var import_jsx_runtime16 = require("react/jsx-runtime");
3841
+ var import_react26 = require("react");
3842
+ var import_react27 = require("@ai-matrx/records/react");
3843
+ var import_jsx_runtime17 = require("react/jsx-runtime");
3643
3844
  function personActor(userId) {
3644
3845
  return userId ? { actor: "user", user_id: userId } : { actor: "user" };
3645
3846
  }
3646
3847
 
3647
3848
  // src/tablePicking.tsx
3648
- var import_react26 = require("react");
3849
+ var import_react28 = require("react");
3649
3850
  var import_records11 = require("@ai-matrx/records");
3650
- var import_react27 = require("@ai-matrx/records/react");
3651
- var import_design_system14 = require("@ai-matrx/design-system");
3652
- var import_jsx_runtime17 = require("react/jsx-runtime");
3851
+ var import_react29 = require("@ai-matrx/records/react");
3852
+ var import_design_system15 = require("@ai-matrx/design-system");
3853
+ var import_jsx_runtime18 = require("react/jsx-runtime");
3653
3854
  var APP_TABLE_PREFIX = "records_ui_";
3654
3855
  function isValueSet(table) {
3655
3856
  if (table.kept_for === "choices") return true;
@@ -3692,10 +3893,10 @@ function madeOn(stamp) {
3692
3893
  }
3693
3894
 
3694
3895
  // src/TablePickers.tsx
3695
- var import_jsx_runtime18 = require("react/jsx-runtime");
3896
+ var import_jsx_runtime19 = require("react/jsx-runtime");
3696
3897
  function useTablesAnywhere(dataSource) {
3697
- const [state, setState] = (0, import_react28.useState)({ loading: true, error: null, rows: [] });
3698
- (0, import_react28.useEffect)(() => {
3898
+ const [state, setState] = (0, import_react30.useState)({ loading: true, error: null, rows: [] });
3899
+ (0, import_react30.useEffect)(() => {
3699
3900
  let live = true;
3700
3901
  void Promise.resolve(dataSource.rpc("data_home_tables", {}, { schema: "custom" })).then(
3701
3902
  ({ data, error }) => {
@@ -3732,9 +3933,9 @@ function TablePicker({ dataSource, value, onChange, disabled, tables }) {
3732
3933
  keywords: t.organization_name
3733
3934
  }));
3734
3935
  const missing = Boolean(value) && !list.loading && !list.error && !list.rows.some((t) => t.table_id === value);
3735
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-1", children: [
3736
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3737
- import_design_system15.CreatablePicker,
3936
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex flex-col gap-1", children: [
3937
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3938
+ import_design_system16.CreatablePicker,
3738
3939
  {
3739
3940
  value: value || null,
3740
3941
  options,
@@ -3747,23 +3948,23 @@ function TablePicker({ dataSource, value, onChange, disabled, tables }) {
3747
3948
  ariaLabel: "Table"
3748
3949
  }
3749
3950
  ),
3750
- list.error && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(RefusalLine, { error: refusal("door", list.error, "Try again in a moment.") }),
3751
- missing && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { className: "text-[11px] text-destructive", children: "This table is archived or not shared with you." })
3951
+ list.error && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(RefusalLine, { error: refusal("door", list.error, "Try again in a moment.") }),
3952
+ missing && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "text-[11px] text-destructive", children: "This table is archived or not shared with you." })
3752
3953
  ] });
3753
3954
  }
3754
3955
  function TableScope({ dataSource, userId, tableId, children, fallback = null, tables }) {
3755
3956
  const own3 = useTablesAnywhere(dataSource);
3756
3957
  const list = tables ?? own3;
3757
3958
  const organizationId = list.rows.find((t) => t.table_id === tableId)?.organization_id ?? null;
3758
- if (!tableId || !organizationId) return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children: fallback });
3759
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react29.RecordsProvider, { config: { dataSource, actor: personActor(userId), organizationId }, children });
3959
+ if (!tableId || !organizationId) return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children: fallback });
3960
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react31.RecordsProvider, { config: { dataSource, actor: personActor(userId), organizationId }, children });
3760
3961
  }
3761
3962
  function ColumnValuesEditor({ tableId, value, onChange, disabled, addLabel }) {
3762
- const fields = (0, import_react29.useFields)(tableId);
3763
- const all = (0, import_react28.useMemo)(() => fields.data ?? [], [fields.data]);
3764
- const byKey = (0, import_react28.useMemo)(() => new Map(all.map((f) => [f.key, f])), [all]);
3963
+ const fields = (0, import_react31.useFields)(tableId);
3964
+ const all = (0, import_react30.useMemo)(() => fields.data ?? [], [fields.data]);
3965
+ const byKey = (0, import_react30.useMemo)(() => new Map(all.map((f) => [f.key, f])), [all]);
3765
3966
  const keys = Object.keys(value);
3766
- const [adding, setAdding] = (0, import_react28.useState)(false);
3967
+ const [adding, setAdding] = (0, import_react30.useState)(false);
3767
3968
  const optionsFor = (current) => all.filter((f) => f.key === current || !(f.key in value)).map((f) => ({ value: f.key, label: fieldName(f) }));
3768
3969
  const rename = (from, to) => {
3769
3970
  if (from === to) return;
@@ -3776,11 +3977,11 @@ function ColumnValuesEditor({ tableId, value, onChange, disabled, addLabel }) {
3776
3977
  void _gone;
3777
3978
  onChange(rest);
3778
3979
  };
3779
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-2", children: [
3780
- fields.error && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(RefusalLine, { error: fields.error }),
3980
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex flex-col gap-2", children: [
3981
+ fields.error && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(RefusalLine, { error: fields.error }),
3781
3982
  keys.map((key) => {
3782
3983
  const field = byKey.get(key);
3783
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3984
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3784
3985
  ColumnValueRow,
3785
3986
  {
3786
3987
  columnKey: key,
@@ -3796,7 +3997,7 @@ function ColumnValuesEditor({ tableId, value, onChange, disabled, addLabel }) {
3796
3997
  key
3797
3998
  );
3798
3999
  }),
3799
- adding && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4000
+ adding && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3800
4001
  ColumnValueRow,
3801
4002
  {
3802
4003
  columnKey: null,
@@ -3813,7 +4014,7 @@ function ColumnValuesEditor({ tableId, value, onChange, disabled, addLabel }) {
3813
4014
  onRemove: () => setAdding(false)
3814
4015
  }
3815
4016
  ),
3816
- !disabled && !adding && keys.length < all.length && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_design_system15.Button, { type: "button", variant: "outline", size: "sm", className: "self-start", onClick: () => setAdding(true), children: addLabel })
4017
+ !disabled && !adding && keys.length < all.length && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_design_system16.Button, { type: "button", variant: "outline", size: "sm", className: "self-start", onClick: () => setAdding(true), children: addLabel })
3817
4018
  ] });
3818
4019
  }
3819
4020
  function ColumnValueRow({
@@ -3829,10 +4030,10 @@ function ColumnValueRow({
3829
4030
  }) {
3830
4031
  const orphan = columnKey !== null && !loading && field === void 0;
3831
4032
  const shown2 = orphan ? [{ value: columnKey, label: columnKey, hint: "Not a column" }, ...options] : options;
3832
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-1 rounded-md border border-border/60 p-2", children: [
3833
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-2", children: [
3834
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3835
- import_design_system15.CreatablePicker,
4033
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex flex-col gap-1 rounded-md border border-border/60 p-2", children: [
4034
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-2", children: [
4035
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
4036
+ import_design_system16.CreatablePicker,
3836
4037
  {
3837
4038
  value: columnKey,
3838
4039
  options: shown2,
@@ -3845,23 +4046,23 @@ function ColumnValueRow({
3845
4046
  ariaLabel: "Column"
3846
4047
  }
3847
4048
  ) }),
3848
- !disabled && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_design_system15.Button, { type: "button", variant: "ghost", size: "sm", "aria-label": "Remove", onClick: onRemove, children: "\u2715" })
4049
+ !disabled && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_design_system16.Button, { type: "button", variant: "ghost", size: "sm", "aria-label": "Remove", onClick: onRemove, children: "\u2715" })
3849
4050
  ] }),
3850
- field ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FieldControl, { field, value, onChange: onValue, disabled }) : orphan ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { className: "text-[11px] text-muted-foreground", children: value === null || value === void 0 ? "\u2014" : String(value) }) : null
4051
+ field ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(FieldControl, { field, value, onChange: onValue, disabled }) : orphan ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "text-[11px] text-muted-foreground", children: value === null || value === void 0 ? "\u2014" : String(value) }) : null
3851
4052
  ] });
3852
4053
  }
3853
4054
  function RecordPicker({ tableId, value, onChange, disabled }) {
3854
- const table = (0, import_react29.useTable)(tableId);
3855
- const records = (0, import_react29.useRecords)(tableId, { pageSize: 200 });
4055
+ const table = (0, import_react31.useTable)(tableId);
4056
+ const records = (0, import_react31.useRecords)(tableId, { pageSize: 200 });
3856
4057
  const rows = records.data?.rows ?? [];
3857
4058
  const options = rows.map((row) => ({
3858
4059
  value: row.id,
3859
4060
  label: rowNameIn(table.data ?? null, row)
3860
4061
  }));
3861
4062
  const missing = Boolean(value) && !records.loading && !records.error && !rows.some((r) => r.id === value);
3862
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-1", children: [
3863
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3864
- import_design_system15.CreatablePicker,
4063
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex flex-col gap-1", children: [
4064
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
4065
+ import_design_system16.CreatablePicker,
3865
4066
  {
3866
4067
  value: value || null,
3867
4068
  options,
@@ -3874,16 +4075,16 @@ function RecordPicker({ tableId, value, onChange, disabled }) {
3874
4075
  ariaLabel: "Record"
3875
4076
  }
3876
4077
  ),
3877
- records.error && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(RefusalLine, { error: records.error })
4078
+ records.error && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(RefusalLine, { error: records.error })
3878
4079
  ] });
3879
4080
  }
3880
4081
 
3881
4082
  // src/DataBindingPicker.tsx
3882
- var import_react30 = require("react");
4083
+ var import_react32 = require("react");
3883
4084
  var import_records12 = require("@ai-matrx/records");
3884
- var import_react31 = require("@ai-matrx/records/react");
3885
- var import_design_system16 = require("@ai-matrx/design-system");
3886
- var import_jsx_runtime19 = require("react/jsx-runtime");
4085
+ var import_react33 = require("@ai-matrx/records/react");
4086
+ var import_design_system17 = require("@ai-matrx/design-system");
4087
+ var import_jsx_runtime20 = require("react/jsx-runtime");
3887
4088
  var DATA_BINDING_SHAPES = [
3888
4089
  { value: "collection", label: "The whole table" },
3889
4090
  { value: "reference", label: "One record" },
@@ -3950,9 +4151,9 @@ function DataBindingPicker({ dataSource, userId, binding, onChange, disabled, de
3950
4151
  ...binding.semantic_type === "collection" && defaultRowLimit ? { limit: defaultRowLimit } : {}
3951
4152
  });
3952
4153
  };
3953
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex flex-col gap-2", children: [
3954
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(TablePicker, { dataSource, value: tableId, onChange: selectTable, disabled: Boolean(disabled), tables }),
3955
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(TableScope, { dataSource, userId, tableId, tables, children: tableId && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
4154
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex flex-col gap-2", children: [
4155
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(TablePicker, { dataSource, value: tableId, onChange: selectTable, disabled: Boolean(disabled), tables }),
4156
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(TableScope, { dataSource, userId, tableId, tables, children: tableId && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
3956
4157
  BindingDetails,
3957
4158
  {
3958
4159
  tableId,
@@ -3971,11 +4172,11 @@ function BindingDetails({
3971
4172
  disabled,
3972
4173
  defaultRowLimit
3973
4174
  }) {
3974
- const table = (0, import_react31.useTable)(tableId);
3975
- const fields = (0, import_react31.useFields)(tableId);
3976
- const fieldList = (0, import_react30.useMemo)(() => fields.data ?? [], [fields.data]);
4175
+ const table = (0, import_react33.useTable)(tableId);
4176
+ const fields = (0, import_react33.useFields)(tableId);
4177
+ const fieldList = (0, import_react32.useMemo)(() => fields.data ?? [], [fields.data]);
3977
4178
  const shape = binding.semantic_type;
3978
- (0, import_react30.useEffect)(() => {
4179
+ (0, import_react32.useEffect)(() => {
3979
4180
  if (disabled || shape === "value" || binding.transform || fields.loading || fieldList.length === 0) return;
3980
4181
  onChange({
3981
4182
  ...binding,
@@ -4016,9 +4217,9 @@ function BindingDetails({
4016
4217
  const fieldOptions = fieldList.map((f) => ({ value: f.key, label: fieldName(f) }));
4017
4218
  const template = binding.transform?.template ?? "";
4018
4219
  const setTemplate = (next) => onChange({ ...binding, transform: { join: "\n", ...binding.transform, name: "list", template: next } });
4019
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex flex-col gap-2", children: [
4020
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "flex flex-wrap gap-1", role: "radiogroup", "aria-label": "What to read", children: DATA_BINDING_SHAPES.map((s) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
4021
- import_design_system16.Button,
4220
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex flex-col gap-2", children: [
4221
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "flex flex-wrap gap-1", role: "radiogroup", "aria-label": "What to read", children: DATA_BINDING_SHAPES.map((s) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4222
+ import_design_system17.Button,
4022
4223
  {
4023
4224
  type: "button",
4024
4225
  size: "sm",
@@ -4031,7 +4232,7 @@ function BindingDetails({
4031
4232
  },
4032
4233
  s.value
4033
4234
  )) }),
4034
- shape !== "collection" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
4235
+ shape !== "collection" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4035
4236
  RecordPicker,
4036
4237
  {
4037
4238
  tableId,
@@ -4040,8 +4241,8 @@ function BindingDetails({
4040
4241
  disabled: Boolean(disabled)
4041
4242
  }
4042
4243
  ),
4043
- shape === "value" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
4044
- import_design_system16.CreatablePicker,
4244
+ shape === "value" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4245
+ import_design_system17.CreatablePicker,
4045
4246
  {
4046
4247
  value: binding.field_key ?? null,
4047
4248
  options: fieldOptions,
@@ -4054,11 +4255,11 @@ function BindingDetails({
4054
4255
  ariaLabel: "Column"
4055
4256
  }
4056
4257
  ),
4057
- shape !== "value" && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex flex-col gap-1", children: [
4058
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
4258
+ shape !== "value" && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex flex-col gap-1", children: [
4259
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4059
4260
  "textarea",
4060
4261
  {
4061
- className: (0, import_design_system16.cn)(
4262
+ className: (0, import_design_system17.cn)(
4062
4263
  "min-h-[3.5rem] w-full rounded-md border border-border bg-background px-2 py-1.5 font-mono text-xs"
4063
4264
  ),
4064
4265
  "aria-label": "Each row reads as",
@@ -4067,8 +4268,8 @@ function BindingDetails({
4067
4268
  onChange: (e) => setTemplate(e.target.value)
4068
4269
  }
4069
4270
  ),
4070
- !disabled && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "flex flex-wrap gap-1", children: fieldList.flatMap(bindingPlaceholdersFor).map((p) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
4071
- import_design_system16.Button,
4271
+ !disabled && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "flex flex-wrap gap-1", children: fieldList.flatMap(bindingPlaceholdersFor).map((p) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4272
+ import_design_system17.Button,
4072
4273
  {
4073
4274
  type: "button",
4074
4275
  size: "sm",
@@ -4080,10 +4281,10 @@ function BindingDetails({
4080
4281
  p.token
4081
4282
  )) })
4082
4283
  ] }),
4083
- shape === "collection" && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("label", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
4284
+ shape === "collection" && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
4084
4285
  "Up to",
4085
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
4086
- import_design_system16.BasicInput,
4286
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4287
+ import_design_system17.BasicInput,
4087
4288
  {
4088
4289
  type: "number",
4089
4290
  min: 1,
@@ -4099,10 +4300,10 @@ function BindingDetails({
4099
4300
  ),
4100
4301
  "rows"
4101
4302
  ] }),
4102
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex flex-wrap items-center gap-1", role: "radiogroup", "aria-label": "If nothing is found", children: [
4103
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "text-xs text-muted-foreground", children: "If nothing is found" }),
4104
- DATA_BINDING_MISSING.map((m) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
4105
- import_design_system16.Button,
4303
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex flex-wrap items-center gap-1", role: "radiogroup", "aria-label": "If nothing is found", children: [
4304
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-xs text-muted-foreground", children: "If nothing is found" }),
4305
+ DATA_BINDING_MISSING.map((m) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4306
+ import_design_system17.Button,
4106
4307
  {
4107
4308
  type: "button",
4108
4309
  size: "sm",
@@ -4120,12 +4321,12 @@ function BindingDetails({
4120
4321
  }
4121
4322
 
4122
4323
  // src/PickedSummaries.tsx
4123
- var import_react33 = require("@ai-matrx/records/react");
4324
+ var import_react35 = require("@ai-matrx/records/react");
4124
4325
 
4125
4326
  // src/values.tsx
4126
4327
  var import_data_table4 = require("@ai-matrx/design-system/data-table");
4127
4328
  var import_field_formats5 = require("@ai-matrx/design-system/field-formats");
4128
- var import_design_system19 = require("@ai-matrx/design-system");
4329
+ var import_design_system20 = require("@ai-matrx/design-system");
4129
4330
 
4130
4331
  // src/enumLabels.ts
4131
4332
  function exhaustiveValuesOf() {
@@ -4162,10 +4363,10 @@ var ABSENCE_WORD_LABEL = {
4162
4363
  var import_core2 = require("@ai-matrx/records/core");
4163
4364
 
4164
4365
  // src/WholeValue.tsx
4165
- var import_react32 = require("react");
4366
+ var import_react34 = require("react");
4166
4367
  var import_core = require("@ai-matrx/records/core");
4167
- var import_design_system17 = require("@ai-matrx/design-system");
4168
- var import_jsx_runtime20 = require("react/jsx-runtime");
4368
+ var import_design_system18 = require("@ai-matrx/design-system");
4369
+ var import_jsx_runtime21 = require("react/jsx-runtime");
4169
4370
  var WHOLE_VALUE_UNBOUND = "The whole text is kept as a file, and this screen has no way to open files yet.";
4170
4371
  function wholeValueLine(pointer) {
4171
4372
  return `Open the whole text (${(0, import_core.wholeValueSize)(pointer)})`;
@@ -4174,18 +4375,18 @@ function WholeValueCell({ words, pointer }) {
4174
4375
  const host = useRecordsUi();
4175
4376
  const href = host.hrefForFile?.({ fileId: pointer.file_id });
4176
4377
  const line = wholeValueLine(pointer);
4177
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { className: "flex min-w-0 items-baseline gap-2", "data-whole-value-file": pointer.file_id, children: [
4178
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { className: "truncate", title: `The first ${pointer.shown_chars} of ${pointer.chars} characters`, children: [
4378
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "flex min-w-0 items-baseline gap-2", "data-whole-value-file": pointer.file_id, children: [
4379
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "truncate", title: `The first ${pointer.shown_chars} of ${pointer.chars} characters`, children: [
4179
4380
  words,
4180
4381
  "\u2026"
4181
4382
  ] }),
4182
- href ? host.Link ? host.Link({ href, children: line, className: "shrink-0 text-xs text-primary underline-offset-2 hover:underline" }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("a", { className: "shrink-0 text-xs text-primary underline-offset-2 hover:underline", href, target: "_blank", rel: "noreferrer", children: line }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "shrink-0 text-xs italic text-muted-foreground", title: WHOLE_VALUE_UNBOUND, children: `${(0, import_core.wholeValueSize)(pointer)} in a file` })
4383
+ href ? host.Link ? host.Link({ href, children: line, className: "shrink-0 text-xs text-primary underline-offset-2 hover:underline" }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("a", { className: "shrink-0 text-xs text-primary underline-offset-2 hover:underline", href, target: "_blank", rel: "noreferrer", children: line }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "shrink-0 text-xs italic text-muted-foreground", title: WHOLE_VALUE_UNBOUND, children: `${(0, import_core.wholeValueSize)(pointer)} in a file` })
4183
4384
  ] });
4184
4385
  }
4185
4386
 
4186
4387
  // src/ReferenceChips.tsx
4187
4388
  var import_records13 = require("@ai-matrx/records");
4188
- var import_design_system18 = require("@ai-matrx/design-system");
4389
+ var import_design_system19 = require("@ai-matrx/design-system");
4189
4390
 
4190
4391
  // src/kindValues.ts
4191
4392
  var import_directives = require("@ai-matrx/content-ir/directives");
@@ -4239,7 +4440,7 @@ function kindLabel(kind) {
4239
4440
  }
4240
4441
 
4241
4442
  // src/ReferenceChips.tsx
4242
- var import_jsx_runtime21 = require("react/jsx-runtime");
4443
+ var import_jsx_runtime22 = require("react/jsx-runtime");
4243
4444
  function referencesOf(field, value, kind, labels) {
4244
4445
  if (kind === "entity_reference") {
4245
4446
  return (0, import_records13.entityRefsOf)(value).map((r) => ({ token: r.token, id: r.id, label: r.label }));
@@ -4260,11 +4461,11 @@ function ReferenceChip({ reference, waiting }) {
4260
4461
  const host = useRecordsUi();
4261
4462
  const words = reference.label ?? (reference.token === "record" ? waiting ?? "Loading\u2026" : WITHHELD_ENTITY_LABEL);
4262
4463
  const drawn = host.renderReference ? host.renderReference({ ...reference, label: reference.label ?? words }) : null;
4263
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
4264
- import_design_system18.Badge,
4464
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
4465
+ import_design_system19.Badge,
4265
4466
  {
4266
4467
  variant: "secondary",
4267
- className: (0, import_design_system18.cn)(
4468
+ className: (0, import_design_system19.cn)(
4268
4469
  "max-w-full min-w-0 gap-1 px-1.5 py-0 text-[11px] font-normal",
4269
4470
  reference.archived && "opacity-70"
4270
4471
  ),
@@ -4272,15 +4473,15 @@ function ReferenceChip({ reference, waiting }) {
4272
4473
  "data-records-reference-archived": reference.archived ? "" : void 0,
4273
4474
  title: reference.archived ? ARCHIVED_REFERENCE_TIP : words,
4274
4475
  children: [
4275
- drawn ?? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "truncate", children: words }),
4276
- reference.archived ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "shrink-0 text-muted-foreground", children: ARCHIVED_REFERENCE_WORD }) : null
4476
+ drawn ?? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "truncate", children: words }),
4477
+ reference.archived ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "shrink-0 text-muted-foreground", children: ARCHIVED_REFERENCE_WORD }) : null
4277
4478
  ]
4278
4479
  }
4279
4480
  );
4280
4481
  }
4281
4482
  function ReferenceChips({ refs, waiting }) {
4282
- if (refs.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "text-muted-foreground", children: "\u2014" });
4283
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "flex min-w-0 flex-wrap gap-1", "data-records-reference-chips": "", children: refs.map((r) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ReferenceChip, { reference: r, waiting }, `${r.token}:${r.id}`)) });
4483
+ if (refs.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "text-muted-foreground", children: "\u2014" });
4484
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "flex min-w-0 flex-wrap gap-1", "data-records-reference-chips": "", children: refs.map((r) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ReferenceChip, { reference: r, waiting }, `${r.token}:${r.id}`)) });
4284
4485
  }
4285
4486
  function KindValueCell({
4286
4487
  kv,
@@ -4289,18 +4490,18 @@ function KindValueCell({
4289
4490
  }) {
4290
4491
  const host = useRecordsUi();
4291
4492
  if (host.renderKind) {
4292
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "flex min-w-0 max-w-full items-center", "data-records-kind-value": kv.kind, children: host.renderKind({ value: kv.value, kind: kv.kind, where, title }) });
4493
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "flex min-w-0 max-w-full items-center", "data-records-kind-value": kv.kind, children: host.renderKind({ value: kv.value, kind: kv.kind, where, title }) });
4293
4494
  }
4294
4495
  const named = kv.items.map(kindItemWords).filter((w) => w !== null);
4295
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: (0, import_design_system18.cn)("flex min-w-0 flex-wrap gap-1"), "data-records-kind-value": kv.kind, title: JSON.stringify(kv.value), children: named.length > 0 ? named.map((w, i) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_design_system18.Badge, { variant: "secondary", className: "px-1.5 py-0 text-[11px] font-normal", children: w }, `${w}-${i}`)) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_design_system18.Badge, { variant: "outline", className: "px-1.5 py-0 text-[11px] font-normal", children: kindLabel(kv.kind) }) });
4496
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: (0, import_design_system19.cn)("flex min-w-0 flex-wrap gap-1"), "data-records-kind-value": kv.kind, title: JSON.stringify(kv.value), children: named.length > 0 ? named.map((w, i) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_design_system19.Badge, { variant: "secondary", className: "px-1.5 py-0 text-[11px] font-normal", children: w }, `${w}-${i}`)) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_design_system19.Badge, { variant: "outline", className: "px-1.5 py-0 text-[11px] font-normal", children: kindLabel(kv.kind) }) });
4296
4497
  }
4297
4498
 
4298
4499
  // src/values.tsx
4299
4500
  var import_records14 = require("@ai-matrx/records");
4300
- var import_jsx_runtime22 = require("react/jsx-runtime");
4301
- function statusMark(field, item) {
4302
- const mark = statusMarkOf(field, item);
4303
- return mark ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { "aria-label": mark.words, title: mark.words, className: "mr-1", "data-records-status-group": mark.group, children: mark.mark }) : null;
4501
+ var import_jsx_runtime23 = require("react/jsx-runtime");
4502
+ function statusMark(field, item, document2) {
4503
+ const mark = statusMarkOf(field, item, document2);
4504
+ return mark ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { "aria-label": mark.words, title: mark.words, className: "mr-1", "data-records-status-group": mark.group, children: mark.mark }) : null;
4304
4505
  }
4305
4506
  function envelopeFor(document2, key) {
4306
4507
  const block = document2?._values;
@@ -4344,32 +4545,32 @@ var ABSENCE_WORDS = ABSENCE_WORD_LABEL;
4344
4545
  function renderValue(field, value, document2, labels, stillWaitingFor) {
4345
4546
  const envelope = envelopeFor(document2, field.key);
4346
4547
  if (envelope?.absent) {
4347
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "text-xs italic text-muted-foreground", title: `VAL-2: ${envelope.absent}`, children: ABSENCE_WORDS[String(envelope.absent)] ?? String(envelope.absent) });
4548
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "text-xs italic text-muted-foreground", title: `VAL-2: ${envelope.absent}`, children: ABSENCE_WORDS[String(envelope.absent)] ?? String(envelope.absent) });
4348
4549
  }
4349
4550
  if (value === null || value === void 0 || value === "") {
4350
4551
  const gone = unresolvedFor(document2, field.key);
4351
4552
  if (gone) {
4352
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "text-xs italic text-muted-foreground", title: `It pointed at ${gone}`, children: "The record this pointed at no longer exists" });
4553
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "text-xs italic text-muted-foreground", title: `It pointed at ${gone}`, children: "The record this pointed at no longer exists" });
4353
4554
  }
4354
4555
  const computed = computedEmptyOf(field, document2);
4355
- if (computed?.sentence) return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "text-xs italic text-muted-foreground", children: computed.sentence });
4356
- if (computed?.words) return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { "data-records-empty-why": computed.kind, children: computed.words });
4556
+ if (computed?.sentence) return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "text-xs italic text-muted-foreground", children: computed.sentence });
4557
+ if (computed?.words) return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { "data-records-empty-why": computed.kind, children: computed.words });
4357
4558
  if (computed?.why) {
4358
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "text-muted-foreground", title: computed.why, "data-records-empty-why": computed.kind, children: "\u2014" });
4559
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "text-muted-foreground", title: computed.why, "data-records-empty-why": computed.kind, children: "\u2014" });
4359
4560
  }
4360
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "text-muted-foreground", children: "\u2014" });
4561
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "text-muted-foreground", children: "\u2014" });
4361
4562
  }
4362
- if (isSignatureField(field)) return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SignatureValue, { value });
4563
+ if (isSignatureField(field)) return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(SignatureValue, { value, fieldKey: field.key, document: document2 });
4363
4564
  const newer = newerKindValue(field, value);
4364
4565
  if (newer !== void 0) return newer;
4365
4566
  const whole = typeof value === "string" ? (0, import_core2.wholeValueOf)(document2, field.key) : null;
4366
- if (whole) return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(WholeValueCell, { words: value, pointer: whole });
4567
+ if (whole) return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(WholeValueCell, { words: value, pointer: whole });
4367
4568
  const kind = editorKindFor(field);
4368
4569
  if (kind === "relation" || kind === "entity_reference") {
4369
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ReferenceChips, { refs: referencesOf(field, value, kind, labels), waiting: stillWaitingFor });
4570
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ReferenceChips, { refs: referencesOf(field, value, kind, labels), waiting: stillWaitingFor });
4370
4571
  }
4371
4572
  const kv = kind === "attachment" || kind === "member" ? null : kindValueOf(value);
4372
- if (kv) return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(KindValueCell, { kv, where: "cell", title: field.label });
4573
+ if (kv) return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(KindValueCell, { kv, where: "cell", title: field.label });
4373
4574
  const chosen = kind === "select" || kind === "multi_select";
4374
4575
  const chipOf = (item) => {
4375
4576
  const look = choiceChipLookOf(field, item, scalarText(field, item, labels));
@@ -4377,17 +4578,17 @@ function renderValue(field, value, document2, labels, stillWaitingFor) {
4377
4578
  };
4378
4579
  if (chosen) {
4379
4580
  const items = Array.isArray(value) ? value : [value];
4380
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "flex flex-wrap gap-1", "data-records-choice-chips": "", children: items.map((item, i) => {
4581
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "flex flex-wrap gap-1", "data-records-choice-chips": "", children: items.map((item, i) => {
4381
4582
  const chip = chipOf(item);
4382
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
4383
- import_design_system19.Badge,
4583
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
4584
+ import_design_system20.Badge,
4384
4585
  {
4385
4586
  variant: "outline",
4386
- className: (0, import_design_system19.cn)("text-[11px]", chip.className),
4587
+ className: (0, import_design_system20.cn)("text-[11px]", chip.className),
4387
4588
  "data-records-choice-chip": "",
4388
4589
  ...chip.tinted ? { "data-records-choice-tint": "" } : {},
4389
4590
  children: [
4390
- statusMark(field, item),
4591
+ statusMark(field, item, Array.isArray(value) ? void 0 : document2),
4391
4592
  scalarText(field, item, labels, Array.isArray(value) ? void 0 : stillWaitingFor)
4392
4593
  ]
4393
4594
  },
@@ -4395,13 +4596,13 @@ function renderValue(field, value, document2, labels, stillWaitingFor) {
4395
4596
  );
4396
4597
  }) });
4397
4598
  }
4398
- if (kind === "attachment") return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(AttachmentChips, { value });
4599
+ if (kind === "attachment") return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(AttachmentChips, { value });
4399
4600
  if (Array.isArray(value)) {
4400
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "flex flex-wrap gap-1", children: value.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_design_system19.Badge, { variant: "secondary", className: "text-[11px]", children: scalarText(field, item, labels) }, `${String(item)}-${i}`)) });
4601
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "flex flex-wrap gap-1", children: value.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_design_system20.Badge, { variant: "secondary", className: "text-[11px]", children: scalarText(field, item, labels) }, `${String(item)}-${i}`)) });
4401
4602
  }
4402
4603
  if (kind === "url" && typeof value === "string") {
4403
4604
  const href = value.includes("://") ? value : `https://${value}`;
4404
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
4605
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
4405
4606
  "a",
4406
4607
  {
4407
4608
  className: "inline-flex min-w-0 max-w-full items-center gap-1 rounded-md border border-border bg-muted/60 px-1.5 py-0.5 text-[11px] text-foreground hover:bg-accent",
@@ -4412,14 +4613,14 @@ function renderValue(field, value, document2, labels, stillWaitingFor) {
4412
4613
  "data-records-link-chip": "",
4413
4614
  onClick: (event) => event.stopPropagation(),
4414
4615
  children: [
4415
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { "aria-hidden": "true", className: "text-muted-foreground", children: "\u2197" }),
4416
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "truncate", children: linkChipText(value) })
4616
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { "aria-hidden": "true", className: "text-muted-foreground", children: "\u2197" }),
4617
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "truncate", children: linkChipText(value) })
4417
4618
  ]
4418
4619
  }
4419
4620
  );
4420
4621
  }
4421
4622
  if (kind === "phone" && typeof value === "string" && value.trim() !== "") {
4422
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
4623
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4423
4624
  "a",
4424
4625
  {
4425
4626
  className: "truncate tabular-nums text-primary underline-offset-2 hover:underline",
@@ -4432,12 +4633,12 @@ function renderValue(field, value, document2, labels, stillWaitingFor) {
4432
4633
  );
4433
4634
  }
4434
4635
  if (kind === "email" && typeof value === "string") {
4435
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("a", { className: "truncate text-primary underline-offset-2 hover:underline", href: `mailto:${value}`, children: value });
4636
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("a", { className: "truncate text-primary underline-offset-2 hover:underline", href: `mailto:${value}`, children: value });
4436
4637
  }
4437
4638
  if (typeof value === "boolean") {
4438
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: kind === "checkbox" ? "text-sm" : "", title: value ? "Yes" : "No", children: value ? "\u2713" : "\u2014" });
4639
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: kind === "checkbox" ? "text-sm" : "", title: value ? "Yes" : "No", children: value ? "\u2713" : "\u2014" });
4439
4640
  }
4440
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: (0, import_design_system19.cn)("truncate", kind === "number" || kind === "currency" || kind === "percent" ? "tabular-nums" : ""), children: scalarText(field, value, labels, stillWaitingFor) });
4641
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: (0, import_design_system20.cn)("truncate", kind === "number" || kind === "currency" || kind === "percent" ? "tabular-nums" : ""), children: scalarText(field, value, labels, stillWaitingFor) });
4441
4642
  }
4442
4643
  function scalarText(field, value, labels, stillWaitingFor) {
4443
4644
  if (value === null || value === void 0) return "\u2014";
@@ -4478,13 +4679,13 @@ function scalarText(field, value, labels, stillWaitingFor) {
4478
4679
  }
4479
4680
 
4480
4681
  // src/PickedSummaries.tsx
4481
- var import_jsx_runtime23 = require("react/jsx-runtime");
4682
+ var import_jsx_runtime24 = require("react/jsx-runtime");
4482
4683
  function TableNameText({ dataSource, tableId }) {
4483
4684
  const tables = useTablesAnywhere(dataSource);
4484
- if (!tableId) return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_jsx_runtime23.Fragment, { children: "\u2014" });
4485
- if (tables.loading) return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_jsx_runtime23.Fragment, { children: "\u2026" });
4486
- if (tables.error) return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_jsx_runtime23.Fragment, { children: "Couldn't load the table's name" });
4487
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_jsx_runtime23.Fragment, { children: tables.rows.find((t) => t.table_id === tableId)?.table_name ?? "\u2014" });
4685
+ if (!tableId) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: "\u2014" });
4686
+ if (tables.loading) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: "\u2026" });
4687
+ if (tables.error) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: "Couldn't load the table's name" });
4688
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: tables.rows.find((t) => t.table_id === tableId)?.table_name ?? "\u2014" });
4488
4689
  }
4489
4690
  function ColumnValuesText({
4490
4691
  dataSource,
@@ -4492,28 +4693,28 @@ function ColumnValuesText({
4492
4693
  tableId,
4493
4694
  value
4494
4695
  }) {
4495
- if (!tableId) return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_jsx_runtime23.Fragment, { children: "\u2014" });
4496
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TableScope, { dataSource, userId, tableId, fallback: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_jsx_runtime23.Fragment, { children: "\u2026" }), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(RecordLabelProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ColumnValuesWords, { tableId, value }) }) });
4696
+ if (!tableId) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: "\u2014" });
4697
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(TableScope, { dataSource, userId, tableId, fallback: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: "\u2026" }), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(RecordLabelProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ColumnValuesWords, { tableId, value }) }) });
4497
4698
  }
4498
4699
  function ColumnValuesWords({ tableId, value }) {
4499
- const fields = (0, import_react33.useFields)(tableId);
4700
+ const fields = (0, import_react35.useFields)(tableId);
4500
4701
  const labels = useRecordLabels(fields.data ?? void 0);
4501
- if (fields.loading) return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_jsx_runtime23.Fragment, { children: "\u2026" });
4502
- if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_jsx_runtime23.Fragment, { children: "Couldn't load this table's columns" });
4702
+ if (fields.loading) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: "\u2026" });
4703
+ if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: "Couldn't load this table's columns" });
4503
4704
  const parts = [];
4504
4705
  for (const [key, stored] of Object.entries(value)) {
4505
4706
  if (key.startsWith("_")) continue;
4506
4707
  const field = (fields.data ?? []).find((f) => f.key === key);
4507
- if (parts.length) parts.push(/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: ", " }, `${key}-sep`));
4708
+ if (parts.length) parts.push(/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { children: ", " }, `${key}-sep`));
4508
4709
  parts.push(
4509
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("span", { children: [
4710
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("span", { children: [
4510
4711
  field ? fieldName(field) : "A removed column",
4511
4712
  " is ",
4512
4713
  field ? renderValue(field, stored, void 0, labels) : "\u2014"
4513
4714
  ] }, key)
4514
4715
  );
4515
4716
  }
4516
- return parts.length ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_jsx_runtime23.Fragment, { children: parts }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_jsx_runtime23.Fragment, { children: "\u2014" });
4717
+ return parts.length ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: parts }) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: "\u2014" });
4517
4718
  }
4518
4719
  function RecordNameText({
4519
4720
  dataSource,
@@ -4521,32 +4722,32 @@ function RecordNameText({
4521
4722
  tableId,
4522
4723
  recordId
4523
4724
  }) {
4524
- if (!tableId || !recordId) return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_jsx_runtime23.Fragment, { children: "\u2014" });
4525
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TableScope, { dataSource, userId, tableId, fallback: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_jsx_runtime23.Fragment, { children: "\u2026" }), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(RecordNameWords, { tableId, recordId }) });
4725
+ if (!tableId || !recordId) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: "\u2014" });
4726
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(TableScope, { dataSource, userId, tableId, fallback: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: "\u2026" }), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(RecordNameWords, { tableId, recordId }) });
4526
4727
  }
4527
4728
  function RecordNameWords({ tableId, recordId }) {
4528
- const table = (0, import_react33.useTable)(tableId);
4529
- const record = (0, import_react33.useRecord)(recordId);
4530
- if (record.loading || table.loading) return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_jsx_runtime23.Fragment, { children: "\u2026" });
4531
- if (record.error) return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_jsx_runtime23.Fragment, { children: "Couldn't load this record" });
4532
- if (!record.data) return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_jsx_runtime23.Fragment, { children: "A record you cannot open" });
4533
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_jsx_runtime23.Fragment, { children: recordName(record.data.document, table.data?.title_field ?? null) });
4729
+ const table = (0, import_react35.useTable)(tableId);
4730
+ const record = (0, import_react35.useRecord)(recordId);
4731
+ if (record.loading || table.loading) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: "\u2026" });
4732
+ if (record.error) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: "Couldn't load this record" });
4733
+ if (!record.data) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: "A record you cannot open" });
4734
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: recordName(record.data.document, table.data?.title_field ?? null) });
4534
4735
  }
4535
4736
 
4536
4737
  // src/HeldChangeDecision.tsx
4537
- var import_react34 = require("react");
4538
- var import_react35 = require("@ai-matrx/records/react");
4539
- var import_design_system20 = require("@ai-matrx/design-system");
4540
- var import_jsx_runtime24 = require("react/jsx-runtime");
4738
+ var import_react36 = require("react");
4739
+ var import_react37 = require("@ai-matrx/records/react");
4740
+ var import_design_system21 = require("@ai-matrx/design-system");
4741
+ var import_jsx_runtime25 = require("react/jsx-runtime");
4541
4742
  function HeldChangeDecision({ dataSource, userId, organizationId, approvalId, onDecided }) {
4542
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react35.RecordsProvider, { config: { dataSource, actor: personActor(userId), organizationId }, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Decision, { approvalId, onDecided }) });
4743
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react37.RecordsProvider, { config: { dataSource, actor: personActor(userId), organizationId }, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Decision, { approvalId, onDecided }) });
4543
4744
  }
4544
4745
  function Decision({ approvalId, onDecided }) {
4545
- const client = (0, import_react35.useRecordsClient)();
4546
- const [may, setMay] = (0, import_react34.useState)(null);
4547
- const [busy, setBusy] = (0, import_react34.useState)(null);
4548
- const [error, setError] = (0, import_react34.useState)(null);
4549
- (0, import_react34.useEffect)(() => {
4746
+ const client = (0, import_react37.useRecordsClient)();
4747
+ const [may, setMay] = (0, import_react36.useState)(null);
4748
+ const [busy, setBusy] = (0, import_react36.useState)(null);
4749
+ const [error, setError] = (0, import_react36.useState)(null);
4750
+ (0, import_react36.useEffect)(() => {
4550
4751
  let live = true;
4551
4752
  void client.workApprovalMayDecide({ approval_id: approvalId }).then((res) => {
4552
4753
  if (!live) return;
@@ -4568,13 +4769,13 @@ function Decision({ approvalId, onDecided }) {
4568
4769
  if (res.ok) onDecided(approve);
4569
4770
  else setError(res.error);
4570
4771
  };
4571
- if (may === null) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "text-xs text-muted-foreground", children: "Checking who can decide\u2026" });
4572
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex flex-col gap-1.5", children: [
4573
- may ? /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex gap-2", children: [
4574
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_design_system20.Button, { type: "button", size: "sm", disabled: busy !== null, onClick: () => void decide(true), children: busy === "approve" ? "Approving\u2026" : "Approve" }),
4575
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_design_system20.Button, { type: "button", size: "sm", variant: "outline", disabled: busy !== null, onClick: () => void decide(false), children: busy === "refuse" ? "Refusing\u2026" : "Refuse" })
4576
- ] }) : !error && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "text-xs text-muted-foreground", children: "An owner or admin of this organization decides this." }),
4577
- error ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(RefusalLine, { error }) : null
4772
+ if (may === null) return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-xs text-muted-foreground", children: "Checking who can decide\u2026" });
4773
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-col gap-1.5", children: [
4774
+ may ? /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex gap-2", children: [
4775
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_design_system21.Button, { type: "button", size: "sm", disabled: busy !== null, onClick: () => void decide(true), children: busy === "approve" ? "Approving\u2026" : "Approve" }),
4776
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_design_system21.Button, { type: "button", size: "sm", variant: "outline", disabled: busy !== null, onClick: () => void decide(false), children: busy === "refuse" ? "Refusing\u2026" : "Refuse" })
4777
+ ] }) : !error && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-xs text-muted-foreground", children: "An owner or admin of this organization decides this." }),
4778
+ error ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(RefusalLine, { error }) : null
4578
4779
  ] });
4579
4780
  }
4580
4781
  //# sourceMappingURL=pickers.cjs.map