@ai-matrx/records-ui 0.59.0 → 0.61.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -51,6 +51,7 @@ __export(src_exports, {
51
51
  ChecklistTemplateEditor: () => ChecklistTemplateEditor,
52
52
  ChecklistsPanel: () => ChecklistsPanel,
53
53
  CommentThread: () => CommentThread,
54
+ ConditionGroup: () => ConditionGroup,
54
55
  ConditionRow: () => ConditionRow,
55
56
  CustomFieldsSection: () => CustomFieldsSection,
56
57
  DEFAULT_FIELDS: () => DEFAULT_FIELDS,
@@ -109,6 +110,8 @@ __export(src_exports, {
109
110
  NO_SHARE_REASON: () => NO_SHARE_REASON,
110
111
  NO_UPLOAD_REASON: () => NO_UPLOAD_REASON,
111
112
  NotifyRuleEditor: () => NotifyRuleEditor,
113
+ PAGE_VIEWS: () => PAGE_VIEWS,
114
+ PAGE_VIEW_LABEL: () => PAGE_VIEW_LABEL,
112
115
  PARITY_LABEL: () => PARITY_LABEL,
113
116
  PARITY_MADE_OF: () => PARITY_MADE_OF,
114
117
  Peek: () => Peek,
@@ -132,6 +135,7 @@ __export(src_exports, {
132
135
  RefusalNotice: () => RefusalNotice,
133
136
  RelationPicker: () => RelationPicker,
134
137
  SAVED_VIEWS_UNAVAILABLE: () => SAVED_VIEWS_UNAVAILABLE,
138
+ SAY_WHAT_YOU_ARE_WAITING_FOR_AFTER_MS: () => SAY_WHAT_YOU_ARE_WAITING_FOR_AFTER_MS,
135
139
  SERIES_COLORS: () => SERIES_COLORS,
136
140
  SOMEBODY: () => SOMEBODY,
137
141
  STORE_ANSWERS_THESE: () => STORE_ANSWERS_THESE,
@@ -165,6 +169,7 @@ __export(src_exports, {
165
169
  colorFromTheValue: () => colorFromTheValue,
166
170
  columnForField: () => columnForField,
167
171
  conditionInWords: () => conditionInWords,
172
+ conditionIsDrawable: () => conditionIsDrawable,
168
173
  conditionIsSimple: () => conditionIsSimple,
169
174
  conditionValue: () => conditionValue,
170
175
  controlFor: () => controlFor,
@@ -201,6 +206,9 @@ __export(src_exports, {
201
206
  machineIdentityIn: () => machineIdentityIn,
202
207
  memberName: () => memberName,
203
208
  nextInWords: () => nextInWords,
209
+ openingRail: () => openingRail,
210
+ openingView: () => openingView,
211
+ pageViewFromParam: () => pageViewFromParam,
204
212
  parityTypesWithNoExplanation: () => parityTypesWithNoExplanation,
205
213
  parseGridPresentation: () => parseGridPresentation,
206
214
  personActor: () => personActor,
@@ -226,10 +234,12 @@ __export(src_exports, {
226
234
  tableName: () => tableName,
227
235
  tableRightsAt: () => tableRightsAt,
228
236
  tokenFor: () => tokenFor,
237
+ unknownViewLine: () => unknownViewLine,
229
238
  useCanShare: () => useCanShare,
230
239
  useEmbedHandshake: () => useEmbedHandshake,
231
240
  useEnrichCells: () => useEnrichCells,
232
241
  useGridEditing: () => useGridEditing,
242
+ useLabelWait: () => useLabelWait,
233
243
  useMeasuredWidth: () => useMeasuredWidth,
234
244
  useMyChecklistSteps: () => useMyChecklistSteps,
235
245
  useRecordLabels: () => useRecordLabels,
@@ -513,11 +523,17 @@ function recordName(document2, titleKey, fallback = "Untitled") {
513
523
  );
514
524
  for (const key of keys) {
515
525
  const value = data[key];
516
- if (typeof value === "string" && value.trim() !== "") return value.trim();
526
+ if (typeof value === "string" && value.trim() !== "" && !looksLikeId(value.trim())) {
527
+ return value.trim();
528
+ }
517
529
  if (typeof value === "number") return String(value);
518
530
  }
519
531
  return fallback;
520
532
  }
533
+ var RECORD_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
534
+ function looksLikeId(value) {
535
+ return typeof value === "string" && RECORD_ID.test(value.trim());
536
+ }
521
537
  function rowName(row, titleKey, fallback = "Untitled") {
522
538
  return recordName(row?.document, titleKey, fallback);
523
539
  }
@@ -1391,8 +1407,13 @@ var LabelContext = (0, import_react11.createContext)({
1391
1407
  // provides one, so this is only ever a bare unit test.
1392
1408
  lookup: () => null,
1393
1409
  want: () => {
1394
- }
1410
+ },
1411
+ waiting: () => null
1395
1412
  });
1413
+ var SAY_WHAT_YOU_ARE_WAITING_FOR_AFTER_MS = 1e3;
1414
+ function waitingLineFor(field, target) {
1415
+ return field.type === "list" ? "Reading this column\u2019s list of choices\u2026" : `Reading the ${target ?? "records"} this column points at\u2026`;
1416
+ }
1396
1417
  function idsOf(value) {
1397
1418
  if (Array.isArray(value)) return value.map(String).filter(isId);
1398
1419
  if (typeof value === "string" && isId(value)) return [value];
@@ -1409,13 +1430,48 @@ function RecordLabelProvider({ children }) {
1409
1430
  const client = (0, import_react12.useRecordsClient)();
1410
1431
  const [names, setNames] = (0, import_react11.useState)({});
1411
1432
  const [settled, setSettled] = (0, import_react11.useState)({});
1433
+ const [waitingLines, setWaitingLines] = (0, import_react11.useState)({});
1412
1434
  const asked = (0, import_react11.useRef)(/* @__PURE__ */ new Set());
1413
1435
  const chased = (0, import_react11.useRef)(/* @__PURE__ */ new Set());
1436
+ const timers = (0, import_react11.useRef)(/* @__PURE__ */ new Map());
1437
+ const startWaitClock = (0, import_react11.useCallback)((field, target) => {
1438
+ if (timers.current.has(field.id)) return;
1439
+ timers.current.set(
1440
+ field.id,
1441
+ setTimeout(() => {
1442
+ timers.current.delete(field.id);
1443
+ setWaitingLines(
1444
+ (current) => current[field.id] ? current : { ...current, [field.id]: waitingLineFor(field, target) }
1445
+ );
1446
+ }, SAY_WHAT_YOU_ARE_WAITING_FOR_AFTER_MS)
1447
+ );
1448
+ }, []);
1449
+ const stopWaitClock = (0, import_react11.useCallback)((fieldId) => {
1450
+ const timer = timers.current.get(fieldId);
1451
+ if (timer) {
1452
+ clearTimeout(timer);
1453
+ timers.current.delete(fieldId);
1454
+ }
1455
+ setWaitingLines((current) => {
1456
+ if (!current[fieldId]) return current;
1457
+ const next = { ...current };
1458
+ delete next[fieldId];
1459
+ return next;
1460
+ });
1461
+ }, []);
1462
+ (0, import_react11.useEffect)(
1463
+ () => () => {
1464
+ for (const timer of timers.current.values()) clearTimeout(timer);
1465
+ timers.current.clear();
1466
+ },
1467
+ []
1468
+ );
1414
1469
  const want = (0, import_react11.useCallback)(
1415
1470
  (field) => {
1416
1471
  if (!pointsAtRecords(field)) return;
1417
1472
  if (asked.current.has(field.id)) return;
1418
1473
  asked.current.add(field.id);
1474
+ startWaitClock(field, null);
1419
1475
  void (async () => {
1420
1476
  if (field.type === "list") {
1421
1477
  const result = await client.fieldOptions({ field_id: field.id });
@@ -1429,11 +1485,13 @@ function RecordLabelProvider({ children }) {
1429
1485
  });
1430
1486
  }
1431
1487
  setSettled((current) => ({ ...current, [field.id]: true }));
1488
+ stopWaitClock(field.id);
1432
1489
  return;
1433
1490
  }
1434
1491
  const target = field.relation_target;
1435
1492
  if (!target) {
1436
1493
  setSettled((current) => ({ ...current, [field.id]: true }));
1494
+ stopWaitClock(field.id);
1437
1495
  return;
1438
1496
  }
1439
1497
  const [rows, tables] = await Promise.all([
@@ -1451,24 +1509,54 @@ function RecordLabelProvider({ children }) {
1451
1509
  });
1452
1510
  }
1453
1511
  setSettled((current) => ({ ...current, [field.id]: true }));
1512
+ stopWaitClock(field.id);
1454
1513
  })();
1455
1514
  },
1456
- [client]
1515
+ [client, startWaitClock, stopWaitClock]
1457
1516
  );
1517
+ const queued = (0, import_react11.useRef)(/* @__PURE__ */ new Map());
1518
+ const flushing = (0, import_react11.useRef)(null);
1519
+ const flush = (0, import_react11.useCallback)(() => {
1520
+ flushing.current = null;
1521
+ const batch = [...queued.current.entries()];
1522
+ queued.current.clear();
1523
+ if (batch.length === 0) return;
1524
+ void (async () => {
1525
+ const learned = {};
1526
+ const LANES = 6;
1527
+ let at = 0;
1528
+ await Promise.all(
1529
+ Array.from({ length: Math.min(LANES, batch.length) }, async () => {
1530
+ for (; ; ) {
1531
+ const next = batch[at];
1532
+ at += 1;
1533
+ if (!next) return;
1534
+ const [id] = next;
1535
+ const result = await client.recordRead({ record_id: id });
1536
+ learned[id] = result.ok ? recordName(result.data.document, null, "Untitled") : WITHHELD_RECORD_LABEL;
1537
+ }
1538
+ })
1539
+ );
1540
+ setNames((current) => ({ ...current, ...learned }));
1541
+ for (const [, field] of batch) stopWaitClock(field.id);
1542
+ })();
1543
+ }, [client, stopWaitClock]);
1458
1544
  const chase = (0, import_react11.useCallback)(
1459
1545
  (field, id) => {
1460
1546
  const key = `${field.id}:${id}`;
1461
1547
  if (chased.current.has(key)) return;
1462
1548
  chased.current.add(key);
1463
- void (async () => {
1464
- const result = await client.recordRead({ record_id: id });
1465
- setNames((current) => ({
1466
- ...current,
1467
- [id]: result.ok ? recordName(result.data.document, null, "Untitled") : WITHHELD_RECORD_LABEL
1468
- }));
1469
- })();
1549
+ queued.current.set(id, field);
1550
+ startWaitClock(field, null);
1551
+ if (flushing.current === null) flushing.current = setTimeout(flush, 0);
1470
1552
  },
1471
- [client]
1553
+ [flush, startWaitClock]
1554
+ );
1555
+ (0, import_react11.useEffect)(
1556
+ () => () => {
1557
+ if (flushing.current !== null) clearTimeout(flushing.current);
1558
+ },
1559
+ []
1472
1560
  );
1473
1561
  const lookup = (0, import_react11.useCallback)(
1474
1562
  (field, id) => {
@@ -1479,7 +1567,8 @@ function RecordLabelProvider({ children }) {
1479
1567
  },
1480
1568
  [names, settled, chase]
1481
1569
  );
1482
- const value = (0, import_react11.useMemo)(() => ({ lookup, want }), [lookup, want]);
1570
+ const waiting = (0, import_react11.useCallback)((field) => waitingLines[field.id] ?? null, [waitingLines]);
1571
+ const value = (0, import_react11.useMemo)(() => ({ lookup, want, waiting }), [lookup, want, waiting]);
1483
1572
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(LabelContext.Provider, { value, children });
1484
1573
  }
1485
1574
  function useRecordLabels(fields) {
@@ -1489,6 +1578,10 @@ function useRecordLabels(fields) {
1489
1578
  }, [fields, want]);
1490
1579
  return lookup;
1491
1580
  }
1581
+ function useLabelWait(field) {
1582
+ const { waiting } = (0, import_react11.useContext)(LabelContext);
1583
+ return field ? waiting(field) : null;
1584
+ }
1492
1585
 
1493
1586
  // src/values.tsx
1494
1587
  var import_jsx_runtime8 = require("react/jsx-runtime");
@@ -1502,7 +1595,7 @@ var ABSENCE_WORDS = {
1502
1595
  refused: "refused",
1503
1596
  conflicting: "conflicting"
1504
1597
  };
1505
- function renderValue(field, value, document2, labels) {
1598
+ function renderValue(field, value, document2, labels, stillWaitingFor) {
1506
1599
  const envelope = envelopeFor(document2, field.key);
1507
1600
  if (envelope?.absent) {
1508
1601
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "text-xs italic text-muted-foreground", title: `VAL-2: ${envelope.absent}`, children: ABSENCE_WORDS[String(envelope.absent)] ?? String(envelope.absent) });
@@ -1523,13 +1616,13 @@ function renderValue(field, value, document2, labels) {
1523
1616
  if (typeof value === "boolean") {
1524
1617
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: kind === "checkbox" ? "text-sm" : "", title: value ? "Yes" : "No", children: value ? "\u2713" : "\u2014" });
1525
1618
  }
1526
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: (0, import_design_system5.cn)("truncate", kind === "number" || kind === "currency" || kind === "percent" ? "tabular-nums" : ""), children: scalarText(field, value, labels) });
1619
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: (0, import_design_system5.cn)("truncate", kind === "number" || kind === "currency" || kind === "percent" ? "tabular-nums" : ""), children: scalarText(field, value, labels, stillWaitingFor) });
1527
1620
  }
1528
- function scalarText(field, value, labels) {
1621
+ function scalarText(field, value, labels, stillWaitingFor) {
1529
1622
  if (value === null || value === void 0) return "\u2014";
1530
1623
  const kind = editorKindFor(field);
1531
1624
  if (isId(value) && (field.type === "list" || field.type === "relation")) {
1532
- return labels?.(field, String(value)) ?? "Loading\u2026";
1625
+ return labels?.(field, String(value)) ?? stillWaitingFor ?? "Loading\u2026";
1533
1626
  }
1534
1627
  if (typeof value === "number") {
1535
1628
  if (kind === "percent") return `${value}%`;
@@ -1561,9 +1654,10 @@ function RecordValue({
1561
1654
  format
1562
1655
  }) {
1563
1656
  const labels = useRecordLabels(ONE_FIELD_ARRAY_CACHE(field));
1657
+ const stillWaitingFor = useLabelWait(field);
1564
1658
  const formatted = format ? (0, import_data_table.formatColumnValue)({ format }, value) : null;
1565
1659
  if (formatted) return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_data_table.FormattedCell, { result: formatted });
1566
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: renderValue(field, value, document2, labels) });
1660
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: renderValue(field, value, document2, labels, stillWaitingFor) });
1567
1661
  }
1568
1662
  var ONE_FIELD_ARRAYS = /* @__PURE__ */ new WeakMap();
1569
1663
  function ONE_FIELD_ARRAY_CACHE(field) {
@@ -4961,11 +5055,12 @@ function ValueOnTheOtherSide({
4961
5055
  }
4962
5056
 
4963
5057
  // src/StageRules.tsx
4964
- var import_react29 = require("react");
4965
- var import_react30 = require("@ai-matrx/records/react");
5058
+ var import_react30 = require("react");
5059
+ var import_react31 = require("@ai-matrx/records/react");
4966
5060
  var import_design_system15 = require("@ai-matrx/design-system");
4967
5061
 
4968
5062
  // src/Condition.tsx
5063
+ var import_react29 = require("react");
4969
5064
  var import_design_system14 = require("@ai-matrx/design-system");
4970
5065
  var import_jsx_runtime17 = require("react/jsx-runtime");
4971
5066
  var CONDITION_OPS = [
@@ -5095,6 +5190,155 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
5095
5190
  ] }) : null
5096
5191
  ] });
5097
5192
  }
5193
+ var JOINERS = [
5194
+ { op: "and", label: "All of these are true" },
5195
+ { op: "or", label: "Any of these is true" }
5196
+ ];
5197
+ function asNode(expr) {
5198
+ return expr && typeof expr === "object" && !Array.isArray(expr) ? expr : null;
5199
+ }
5200
+ function groupOf(expr) {
5201
+ const node = asNode(expr);
5202
+ if (!node) return null;
5203
+ const op = node["op"];
5204
+ if (op !== "and" && op !== "or") return null;
5205
+ const args = Array.isArray(node["args"]) ? node["args"] : [];
5206
+ return { op, args };
5207
+ }
5208
+ function conditionIsDrawable(expr, depth = 1) {
5209
+ if (expr === null || expr === void 0) return true;
5210
+ const group = groupOf(expr);
5211
+ if (!group) return conditionIsSimple(expr);
5212
+ if (group.args.length === 0) return true;
5213
+ return group.args.every((arg) => {
5214
+ const node = asNode(arg);
5215
+ if (node === null) return false;
5216
+ return conditionIsSimple(node) || depth > 0 && conditionIsDrawable(node, depth - 1);
5217
+ });
5218
+ }
5219
+ function clausesOf(expr) {
5220
+ const group = groupOf(expr);
5221
+ if (group) return group;
5222
+ return { op: "and", args: expr === null || expr === void 0 ? [] : [expr] };
5223
+ }
5224
+ function writeGroup(op, args) {
5225
+ const kept = args.filter((a) => a !== null && a !== void 0);
5226
+ if (kept.length === 0) return null;
5227
+ if (kept.length === 1) return kept[0];
5228
+ return { op, args: kept };
5229
+ }
5230
+ function ConditionGroup({
5231
+ lead,
5232
+ expr,
5233
+ fields,
5234
+ onChange,
5235
+ emptyLabel = "always",
5236
+ allowNesting = true,
5237
+ className
5238
+ }) {
5239
+ const { op, args } = clausesOf(expr);
5240
+ const [drafting, setDrafting] = (0, import_react29.useState)(false);
5241
+ const replaceAt = (index, next) => {
5242
+ const nextArgs = args.slice();
5243
+ if (next === null || next === void 0) nextArgs.splice(index, 1);
5244
+ else nextArgs[index] = next;
5245
+ onChange(writeGroup(op, nextArgs));
5246
+ };
5247
+ const joinWord = (index) => index === 0 ? lead : op === "and" ? "and" : "or";
5248
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: className ?? "flex flex-col gap-1 text-xs", "data-testid": "condition-group", children: [
5249
+ args.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center gap-1", children: [
5250
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-muted-foreground", children: lead }),
5251
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
5252
+ "select",
5253
+ {
5254
+ "aria-label": "How these conditions are joined",
5255
+ className: "h-8 rounded border bg-background px-1 text-xs",
5256
+ value: op,
5257
+ onChange: (e) => onChange(writeGroup(e.target.value, args)),
5258
+ children: JOINERS.map((j) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: j.op, children: j.label }, j.op))
5259
+ }
5260
+ )
5261
+ ] }) : null,
5262
+ args.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
5263
+ ConditionRow,
5264
+ {
5265
+ lead,
5266
+ emptyLabel,
5267
+ expr: null,
5268
+ fields,
5269
+ onChange: (next) => onChange(next)
5270
+ }
5271
+ ) : args.map((arg, index) => {
5272
+ const nested = groupOf(arg);
5273
+ const key = `clause-${index}`;
5274
+ if (nested && allowNesting) {
5275
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "ml-4 rounded border border-dashed p-1", "data-testid": "condition-nested-group", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
5276
+ ConditionGroup,
5277
+ {
5278
+ lead: op === "and" ? "and also, any of:" : "or, all of:",
5279
+ expr: arg,
5280
+ fields,
5281
+ onChange: (next) => replaceAt(index, next),
5282
+ emptyLabel,
5283
+ allowNesting: false
5284
+ }
5285
+ ) }, key);
5286
+ }
5287
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
5288
+ ConditionRow,
5289
+ {
5290
+ lead: args.length > 1 ? joinWord(index) : lead,
5291
+ emptyLabel,
5292
+ expr: arg,
5293
+ fields,
5294
+ onChange: (next) => replaceAt(index, next)
5295
+ },
5296
+ key
5297
+ );
5298
+ }),
5299
+ drafting ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
5300
+ ConditionRow,
5301
+ {
5302
+ lead: op === "and" ? "and" : "or",
5303
+ emptyLabel,
5304
+ expr: null,
5305
+ fields,
5306
+ onChange: (next) => {
5307
+ if (next === null) return;
5308
+ setDrafting(false);
5309
+ onChange(writeGroup(op, [...args, next]));
5310
+ }
5311
+ }
5312
+ ) : null,
5313
+ args.length > 0 && !drafting ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center gap-1", children: [
5314
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
5315
+ import_design_system14.Button,
5316
+ {
5317
+ size: "sm",
5318
+ variant: "ghost",
5319
+ className: "h-6 px-1 text-xs",
5320
+ "data-testid": "condition-add-clause",
5321
+ onClick: () => setDrafting(true),
5322
+ children: "Add another condition"
5323
+ }
5324
+ ),
5325
+ allowNesting && args.length > 1 && !args.some((a) => groupOf(a) !== null) ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
5326
+ import_design_system14.Button,
5327
+ {
5328
+ size: "sm",
5329
+ variant: "ghost",
5330
+ className: "h-6 px-1 text-xs",
5331
+ "data-testid": "condition-add-group",
5332
+ onClick: () => replaceAt(args.length - 1, {
5333
+ op: op === "and" ? "or" : "and",
5334
+ args: [args[args.length - 1]]
5335
+ }),
5336
+ children: "Group the last one"
5337
+ }
5338
+ ) : null
5339
+ ] }) : null
5340
+ ] });
5341
+ }
5098
5342
 
5099
5343
  // src/StageRules.tsx
5100
5344
  var import_jsx_runtime18 = require("react/jsx-runtime");
@@ -5128,38 +5372,38 @@ function draftOf(rule) {
5128
5372
  };
5129
5373
  }
