@ai-matrx/records-ui 0.110.7 → 0.110.9

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
@@ -85,7 +85,7 @@ __export(src_exports, {
85
85
  DATA_BINDING_MISSING: () => DATA_BINDING_MISSING,
86
86
  DATA_BINDING_SHAPES: () => DATA_BINDING_SHAPES,
87
87
  DEFAULT_ACTION_ORIGIN: () => DEFAULT_ACTION_ORIGIN,
88
- DEFAULT_FIELDS: () => import_core2.DEFAULT_FIELDS,
88
+ DEFAULT_FIELDS: () => import_core3.DEFAULT_FIELDS,
89
89
  DEFAULT_FOOTER: () => DEFAULT_FOOTER,
90
90
  DEFAULT_VIEW_NAME: () => DEFAULT_VIEW_NAME,
91
91
  DUE_STATE_LABEL: () => DUE_STATE_LABEL,
@@ -308,7 +308,7 @@ __export(src_exports, {
308
308
  actorBadge: () => actorBadge,
309
309
  actorWords: () => actorWords,
310
310
  addDays: () => addDays,
311
- addFields: () => import_core2.addFields,
311
+ addFields: () => import_core3.addFields,
312
312
  announceTableArchived: () => announceTableArchived,
313
313
  applyLook: () => applyLook,
314
314
  archiveConfirmSentence: () => archiveConfirmSentence,
@@ -360,7 +360,7 @@ __export(src_exports, {
360
360
  dayAt: () => dayAt,
361
361
  dayKeyOf: () => dayKeyOf,
362
362
  daysBetween: () => daysBetween,
363
- declareTable: () => import_core2.declareTable,
363
+ declareTable: () => import_core3.declareTable,
364
364
  declareView: () => declareView,
365
365
  defaultBindingTemplate: () => defaultBindingTemplate,
366
366
  defaultViewOf: () => defaultViewOf,
@@ -391,7 +391,7 @@ __export(src_exports, {
391
391
  entityTitleColumn: () => entityTitleColumn,
392
392
  entityValueText: () => entityValueText,
393
393
  envelopeFor: () => envelopeFor,
394
- fieldDeclarationFor: () => import_core2.fieldDeclarationFor,
394
+ fieldDeclarationFor: () => import_core3.fieldDeclarationFor,
395
395
  fieldIsEditable: () => fieldIsEditable,
396
396
  fieldName: () => fieldName,
397
397
  fieldToken: () => fieldToken,
@@ -557,7 +557,7 @@ __export(src_exports, {
557
557
  titleRepeats: () => titleRepeats,
558
558
  toDropdownEntries: () => toDropdownEntries,
559
559
  toStripAndRows: () => toStripAndRows,
560
- tokenFor: () => import_core2.tokenFor,
560
+ tokenFor: () => import_core3.tokenFor,
561
561
  unknownRailLine: () => unknownRailLine,
562
562
  unknownViewLine: () => unknownViewLine,
563
563
  unreadableKeys: () => unreadableKeys,
@@ -1701,6 +1701,11 @@ function inColumnWords(error, fields) {
1701
1701
  }
1702
1702
 
1703
1703
  // src/askOnce.ts
1704
+ var import_core = require("@ai-matrx/records/core");
1705
+ var structureEpoch = 0;
1706
+ (0, import_core.onTableStructureChanged)(() => {
1707
+ structureEpoch += 1;
1708
+ });
1704
1709
  var asked = /* @__PURE__ */ new WeakMap();
1705
1710
  var byPerson = /* @__PURE__ */ new WeakMap();
1706
1711
  function heldFor(client) {
@@ -1731,7 +1736,7 @@ function askOnce(client, key, ask, freshMs) {
1731
1736
  const held = heldFor(client);
1732
1737
  const now = Date.now();
1733
1738
  const kept = held.get(key);
1734
- if (kept && now - kept.at <= freshMs) return kept.answer;
1739
+ if (kept && kept.epoch === structureEpoch && now - kept.at <= freshMs) return kept.answer;
1735
1740
  const answer = ask().then(
1736
1741
  (result) => {
1737
1742
  if (!result.ok) held.delete(key);
@@ -1742,17 +1747,18 @@ function askOnce(client, key, ask, freshMs) {
1742
1747
  throw thrown;
1743
1748
  }
1744
1749
  );
1745
- held.set(key, { at: now, answer });
1750
+ held.set(key, { at: now, epoch: structureEpoch, answer });
1746
1751
  return answer;
1747
1752
  }
1748
1753
  function forgetAsked(client, prefix) {
1749
1754
  const held = heldFor(client);
1750
1755
  for (const key of [...held.keys()]) if (key.startsWith(prefix)) held.delete(key);
1751
1756
  }
1752
- var FIELD_OPTIONS_FRESH_MS = 2e3;
1757
+ var FIELD_OPTIONS_FRESH_MS = 1e4;
1753
1758
  function fieldOptionsOnce(client, fieldId) {
1754
1759
  return askOnce(client, `field_options:${fieldId}`, () => client.fieldOptions({ field_id: fieldId }), FIELD_OPTIONS_FRESH_MS);
1755
1760
  }
1761
+ var ENRICH_CELLS_FRESH_MS = 5e3;
1756
1762
 
1757
1763
  // src/labels.tsx
1758
1764
  var import_react7 = require("react");
@@ -2847,15 +2853,18 @@ function rowSection(rowId, ctx, rowText) {
2847
2853
  items.push({ id: "row-history", label: "Row history", icon: "history", onSelect: () => a.openRecord?.(rowId) });
2848
2854
  }
2849
2855
  items.push(...ctx.extras?.row?.(rowId) ?? []);
2850
- items.push({
2851
- id: "row-archive",
2852
- label: "Archive record",
2853
- icon: "trash",
2854
- destructive: true,
2855
- separatorBefore: true,
2856
- disabledReason: mayWrite ? void 0 : ctx.whyNotWrite(rowId),
2857
- onSelect: () => a.archiveRow(rowId)
2858
- });
2856
+ const mayRemove = mayWrite && (ctx.mayRemoveRow ? ctx.mayRemoveRow(rowId) : true);
2857
+ if (mayRemove || !ctx.hideRefusedRowActions) {
2858
+ items.push({
2859
+ id: "row-archive",
2860
+ label: "Archive record",
2861
+ icon: "trash",
2862
+ destructive: true,
2863
+ separatorBefore: true,
2864
+ disabledReason: mayRemove ? void 0 : !mayWrite ? ctx.whyNotWrite(rowId) : ctx.whyNotRemove?.(rowId) ?? ctx.whyNotWrite(rowId),
2865
+ onSelect: () => a.archiveRow(rowId)
2866
+ });
2867
+ }
2859
2868
  return { id: "row", title: ctx.extras?.rowTitle?.(rowId) || "Row", items };
2860
2869
  }
2861
2870
  function columnSection(columnId2, columnLabel2, ctx) {
@@ -3608,7 +3617,7 @@ function useTableVersion(client, tableId, table) {
3608
3617
  }
3609
3618
 
3610
3619
  // src/writeOnTheWinningVersion.ts
3611
- var import_core = require("@ai-matrx/records/core");
3620
+ var import_core2 = require("@ai-matrx/records/core");
3612
3621
  function sameStoredValue(left, right) {
3613
3622
  if (left === right) return true;
3614
3623
  const empty = (v) => v === null || v === void 0 || v === "";
@@ -3626,7 +3635,7 @@ async function updateOnTheWinningVersion(client, recordId, patch, expectedVersio
3626
3635
  const send = (expected) => updateRecordAt(client, { record_id: recordId, patch, version: expected });
3627
3636
  const first = await send(expectedVersion);
3628
3637
  if (first.ok) return first;
3629
- const conflict = (0, import_core.asWriteConflict)(first.error, recordId);
3638
+ const conflict = (0, import_core2.asWriteConflict)(first.error, recordId);
3630
3639
  if (!conflict) return first;
3631
3640
  const untouched = base === "always" || Object.keys(patch).every((key) => sameStoredValue(conflict.contested_fields[key], base[key]));
3632
3641
  if (!untouched) return first;
@@ -3749,10 +3758,10 @@ async function saveTableDescription(client, tableId, text2) {
3749
3758
  // src/ReferenceBuilder.tsx
3750
3759
  var import_react18 = require("react");
3751
3760
  var import_react19 = require("@ai-matrx/records/react");
3752
- var import_core3 = require("@ai-matrx/records/core");
3761
+ var import_core4 = require("@ai-matrx/records/core");
3753
3762
 
3754
3763
  // src/createTable.ts
3755
- var import_core2 = require("@ai-matrx/records/core");
3764
+ var import_core3 = require("@ai-matrx/records/core");
3756
3765
 
3757
3766
  // src/tablePicking.tsx
3758
3767
  var import_react16 = require("react");
@@ -3925,7 +3934,7 @@ function ReferenceBuilder({
3925
3934
  if (!name || making) return;
3926
3935
  setMaking(true);
3927
3936
  setRefused(null);
3928
- const slug = (0, import_core2.tokenFor)(name);
3937
+ const slug = (0, import_core3.tokenFor)(name);
3929
3938
  const found = await client.tableFind({ slug });
3930
3939
  if (!found.ok) {
3931
3940
  setMaking(false);
@@ -3939,7 +3948,7 @@ function ReferenceBuilder({
3939
3948
  id = existing.id;
3940
3949
  bornName = tableName(existing);
3941
3950
  } else {
3942
- const made = await (0, import_core2.ensureTable)(client, {
3951
+ const made = await (0, import_core3.ensureTable)(client, {
3943
3952
  name,
3944
3953
  slug,
3945
3954
  titleField: "name",
@@ -3958,7 +3967,7 @@ function ReferenceBuilder({
3958
3967
  tables.reload();
3959
3968
  onChange({ targetTableId: id, display: null });
3960
3969
  };
3961
- const mayMakeTable = (0, import_core3.doorReady)(client.config, import_core3.DOORS.tableFind) && (0, import_core3.doorReady)(client.config, import_core3.DOORS.tableEnsure);
3970
+ const mayMakeTable = (0, import_core4.doorReady)(client.config, import_core4.DOORS.tableFind) && (0, import_core4.doorReady)(client.config, import_core4.DOORS.tableEnsure);
3962
3971
  const newTableButton = !mayMakeTable ? null : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3963
3972
  import_design_system9.Button,
3964
3973
  {
@@ -4357,7 +4366,7 @@ function PersonPicker({ field: field2, value, onChange, disabled, id, className,
4357
4366
 
4358
4367
  // src/gridEditing.tsx
4359
4368
  var import_react46 = require("react");
4360
- var import_core9 = require("@ai-matrx/records/core");
4369
+ var import_core10 = require("@ai-matrx/records/core");
4361
4370
  var import_react47 = require("@ai-matrx/records/react");
4362
4371
  var import_design_system25 = require("@ai-matrx/design-system");
4363
4372
 
@@ -7462,7 +7471,7 @@ var import_design_system24 = require("@ai-matrx/design-system");
7462
7471
  var import_react40 = require("react");
7463
7472
 
7464
7473
  // src/firstPage.ts
7465
- var import_core6 = require("@ai-matrx/records/core");
7474
+ var import_core7 = require("@ai-matrx/records/core");
7466
7475
  var import_uuid4 = require("@ai-matrx/kit/uuid");
7467
7476
 
7468
7477
  // src/groupReads.ts
@@ -7943,10 +7952,10 @@ var import_uuid3 = require("@ai-matrx/kit/uuid");
7943
7952
  var import_records16 = require("@ai-matrx/records");
7944
7953
 
7945
7954
  // ../entity-data/src/core/client.ts
7946
- var import_core5 = require("@ai-matrx/records/core");
7955
+ var import_core6 = require("@ai-matrx/records/core");
7947
7956
 
7948
7957
  // ../entity-data/src/core/errors.ts
7949
- var import_core4 = require("@ai-matrx/records/core");
7958
+ var import_core5 = require("@ai-matrx/records/core");
7950
7959
  var ENTITY_REFUSALS = {
7951
7960
  /** conflict_version: somebody else's write won. */
7952
7961
  MX001: "stale_write",
@@ -7970,7 +7979,7 @@ var ENTITY_REFUSALS = {
7970
7979
  MX016: "invalid_argument"
7971
7980
  };
7972
7981
  function mapEntityError(error, where) {
7973
- const mapped = (0, import_core4.mapPgError)(error, where);
7982
+ const mapped = (0, import_core5.mapPgError)(error, where);
7974
7983
  const state = mapped.sqlstate;
7975
7984
  if (state && /^MX\d{3}$/.test(state)) {
7976
7985
  const code = ENTITY_REFUSALS[state];
@@ -7992,7 +8001,7 @@ function refusal2(code, message, hint) {
7992
8001
  var OP_ID_HEADER = "x-matrx-op-id";
7993
8002
  var ENTITY_DOOR_SCHEMA = "platform";
7994
8003
  function createEntityClient(options) {
7995
- const source = (0, import_core5.asRecordsDataSource)(options.dataSource ?? options.supabase);
8004
+ const source = (0, import_core6.asRecordsDataSource)(options.dataSource ?? options.supabase);
7996
8005
  let warnedHeaderless = false;
7997
8006
  function withHeaders(pending, headers) {
7998
8007
  if (!headers) return;
@@ -8777,16 +8786,16 @@ var ABSENCE_WORD_LABEL = {
8777
8786
  };
8778
8787
 
8779
8788
  // src/values.tsx
8780
- var import_core8 = require("@ai-matrx/records/core");
8789
+ var import_core9 = require("@ai-matrx/records/core");
8781
8790
 
8782
8791
  // src/WholeValue.tsx
8783
8792
  var import_react41 = require("react");
8784
- var import_core7 = require("@ai-matrx/records/core");
8793
+ var import_core8 = require("@ai-matrx/records/core");
8785
8794
  var import_design_system20 = require("@ai-matrx/design-system");
8786
8795
  var import_jsx_runtime25 = require("react/jsx-runtime");
8787
8796
  var WHOLE_VALUE_UNBOUND = "The whole text is kept as a file, and this screen has no way to open files yet.";
8788
8797
  function wholeValueLine(pointer) {
8789
- return `Open the whole text (${(0, import_core7.wholeValueSize)(pointer)})`;
8798
+ return `Open the whole text (${(0, import_core8.wholeValueSize)(pointer)})`;
8790
8799
  }
8791
8800
  function WholeValueCell({ words: words2, pointer }) {
8792
8801
  const host = useRecordsUi();
@@ -8797,12 +8806,12 @@ function WholeValueCell({ words: words2, pointer }) {
8797
8806
  words2,
8798
8807
  "\u2026"
8799
8808
  ] }),
8800
- href ? host.Link ? host.Link({ href, children: line, className: "shrink-0 text-xs text-primary underline-offset-2 hover:underline" }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("a", { className: "shrink-0 text-xs text-primary underline-offset-2 hover:underline", href, target: "_blank", rel: "noreferrer", children: line }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "shrink-0 text-xs italic text-muted-foreground", title: WHOLE_VALUE_UNBOUND, children: `${(0, import_core7.wholeValueSize)(pointer)} in a file` })
8809
+ href ? host.Link ? host.Link({ href, children: line, className: "shrink-0 text-xs text-primary underline-offset-2 hover:underline" }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("a", { className: "shrink-0 text-xs text-primary underline-offset-2 hover:underline", href, target: "_blank", rel: "noreferrer", children: line }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "shrink-0 text-xs italic text-muted-foreground", title: WHOLE_VALUE_UNBOUND, children: `${(0, import_core8.wholeValueSize)(pointer)} in a file` })
8801
8810
  ] });
8802
8811
  }
8803
8812
  var WHOLE_VALUE_NOT_EDITABLE_HERE = "The whole text is kept as a file. Open it to read it; this screen cannot load it to edit.";
8804
8813
  function wholeValueOpening(pointer) {
8805
- return `Opening the whole text (${(0, import_core7.wholeValueSize)(pointer)})\u2026`;
8814
+ return `Opening the whole text (${(0, import_core8.wholeValueSize)(pointer)})\u2026`;
8806
8815
  }
8807
8816
  function useWholeText(pointer) {
8808
8817
  const host = useRecordsUi();
@@ -9498,7 +9507,7 @@ function renderValue(field2, value, document2, labels, stillWaitingFor, look) {
9498
9507
  if (isSignatureField(field2)) return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(SignatureValue, { value, fieldKey: field2.key, document: document2 });
9499
9508
  const newer = newerKindValue(field2, value);
9500
9509
  if (newer !== void 0) return newer;
9501
- const whole = typeof value === "string" ? (0, import_core8.wholeValueOf)(document2, field2.key) : null;
9510
+ const whole = typeof value === "string" ? (0, import_core9.wholeValueOf)(document2, field2.key) : null;
9502
9511
  if (whole) return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(WholeValueCell, { words: value, pointer: whole });
9503
9512
  const kind = editorKindFor(field2);
9504
9513
  if (kind === "relation" || kind === "entity_reference") {
@@ -9621,7 +9630,7 @@ function scalarText(field2, value, labels, stillWaitingFor) {
9621
9630
  function ProvenanceBadge({ document: document2, fieldKey }) {
9622
9631
  const envelope = envelopeFor(document2, fieldKey);
9623
9632
  if (!envelope?.src) return null;
9624
- if ((0, import_core8.wholeValueOf)(document2, fieldKey)) return null;
9633
+ if ((0, import_core9.wholeValueOf)(document2, fieldKey)) return null;
9625
9634
  const sources = document2?._sources;
9626
9635
  const source = sources?.[envelope.src];
9627
9636
  const label = source ? Object.values(source).map(String).join(" \xB7 ") : envelope.src;
@@ -9656,7 +9665,7 @@ function RecordValue({
9656
9665
  const newer = newerKindValue(field2, value, { inCell });
9657
9666
  if (newer !== void 0) return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children: newer });
9658
9667
  }
9659
- if (inCell && ui.grid === "merged" && ui.renderText && typeof value === "string" && value.trim() !== "" && editorKindFor(field2) === "long_text" && !shownAsOf(field2) && !(0, import_core8.wholeValueOf)(document2, field2.key) && !envelopeFor(document2, field2.key)?.absent && // A long-text cell holding a kind is drawn by the kind system below, not as markdown.
9668
+ if (inCell && ui.grid === "merged" && ui.renderText && typeof value === "string" && value.trim() !== "" && editorKindFor(field2) === "long_text" && !shownAsOf(field2) && !(0, import_core9.wholeValueOf)(document2, field2.key) && !envelopeFor(document2, field2.key)?.absent && // A long-text cell holding a kind is drawn by the kind system below, not as markdown.
9660
9669
  !kindValueOf(value)) {
9661
9670
  return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "block h-[1.5em] min-w-0 overflow-hidden whitespace-normal", "data-records-cell-text": "", children: ui.renderText(value, "cell") });
9662
9671
  }
@@ -9869,7 +9878,7 @@ function useGridEditing({ tableId, fields, rows, reload, reloadAfterWrite, canWr
9869
9878
  }
9870
9879
  const held = optimistic[cellKey(address.rowId, address.key)];
9871
9880
  const document2 = rows.find((r) => r.id === address.rowId)?.document;
9872
- const pointer = held === void 0 && typeof current === "string" ? (0, import_core9.wholeValueOf)(document2, address.key) : null;
9881
+ const pointer = held === void 0 && typeof current === "string" ? (0, import_core10.wholeValueOf)(document2, address.key) : null;
9873
9882
  if (pointer) {
9874
9883
  const read = host.readFileText;
9875
9884
  if (!read) return;
@@ -9980,7 +9989,7 @@ function useGridEditing({ tableId, fields, rows, reload, reloadAfterWrite, canWr
9980
9989
  delete next[id];
9981
9990
  return next;
9982
9991
  });
9983
- const conflict = (0, import_core9.asWriteConflict)(written.error, rowId);
9992
+ const conflict = (0, import_core10.asWriteConflict)(written.error, rowId);
9984
9993
  if (written.error.code === "stale_write") {
9985
9994
  if (conflict) rememberVersion(versions.current, rowId, conflict.current_version);
9986
9995
  else versions.current.delete(rowId);
@@ -10068,7 +10077,7 @@ function useGridEditing({ tableId, fields, rows, reload, reloadAfterWrite, canWr
10068
10077
  }
10069
10078
  const starting = shownValue2(next.rowId, next.key);
10070
10079
  const nextDocument = rows.find((r) => r.id === next.rowId)?.document;
10071
- if (typeof starting === "string" && optimistic[cellKey(next.rowId, next.key)] === void 0 && (0, import_core9.wholeValueOf)(nextDocument, next.key)) {
10080
+ if (typeof starting === "string" && optimistic[cellKey(next.rowId, next.key)] === void 0 && (0, import_core10.wholeValueOf)(nextDocument, next.key)) {
10072
10081
  setEditing(null);
10073
10082
  setDraft(null);
10074
10083
  typed2.current = null;
@@ -11089,7 +11098,7 @@ var import_react123 = require("react");
11089
11098
  var import_react124 = require("@ai-matrx/records/react");
11090
11099
  var import_records37 = require("@ai-matrx/records");
11091
11100
  var import_data_table13 = require("@ai-matrx/design-system/data-table");
11092
- var import_core19 = require("@ai-matrx/records/core");
11101
+ var import_core20 = require("@ai-matrx/records/core");
11093
11102
 
11094
11103
  // src/archiveWords.ts
11095
11104
  var import_format2 = require("@ai-matrx/kit/format");
@@ -11235,7 +11244,7 @@ function columnNameTakenLine(taken, noun = "column") {
11235
11244
  // src/FieldEditor.tsx
11236
11245
  var import_react65 = require("react");
11237
11246
  var import_react66 = require("@ai-matrx/records/react");
11238
- var import_core10 = require("@ai-matrx/records/core");
11247
+ var import_core11 = require("@ai-matrx/records/core");
11239
11248
  var import_design_system35 = require("@ai-matrx/design-system");
11240
11249
 
11241
11250
  // src/FormulaTextEditor.tsx
@@ -13056,7 +13065,7 @@ function FieldEditor(props) {
13056
13065
  return;
13057
13066
  }
13058
13067
  (0, import_react66.tableShapeChanged)(tableId);
13059
- for (const c of done.data.undo.cells_back) (0, import_core10.announceRecordChanged)(c.record_id);
13068
+ for (const c of done.data.undo.cells_back) (0, import_core11.announceRecordChanged)(c.record_id);
13060
13069
  const n = done.data.rehomed.reduce((sum, r) => sum + r.records, 0);
13061
13070
  setRehome({});
13062
13071
  setRehomed({ said: `Saved. ${n} ${n === 1 ? "record was" : "records were"} changed with the choices.`, undo: done.data.undo });
@@ -13478,7 +13487,7 @@ function FieldEditor(props) {
13478
13487
  return;
13479
13488
  }
13480
13489
  (0, import_react66.tableShapeChanged)(tableId);
13481
- for (const c of undo.cells_back) (0, import_core10.announceRecordChanged)(c.record_id);
13490
+ for (const c of undo.cells_back) (0, import_core11.announceRecordChanged)(c.record_id);
13482
13491
  setChoiceList(null);
13483
13492
  setChoiceListStart(null);
13484
13493
  setRehomed({ said: "Undone. The choices and the records that held them are back as they were.", undo: null });
@@ -16169,7 +16178,7 @@ function WholeTextDialog({
16169
16178
  }
16170
16179
 
16171
16180
  // src/pasteValues.ts
16172
- var import_core11 = require("@ai-matrx/records/core");
16181
+ var import_core12 = require("@ai-matrx/records/core");
16173
16182
  var import_records30 = require("@ai-matrx/records");
16174
16183
  function wordForStoredChoice(options, value) {
16175
16184
  if (options === void 0 || typeof value !== "string" || value === "") return null;
@@ -16248,7 +16257,7 @@ function planPastedBlock(args) {
16248
16257
  });
16249
16258
  accepted[key] = judged.value;
16250
16259
  }
16251
- const predicted = (0, import_core11.predictValueRefusals)(args.fields, accepted);
16260
+ const predicted = (0, import_core12.predictValueRefusals)(args.fields, accepted);
16252
16261
  for (const refusal4 of predicted) {
16253
16262
  const key = refusal4.field_key;
16254
16263
  if (key === void 0) continue;
@@ -16419,6 +16428,9 @@ function useMergedGridControls(args) {
16419
16428
  canWrite,
16420
16429
  mayWriteRow,
16421
16430
  whyNotRow,
16431
+ mayRemoveRow,
16432
+ whyNotRemoveRow,
16433
+ hideRefusedRowActions,
16422
16434
  rights,
16423
16435
  editable,
16424
16436
  presentation,
@@ -16676,6 +16688,9 @@ function useMergedGridControls(args) {
16676
16688
  titleField: table?.title_field ?? null,
16677
16689
  mayWriteRow: (rowId) => canWrite && mayWriteRow(rowId),
16678
16690
  whyNotWrite: (rowId) => !editable ? "Editing is off here." : rowId ? whyNotRow(rowId) : rights.why("write"),
16691
+ mayRemoveRow: (rowId) => canWrite && mayRemoveRow(rowId),
16692
+ whyNotRemove: (rowId) => rowId ? whyNotRemoveRow(rowId) : rights.why("remove"),
16693
+ hideRefusedRowActions,
16679
16694
  mayAddRecord: editable && rights.write,
16680
16695
  whyNotAdd: editable ? rights.why("write") : "Editing is off here.",
16681
16696
  mayStructure,
@@ -17165,7 +17180,7 @@ var import_design_system51 = require("@ai-matrx/design-system");
17165
17180
  // src/RecordForm.tsx
17166
17181
  var import_react92 = require("react");
17167
17182
  var import_react93 = require("@ai-matrx/records/react");
17168
- var import_core13 = require("@ai-matrx/records/core");
17183
+ var import_core14 = require("@ai-matrx/records/core");
17169
17184
  var import_design_system50 = require("@ai-matrx/design-system");
17170
17185
  var import_text_case6 = require("@ai-matrx/kit/text-case");
17171
17186
 
@@ -17178,7 +17193,7 @@ var import_design_system49 = require("@ai-matrx/design-system");
17178
17193
  var import_react88 = require("react");
17179
17194
  var import_react89 = require("@ai-matrx/records/react");
17180
17195
  var import_design_system48 = require("@ai-matrx/design-system");
17181
- var import_core12 = require("@ai-matrx/records/core");
17196
+ var import_core13 = require("@ai-matrx/records/core");
17182
17197
  var import_jsx_runtime55 = require("react/jsx-runtime");
17183
17198
  function isEmptyValue(value) {
17184
17199
  return value === null || value === void 0 || value === "" || Array.isArray(value) && value.length === 0;
@@ -17250,7 +17265,7 @@ async function writeStandardRowValues(client, args) {
17250
17265
  { schema: config.schema ?? "custom" }
17251
17266
  );
17252
17267
  if (!old.error) return { ok: true };
17253
- const error = (0, import_core12.mapPgError)(old.error, "entityValueWrite");
17268
+ const error = (0, import_core13.mapPgError)(old.error, "entityValueWrite");
17254
17269
  return { ok: false, error: doorIsAbsent(error) && first && first.error.code !== "door_absent" ? first.error : error };
17255
17270
  }
17256
17271
  function doorIsAbsent(error) {
@@ -17831,7 +17846,7 @@ function CustomRecordForm({
17831
17846
  return out;
17832
17847
  }, [draft]);
17833
17848
  const predicted = (0, import_react92.useMemo)(
17834
- () => fields.data ? (0, import_core13.predictWriteRefusals)({ fields: fields.data, document: document2, ...recordType ? { recordType } : {} }) : [],
17849
+ () => fields.data ? (0, import_core14.predictWriteRefusals)({ fields: fields.data, document: document2, ...recordType ? { recordType } : {} }) : [],
17835
17850
  [fields.data, document2, recordType]
17836
17851
  );
17837
17852
  if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(RefusalNotice, { error: fields.error, className });
@@ -17881,7 +17896,7 @@ function CustomRecordForm({
17881
17896
  setEdit({
17882
17897
  saving: false,
17883
17898
  error: answered2.ok ? null : answered2.error,
17884
- conflict: answered2.ok ? null : (0, import_core13.asWriteConflict)(answered2.error, recordId)
17899
+ conflict: answered2.ok ? null : (0, import_core14.asWriteConflict)(answered2.error, recordId)
17885
17900
  });
17886
17901
  const moved = answered2.ok ? answered2.data : null;
17887
17902
  if (moved !== null) {
@@ -17990,7 +18005,7 @@ function FieldRow({
17990
18005
  }) {
17991
18006
  const id = `field-${field2.id}`;
17992
18007
  const storedWords = document2?.[field2.key];
17993
- const whole = typeof storedWords === "string" ? (0, import_core13.wholeValueOf)(document2, field2.key) : null;
18008
+ const whole = typeof storedWords === "string" ? (0, import_core14.wholeValueOf)(document2, field2.key) : null;
17994
18009
  return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { className: (0, import_design_system50.cn)("flex min-w-0 flex-col gap-1", whole && "sm:col-span-2"), children: [
17995
18010
  /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(FieldLabel, { field: field2, htmlFor: id, children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(ProvenanceBadge, { document: document2, fieldKey: field2.key }) }),
17996
18011
  whole ? (
@@ -18923,12 +18938,14 @@ function useEnrichCells(tableId, recordIds) {
18923
18938
  const [cells, setCells] = (0, import_react100.useState)(/* @__PURE__ */ new Map());
18924
18939
  const [error, setError] = (0, import_react100.useState)(null);
18925
18940
  const key = (recordIds ?? []).join(",");
18926
- const refresh = (0, import_react100.useCallback)(async () => {
18941
+ const load = (0, import_react100.useCallback)(async (fresh) => {
18927
18942
  if (!tableId || !recordIds || recordIds.length === 0) {
18928
18943
  setCells(/* @__PURE__ */ new Map());
18929
18944
  return;
18930
18945
  }
18931
- const answered = await client.enrichCells({ table_id: tableId, record_ids: recordIds });
18946
+ const asking = `enrich_cells:${tableId}:${key}`;
18947
+ if (fresh) forgetAsked(client, asking);
18948
+ const answered = await askOnce(client, asking, () => client.enrichCells({ table_id: tableId, record_ids: recordIds }), ENRICH_CELLS_FRESH_MS);
18932
18949
  if (!answered.ok) {
18933
18950
  setError(answered.error);
18934
18951
  return;
@@ -18938,9 +18955,10 @@ function useEnrichCells(tableId, recordIds) {
18938
18955
  for (const cell2 of answered.data) next.set(`${cell2.record_id}:${cell2.field_key}`, cell2);
18939
18956
  setCells(next);
18940
18957
  }, [client, tableId, key]);
18958
+ const refresh = (0, import_react100.useCallback)(() => load(true), [load]);
18941
18959
  (0, import_react100.useEffect)(() => {
18942
- void refresh();
18943
- }, [refresh]);
18960
+ void load(false);
18961
+ }, [load]);
18944
18962
  return { cells, refresh, error };
18945
18963
  }
18946
18964
  var NEVER2 = "Fill it in once and leave it alone";
@@ -20052,12 +20070,12 @@ function withOpenRecord(columns, onOpen, nameOf2, place = "end", hrefOf) {
20052
20070
  // src/ImportWizard.tsx
20053
20071
  var import_react105 = require("react");
20054
20072
  var import_react106 = require("@ai-matrx/records/react");
20055
- var import_core15 = require("@ai-matrx/records/core");
20073
+ var import_core16 = require("@ai-matrx/records/core");
20056
20074
  var import_design_system56 = require("@ai-matrx/design-system");
20057
20075
  var import_records34 = require("@ai-matrx/records");
20058
20076
 
20059
20077
  // src/importRuleCheck.ts
20060
- var import_core14 = require("@ai-matrx/records/core");
20078
+ var import_core15 = require("@ai-matrx/records/core");
20061
20079
  function checkImportRules(fields, rows, mapping, choiceOptions, relationNames) {
20062
20080
  const byKey = new Map(fields.map((f) => [f.key, f]));
20063
20081
  const verdicts = [];
@@ -20083,7 +20101,7 @@ function checkImportRules(fields, rows, mapping, choiceOptions, relationNames) {
20083
20101
  if ("unmatchedNames" in meant) return;
20084
20102
  if ("refusal" in meant) why = meant.refusal;
20085
20103
  else {
20086
- const predicted = (0, import_core14.predictValueRefusals)([field2], { [key]: meant.value }).filter(
20104
+ const predicted = (0, import_core15.predictValueRefusals)([field2], { [key]: meant.value }).filter(
20087
20105
  (p) => p.field_key === void 0 || p.field_key === key
20088
20106
  );
20089
20107
  if (predicted.length > 0) why = predicted[0].message;
@@ -20587,7 +20605,7 @@ function ImportWizard({ tableId, source, onDone, onWrote, className }) {
20587
20605
  try {
20588
20606
  const xlsx = file.name.toLowerCase().endsWith(".xlsx");
20589
20607
  const bytes = await file.arrayBuffer();
20590
- const result = xlsx ? await (0, import_core15.importXlsx)(bytes) : (0, import_core15.importCsv)(new TextDecoder().decode(bytes));
20608
+ const result = xlsx ? await (0, import_core16.importXlsx)(bytes) : (0, import_core16.importCsv)(new TextDecoder().decode(bytes));
20591
20609
  await planFrom(result, { name: file.name, bytes: file.size, hash: await sha256(bytes), format: xlsx ? "xlsx" : "csv" });
20592
20610
  } catch (thrown) {
20593
20611
  setProblem(
@@ -22596,7 +22614,7 @@ function useGroupLabel(fields, groupKey) {
22596
22614
  // src/gridUndo.tsx
22597
22615
  var import_react113 = require("react");
22598
22616
  var import_react114 = require("@ai-matrx/records/react");
22599
- var import_core16 = require("@ai-matrx/records/core");
22617
+ var import_core17 = require("@ai-matrx/records/core");
22600
22618
  var import_design_system58 = require("@ai-matrx/design-system");
22601
22619
  var import_data_table12 = require("@ai-matrx/design-system/data-table");
22602
22620
  var import_jsx_runtime68 = require("react/jsx-runtime");
@@ -22690,7 +22708,7 @@ function useGridUndo(args) {
22690
22708
  }
22691
22709
  forget(step2.cells.map((c) => ({ rowId: c.rowId, key: c.key })));
22692
22710
  for (const id of /* @__PURE__ */ new Set([...step2.cells.map((c) => c.rowId), ...step2.created ?? [], ...step2.archived ?? []])) {
22693
- (0, import_core16.announceRecordChanged)(id);
22711
+ (0, import_core17.announceRecordChanged)(id);
22694
22712
  }
22695
22713
  setHeld(() => {
22696
22714
  let stack = taken.stack;
@@ -23078,7 +23096,7 @@ function holdKeys() {
23078
23096
  // src/gridAssist.tsx
23079
23097
  var import_clipboard2 = require("@ai-matrx/kit/clipboard");
23080
23098
  var import_react117 = require("react");
23081
- var import_core17 = require("@ai-matrx/records/core");
23099
+ var import_core18 = require("@ai-matrx/records/core");
23082
23100
  var import_workspace = require("@ai-matrx/alchemy/react/workspace");
23083
23101
 
23084
23102
  // src/gridAgentContext.ts
@@ -23208,7 +23226,7 @@ function useGridAssist(args) {
23208
23226
  const copyRecordReference = (0, import_react117.useCallback)(
23209
23227
  (rowId) => {
23210
23228
  void (async () => {
23211
- const text2 = JSON.stringify({ __kind: (0, import_core17.tableKindSlug)(tableId), _record_id: rowId });
23229
+ const text2 = JSON.stringify({ __kind: (0, import_core18.tableKindSlug)(tableId), _record_id: rowId });
23212
23230
  if (!await (0, import_clipboard2.copyText)(text2)) {
23213
23231
  say2(false, "This browser did not let the page write to the clipboard.");
23214
23232
  return;
@@ -23264,7 +23282,7 @@ function useGridAssist(args) {
23264
23282
  if (!row) return;
23265
23283
  const document2 = row.document ?? {};
23266
23284
  const value = editing.valueFor(row, fieldOf2(key));
23267
- const pointer = typeof document2[key] === "string" ? (0, import_core17.wholeValueOf)(document2, key) : null;
23285
+ const pointer = typeof document2[key] === "string" ? (0, import_core18.wholeValueOf)(document2, key) : null;
23268
23286
  setWhole({ rowId, key, rowTitle: titleOf(row), value, pointer });
23269
23287
  },
23270
23288
  [rowOf, fieldOf2, titleOf, editing]
@@ -23360,7 +23378,7 @@ function useGridAssist(args) {
23360
23378
  // src/gridBulk.tsx
23361
23379
  var import_react118 = require("react");
23362
23380
  var import_react119 = require("@ai-matrx/records/react");
23363
- var import_core18 = require("@ai-matrx/records/core");
23381
+ var import_core19 = require("@ai-matrx/records/core");
23364
23382
  var import_design_system59 = require("@ai-matrx/design-system");
23365
23383
  var import_jsx_runtime70 = require("react/jsx-runtime");
23366
23384
  function countOf(n, one, many) {
@@ -23426,7 +23444,7 @@ function useGridBulk(args) {
23426
23444
  return null;
23427
23445
  }
23428
23446
  for (const result of done.data ?? []) if (result.op === "update") versions.wrote(result.id, result.version);
23429
- for (const change of changes) if ("record_id" in change && change.record_id) (0, import_core18.announceRecordChanged)(change.record_id);
23447
+ for (const change of changes) if ("record_id" in change && change.record_id) (0, import_core19.announceRecordChanged)(change.record_id);
23430
23448
  return done.data;
23431
23449
  },
23432
23450
  [client, tableId, versions, reload]
@@ -23920,7 +23938,8 @@ function GridBody({
23920
23938
  sortOverride,
23921
23939
  searchOverride,
23922
23940
  onSearchChange,
23923
- searchBox = true
23941
+ searchBox = true,
23942
+ hideRefusedRowActions = false
23924
23943
  }) {
23925
23944
  const toolbarSlot = useTableToolbarSlot();
23926
23945
  const tableCard = (0, import_data_table13.useMatrxTableCard)();
@@ -24159,6 +24178,14 @@ function GridBody({
24159
24178
  (rowId) => askPerRow ? rowRights(rowId)?.write ?? false : rights.write,
24160
24179
  [askPerRow, rowRights, rights.write]
24161
24180
  );
24181
+ const mayRemoveRow = (0, import_react123.useCallback)(
24182
+ (rowId) => askPerRow ? rowRights(rowId)?.remove ?? false : rights.remove,
24183
+ [askPerRow, rowRights, rights.remove]
24184
+ );
24185
+ const whyNotRemoveRow = (0, import_react123.useCallback)(
24186
+ (rowId) => askPerRow ? rowRights(rowId)?.why("remove") ?? rights.why("remove") : rights.why("remove"),
24187
+ [askPerRow, rowRights, rights]
24188
+ );
24162
24189
  const whyNotRow = (0, import_react123.useCallback)(
24163
24190
  (rowId) => askPerRow ? rowRights(rowId)?.why("write") ?? rights.why("write") : rights.why("write"),
24164
24191
  [askPerRow, rowRights, rights]
@@ -24586,7 +24613,7 @@ function GridBody({
24586
24613
  }))
24587
24614
  );
24588
24615
  editing.forget(cells);
24589
- for (const u of updates) (0, import_core19.announceRecordChanged)(u.row.recordId);
24616
+ for (const u of updates) (0, import_core20.announceRecordChanged)(u.row.recordId);
24590
24617
  const lines = updates.length + creates.length;
24591
24618
  undo.push({ label: `Pasted ${lines} ${lines === 1 ? "row" : "rows"}`, cells, created });
24592
24619
  const expected = [
@@ -24829,6 +24856,9 @@ function GridBody({
24829
24856
  canWrite,
24830
24857
  mayWriteRow,
24831
24858
  whyNotRow,
24859
+ mayRemoveRow,
24860
+ whyNotRemoveRow,
24861
+ hideRefusedRowActions,
24832
24862
  rights,
24833
24863
  editable: Boolean(editable),
24834
24864
  readOnly,
@@ -24863,7 +24893,7 @@ function GridBody({
24863
24893
  const addRowHere = (0, import_react123.useCallback)(async (values) => {
24864
24894
  setAddRefused(null);
24865
24895
  if (formHosted && fields.data) {
24866
- const wouldRefuse = (0, import_core19.predictWriteRefusals)({ fields: fields.data, document: values ?? {} });
24896
+ const wouldRefuse = (0, import_core20.predictWriteRefusals)({ fields: fields.data, document: values ?? {} });
24867
24897
  if (wouldRefuse.length > 0) {
24868
24898
  setFormAsk((held) => ({ n: (held?.n ?? 0) + 1, initial: { ...values ?? {} } }));
24869
24899
  return;
@@ -26394,7 +26424,7 @@ function ConnectedRecordsTableCard({
26394
26424
  var import_download2 = require("@ai-matrx/kit/download");
26395
26425
  var import_react132 = require("react");
26396
26426
  var import_react133 = require("@ai-matrx/records/react");
26397
- var import_core20 = require("@ai-matrx/records/core");
26427
+ var import_core21 = require("@ai-matrx/records/core");
26398
26428
 
26399
26429
  // src/viewExport.ts
26400
26430
  var import_format5 = require("@ai-matrx/kit/format");
@@ -26461,7 +26491,7 @@ function toRows(fields, records, labels) {
26461
26491
  absent_reason: envelope?.absent ?? null,
26462
26492
  // A VALUE KEPT AS A FILE carries its pointer, so the export writes the whole text
26463
26493
  // (`withWholeValues`), never the first words passed off as the value.
26464
- source: (0, import_core20.wholeValueOf)(document2, field2.key)
26494
+ source: (0, import_core21.wholeValueOf)(document2, field2.key)
26465
26495
  };
26466
26496
  }
26467
26497
  return row;
@@ -26492,7 +26522,7 @@ async function rowsForFile(args) {
26492
26522
  );
26493
26523
  const lookup = ((field2, id) => labels(field2, id) ?? learned.get(`${field2.id}:${id}`) ?? null);
26494
26524
  const read = host.readFileText;
26495
- return (0, import_core20.withWholeValues)(toRows(all, records, lookup), read ? (fileId) => read({ fileId }) : null);
26525
+ return (0, import_core21.withWholeValues)(toRows(all, records, lookup), read ? (fileId) => read({ fileId }) : null);
26496
26526
  }
26497
26527
  function ExportMenu({ tableId, rows, label, className, view }) {
26498
26528
  const client = (0, import_react133.useRecordsClient)();
@@ -26531,7 +26561,7 @@ function ExportMenu({ tableId, rows, label, className, view }) {
26531
26561
  {
26532
26562
  size: "sm",
26533
26563
  variant: "outline",
26534
- onClick: () => void exported().then((rows2) => download(`${name}.csv`, "text/csv;charset=utf-8", (0, import_core20.exportCsv)(columns, rows2))).catch(
26564
+ onClick: () => void exported().then((rows2) => download(`${name}.csv`, "text/csv;charset=utf-8", (0, import_core21.exportCsv)(columns, rows2))).catch(
26535
26565
  (thrown) => setFailure(refusalFromThrown(thrown, "The CSV could not be written.", "Try again in a moment."))
26536
26566
  ),
26537
26567
  children: "CSV"
@@ -26552,7 +26582,7 @@ function ExportMenu({ tableId, rows, label, className, view }) {
26552
26582
  );
26553
26583
  setFailure(null);
26554
26584
  try {
26555
- exported().then((rows2) => (0, import_core20.exportXlsx)(columns, rows2, name)).then(
26585
+ exported().then((rows2) => (0, import_core21.exportXlsx)(columns, rows2, name)).then(
26556
26586
  (bytes) => download(
26557
26587
  `${name}.xlsx`,
26558
26588
  "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
@@ -26573,7 +26603,7 @@ function ExportMenu({ tableId, rows, label, className, view }) {
26573
26603
  sourceId: `records:${tableId}`,
26574
26604
  size: "xs",
26575
26605
  json: () => records.map((r) => r.document),
26576
- human: () => (0, import_core20.exportCsv)(columns, toRows(columns, records, labels))
26606
+ human: () => (0, import_core21.exportCsv)(columns, toRows(columns, records, labels))
26577
26607
  }
26578
26608
  ),
26579
26609
  viewHeld && "rows" in viewHeld && viewHeld.cut ? /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("span", { className: "text-xs text-muted-foreground", children: cutWords(viewHeld.rows.length) }) : null,
@@ -26693,7 +26723,7 @@ var import_design_system74 = require("@ai-matrx/design-system");
26693
26723
  // src/TablesHome.tsx
26694
26724
  var import_react146 = require("react");
26695
26725
  var import_react147 = require("@ai-matrx/records/react");
26696
- var import_core21 = require("@ai-matrx/records/core");
26726
+ var import_core22 = require("@ai-matrx/records/core");
26697
26727
  var import_records42 = require("@ai-matrx/records");
26698
26728
  var import_design_system73 = require("@ai-matrx/design-system");
26699
26729
 
@@ -26854,7 +26884,7 @@ function columnsFrom(text2) {
26854
26884
  function fieldsForNewColumns(columns) {
26855
26885
  const keys = /* @__PURE__ */ new Set();
26856
26886
  return columns.map((column, i) => {
26857
- let key = (0, import_core2.tokenFor)(column.label) || `column_${i + 1}`;
26887
+ let key = (0, import_core3.tokenFor)(column.label) || `column_${i + 1}`;
26858
26888
  while (keys.has(key)) key = `${key}_${i + 1}`;
26859
26889
  keys.add(key);
26860
26890
  const base = { key, label: column.label, sort: (i + 1) * 10, required: false };
@@ -28429,7 +28459,7 @@ function TablesHome({ onOpenTable, organizationName, makingOnly = false, askedBy
28429
28459
  };
28430
28460
  }, [client]);
28431
28461
  const listed = facts.phase === "read" ? (0, import_records42.withTablePlacement)(
28432
- (0, import_core21.withTableFacts)(tables.data ?? [], facts.rows, me),
28462
+ (0, import_core22.withTableFacts)(tables.data ?? [], facts.rows, me),
28433
28463
  facts.rows
28434
28464
  ) : tables.data ?? [];
28435
28465
  const [showEverything, setShowEverything] = (0, import_react146.useState)(false);
@@ -28479,9 +28509,9 @@ function TablesHome({ onOpenTable, organizationName, makingOnly = false, askedBy
28479
28509
  if (!trimmed) return;
28480
28510
  setBusy(true);
28481
28511
  setError(null);
28482
- const result = await (0, import_core2.declareTable)(client, {
28512
+ const result = await (0, import_core3.declareTable)(client, {
28483
28513
  name: trimmed,
28484
- slug: (0, import_core2.tokenFor)(trimmed),
28514
+ slug: (0, import_core3.tokenFor)(trimmed),
28485
28515
  ...columns.length > 0 ? { fields: fieldsForNewColumns(columns) } : {}
28486
28516
  });
28487
28517
  setBusy(false);
@@ -28716,7 +28746,7 @@ function draftsFor(headers, rows) {
28716
28746
  function keysFor(labels) {
28717
28747
  const used = /* @__PURE__ */ new Set();
28718
28748
  return labels.map((label, i) => {
28719
- const base = (0, import_core2.tokenFor)(label) === "table" && !/table/i.test(label) ? `column_${i + 1}` : (0, import_core2.tokenFor)(label);
28749
+ const base = (0, import_core3.tokenFor)(label) === "table" && !/table/i.test(label) ? `column_${i + 1}` : (0, import_core3.tokenFor)(label);
28720
28750
  let key = base;
28721
28751
  let n = 2;
28722
28752
  while (used.has(key)) key = `${base}_${n++}`;
@@ -28812,7 +28842,7 @@ function SaveToTable({ source, shapeIndex = 0, onOpenTable, onSaved, onClose, cl
28812
28842
  const tableName2 = freeName(name ?? proposedName, (tables.data ?? []).map((t) => t.name));
28813
28843
  setPhase("making");
28814
28844
  try {
28815
- const born = await (0, import_core2.declareTable)(client, { name: tableName2, fields });
28845
+ const born = await (0, import_core3.declareTable)(client, { name: tableName2, fields });
28816
28846
  if (!born.ok) {
28817
28847
  setProblem(born.error);
28818
28848
  setPhase("ready");
@@ -34351,6 +34381,7 @@ function ViewSwitcher({
34351
34381
  searchOverride,
34352
34382
  onSearchChange,
34353
34383
  searchBox,
34384
+ hideRefusedRowActions,
34354
34385
  newRowLabel,
34355
34386
  className
34356
34387
  }) {
@@ -34396,6 +34427,7 @@ function ViewSwitcher({
34396
34427
  ...searchOverride !== void 0 ? { searchOverride } : {},
34397
34428
  ...onSearchChange ? { onSearchChange } : {},
34398
34429
  ...searchBox === false ? { searchBox } : {},
34430
+ ...hideRefusedRowActions ? { hideRefusedRowActions } : {},
34399
34431
  ...newRowLabel ? { newRowLabel } : {},
34400
34432
  ...filter ? { filter } : {},
34401
34433
  ...onClearFilter ? { onClearFilter } : {},
@@ -38741,7 +38773,7 @@ var import_design_system105 = require("@ai-matrx/design-system");
38741
38773
  var import_react219 = require("react");
38742
38774
  var import_recharts = require("recharts");
38743
38775
  var import_records50 = require("@ai-matrx/records");
38744
- var import_core22 = require("@ai-matrx/records/core");
38776
+ var import_core23 = require("@ai-matrx/records/core");
38745
38777
  var import_design_system104 = require("@ai-matrx/design-system");
38746
38778
  var import_format10 = require("@ai-matrx/kit/format");
38747
38779
 
@@ -39203,7 +39235,7 @@ function pretty(n) {
39203
39235
  return Number.isInteger(n) ? n.toLocaleString() : n.toLocaleString(void 0, { maximumFractionDigits: 2 });
39204
39236
  }
39205
39237
  function asRefusal2(block) {
39206
- return (0, import_core22.mapPgError)(
39238
+ return (0, import_core23.mapPgError)(
39207
39239
  {
39208
39240
  message: block.refused ?? "",
39209
39241
  ...block.sqlstate ? { code: block.sqlstate } : {}
@@ -42111,7 +42143,7 @@ function SubscriptionsPanel({ tableId, activeRuleId, className }) {
42111
42143
  var import_clipboard9 = require("@ai-matrx/kit/clipboard");
42112
42144
  var import_design_system117 = require("@ai-matrx/design-system");
42113
42145
  var import_react237 = require("react");
42114
- var import_core23 = require("@dnd-kit/core");
42146
+ var import_core24 = require("@dnd-kit/core");
42115
42147
  var import_sortable = require("@dnd-kit/sortable");
42116
42148
  var import_utilities = require("@dnd-kit/utilities");
42117
42149
  var import_react238 = require("@ai-matrx/records/react");
@@ -43741,9 +43773,9 @@ function QuestionList({
43741
43773
  onQuestions,
43742
43774
  onQuestion
43743
43775
  }) {
43744
- const sensors = (0, import_core23.useSensors)(
43745
- (0, import_core23.useSensor)(import_core23.PointerSensor, { activationConstraint: { distance: 4 } }),
43746
- (0, import_core23.useSensor)(import_core23.KeyboardSensor, { coordinateGetter: import_sortable.sortableKeyboardCoordinates })
43776
+ const sensors = (0, import_core24.useSensors)(
43777
+ (0, import_core24.useSensor)(import_core24.PointerSensor, { activationConstraint: { distance: 4 } }),
43778
+ (0, import_core24.useSensor)(import_core24.KeyboardSensor, { coordinateGetter: import_sortable.sortableKeyboardCoordinates })
43747
43779
  );
43748
43780
  const askable = askableFields([...fields]);
43749
43781
  const unasked = askable.filter((f) => !draft.questions.some((q) => q.field === f.key));
@@ -43765,7 +43797,7 @@ function QuestionList({
43765
43797
  /* @__PURE__ */ (0, import_jsx_runtime133.jsx)("span", { className: "font-medium text-foreground", children: "Questions" }),
43766
43798
  /* @__PURE__ */ (0, import_jsx_runtime133.jsx)("span", { className: "tabular-nums", children: draft.questions.length })
43767
43799
  ] }),
43768
- /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(import_core23.DndContext, { sensors, collisionDetection: import_core23.closestCenter, onDragEnd: dragEnd, children: /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(import_sortable.SortableContext, { items: draft.questions.map((q) => q.field), strategy: import_sortable.verticalListSortingStrategy, children: draft.questions.map((question, index) => /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
43800
+ /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(import_core24.DndContext, { sensors, collisionDetection: import_core24.closestCenter, onDragEnd: dragEnd, children: /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(import_sortable.SortableContext, { items: draft.questions.map((q) => q.field), strategy: import_sortable.verticalListSortingStrategy, children: draft.questions.map((question, index) => /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
43769
43801
  QuestionRow,
43770
43802
  {
43771
43803
  index,
@@ -44761,7 +44793,7 @@ var import_react255 = require("@ai-matrx/records/react");
44761
44793
  var import_design_system126 = require("@ai-matrx/design-system");
44762
44794
 
44763
44795
  // src/DashboardGrid.tsx
44764
- var import_core24 = require("@dnd-kit/core");
44796
+ var import_core25 = require("@dnd-kit/core");
44765
44797
  var import_sortable2 = require("@dnd-kit/sortable");
44766
44798
  var import_utilities2 = require("@dnd-kit/utilities");
44767
44799
  var import_design_system123 = require("@ai-matrx/design-system");
@@ -44817,7 +44849,7 @@ function withBlockIds(blocks) {
44817
44849
  // src/DashboardGrid.tsx
44818
44850
  var import_jsx_runtime138 = require("react/jsx-runtime");
44819
44851
  var dashboardCollision = (args) => {
44820
- const under = (0, import_core24.pointerWithin)(args);
44852
+ const under = (0, import_core25.pointerWithin)(args);
44821
44853
  if (under.length > 0) return under;
44822
44854
  const at = args.collisionRect;
44823
44855
  return args.droppableContainers.flatMap((container) => {
@@ -44827,9 +44859,9 @@ var dashboardCollision = (args) => {
44827
44859
  }).sort((a, b) => a.data.value - b.data.value);
44828
44860
  };
44829
44861
  function DashboardGrid({ items, arranging, onMove, onSpan }) {
44830
- const sensors = (0, import_core24.useSensors)(
44831
- (0, import_core24.useSensor)(import_core24.PointerSensor, { activationConstraint: { distance: 4 } }),
44832
- (0, import_core24.useSensor)(import_core24.KeyboardSensor, { coordinateGetter: import_sortable2.sortableKeyboardCoordinates })
44862
+ const sensors = (0, import_core25.useSensors)(
44863
+ (0, import_core25.useSensor)(import_core25.PointerSensor, { activationConstraint: { distance: 4 } }),
44864
+ (0, import_core25.useSensor)(import_core25.KeyboardSensor, { coordinateGetter: import_sortable2.sortableKeyboardCoordinates })
44833
44865
  );
44834
44866
  const ids = items.map((item) => item.id);
44835
44867
  function dragEnd(event) {
@@ -44839,7 +44871,7 @@ function DashboardGrid({ items, arranging, onMove, onSpan }) {
44839
44871
  }
44840
44872
  const grid = /* @__PURE__ */ (0, import_jsx_runtime138.jsx)("div", { className: "grid grid-cols-1 gap-2 sm:grid-cols-12", children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(GridCell2, { item, index, arranging, onSpan }, item.id)) });
44841
44873
  if (!arranging) return grid;
44842
- return /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(import_core24.DndContext, { sensors, collisionDetection: dashboardCollision, onDragEnd: dragEnd, children: /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(import_sortable2.SortableContext, { items: ids, strategy: import_sortable2.rectSortingStrategy, children: grid }) });
44874
+ return /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(import_core25.DndContext, { sensors, collisionDetection: dashboardCollision, onDragEnd: dragEnd, children: /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(import_sortable2.SortableContext, { items: ids, strategy: import_sortable2.rectSortingStrategy, children: grid }) });
44843
44875
  }
44844
44876
  function GridCell2({
44845
44877
  item,
@@ -46052,7 +46084,7 @@ var import_react257 = require("@ai-matrx/records/react");
46052
46084
 
46053
46085
  // src/question.ts
46054
46086
  var import_records58 = require("@ai-matrx/records");
46055
- var import_core25 = require("@ai-matrx/records/core");
46087
+ var import_core26 = require("@ai-matrx/records/core");
46056
46088
  var QUESTION_OPS = ["count", "sum", "avg", "min", "max"];
46057
46089
  var QUESTION_LIMIT_DEFAULT = 25;
46058
46090
  var QUESTION_GROUP_CEILING = 200;
@@ -46304,7 +46336,7 @@ async function askAsOf(client, tableId, spec, fields, measures, keys) {
46304
46336
  },
46305
46337
  { schema: config.schema ?? "custom" }
46306
46338
  );
46307
- if (response.error) return { ok: false, error: (0, import_core25.mapPgError)(response.error, "askQuestion.asOf") };
46339
+ if (response.error) return { ok: false, error: (0, import_core26.mapPgError)(response.error, "askQuestion.asOf") };
46308
46340
  const rows2 = Array.isArray(response.data) ? response.data : [];
46309
46341
  const bad = rows2.find((r) => Number(r.not_numbers ?? 0) > 0);
46310
46342
  if (bad && m.op !== "count") {
@@ -46375,7 +46407,7 @@ function savedOf(row) {
46375
46407
  }
46376
46408
  async function questionsOf(client, tableId) {
46377
46409
  const response = await client.config.dataSource.schema("platform").from("saved_view").select("id, name, definition, visibility, version, created_by").eq("surface_key", QUESTION_SURFACE).eq("subject_id", tableId).is("deleted_at", null).order("name", { ascending: true });
46378
- if (response.error) return { ok: false, error: (0, import_core25.mapPgError)(response.error, "questionsOf") };
46410
+ if (response.error) return { ok: false, error: (0, import_core26.mapPgError)(response.error, "questionsOf") };
46379
46411
  const me = client.config.actor?.user_id ?? null;
46380
46412
  return {
46381
46413
  ok: true,
@@ -46404,7 +46436,7 @@ async function questionSave(client, args) {
46404
46436
  if (response.error.code === "23505") {
46405
46437
  return { ok: false, error: { code: "already_exists", message: `You already have a question called \u201C${name}\u201D.` } };
46406
46438
  }
46407
- return { ok: false, error: (0, import_core25.mapPgError)(response.error, "questionSave") };
46439
+ return { ok: false, error: (0, import_core26.mapPgError)(response.error, "questionSave") };
46408
46440
  }
46409
46441
  return { ok: true, data: response.data ? savedOf(response.data) : null };
46410
46442
  }
@@ -46414,7 +46446,7 @@ async function questionArchive(client, id, version) {
46414
46446
  { p_surface_key: QUESTION_SURFACE, p_id: id, ...version !== void 0 ? { p_expected_version: version } : {} },
46415
46447
  { schema: "public" }
46416
46448
  );
46417
- if (response.error) return { ok: false, error: (0, import_core25.mapPgError)(response.error, "questionArchive") };
46449
+ if (response.error) return { ok: false, error: (0, import_core26.mapPgError)(response.error, "questionArchive") };
46418
46450
  return { ok: true, data: response.data !== null };
46419
46451
  }
46420
46452
 
@@ -47273,7 +47305,7 @@ function TableAsk({ tableId, onOpenInQuestions }) {
47273
47305
  // src/PageScreen.tsx
47274
47306
  var import_react260 = require("react");
47275
47307
  var import_react261 = require("@ai-matrx/records/react");
47276
- var import_core26 = require("@ai-matrx/records/core");
47308
+ var import_core27 = require("@ai-matrx/records/core");
47277
47309
  var import_design_system129 = require("@ai-matrx/design-system");
47278
47310
  var import_jsx_runtime145 = require("react/jsx-runtime");
47279
47311
  var EDIT_LEVELS = /* @__PURE__ */ new Set(["edit_content", "editor", "admin", "owner"]);
@@ -47689,7 +47721,7 @@ function ListBlockView({
47689
47721
  ...sort.length > 0 ? { sort } : {}
47690
47722
  });
47691
47723
  const reload = page.reload;
47692
- (0, import_react260.useEffect)(() => (0, import_core26.onRecordChanged)(() => reload()), [reload]);
47724
+ (0, import_react260.useEffect)(() => (0, import_core27.onRecordChanged)(() => reload()), [reload]);
47693
47725
  const rows = nobodyIsMe ? [] : page.data?.rows ?? [];
47694
47726
  const columns = block.columns && block.columns.length > 0 ? block.columns.map((k) => all.find((f) => f.key === k)).filter((f) => !!f) : [...all].sort((a, b) => (a.sort ?? 100) - (b.sort ?? 100)).slice(0, DEFAULT_COLUMNS);
47695
47727
  const firstId = rows[0]?.id ?? null;
@@ -49224,7 +49256,7 @@ var import_design_system142 = require("@ai-matrx/design-system");
49224
49256
  var import_text_case19 = require("@ai-matrx/kit/text-case");
49225
49257
 
49226
49258
  // src/viewShare.ts
49227
- var import_core27 = require("@ai-matrx/records/core");
49259
+ var import_core28 = require("@ai-matrx/records/core");
49228
49260
  var NO_VIEW_REASON = "No saved view yet";
49229
49261
  function viewLink(tableId, viewId, origin) {
49230
49262
  return `${tableLink(tableId, origin)}?view=${encodeURIComponent(viewId)}`;
@@ -49260,7 +49292,7 @@ async function downloadViewCsv(args) {
49260
49292
  const columns = viewColumns(fields, view.presentation);
49261
49293
  const rows = await rowsForFile({ client, host, fields: columns, records: read.rows, labels });
49262
49294
  const name = fileNameOf(args.tableName) || "records";
49263
- download(`${name}.csv`, "text/csv;charset=utf-8", (0, import_core27.exportCsv)(columns, rows));
49295
+ download(`${name}.csv`, "text/csv;charset=utf-8", (0, import_core28.exportCsv)(columns, rows));
49264
49296
  host.notify?.success(read.cut ? cutWords(read.rows.length) : "CSV downloaded");
49265
49297
  }
49266
49298