5130
5374
  function StageRulesSection({ tableId, stage, className }) {
5131
- const client = (0, import_react30.useRecordsClient)();
5132
- const table = (0, import_react30.useTable)(tableId);
5375
+ const client = (0, import_react31.useRecordsClient)();
5376
+ const table = (0, import_react31.useTable)(tableId);
5133
5377
  const rights = useTableRights(table.data);
5134
- const fields = (0, import_react30.useFields)(tableId);
5135
- const [pipeline, setPipeline] = (0, import_react29.useState)(null);
5136
- const [enforcement, setEnforcement] = (0, import_react29.useState)(null);
5137
- const [asked, setAsked] = (0, import_react29.useState)(false);
5138
- const [error, setError] = (0, import_react29.useState)(null);
5139
- const [chosen, setChosen] = (0, import_react29.useState)(stage ?? null);
5140
- const [draft, setDraft] = (0, import_react29.useState)(null);
5141
- const [preview, setPreview] = (0, import_react29.useState)(null);
5142
- const [previewError, setPreviewError] = (0, import_react29.useState)(null);
5143
- const [saving, setSaving] = (0, import_react29.useState)(false);
5144
- const load = (0, import_react29.useCallback)(async () => {
5378
+ const fields = (0, import_react31.useFields)(tableId);
5379
+ const [pipeline, setPipeline] = (0, import_react30.useState)(null);
5380
+ const [enforcement, setEnforcement] = (0, import_react30.useState)(null);
5381
+ const [asked, setAsked] = (0, import_react30.useState)(false);
5382
+ const [error, setError] = (0, import_react30.useState)(null);
5383
+ const [chosen, setChosen] = (0, import_react30.useState)(stage ?? null);
5384
+ const [draft, setDraft] = (0, import_react30.useState)(null);
5385
+ const [preview, setPreview] = (0, import_react30.useState)(null);
5386
+ const [previewError, setPreviewError] = (0, import_react30.useState)(null);
5387
+ const [saving, setSaving] = (0, import_react30.useState)(false);
5388
+ const load = (0, import_react30.useCallback)(async () => {
5145
5389
  const [read, mode] = await Promise.all([client.pipelineRead({ table_id: tableId }), client.stageRuleEnforcement()]);
5146
5390
  if (!read.ok) setError(read.error);
5147
5391
  else setPipeline(read.data);
5148
5392
  if (mode.ok) setEnforcement(mode.data);
5149
5393
  setAsked(true);
5150
5394
  }, [client, tableId]);
5151
- (0, import_react29.useEffect)(() => {
5395
+ (0, import_react30.useEffect)(() => {
5152
5396
  void load();
5153
5397
  }, [load]);
5154
5398
  const stages = pipeline?.stages ?? [];
5155
5399
  const stageKey = chosen ?? stages.find((s) => !s.retired)?.key ?? null;
5156
5400
  const stageLabel = stages.find((s) => s.key === stageKey)?.label ?? stageKey ?? "";
5157
- const gates = (0, import_react29.useMemo)(() => stageKey ? gatesOf(pipeline, stageKey) : [], [pipeline, stageKey]);
5158
- const conditionFields = (0, import_react29.useMemo)(
5401
+ const gates = (0, import_react30.useMemo)(() => stageKey ? gatesOf(pipeline, stageKey) : [], [pipeline, stageKey]);
5402
+ const conditionFields = (0, import_react30.useMemo)(
5159
5403
  () => (fields.data ?? []).map((f) => ({ id: String(f.id), key: f.key, label: fieldName(f) })),
5160
5404
  [fields.data]
5161
5405
  );
5162
- (0, import_react29.useEffect)(() => {
5406
+ (0, import_react30.useEffect)(() => {
5163
5407
  if (!draft || !stageKey || !draft.demands || Object.keys(draft.demands).length === 0) {
5164
5408
  setPreview(null);
5165
5409
  setPreviewError(null);
@@ -5342,15 +5586,15 @@ function Clause({
5342
5586
  fields,
5343
5587
  onChange
5344
5588
  }) {
5345
- const [replacing, setReplacing] = (0, import_react29.useState)(false);
5346
- const drawable = conditionIsSimple(expr) || replacing;
5589
+ const [replacing, setReplacing] = (0, import_react30.useState)(false);
5590
+ const drawable = conditionIsDrawable(expr) || replacing;
5347
5591
  if (drawable) {
5348
5592
  return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
5349
- ConditionRow,
5593
+ ConditionGroup,
5350
5594
  {
5351
5595
  lead,
5352
5596
  emptyLabel,
5353
- expr: replacing && !conditionIsSimple(expr) ? null : expr,
5597
+ expr: replacing && !conditionIsDrawable(expr) ? null : expr,
5354
5598
  fields,
5355
5599
  onChange
5356
5600
  }
@@ -5381,8 +5625,8 @@ function Clause({
5381
5625
  }
5382
5626
 
5383
5627
  // src/TableSettings.tsx
5384
- var import_react31 = require("react");
5385
- var import_react32 = require("@ai-matrx/records/react");
5628
+ var import_react32 = require("react");
5629
+ var import_react33 = require("@ai-matrx/records/react");
5386
5630
  var import_design_system16 = require("@ai-matrx/design-system");
5387
5631
  var import_jsx_runtime19 = require("react/jsx-runtime");
5388
5632
  function TableSettings({
@@ -5393,15 +5637,15 @@ function TableSettings({
5393
5637
  onDeleted,
5394
5638
  className
5395
5639
  }) {
5396
- const table = (0, import_react32.useTable)(tableId);
5397
- const fields = (0, import_react32.useFields)(tableId);
5640
+ const table = (0, import_react33.useTable)(tableId);
5641
+ const fields = (0, import_react33.useFields)(tableId);
5398
5642
  const rights = useTableRights(table.data);
5399
- const mutation = (0, import_react32.useRecordMutation)();
5400
- const shape = (0, import_react32.useFieldMutation)();
5401
- const [editing, setEditing] = (0, import_react31.useState)(null);
5402
- const [askingToDelete, setAskingToDelete] = (0, import_react31.useState)(false);
5403
- const [askingToRemove, setAskingToRemove] = (0, import_react31.useState)(null);
5404
- const [enriching, setEnriching] = (0, import_react31.useState)(null);
5643
+ const mutation = (0, import_react33.useRecordMutation)();
5644
+ const shape = (0, import_react33.useFieldMutation)();
5645
+ const [editing, setEditing] = (0, import_react32.useState)(null);
5646
+ const [askingToDelete, setAskingToDelete] = (0, import_react32.useState)(false);
5647
+ const [askingToRemove, setAskingToRemove] = (0, import_react32.useState)(null);
5648
+ const [enriching, setEnriching] = (0, import_react32.useState)(null);
5405
5649
  if (table.error) return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(RefusalNotice, { error: table.error, className });
5406
5650
  if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(RefusalNotice, { error: fields.error, className });
5407
5651
  if (!rights.structure) return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: (0, import_design_system16.cn)("text-xs text-muted-foreground", className), children: rights.why("structure") });
@@ -5572,22 +5816,22 @@ function TableSettings({
5572
5816
  }
5573
5817
 
5574
5818
  // src/Peek.tsx
5575
- var import_react40 = require("react");
5576
- var import_react41 = require("@ai-matrx/records/react");
5577
- var import_react42 = require("@ai-matrx/alchemy/react");
5819
+ var import_react41 = require("react");
5820
+ var import_react42 = require("@ai-matrx/records/react");
5821
+ var import_react43 = require("@ai-matrx/alchemy/react");
5578
5822
 
5579
5823
  // src/RecordChat.tsx
5580
- var import_react33 = require("react");
5581
- var import_react34 = require("@ai-matrx/records/react");
5824
+ var import_react34 = require("react");
5825
+ var import_react35 = require("@ai-matrx/records/react");
5582
5826
  var import_design_system17 = require("@ai-matrx/design-system");
5583
5827
  var import_jsx_runtime20 = require("react/jsx-runtime");
5584
5828
  var NO_CHAT_REASON = "No chat port is bound, so this panel is absent rather than showing a composer that goes nowhere. Bind `chat` on <RecordsUiProvider> with your host's own chat surface \u2014 in AI Matrx that is `AgentConversationColumn`, launched through a Mandate \u2014 and this panel becomes that surface with this record as its context. This package deliberately ships no second chat UI.";
5585
5829
  function RecordChat({ tableId, recordId, className }) {
5586
- const client = (0, import_react34.useRecordsClient)();
5830
+ const client = (0, import_react35.useRecordsClient)();
5587
5831
  const host = useRecordsUi();
5588
- const [scope, setScope] = (0, import_react33.useState)(null);
5589
- const [error, setError] = (0, import_react33.useState)(null);
5590
- (0, import_react33.useEffect)(() => {
5832
+ const [scope, setScope] = (0, import_react34.useState)(null);
5833
+ const [error, setError] = (0, import_react34.useState)(null);
5834
+ (0, import_react34.useEffect)(() => {
5591
5835
  let cancelled = false;
5592
5836
  setScope(null);
5593
5837
  setError(null);
@@ -5603,7 +5847,7 @@ function RecordChat({ tableId, recordId, className }) {
5603
5847
  cancelled = true;
5604
5848
  };
5605
5849
  }, [client, recordId]);
5606
- const context = (0, import_react33.useMemo)(() => {
5850
+ const context = (0, import_react34.useMemo)(() => {
5607
5851
  if (!scope) return null;
5608
5852
  return {
5609
5853
  surfaceKey: `records-ui:record-chat:${recordId}`,
@@ -5704,14 +5948,14 @@ function entriesFor(scope) {
5704
5948
  var import_design_system20 = require("@ai-matrx/design-system");
5705
5949
 
5706
5950
  // src/RecordForm.tsx
5707
- var import_react37 = require("react");
5708
- var import_react38 = require("@ai-matrx/records/react");
5951
+ var import_react38 = require("react");
5952
+ var import_react39 = require("@ai-matrx/records/react");
5709
5953
  var import_core5 = require("@ai-matrx/records/core");
5710
5954
  var import_design_system18 = require("@ai-matrx/design-system");
5711
5955
 
5712
5956
  // src/systemTable.ts
5713
- var import_react35 = require("react");
5714
- var import_react36 = require("@ai-matrx/records/react");
5957
+ var import_react36 = require("react");
5958
+ var import_react37 = require("@ai-matrx/records/react");
5715
5959
  var inFlight = /* @__PURE__ */ new Map();
5716
5960
  async function ensureSystemTable(client, spec) {
5717
5961
  const cacheKey = `${client.config.organizationId}:${spec.slug}`;
@@ -5839,11 +6083,11 @@ async function declare(client, spec) {
5839
6083
  return { ok: true, data: table.data };
5840
6084
  }
5841
6085
  function useSystemTable(spec) {
5842
- const client = (0, import_react36.useRecordsClient)();
5843
- const [state, setState] = (0, import_react35.useState)({ tableId: null, loading: true, error: null });
6086
+ const client = (0, import_react37.useRecordsClient)();
6087
+ const [state, setState] = (0, import_react36.useState)({ tableId: null, loading: true, error: null });
5844
6088
  const slug = spec.slug;
5845
- const stable = (0, import_react35.useMemo)(() => spec, [slug]);
5846
- (0, import_react35.useEffect)(() => {
6089
+ const stable = (0, import_react36.useMemo)(() => spec, [slug]);
6090
+ (0, import_react36.useEffect)(() => {
5847
6091
  let cancelled = false;
5848
6092
  setState({ tableId: null, loading: true, error: null });
5849
6093
  void ensureSystemTable(client, stable).then((result) => {
@@ -5859,9 +6103,9 @@ function useSystemTable(spec) {
5859
6103
  return state;
5860
6104
  }
5861
6105
  function useRecordVersion(recordId) {
5862
- const client = (0, import_react36.useRecordsClient)();
5863
- const [version, setVersion] = (0, import_react35.useState)(null);
5864
- (0, import_react35.useEffect)(() => {
6106
+ const client = (0, import_react37.useRecordsClient)();
6107
+ const [version, setVersion] = (0, import_react36.useState)(null);
6108
+ (0, import_react36.useEffect)(() => {
5865
6109
  let cancelled = false;
5866
6110
  setVersion(null);
5867
6111
  if (!recordId) return;
@@ -5891,18 +6135,18 @@ function RecordForm({
5891
6135
  className
5892
6136
  }) {
5893
6137
  const host = useRecordsUi();
5894
- const fields = (0, import_react38.useFields)(tableId, recordType);
5895
- const existing = (0, import_react38.useRecord)(recordId ?? null);
5896
- const mutation = (0, import_react38.useRecordMutation)();
5897
- const [draft, setDraft] = (0, import_react37.useState)({});
5898
- const [touched, setTouched] = (0, import_react37.useState)(false);
6138
+ const fields = (0, import_react39.useFields)(tableId, recordType);
6139
+ const existing = (0, import_react39.useRecord)(recordId ?? null);
6140
+ const mutation = (0, import_react39.useRecordMutation)();
6141
+ const [draft, setDraft] = (0, import_react38.useState)({});
6142
+ const [touched, setTouched] = (0, import_react38.useState)(false);
5899
6143
  const loaded = useRecordVersion(recordId ?? null);
5900
6144
  const loadedVersion = loaded.version;
5901
- (0, import_react37.useEffect)(() => {
6145
+ (0, import_react38.useEffect)(() => {
5902
6146
  const document3 = existing.data?.document;
5903
6147
  if (document3) setDraft({ ...document3 });
5904
6148
  }, [existing.data?.record_id, loadedVersion]);
5905
- const document2 = (0, import_react37.useMemo)(() => {
6149
+ const document2 = (0, import_react38.useMemo)(() => {
5906
6150
  const out = {};
5907
6151
  for (const [key, value] of Object.entries(draft)) {
5908
6152
  if (key.startsWith("_")) continue;
@@ -5910,7 +6154,7 @@ function RecordForm({
5910
6154
  }
5911
6155
  return out;
5912
6156
  }, [draft]);
5913
- const predicted = (0, import_react37.useMemo)(
6157
+ const predicted = (0, import_react38.useMemo)(
5914
6158
  () => fields.data ? (0, import_core5.predictWriteRefusals)({ fields: fields.data, document: document2, ...recordType ? { recordType } : {} }) : [],
5915
6159
  [fields.data, document2, recordType]
5916
6160
  );
@@ -6025,7 +6269,7 @@ function asWords(value) {
6025
6269
  }
6026
6270
 
6027
6271
  // src/ShareControl.tsx
6028
- var import_react39 = require("react");
6272
+ var import_react40 = require("react");
6029
6273
  var import_design_system19 = require("@ai-matrx/design-system");
6030
6274
  var import_jsx_runtime22 = require("react/jsx-runtime");
6031
6275
  function useCanShare() {
@@ -6045,7 +6289,7 @@ function ShareControl({
6045
6289
  className
6046
6290
  }) {
6047
6291
  const host = useRecordsUi();
6048
- const [open, setOpen] = (0, import_react39.useState)(false);
6292
+ const [open, setOpen] = (0, import_react40.useState)(false);
6049
6293
  const asked = useRecordRights(may === void 0 ? subjectId : null);
6050
6294
  const mayShare = may ?? asked.share;
6051
6295
  if (!host.share) return null;
@@ -6077,14 +6321,14 @@ function ShareControl({
6077
6321
  // src/Peek.tsx
6078
6322
  var import_jsx_runtime23 = require("react/jsx-runtime");
6079
6323
  function Peek({ tableId, recordId, onClose, className }) {
6080
- const table = (0, import_react41.useTable)(tableId);
6081
- const fields = (0, import_react41.useFields)(tableId);
6082
- const record = (0, import_react41.useRecord)(recordId, true);
6324
+ const table = (0, import_react42.useTable)(tableId);
6325
+ const fields = (0, import_react42.useFields)(tableId);
6326
+ const record = (0, import_react42.useRecord)(recordId, true);
6083
6327
  const may = useRecordRights(recordId);
6084
6328
  const host = useRecordsUi();
6085
- const organizationId = (0, import_react41.useRecordsClient)().config.organizationId;
6086
- const [editing, setEditing] = (0, import_react40.useState)(false);
6087
- const [talking, setTalking] = (0, import_react40.useState)(false);
6329
+ const organizationId = (0, import_react42.useRecordsClient)().config.organizationId;
6330
+ const [editing, setEditing] = (0, import_react41.useState)(false);
6331
+ const [talking, setTalking] = (0, import_react41.useState)(false);
6088
6332
  if (record.error) return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(RefusalNotice, { error: record.error, className });
6089
6333
  if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(RefusalNotice, { error: fields.error, className });
6090
6334
  const document2 = record.data?.document;
@@ -6094,7 +6338,7 @@ function Peek({ tableId, recordId, onClose, className }) {
6094
6338
  /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex items-center gap-2", children: [
6095
6339
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("h3", { className: "min-w-0 flex-1 truncate text-sm font-medium", children: record.loading && !document2 ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_design_system20.Skeleton, { className: "h-4 w-40" }) : title }),
6096
6340
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
6097
- import_react42.AlchemyMenu,
6341
+ import_react43.AlchemyMenu,
6098
6342
  {
6099
6343
  label: title || "Record",
6100
6344
  sourceId: `record:${recordId}`,
@@ -6222,6 +6466,37 @@ var LAYOUT_FIELD_KIND = {
6222
6466
  calendar: "date",
6223
6467
  gallery: null
6224
6468
  };
6469
+ var PAGE_VIEWS = [...VIEW_LAYOUTS, "dashboards"];
6470
+ var PAGE_VIEW_LABEL = {
6471
+ ...LAYOUT_LABEL,
6472
+ dashboards: "Dashboards"
6473
+ };
6474
+ var PAGE_VIEW_SPELLINGS = {
6475
+ grid: "grid",
6476
+ table: "grid",
6477
+ rows: "grid",
6478
+ list: "grid",
6479
+ kanban: "kanban",
6480
+ board: "kanban",
6481
+ pipeline: "kanban",
6482
+ calendar: "calendar",
6483
+ month: "calendar",
6484
+ schedule: "calendar",
6485
+ gallery: "gallery",
6486
+ cards: "gallery",
6487
+ dashboards: "dashboards",
6488
+ dashboard: "dashboards",
6489
+ charts: "dashboards"
6490
+ };
6491
+ function pageViewFromParam(raw) {
6492
+ if (typeof raw !== "string") return null;
6493
+ const token = raw.trim().toLowerCase();
6494
+ if (token === "") return null;
6495
+ return PAGE_VIEW_SPELLINGS[token] ?? null;
6496
+ }
6497
+ function unknownViewLine(raw) {
6498
+ return `The link asked for a view called \u201C${raw}\u201D, which this table has no view for, so you are looking at ${PAGE_VIEW_LABEL.grid}. The views this table has are ${PAGE_VIEWS.map((v) => PAGE_VIEW_LABEL[v]).join(", ")} \u2014 pick one above and the address follows it.`;
6499
+ }
6225
6500
  var LAYOUT_NO_FIELD = {
6226
6501
  grid: "",
6227
6502
  kanban: "This table has no choice field yet, so there is nothing to make columns from. Add a field that holds one of a set of choices \u2014 Add field, then Select \u2014 and it appears here.",
@@ -6287,13 +6562,13 @@ function parseSorts(raw) {
6287
6562
  }
6288
6563
 
6289
6564
  // src/ViewSwitcher.tsx
6290
- var import_react45 = require("react");
6291
- var import_react46 = require("@ai-matrx/records/react");
6565
+ var import_react46 = require("react");
6566
+ var import_react47 = require("@ai-matrx/records/react");
6292
6567
  var import_design_system22 = require("@ai-matrx/design-system");
6293
6568
 
6294
6569
  // src/Pipeline.tsx
6295
- var import_react43 = require("react");
6296
- var import_react44 = require("@ai-matrx/records/react");
6570
+ var import_react44 = require("react");
6571
+ var import_react45 = require("@ai-matrx/records/react");
6297
6572
  var import_design_system21 = require("@ai-matrx/design-system");
6298
6573
  var import_jsx_runtime24 = require("react/jsx-runtime");
6299
6574
  var UNPLACED = "\0unplaced";
@@ -6326,24 +6601,24 @@ function PipelineBoard({
6326
6601
  onMoved,
6327
6602
  className
6328
6603
  }) {
6329
- const client = (0, import_react44.useRecordsClient)();
6330
- const fields = (0, import_react44.useFields)(tableId);
6331
- const [definition, setDefinition] = (0, import_react43.useState)(null);
6332
- const [columns, setColumns] = (0, import_react43.useState)([]);
6333
- const [error, setError] = (0, import_react43.useState)(null);
6334
- const [loading, setLoading] = (0, import_react43.useState)(true);
6335
- const [pending, setPending] = (0, import_react43.useState)({ kind: "none" });
6336
- const [waiting, setWaiting] = (0, import_react43.useState)(/* @__PURE__ */ new Map());
6337
- const [dragging, setDragging] = (0, import_react43.useState)(null);
6338
- const [over, setOver] = (0, import_react43.useState)(null);
6339
- const alive = (0, import_react43.useRef)(true);
6340
- (0, import_react43.useEffect)(() => {
6604
+ const client = (0, import_react45.useRecordsClient)();
6605
+ const fields = (0, import_react45.useFields)(tableId);
6606
+ const [definition, setDefinition] = (0, import_react44.useState)(null);
6607
+ const [columns, setColumns] = (0, import_react44.useState)([]);
6608
+ const [error, setError] = (0, import_react44.useState)(null);
6609
+ const [loading, setLoading] = (0, import_react44.useState)(true);
6610
+ const [pending, setPending] = (0, import_react44.useState)({ kind: "none" });
6611
+ const [waiting, setWaiting] = (0, import_react44.useState)(/* @__PURE__ */ new Map());
6612
+ const [dragging, setDragging] = (0, import_react44.useState)(null);
6613
+ const [over, setOver] = (0, import_react44.useState)(null);
6614
+ const alive = (0, import_react44.useRef)(true);
6615
+ (0, import_react44.useEffect)(() => {
6341
6616
  alive.current = true;
6342
6617
  return () => {
6343
6618
  alive.current = false;
6344
6619
  };
6345
6620
  }, []);
6346
- const reload = (0, import_react43.useCallback)(async () => {
6621
+ const reload = (0, import_react44.useCallback)(async () => {
6347
6622
  setLoading(true);
6348
6623
  const [read, board, held] = await Promise.all([
6349
6624
  client.pipelineRead({ table_id: tableId }),
@@ -6361,11 +6636,11 @@ function PipelineBoard({
6361
6636
  setWaiting(held.ok ? new Map((held.data ?? []).map((p) => [p.record_id, p])) : /* @__PURE__ */ new Map());
6362
6637
  setColumns(board.ok ? board.data ?? [] : []);
6363
6638
  }, [client, tableId, measure]);
6364
- (0, import_react43.useEffect)(() => {
6639
+ (0, import_react44.useEffect)(() => {
6365
6640
  void reload();
6366
6641
  }, [reload]);
6367
6642
  const stageKey = definition?.stage_field ?? null;
6368
- const cardsByStage = (0, import_react43.useMemo)(() => {
6643
+ const cardsByStage = (0, import_react44.useMemo)(() => {
6369
6644
  const map = /* @__PURE__ */ new Map();
6370
6645
  if (!stageKey) return map;
6371
6646
  for (const row of rows) {
@@ -6376,15 +6651,16 @@ function PipelineBoard({
6376
6651
  }, [rows, stageKey, definition?.stages]);
6377
6652
  const unplaced = cardsByStage.get(UNPLACED) ?? [];
6378
6653
  const all = fields.data ?? [];
6379
- const titleField = (0, import_react43.useMemo)(
6654
+ const titleField = (0, import_react44.useMemo)(
6380
6655
  () => all.find((f) => f.key !== stageKey) ?? all[0],
6381
6656
  [all, stageKey]
6382
6657
  );
6383
- const measurable = (0, import_react43.useMemo)(
6658
+ const unplacedLabels = useRecordLabels(titleField ? [titleField] : []);
6659
+ const measurable = (0, import_react44.useMemo)(
6384
6660
  () => all.filter((f) => ["number", "currency", "percentage"].includes(String(f.type ?? ""))),
6385
6661
  [all]
6386
6662
  );
6387
- const drop = (0, import_react43.useCallback)(
6663
+ const drop = (0, import_react44.useCallback)(
6388
6664
  async (recordId, to) => {
6389
6665
  setOver(null);
6390
6666
  setDragging(null);
@@ -6423,7 +6699,7 @@ function PipelineBoard({
6423
6699
  },
6424
6700
  [client, onMoved, reload]
6425
6701
  );
6426
- const askForApproval = (0, import_react43.useCallback)(
6702
+ const askForApproval = (0, import_react44.useCallback)(
6427
6703
  async (recordId, to) => {
6428
6704
  const moved = await client.pipelineMove({ record_id: recordId, to });
6429
6705
  if (!alive.current) return;
@@ -6437,7 +6713,7 @@ function PipelineBoard({
6437
6713
  },
6438
6714
  [client, reload]
6439
6715
  );
6440
- const moveWith = (0, import_react43.useCallback)(
6716
+ const moveWith = (0, import_react44.useCallback)(
6441
6717
  async (recordId, to, also) => {
6442
6718
  const moved = await client.pipelineMove({ record_id: recordId, to, also });
6443
6719
  if (!alive.current) return;
@@ -6550,7 +6826,7 @@ function PipelineBoard({
6550
6826
  unplaced.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("p", { className: "text-xs text-muted-foreground", "data-testid": "pipeline-unplaced", children: [
6551
6827
  unplaced.length === 1 ? "One record is" : `${unplaced.length} records are`,
6552
6828
  " not in any of these columns \u2014 ",
6553
- unplaced.slice(0, 3).map((r) => rowName(r, titleField?.key ?? null, "Untitled")).join(", "),
6829
+ unplaced.slice(0, 3).map((r) => unplacedName(r, titleField, unplacedLabels)).join(", "),
6554
6830
  unplaced.length > 3 ? ` and ${unplaced.length - 3} more` : "",
6555
6831
  ". Their stage is not one this pipeline offers, so nothing here can draw them; open one from the grid to move it."
6556
6832
  ] }) : null
@@ -6566,7 +6842,7 @@ function Held({
6566
6842
  onFill,
6567
6843
  onAsk
6568
6844
  }) {
6569
- const [draft, setDraft] = (0, import_react43.useState)({});
6845
+ const [draft, setDraft] = (0, import_react44.useState)({});
6570
6846
  if (pending.kind === "asking") {
6571
6847
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "px-2 py-1 text-xs text-muted-foreground", children: "Asking\u2026" });
6572
6848
  }
@@ -6653,7 +6929,7 @@ function Card({
6653
6929
  stages
6654
6930
  }) {
6655
6931
  const labels = useRecordLabels(field ? [field] : []);
6656
- const draggable = (0, import_react44.mayDrag)(record.level);
6932
+ const draggable = (0, import_react45.mayDrag)(record.level);
6657
6933
  const label = field ? scalarText(field, (record.document ?? {})[field.key], labels) : rowName(record, null, "Untitled");
6658
6934
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
6659
6935
  "button",
@@ -6687,20 +6963,24 @@ function Card({
6687
6963
  }
6688
6964
  );
6689
6965
  }
6966
+ function unplacedName(record, field, labels) {
6967
+ if (!field) return rowName(record, null, "Untitled");
6968
+ return scalarText(field, (record.document ?? {})[field.key], labels);
6969
+ }
6690
6970
 
6691
6971
  // src/ViewSwitcher.tsx
6692
6972
  var import_jsx_runtime25 = require("react/jsx-runtime");
6693
6973
  var NO_FIELDS = [];
6694
6974
  function useViewRecords(view, pageSize = 200) {
6695
- const client = (0, import_react46.useRecordsClient)();
6696
- const table = (0, import_react46.useRecords)(view.ruleId ? null : view.subject, { pageSize });
6697
- const [ruled, setRuled] = (0, import_react45.useState)({
6975
+ const client = (0, import_react47.useRecordsClient)();
6976
+ const table = (0, import_react47.useRecords)(view.ruleId ? null : view.subject, { pageSize });
6977
+ const [ruled, setRuled] = (0, import_react46.useState)({
6698
6978
  rows: [],
6699
6979
  loading: Boolean(view.ruleId),
6700
6980
  error: null
6701
6981
  });
6702
6982
  const ruleId = view.ruleId ?? null;
6703
- (0, import_react45.useEffect)(() => {
6983
+ (0, import_react46.useEffect)(() => {
6704
6984
  if (!ruleId) return;
6705
6985
  let cancelled = false;
6706
6986
  setRuled({ rows: [], loading: true, error: null });
@@ -6750,9 +7030,9 @@ function ViewSwitcher({
6750
7030
  pageSize = 200,
6751
7031
  className
6752
7032
  }) {
6753
- const [layout, setLayout] = (0, import_react45.useState)(view.layout);
6754
- const [local, setLocal] = (0, import_react45.useState)({});
6755
- (0, import_react45.useEffect)(() => {
7033
+ const [layout, setLayout] = (0, import_react46.useState)(view.layout);
7034
+ const [local, setLocal] = (0, import_react46.useState)({});
7035
+ (0, import_react46.useEffect)(() => {
6756
7036
  setLayout(view.layout);
6757
7037
  setLocal({});
6758
7038
  }, [view.layout, view.name, view.subject]);
@@ -6812,12 +7092,12 @@ function offerableFields(all, want) {
6812
7092
  });
6813
7093
  }
6814
7094
  function useStageField(tableId) {
6815
- const client = (0, import_react46.useRecordsClient)();
6816
- const [stage, setStage] = (0, import_react45.useState)({
7095
+ const client = (0, import_react47.useRecordsClient)();
7096
+ const [stage, setStage] = (0, import_react46.useState)({
6817
7097
  asked: false,
6818
7098
  key: null
6819
7099
  });
6820
- (0, import_react45.useEffect)(() => {
7100
+ (0, import_react46.useEffect)(() => {
6821
7101
  let cancelled = false;
6822
7102
  setStage({ asked: false, key: null });
6823
7103
  void client.tableStageField({ table_id: tableId }).then((r) => {
@@ -6848,7 +7128,7 @@ function Board({
6848
7128
  onOpenRecord,
6849
7129
  onMoved
6850
7130
  }) {
6851
- const fields = (0, import_react46.useFields)(view.subject);
7131
+ const fields = (0, import_react47.useFields)(view.subject);
6852
7132
  const records = useViewRecords(view, pageSize);
6853
7133
  const stage = useStageField(view.subject);
6854
7134
  if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(RefusalNotice, { error: fields.error });
@@ -6958,9 +7238,9 @@ function Kanban({
6958
7238
  onOpenRecord,
6959
7239
  note
6960
7240
  }) {
6961
- const groupFields = (0, import_react45.useMemo)(() => [groupField], [groupField]);
7241
+ const groupFields = (0, import_react46.useMemo)(() => [groupField], [groupField]);
6962
7242
  const labels = useRecordLabels(groupFields);
6963
- const columns = (0, import_react45.useMemo)(() => {
7243
+ const columns = (0, import_react46.useMemo)(() => {
6964
7244
  const map = /* @__PURE__ */ new Map();
6965
7245
  for (const row of rows) {
6966
7246
  const raw = (row.document ?? {})[groupField.key];
@@ -6987,7 +7267,7 @@ function Calendar({
6987
7267
  onOpenRecord,
6988
7268
  note
6989
7269
  }) {
6990
- const { days, undated } = (0, import_react45.useMemo)(() => {
7270
+ const { days, undated } = (0, import_react46.useMemo)(() => {
6991
7271
  const byDay = /* @__PURE__ */ new Map();
6992
7272
  const without = [];
6993
7273
  for (const row of rows) {
@@ -7060,7 +7340,7 @@ function Card2({
7060
7340
  onOpenRecord
7061
7341
  }) {
7062
7342
  const host = useRecordsUi();
7063
- const wanted = (0, import_react45.useMemo)(
7343
+ const wanted = (0, import_react46.useMemo)(
7064
7344
  () => field && pointsAtRecords(field) ? [field] : NO_FIELDS,
7065
7345
  [field]
7066
7346
  );
@@ -7082,15 +7362,15 @@ function Card2({
7082
7362
  }
7083
7363
 
7084
7364
  // src/ViewBar.tsx
7085
- var import_react48 = require("react");
7086
- var import_react49 = require("@ai-matrx/records/react");
7365
+ var import_react49 = require("react");
7366
+ var import_react50 = require("@ai-matrx/records/react");
7087
7367
  var import_design_system23 = require("@ai-matrx/design-system");
7088
7368
 
7089
7369
  // src/seedOnce.ts
7090
- var import_react47 = require("react");
7370
+ var import_react48 = require("react");
7091
7371
  function useSeedGuard() {
7092
- const claimed = (0, import_react47.useRef)(/* @__PURE__ */ new Set());
7093
- return (0, import_react47.useCallback)((name) => {
7372
+ const claimed = (0, import_react48.useRef)(/* @__PURE__ */ new Set());
7373
+ return (0, import_react48.useCallback)((name) => {
7094
7374
  if (claimed.current.has(name)) return false;
7095
7375
  claimed.current.add(name);
7096
7376
  return true;
@@ -7098,22 +7378,22 @@ function useSeedGuard() {
7098
7378
  }
7099
7379
 
7100
7380
  // src/ViewBar.tsx
7101
- var import_react50 = require("@ai-matrx/records/react");
7381
+ var import_react51 = require("@ai-matrx/records/react");
7102
7382
  var import_jsx_runtime26 = require("react/jsx-runtime");
7103
7383
  var SAVED_VIEWS_UNAVAILABLE = "Saved views are not available in this organization right now, so the layout you pick here is not being kept. Everything else on this table works as usual.";
7104
7384
  function ViewBar({ tableId, activeViewId, onActiveView, seed, className }) {
7105
- const client = (0, import_react49.useRecordsClient)();
7385
+ const client = (0, import_react50.useRecordsClient)();
7106
7386
  const claimSeed = useSeedGuard();
7107
- const table = (0, import_react50.useTable)(tableId);
7387
+ const table = (0, import_react51.useTable)(tableId);
7108
7388
  const rights = useTableRights(table.data);
7109
7389
  const home = useSystemTable(VIEW_TABLE);
7110
- const [views, setViews] = (0, import_react48.useState)(null);
7111
- const [error, setError] = (0, import_react48.useState)(null);
7112
- const [active, setActive] = (0, import_react48.useState)(activeViewId ?? null);
7113
- const [naming, setNaming] = (0, import_react48.useState)(false);
7114
- const [draftName, setDraftName] = (0, import_react48.useState)("");
7390
+ const [views, setViews] = (0, import_react49.useState)(null);
7391
+ const [error, setError] = (0, import_react49.useState)(null);
7392
+ const [active, setActive] = (0, import_react49.useState)(activeViewId ?? null);
7393
+ const [naming, setNaming] = (0, import_react49.useState)(false);
7394
+ const [draftName, setDraftName] = (0, import_react49.useState)("");
7115
7395
  const viewTableId = home.tableId;
7116
- const load = (0, import_react48.useCallback)(async () => {
7396
+ const load = (0, import_react49.useCallback)(async () => {
7117
7397
  if (!viewTableId) return;
7118
7398
  const result = await client.list({ table_id: viewTableId, limit: 500 });
7119
7399
  if (!result.ok) {
@@ -7145,10 +7425,10 @@ function ViewBar({ tableId, activeViewId, onActiveView, seed, className }) {
7145
7425
  setError(null);
7146
7426
  setViews(mine);
7147
7427
  }, [client, viewTableId, tableId, seed]);
7148
- (0, import_react48.useEffect)(() => {
7428
+ (0, import_react49.useEffect)(() => {
7149
7429
  void load();
7150
7430
  }, [load]);
7151
- (0, import_react48.useEffect)(() => {
7431
+ (0, import_react49.useEffect)(() => {
7152
7432
  if (!views || views.length === 0) return;
7153
7433
  const chosen = views.find((v) => v.id === (activeViewId ?? active)) ?? views.find((v) => v.isDefault) ?? views[0];
7154
7434
  if (chosen.id !== active) setActive(chosen.id);
@@ -7222,8 +7502,8 @@ function ViewBar({ tableId, activeViewId, onActiveView, seed, className }) {
7222
7502
  }
7223
7503
 
7224
7504
  // src/ProposalRow.tsx
7225
- var import_react51 = require("react");
7226
- var import_react52 = require("@ai-matrx/records/react");
7505
+ var import_react52 = require("react");
7506
+ var import_react53 = require("@ai-matrx/records/react");
7227
7507
  var import_design_system24 = require("@ai-matrx/design-system");
7228
7508
  var import_jsx_runtime27 = require("react/jsx-runtime");
7229
7509
  var ACT_WORD = {
@@ -7240,10 +7520,10 @@ function ProposalRow({
7240
7520
  onSettled,
7241
7521
  className
7242
7522
  }) {
7243
- const client = (0, import_react52.useRecordsClient)();
7244
- const [settled, setSettled] = (0, import_react51.useState)(outcome ?? null);
7245
- const [busy, setBusy] = (0, import_react51.useState)(false);
7246
- const [confirming, setConfirming] = (0, import_react51.useState)(false);
7523
+ const client = (0, import_react53.useRecordsClient)();
7524
+ const [settled, setSettled] = (0, import_react52.useState)(outcome ?? null);
7525
+ const [busy, setBusy] = (0, import_react52.useState)(false);
7526
+ const [confirming, setConfirming] = (0, import_react52.useState)(false);
7247
7527
  async function applyThroughTheStore() {
7248
7528
  if (change.act === "add") {
7249
7529
  if (!change.table) {
@@ -7328,13 +7608,13 @@ function ProposalRow({
7328
7608
  }
7329
7609
 
7330
7610
  // src/ActionInbox.tsx
7331
- var import_react55 = require("react");
7332
- var import_react56 = require("@ai-matrx/records/react");
7611
+ var import_react56 = require("react");
7612
+ var import_react57 = require("@ai-matrx/records/react");
7333
7613
  var import_design_system26 = require("@ai-matrx/design-system");
7334
7614
 
7335
7615
  // src/ChecklistRunner.tsx
7336
- var import_react53 = require("react");
7337
- var import_react54 = require("@ai-matrx/records/react");
7616
+ var import_react54 = require("react");
7617
+ var import_react55 = require("@ai-matrx/records/react");
7338
7618
  var import_design_system25 = require("@ai-matrx/design-system");
7339
7619
  var import_jsx_runtime28 = require("react/jsx-runtime");
7340
7620
  var DUE_WORD = {
@@ -7361,18 +7641,18 @@ function ChecklistRunner({
7361
7641
  offerToStart,
7362
7642
  className
7363
7643
  }) {
7364
- const client = (0, import_react54.useRecordsClient)();
7365
- const table = (0, import_react54.useTable)(tableId ?? null);
7644
+ const client = (0, import_react55.useRecordsClient)();
7645
+ const table = (0, import_react55.useTable)(tableId ?? null);
7366
7646
  const rights = useTableRights(table.data);
7367
- const [runs, setRuns] = (0, import_react53.useState)(null);
7368
- const [activeId, setActiveId] = (0, import_react53.useState)(runId ?? null);
7369
- const [steps, setSteps] = (0, import_react53.useState)(null);
7370
- const [templates, setTemplates] = (0, import_react53.useState)(null);
7371
- const [error, setError] = (0, import_react53.useState)(null);
7372
- const [busy, setBusy] = (0, import_react53.useState)(null);
7373
- const [said, setSaid] = (0, import_react53.useState)(null);
7647
+ const [runs, setRuns] = (0, import_react54.useState)(null);
7648
+ const [activeId, setActiveId] = (0, import_react54.useState)(runId ?? null);
7649
+ const [steps, setSteps] = (0, import_react54.useState)(null);
7650
+ const [templates, setTemplates] = (0, import_react54.useState)(null);
7651
+ const [error, setError] = (0, import_react54.useState)(null);
7652
+ const [busy, setBusy] = (0, import_react54.useState)(null);
7653
+ const [said, setSaid] = (0, import_react54.useState)(null);
7374
7654
  const mayStart = offerToStart ?? Boolean(recordId);
7375
- const loadRuns = (0, import_react53.useCallback)(async () => {
7655
+ const loadRuns = (0, import_react54.useCallback)(async () => {
7376
7656
  if (runId) {
7377
7657
  setRuns(null);
7378
7658
  return;
@@ -7394,13 +7674,13 @@ function ChecklistRunner({
7394
7674
  (held) => held && answered.data.some((r) => r.run_id === held) ? held : answered.data[0]?.run_id ?? null
7395
7675
  );
7396
7676
  }, [client, includeClosed, recordId, runId, tableId]);
7397
- (0, import_react53.useEffect)(() => {
7677
+ (0, import_react54.useEffect)(() => {
7398
7678
  void loadRuns();
7399
7679
  }, [loadRuns]);
7400
- (0, import_react53.useEffect)(() => {
7680
+ (0, import_react54.useEffect)(() => {
7401
7681
  if (runId) setActiveId(runId);
7402
7682
  }, [runId]);
7403
- const loadSteps = (0, import_react53.useCallback)(async () => {
7683
+ const loadSteps = (0, import_react54.useCallback)(async () => {
7404
7684
  if (!activeId) {
7405
7685
  setSteps(null);
7406
7686
  return;
@@ -7414,10 +7694,10 @@ function ChecklistRunner({
7414
7694
  setError(null);
7415
7695
  setSteps(answered.data);
7416
7696
  }, [client, activeId]);
7417
- (0, import_react53.useEffect)(() => {
7697
+ (0, import_react54.useEffect)(() => {
7418
7698
  void loadSteps();
7419
7699
  }, [loadSteps]);
7420
- (0, import_react53.useEffect)(() => {
7700
+ (0, import_react54.useEffect)(() => {
7421
7701
  if (!mayStart || !tableId) return;
7422
7702
  let cancelled = false;
7423
7703
  void client.checklistTemplates({ about_table_id: tableId, limit: 50 }).then((answered) => {
@@ -7428,7 +7708,7 @@ function ChecklistRunner({
7428
7708
  cancelled = true;
7429
7709
  };
7430
7710
  }, [client, mayStart, tableId]);
7431
- const start = (0, import_react53.useCallback)(
7711
+ const start = (0, import_react54.useCallback)(
7432
7712
  async (templateId) => {
7433
7713
  setBusy(templateId);
7434
7714
  setSaid(null);
@@ -7450,7 +7730,7 @@ function ChecklistRunner({
7450
7730
  },
7451
7731
  [client, loadRuns, recordId]
7452
7732
  );
7453
- const complete = (0, import_react53.useCallback)(
7733
+ const complete = (0, import_react54.useCallback)(
7454
7734
  async (step2, evidence) => {
7455
7735
  setBusy(step2.step_id);
7456
7736
  setSaid(null);
@@ -7467,7 +7747,7 @@ function ChecklistRunner({
7467
7747
  },
7468
7748
  [client, loadSteps, loadRuns]
7469
7749
  );
7470
- const active = (0, import_react53.useMemo)(
7750
+ const active = (0, import_react54.useMemo)(
7471
7751
  () => runs?.find((r) => r.run_id === activeId) ?? null,
7472
7752
  [runs, activeId]
7473
7753
  );
@@ -7537,7 +7817,7 @@ function StepRow({
7537
7817
  onComplete,
7538
7818
  className
7539
7819
  }) {
7540
- const [answer, setAnswer] = (0, import_react53.useState)("");
7820
+ const [answer, setAnswer] = (0, import_react54.useState)("");
7541
7821
  const key = step2.requires_key ?? (step2.requires === "note" ? "note" : null);
7542
7822
  const asksHere = step2.requires === "note" || step2.requires === "answer";
7543
7823
  const needsAnswer = asksHere && answer.trim().length === 0;
@@ -7610,12 +7890,12 @@ function StepRow({
7610
7890
  );
7611
7891
  }
7612
7892
  function useMyChecklistSteps(limit = 25) {
7613
- const client = (0, import_react54.useRecordsClient)();
7893
+ const client = (0, import_react55.useRecordsClient)();
7614
7894
  const me = client.config.actor.user_id ?? null;
7615
- const [steps, setSteps] = (0, import_react53.useState)([]);
7616
- const [loading, setLoading] = (0, import_react53.useState)(true);
7617
- const [error, setError] = (0, import_react53.useState)(null);
7618
- const refresh = (0, import_react53.useCallback)(async () => {
7895
+ const [steps, setSteps] = (0, import_react54.useState)([]);
7896
+ const [loading, setLoading] = (0, import_react54.useState)(true);
7897
+ const [error, setError] = (0, import_react54.useState)(null);
7898
+ const refresh = (0, import_react54.useCallback)(async () => {
7619
7899
  if (!me) {
7620
7900
  setSteps([]);
7621
7901
  setLoading(false);
@@ -7643,17 +7923,17 @@ function useMyChecklistSteps(limit = 25) {
7643
7923
  setSteps(held);
7644
7924
  setLoading(false);
7645
7925
  }, [client, limit, me]);
7646
- (0, import_react53.useEffect)(() => {
7926
+ (0, import_react54.useEffect)(() => {
7647
7927
  void refresh();
7648
7928
  }, [refresh]);
7649
7929
  return { steps, loading, error, refresh };
7650
7930
  }
7651
7931
  function MyChecklistSteps({ className }) {
7652
- const client = (0, import_react54.useRecordsClient)();
7932
+ const client = (0, import_react55.useRecordsClient)();
7653
7933
  const { steps, loading, error, refresh } = useMyChecklistSteps();
7654
- const [busy, setBusy] = (0, import_react53.useState)(null);
7655
- const [refusal, setRefusal] = (0, import_react53.useState)(null);
7656
- const complete = (0, import_react53.useCallback)(
7934
+ const [busy, setBusy] = (0, import_react54.useState)(null);
7935
+ const [refusal, setRefusal] = (0, import_react54.useState)(null);
7936
+ const complete = (0, import_react54.useCallback)(
7657
7937
  async (step2, evidence) => {
7658
7938
  setBusy(step2.step_id);
7659
7939
  const answered = await client.checklistStepComplete({ step_id: step2.step_id, evidence });
@@ -7688,15 +7968,15 @@ function MyChecklistSteps({ className }) {
7688
7968
  ] });
7689
7969
  }
7690
7970
  function ChecklistsPanel({ tableId, onOpenRecord, className }) {
7691
- const client = (0, import_react54.useRecordsClient)();
7692
- const table = (0, import_react54.useTable)(tableId);
7971
+ const client = (0, import_react55.useRecordsClient)();
7972
+ const table = (0, import_react55.useTable)(tableId);
7693
7973
  const rights = useTableRights(table.data);
7694
- const [templates, setTemplates] = (0, import_react53.useState)(null);
7695
- const [runs, setRuns] = (0, import_react53.useState)(null);
7696
- const [error, setError] = (0, import_react53.useState)(null);
7697
- const [editing, setEditing] = (0, import_react53.useState)(null);
7698
- const [openRun, setOpenRun] = (0, import_react53.useState)(null);
7699
- const load = (0, import_react53.useCallback)(async () => {
7974
+ const [templates, setTemplates] = (0, import_react54.useState)(null);
7975
+ const [runs, setRuns] = (0, import_react54.useState)(null);
7976
+ const [error, setError] = (0, import_react54.useState)(null);
7977
+ const [editing, setEditing] = (0, import_react54.useState)(null);
7978
+ const [openRun, setOpenRun] = (0, import_react54.useState)(null);
7979
+ const load = (0, import_react54.useCallback)(async () => {
7700
7980
  const [t, r] = await Promise.all([
7701
7981
  client.checklistTemplates({ about_table_id: tableId, limit: 100 }),
7702
7982
  client.checklistRuns({ about_table_id: tableId, includeClosed: true, limit: 100 })
@@ -7710,7 +7990,7 @@ function ChecklistsPanel({ tableId, onOpenRecord, className }) {
7710
7990
  if (!r.ok) setRuns([]);
7711
7991
  else setRuns(r.data);
7712
7992
  }, [client, tableId]);
7713
- (0, import_react53.useEffect)(() => {
7993
+ (0, import_react54.useEffect)(() => {
7714
7994
  void load();
7715
7995
  }, [load]);
7716
7996
  if (templates === null) return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_design_system25.Skeleton, { className: (0, import_design_system25.cn)("h-40 w-full", className) });
@@ -7849,14 +8129,14 @@ function ChecklistTemplateEditor({
7849
8129
  onDone,
7850
8130
  className
7851
8131
  }) {
7852
- const client = (0, import_react54.useRecordsClient)();
7853
- const [name, setName] = (0, import_react53.useState)("");
7854
- const [rows, setRows] = (0, import_react53.useState)([{ ...EMPTY_ROW }]);
7855
- const [refusal, setRefusal] = (0, import_react53.useState)(null);
7856
- const [error, setError] = (0, import_react53.useState)(null);
7857
- const [busy, setBusy] = (0, import_react53.useState)(false);
7858
- const [loading, setLoading] = (0, import_react53.useState)(Boolean(templateId));
7859
- (0, import_react53.useEffect)(() => {
8132
+ const client = (0, import_react55.useRecordsClient)();
8133
+ const [name, setName] = (0, import_react54.useState)("");
8134
+ const [rows, setRows] = (0, import_react54.useState)([{ ...EMPTY_ROW }]);
8135
+ const [refusal, setRefusal] = (0, import_react54.useState)(null);
8136
+ const [error, setError] = (0, import_react54.useState)(null);
8137
+ const [busy, setBusy] = (0, import_react54.useState)(false);
8138
+ const [loading, setLoading] = (0, import_react54.useState)(Boolean(templateId));
8139
+ (0, import_react54.useEffect)(() => {
7860
8140
  if (!templateId) return;
7861
8141
  let cancelled = false;
7862
8142
  void client.checklistTemplateShape({ template_id: templateId }).then((answered) => {
@@ -7884,7 +8164,7 @@ function ChecklistTemplateEditor({
7884
8164
  cancelled = true;
7885
8165
  };
7886
8166
  }, [client, templateId]);
7887
- const spec = (0, import_react53.useMemo)(
8167
+ const spec = (0, import_react54.useMemo)(
7888
8168
  () => ({
7889
8169
  name: name.trim(),
7890
8170
  about_table_id: aboutTableId,
@@ -7893,7 +8173,7 @@ function ChecklistTemplateEditor({
7893
8173
  }),
7894
8174
  [aboutTableId, name, rows]
7895
8175
  );
7896
- (0, import_react53.useEffect)(() => {
8176
+ (0, import_react54.useEffect)(() => {
7897
8177
  if (spec.steps.length === 0 || spec.name.length === 0) {
7898
8178
  setRefusal(null);
7899
8179
  return;
@@ -7907,7 +8187,7 @@ function ChecklistTemplateEditor({
7907
8187
  cancelled = true;
7908
8188
  };
7909
8189
  }, [client, spec]);
7910
- const save = (0, import_react53.useCallback)(async () => {
8190
+ const save = (0, import_react54.useCallback)(async () => {
7911
8191
  setBusy(true);
7912
8192
  const answered = await client.checklistDeclare({
7913
8193
  spec,
@@ -8072,14 +8352,14 @@ var DUE_WORD2 = {
8072
8352
  finished: "Finished"
8073
8353
  };
8074
8354
  function ActionInbox({ tableId, includeSettled = false, onOpenRecord, className }) {
8075
- const client = (0, import_react56.useRecordsClient)();
8076
- const [items, setItems] = (0, import_react55.useState)(null);
8077
- const [error, setError] = (0, import_react55.useState)(null);
8078
- const [outcome, setOutcome] = (0, import_react55.useState)({});
8079
- const [busy, setBusy] = (0, import_react55.useState)(null);
8080
- const [cursor, setCursor] = (0, import_react55.useState)(0);
8081
- const listRef = (0, import_react55.useRef)(null);
8082
- const load = (0, import_react55.useCallback)(async () => {
8355
+ const client = (0, import_react57.useRecordsClient)();
8356
+ const [items, setItems] = (0, import_react56.useState)(null);
8357
+ const [error, setError] = (0, import_react56.useState)(null);
8358
+ const [outcome, setOutcome] = (0, import_react56.useState)({});
8359
+ const [busy, setBusy] = (0, import_react56.useState)(null);
8360
+ const [cursor, setCursor] = (0, import_react56.useState)(0);
8361
+ const listRef = (0, import_react56.useRef)(null);
8362
+ const load = (0, import_react56.useCallback)(async () => {
8083
8363
  const result = await client.workInbox({ limit: 200, includeDecided: includeSettled });
8084
8364
  if (!result.ok) {
8085
8365
  setError(result.error);
@@ -8089,22 +8369,22 @@ function ActionInbox({ tableId, includeSettled = false, onOpenRecord, className
8089
8369
  setError(null);
8090
8370
  setItems(result.data);
8091
8371
  }, [client, includeSettled]);
8092
- (0, import_react55.useEffect)(() => {
8372
+ (0, import_react56.useEffect)(() => {
8093
8373
  void load();
8094
8374
  }, [load]);
8095
- const shown = (0, import_react55.useMemo)(() => {
8375
+ const shown = (0, import_react56.useMemo)(() => {
8096
8376
  const all = items ?? [];
8097
8377
  if (!tableId) return all;
8098
8378
  return all.filter((i) => i.kind !== "assignment" || i.subject_kind !== "record" || true);
8099
8379
  }, [items, tableId]);
8100
- (0, import_react55.useEffect)(() => {
8380
+ (0, import_react56.useEffect)(() => {
8101
8381
  if (cursor >= shown.length) setCursor(Math.max(0, shown.length - 1));
8102
8382
  }, [shown.length, cursor]);
8103
- (0, import_react55.useEffect)(() => {
8383
+ (0, import_react56.useEffect)(() => {
8104
8384
  const el = listRef.current?.querySelector(`[data-row="${cursor}"]`);
8105
8385
  el?.scrollIntoView({ block: "nearest" });
8106
8386
  }, [cursor, shown.length]);
8107
- const decide = (0, import_react55.useCallback)(
8387
+ const decide = (0, import_react56.useCallback)(
8108
8388
  async (item, approve) => {
8109
8389
  if (item.kind === "assignment") return;
8110
8390
  setBusy(item.item_id);
@@ -8119,14 +8399,14 @@ function ActionInbox({ tableId, includeSettled = false, onOpenRecord, className
8119
8399
  },
8120
8400
  [client, load]
8121
8401
  );
8122
- const open = (0, import_react55.useCallback)(
8402
+ const open = (0, import_react56.useCallback)(
8123
8403
  (item) => {
8124
8404
  if (!onOpenRecord || !item.subject_id) return;
8125
8405
  onOpenRecord(item.subject_id, tableId ?? item.subject_id);
8126
8406
  },
8127
8407
  [onOpenRecord, tableId]
8128
8408
  );
8129
- const onKeyDown = (0, import_react55.useCallback)(
8409
+ const onKeyDown = (0, import_react56.useCallback)(
8130
8410
  (event) => {
8131
8411
  const item = shown[cursor];
8132
8412
  const key = event.key;
@@ -8226,22 +8506,22 @@ function ActionInbox({ tableId, includeSettled = false, onOpenRecord, className
8226
8506
  }
8227
8507
 
8228
8508
  // src/HistoryPanel.tsx
8229
- var import_react57 = require("react");
8230
- var import_react58 = require("@ai-matrx/records/react");
8509
+ var import_react58 = require("react");
8510
+ var import_react59 = require("@ai-matrx/records/react");
8231
8511
  var import_design_system27 = require("@ai-matrx/design-system");
8232
8512
  var import_jsx_runtime30 = require("react/jsx-runtime");
8233
8513
  function HistoryPanel({ tableId, recordId, onAskAboutField, className }) {
8234
- const client = (0, import_react58.useRecordsClient)();
8235
- const table = (0, import_react58.useTable)(tableId);
8236
- const fields = (0, import_react58.useFields)(tableId);
8514
+ const client = (0, import_react59.useRecordsClient)();
8515
+ const table = (0, import_react59.useTable)(tableId);
8516
+ const fields = (0, import_react59.useFields)(tableId);
8237
8517
  const rights = useTableRights(table.data);
8238
- const [entries, setEntries] = (0, import_react57.useState)(null);
8239
- const [error, setError] = (0, import_react57.useState)(null);
8240
- const [open, setOpen] = (0, import_react57.useState)(null);
8241
- const [pending, setPending] = (0, import_react57.useState)({ phase: "idle" });
8242
- const [said, setSaid] = (0, import_react57.useState)(null);
8243
- const listRef = (0, import_react57.useRef)(null);
8244
- const load = (0, import_react57.useCallback)(async () => {
8518
+ const [entries, setEntries] = (0, import_react58.useState)(null);
8519
+ const [error, setError] = (0, import_react58.useState)(null);
8520
+ const [open, setOpen] = (0, import_react58.useState)(null);
8521
+ const [pending, setPending] = (0, import_react58.useState)({ phase: "idle" });
8522
+ const [said, setSaid] = (0, import_react58.useState)(null);
8523
+ const listRef = (0, import_react58.useRef)(null);
8524
+ const load = (0, import_react58.useCallback)(async () => {
8245
8525
  const answered = await client.recordHistory({ record_id: recordId });
8246
8526
  if (!answered.ok) {
8247
8527
  setError(answered.error);
@@ -8250,7 +8530,7 @@ function HistoryPanel({ tableId, recordId, onAskAboutField, className }) {
8250
8530
  setError(null);
8251
8531
  setEntries(answered.data);
8252
8532
  }, [client, recordId]);
8253
- (0, import_react57.useEffect)(() => {
8533
+ (0, import_react58.useEffect)(() => {
8254
8534
  void load();
8255
8535
  }, [load]);
8256
8536
  if (error) return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(RefusalNotice, { error, className });
@@ -8531,27 +8811,27 @@ function say(value, field) {
8531
8811
  }
8532
8812
 
8533
8813
  // src/CommentThread.tsx
8534
- var import_react59 = require("react");
8535
- var import_react60 = require("@ai-matrx/records/react");
8814
+ var import_react60 = require("react");
8815
+ var import_react61 = require("@ai-matrx/records/react");
8536
8816
  var import_design_system28 = require("@ai-matrx/design-system");
8537
8817
  var import_jsx_runtime31 = require("react/jsx-runtime");
8538
8818
  function CommentThread({ tableId, recordId, fieldKey, className }) {
8539
- const client = (0, import_react60.useRecordsClient)();
8540
- const table = (0, import_react60.useTable)(tableId);
8541
- const fields = (0, import_react60.useFields)(tableId);
8819
+ const client = (0, import_react61.useRecordsClient)();
8820
+ const table = (0, import_react61.useTable)(tableId);
8821
+ const fields = (0, import_react61.useFields)(tableId);
8542
8822
  const host = useRecordsUi();
8543
- const [thread, setThread] = (0, import_react59.useState)(null);
8544
- const [error, setError] = (0, import_react59.useState)(null);
8545
- const [draft, setDraft] = (0, import_react59.useState)("");
8546
- const [replyTo, setReplyTo] = (0, import_react59.useState)(null);
8547
- const [busy, setBusy] = (0, import_react59.useState)(false);
8548
- const [said, setSaid] = (0, import_react59.useState)(null);
8549
- const [showResolved, setShowResolved] = (0, import_react59.useState)(false);
8550
- const [people, setPeople] = (0, import_react59.useState)([]);
8551
- const [mentionQuery, setMentionQuery] = (0, import_react59.useState)(null);
8552
- const [picked, setPicked] = (0, import_react59.useState)([]);
8553
- const box = (0, import_react59.useRef)(null);
8554
- const load = (0, import_react59.useCallback)(async () => {
8823
+ const [thread, setThread] = (0, import_react60.useState)(null);
8824
+ const [error, setError] = (0, import_react60.useState)(null);
8825
+ const [draft, setDraft] = (0, import_react60.useState)("");
8826
+ const [replyTo, setReplyTo] = (0, import_react60.useState)(null);
8827
+ const [busy, setBusy] = (0, import_react60.useState)(false);
8828
+ const [said, setSaid] = (0, import_react60.useState)(null);
8829
+ const [showResolved, setShowResolved] = (0, import_react60.useState)(false);
8830
+ const [people, setPeople] = (0, import_react60.useState)([]);
8831
+ const [mentionQuery, setMentionQuery] = (0, import_react60.useState)(null);
8832
+ const [picked, setPicked] = (0, import_react60.useState)([]);
8833
+ const box = (0, import_react60.useRef)(null);
8834
+ const load = (0, import_react60.useCallback)(async () => {
8555
8835
  const answered = await client.commentThread({ record_id: recordId, include_resolved: showResolved });
8556
8836
  if (!answered.ok) {
8557
8837
  setError(answered.error);
@@ -8564,10 +8844,10 @@ function CommentThread({ tableId, recordId, fieldKey, className }) {
8564
8844
  mayResolve: answered.data.may_resolve
8565
8845
  });
8566
8846
  }, [client, recordId, showResolved]);
8567
- (0, import_react59.useEffect)(() => {
8847
+ (0, import_react60.useEffect)(() => {
8568
8848
  void load();
8569
8849
  }, [load]);
8570
- (0, import_react59.useEffect)(() => {
8850
+ (0, import_react60.useEffect)(() => {
8571
8851
  let alive = true;
8572
8852
  if (!host.members) return;
8573
8853
  void host.members().then((roster) => {
@@ -8584,7 +8864,7 @@ function CommentThread({ tableId, recordId, fieldKey, className }) {
8584
8864
  alive = false;
8585
8865
  };
8586
8866
  }, [host]);
8587
- const candidates = (0, import_react59.useMemo)(() => {
8867
+ const candidates = (0, import_react60.useMemo)(() => {
8588
8868
  if (mentionQuery === null) return [];
8589
8869
  const q = mentionQuery.trim().toLowerCase();
8590
8870
  return people.filter((p) => !picked.some((already) => already.userId === p.userId)).filter((p) => q === "" || (p.name ?? p.email ?? "").toLowerCase().includes(q)).slice(0, 6);
@@ -8770,8 +9050,8 @@ function Line({
8770
9050
  }
8771
9051
 
8772
9052
  // src/FieldHistoryPanel.tsx
8773
- var import_react61 = require("react");
8774
- var import_react62 = require("@ai-matrx/records/react");
9053
+ var import_react62 = require("react");
9054
+ var import_react63 = require("@ai-matrx/records/react");
8775
9055
  var import_design_system29 = require("@ai-matrx/design-system");
8776
9056
  var import_jsx_runtime32 = require("react/jsx-runtime");
8777
9057
  function FieldHistoryPanel({
@@ -8782,15 +9062,15 @@ function FieldHistoryPanel({
8782
9062
  onOpenRecord,
8783
9063
  className
8784
9064
  }) {
8785
- const client = (0, import_react62.useRecordsClient)();
8786
- const table = (0, import_react62.useTable)(tableId);
8787
- const fields = (0, import_react62.useFields)(tableId);
9065
+ const client = (0, import_react63.useRecordsClient)();
9066
+ const table = (0, import_react63.useTable)(tableId);
9067
+ const fields = (0, import_react63.useFields)(tableId);
8788
9068
  const rights = useTableRights(table.data);
8789
- const [rows, setRows] = (0, import_react61.useState)(null);
8790
- const [error, setError] = (0, import_react61.useState)(null);
8791
- const [pending, setPending] = (0, import_react61.useState)({ phase: "idle" });
8792
- const [said, setSaid] = (0, import_react61.useState)(null);
8793
- const load = (0, import_react61.useCallback)(async () => {
9069
+ const [rows, setRows] = (0, import_react62.useState)(null);
9070
+ const [error, setError] = (0, import_react62.useState)(null);
9071
+ const [pending, setPending] = (0, import_react62.useState)({ phase: "idle" });
9072
+ const [said, setSaid] = (0, import_react62.useState)(null);
9073
+ const load = (0, import_react62.useCallback)(async () => {
8794
9074
  const answered = await client.fieldHistory(
8795
9075
  recordId ? { table_id: tableId, field_key: fieldKey, record_id: recordId } : { table_id: tableId, field_key: fieldKey }
8796
9076
  );
@@ -8801,7 +9081,7 @@ function FieldHistoryPanel({
8801
9081
  setError(null);
8802
9082
  setRows(answered.data);
8803
9083
  }, [client, tableId, fieldKey, recordId]);
8804
- (0, import_react61.useEffect)(() => {
9084
+ (0, import_react62.useEffect)(() => {
8805
9085
  void load();
8806
9086
  }, [load]);
8807
9087
  const label = (fields.data ?? []).find((f) => f.key === fieldKey)?.label || humanize(fieldKey);
@@ -8994,28 +9274,28 @@ function submissionStamp(args) {
8994
9274
  }
8995
9275
 
8996
9276
  // src/PortalBuilder.tsx
8997
- var import_react63 = require("react");
8998
- var import_react64 = require("@ai-matrx/records/react");
9277
+ var import_react64 = require("react");
9278
+ var import_react65 = require("@ai-matrx/records/react");
8999
9279
  var import_design_system30 = require("@ai-matrx/design-system");
9000
9280
  var import_jsx_runtime33 = require("react/jsx-runtime");
9001
9281
  var RESTATING_REPLACES = "Saving replaces what this portal shows: a table you untick stops being visible to every client the moment you save. Who is invited is not touched.";
9002
9282
  function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
9003
- const client = (0, import_react64.useRecordsClient)();
9004
- const tables = (0, import_react64.useTables)();
9005
- const [title, setTitle] = (0, import_react63.useState)("");
9006
- const [clientTableId, setClientTableId] = (0, import_react63.useState)(null);
9007
- const [exposures, setExposures] = (0, import_react63.useState)({});
9008
- const [fieldsByTable, setFieldsByTable] = (0, import_react63.useState)({});
9009
- const [error, setError] = (0, import_react63.useState)(null);
9010
- const [saving, setSaving] = (0, import_react63.useState)(false);
9011
- const [savedId, setSavedId] = (0, import_react63.useState)(portalId ?? null);
9012
- const [existing, setExisting] = (0, import_react63.useState)(null);
9013
- const [loading, setLoading] = (0, import_react63.useState)(Boolean(portalId));
9014
- const [inviteEmail, setInviteEmail] = (0, import_react63.useState)("");
9015
- const [inviteRecordId, setInviteRecordId] = (0, import_react63.useState)("");
9016
- const [inviting, setInviting] = (0, import_react63.useState)(false);
9017
- const [invitationSaid, setInvitationSaid] = (0, import_react63.useState)(null);
9018
- const loadFields = (0, import_react63.useCallback)(
9283
+ const client = (0, import_react65.useRecordsClient)();
9284
+ const tables = (0, import_react65.useTables)();
9285
+ const [title, setTitle] = (0, import_react64.useState)("");
9286
+ const [clientTableId, setClientTableId] = (0, import_react64.useState)(null);
9287
+ const [exposures, setExposures] = (0, import_react64.useState)({});
9288
+ const [fieldsByTable, setFieldsByTable] = (0, import_react64.useState)({});
9289
+ const [error, setError] = (0, import_react64.useState)(null);
9290
+ const [saving, setSaving] = (0, import_react64.useState)(false);
9291
+ const [savedId, setSavedId] = (0, import_react64.useState)(portalId ?? null);
9292
+ const [existing, setExisting] = (0, import_react64.useState)(null);
9293
+ const [loading, setLoading] = (0, import_react64.useState)(Boolean(portalId));
9294
+ const [inviteEmail, setInviteEmail] = (0, import_react64.useState)("");
9295
+ const [inviteRecordId, setInviteRecordId] = (0, import_react64.useState)("");
9296
+ const [inviting, setInviting] = (0, import_react64.useState)(false);
9297
+ const [invitationSaid, setInvitationSaid] = (0, import_react64.useState)(null);
9298
+ const loadFields = (0, import_react64.useCallback)(
9019
9299
  async (id) => {
9020
9300
  if (fieldsByTable[id]) return;
9021
9301
  const answered = await client.fields({ table_id: id });
@@ -9027,7 +9307,7 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
9027
9307
  },
9028
9308
  [client, fieldsByTable]
9029
9309
  );
9030
- (0, import_react63.useEffect)(() => {
9310
+ (0, import_react64.useEffect)(() => {
9031
9311
  if (!portalId) return;
9032
9312
  void (async () => {
9033
9313
  const answered = await client.portalCard({ portal_id: portalId });
@@ -9041,7 +9321,7 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
9041
9321
  setClientTableId(answered.data.client_table_id);
9042
9322
  })();
9043
9323
  }, [client, portalId]);
9044
- (0, import_react63.useEffect)(() => {
9324
+ (0, import_react64.useEffect)(() => {
9045
9325
  if (!tableId) return;
9046
9326
  setExposures(
9047
9327
  (prev) => prev[tableId] ? prev : {
@@ -9051,8 +9331,8 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
9051
9331
  );
9052
9332
  void loadFields(tableId);
9053
9333
  }, [tableId]);
9054
- const ticked = (0, import_react63.useMemo)(() => Object.values(exposures).filter((e) => e.on), [exposures]);
9055
- const tiesTo = (0, import_react63.useCallback)(
9334
+ const ticked = (0, import_react64.useMemo)(() => Object.values(exposures).filter((e) => e.on), [exposures]);
9335
+ const tiesTo = (0, import_react64.useCallback)(
9056
9336
  (id) => (fieldsByTable[id] ?? []).filter(
9057
9337
  (f) => f.type === "relation" && f.relation_target === clientTableId
9058
9338
  ),
@@ -9289,8 +9569,8 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
9289
9569
  }
9290
9570
 
9291
9571
  // src/PortalsPanel.tsx
9292
- var import_react65 = require("react");
9293
- var import_react66 = require("@ai-matrx/records/react");
9572
+ var import_react66 = require("react");
9573
+ var import_react67 = require("@ai-matrx/records/react");
9294
9574
  var import_records6 = require("@ai-matrx/records");
9295
9575
  var import_design_system32 = require("@ai-matrx/design-system");
9296
9576
 
@@ -9355,13 +9635,13 @@ function stateWords(person) {
9355
9635
  }
9356
9636
  var PORTAL_SUGGESTION = "Let each of my customers sign in and see their own jobs and invoices, and nothing else.";
9357
9637
  function PortalsPanel({ tableId, className }) {
9358
- const client = (0, import_react66.useRecordsClient)();
9638
+ const client = (0, import_react67.useRecordsClient)();
9359
9639
  const host = useRecordsUi();
9360
- const [portals, setPortals] = (0, import_react65.useState)(null);
9361
- const [listError, setListError] = (0, import_react65.useState)(null);
9362
- const [openId, setOpenId] = (0, import_react65.useState)(null);
9363
- const [building, setBuilding] = (0, import_react65.useState)(false);
9364
- const load = (0, import_react65.useCallback)(async () => {
9640
+ const [portals, setPortals] = (0, import_react66.useState)(null);
9641
+ const [listError, setListError] = (0, import_react66.useState)(null);
9642
+ const [openId, setOpenId] = (0, import_react66.useState)(null);
9643
+ const [building, setBuilding] = (0, import_react66.useState)(false);
9644
+ const load = (0, import_react66.useCallback)(async () => {
9365
9645
  const answered = await client.portals();
9366
9646
  if (!answered.ok) {
9367
9647
  setListError(answered.error);
@@ -9371,7 +9651,7 @@ function PortalsPanel({ tableId, className }) {
9371
9651
  setListError(null);
9372
9652
  setPortals(answered.data);
9373
9653
  }, [client]);
9374
- (0, import_react65.useEffect)(() => {
9654
+ (0, import_react66.useEffect)(() => {
9375
9655
  void load();
9376
9656
  }, [load]);
9377
9657
  if (portals === null) return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_design_system32.Skeleton, { className: (0, import_design_system32.cn)("h-32 w-full", className) });
@@ -9453,8 +9733,8 @@ function PortalsPanel({ tableId, className }) {
9453
9733
  ] });
9454
9734
  }
9455
9735
  function CopyLink({ url }) {
9456
- const [copied, setCopied] = (0, import_react65.useState)(false);
9457
- const [shown, setShown] = (0, import_react65.useState)(false);
9736
+ const [copied, setCopied] = (0, import_react66.useState)(false);
9737
+ const [shown, setShown] = (0, import_react66.useState)(false);
9458
9738
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
9459
9739
  /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
9460
9740
  import_design_system32.Button,
@@ -9487,10 +9767,10 @@ function PortalDetail({
9487
9767
  tableId,
9488
9768
  onChanged
9489
9769
  }) {
9490
- const client = (0, import_react66.useRecordsClient)();
9491
- const [card, setCard] = (0, import_react65.useState)(null);
9492
- const [error, setError] = (0, import_react65.useState)(null);
9493
- const load = (0, import_react65.useCallback)(async () => {
9770
+ const client = (0, import_react67.useRecordsClient)();
9771
+ const [card, setCard] = (0, import_react66.useState)(null);
9772
+ const [error, setError] = (0, import_react66.useState)(null);
9773
+ const load = (0, import_react66.useCallback)(async () => {
9494
9774
  const answered = await client.portalCard({ portal_id: portalId });
9495
9775
  if (!answered.ok) {
9496
9776
  setError(answered.error);
@@ -9500,10 +9780,10 @@ function PortalDetail({
9500
9780
  setError(null);
9501
9781
  setCard(answered.data);
9502
9782
  }, [client, portalId]);
9503
- (0, import_react65.useEffect)(() => {
9783
+ (0, import_react66.useEffect)(() => {
9504
9784
  void load();
9505
9785
  }, [load]);
9506
- const revoke = (0, import_react65.useCallback)(
9786
+ const revoke = (0, import_react66.useCallback)(
9507
9787
  async (person) => {
9508
9788
  const answered = await client.portalRevoke({
9509
9789
  portal_id: portalId,
@@ -9516,7 +9796,7 @@ function PortalDetail({
9516
9796
  },
9517
9797
  [client, load, onChanged, portalId]
9518
9798
  );
9519
- const preview = (0, import_react65.useCallback)(
9799
+ const preview = (0, import_react66.useCallback)(
9520
9800
  async (person, subject) => {
9521
9801
  const answered = await client.portalPreview({
9522
9802
  portal_id: portalId,
@@ -9598,12 +9878,12 @@ function People({
9598
9878
  onRevoke,
9599
9879
  onPreview
9600
9880
  }) {
9601
- const [askingToRevoke, setAskingToRevoke] = (0, import_react65.useState)(null);
9602
- const [busy, setBusy] = (0, import_react65.useState)(false);
9603
- const [said, setSaid] = (0, import_react65.useState)(null);
9604
- const [error, setError] = (0, import_react65.useState)(null);
9605
- const [previewing, setPreviewing] = (0, import_react65.useState)(null);
9606
- const revoke = (0, import_react65.useCallback)(
9881
+ const [askingToRevoke, setAskingToRevoke] = (0, import_react66.useState)(null);
9882
+ const [busy, setBusy] = (0, import_react66.useState)(false);
9883
+ const [said, setSaid] = (0, import_react66.useState)(null);
9884
+ const [error, setError] = (0, import_react66.useState)(null);
9885
+ const [previewing, setPreviewing] = (0, import_react66.useState)(null);
9886
+ const revoke = (0, import_react66.useCallback)(
9607
9887
  async (person) => {
9608
9888
  setBusy(true);
9609
9889
  const answered = await onRevoke(person);
@@ -9680,10 +9960,10 @@ function Preview({
9680
9960
  onPreview
9681
9961
  }) {
9682
9962
  const first = card.tables[0];
9683
- const [which, setWhich] = (0, import_react65.useState)(first?.table_id ?? null);
9684
- const [rows, setRows] = (0, import_react65.useState)(null);
9685
- const [error, setError] = (0, import_react65.useState)(null);
9686
- (0, import_react65.useEffect)(() => {
9963
+ const [which, setWhich] = (0, import_react66.useState)(first?.table_id ?? null);
9964
+ const [rows, setRows] = (0, import_react66.useState)(null);
9965
+ const [error, setError] = (0, import_react66.useState)(null);
9966
+ (0, import_react66.useEffect)(() => {
9687
9967
  if (!which) return;
9688
9968
  let cancelled = false;
9689
9969
  setRows(null);
@@ -9720,16 +10000,16 @@ function Preview({
9720
10000
  ] });
9721
10001
  }
9722
10002
  function Invite({ card, onInvited }) {
9723
- const client = (0, import_react66.useRecordsClient)();
9724
- const [rows, setRows] = (0, import_react65.useState)(null);
9725
- const [titleKey, setTitleKey] = (0, import_react65.useState)(null);
9726
- const [search, setSearch] = (0, import_react65.useState)("");
9727
- const [picked, setPicked] = (0, import_react65.useState)(null);
9728
- const [email, setEmail] = (0, import_react65.useState)("");
9729
- const [busy, setBusy] = (0, import_react65.useState)(false);
9730
- const [said, setSaid] = (0, import_react65.useState)(null);
9731
- const [error, setError] = (0, import_react65.useState)(null);
9732
- (0, import_react65.useEffect)(() => {
10003
+ const client = (0, import_react67.useRecordsClient)();
10004
+ const [rows, setRows] = (0, import_react66.useState)(null);
10005
+ const [titleKey, setTitleKey] = (0, import_react66.useState)(null);
10006
+ const [search, setSearch] = (0, import_react66.useState)("");
10007
+ const [picked, setPicked] = (0, import_react66.useState)(null);
10008
+ const [email, setEmail] = (0, import_react66.useState)("");
10009
+ const [busy, setBusy] = (0, import_react66.useState)(false);
10010
+ const [said, setSaid] = (0, import_react66.useState)(null);
10011
+ const [error, setError] = (0, import_react66.useState)(null);
10012
+ (0, import_react66.useEffect)(() => {
9733
10013
  let cancelled = false;
9734
10014
  void client.list({ table_id: card.client_table_id, limit: 200 }).then((answered) => {
9735
10015
  if (cancelled) return;
@@ -9747,12 +10027,12 @@ function Invite({ card, onInvited }) {
9747
10027
  cancelled = true;
9748
10028
  };
9749
10029
  }, [client, card.client_table_id]);
9750
- const options = (0, import_react65.useMemo)(() => {
10030
+ const options = (0, import_react66.useMemo)(() => {
9751
10031
  const all = (rows ?? []).map((row) => ({ id: row.id, name: rowName(row, titleKey) }));
9752
10032
  const needle = search.trim().toLowerCase();
9753
10033
  return needle === "" ? all.slice(0, 25) : all.filter((o) => o.name.toLowerCase().includes(needle)).slice(0, 25);
9754
10034
  }, [rows, titleKey, search]);
9755
- const send = (0, import_react65.useCallback)(async () => {
10035
+ const send = (0, import_react66.useCallback)(async () => {
9756
10036
  if (!picked) return;
9757
10037
  setBusy(true);
9758
10038
  const answered = await client.portalInvite({
@@ -9831,8 +10111,8 @@ function Invite({ card, onInvited }) {
9831
10111
  }
9832
10112
 
9833
10113
  // src/DigestScheduler.tsx
9834
- var import_react67 = require("react");
9835
- var import_react68 = require("@ai-matrx/records/react");
10114
+ var import_react68 = require("react");
10115
+ var import_react69 = require("@ai-matrx/records/react");
9836
10116
  var import_design_system33 = require("@ai-matrx/design-system");
9837
10117
  var import_jsx_runtime36 = require("react/jsx-runtime");
9838
10118
  var WEEKDAYS = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"];
@@ -9856,27 +10136,27 @@ function DigestScheduler({
9856
10136
  onClose,
9857
10137
  className
9858
10138
  }) {
9859
- const client = (0, import_react68.useRecordsClient)();
10139
+ const client = (0, import_react69.useRecordsClient)();
9860
10140
  const host = useRecordsUi();
9861
- const [views, setViews] = (0, import_react67.useState)(null);
9862
- const [cadences, setCadences] = (0, import_react67.useState)([]);
9863
- const [members, setMembers] = (0, import_react67.useState)(null);
9864
- const [error, setError] = (0, import_react67.useState)(null);
9865
- const [viewId, setViewId] = (0, import_react67.useState)(savedViewId ?? "");
9866
- const [name, setName] = (0, import_react67.useState)(subjectName?.trim() ? `${subjectName.trim()} summary` : "");
9867
- const [cadence, setCadence] = (0, import_react67.useState)("weekly");
9868
- const [weekday, setWeekday] = (0, import_react67.useState)("monday");
9869
- const [time, setTime] = (0, import_react67.useState)("08:00");
9870
- const [channel, setChannel] = (0, import_react67.useState)("in_app");
9871
- const [quiet, setQuiet] = (0, import_react67.useState)(false);
9872
- const [quietFrom, setQuietFrom] = (0, import_react67.useState)("22:00");
9873
- const [quietTo, setQuietTo] = (0, import_react67.useState)("07:00");
9874
- const [recipients, setRecipients] = (0, import_react67.useState)([]);
9875
- const [saving, setSaving] = (0, import_react67.useState)(false);
9876
- const [outcomes, setOutcomes] = (0, import_react67.useState)(null);
9877
- const [preview, setPreview] = (0, import_react67.useState)(null);
9878
- const [previewing, setPreviewing] = (0, import_react67.useState)(false);
9879
- const load = (0, import_react67.useCallback)(async () => {
10141
+ const [views, setViews] = (0, import_react68.useState)(null);
10142
+ const [cadences, setCadences] = (0, import_react68.useState)([]);
10143
+ const [members, setMembers] = (0, import_react68.useState)(null);
10144
+ const [error, setError] = (0, import_react68.useState)(null);
10145
+ const [viewId, setViewId] = (0, import_react68.useState)(savedViewId ?? "");
10146
+ const [name, setName] = (0, import_react68.useState)(subjectName?.trim() ? `${subjectName.trim()} summary` : "");
10147
+ const [cadence, setCadence] = (0, import_react68.useState)("weekly");
10148
+ const [weekday, setWeekday] = (0, import_react68.useState)("monday");
10149
+ const [time, setTime] = (0, import_react68.useState)("08:00");
10150
+ const [channel, setChannel] = (0, import_react68.useState)("in_app");
10151
+ const [quiet, setQuiet] = (0, import_react68.useState)(false);
10152
+ const [quietFrom, setQuietFrom] = (0, import_react68.useState)("22:00");
10153
+ const [quietTo, setQuietTo] = (0, import_react68.useState)("07:00");
10154
+ const [recipients, setRecipients] = (0, import_react68.useState)([]);
10155
+ const [saving, setSaving] = (0, import_react68.useState)(false);
10156
+ const [outcomes, setOutcomes] = (0, import_react68.useState)(null);
10157
+ const [preview, setPreview] = (0, import_react68.useState)(null);
10158
+ const [previewing, setPreviewing] = (0, import_react68.useState)(false);
10159
+ const load = (0, import_react68.useCallback)(async () => {
9880
10160
  const [saved, offered] = await Promise.all([
9881
10161
  // The store's own door onto `platform.saved_view`, narrowed in SQL to
9882
10162
  // Tables this person can already open — never a grant on the table behind it.
@@ -9895,15 +10175,15 @@ function DigestScheduler({
9895
10175
  setMembers([]);
9896
10176
  }
9897
10177
  }, [client, tableId, host]);
9898
- (0, import_react67.useEffect)(() => {
10178
+ (0, import_react68.useEffect)(() => {
9899
10179
  void load();
9900
10180
  }, [load]);
9901
- const schedule = (0, import_react67.useMemo)(() => {
10181
+ const schedule = (0, import_react68.useMemo)(() => {
9902
10182
  if (cadence === "weekly") return `${weekday} ${time}`;
9903
10183
  if (cadence === "daily") return time;
9904
10184
  return null;
9905
10185
  }, [cadence, weekday, time]);
9906
- const quietHours = (0, import_react67.useMemo)(
10186
+ const quietHours = (0, import_react68.useMemo)(
9907
10187
  () => quiet ? { start: quietFrom, end: quietTo } : null,
9908
10188
  [quiet, quietFrom, quietTo]
9909
10189
  );
@@ -10125,8 +10405,8 @@ function DigestScheduler({
10125
10405
  }
10126
10406
 
10127
10407
  // src/SubscriptionsPanel.tsx
10128
- var import_react69 = require("react");
10129
- var import_react70 = require("@ai-matrx/records/react");
10408
+ var import_react70 = require("react");
10409
+ var import_react71 = require("@ai-matrx/records/react");
10130
10410
  var import_design_system34 = require("@ai-matrx/design-system");
10131
10411
  var import_jsx_runtime37 = require("react/jsx-runtime");
10132
10412
  function whenItFires(subscription) {
@@ -10141,14 +10421,14 @@ var CHANNEL_WORDS2 = {
10141
10421
  };
10142
10422
  var DIGEST_SUGGESTION = "Email me a summary of this every Monday at 8 in the morning.";
10143
10423
  function SubscriptionsPanel({ tableId, className }) {
10144
- const client = (0, import_react70.useRecordsClient)();
10145
- const [rows, setRows] = (0, import_react69.useState)(null);
10146
- const [error, setError] = (0, import_react69.useState)(null);
10147
- const [busy, setBusy] = (0, import_react69.useState)(null);
10148
- const [preview, setPreview] = (0, import_react69.useState)(null);
10149
- const [scheduling, setScheduling] = (0, import_react69.useState)(false);
10424
+ const client = (0, import_react71.useRecordsClient)();
10425
+ const [rows, setRows] = (0, import_react70.useState)(null);
10426
+ const [error, setError] = (0, import_react70.useState)(null);
10427
+ const [busy, setBusy] = (0, import_react70.useState)(null);
10428
+ const [preview, setPreview] = (0, import_react70.useState)(null);
10429
+ const [scheduling, setScheduling] = (0, import_react70.useState)(false);
10150
10430
  const host = useRecordsUi();
10151
- const load = (0, import_react69.useCallback)(async () => {
10431
+ const load = (0, import_react70.useCallback)(async () => {
10152
10432
  const answered = await client.subscriptions({ table_id: tableId });
10153
10433
  if (!answered.ok) {
10154
10434
  setError(answered.error);
@@ -10158,10 +10438,10 @@ function SubscriptionsPanel({ tableId, className }) {
10158
10438
  setError(null);
10159
10439
  setRows(answered.data);
10160
10440
  }, [client, tableId]);
10161
- (0, import_react69.useEffect)(() => {
10441
+ (0, import_react70.useEffect)(() => {
10162
10442
  void load();
10163
10443
  }, [load]);
10164
- const flip = (0, import_react69.useCallback)(
10444
+ const flip = (0, import_react70.useCallback)(
10165
10445
  async (subscription, on) => {
10166
10446
  setBusy(subscription.rule_id);
10167
10447
  const answered = await client.subscriptionMute({
@@ -10177,7 +10457,7 @@ function SubscriptionsPanel({ tableId, className }) {
10177
10457
  },
10178
10458
  [client, load]
10179
10459
  );
10180
- const showOne = (0, import_react69.useCallback)(
10460
+ const showOne = (0, import_react70.useCallback)(
10181
10461
  async (subscription) => {
10182
10462
  setBusy(subscription.rule_id);
10183
10463
  const answered = await client.subscriptionPreview({ rule_id: subscription.rule_id });
@@ -10310,14 +10590,14 @@ function SubscriptionsPanel({ tableId, className }) {
10310
10590
  }
10311
10591
 
10312
10592
  // src/FormBuilder.tsx
10313
- var import_react73 = require("react");
10314
- var import_react74 = require("@ai-matrx/records/react");
10593
+ var import_react74 = require("react");
10594
+ var import_react75 = require("@ai-matrx/records/react");
10315
10595
  var import_records7 = require("@ai-matrx/records");
10316
10596
  var import_design_system36 = require("@ai-matrx/design-system");
10317
10597
 
10318
10598
  // src/FormRunner.tsx
10319
- var import_react71 = require("react");
10320
- var import_react72 = require("@ai-matrx/records/react");
10599
+ var import_react72 = require("react");
10600
+ var import_react73 = require("@ai-matrx/records/react");
10321
10601
  var import_design_system35 = require("@ai-matrx/design-system");
10322
10602
  var import_jsx_runtime38 = require("react/jsx-runtime");
10323
10603
  function FormRunner(props) {
@@ -10327,10 +10607,10 @@ function FormRunner(props) {
10327
10607
  return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ConnectedFormRunner, { ...props });
10328
10608
  }
10329
10609
  function ConnectedFormRunner(props) {
10330
- const client = (0, import_react72.useOptionalRecordsClient)();
10331
- const fields = (0, import_react72.useFields)(props.form.subject);
10610
+ const client = (0, import_react73.useOptionalRecordsClient)();
10611
+ const fields = (0, import_react73.useFields)(props.form.subject);
10332
10612
  const { form, className } = props;
10333
- const submit = (0, import_react71.useCallback)(
10613
+ const submit = (0, import_react72.useCallback)(
10334
10614
  async (values) => {
10335
10615
  if (!client) {
10336
10616
  return {
@@ -10353,7 +10633,7 @@ function ConnectedFormRunner(props) {
10353
10633
  },
10354
10634
  [client, form]
10355
10635
  );
10356
- const evaluate = (0, import_react71.useCallback)(
10636
+ const evaluate = (0, import_react72.useCallback)(
10357
10637
  async (expr, values) => {
10358
10638
  if (!client) return null;
10359
10639
  const answered = await client.ruleEval({ expr, values });
@@ -10387,16 +10667,16 @@ function FormStage({
10387
10667
  connected = false
10388
10668
  }) {
10389
10669
  const host = useRecordsUi();
10390
- const [answers, setAnswers] = (0, import_react71.useState)({});
10391
- const [at, setAt] = (0, import_react71.useState)(0);
10392
- const [error, setError] = (0, import_react71.useState)(null);
10393
- const [refusal, setRefusal] = (0, import_react71.useState)(null);
10394
- const [writing, setWriting] = (0, import_react71.useState)(false);
10395
- const [done, setDone] = (0, import_react71.useState)(null);
10396
- const [hidden, setHidden] = (0, import_react71.useState)({});
10397
- const decoy = (0, import_react71.useRef)("");
10398
- const stage = (0, import_react71.useRef)(null);
10399
- const questions = (0, import_react71.useMemo)(() => {
10670
+ const [answers, setAnswers] = (0, import_react72.useState)({});
10671
+ const [at, setAt] = (0, import_react72.useState)(0);
10672
+ const [error, setError] = (0, import_react72.useState)(null);
10673
+ const [refusal, setRefusal] = (0, import_react72.useState)(null);
10674
+ const [writing, setWriting] = (0, import_react72.useState)(false);
10675
+ const [done, setDone] = (0, import_react72.useState)(null);
10676
+ const [hidden, setHidden] = (0, import_react72.useState)({});
10677
+ const decoy = (0, import_react72.useRef)("");
10678
+ const stage = (0, import_react72.useRef)(null);
10679
+ const questions = (0, import_react72.useMemo)(() => {
10400
10680
  const byKey = new Map((fields ?? []).map((f) => [f.key, f]));
10401
10681
  return (form.questions ?? []).map((q) => {
10402
10682
  const field = byKey.get(q.field) ?? null;
@@ -10410,7 +10690,7 @@ function FormStage({
10410
10690
  };
10411
10691
  });
10412
10692
  }, [fields, form.questions]);
10413
- (0, import_react71.useEffect)(() => {
10693
+ (0, import_react72.useEffect)(() => {
10414
10694
  let cancelled = false;
10415
10695
  const conditional = questions.filter((q) => q.showIf);
10416
10696
  if (conditional.length === 0 || !evaluate) return;
@@ -10444,7 +10724,7 @@ function FormStage({
10444
10724
  const v = answers[q.key];
10445
10725
  return q.required && (v === void 0 || v === null || v === "");
10446
10726
  });
10447
- const submit = (0, import_react71.useCallback)(async () => {
10727
+ const submit = (0, import_react72.useCallback)(async () => {
10448
10728
  if (preview) {
10449
10729
  setDone("preview");
10450
10730
  return;
@@ -10481,7 +10761,7 @@ function FormStage({
10481
10761
  if (event.shiftKey) retreat();
10482
10762
  else advance();
10483
10763
  }
10484
- (0, import_react71.useEffect)(() => {
10764
+ (0, import_react72.useEffect)(() => {
10485
10765
  const input = stage.current?.querySelector(
10486
10766
  "input:not([tabindex='-1']), textarea, select, [role='combobox']"
10487
10767
  );
@@ -10575,7 +10855,7 @@ function Question({
10575
10855
  onChange,
10576
10856
  upload
10577
10857
  }) {
10578
- const [uploadError, setUploadError] = (0, import_react71.useState)(null);
10858
+ const [uploadError, setUploadError] = (0, import_react72.useState)(null);
10579
10859
  const field = question.field;
10580
10860
  if (!field) return null;
10581
10861
  const id = `form-${field.key}`;
@@ -10632,23 +10912,23 @@ function whyNotAskable(fields, hidden = []) {
10632
10912
  // src/FormBuilder.tsx
10633
10913
  var import_jsx_runtime39 = require("react/jsx-runtime");
10634
10914
  function FormBuilder({ tableId, seed, activeFormId, onActiveForm, className }) {
10635
- const client = (0, import_react74.useRecordsClient)();
10915
+ const client = (0, import_react75.useRecordsClient)();
10636
10916
  const host = useRecordsUi();
10637
10917
  const claimSeed = useSeedGuard();
10638
- const table = (0, import_react74.useTable)(tableId);
10918
+ const table = (0, import_react75.useTable)(tableId);
10639
10919
  const rights = useTableRights(table.data);
10640
- const fields = (0, import_react74.useFields)(tableId);
10641
- const [forms, setForms] = (0, import_react73.useState)(null);
10642
- const [error, setError] = (0, import_react73.useState)(null);
10643
- const [activeId, setActiveId] = (0, import_react73.useState)(activeFormId ?? null);
10644
- const [draft, setDraft] = (0, import_react73.useState)(null);
10645
- const [saving, setSaving] = (0, import_react73.useState)(false);
10646
- const [saved, setSaved] = (0, import_react73.useState)(null);
10647
- const [publishing, setPublishing] = (0, import_react73.useState)(false);
10648
- const [copied, setCopied] = (0, import_react73.useState)(false);
10649
- const [shownUrl, setShownUrl] = (0, import_react73.useState)(null);
10920
+ const fields = (0, import_react75.useFields)(tableId);
10921
+ const [forms, setForms] = (0, import_react74.useState)(null);
10922
+ const [error, setError] = (0, import_react74.useState)(null);
10923
+ const [activeId, setActiveId] = (0, import_react74.useState)(activeFormId ?? null);
10924
+ const [draft, setDraft] = (0, import_react74.useState)(null);
10925
+ const [saving, setSaving] = (0, import_react74.useState)(false);
10926
+ const [saved, setSaved] = (0, import_react74.useState)(null);
10927
+ const [publishing, setPublishing] = (0, import_react74.useState)(false);
10928
+ const [copied, setCopied] = (0, import_react74.useState)(false);
10929
+ const [shownUrl, setShownUrl] = (0, import_react74.useState)(null);
10650
10930
  const publicOrigin = host.publicOrigin ?? (typeof window === "undefined" ? "" : window.location.origin);
10651
- const load = (0, import_react73.useCallback)(async () => {
10931
+ const load = (0, import_react74.useCallback)(async () => {
10652
10932
  const answered = await client.forms({ table_id: tableId });
10653
10933
  if (!answered.ok) {
10654
10934
  setError(answered.error);
@@ -10675,17 +10955,17 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, className }) {
10675
10955
  setError(null);
10676
10956
  setForms(mine);
10677
10957
  }, [client, tableId, seed, claimSeed]);
10678
- (0, import_react73.useEffect)(() => {
10958
+ (0, import_react74.useEffect)(() => {
10679
10959
  void load();
10680
10960
  }, [load]);
10681
- (0, import_react73.useEffect)(() => {
10961
+ (0, import_react74.useEffect)(() => {
10682
10962
  if (!forms || forms.length === 0) return;
10683
10963
  const chosen = forms.find((f) => f.id === (activeFormId ?? activeId)) ?? forms[0];
10684
10964
  if (chosen.id !== activeId) setActiveId(chosen.id);
10685
10965
  setDraft(chosen);
10686
10966
  onActiveForm?.(chosen);
10687
10967
  }, [forms, activeFormId]);
10688
- const byKey = (0, import_react73.useMemo)(() => new Map((fields.data ?? []).map((f) => [f.key, f])), [fields.data]);
10968
+ const byKey = (0, import_react74.useMemo)(() => new Map((fields.data ?? []).map((f) => [f.key, f])), [fields.data]);
10689
10969
  function patch(change) {
10690
10970
  setDraft((prev) => prev ? { ...prev, ...change } : prev);
10691
10971
  setSaved(null);
@@ -10980,13 +11260,13 @@ function Condition({
10980
11260
  onChange
10981
11261
  }) {
10982
11262
  return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
10983
- ConditionRow,
11263
+ ConditionGroup,
10984
11264
  {
10985
11265
  lead: "Ask only when",
10986
11266
  expr: question.showIf,
10987
11267
  fields: fieldKeys,
10988
11268
  onChange,
10989
- className: "col-span-2 flex items-center gap-1 text-xs"
11269
+ className: "col-span-2 flex flex-col gap-1 text-xs"
10990
11270
  }
10991
11271
  );
10992
11272
  }
@@ -11076,13 +11356,13 @@ function groupLabel(groups) {
11076
11356
  }
11077
11357
 
11078
11358
  // src/chartFrame.tsx
11079
- var import_react75 = require("react");
11359
+ var import_react76 = require("react");
11080
11360
  var import_design_system37 = require("@ai-matrx/design-system");
11081
11361
  var import_jsx_runtime40 = require("react/jsx-runtime");
11082
11362
  function useMeasuredWidth(fallback = 480) {
11083
- const ref = (0, import_react75.useRef)(null);
11084
- const [width, setWidth] = (0, import_react75.useState)(fallback);
11085
- (0, import_react75.useEffect)(() => {
11363
+ const ref = (0, import_react76.useRef)(null);
11364
+ const [width, setWidth] = (0, import_react76.useState)(fallback);
11365
+ (0, import_react76.useEffect)(() => {
11086
11366
  const node = ref.current;
11087
11367
  if (!node) return;
11088
11368
  const apply = () => {
@@ -11112,7 +11392,7 @@ function ChartFrame({
11112
11392
  children
11113
11393
  }) {
11114
11394
  const [ref, width] = useMeasuredWidth();
11115
- const chartId = `records-chart-${(0, import_react75.useId)().replace(/:/g, "")}`;
11395
+ const chartId = `records-chart-${(0, import_react76.useId)().replace(/:/g, "")}`;
11116
11396
  return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
11117
11397
  "div",
11118
11398
  {
@@ -11206,24 +11486,24 @@ function isSignatureField(field) {
11206
11486
  }
11207
11487
 
11208
11488
  // src/DocTemplate.tsx
11209
- var import_react76 = require("react");
11210
- var import_react77 = require("@ai-matrx/records/react");
11489
+ var import_react77 = require("react");
11490
+ var import_react78 = require("@ai-matrx/records/react");
11211
11491
  var import_design_system38 = require("@ai-matrx/design-system");
11212
11492
  var import_jsx_runtime41 = require("react/jsx-runtime");
11213
11493
  function DocTemplate({ tableId, seed, activeTemplateId, onActiveTemplate, className }) {
11214
- const client = (0, import_react77.useRecordsClient)();
11494
+ const client = (0, import_react78.useRecordsClient)();
11215
11495
  const claimSeed = useSeedGuard();
11216
- const table = (0, import_react77.useTable)(tableId);
11496
+ const table = (0, import_react78.useTable)(tableId);
11217
11497
  const rights = useTableRights(table.data);
11218
- const fields = (0, import_react77.useFields)(tableId);
11219
- const [templates, setTemplates] = (0, import_react76.useState)(null);
11220
- const [error, setError] = (0, import_react76.useState)(null);
11221
- const [activeId, setActiveId] = (0, import_react76.useState)(activeTemplateId ?? null);
11222
- const [draftName, setDraftName] = (0, import_react76.useState)("");
11223
- const [draftBody, setDraftBody] = (0, import_react76.useState)("");
11224
- const [unresolved, setUnresolved] = (0, import_react76.useState)([]);
11225
- const [saving, setSaving] = (0, import_react76.useState)(false);
11226
- const load = (0, import_react76.useCallback)(async () => {
11498
+ const fields = (0, import_react78.useFields)(tableId);
11499
+ const [templates, setTemplates] = (0, import_react77.useState)(null);
11500
+ const [error, setError] = (0, import_react77.useState)(null);
11501
+ const [activeId, setActiveId] = (0, import_react77.useState)(activeTemplateId ?? null);
11502
+ const [draftName, setDraftName] = (0, import_react77.useState)("");
11503
+ const [draftBody, setDraftBody] = (0, import_react77.useState)("");
11504
+ const [unresolved, setUnresolved] = (0, import_react77.useState)([]);
11505
+ const [saving, setSaving] = (0, import_react77.useState)(false);
11506
+ const load = (0, import_react77.useCallback)(async () => {
11227
11507
  const held = await client.docTemplates({ table_id: tableId });
11228
11508
  if (!held.ok) {
11229
11509
  setError(held.error);
@@ -11254,10 +11534,10 @@ function DocTemplate({ tableId, seed, activeTemplateId, onActiveTemplate, classN
11254
11534
  setError(null);
11255
11535
  setTemplates(rows);
11256
11536
  }, [client, tableId, seed, fields.data]);
11257
- (0, import_react76.useEffect)(() => {
11537
+ (0, import_react77.useEffect)(() => {
11258
11538
  void load();
11259
11539
  }, [load]);
11260
- (0, import_react76.useEffect)(() => {
11540
+ (0, import_react77.useEffect)(() => {
11261
11541
  if (!templates || templates.length === 0) return;
11262
11542
  const chosen = templates.find((t) => t.id === (activeTemplateId ?? activeId)) ?? templates[0];
11263
11543
  if (chosen.id !== activeId) setActiveId(chosen.id);
@@ -11265,7 +11545,7 @@ function DocTemplate({ tableId, seed, activeTemplateId, onActiveTemplate, classN
11265
11545
  setDraftBody(chosen.body);
11266
11546
  onActiveTemplate?.(chosen);
11267
11547
  }, [templates, activeTemplateId]);
11268
- (0, import_react76.useEffect)(() => {
11548
+ (0, import_react77.useEffect)(() => {
11269
11549
  let cancelled = false;
11270
11550
  if (draftBody.trim() === "") {
11271
11551
  setUnresolved([]);
@@ -11385,19 +11665,19 @@ function DocTemplate({ tableId, seed, activeTemplateId, onActiveTemplate, classN
11385
11665
  }
11386
11666
 
11387
11667
  // src/DocRender.tsx
11388
- var import_react78 = require("react");
11389
- var import_react79 = require("@ai-matrx/records/react");
11668
+ var import_react79 = require("react");
11669
+ var import_react80 = require("@ai-matrx/records/react");
11390
11670
  var import_design_system39 = require("@ai-matrx/design-system");
11391
11671
  var import_jsx_runtime42 = require("react/jsx-runtime");
11392
11672
  function DocRender({ templateId, recordId, filename, onRendered, className }) {
11393
- const client = (0, import_react79.useRecordsClient)();
11394
- const [preview, setPreview] = (0, import_react78.useState)(null);
11395
- const [renders, setRenders] = (0, import_react78.useState)(null);
11396
- const [showing, setShowing] = (0, import_react78.useState)(null);
11397
- const [error, setError] = (0, import_react78.useState)(null);
11398
- const [busy, setBusy] = (0, import_react78.useState)(null);
11399
- const paper = (0, import_react78.useRef)(null);
11400
- const load = (0, import_react78.useCallback)(async () => {
11673
+ const client = (0, import_react80.useRecordsClient)();
11674
+ const [preview, setPreview] = (0, import_react79.useState)(null);
11675
+ const [renders, setRenders] = (0, import_react79.useState)(null);
11676
+ const [showing, setShowing] = (0, import_react79.useState)(null);
11677
+ const [error, setError] = (0, import_react79.useState)(null);
11678
+ const [busy, setBusy] = (0, import_react79.useState)(null);
11679
+ const paper = (0, import_react79.useRef)(null);
11680
+ const load = (0, import_react79.useCallback)(async () => {
11401
11681
  const [body, held] = await Promise.all([
11402
11682
  client.docRenderBody({ template_id: templateId, record_id: recordId }),
11403
11683
  client.docRenders({ record_id: recordId })
@@ -11414,7 +11694,7 @@ function DocRender({ templateId, recordId, filename, onRendered, className }) {
11414
11694
  setPreview(body.data);
11415
11695
  setRenders(held.data.filter((r) => r.template_id === templateId));
11416
11696
  }, [client, templateId, recordId]);
11417
- (0, import_react78.useEffect)(() => {
11697
+ (0, import_react79.useEffect)(() => {
11418
11698
  void load();
11419
11699
  }, [load]);
11420
11700
  async function freeze() {
@@ -11498,22 +11778,22 @@ function DocRender({ templateId, recordId, filename, onRendered, className }) {
11498
11778
  }
11499
11779
 
11500
11780
  // src/SignBlock.tsx
11501
- var import_react80 = require("react");
11502
- var import_react81 = require("@ai-matrx/records/react");
11503
- var import_design_system40 = require("@ai-matrx/design-system");
11781
+ var import_react81 = require("react");
11504
11782
  var import_react82 = require("@ai-matrx/records/react");
11783
+ var import_design_system40 = require("@ai-matrx/design-system");
11784
+ var import_react83 = require("@ai-matrx/records/react");
11505
11785
  var import_jsx_runtime43 = require("react/jsx-runtime");
11506
11786
  function SignBlock({ tableId, recordId, render, className }) {
11507
- const client = (0, import_react81.useRecordsClient)();
11508
- const table = (0, import_react82.useTable)(tableId);
11787
+ const client = (0, import_react82.useRecordsClient)();
11788
+ const table = (0, import_react83.useTable)(tableId);
11509
11789
  const rights = useTableRights(table.data);
11510
- const fields = (0, import_react81.useFields)(tableId);
11511
- const [signatures, setSignatures] = (0, import_react80.useState)(null);
11512
- const [verdicts, setVerdicts] = (0, import_react80.useState)({});
11513
- const [error, setError] = (0, import_react80.useState)(null);
11514
- const [name, setName] = (0, import_react80.useState)("");
11515
- const [busy, setBusy] = (0, import_react80.useState)(false);
11516
- const load = (0, import_react80.useCallback)(async () => {
11790
+ const fields = (0, import_react82.useFields)(tableId);
11791
+ const [signatures, setSignatures] = (0, import_react81.useState)(null);
11792
+ const [verdicts, setVerdicts] = (0, import_react81.useState)({});
11793
+ const [error, setError] = (0, import_react81.useState)(null);
11794
+ const [name, setName] = (0, import_react81.useState)("");
11795
+ const [busy, setBusy] = (0, import_react81.useState)(false);
11796
+ const load = (0, import_react81.useCallback)(async () => {
11517
11797
  const held = await client.docSignatures({ record_id: recordId });
11518
11798
  if (!held.ok) {
11519
11799
  setError(held.error);
@@ -11528,7 +11808,7 @@ function SignBlock({ tableId, recordId, render, className }) {
11528
11808
  }
11529
11809
  setVerdicts(answers);
11530
11810
  }, [client, recordId]);
11531
- (0, import_react80.useEffect)(() => {
11811
+ (0, import_react81.useEffect)(() => {
11532
11812
  void load();
11533
11813
  }, [load]);
11534
11814
  async function sign(field) {
@@ -11635,8 +11915,8 @@ function SignBlock({ tableId, recordId, render, className }) {
11635
11915
  }
11636
11916
 
11637
11917
  // src/NotifyRuleEditor.tsx
11638
- var import_react83 = require("react");
11639
- var import_react84 = require("@ai-matrx/records/react");
11918
+ var import_react84 = require("react");
11919
+ var import_react85 = require("@ai-matrx/records/react");
11640
11920
  var import_design_system41 = require("@ai-matrx/design-system");
11641
11921
  var import_jsx_runtime44 = require("react/jsx-runtime");
11642
11922
  var CADENCE_WORDS2 = {
@@ -11651,16 +11931,16 @@ var CHANNEL_WORDS3 = {
11651
11931
  sms: "by text"
11652
11932
  };
11653
11933
  function NotifyRuleEditor({ tableId, seed, className }) {
11654
- const client = (0, import_react84.useRecordsClient)();
11934
+ const client = (0, import_react85.useRecordsClient)();
11655
11935
  const host = useRecordsUi();
11656
- const table = (0, import_react84.useTable)(tableId);
11936
+ const table = (0, import_react85.useTable)(tableId);
11657
11937
  const rights = useTableRights(table.data);
11658
- const [subscriptions, setSubscriptions] = (0, import_react83.useState)(null);
11659
- const [cadences, setCadences] = (0, import_react83.useState)([]);
11660
- const [views, setViews] = (0, import_react83.useState)(null);
11661
- const [error, setError] = (0, import_react83.useState)(null);
11662
- const [busy, setBusy] = (0, import_react83.useState)(false);
11663
- const load = (0, import_react83.useCallback)(async () => {
11938
+ const [subscriptions, setSubscriptions] = (0, import_react84.useState)(null);
11939
+ const [cadences, setCadences] = (0, import_react84.useState)([]);
11940
+ const [views, setViews] = (0, import_react84.useState)(null);
11941
+ const [error, setError] = (0, import_react84.useState)(null);
11942
+ const [busy, setBusy] = (0, import_react84.useState)(false);
11943
+ const load = (0, import_react84.useCallback)(async () => {
11664
11944
  const [held, offered] = await Promise.all([
11665
11945
  // THE PERSON'S OWN DOOR, not the notifier's. It answers what is addressed
11666
11946
  // to them plus — only where they hold admin on this Table — anyone's over
@@ -11680,10 +11960,10 @@ function NotifyRuleEditor({ tableId, seed, className }) {
11680
11960
  if (host.savedViews) setViews(await host.savedViews());
11681
11961
  else setViews(null);
11682
11962
  }, [client, host, tableId]);
11683
- (0, import_react83.useEffect)(() => {
11963
+ (0, import_react84.useEffect)(() => {
11684
11964
  void load();
11685
11965
  }, [load]);
11686
- const write = (0, import_react83.useCallback)(
11966
+ const write = (0, import_react84.useCallback)(
11687
11967
  async (spec) => {
11688
11968
  const declared = await client.subscriptionDeclare({
11689
11969
  table_id: tableId,
@@ -11708,7 +11988,7 @@ function NotifyRuleEditor({ tableId, seed, className }) {
11708
11988
  },
11709
11989
  [client, tableId]
11710
11990
  );
11711
- (0, import_react83.useEffect)(() => {
11991
+ (0, import_react84.useEffect)(() => {
11712
11992
  if (!subscriptions || !seed || seed.length === 0) return;
11713
11993
  const missing = seed.filter((s) => !subscriptions.some((held) => held.name === s.name));
11714
11994
  if (missing.length === 0) return;
@@ -11851,7 +12131,7 @@ function NotifyRuleEditor({ tableId, seed, className }) {
11851
12131
  }
11852
12132
 
11853
12133
  // src/ChartBlock.tsx
11854
- var import_react85 = require("react");
12134
+ var import_react86 = require("react");
11855
12135
  var import_recharts = require("recharts");
11856
12136
  var import_records8 = require("@ai-matrx/records");
11857
12137
  var import_core6 = require("@ai-matrx/records/core");
@@ -11876,7 +12156,7 @@ function ChartBlock({ block, subject, className }) {
11876
12156
  const measures = block.measures && block.measures.length > 0 ? block.measures : [{ op: "count" }];
11877
12157
  const primary = (0, import_records8.measureKey)(measures[0]);
11878
12158
  const series = [primary];
11879
- const points = (0, import_react85.useMemo)(() => {
12159
+ const points = (0, import_react86.useMemo)(() => {
11880
12160
  if (kind === "stuck") return [];
11881
12161
  const rows = block.rows ?? [];
11882
12162
  return rows.map((row) => ({
@@ -11888,7 +12168,7 @@ function ChartBlock({ block, subject, className }) {
11888
12168
  n: row.row_count
11889
12169
  }));
11890
12170
  }, [block.rows, kind, series.join("|")]);
11891
- const config = (0, import_react85.useMemo)(() => {
12171
+ const config = (0, import_react86.useMemo)(() => {
11892
12172
  const out = {};
11893
12173
  series.forEach((key, index) => {
11894
12174
  out[key] = {
@@ -12149,25 +12429,25 @@ function Drawing({
12149
12429
  }
12150
12430
 
12151
12431
  // src/DashboardCanvas.tsx
12152
- var import_react86 = require("react");
12153
- var import_react87 = require("@ai-matrx/records/react");
12432
+ var import_react87 = require("react");
12433
+ var import_react88 = require("@ai-matrx/records/react");
12154
12434
  var import_design_system43 = require("@ai-matrx/design-system");
12155
12435
  var import_jsx_runtime46 = require("react/jsx-runtime");
12156
12436
  function DashboardCanvas({ tableId, activeDashboardId, filter, className }) {
12157
- const client = (0, import_react87.useRecordsClient)();
12437
+ const client = (0, import_react88.useRecordsClient)();
12158
12438
  const host = useRecordsUi();
12159
- const table = (0, import_react87.useTable)(tableId);
12439
+ const table = (0, import_react88.useTable)(tableId);
12160
12440
  const rights = useTableRights(table.data);
12161
- const fields = (0, import_react87.useFields)(tableId);
12162
- const [boards, setBoards] = (0, import_react86.useState)(null);
12163
- const [error, setError] = (0, import_react86.useState)(null);
12164
- const [activeId, setActiveId] = (0, import_react86.useState)(activeDashboardId ?? null);
12165
- const [run, setRun] = (0, import_react86.useState)(null);
12166
- const [running, setRunning] = (0, import_react86.useState)(false);
12167
- const [question, setQuestion] = (0, import_react86.useState)("");
12168
- const [asking, setAsking] = (0, import_react86.useState)(false);
12169
- const [scheduling, setScheduling] = (0, import_react86.useState)(false);
12170
- const load = (0, import_react86.useCallback)(async () => {
12441
+ const fields = (0, import_react88.useFields)(tableId);
12442
+ const [boards, setBoards] = (0, import_react87.useState)(null);
12443
+ const [error, setError] = (0, import_react87.useState)(null);
12444
+ const [activeId, setActiveId] = (0, import_react87.useState)(activeDashboardId ?? null);
12445
+ const [run, setRun] = (0, import_react87.useState)(null);
12446
+ const [running, setRunning] = (0, import_react87.useState)(false);
12447
+ const [question, setQuestion] = (0, import_react87.useState)("");
12448
+ const [asking, setAsking] = (0, import_react87.useState)(false);
12449
+ const [scheduling, setScheduling] = (0, import_react87.useState)(false);
12450
+ const load = (0, import_react87.useCallback)(async () => {
12171
12451
  const answered = await client.dashboards({ table_id: tableId });
12172
12452
  if (!answered.ok) {
12173
12453
  setError(answered.error);
@@ -12176,17 +12456,17 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, className }) {
12176
12456
  setError(null);
12177
12457
  setBoards(answered.data.map(dashboardFromSummary));
12178
12458
  }, [client, tableId]);
12179
- (0, import_react86.useEffect)(() => {
12459
+ (0, import_react87.useEffect)(() => {
12180
12460
  void load();
12181
12461
  }, [load]);
12182
- (0, import_react86.useEffect)(() => {
12462
+ (0, import_react87.useEffect)(() => {
12183
12463
  if (!boards || boards.length === 0) return;
12184
12464
  const chosen = boards.find((d) => d.id === (activeDashboardId ?? activeId)) ?? boards[0];
12185
12465
  if (chosen.id !== activeId) setActiveId(chosen.id);
12186
12466
  }, [boards, activeDashboardId]);
12187
- const board = (0, import_react86.useMemo)(() => boards?.find((d) => d.id === activeId) ?? null, [boards, activeId]);
12467
+ const board = (0, import_react87.useMemo)(() => boards?.find((d) => d.id === activeId) ?? null, [boards, activeId]);
12188
12468
  const filterKey = JSON.stringify(filter ?? {});
12189
- (0, import_react86.useEffect)(() => {
12469
+ (0, import_react87.useEffect)(() => {
12190
12470
  if (!activeId) {
12191
12471
  setRun(null);
12192
12472
  return;
@@ -12204,7 +12484,7 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, className }) {
12204
12484
  cancelled = true;
12205
12485
  };
12206
12486
  }, [client, activeId, filterKey]);
12207
- const declare2 = (0, import_react86.useCallback)(
12487
+ const declare2 = (0, import_react87.useCallback)(
12208
12488
  async (next, blocks) => {
12209
12489
  const written = await client.dashboardDeclare(
12210
12490
  dashboardDeclareArgs({ ...next, blocks }, tableId)
@@ -12250,7 +12530,7 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, className }) {
12250
12530
  ]
12251
12531
  );
12252
12532
  }
12253
- const refresh = (0, import_react86.useCallback)(async () => {
12533
+ const refresh = (0, import_react87.useCallback)(async () => {
12254
12534
  if (!activeId) return;
12255
12535
  setRunning(true);
12256
12536
  const again = await client.dashboardRun({
@@ -12406,8 +12686,8 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, className }) {
12406
12686
  }
12407
12687
 
12408
12688
  // src/FormsPanel.tsx
12409
- var import_react88 = require("react");
12410
- var import_react89 = require("@ai-matrx/records/react");
12689
+ var import_react89 = require("react");
12690
+ var import_react90 = require("@ai-matrx/records/react");
12411
12691
  var import_records9 = require("@ai-matrx/records");
12412
12692
  var import_design_system44 = require("@ai-matrx/design-system");
12413
12693
  var import_jsx_runtime47 = require("react/jsx-runtime");
@@ -12418,16 +12698,16 @@ function formSuggestion(tableName2) {
12418
12698
  return `Make me a form that collects new ${subject} entries and tells me when somebody answers.`;
12419
12699
  }
12420
12700
  function FormsPanel({ tableId, className }) {
12421
- const client = (0, import_react89.useRecordsClient)();
12701
+ const client = (0, import_react90.useRecordsClient)();
12422
12702
  const host = useRecordsUi();
12423
- const table = (0, import_react89.useTable)(tableId);
12703
+ const table = (0, import_react90.useTable)(tableId);
12424
12704
  const rights = useTableRights(table.data);
12425
- const [forms, setForms] = (0, import_react88.useState)(null);
12426
- const [error, setError] = (0, import_react88.useState)(null);
12427
- const [busy, setBusy] = (0, import_react88.useState)(null);
12428
- const [copied, setCopied] = (0, import_react88.useState)(null);
12429
- const [building, setBuilding] = (0, import_react88.useState)(false);
12430
- const load = (0, import_react88.useCallback)(async () => {
12705
+ const [forms, setForms] = (0, import_react89.useState)(null);
12706
+ const [error, setError] = (0, import_react89.useState)(null);
12707
+ const [busy, setBusy] = (0, import_react89.useState)(null);
12708
+ const [copied, setCopied] = (0, import_react89.useState)(null);
12709
+ const [building, setBuilding] = (0, import_react89.useState)(false);
12710
+ const load = (0, import_react89.useCallback)(async () => {
12431
12711
  const answered = await client.forms({ table_id: tableId });
12432
12712
  if (!answered.ok) {
12433
12713
  setError(answered.error);
@@ -12437,10 +12717,10 @@ function FormsPanel({ tableId, className }) {
12437
12717
  setError(null);
12438
12718
  setForms(answered.data);
12439
12719
  }, [client, tableId]);
12440
- (0, import_react88.useEffect)(() => {
12720
+ (0, import_react89.useEffect)(() => {
12441
12721
  void load();
12442
12722
  }, [load]);
12443
- const toggle = (0, import_react88.useCallback)(
12723
+ const toggle = (0, import_react89.useCallback)(
12444
12724
  async (form) => {
12445
12725
  setBusy(form.form_id);
12446
12726
  const wanted = form.published_at === null || form.closed_at !== null;
@@ -12454,8 +12734,8 @@ function FormsPanel({ tableId, className }) {
12454
12734
  },
12455
12735
  [client, load]
12456
12736
  );
12457
- const [shown, setShown] = (0, import_react88.useState)(null);
12458
- const copy = (0, import_react88.useCallback)(async (url, formId) => {
12737
+ const [shown, setShown] = (0, import_react89.useState)(null);
12738
+ const copy = (0, import_react89.useCallback)(async (url, formId) => {
12459
12739
  try {
12460
12740
  await navigator.clipboard.writeText(url);
12461
12741
  setCopied(formId);
@@ -12553,8 +12833,8 @@ function FormsPanel({ tableId, className }) {
12553
12833
  }
12554
12834
 
12555
12835
  // src/BookingBuilder.tsx
12556
- var import_react90 = require("react");
12557
- var import_react91 = require("@ai-matrx/records/react");
12836
+ var import_react91 = require("react");
12837
+ var import_react92 = require("@ai-matrx/records/react");
12558
12838
  var import_records10 = require("@ai-matrx/records");
12559
12839
  var import_design_system45 = require("@ai-matrx/design-system");
12560
12840
  var import_jsx_runtime48 = require("react/jsx-runtime");
@@ -12582,38 +12862,38 @@ function draftWindows(availability) {
12582
12862
  });
12583
12863
  }
12584
12864
  function BookingBuilder({ tableId, bookingId, onSaved, onClose, className }) {
12585
- const client = (0, import_react91.useRecordsClient)();
12865
+ const client = (0, import_react92.useRecordsClient)();
12586
12866
  const host = useRecordsUi();
12587
- const table = (0, import_react91.useTable)(tableId);
12867
+ const table = (0, import_react92.useTable)(tableId);
12588
12868
  const rights = useTableRights(table.data);
12589
- const fields = (0, import_react91.useFields)(tableId);
12590
- const [existing, setExisting] = (0, import_react90.useState)(null);
12591
- const [loaded, setLoaded] = (0, import_react90.useState)(false);
12592
- const [error, setError] = (0, import_react90.useState)(null);
12593
- const [saving, setSaving] = (0, import_react90.useState)(false);
12594
- const [publishing, setPublishing] = (0, import_react90.useState)(false);
12595
- const [copied, setCopied] = (0, import_react90.useState)(false);
12596
- const [title, setTitle] = (0, import_react90.useState)("");
12597
- const [minutes, setMinutes] = (0, import_react90.useState)(30);
12598
- const [buffer, setBuffer] = (0, import_react90.useState)(0);
12599
- const [lead, setLead] = (0, import_react90.useState)(120);
12600
- const [perDay, setPerDay] = (0, import_react90.useState)(8);
12601
- const [days, setDays] = (0, import_react90.useState)(30);
12602
- const [windows, setWindows] = (0, import_react90.useState)(() => draftWindows(null));
12603
- const [asked, setAsked] = (0, import_react90.useState)([]);
12604
- const [confirmation, setConfirmation] = (0, import_react90.useState)("");
12605
- const [offer, setOffer] = (0, import_react90.useState)(null);
12606
- const [formId, setFormId] = (0, import_react90.useState)(bookingId ?? null);
12869
+ const fields = (0, import_react92.useFields)(tableId);
12870
+ const [existing, setExisting] = (0, import_react91.useState)(null);
12871
+ const [loaded, setLoaded] = (0, import_react91.useState)(false);
12872
+ const [error, setError] = (0, import_react91.useState)(null);
12873
+ const [saving, setSaving] = (0, import_react91.useState)(false);
12874
+ const [publishing, setPublishing] = (0, import_react91.useState)(false);
12875
+ const [copied, setCopied] = (0, import_react91.useState)(false);
12876
+ const [title, setTitle] = (0, import_react91.useState)("");
12877
+ const [minutes, setMinutes] = (0, import_react91.useState)(30);
12878
+ const [buffer, setBuffer] = (0, import_react91.useState)(0);
12879
+ const [lead, setLead] = (0, import_react91.useState)(120);
12880
+ const [perDay, setPerDay] = (0, import_react91.useState)(8);
12881
+ const [days, setDays] = (0, import_react91.useState)(30);
12882
+ const [windows, setWindows] = (0, import_react91.useState)(() => draftWindows(null));
12883
+ const [asked, setAsked] = (0, import_react91.useState)([]);
12884
+ const [confirmation, setConfirmation] = (0, import_react91.useState)("");
12885
+ const [offer, setOffer] = (0, import_react91.useState)(null);
12886
+ const [formId, setFormId] = (0, import_react91.useState)(bookingId ?? null);
12607
12887
  const publicOrigin = host.publicOrigin ?? (typeof window === "undefined" ? "" : window.location.origin);
12608
- const askable = (0, import_react90.useMemo)(
12888
+ const askable = (0, import_react91.useMemo)(
12609
12889
  () => askableFields(fields.data ?? [], STORE_ANSWERS_THESE),
12610
12890
  [fields.data]
12611
12891
  );
12612
- const leftOut = (0, import_react90.useMemo)(
12892
+ const leftOut = (0, import_react91.useMemo)(
12613
12893
  () => whyNotAskable(fields.data ?? [], STORE_ANSWERS_THESE),
12614
12894
  [fields.data]
12615
12895
  );
12616
- const load = (0, import_react90.useCallback)(async () => {
12896
+ const load = (0, import_react91.useCallback)(async () => {
12617
12897
  const answered = await client.bookings({ table_id: tableId });
12618
12898
  if (!answered.ok) {
12619
12899
  setError(answered.error);
@@ -12625,18 +12905,18 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, className }) {
12625
12905
  setLoaded(true);
12626
12906
  if (mine) setFormId(mine.form_id);
12627
12907
  }, [client, tableId, bookingId]);
12628
- (0, import_react90.useEffect)(() => {
12908
+ (0, import_react91.useEffect)(() => {
12629
12909
  void load();
12630
12910
  }, [load]);
12631
- (0, import_react90.useEffect)(() => {
12911
+ (0, import_react91.useEffect)(() => {
12632
12912
  if (title !== "" || !table.data) return;
12633
12913
  setTitle(existing?.title ?? `Book a ${minutes}-minute ${table.data.name} appointment`);
12634
12914
  }, [table.data, existing]);
12635
- (0, import_react90.useEffect)(() => {
12915
+ (0, import_react91.useEffect)(() => {
12636
12916
  if (!existing) return;
12637
12917
  setMinutes(existing.slot_minutes);
12638
12918
  }, [existing]);
12639
- (0, import_react90.useEffect)(() => {
12919
+ (0, import_react91.useEffect)(() => {
12640
12920
  if (!offer) return;
12641
12921
  setWindows(draftWindows(offer));
12642
12922
  setMinutes(offer.slot_minutes);
@@ -12645,7 +12925,7 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, className }) {
12645
12925
  setPerDay(offer.max_per_day);
12646
12926
  setDays(offer.days);
12647
12927
  }, [offer]);
12648
- const availability = (0, import_react90.useCallback)(
12928
+ const availability = (0, import_react91.useCallback)(
12649
12929
  () => ({
12650
12930
  slot_minutes: minutes,
12651
12931
  buffer_minutes: buffer,
@@ -12898,8 +13178,8 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, className }) {
12898
13178
  }
12899
13179
 
12900
13180
  // src/BookingSlots.tsx
12901
- var import_react92 = require("react");
12902
- var import_react93 = require("@ai-matrx/records/react");
13181
+ var import_react93 = require("react");
13182
+ var import_react94 = require("@ai-matrx/records/react");
12903
13183
  var import_records11 = require("@ai-matrx/records");
12904
13184
  var import_design_system46 = require("@ai-matrx/design-system");
12905
13185
  var import_jsx_runtime49 = require("react/jsx-runtime");
@@ -12916,15 +13196,15 @@ var STATE_WORDS = {
12916
13196
  full: "Every time you offered is taken."
12917
13197
  };
12918
13198
  function BookingSlots({ tableId, className }) {
12919
- const client = (0, import_react93.useRecordsClient)();
13199
+ const client = (0, import_react94.useRecordsClient)();
12920
13200
  const host = useRecordsUi();
12921
- const [pages, setPages] = (0, import_react92.useState)(null);
12922
- const [error, setError] = (0, import_react92.useState)(null);
12923
- const [busy, setBusy] = (0, import_react92.useState)(null);
12924
- const [copied, setCopied] = (0, import_react92.useState)(null);
12925
- const [shown, setShown] = (0, import_react92.useState)(null);
12926
- const [building, setBuilding] = (0, import_react92.useState)(false);
12927
- const load = (0, import_react92.useCallback)(async () => {
13201
+ const [pages, setPages] = (0, import_react93.useState)(null);
13202
+ const [error, setError] = (0, import_react93.useState)(null);
13203
+ const [busy, setBusy] = (0, import_react93.useState)(null);
13204
+ const [copied, setCopied] = (0, import_react93.useState)(null);
13205
+ const [shown, setShown] = (0, import_react93.useState)(null);
13206
+ const [building, setBuilding] = (0, import_react93.useState)(false);
13207
+ const load = (0, import_react93.useCallback)(async () => {
12928
13208
  const answered = await client.bookings(tableId ? { table_id: tableId } : {});
12929
13209
  if (!answered.ok) {
12930
13210
  setError(answered.error);
@@ -12934,15 +13214,15 @@ function BookingSlots({ tableId, className }) {
12934
13214
  setError(null);
12935
13215
  setPages(answered.data);
12936
13216
  }, [client, tableId]);
12937
- (0, import_react92.useEffect)(() => {
13217
+ (0, import_react93.useEffect)(() => {
12938
13218
  void load();
12939
13219
  }, [load]);
12940
- const subjectIds = (0, import_react92.useMemo)(
13220
+ const subjectIds = (0, import_react93.useMemo)(
12941
13221
  () => Array.from(new Set((pages ?? []).map((p) => p.table_id))),
12942
13222
  [pages]
12943
13223
  );
12944
- const levels = (0, import_react93.useMyLevels)(subjectIds);
12945
- const toggle = (0, import_react92.useCallback)(
13224
+ const levels = (0, import_react94.useMyLevels)(subjectIds);
13225
+ const toggle = (0, import_react93.useCallback)(
12946
13226
  async (page) => {
12947
13227
  setBusy(page.form_id);
12948
13228
  const wanted = page.published_at === null || page.closed_at !== null;
@@ -12956,7 +13236,7 @@ function BookingSlots({ tableId, className }) {
12956
13236
  },
12957
13237
  [client, load]
12958
13238
  );
12959
- const copy = (0, import_react92.useCallback)(async (url, formId) => {
13239
+ const copy = (0, import_react93.useCallback)(async (url, formId) => {
12960
13240
  try {
12961
13241
  await navigator.clipboard.writeText(url);
12962
13242
  setCopied(formId);
@@ -13091,14 +13371,14 @@ function nextInWords(page) {
13091
13371
  }
13092
13372
 
13093
13373
  // src/CaptureSheet.tsx
13094
- var import_react96 = require("react");
13095
- var import_react97 = require("@ai-matrx/records/react");
13374
+ var import_react97 = require("react");
13375
+ var import_react98 = require("@ai-matrx/records/react");
13096
13376
  var import_design_system48 = require("@ai-matrx/design-system");
13097
13377
 
13098
13378
  // src/CaptureRun.tsx
13099
- var import_react94 = require("react");
13379
+ var import_react95 = require("react");
13100
13380
  var import_records12 = require("@ai-matrx/records");
13101
- var import_react95 = require("@ai-matrx/records/react");
13381
+ var import_react96 = require("@ai-matrx/records/react");
13102
13382
  var import_design_system47 = require("@ai-matrx/design-system");
13103
13383
  var import_jsx_runtime50 = require("react/jsx-runtime");
13104
13384
  function controlFor(field) {
@@ -13137,21 +13417,21 @@ function whereWeAre(timeoutMs = 4e3) {
13137
13417
  });
13138
13418
  }
13139
13419
  function CaptureRun({ sheetId, face: given, className }) {
13140
- const client = (0, import_react95.useRecordsClient)();
13420
+ const client = (0, import_react96.useRecordsClient)();
13141
13421
  const host = useRecordsUi();
13142
- const [face, setFace] = (0, import_react94.useState)(given);
13143
- const [loadFailed, setLoadFailed] = (0, import_react94.useState)(null);
13144
- const [at, setAt] = (0, import_react94.useState)(0);
13145
- const [answers, setAnswers] = (0, import_react94.useState)({});
13146
- const [files, setFiles] = (0, import_react94.useState)({});
13147
- const [missing, setMissing] = (0, import_react94.useState)(null);
13148
- const [done, setDone] = (0, import_react94.useState)(null);
13149
- const [counts, setCounts] = (0, import_react94.useState)({ waiting: 0, sending: 0, refused: 0, landed: 0 });
13150
- const [items, setItems] = (0, import_react94.useState)([]);
13151
- const [lastSynced, setLastSynced] = (0, import_react94.useState)(null);
13152
- const [sending, setSending] = (0, import_react94.useState)(false);
13153
- const queueRef = (0, import_react94.useRef)(null);
13154
- (0, import_react94.useEffect)(() => {
13422
+ const [face, setFace] = (0, import_react95.useState)(given);
13423
+ const [loadFailed, setLoadFailed] = (0, import_react95.useState)(null);
13424
+ const [at, setAt] = (0, import_react95.useState)(0);
13425
+ const [answers, setAnswers] = (0, import_react95.useState)({});
13426
+ const [files, setFiles] = (0, import_react95.useState)({});
13427
+ const [missing, setMissing] = (0, import_react95.useState)(null);
13428
+ const [done, setDone] = (0, import_react95.useState)(null);
13429
+ const [counts, setCounts] = (0, import_react95.useState)({ waiting: 0, sending: 0, refused: 0, landed: 0 });
13430
+ const [items, setItems] = (0, import_react95.useState)([]);
13431
+ const [lastSynced, setLastSynced] = (0, import_react95.useState)(null);
13432
+ const [sending, setSending] = (0, import_react95.useState)(false);
13433
+ const queueRef = (0, import_react95.useRef)(null);
13434
+ (0, import_react95.useEffect)(() => {
13155
13435
  const q2 = (0, import_records12.openCaptureQueue)({
13156
13436
  onChange: (c, all) => {
13157
13437
  setCounts(c);
@@ -13189,7 +13469,7 @@ function CaptureRun({ sheetId, face: given, className }) {
13189
13469
  void q2.sync().then(() => void q2.lastSyncedAt().then(setLastSynced));
13190
13470
  return () => q2.dispose();
13191
13471
  }, [client, host]);
13192
- (0, import_react94.useEffect)(() => {
13472
+ (0, import_react95.useEffect)(() => {
13193
13473
  if (given !== void 0) return;
13194
13474
  let cancelled = false;
13195
13475
  void client.captureOpen({ sheet_id: sheetId }).then((res) => {
@@ -13201,7 +13481,7 @@ function CaptureRun({ sheetId, face: given, className }) {
13201
13481
  cancelled = true;
13202
13482
  };
13203
13483
  }, [client, given, sheetId]);
13204
- const questions = (0, import_react94.useMemo)(() => {
13484
+ const questions = (0, import_react95.useMemo)(() => {
13205
13485
  const asked = face?.presentation?.questions ?? [];
13206
13486
  if (asked.length > 0) return asked;
13207
13487
  return (face?.fields ?? []).map((f) => ({
@@ -13211,11 +13491,11 @@ function CaptureRun({ sheetId, face: given, className }) {
13211
13491
  required: f.required
13212
13492
  }));
13213
13493
  }, [face]);
13214
- const fieldOf = (0, import_react94.useCallback)(
13494
+ const fieldOf = (0, import_react95.useCallback)(
13215
13495
  (key) => (face?.fields ?? []).find((f) => f.key === key),
13216
13496
  [face]
13217
13497
  );
13218
- const sync = (0, import_react94.useCallback)(async () => {
13498
+ const sync = (0, import_react95.useCallback)(async () => {
13219
13499
  const q2 = queueRef.current;
13220
13500
  if (!q2) return;
13221
13501
  setSending(true);
@@ -13228,7 +13508,7 @@ function CaptureRun({ sheetId, face: given, className }) {
13228
13508
  setSending(false);
13229
13509
  }
13230
13510
  }, []);
13231
- const answered = (0, import_react94.useCallback)(
13511
+ const answered = (0, import_react95.useCallback)(
13232
13512
  (key) => {
13233
13513
  if (files[key]) return true;
13234
13514
  const v = answers[key];
@@ -13495,21 +13775,21 @@ function AdHocCaptureSheet({
13495
13775
  attachmentField,
13496
13776
  className
13497
13777
  }) {
13498
- const client = (0, import_react97.useRecordsClient)();
13778
+ const client = (0, import_react98.useRecordsClient)();
13499
13779
  const host = useRecordsUi();
13500
- const table = (0, import_react97.useTable)(tableId);
13501
- const fields = (0, import_react97.useFields)(tableId);
13502
- const [mode, setMode] = (0, import_react96.useState)("reading");
13503
- const [reading, setReading] = (0, import_react96.useState)("");
13504
- const [note, setNote] = (0, import_react96.useState)("");
13505
- const [fileId, setFileId] = (0, import_react96.useState)(null);
13506
- const [pending, setPending] = (0, import_react96.useState)(null);
13507
- const [saved, setSaved] = (0, import_react96.useState)([]);
13508
- const [error, setError] = (0, import_react96.useState)(null);
13509
- const [uploadError, setUploadError] = (0, import_react96.useState)(null);
13510
- const [flushing, setFlushing] = (0, import_react96.useState)(false);
13511
- const queue = (0, import_react96.useRef)([]);
13512
- const keep = (0, import_react96.useCallback)(
13780
+ const table = (0, import_react98.useTable)(tableId);
13781
+ const fields = (0, import_react98.useFields)(tableId);
13782
+ const [mode, setMode] = (0, import_react97.useState)("reading");
13783
+ const [reading, setReading] = (0, import_react97.useState)("");
13784
+ const [note, setNote] = (0, import_react97.useState)("");
13785
+ const [fileId, setFileId] = (0, import_react97.useState)(null);
13786
+ const [pending, setPending] = (0, import_react97.useState)(null);
13787
+ const [saved, setSaved] = (0, import_react97.useState)([]);
13788
+ const [error, setError] = (0, import_react97.useState)(null);
13789
+ const [uploadError, setUploadError] = (0, import_react97.useState)(null);
13790
+ const [flushing, setFlushing] = (0, import_react97.useState)(false);
13791
+ const queue = (0, import_react97.useRef)([]);
13792
+ const keep = (0, import_react97.useCallback)(
13513
13793
  async (next) => {
13514
13794
  queue.current = next;
13515
13795
  setPending(next);
@@ -13517,7 +13797,7 @@ function AdHocCaptureSheet({
13517
13797
  },
13518
13798
  [host]
13519
13799
  );
13520
- (0, import_react96.useEffect)(() => {
13800
+ (0, import_react97.useEffect)(() => {
13521
13801
  let cancelled = false;
13522
13802
  void (async () => {
13523
13803
  const held = host.captureQueue ? await host.captureQueue.load() : [];
@@ -13529,7 +13809,7 @@ function AdHocCaptureSheet({
13529
13809
  cancelled = true;
13530
13810
  };
13531
13811
  }, [host]);
13532
- const resolved = (0, import_react96.useCallback)(() => {
13812
+ const resolved = (0, import_react97.useCallback)(() => {
13533
13813
  const all = fields.data ?? [];
13534
13814
  return {
13535
13815
  reading: readingField ?? all.find((f) => f.type === "range")?.key ?? null,
@@ -13537,7 +13817,7 @@ function AdHocCaptureSheet({
13537
13817
  attachment: attachmentField ?? all.find((f) => f.format === "file" || f.format === "image")?.key ?? null
13538
13818
  };
13539
13819
  }, [attachmentField, fields.data, noteField, readingField, table.data]);
13540
- const flush = (0, import_react96.useCallback)(async () => {
13820
+ const flush = (0, import_react97.useCallback)(async () => {
13541
13821
  if (flushing || queue.current.length === 0) return;
13542
13822
  setFlushing(true);
13543
13823
  const left = [];
@@ -13696,18 +13976,18 @@ function AdHocCaptureSheet({
13696
13976
  }
13697
13977
 
13698
13978
  // src/PortalShell.tsx
13699
- var import_react98 = require("react");
13700
- var import_react99 = require("@ai-matrx/records/react");
13979
+ var import_react99 = require("react");
13980
+ var import_react100 = require("@ai-matrx/records/react");
13701
13981
  var import_design_system49 = require("@ai-matrx/design-system");
13702
13982
  var import_jsx_runtime52 = require("react/jsx-runtime");
13703
13983
  function PortalShell({ tableId, form, resourceType = "record", className }) {
13704
- const client = (0, import_react99.useRecordsClient)();
13705
- const [card, setCard] = (0, import_react98.useState)(null);
13706
- const [reach, setReach] = (0, import_react98.useState)(null);
13707
- const [error, setError] = (0, import_react98.useState)(null);
13708
- const [open, setOpen] = (0, import_react98.useState)(null);
13709
- const [sending, setSending] = (0, import_react98.useState)(false);
13710
- const load = (0, import_react98.useCallback)(async () => {
13984
+ const client = (0, import_react100.useRecordsClient)();
13985
+ const [card, setCard] = (0, import_react99.useState)(null);
13986
+ const [reach, setReach] = (0, import_react99.useState)(null);
13987
+ const [error, setError] = (0, import_react99.useState)(null);
13988
+ const [open, setOpen] = (0, import_react99.useState)(null);
13989
+ const [sending, setSending] = (0, import_react99.useState)(false);
13990
+ const load = (0, import_react99.useCallback)(async () => {
13711
13991
  const who = await client.externalPrincipalCard();
13712
13992
  if (!who.ok) {
13713
13993
  setError(who.error);
@@ -13722,7 +14002,7 @@ function PortalShell({ tableId, form, resourceType = "record", className }) {
13722
14002
  }
13723
14003
  setReach(reached.data.map((row) => row.resource_id));
13724
14004
  }, [client, resourceType]);
13725
- (0, import_react98.useEffect)(() => {
14005
+ (0, import_react99.useEffect)(() => {
13726
14006
  void load();
13727
14007
  }, [load]);
13728
14008
  if (error) {
@@ -13780,9 +14060,9 @@ function PortalShell({ tableId, form, resourceType = "record", className }) {
13780
14060
  ] });
13781
14061
  }
13782
14062
  function PortalRow({ tableId, recordId }) {
13783
- const client = (0, import_react99.useRecordsClient)();
13784
- const [title, setTitle] = (0, import_react98.useState)(null);
13785
- (0, import_react98.useEffect)(() => {
14063
+ const client = (0, import_react100.useRecordsClient)();
14064
+ const [title, setTitle] = (0, import_react99.useState)(null);
14065
+ (0, import_react99.useEffect)(() => {
13786
14066
  let cancelled = false;
13787
14067
  void client.recordRead({ record_id: recordId }).then((answered) => {
13788
14068
  if (cancelled) return;
@@ -13802,18 +14082,18 @@ function PortalRow({ tableId, recordId }) {
13802
14082
  }
13803
14083
 
13804
14084
  // src/PublicViewPage.tsx
13805
- var import_react100 = require("react");
13806
- var import_react101 = require("@ai-matrx/records/react");
14085
+ var import_react101 = require("react");
14086
+ var import_react102 = require("@ai-matrx/records/react");
13807
14087
  var import_design_system50 = require("@ai-matrx/design-system");
13808
14088
  var import_jsx_runtime53 = require("react/jsx-runtime");
13809
14089
  function PublicViewPage({ slug, className }) {
13810
- const client = (0, import_react101.useRecordsClient)();
13811
- const [binding, setBinding] = (0, import_react100.useState)(null);
13812
- const [rows, setRows] = (0, import_react100.useState)(null);
13813
- const [fields, setFields] = (0, import_react100.useState)(null);
13814
- const [error, setError] = (0, import_react100.useState)(null);
13815
- const [gap, setGap] = (0, import_react100.useState)(null);
13816
- const load = (0, import_react100.useCallback)(async () => {
14090
+ const client = (0, import_react102.useRecordsClient)();
14091
+ const [binding, setBinding] = (0, import_react101.useState)(null);
14092
+ const [rows, setRows] = (0, import_react101.useState)(null);
14093
+ const [fields, setFields] = (0, import_react101.useState)(null);
14094
+ const [error, setError] = (0, import_react101.useState)(null);
14095
+ const [gap, setGap] = (0, import_react101.useState)(null);
14096
+ const load = (0, import_react101.useCallback)(async () => {
13817
14097
  const notice = await client.worldPublishGapNotice();
13818
14098
  if (notice.ok) setGap(notice.data);
13819
14099
  const resolved = await client.resolvePublishBinding({ slug });
@@ -13846,7 +14126,7 @@ function PublicViewPage({ slug, className }) {
13846
14126
  }
13847
14127
  setRows([{ id: found.resource_id, document: read.data.document, level: "viewer", hidden: read.data.hidden }]);
13848
14128
  }, [client, slug]);
13849
- (0, import_react100.useEffect)(() => {
14129
+ (0, import_react101.useEffect)(() => {
13850
14130
  void load();
13851
14131
  }, [load]);
13852
14132
  if (error) return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(RefusalNotice, { error, className });
@@ -13883,10 +14163,10 @@ function PublicRow({ row, fields }) {
13883
14163
  }
13884
14164
 
13885
14165
  // src/EmbedFrame.tsx
13886
- var import_react102 = require("react");
13887
- var import_react103 = require("@ai-matrx/records/react");
13888
- var import_design_system51 = require("@ai-matrx/design-system");
14166
+ var import_react103 = require("react");
13889
14167
  var import_react104 = require("@ai-matrx/records/react");
14168
+ var import_design_system51 = require("@ai-matrx/design-system");
14169
+ var import_react105 = require("@ai-matrx/records/react");
13890
14170
  var import_jsx_runtime54 = require("react/jsx-runtime");
13891
14171
  function EmbedFrame({
13892
14172
  tableId,
@@ -13896,18 +14176,18 @@ function EmbedFrame({
13896
14176
  embedUrl,
13897
14177
  className
13898
14178
  }) {
13899
- const client = (0, import_react103.useRecordsClient)();
14179
+ const client = (0, import_react104.useRecordsClient)();
13900
14180
  const host = useRecordsUi();
13901
- const table = (0, import_react104.useTable)(tableId);
14181
+ const table = (0, import_react105.useTable)(tableId);
13902
14182
  const rights = useTableRights(table.data);
13903
- const [origins, setOrigins] = (0, import_react102.useState)("");
13904
- const [secret, setSecret] = (0, import_react102.useState)(null);
13905
- const [tokenId, setTokenId] = (0, import_react102.useState)(null);
13906
- const [error, setError] = (0, import_react102.useState)(null);
13907
- const [busy, setBusy] = (0, import_react102.useState)(false);
14183
+ const [origins, setOrigins] = (0, import_react103.useState)("");
14184
+ const [secret, setSecret] = (0, import_react103.useState)(null);
14185
+ const [tokenId, setTokenId] = (0, import_react103.useState)(null);
14186
+ const [error, setError] = (0, import_react103.useState)(null);
14187
+ const [busy, setBusy] = (0, import_react103.useState)(false);
13908
14188
  const mode = formId ? "write" : "read";
13909
14189
  const parsed = origins.split(/[\s,]+/).map((o) => o.trim()).filter((o) => o.length > 0);
13910
- const issue = (0, import_react102.useCallback)(async () => {
14190
+ const issue = (0, import_react103.useCallback)(async () => {
13911
14191
  setBusy(true);
13912
14192
  setError(null);
13913
14193
  const minted = await client.anonTokenIssue({
@@ -13926,7 +14206,7 @@ function EmbedFrame({
13926
14206
  setTokenId(minted.data.token_id);
13927
14207
  host.notify?.success("Embed token issued. Copy it now \u2014 it is never shown again.");
13928
14208
  }, [client, formId, host, mode, parsed, recordId, savedViewId]);
13929
- const revoke = (0, import_react102.useCallback)(async () => {
14209
+ const revoke = (0, import_react103.useCallback)(async () => {
13930
14210
  if (!tokenId) return;
13931
14211
  setBusy(true);
13932
14212
  const done = await client.anonTokenRevoke({ token_id: tokenId });
@@ -13990,13 +14270,13 @@ function EmbedFrame({
13990
14270
  ] });
13991
14271
  }
13992
14272
  function useEmbedHandshake(args) {
13993
- const client = (0, import_react103.useRecordsClient)();
13994
- const [binding, setBinding] = (0, import_react102.useState)(null);
13995
- const [error, setError] = (0, import_react102.useState)(null);
13996
- const [loading, setLoading] = (0, import_react102.useState)(true);
14273
+ const client = (0, import_react104.useRecordsClient)();
14274
+ const [binding, setBinding] = (0, import_react103.useState)(null);
14275
+ const [error, setError] = (0, import_react103.useState)(null);
14276
+ const [loading, setLoading] = (0, import_react103.useState)(true);
13997
14277
  const origin = args.origin ?? (typeof location === "undefined" ? "" : location.origin);
13998
14278
  const { secret, requiredMode } = args;
13999
- (0, import_react102.useEffect)(() => {
14279
+ (0, import_react103.useEffect)(() => {
14000
14280
  let cancelled = false;
14001
14281
  setLoading(true);
14002
14282
  setError(null);
@@ -14018,7 +14298,7 @@ function useEmbedHandshake(args) {
14018
14298
  }
14019
14299
 
14020
14300
  // src/RecordsMount.tsx
14021
- var import_react105 = require("@ai-matrx/records/react");
14301
+ var import_react106 = require("@ai-matrx/records/react");
14022
14302
  var import_jsx_runtime55 = require("react/jsx-runtime");
14023
14303
  var STORE_DECIDES_REASON = "This host offers exactly what the record store says this person may do: the level comes back with the table on the read door, so a control they cannot use is never drawn in the first place.";
14024
14304
  function storeDecidesRights(_table) {
@@ -14032,7 +14312,7 @@ function RecordsMount({
14032
14312
  }) {
14033
14313
  const bound = { ...host ?? {} };
14034
14314
  void letTheStoreDecideRights;
14035
- return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_react105.RecordsProvider, { config, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(RecordsUiProvider, { value: bound, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(RecordLabelProvider, { children }) }) });
14315
+ return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_react106.RecordsProvider, { config, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(RecordsUiProvider, { value: bound, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(RecordLabelProvider, { children }) }) });
14036
14316
  }
14037
14317
  function personActor(userId) {
14038
14318
  return userId ? { actor: "user", user_id: userId } : { actor: "user" };
@@ -14051,8 +14331,8 @@ function recordsDataSource(client, fallbackSchema = "custom") {
14051
14331
  }
14052
14332
 
14053
14333
  // src/TablesHome.tsx
14054
- var import_react106 = require("react");
14055
- var import_react107 = require("@ai-matrx/records/react");
14334
+ var import_react107 = require("react");
14335
+ var import_react108 = require("@ai-matrx/records/react");
14056
14336
  var import_design_system52 = require("@ai-matrx/design-system");
14057
14337
 
14058
14338
  // src/createTable.ts
@@ -14188,15 +14468,15 @@ function laneFor(table) {
14188
14468
  return "organization";
14189
14469
  }
14190
14470
  function TablesHome({ onOpenTable, className }) {
14191
- const client = (0, import_react107.useRecordsClient)();
14192
- const tables = (0, import_react107.useTables)();
14193
- const [creating, setCreating] = (0, import_react106.useState)(false);
14194
- const [name, setName] = (0, import_react106.useState)("");
14195
- const [busy, setBusy] = (0, import_react106.useState)(false);
14196
- const [error, setError] = (0, import_react106.useState)(null);
14197
- const [importInto, setImportInto] = (0, import_react106.useState)(null);
14198
- const [boards, setBoards] = (0, import_react106.useState)(null);
14199
- (0, import_react106.useEffect)(() => {
14471
+ const client = (0, import_react108.useRecordsClient)();
14472
+ const tables = (0, import_react108.useTables)();
14473
+ const [creating, setCreating] = (0, import_react107.useState)(false);
14474
+ const [name, setName] = (0, import_react107.useState)("");
14475
+ const [busy, setBusy] = (0, import_react107.useState)(false);
14476
+ const [error, setError] = (0, import_react107.useState)(null);
14477
+ const [importInto, setImportInto] = (0, import_react107.useState)(null);
14478
+ const [boards, setBoards] = (0, import_react107.useState)(null);
14479
+ (0, import_react107.useEffect)(() => {
14200
14480
  let cancelled = false;
14201
14481
  void client.dashboards({}).then((result) => {
14202
14482
  if (cancelled) return;
@@ -14206,7 +14486,7 @@ function TablesHome({ onOpenTable, className }) {
14206
14486
  cancelled = true;
14207
14487
  };
14208
14488
  }, [client]);
14209
- const create = (0, import_react106.useCallback)(
14489
+ const create = (0, import_react107.useCallback)(
14210
14490
  async (mode) => {
14211
14491
  const trimmed = name.trim();
14212
14492
  if (!trimmed) return;
@@ -14330,8 +14610,8 @@ function TablesHome({ onOpenTable, className }) {
14330
14610
  }
14331
14611
 
14332
14612
  // src/TablePage.tsx
14333
- var import_react108 = require("react");
14334
- var import_react109 = require("@ai-matrx/records/react");
14613
+ var import_react109 = require("react");
14614
+ var import_react110 = require("@ai-matrx/records/react");
14335
14615
  var import_design_system53 = require("@ai-matrx/design-system");
14336
14616
  var import_jsx_runtime57 = require("react/jsx-runtime");
14337
14617
  var TABLE_NOT_REACHABLE = "This table is not in the organization you are working in, so there is nothing here to show. Switch to the organization that owns it and open it again \u2014 or it may have been deleted.";
@@ -14354,6 +14634,19 @@ function surfaceChosen(current, asking) {
14354
14634
  function openingRail(activeRecordId) {
14355
14635
  return activeRecordId ? { rail: "record", record: activeRecordId } : { rail: "none", record: null };
14356
14636
  }
14637
+ function openingView(activeView, activeDashboardId) {
14638
+ const named = pageViewFromParam(activeView);
14639
+ if (named === null) {
14640
+ const asked = typeof activeView === "string" ? activeView.trim() : "";
14641
+ return {
14642
+ main: activeDashboardId ? "dashboards" : "records",
14643
+ layout: null,
14644
+ unknown: asked === "" ? null : asked
14645
+ };
14646
+ }
14647
+ if (named === "dashboards") return { main: "dashboards", layout: null, unknown: null };
14648
+ return { main: "records", layout: named, unknown: null };
14649
+ }
14357
14650
  function TablePage({
14358
14651
  tableId,
14359
14652
  pageSize = 100,
@@ -14362,31 +14655,48 @@ function TablePage({
14362
14655
  leaveLabel = "Back to your tables",
14363
14656
  activeDashboardId,
14364
14657
  activeRecordId,
14658
+ activeView,
14659
+ onViewChanged,
14365
14660
  className
14366
14661
  }) {
14367
- const client = (0, import_react109.useRecordsClient)();
14368
- const table = (0, import_react109.useTable)(tableId);
14662
+ const client = (0, import_react110.useRecordsClient)();
14663
+ const table = (0, import_react110.useTable)(tableId);
14369
14664
  const rights = useTableRights(table.data);
14370
- const organizationId = (0, import_react109.useRecordsClient)().config.organizationId;
14371
- const [view, setView] = (0, import_react108.useState)(null);
14665
+ const organizationId = (0, import_react110.useRecordsClient)().config.organizationId;
14666
+ const [view, setView] = (0, import_react109.useState)(null);
14372
14667
  const opening = openingRail(activeRecordId);
14373
- const [asking, setAsking] = (0, import_react108.useState)(null);
14374
- const [surface, setSurface] = (0, import_react108.useState)({
14375
- main: activeDashboardId ? "dashboards" : "records",
14668
+ const opened = openingView(activeView, activeDashboardId);
14669
+ const [asking, setAsking] = (0, import_react109.useState)(null);
14670
+ const [layoutFromLink, setLayoutFromLink] = (0, import_react109.useState)(opened.layout);
14671
+ const [surface, setSurface] = (0, import_react109.useState)({
14672
+ main: opened.main,
14376
14673
  rail: opening.rail
14377
14674
  });
14378
14675
  const { main, rail } = surface;
14379
14676
  const setRail = (next) => setSurface((now) => ({ ...now, rail: next }));
14380
- const [openRecord, setOpenRecord] = (0, import_react108.useState)(opening.record);
14677
+ const [openRecord, setOpenRecord] = (0, import_react109.useState)(opening.record);
14381
14678
  const viewVersion = useRecordVersion(view?.id ?? null);
14382
- const press = (pressed) => setSurface((now) => chooseSurface(now, pressed));
14679
+ const shownLayout = layoutFromLink ?? view?.layout ?? "grid";
14680
+ const press = (pressed) => {
14681
+ const next = chooseSurface(surface, pressed);
14682
+ setSurface(next);
14683
+ if (next.main !== surface.main) {
14684
+ onViewChanged?.(next.main === "dashboards" ? "dashboards" : shownLayout);
14685
+ }
14686
+ };
14383
14687
  const show = (next) => press({ rail: next });
14384
- (0, import_react108.useEffect)(() => {
14688
+ (0, import_react109.useEffect)(() => {
14385
14689
  if (!activeRecordId) return;
14386
14690
  setOpenRecord(activeRecordId);
14387
14691
  setSurface((now) => ({ ...now, rail: "record" }));
14388
14692
  }, [activeRecordId]);
14389
- const patchView = (0, import_react108.useCallback)(
14693
+ (0, import_react109.useEffect)(() => {
14694
+ const named = pageViewFromParam(activeView);
14695
+ if (named === null) return;
14696
+ setLayoutFromLink(named === "dashboards" ? null : named);
14697
+ setSurface((now) => ({ ...now, main: named === "dashboards" ? "dashboards" : "records" }));
14698
+ }, [activeView]);
14699
+ const patchView = (0, import_react109.useCallback)(
14390
14700
  async (patch) => {
14391
14701
  const current = view;
14392
14702
  if (!current) return;
@@ -14539,11 +14849,16 @@ function TablePage({
14539
14849
  /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(ExportMenu, { tableId })
14540
14850
  ] }),
14541
14851
  main === "dashboards" ? /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(DashboardCanvas, { tableId, activeDashboardId: activeDashboardId ?? null }) : /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_jsx_runtime57.Fragment, { children: [
14852
+ opened.unknown ? /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("p", { className: "rounded-md border border-amber-600/40 bg-amber-500/5 px-3 py-2 text-xs leading-relaxed text-amber-700 dark:border-amber-400/40 dark:text-amber-300", children: unknownViewLine(opened.unknown) }) : null,
14542
14853
  /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
14543
14854
  ViewSwitcher,
14544
14855
  {
14545
- view: view ?? defaultView(tableId),
14856
+ view: { ...view ?? defaultView(tableId), layout: shownLayout },
14546
14857
  pageSize,
14858
+ onLayoutChange: (layout) => {
14859
+ setLayoutFromLink(layout);
14860
+ onViewChanged?.(layout);
14861
+ },
14547
14862
  ...view ? { onViewChange: (patch) => void patchView(patch) } : {},
14548
14863
  ...rights.write ? { onNewRecordForm: () => setRail("new-record") } : {},
14549
14864
  onOpenRecord: (recordId) => {