@ai-matrx/records-ui 0.114.1 → 0.115.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.js CHANGED
@@ -130,40 +130,40 @@ function quiet(may, say2) {
130
130
  }
131
131
  function useTableRights(table) {
132
132
  const host = useRecordsUi();
133
- const asked2 = useTableRightsAsked(table, host);
134
- return useMemo(() => quiet(asked2, host.sayLevelNeeded), [asked2, host.sayLevelNeeded]);
133
+ const asked3 = useTableRightsAsked(table, host);
134
+ return useMemo(() => quiet(asked3, host.sayLevelNeeded), [asked3, host.sayLevelNeeded]);
135
135
  }
136
136
  function useTableRightsAsked(table, host) {
137
137
  const bound2 = Boolean(host.rights);
138
- const asked2 = useMyLevel(bound2 || !table ? null : table.id);
138
+ const asked3 = useMyLevel(bound2 || !table ? null : table.id);
139
139
  return useMemo(() => {
140
140
  if (!table) return NO_RIGHTS;
141
141
  if (host.rights) return host.rights(table);
142
- if (asked2.loading) return tableRights(NOT_ANSWERED_YET);
143
- const level = asked2.error ? null : asked2.data;
142
+ if (asked3.loading) return tableRights(NOT_ANSWERED_YET);
143
+ const level = asked3.error ? null : asked3.data;
144
144
  return tableRights(whatYouMayDoWithTable(table, level, true));
145
- }, [host, table, bound2, asked2.loading, asked2.error, asked2.data]);
145
+ }, [host, table, bound2, asked3.loading, asked3.error, asked3.data]);
146
146
  }
147
147
  function useRecordRights(recordId) {
148
- const asked2 = useMyLevel(recordId);
148
+ const asked3 = useMyLevel(recordId);
149
149
  const say2 = useRecordsUi().sayLevelNeeded;
150
150
  return useMemo(() => {
151
151
  if (!recordId) return NOT_ANSWERED_YET;
152
- if (asked2.loading) return NOT_ANSWERED_YET;
153
- if (asked2.error) return quiet(whatYouMayDo(null, true), say2);
154
- return quiet(whatYouMayDo(asked2.data, true), say2);
155
- }, [recordId, asked2.loading, asked2.error, asked2.data, say2]);
152
+ if (asked3.loading) return NOT_ANSWERED_YET;
153
+ if (asked3.error) return quiet(whatYouMayDo(null, true), say2);
154
+ return quiet(whatYouMayDo(asked3.data, true), say2);
155
+ }, [recordId, asked3.loading, asked3.error, asked3.data, say2]);
156
156
  }
157
157
  function useRowRights(rowIds, enabled) {
158
- const asked2 = useMyLevels(enabled ? rowIds : []);
158
+ const asked3 = useMyLevels(enabled ? rowIds : []);
159
159
  const say2 = useRecordsUi().sayLevelNeeded;
160
160
  return useMemo(() => {
161
161
  if (!enabled) return () => null;
162
- if (asked2.loading) return () => NOT_ANSWERED_YET;
163
- if (asked2.error) return () => quiet(whatYouMayDo(null, true), say2);
164
- const held = asked2.data ?? {};
162
+ if (asked3.loading) return () => NOT_ANSWERED_YET;
163
+ if (asked3.error) return () => quiet(whatYouMayDo(null, true), say2);
164
+ const held = asked3.data ?? {};
165
165
  return (rowId) => quiet(whatYouMayDo(held[rowId] ?? null, true), say2);
166
- }, [enabled, asked2.loading, asked2.error, asked2.data, say2]);
166
+ }, [enabled, asked3.loading, asked3.error, asked3.data, say2]);
167
167
  }
168
168
 
169
169
  // src/settingsAgent.ts
@@ -464,8 +464,8 @@ function isObject(value) {
464
464
  return typeof value === "object" && value !== null && !Array.isArray(value);
465
465
  }
466
466
  function columnNamed(name, fields) {
467
- const asked2 = name.trim().replace(/^\{|\}$/g, "").toLowerCase();
468
- return fields.find((f) => f.id === name) ?? fields.find((f) => f.key.toLowerCase() === asked2) ?? fields.find((f) => fieldName(f).toLowerCase() === asked2);
467
+ const asked3 = name.trim().replace(/^\{|\}$/g, "").toLowerCase();
468
+ return fields.find((f) => f.id === name) ?? fields.find((f) => f.key.toLowerCase() === asked3) ?? fields.find((f) => fieldName(f).toLowerCase() === asked3);
469
469
  }
470
470
  function settable(field2) {
471
471
  return field2.type !== "formula" && field2.source !== "formula";
@@ -1160,31 +1160,31 @@ var FILES = /* @__PURE__ */ new WeakMap();
1160
1160
  function signatureFilesOf(client, recordId) {
1161
1161
  let held = SOURCES.get(client);
1162
1162
  if (!held) SOURCES.set(client, held = /* @__PURE__ */ new Map());
1163
- let asked2 = held.get(recordId);
1164
- if (!asked2) {
1165
- asked2 = client.recordValuesVersioned({ record_id: recordId }).then((answered) => {
1163
+ let asked3 = held.get(recordId);
1164
+ if (!asked3) {
1165
+ asked3 = client.recordValuesVersioned({ record_id: recordId }).then((answered) => {
1166
1166
  if (!answered.ok) return {};
1167
1167
  return Object.fromEntries(answered.data.map((v) => [v.field_key, signatureFileOf(v.source)]));
1168
1168
  });
1169
- held.set(recordId, asked2);
1169
+ held.set(recordId, asked3);
1170
1170
  }
1171
- return asked2;
1171
+ return asked3;
1172
1172
  }
1173
1173
  function drawingOf(client, fileId) {
1174
1174
  let held = FILES.get(client);
1175
1175
  if (!held) FILES.set(client, held = /* @__PURE__ */ new Map());
1176
- let asked2 = held.get(fileId);
1177
- if (!asked2) {
1178
- asked2 = client.recordRead({ record_id: fileId }).then((answered) => {
1176
+ let asked3 = held.get(fileId);
1177
+ if (!asked3) {
1178
+ asked3 = client.recordRead({ record_id: fileId }).then((answered) => {
1179
1179
  if (!answered.ok) return { src: null, hostFileId: null };
1180
1180
  const doc = answered.data.document ?? {};
1181
1181
  const content = drawnSignatureOf(doc["content"]);
1182
1182
  const hostFileId = typeof doc["file_id"] === "string" && doc["file_id"] !== "" ? doc["file_id"] : null;
1183
1183
  return { src: content, hostFileId };
1184
1184
  });
1185
- held.set(fileId, asked2);
1185
+ held.set(fileId, asked3);
1186
1186
  }
1187
- return asked2;
1187
+ return asked3;
1188
1188
  }
1189
1189
  function DrawnImage({ src, inCell }) {
1190
1190
  return /* @__PURE__ */ jsx2(
@@ -1446,7 +1446,7 @@ function RecordLabelProvider({ children }) {
1446
1446
  const [iconsOf, setIconsOf] = useState2({});
1447
1447
  const [settled, setSettled] = useState2({});
1448
1448
  const [waitingLines, setWaitingLines] = useState2({});
1449
- const asked2 = useRef2(/* @__PURE__ */ new Set());
1449
+ const asked3 = useRef2(/* @__PURE__ */ new Set());
1450
1450
  const chased = useRef2(/* @__PURE__ */ new Set());
1451
1451
  const timers = useRef2(/* @__PURE__ */ new Map());
1452
1452
  const startWaitClock = useCallback((field2, target) => {
@@ -1484,8 +1484,8 @@ function RecordLabelProvider({ children }) {
1484
1484
  const want = useCallback(
1485
1485
  (field2) => {
1486
1486
  if (!pointsAtRecords(field2)) return;
1487
- if (asked2.current.has(field2.id)) return;
1488
- asked2.current.add(field2.id);
1487
+ if (asked3.current.has(field2.id)) return;
1488
+ asked3.current.add(field2.id);
1489
1489
  startWaitClock(field2, null);
1490
1490
  void (async () => {
1491
1491
  if (field2.type === "list") {
@@ -1576,7 +1576,7 @@ function RecordLabelProvider({ children }) {
1576
1576
  const once = choiceKeyName(field2.id, id);
1577
1577
  if (settled[field2.id] && !rereadFor.current.has(once)) {
1578
1578
  rereadFor.current.add(once);
1579
- asked2.current.delete(field2.id);
1579
+ asked3.current.delete(field2.id);
1580
1580
  want(field2);
1581
1581
  }
1582
1582
  return null;
@@ -4783,8 +4783,8 @@ function FormulaTextEditor({
4783
4783
  const report = useRef8(onChecked);
4784
4784
  report.current = onChecked;
4785
4785
  useEffect11(() => {
4786
- const asked2 = text.trim();
4787
- if (asked2 === "") {
4786
+ const asked3 = text.trim();
4787
+ if (asked3 === "") {
4788
4788
  setParsed(null);
4789
4789
  setError(null);
4790
4790
  report.current(null);
@@ -4793,7 +4793,7 @@ function FormulaTextEditor({
4793
4793
  report.current(null);
4794
4794
  let cancelled = false;
4795
4795
  const timer = setTimeout(() => {
4796
- void client.formulaPreview({ table_id: tableId, record_id: sampled, text: asked2 }).then((previewed) => previewed.ok ? previewed : client.formulaParse({ table_id: tableId, text: asked2 })).then((answered) => {
4796
+ void client.formulaPreview({ table_id: tableId, record_id: sampled, text: asked3 }).then((previewed) => previewed.ok ? previewed : client.formulaParse({ table_id: tableId, text: asked3 })).then((answered) => {
4797
4797
  if (cancelled) return;
4798
4798
  if (!answered.ok) {
4799
4799
  setError(answered.error);
@@ -10167,7 +10167,7 @@ function judgeTyped(field2, text, choices, nudge) {
10167
10167
  const allowOther = allowsOtherValues(field2);
10168
10168
  const parts = [];
10169
10169
  const add = [];
10170
- const ask = [];
10170
+ const ask2 = [];
10171
10171
  const notChoices = [];
10172
10172
  let keepOffered = allowOther;
10173
10173
  for (const word of words2) {
@@ -10178,16 +10178,16 @@ function judgeTyped(field2, text, choices, nudge) {
10178
10178
  parts.push(decided.words);
10179
10179
  if (decided.decision === "add") add.push(decided.words);
10180
10180
  else if (decided.decision === "ask") {
10181
- ask.push(decided.words);
10181
+ ask2.push(decided.words);
10182
10182
  keepOffered = keepOffered && decided.keepOffered;
10183
10183
  } else if (decided.decision === "not_a_choice") notChoices.push(decided.words);
10184
10184
  }
10185
10185
  }
10186
10186
  const valueOf2 = (list) => several ? list : list[0] ?? null;
10187
10187
  if (notChoices.length > 0) return { refusal: notAChoiceSentence(field2, notChoices), cancelOnly: true };
10188
- if (ask.length > 0) {
10188
+ if (ask2.length > 0) {
10189
10189
  return {
10190
- ask: { words: ask, keepOffered, onAdd: choiceAddition(valueOf2(parts), [...add, ...ask]), asTyped: valueOf2(parts) }
10190
+ ask: { words: ask2, keepOffered, onAdd: choiceAddition(valueOf2(parts), [...add, ...ask2]), asTyped: valueOf2(parts) }
10191
10191
  };
10192
10192
  }
10193
10193
  if (add.length > 0) return { value: choiceAddition(valueOf2(parts), add) };
@@ -11108,7 +11108,7 @@ function WhoChangedSource({
11108
11108
  const membersPort = host.members;
11109
11109
  const [answers, setAnswers] = useState33({});
11110
11110
  const [roster, setRoster] = useState33({});
11111
- const asked2 = useRef19(/* @__PURE__ */ new Set());
11111
+ const asked3 = useRef19(/* @__PURE__ */ new Set());
11112
11112
  useEffect23(() => {
11113
11113
  if (!membersPort) return;
11114
11114
  let cancelled = false;
@@ -11125,14 +11125,14 @@ function WhoChangedSource({
11125
11125
  cancelled = true;
11126
11126
  };
11127
11127
  }, [membersPort]);
11128
- const ask = useCallback9(
11128
+ const ask2 = useCallback9(
11129
11129
  (fieldKey, recordId) => {
11130
11130
  const key = `${recordId}|${fieldKey}`;
11131
- if (asked2.current.has(key)) return;
11132
- asked2.current.add(key);
11131
+ if (asked3.current.has(key)) return;
11132
+ asked3.current.add(key);
11133
11133
  void client.fieldHistory({ table_id: tableId, field_key: fieldKey, record_id: recordId, limit: 1 }).then((answered) => {
11134
11134
  if (!answered.ok) {
11135
- asked2.current.delete(key);
11135
+ asked3.current.delete(key);
11136
11136
  return;
11137
11137
  }
11138
11138
  setAnswers((now) => ({ ...now, [key]: { entry: answered.data[0] ?? null } }));
@@ -11143,11 +11143,11 @@ function WhoChangedSource({
11143
11143
  const value = useMemo13(
11144
11144
  () => ({
11145
11145
  answerFor: (fieldKey, recordId) => answers[`${recordId}|${fieldKey}`],
11146
- ask,
11146
+ ask: ask2,
11147
11147
  resolve: (userId) => roster[userId] ?? null,
11148
11148
  labelOf
11149
11149
  }),
11150
- [answers, ask, roster, labelOf]
11150
+ [answers, ask2, roster, labelOf]
11151
11151
  );
11152
11152
  return /* @__PURE__ */ jsx43(WhoChangedContext.Provider, { value, children });
11153
11153
  }
@@ -12096,7 +12096,7 @@ function WhoBadge({
12096
12096
  onPressedTwice
12097
12097
  }) {
12098
12098
  const who = useWhoChanged(field2.key, row.id);
12099
- const ask = who.ask;
12099
+ const ask2 = who.ask;
12100
12100
  return (
12101
12101
  // NEVER PART OF THE CELL'S TEXT (merged-grid review 2): its words are drawn from an attribute
12102
12102
  // by CSS, so copying the page, a range or the cell never carries "who?". It is a pointer
@@ -12113,7 +12113,7 @@ function WhoBadge({
12113
12113
  "aria-label": `Who changed ${fieldName(field2)}?`,
12114
12114
  title: who.sentence ?? `Who changed ${fieldName(field2)}? (Option-Shift-H)`,
12115
12115
  className: "hidden max-w-[9rem] shrink-0 select-none items-center truncate rounded px-1 text-[10px] leading-4 text-muted-foreground before:content-[attr(data-who-text)] hover:bg-muted in-data-[matrx-cell-active=true]:inline-flex",
12116
- onMouseEnter: ask,
12116
+ onMouseEnter: ask2,
12117
12117
  onClick: (event) => {
12118
12118
  event.preventDefault();
12119
12119
  event.stopPropagation();
@@ -13845,7 +13845,7 @@ function ActionConfirm({
13845
13845
  );
13846
13846
  }
13847
13847
  function rowActionMenuItems(args) {
13848
- const { rowId, actions, mayRun, whyNot, fields, run, ask } = args;
13848
+ const { rowId, actions, mayRun, whyNot, fields, run, ask: ask2 } = args;
13849
13849
  const items = actions.runnable.map((action3) => ({
13850
13850
  id: `row-action-${action3.id}`,
13851
13851
  label: `Run: ${action3.name}`,
@@ -13853,9 +13853,9 @@ function rowActionMenuItems(args) {
13853
13853
  disabledReason: mayRun ? void 0 : whyNot,
13854
13854
  onSelect: () => run(action3, rowId)
13855
13855
  }));
13856
- if (ask) {
13856
+ if (ask2) {
13857
13857
  for (const action3 of actions.agent) {
13858
- items.push({ id: `row-agent-${action3.id}`, label: `Ask: ${action3.name}`, icon: "zap", onSelect: () => ask(action3, rowId) });
13858
+ items.push({ id: `row-agent-${action3.id}`, label: `Ask: ${action3.name}`, icon: "zap", onSelect: () => ask2(action3, rowId) });
13859
13859
  }
13860
13860
  }
13861
13861
  for (const action3 of actions.notRunnable) {
@@ -14502,8 +14502,8 @@ function useColumnSummaries(args) {
14502
14502
  const filterKey = JSON.stringify(args.filter ?? {});
14503
14503
  useEffect33(() => {
14504
14504
  const entries = JSON.parse(chosenKey);
14505
- const asked2 = JSON.parse(filterKey);
14506
- const filter = Object.keys(asked2).length > 0 ? asked2 : void 0;
14505
+ const asked3 = JSON.parse(filterKey);
14506
+ const filter = Object.keys(asked3).length > 0 ? asked3 : void 0;
14507
14507
  if (entries.length === 0) {
14508
14508
  setValues({});
14509
14509
  setError(null);
@@ -15478,11 +15478,11 @@ function useMergedGridControls(args) {
15478
15478
  const [keys, filters, base2, searched] = JSON.parse(countQuestionKey);
15479
15479
  for (const key of keys) {
15480
15480
  const { [key]: _own, ...others } = filters;
15481
- const asked2 = storeQuestion(fieldsRef.current, base2 ?? void 0, others);
15481
+ const asked3 = storeQuestion(fieldsRef.current, base2 ?? void 0, others);
15482
15482
  void (0, askOnce_exports.askOnce)(
15483
15483
  client,
15484
- `value_counts:${tableId}:${key}:${searched}:${JSON.stringify(asked2.filter ?? null)}`,
15485
- () => client.recordAggregate({ table_id: tableId, groupBy: [key], measures: [{ op: "count" }], ...asked2.filter ? { filter: asked2.filter } : {}, ...searched ? { search: searched } : {}, limit: 500 }),
15484
+ `value_counts:${tableId}:${key}:${searched}:${JSON.stringify(asked3.filter ?? null)}`,
15485
+ () => client.recordAggregate({ table_id: tableId, groupBy: [key], measures: [{ op: "count" }], ...asked3.filter ? { filter: asked3.filter } : {}, ...searched ? { search: searched } : {}, limit: 500 }),
15486
15486
  VALUE_COUNTS_FRESH_MS
15487
15487
  ).then((answer) => {
15488
15488
  if (cancelled || !answer.ok) return;
@@ -16171,7 +16171,7 @@ var ADDABLE_TYPE_SET = new Set(ADDABLE_TYPES.map((t) => t.value));
16171
16171
  function customFieldRequestProblems(requests, existingLabels) {
16172
16172
  const problems = [];
16173
16173
  const taken = new Set(existingLabels.map((l) => l.trim().toLowerCase()));
16174
- const asked2 = /* @__PURE__ */ new Set();
16174
+ const asked3 = /* @__PURE__ */ new Set();
16175
16175
  if (requests.length === 0) problems.push("Name at least one field to add.");
16176
16176
  requests.forEach((request, index) => {
16177
16177
  const at = requests.length > 1 ? `Field ${index + 1}: ` : "";
@@ -16204,8 +16204,8 @@ function customFieldRequestProblems(requests, existingLabels) {
16204
16204
  }
16205
16205
  const key = label.toLowerCase();
16206
16206
  if (taken.has(key)) problems.push(`${at}there is already a field named "${label}".`);
16207
- else if (asked2.has(key)) problems.push(`${at}"${label}" is asked for twice.`);
16208
- asked2.add(key);
16207
+ else if (asked3.has(key)) problems.push(`${at}"${label}" is asked for twice.`);
16208
+ asked3.add(key);
16209
16209
  });
16210
16210
  return problems;
16211
16211
  }
@@ -17019,15 +17019,15 @@ function useAddedRows(args) {
17019
17019
  setAnchors(/* @__PURE__ */ new Map());
17020
17020
  }, [pageKey, tableId]);
17021
17021
  const pinnedKey = added.map((r) => r.id).join(",");
17022
- const asked2 = useRef28(0);
17022
+ const asked3 = useRef28(0);
17023
17023
  useEffect40(() => {
17024
17024
  if (!enabled || added.length === 0) return;
17025
17025
  const onPage = new Set(pageRows.map((r) => r.id));
17026
17026
  const missing = added.filter((r) => !onPage.has(r.id)).map((r) => r.id);
17027
17027
  if (missing.length === 0) return;
17028
- const ticket = asked2.current += 1;
17028
+ const ticket = asked3.current += 1;
17029
17029
  void client.listByIds({ table_id: tableId, ids: missing }).then((answer) => {
17030
- if (ticket !== asked2.current || !answer.ok) return;
17030
+ if (ticket !== asked3.current || !answer.ok) return;
17031
17031
  const fresh = new Map(answer.data.map((r) => [r.id, r]));
17032
17032
  setAdded(
17033
17033
  (held) => held.flatMap((row) => {
@@ -17148,17 +17148,17 @@ function NewRecordControl({
17148
17148
  busy,
17149
17149
  onAdd,
17150
17150
  onCreated,
17151
- ask
17151
+ ask: ask2
17152
17152
  }) {
17153
17153
  const [formOpen, setFormOpen] = useState51(false);
17154
17154
  const [formInitial, setFormInitial] = useState51({});
17155
17155
  const seenAsk = useRef28(0);
17156
17156
  useEffect40(() => {
17157
- if (!ask || ask.n === seenAsk.current) return;
17158
- seenAsk.current = ask.n;
17159
- setFormInitial(ask.initial);
17157
+ if (!ask2 || ask2.n === seenAsk.current) return;
17158
+ seenAsk.current = ask2.n;
17159
+ setFormInitial(ask2.initial);
17160
17160
  setFormOpen(true);
17161
- }, [ask]);
17161
+ }, [ask2]);
17162
17162
  return /* @__PURE__ */ jsxs57(Fragment17, { children: [
17163
17163
  /* @__PURE__ */ jsxs57("div", { className: "inline-flex shrink-0", "data-records-new-record": "", children: [
17164
17164
  /* @__PURE__ */ jsx62(Button34, { size: "sm", className: "rounded-r-none", disabled: busy, onClick: onAdd, children: busy ? "Adding\u2026" : "New record" }),
@@ -17224,7 +17224,7 @@ import {
17224
17224
  drillRequestKey,
17225
17225
  parseDimensionRef
17226
17226
  } from "@ai-matrx/design-system/data-table";
17227
- var askId = (ask) => `${ask.outer ?? ""}|${ask.fact}`;
17227
+ var askId = (ask2) => `${ask2.outer ?? ""}|${ask2.fact}`;
17228
17228
  function valueOf(v) {
17229
17229
  return v === null || v === void 0 || v === "" ? null : String(v);
17230
17230
  }
@@ -17266,14 +17266,14 @@ function drillLevelAsks(args) {
17266
17266
  }
17267
17267
  return { attributes, focus, names };
17268
17268
  }
17269
- function drillLevelHeld(ask, rows) {
17269
+ function drillLevelHeld(ask2, rows) {
17270
17270
  const held = {};
17271
17271
  for (const row of rows) {
17272
17272
  if (row.kind !== "group" || !row.groups) continue;
17273
- const g = ask.outer ? valueOf(row.groups[ask.outer]) : "\0";
17273
+ const g = ask2.outer ? valueOf(row.groups[ask2.outer]) : "\0";
17274
17274
  if (g === null) continue;
17275
- const v = valueOf(row.groups[ask.fact]);
17276
- (held[g] ??= /* @__PURE__ */ new Map()).set(v, row.labels?.[ask.fact] ?? null);
17275
+ const v = valueOf(row.groups[ask2.fact]);
17276
+ (held[g] ??= /* @__PURE__ */ new Map()).set(v, row.labels?.[ask2.fact] ?? null);
17277
17277
  }
17278
17278
  return held;
17279
17279
  }
@@ -17297,20 +17297,20 @@ function useDrillLevelReads(args) {
17297
17297
  let cancelled = false;
17298
17298
  const parsed = JSON.parse(key);
17299
17299
  void Promise.all(
17300
- parsed.all.map(async (ask) => {
17301
- const by = ask.outer ? [ask.outer, ask.fact] : [ask.fact];
17300
+ parsed.all.map(async (ask2) => {
17301
+ const by = ask2.outer ? [ask2.outer, ask2.fact] : [ask2.fact];
17302
17302
  const got = await client.drillAsk({
17303
17303
  source: parsed.source,
17304
17304
  question: {
17305
17305
  by,
17306
17306
  show: ["count"],
17307
- where: ask.where,
17307
+ where: ask2.where,
17308
17308
  ...parsed.window ? { window: parsed.window } : {},
17309
17309
  ...parsed.lane ? { lane: parsed.lane } : {}
17310
17310
  }
17311
17311
  }).catch((e) => ({ ok: false, error: { message: e instanceof Error ? e.message : "" } }));
17312
- if (!got.ok) return { ask, rows: [], failed: refusalSentence(got.error) || "Not read" };
17313
- return { ask, rows: got.data.rows, failed: null };
17312
+ if (!got.ok) return { ask: ask2, rows: [], failed: refusalSentence(got.error) || "Not read" };
17313
+ return { ask: ask2, rows: got.data.rows, failed: null };
17314
17314
  })
17315
17315
  ).then((results) => {
17316
17316
  if (cancelled) return;
@@ -17329,41 +17329,41 @@ function useDrillLevelReads(args) {
17329
17329
  const ready = state.key === key;
17330
17330
  const dim = (k) => dimensions.find((d) => d.key === k);
17331
17331
  const outer2 = question.by[0] ?? null;
17332
- const attributes = asks.attributes.length === 0 || !outer2 ? void 0 : asks.attributes.map((ask) => {
17333
- const d = dim(ask.fact);
17334
- const why = ready ? state.failed[askId(ask)] : void 0;
17332
+ const attributes = asks.attributes.length === 0 || !outer2 ? void 0 : asks.attributes.map((ask2) => {
17333
+ const d = dim(ask2.fact);
17334
+ const why = ready ? state.failed[askId(ask2)] : void 0;
17335
17335
  return {
17336
- key: ask.fact,
17337
- label: d?.label ?? ask.fact,
17336
+ key: ask2.fact,
17337
+ label: d?.label ?? ask2.fact,
17338
17338
  ...d?.description ? { description: d.description } : {},
17339
17339
  ...why ? { error: why } : {},
17340
17340
  read: (groups) => {
17341
17341
  if (!ready) return void 0;
17342
17342
  const g = groups[outer2];
17343
- return g ? drillFactWords(state.held[askId(ask)]?.[g], d) : null;
17343
+ return g ? drillFactWords(state.held[askId(ask2)]?.[g], d) : null;
17344
17344
  }
17345
17345
  };
17346
17346
  });
17347
- const focusAttributes = asks.focus.length === 0 ? void 0 : asks.focus.map((ask) => {
17348
- const d = dim(ask.fact);
17349
- const why = ready ? state.failed[askId(ask)] : void 0;
17347
+ const focusAttributes = asks.focus.length === 0 ? void 0 : asks.focus.map((ask2) => {
17348
+ const d = dim(ask2.fact);
17349
+ const why = ready ? state.failed[askId(ask2)] : void 0;
17350
17350
  return {
17351
- key: ask.fact,
17352
- label: d?.label ?? ask.fact,
17353
- value: ready ? drillFactWords(state.held[askId(ask)]?.["\0"], d) : void 0,
17351
+ key: ask2.fact,
17352
+ label: d?.label ?? ask2.fact,
17353
+ value: ready ? drillFactWords(state.held[askId(ask2)]?.["\0"], d) : void 0,
17354
17354
  ...why ? { error: why } : {}
17355
17355
  };
17356
17356
  });
17357
17357
  const names = /* @__PURE__ */ new Map();
17358
17358
  if (ready) {
17359
- for (const ask of asks.names) {
17360
- if (!ask.outer) continue;
17361
- const out = names.get(ask.outer) ?? /* @__PURE__ */ new Map();
17362
- for (const [value, facts] of Object.entries(state.held[askId(ask)] ?? {})) {
17363
- const words2 = drillFactWords(facts, dim(ask.fact));
17359
+ for (const ask2 of asks.names) {
17360
+ if (!ask2.outer) continue;
17361
+ const out = names.get(ask2.outer) ?? /* @__PURE__ */ new Map();
17362
+ for (const [value, facts] of Object.entries(state.held[askId(ask2)] ?? {})) {
17363
+ const words2 = drillFactWords(facts, dim(ask2.fact));
17364
17364
  if (words2 && words2 !== "Several") out.set(value, words2);
17365
17365
  }
17366
- names.set(ask.outer, out);
17366
+ names.set(ask2.outer, out);
17367
17367
  }
17368
17368
  }
17369
17369
  return { attributes, focusAttributes, names };
@@ -17492,33 +17492,33 @@ function useDrillAnswers(args) {
17492
17492
  });
17493
17493
  useEffect42(() => {
17494
17494
  if (!enabled || !source || question.by.length === 0) return;
17495
- const asked2 = JSON.parse(askKey2);
17496
- const range = asked2.window && asked2.windowKey ? drillWindowRange(asked2.window) : null;
17497
- const compare = asked2.compare && range && asked2.windowKey ? {
17498
- against: asked2.compare,
17495
+ const asked3 = JSON.parse(askKey2);
17496
+ const range = asked3.window && asked3.windowKey ? drillWindowRange(asked3.window) : null;
17497
+ const compare = asked3.compare && range && asked3.windowKey ? {
17498
+ against: asked3.compare,
17499
17499
  from: range.from,
17500
17500
  to: range.to,
17501
- ...asked2.source.kind === "table" ? { key: asked2.windowKey } : {}
17501
+ ...asked3.source.kind === "table" ? { key: asked3.windowKey } : {}
17502
17502
  } : void 0;
17503
17503
  let cancelled = false;
17504
17504
  setAnswers({});
17505
17505
  setError(null);
17506
- const requests = drillRequests({ by: asked2.by, across: asked2.across, show: asked2.show, where: [] });
17506
+ const requests = drillRequests({ by: asked3.by, across: asked3.across, show: asked3.show, where: [] });
17507
17507
  void Promise.all(
17508
17508
  requests.map(async (request) => {
17509
- if (asked2.rule && asked2.source.kind === "table") {
17509
+ if (asked3.rule && asked3.source.kind === "table") {
17510
17510
  const time = request.by.find((ref) => parseDimensionRef2(ref).grain !== null) ?? null;
17511
17511
  const t = time ? parseDimensionRef2(time) : null;
17512
- const measures = asked2.show.map(storeMeasure).filter((m) => m !== null);
17512
+ const measures = asked3.show.map(storeMeasure).filter((m) => m !== null);
17513
17513
  if (t?.grain === "hour") return { request, error: "This table's periods start at a day; it cannot be read by the hour." };
17514
17514
  const got2 = await client.recordAggregate({
17515
- table_id: asked2.source.id,
17515
+ table_id: asked3.source.id,
17516
17516
  groupBy: request.by.filter((ref) => ref !== time),
17517
17517
  measures,
17518
17518
  bucket: t && t.grain ? { key: t.key, by: t.grain } : null,
17519
- filter: asked2.rule,
17519
+ filter: asked3.rule,
17520
17520
  limit: 200,
17521
- ...compare ? { compare: { against: compare.against, key: asked2.windowKey, from: compare.from, to: compare.to } } : {}
17521
+ ...compare ? { compare: { against: compare.against, key: asked3.windowKey, from: compare.from, to: compare.to } } : {}
17522
17522
  });
17523
17523
  if (!got2.ok) return { request, error: refusalSentence(got2.error) };
17524
17524
  return {
@@ -17542,13 +17542,13 @@ function useDrillAnswers(args) {
17542
17542
  };
17543
17543
  }
17544
17544
  const got = await client.drillAsk({
17545
- source: asked2.source,
17545
+ source: asked3.source,
17546
17546
  question: {
17547
17547
  by: request.by,
17548
- show: asked2.show,
17549
- where: asked2.where,
17550
- ...asked2.lane ? { lane: asked2.lane } : {},
17551
- ...range && asked2.windowKey ? { window: { key: asked2.windowKey, from: range.from, to: range.to } } : {},
17548
+ show: asked3.show,
17549
+ where: asked3.where,
17550
+ ...asked3.lane ? { lane: asked3.lane } : {},
17551
+ ...range && asked3.windowKey ? { window: { key: asked3.windowKey, from: range.from, to: range.to } } : {},
17552
17552
  ...compare ? { compare } : {}
17553
17553
  }
17554
17554
  });
@@ -20051,12 +20051,12 @@ function ImportWizard({ tableId, source, onDone, onWrote, className }) {
20051
20051
  }
20052
20052
  if (!skip) out[header] = ids.join("; ");
20053
20053
  }
20054
- for (const ask of dateAsks) {
20055
- const raw = String(row[ask.header] ?? "").trim();
20054
+ for (const ask2 of dateAsks) {
20055
+ const raw = String(row[ask2.header] ?? "").trim();
20056
20056
  if (raw === "") continue;
20057
- const day2 = ask.dates.read.get(at);
20058
- if (day2 !== void 0) out[ask.header] = day2;
20059
- else if ((dateMiss[ask.header] ?? "empty") === "empty") out[ask.header] = "";
20057
+ const day2 = ask2.dates.read.get(at);
20058
+ if (day2 !== void 0) out[ask2.header] = day2;
20059
+ else if ((dateMiss[ask2.header] ?? "empty") === "empty") out[ask2.header] = "";
20060
20060
  }
20061
20061
  sent.push(out);
20062
20062
  lines.push(combined?.lines[at]?.[0] ?? at + 1);
@@ -20070,8 +20070,8 @@ function ImportWizard({ tableId, source, onDone, onWrote, className }) {
20070
20070
  if (!plan) return;
20071
20071
  setProblem(null);
20072
20072
  if (nudge === "always_add" && rights.admin) {
20073
- for (const ask of newChoiceWords) {
20074
- if (!await addChoiceWords(ask.field, ask.words)) return;
20073
+ for (const ask2 of newChoiceWords) {
20074
+ if (!await addChoiceWords(ask2.field, ask2.words)) return;
20075
20075
  }
20076
20076
  }
20077
20077
  setOutcomes([]);
@@ -20079,12 +20079,12 @@ function ImportWizard({ tableId, source, onDone, onWrote, className }) {
20079
20079
  setProgress(0);
20080
20080
  setLedger(null);
20081
20081
  let index = relationIndex;
20082
- const toMerge = relationAsks.filter((ask) => choiceFor(ask.field.key).ambiguous === "merge" && ask.ambiguous.length > 0);
20082
+ const toMerge = relationAsks.filter((ask2) => choiceFor(ask2.field.key).ambiguous === "merge" && ask2.ambiguous.length > 0);
20083
20083
  if (toMerge.length > 0) {
20084
20084
  setPhase("linking");
20085
- for (const ask of toMerge) {
20086
- for (const [name] of ask.ambiguous) {
20087
- const hits = ask.index.byName.get(relationNameKey2(name)) ?? [];
20085
+ for (const ask2 of toMerge) {
20086
+ for (const [name] of ask2.ambiguous) {
20087
+ const hits = ask2.index.byName.get(relationNameKey2(name)) ?? [];
20088
20088
  const winner = hits[0];
20089
20089
  if (!winner) continue;
20090
20090
  for (const loser of hits.slice(1)) {
@@ -20108,15 +20108,15 @@ function ImportWizard({ tableId, source, onDone, onWrote, className }) {
20108
20108
  }
20109
20109
  index = reread;
20110
20110
  }
20111
- const toMake = relationAsks.filter((ask) => choiceFor(ask.field.key).unmatched === "create" && ask.unmatched.length > 0);
20111
+ const toMake = relationAsks.filter((ask2) => choiceFor(ask2.field.key).unmatched === "create" && ask2.unmatched.length > 0);
20112
20112
  if (toMake.length > 0) {
20113
20113
  setPhase("linking");
20114
- for (const ask of toMake) {
20115
- const title = ask.index.titleField;
20114
+ for (const ask2 of toMake) {
20115
+ const title = ask2.index.titleField;
20116
20116
  if (!title) continue;
20117
20117
  const made = await client.recordWriteMany({
20118
- table_id: ask.field.relation_target,
20119
- rows: ask.unmatched.map(([name]) => ({ [title]: name }))
20118
+ table_id: ask2.field.relation_target,
20119
+ rows: ask2.unmatched.map(([name]) => ({ [title]: name }))
20120
20120
  });
20121
20121
  if (!made.ok) {
20122
20122
  setProblem(made.error);
@@ -20597,20 +20597,20 @@ function ImportWizard({ tableId, source, onDone, onWrote, className }) {
20597
20597
  linesWord(repeats.map((r) => r.row + 1), lineWord),
20598
20598
  ")"
20599
20599
  ] }) : null,
20600
- newChoiceWords.map((ask) => {
20601
- const words2 = ask.words.map((w) => `\u201C${w}\u201D`).join(", ");
20602
- const column = fieldName(ask.field);
20600
+ newChoiceWords.map((ask2) => {
20601
+ const words2 = ask2.words.map((w) => `\u201C${w}\u201D`).join(", ");
20602
+ const column = fieldName(ask2.field);
20603
20603
  const canAdd = rights.admin && nudge !== "never_add";
20604
20604
  return /* @__PURE__ */ jsxs64(
20605
20605
  "div",
20606
20606
  {
20607
20607
  className: "flex flex-wrap items-center gap-2 rounded border border-amber-500/40 bg-amber-500/5 px-2 py-1.5",
20608
- "data-import-new-choices": ask.field.key,
20608
+ "data-import-new-choices": ask2.field.key,
20609
20609
  children: [
20610
20610
  /* @__PURE__ */ jsxs64("span", { children: [
20611
- ask.words.length === 1 ? `${words2} is not one of ${column}'s choices.` : `${words2} are not among ${column}'s choices.`,
20611
+ ask2.words.length === 1 ? `${words2} is not one of ${column}'s choices.` : `${words2} are not among ${column}'s choices.`,
20612
20612
  " ",
20613
- nudge === "always_add" && rights.admin ? `Your organization adds new choices without asking, so ${ask.words.length === 1 ? "it is" : "they are"} added when you import.` : canAdd ? `Add ${ask.words.length === 1 ? "it" : "them"}, or the rows that use ${ask.words.length === 1 ? "it" : "them"} are refused.` : `The rows that use ${ask.words.length === 1 ? "it" : "them"} are refused${rights.admin ? " (your organization does not add new choices from an import)" : " \u2014 only someone who manages this table can add choices"}.`
20613
+ nudge === "always_add" && rights.admin ? `Your organization adds new choices without asking, so ${ask2.words.length === 1 ? "it is" : "they are"} added when you import.` : canAdd ? `Add ${ask2.words.length === 1 ? "it" : "them"}, or the rows that use ${ask2.words.length === 1 ? "it" : "them"} are refused.` : `The rows that use ${ask2.words.length === 1 ? "it" : "them"} are refused${rights.admin ? " (your organization does not add new choices from an import)" : " \u2014 only someone who manages this table can add choices"}.`
20614
20614
  ] }),
20615
20615
  canAdd && nudge !== "always_add" ? /* @__PURE__ */ jsx69(
20616
20616
  Button39,
@@ -20618,26 +20618,26 @@ function ImportWizard({ tableId, source, onDone, onWrote, className }) {
20618
20618
  size: "sm",
20619
20619
  variant: "outline",
20620
20620
  disabled: busy || addingWords !== null,
20621
- onClick: () => void addChoiceWords(ask.field, ask.words),
20622
- children: addingWords === ask.field.key ? "Adding\u2026" : `Add to ${column}`
20621
+ onClick: () => void addChoiceWords(ask2.field, ask2.words),
20622
+ children: addingWords === ask2.field.key ? "Adding\u2026" : `Add to ${column}`
20623
20623
  }
20624
20624
  ) : null
20625
20625
  ]
20626
20626
  },
20627
- ask.field.key
20627
+ ask2.field.key
20628
20628
  );
20629
20629
  }),
20630
20630
  relationProblem ? /* @__PURE__ */ jsx69(RefusalNotice, { error: relationProblem }) : null,
20631
- relationAsks.map((ask) => {
20632
- const column = fieldName(ask.field);
20633
- const table2 = ask.index.tableName;
20634
- const choice = choiceFor(ask.field.key);
20635
- const setChoice = (patch) => setUnlinkedChoice((held) => ({ ...held, [ask.field.key]: { ...choice, ...patch } }));
20636
- const clean = ask.unmatched.length === 0 && ask.ambiguous.length === 0;
20631
+ relationAsks.map((ask2) => {
20632
+ const column = fieldName(ask2.field);
20633
+ const table2 = ask2.index.tableName;
20634
+ const choice = choiceFor(ask2.field.key);
20635
+ const setChoice = (patch) => setUnlinkedChoice((held) => ({ ...held, [ask2.field.key]: { ...choice, ...patch } }));
20636
+ const clean = ask2.unmatched.length === 0 && ask2.ambiguous.length === 0;
20637
20637
  return /* @__PURE__ */ jsxs64(
20638
20638
  "div",
20639
20639
  {
20640
- "data-import-relation": ask.field.key,
20640
+ "data-import-relation": ask2.field.key,
20641
20641
  className: cn37(
20642
20642
  "flex flex-col gap-1 rounded border px-2 py-1.5",
20643
20643
  clean ? "bg-muted/40" : "border-amber-500/40 bg-amber-500/5"
@@ -20646,21 +20646,21 @@ function ImportWizard({ tableId, source, onDone, onWrote, className }) {
20646
20646
  /* @__PURE__ */ jsxs64("span", { "data-import-relation-linked": "", children: [
20647
20647
  column,
20648
20648
  ": ",
20649
- ask.linked,
20649
+ ask2.linked,
20650
20650
  " of ",
20651
- ask.named,
20651
+ ask2.named,
20652
20652
  " rows link to ",
20653
20653
  table2,
20654
20654
  " by name"
20655
20655
  ] }),
20656
- ask.unmatched.length > 0 ? /* @__PURE__ */ jsxs64("div", { className: "flex flex-col gap-1", "data-import-relation-unmatched": "", children: [
20656
+ ask2.unmatched.length > 0 ? /* @__PURE__ */ jsxs64("div", { className: "flex flex-col gap-1", "data-import-relation-unmatched": "", children: [
20657
20657
  /* @__PURE__ */ jsxs64("span", { children: [
20658
20658
  "Not in ",
20659
20659
  table2,
20660
20660
  ":",
20661
20661
  " ",
20662
- ask.unmatched.slice(0, 6).map(([name, lines]) => `\u201C${name}\u201D (${linesWord(lines, lineWord)})`).join(", "),
20663
- ask.unmatched.length > 6 ? ` +${ask.unmatched.length - 6}` : ""
20662
+ ask2.unmatched.slice(0, 6).map(([name, lines]) => `\u201C${name}\u201D (${linesWord(lines, lineWord)})`).join(", "),
20663
+ ask2.unmatched.length > 6 ? ` +${ask2.unmatched.length - 6}` : ""
20664
20664
  ] }),
20665
20665
  /* @__PURE__ */ jsxs64("label", { className: "flex items-center gap-1", children: [
20666
20666
  /* @__PURE__ */ jsx69("span", { className: "text-muted-foreground", children: "Those rows" }),
@@ -20672,7 +20672,7 @@ function ImportWizard({ tableId, source, onDone, onWrote, className }) {
20672
20672
  disabled: busy,
20673
20673
  onChange: (picked) => setChoice({ unmatched: picked }),
20674
20674
  options: [
20675
- ...ask.index.titleField ? [{ value: "create", label: `add the names to ${table2}` }] : [],
20675
+ ...ask2.index.titleField ? [{ value: "create", label: `add the names to ${table2}` }] : [],
20676
20676
  { value: "empty", label: "import with no link" },
20677
20677
  { value: "skip", label: "are skipped" }
20678
20678
  ]
@@ -20680,13 +20680,13 @@ function ImportWizard({ tableId, source, onDone, onWrote, className }) {
20680
20680
  )
20681
20681
  ] })
20682
20682
  ] }) : null,
20683
- ask.ambiguous.length > 0 ? /* @__PURE__ */ jsxs64("div", { className: "flex flex-col gap-1", "data-import-relation-ambiguous": "", children: [
20683
+ ask2.ambiguous.length > 0 ? /* @__PURE__ */ jsxs64("div", { className: "flex flex-col gap-1", "data-import-relation-ambiguous": "", children: [
20684
20684
  /* @__PURE__ */ jsxs64("span", { children: [
20685
20685
  "More than one record in ",
20686
20686
  table2,
20687
20687
  ":",
20688
20688
  " ",
20689
- ask.ambiguous.slice(0, 6).map(([name, seen]) => `\u201C${name}\u201D \xD7${seen.count} (${linesWord(seen.lines, lineWord)})`).join(", ")
20689
+ ask2.ambiguous.slice(0, 6).map(([name, seen]) => `\u201C${name}\u201D \xD7${seen.count} (${linesWord(seen.lines, lineWord)})`).join(", ")
20690
20690
  ] }),
20691
20691
  /* @__PURE__ */ jsxs64("label", { className: "flex items-center gap-1", children: [
20692
20692
  /* @__PURE__ */ jsx69("span", { className: "text-muted-foreground", children: "Those rows" }),
@@ -20708,21 +20708,21 @@ function ImportWizard({ tableId, source, onDone, onWrote, className }) {
20708
20708
  ] }) : null
20709
20709
  ]
20710
20710
  },
20711
- ask.field.key
20711
+ ask2.field.key
20712
20712
  );
20713
20713
  }),
20714
- dateAsks.filter((ask) => ask.dates.unreadable.length > 0).map((ask) => {
20715
- const miss = ask.dates.unreadable;
20714
+ dateAsks.filter((ask2) => ask2.dates.unreadable.length > 0).map((ask2) => {
20715
+ const miss = ask2.dates.unreadable;
20716
20716
  const byWord = /* @__PURE__ */ new Map();
20717
20717
  for (const m of miss) byWord.set(m.raw, [...byWord.get(m.raw) ?? [], m.row + 1]);
20718
20718
  return /* @__PURE__ */ jsxs64(
20719
20719
  "div",
20720
20720
  {
20721
- "data-import-dates": ask.header,
20721
+ "data-import-dates": ask2.header,
20722
20722
  className: "flex flex-col gap-1 rounded border border-amber-500/40 bg-amber-500/5 px-2 py-1.5",
20723
20723
  children: [
20724
20724
  /* @__PURE__ */ jsxs64("span", { children: [
20725
- ask.label,
20725
+ ask2.label,
20726
20726
  ": ",
20727
20727
  miss.length,
20728
20728
  " ",
@@ -20737,10 +20737,10 @@ function ImportWizard({ tableId, source, onDone, onWrote, className }) {
20737
20737
  /* @__PURE__ */ jsx69(
20738
20738
  PickOne,
20739
20739
  {
20740
- label: `What cells of ${ask.header} that are not dates do`,
20741
- value: dateMiss[ask.header] ?? "empty",
20740
+ label: `What cells of ${ask2.header} that are not dates do`,
20741
+ value: dateMiss[ask2.header] ?? "empty",
20742
20742
  disabled: busy,
20743
- onChange: (picked) => setDateMiss((held) => ({ ...held, [ask.header]: picked })),
20743
+ onChange: (picked) => setDateMiss((held) => ({ ...held, [ask2.header]: picked })),
20744
20744
  options: [
20745
20745
  { value: "empty", label: "are left empty" },
20746
20746
  { value: "skip", label: "skip their rows" }
@@ -20750,7 +20750,7 @@ function ImportWizard({ tableId, source, onDone, onWrote, className }) {
20750
20750
  ] })
20751
20751
  ]
20752
20752
  },
20753
- ask.header
20753
+ ask2.header
20754
20754
  );
20755
20755
  }),
20756
20756
  ruleVerdicts.length > 0 ? /* @__PURE__ */ jsx69(
@@ -21720,13 +21720,13 @@ async function askColumnValues(inputs, args) {
21720
21720
  if (kind === "loaded") return null;
21721
21721
  const searched = args.search.trim();
21722
21722
  const { [args.columnId]: _own, ...others } = inputs.columnFilters;
21723
- const asked2 = storeQuestion(inputs.fields, inputs.filter, others);
21723
+ const asked3 = storeQuestion(inputs.fields, inputs.filter, others);
21724
21724
  const limit = Math.min(Math.max(args.limit, 1), MOST_VALUES);
21725
21725
  const answer = await inputs.client.recordAggregate({
21726
21726
  table_id: inputs.tableId,
21727
21727
  ...kind === "days" ? { bucket: { key: field2.key, by: "day" } } : { groupBy: [field2.key] },
21728
21728
  measures: [{ op: "count" }],
21729
- ...asked2.filter ? { filter: asked2.filter } : {},
21729
+ ...asked3.filter ? { filter: asked3.filter } : {},
21730
21730
  ...searched ? { search: searched } : {},
21731
21731
  limit: MOST_VALUES
21732
21732
  });
@@ -21739,7 +21739,7 @@ async function askColumnValues(inputs, args) {
21739
21739
  const unique = await inputs.client.recordAggregate({
21740
21740
  table_id: inputs.tableId,
21741
21741
  measures: [{ op: "unique", key: field2.key }],
21742
- ...asked2.filter ? { filter: asked2.filter } : {},
21742
+ ...asked3.filter ? { filter: asked3.filter } : {},
21743
21743
  ...searched ? { search: searched } : {}
21744
21744
  });
21745
21745
  if (unique.ok) {
@@ -21781,8 +21781,8 @@ function useGroupFacts(args) {
21781
21781
  }
21782
21782
  if (version === void 0 || version === null) return;
21783
21783
  const entries = JSON.parse(chosenKey);
21784
- const asked2 = JSON.parse(filterKey);
21785
- const filter = Object.keys(asked2).length > 0 ? asked2 : void 0;
21784
+ const asked3 = JSON.parse(filterKey);
21785
+ const filter = Object.keys(asked3).length > 0 ? asked3 : void 0;
21786
21786
  const measures = groupFactMeasures(Object.fromEntries(entries));
21787
21787
  let cancelled = false;
21788
21788
  void client.recordAggregate({ table_id: tableId, groupBy: [groupKey], measures, limit: 1e3, ...filter ? { filter } : {} }).then((answered) => {
@@ -23427,7 +23427,7 @@ function GridBody({
23427
23427
  if (appending || !embeddedMore) return;
23428
23428
  const requestAskKey = askKey2;
23429
23429
  setAppending(true);
23430
- const asked2 = await client.listPage({
23430
+ const asked3 = await client.listPage({
23431
23431
  table_id: tableId,
23432
23432
  ...pageFilter ? { filter: pageFilter } : {},
23433
23433
  search: pageSearch.trim() === "" ? null : pageSearch.trim(),
@@ -23438,8 +23438,8 @@ function GridBody({
23438
23438
  });
23439
23439
  if (embeddedAskKey.current !== requestAskKey) return;
23440
23440
  setAppending(false);
23441
- if (asked2.ok) {
23442
- setAppendedRows((held) => [...held, ...asked2.data.rows]);
23441
+ if (asked3.ok) {
23442
+ setAppendedRows((held) => [...held, ...asked3.data.rows]);
23443
23443
  setAppendedPhysicalPages((pages) => pages + 1);
23444
23444
  }
23445
23445
  }, [appending, embeddedMore, askKey2, client, tableId, pageFilter, pageSearch, pageSort, pageDoorViewId, nextEmbeddedPhysicalOffset]);
@@ -25351,8 +25351,8 @@ function GridBody({
25351
25351
  }
25352
25352
  ) });
25353
25353
  }
25354
- function askWhenAColumnMenuIsReached(target, ask) {
25355
- if (target?.closest?.('[role="columnheader"], thead, [data-matrx-canonical-signature="column-menu"]')) ask();
25354
+ function askWhenAColumnMenuIsReached(target, ask2) {
25355
+ if (target?.closest?.('[role="columnheader"], thead, [data-matrx-canonical-signature="column-menu"]')) ask2();
25356
25356
  }
25357
25357
  var DETAIL_OFF = { enabled: false };
25358
25358
  var WINDOW_OFF = { enabled: false };
@@ -26261,9 +26261,9 @@ function whyNotAskable(fields, hidden = []) {
26261
26261
  const said2 = left.map((f) => `${f.label || f.key} ${CANNOT_ASK[f.type]}`);
26262
26262
  return said2.length === 1 ? `${said2[0]}, so it is not offered here.` : `These are not offered here: ${said2.join("; ")}.`;
26263
26263
  }
26264
- function requiredLeftUnasked(fields, asked2, storeFills = []) {
26264
+ function requiredLeftUnasked(fields, asked3, storeFills = []) {
26265
26265
  const missing = fields.filter(
26266
- (f) => f.required === true && !asked2.includes(f.key) && !storeFills.includes(f.key) && !COMPUTED.has(f.type)
26266
+ (f) => f.required === true && !asked3.includes(f.key) && !storeFills.includes(f.key) && !COMPUTED.has(f.type)
26267
26267
  );
26268
26268
  if (missing.length === 0) return null;
26269
26269
  const said2 = missing.map((f) => {
@@ -26365,7 +26365,7 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, startNew, classN
26365
26365
  const [days, setDays] = useState67(30);
26366
26366
  const [timezone, setTimezone] = useState67(() => ownTimeZone());
26367
26367
  const [windows, setWindows] = useState67(() => draftWindows(null));
26368
- const [asked2, setAsked] = useState67([]);
26368
+ const [asked3, setAsked] = useState67([]);
26369
26369
  const [confirmation, setConfirmation] = useState67("");
26370
26370
  const [offer, setOffer] = useState67(null);
26371
26371
  const [formId, setFormId] = useState67(bookingId ?? null);
@@ -26375,7 +26375,7 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, startNew, classN
26375
26375
  () => askableFields(fields.data ?? [], STORE_ANSWERS_THESE),
26376
26376
  [fields.data]
26377
26377
  );
26378
- const unfillable = requiredLeftUnasked(fields.data ?? [], asked2, STORE_ANSWERS_THESE);
26378
+ const unfillable = requiredLeftUnasked(fields.data ?? [], asked3, STORE_ANSWERS_THESE);
26379
26379
  const leftOut = useMemo38(
26380
26380
  () => whyNotAskable(fields.data ?? [], STORE_ANSWERS_THESE),
26381
26381
  [fields.data]
@@ -26443,7 +26443,7 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, startNew, classN
26443
26443
  useEffect56(() => {
26444
26444
  if (startedAsking.current || !loaded || existing || formId || !fields.data) return;
26445
26445
  startedAsking.current = true;
26446
- if (asked2.length > 0) return;
26446
+ if (asked3.length > 0) return;
26447
26447
  const keys = askable.filter((f) => f.required || isWhoField(f)).map((f) => f.key);
26448
26448
  const first = askable[0]?.key;
26449
26449
  setAsked(keys.length > 0 ? keys : first ? [first] : []);
@@ -26482,7 +26482,7 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, startNew, classN
26482
26482
  table_id: tableId,
26483
26483
  title: title.trim() === "" ? "Book a time" : title.trim(),
26484
26484
  // The Fields a visitor is asked for, in the order this screen shows them.
26485
- questions: asked2.map((key) => ({ field: key })),
26485
+ questions: asked3.map((key) => ({ field: key })),
26486
26486
  availability: availability(),
26487
26487
  presentation: {
26488
26488
  // THE SENTENCE AFTER THE BOOKING. It is the thank-you screen every other
@@ -26648,7 +26648,7 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, startNew, classN
26648
26648
  /* @__PURE__ */ jsx83(
26649
26649
  Checkbox8,
26650
26650
  {
26651
- checked: asked2.includes(f.key),
26651
+ checked: asked3.includes(f.key),
26652
26652
  onCheckedChange: (on) => setAsked((prev) => on ? [...prev, f.key] : prev.filter((k) => k !== f.key))
26653
26653
  }
26654
26654
  ),
@@ -28534,7 +28534,7 @@ function StageRulesSection({ tableId, stage, className }) {
28534
28534
  const fields = useFields12(tableId);
28535
28535
  const [pipeline, setPipeline] = useState73(null);
28536
28536
  const [enforcement, setEnforcement] = useState73(null);
28537
- const [asked2, setAsked] = useState73(false);
28537
+ const [asked3, setAsked] = useState73(false);
28538
28538
  const [error, setError] = useState73(null);
28539
28539
  const [chosen, setChosen] = useState73(stage ?? null);
28540
28540
  const [draft, setDraft] = useState73(null);
@@ -28613,7 +28613,7 @@ function StageRulesSection({ tableId, stage, className }) {
28613
28613
  setPreview(null);
28614
28614
  await load();
28615
28615
  }
28616
- if (!asked2) return /* @__PURE__ */ jsx92(Skeleton9, { className: "h-24 w-full" });
28616
+ if (!asked3) return /* @__PURE__ */ jsx92(Skeleton9, { className: "h-24 w-full" });
28617
28617
  if (error && !pipeline) return /* @__PURE__ */ jsx92(RefusalNotice, { error });
28618
28618
  if (!pipeline?.is_pipeline) {
28619
28619
  return /* @__PURE__ */ jsxs83("div", { className: cn47("flex min-w-0 flex-col gap-2 text-xs", className), children: [
@@ -28803,20 +28803,20 @@ function tableNameProblem(typed2) {
28803
28803
  }
28804
28804
  function useRenameFromMenu() {
28805
28805
  const [open, setOpen] = useState74(false);
28806
- const asked2 = useRef38(false);
28807
- const ask = useCallback34(() => {
28808
- asked2.current = true;
28806
+ const asked3 = useRef38(false);
28807
+ const ask2 = useCallback34(() => {
28808
+ asked3.current = true;
28809
28809
  window.setTimeout(() => setOpen(true), 0);
28810
- window.setTimeout(() => asked2.current = false, 2e3);
28810
+ window.setTimeout(() => asked3.current = false, 2e3);
28811
28811
  }, []);
28812
28812
  const menuContentProps = {
28813
28813
  onCloseAutoFocus: (event) => {
28814
- if (!asked2.current) return;
28815
- asked2.current = false;
28814
+ if (!asked3.current) return;
28815
+ asked3.current = false;
28816
28816
  event.preventDefault();
28817
28817
  }
28818
28818
  };
28819
- return { open, setOpen, ask, menuContentProps };
28819
+ return { open, setOpen, ask: ask2, menuContentProps };
28820
28820
  }
28821
28821
  function TableRenameDialog({
28822
28822
  tableId,
@@ -29625,10 +29625,10 @@ function TableSettingsPanel({
29625
29625
  const archiveAskedSeen = useRef39(0);
29626
29626
  const panelReady = Boolean(table.data && fields.data && rights.structure);
29627
29627
  useEffect67(() => {
29628
- const ask = askToArchiveRef.current;
29629
- if (!panelReady || !ask || archiveAsked <= archiveAskedSeen.current) return;
29628
+ const ask2 = askToArchiveRef.current;
29629
+ if (!panelReady || !ask2 || archiveAsked <= archiveAskedSeen.current) return;
29630
29630
  archiveAskedSeen.current = archiveAsked;
29631
- void ask();
29631
+ void ask2();
29632
29632
  }, [archiveAsked, panelReady]);
29633
29633
  const [editing, setEditing] = useState80(null);
29634
29634
  const [askingToDelete, setAskingToDelete] = useState80(false);
@@ -30089,8 +30089,8 @@ function ShareControl({
30089
30089
  useEffect69(() => {
30090
30090
  if (initiallyOpen) setOpen(true);
30091
30091
  }, [initiallyOpen]);
30092
- const asked2 = useRecordRights(may === void 0 ? subjectId : null);
30093
- const mayShare = may ?? asked2.share;
30092
+ const asked3 = useRecordRights(may === void 0 ? subjectId : null);
30093
+ const mayShare = may ?? asked3.share;
30094
30094
  if (!host.share) return null;
30095
30095
  if (!mayShare) return whyNot ? /* @__PURE__ */ jsx102(ShareForSomebodyElse, { kind, whyNot, size, variant, className }) : null;
30096
30096
  return /* @__PURE__ */ jsxs93(Fragment37, { children: [
@@ -30578,7 +30578,7 @@ var LOOK_WORDS = {
30578
30578
  };
30579
30579
 
30580
30580
  // src/ViewSwitcher.tsx
30581
- import { useEffect as useEffect83, useMemo as useMemo58, useState as useState97 } from "react";
30581
+ import { useEffect as useEffect84, useMemo as useMemo58, useState as useState98 } from "react";
30582
30582
  import { mayDrag as mayDrag4, useFields as useFields18, useRecordPage as useRecordPage2, useRecordsClient as useRecordsClient66, useTable as useTable18 } from "@ai-matrx/records/react";
30583
30583
  import { isButtonField as isButtonField5, newerKindOf as newerKindOf7, stableFilterKey as stableFilterKey4 } from "@ai-matrx/records";
30584
30584
  import { Button as Button70, Select as Select17, SelectContent as SelectContent17, SelectItem as SelectItem17, SelectTrigger as SelectTrigger17, SelectValue as SelectValue17, cn as cn61 } from "@ai-matrx/design-system";
@@ -31210,14 +31210,14 @@ function PipelineBoard({
31210
31210
  setOver(null);
31211
31211
  setDragging(null);
31212
31212
  setPending({ kind: "asking", recordId, to });
31213
- const asked2 = await client.pipelineTransitionRefusal({ record_id: recordId, to });
31213
+ const asked3 = await client.pipelineTransitionRefusal({ record_id: recordId, to });
31214
31214
  if (!alive.current) return;
31215
- if (!asked2.ok) {
31216
- setPending({ kind: "clash", recordId, to, error: asked2.error });
31215
+ if (!asked3.ok) {
31216
+ setPending({ kind: "clash", recordId, to, error: asked3.error });
31217
31217
  onMoved?.();
31218
31218
  return;
31219
31219
  }
31220
- const verdict = asked2.data;
31220
+ const verdict = asked3.data;
31221
31221
  if (!verdict.allowed) {
31222
31222
  setPending(
31223
31223
  verdict.outcome === "needs_approval" ? { kind: "approval", recordId, to, verdict } : (verdict.missing ?? []).length > 0 ? { kind: "needs", recordId, to, verdict } : { kind: "refused", recordId, to, verdict }
@@ -31829,11 +31829,45 @@ function CardFieldsInline({ row, fields }) {
31829
31829
  }
31830
31830
 
31831
31831
  // src/CalendarView.tsx
31832
- import { useEffect as useEffect75, useMemo as useMemo52, useRef as useRef44, useState as useState89 } from "react";
31832
+ import { useEffect as useEffect76, useMemo as useMemo52, useRef as useRef44, useState as useState90 } from "react";
31833
31833
  import { mayDrag as mayDrag2 } from "@ai-matrx/records/react";
31834
31834
  import { Button as Button67, Select as Select13, SelectContent as SelectContent13, SelectItem as SelectItem13, SelectTrigger as SelectTrigger13, SelectValue as SelectValue13, cn as cn56 } from "@ai-matrx/design-system";
31835
31835
  import { CHOICE_CHIP_CLASS as CHOICE_CHIP_CLASS3 } from "@ai-matrx/design-system/data-table";
31836
31836
 
31837
+ // src/weekStart.ts
31838
+ import { useEffect as useEffect75, useState as useState89 } from "react";
31839
+ import { useOptionalRecordsClient as useOptionalRecordsClient13 } from "@ai-matrx/records/react";
31840
+ var DAYS2 = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
31841
+ function weekStartIndex(word) {
31842
+ const at = DAYS2.indexOf(String(word ?? "").trim().toLowerCase());
31843
+ return at < 0 ? 1 : at;
31844
+ }
31845
+ function daysSinceWeekStart(weekday, first) {
31846
+ return (weekday - first + 7) % 7;
31847
+ }
31848
+ var asked2 = /* @__PURE__ */ new WeakMap();
31849
+ function ask(client) {
31850
+ let p = asked2.get(client);
31851
+ if (!p) {
31852
+ p = client.aggCalendar().then((r) => r.ok ? weekStartIndex(r.data.week_start) : 1);
31853
+ asked2.set(client, p);
31854
+ }
31855
+ return p;
31856
+ }
31857
+ function useReaderWeekStart() {
31858
+ const client = useOptionalRecordsClient13();
31859
+ const [first, setFirst] = useState89(1);
31860
+ useEffect75(() => {
31861
+ if (!client) return;
31862
+ let live = true;
31863
+ void ask(client).then((n) => live && setFirst(n));
31864
+ return () => {
31865
+ live = false;
31866
+ };
31867
+ }, [client]);
31868
+ return first;
31869
+ }
31870
+
31837
31871
  // src/rowColorBy.tsx
31838
31872
  import { useMemo as useMemo51 } from "react";
31839
31873
  import { EMPTY_TABLE_STYLE, resolveRowColor as resolveRowColor2 } from "@ai-matrx/design-system/data-table";
@@ -32038,8 +32072,8 @@ function addDays2(key, n) {
32038
32072
  function daysBetween2(from, to) {
32039
32073
  return Math.round((dayDate(to).getTime() - dayDate(from).getTime()) / 864e5);
32040
32074
  }
32041
- function startOfWeek(key) {
32042
- return addDays2(key, -dayDate(key).getDay());
32075
+ function startOfWeek(key, first) {
32076
+ return addDays2(key, -daysSinceWeekStart(dayDate(key).getDay(), first));
32043
32077
  }
32044
32078
  function instant(value) {
32045
32079
  if (!hasTimePart(value)) return null;
@@ -32109,8 +32143,8 @@ function packOverlaps(blocks) {
32109
32143
  function useNarrow() {
32110
32144
  const query = "(max-width: 639px)";
32111
32145
  const read = () => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia(query).matches;
32112
- const [narrow, setNarrow] = useState89(read);
32113
- useEffect75(() => {
32146
+ const [narrow, setNarrow] = useState90(read);
32147
+ useEffect76(() => {
32114
32148
  if (typeof window === "undefined" || typeof window.matchMedia !== "function") return;
32115
32149
  const list = window.matchMedia(query);
32116
32150
  const on = () => setNarrow(list.matches);
@@ -32152,12 +32186,13 @@ function CalendarView({
32152
32186
  initialMode,
32153
32187
  className
32154
32188
  }) {
32189
+ const firstDay = useReaderWeekStart();
32155
32190
  const moves = useRecordMoves({ tableId, rows, onMoved });
32156
32191
  const narrow = useNarrow();
32157
- const [mode, setMode] = useState89(initialMode ?? (narrow ? "list" : "month"));
32192
+ const [mode, setMode] = useState90(initialMode ?? (narrow ? "list" : "month"));
32158
32193
  usePersonTimeZone();
32159
- const [anchor, setAnchor] = useState89(initialDate ?? dayKey(personWallNow()));
32160
- const [openDay, setOpenDay] = useState89(null);
32194
+ const [anchor, setAnchor] = useState90(initialDate ?? dayKey(personWallNow()));
32195
+ const [openDay, setOpenDay] = useState90(null);
32161
32196
  const titleFields = useMemo52(() => titleField ? [titleField] : [], [titleField]);
32162
32197
  const labels = useRecordLabels(titleFields);
32163
32198
  const all = fields ?? [];
@@ -32167,7 +32202,7 @@ function CalendarView({
32167
32202
  () => eligibleFieldFor("date", all, null, { far: farFields }).eligible.filter((f) => f.key !== dateField.key),
32168
32203
  [all, farFields, dateField.key]
32169
32204
  );
32170
- const [endPick, setEndPick] = useState89(void 0);
32205
+ const [endPick, setEndPick] = useState90(void 0);
32171
32206
  const endChosen = endPick !== void 0 ? endPick : endKey ?? void 0;
32172
32207
  const endUnusual = endChosen && !otherDates.some((f) => f.key === endChosen) ? all.find((f) => f.key === endChosen && f.key !== dateField.key) : void 0;
32173
32208
  const endField = endChosen === void 0 ? otherDates.length === 1 ? otherDates[0] : void 0 : otherDates.find((f) => f.key === endChosen) ?? endUnusual ?? void 0;
@@ -32176,13 +32211,13 @@ function CalendarView({
32176
32211
  const canMove = (row) => mayDrag2(row.level) && !startWorkedOut;
32177
32212
  const creates = canCreate && !startWorkedOut;
32178
32213
  const choiceFields = useMemo52(() => eligibleFieldFor("choice", all).eligible.filter(isChoiceField), [all]);
32179
- const [colorPick, setColorPick] = useState89(void 0);
32214
+ const [colorPick, setColorPick] = useState90(void 0);
32180
32215
  const colorKey = colorPick !== void 0 ? colorPick : style?.colorBy?.field ?? choiceFields[0]?.key ?? null;
32181
32216
  const colorOf = useRowColorBy(all, colorKey, style);
32182
- const [placedOver, setPlacedOver] = useState89(() => /* @__PURE__ */ new Map());
32183
- useEffect75(() => setPlacedOver(/* @__PURE__ */ new Map()), [rows]);
32217
+ const [placedOver, setPlacedOver] = useState90(() => /* @__PURE__ */ new Map());
32218
+ useEffect76(() => setPlacedOver(/* @__PURE__ */ new Map()), [rows]);
32184
32219
  const undoneCount = moves.undo.depth.forward;
32185
- useEffect75(() => {
32220
+ useEffect76(() => {
32186
32221
  if (undoneCount > 0) setPlacedOver(/* @__PURE__ */ new Map());
32187
32222
  }, [undoneCount]);
32188
32223
  const startOf = (row) => placedOver.has(row.id) ? placedOver.get(row.id).start : (row.document ?? {})[dateField.key];
@@ -32192,26 +32227,26 @@ function CalendarView({
32192
32227
  const without = [];
32193
32228
  for (const row of rows) {
32194
32229
  const start = startOf(row);
32195
- const firstDay = calendarDayOf(start);
32196
- if (!firstDay) {
32230
+ const firstDay2 = calendarDayOf(start);
32231
+ if (!firstDay2) {
32197
32232
  without.push(row);
32198
32233
  continue;
32199
32234
  }
32200
32235
  const end = endOf(row);
32201
32236
  const endDay = calendarDayOf(end);
32202
- const lastDay = endDay && endDay > firstDay ? addDays2(firstDay, Math.min(daysBetween2(firstDay, endDay), MAX_SPAN_DAYS)) : firstDay;
32237
+ const lastDay = endDay && endDay > firstDay2 ? addDays2(firstDay2, Math.min(daysBetween2(firstDay2, endDay), MAX_SPAN_DAYS)) : firstDay2;
32203
32238
  const at = instant(start);
32204
32239
  const endAt = instant(end);
32205
32240
  const minutes = at && endAt && endAt > at ? Math.round((endAt.getTime() - at.getTime()) / 6e4) : defaultMinutes;
32206
- out.push({ row, start, end, firstDay, lastDay, at, minutes });
32241
+ out.push({ row, start, end, firstDay: firstDay2, lastDay, at, minutes });
32207
32242
  }
32208
32243
  return { placed: out, undated: without };
32209
32244
  }, [rows, dateField.key, endField?.key, placedOver, defaultMinutes]);
32210
32245
  const titleOf = (row) => cardWords(row, titleField, labels).text;
32211
32246
  const rowById = (id) => rows.find((r) => r.id === id);
32212
32247
  const frame = useRef44(null);
32213
- const [focusOn, setFocusOn] = useState89(null);
32214
- useEffect75(() => {
32248
+ const [focusOn, setFocusOn] = useState90(null);
32249
+ useEffect76(() => {
32215
32250
  if (!focusOn) return;
32216
32251
  const button = frame.current?.querySelector(`[data-calendar-card="${focusOn}"] button`);
32217
32252
  button?.focus({ preventScroll: true });
@@ -32259,9 +32294,9 @@ function CalendarView({
32259
32294
  if (made) onOpenRecord?.(made);
32260
32295
  };
32261
32296
  const grabOffset = useRef44(0);
32262
- const [resizing, setResizing] = useState89(null);
32263
- const [ghost, setGhost] = useState89(null);
32264
- useEffect75(() => {
32297
+ const [resizing, setResizing] = useState90(null);
32298
+ const [ghost, setGhost] = useState90(null);
32299
+ useEffect76(() => {
32265
32300
  if (!ghost || typeof document === "undefined") return;
32266
32301
  const clear = () => setGhost(null);
32267
32302
  document.addEventListener("dragend", clear);
@@ -32400,7 +32435,7 @@ function CalendarView({
32400
32435
  window.addEventListener("pointermove", onMove);
32401
32436
  window.addEventListener("pointerup", onUp);
32402
32437
  };
32403
- const [selecting, setSelecting] = useState89(null);
32438
+ const [selecting, setSelecting] = useState90(null);
32404
32439
  const beginSelect = (day2) => (e) => {
32405
32440
  if (!creates || e.button !== 0) return;
32406
32441
  const slot = e.target.closest?.("[data-calendar-slot]");
@@ -32470,7 +32505,7 @@ function CalendarView({
32470
32505
  ] }, key);
32471
32506
  const today = dayKey(personWallNow());
32472
32507
  const anchorDate = dayDate(anchor);
32473
- const heading = mode === "week" ? weekHeading(startOfWeek(anchor)) : mode === "day" ? anchorDate.toLocaleDateString(void 0, { weekday: "long", month: "long", day: "numeric", year: "numeric" }) : anchorDate.toLocaleDateString(void 0, { month: "long", year: "numeric" });
32508
+ const heading = mode === "week" ? weekHeading(startOfWeek(anchor, firstDay)) : mode === "day" ? anchorDate.toLocaleDateString(void 0, { weekday: "long", month: "long", day: "numeric", year: "numeric" }) : anchorDate.toLocaleDateString(void 0, { month: "long", year: "numeric" });
32474
32509
  const step2 = (dir) => {
32475
32510
  if (mode === "week") setAnchor(addDays2(anchor, dir * 7));
32476
32511
  else if (mode === "day") setAnchor(addDays2(anchor, dir));
@@ -32521,7 +32556,7 @@ function CalendarView({
32521
32556
  ) : null;
32522
32557
  let body;
32523
32558
  if (mode === "month") {
32524
- const first = startOfWeek(dayKey(new Date(anchorDate.getFullYear(), anchorDate.getMonth(), 1)));
32559
+ const first = startOfWeek(dayKey(new Date(anchorDate.getFullYear(), anchorDate.getMonth(), 1)), firstDay);
32525
32560
  const weeks = Array.from({ length: 6 }, (_, w) => addDays2(first, w * 7));
32526
32561
  body = /* @__PURE__ */ jsx110("div", { className: "min-w-0 flex-1 overflow-x-auto", children: /* @__PURE__ */ jsxs101("div", { className: "min-w-[560px] border-l border-t", role: "grid", "aria-label": heading, "data-calendar-month": "", children: [
32527
32562
  /* @__PURE__ */ jsx110("div", { className: "grid grid-cols-7", role: "row", children: Array.from({ length: 7 }, (_, i) => addDays2(first, i)).map((d) => /* @__PURE__ */ jsx110("div", { role: "columnheader", className: "border-b border-r px-1 py-0.5 text-center text-xs text-muted-foreground", children: dayDate(d).toLocaleDateString(void 0, { weekday: "short" }) }, `h${d}`)) }),
@@ -32553,7 +32588,7 @@ function CalendarView({
32553
32588
  ))
32554
32589
  ] }) });
32555
32590
  } else if (mode === "week" || mode === "day") {
32556
- const first = mode === "day" ? anchor : startOfWeek(anchor);
32591
+ const first = mode === "day" ? anchor : startOfWeek(anchor, firstDay);
32557
32592
  const days = Array.from({ length: mode === "day" ? 1 : 7 }, (_, i) => addDays2(first, i));
32558
32593
  const allDay = (d) => placed.filter((p) => (!p.at || p.lastDay > p.firstDay) && p.firstDay <= d && p.lastDay >= d).sort(byTime);
32559
32594
  const timed = (d) => packOverlaps(
@@ -32809,12 +32844,12 @@ function WeekHours({
32809
32844
  overlay
32810
32845
  }) {
32811
32846
  const frame = useRef44(null);
32812
- useEffect75(() => {
32847
+ useEffect76(() => {
32813
32848
  if (frame.current) frame.current.scrollTop = 7 * HOUR_PX;
32814
32849
  }, []);
32815
32850
  usePersonTimeZone();
32816
- const [now, setNow] = useState89(() => personWallNow());
32817
- useEffect75(() => {
32851
+ const [now, setNow] = useState90(() => personWallNow());
32852
+ useEffect76(() => {
32818
32853
  const timer = setInterval(() => setNow(personWallNow()), 6e4);
32819
32854
  return () => clearInterval(timer);
32820
32855
  }, []);
@@ -32856,11 +32891,11 @@ function weekHeading(first) {
32856
32891
  }
32857
32892
 
32858
32893
  // src/TimelineView.tsx
32859
- import { useEffect as useEffect76, useMemo as useMemo53, useRef as useRef45, useState as useState90 } from "react";
32894
+ import { useEffect as useEffect77, useMemo as useMemo53, useRef as useRef45, useState as useState91 } from "react";
32860
32895
  import { mayDrag as mayDrag3 } from "@ai-matrx/records/react";
32861
32896
  import { Button as Button68, Select as Select14, SelectContent as SelectContent14, SelectItem as SelectItem14, SelectTrigger as SelectTrigger14, SelectValue as SelectValue14, cn as cn57 } from "@ai-matrx/design-system";
32862
32897
  import { CHOICE_CHIP_CLASS as CHOICE_CHIP_CLASS4 } from "@ai-matrx/design-system/data-table";
32863
- import { useOptionalRecordsClient as useOptionalRecordsClient13 } from "@ai-matrx/records/react";
32898
+ import { useOptionalRecordsClient as useOptionalRecordsClient14 } from "@ai-matrx/records/react";
32864
32899
  import { Fragment as Fragment44, jsx as jsx111, jsxs as jsxs102 } from "react/jsx-runtime";
32865
32900
  var TIMELINE_ZOOMS = ["day", "week", "month", "quarter"];
32866
32901
  var ZOOM_LABEL = { day: "Day", week: "Week", month: "Month", quarter: "Quarter" };
@@ -32933,13 +32968,13 @@ function packRows(bars) {
32933
32968
  return { ...bar, row };
32934
32969
  });
32935
32970
  }
32936
- function windowStart(anchor, zoom) {
32971
+ function windowStart(anchor, zoom, firstDay) {
32937
32972
  const from = dayAt(addDays(anchor, -WINDOW[zoom].lead));
32938
- if (zoom === "day" || zoom === "week") from.setDate(from.getDate() - from.getDay());
32973
+ if (zoom === "day" || zoom === "week") from.setDate(from.getDate() - daysSinceWeekStart(from.getDay(), firstDay));
32939
32974
  else from.setDate(1);
32940
32975
  return dayKeyOf(from);
32941
32976
  }
32942
- function scaleOf(start, days, zoom) {
32977
+ function scaleOf(start, days, zoom, firstDay) {
32943
32978
  const group = (key, label) => {
32944
32979
  const out = [];
32945
32980
  let current = "";
@@ -32962,7 +32997,7 @@ function scaleOf(start, days, zoom) {
32962
32997
  }
32963
32998
  if (zoom === "week") return { top: group(month, monthLong), bottom: group(dayKeyOf, (at) => String(at.getDate())) };
32964
32999
  if (zoom === "month") {
32965
- const weekOf = (at) => dayKeyOf(new Date(at.getFullYear(), at.getMonth(), at.getDate() - at.getDay()));
33000
+ const weekOf = (at) => dayKeyOf(new Date(at.getFullYear(), at.getMonth(), at.getDate() - daysSinceWeekStart(at.getDay(), firstDay)));
32966
33001
  return { top: group(month, monthLong), bottom: group(weekOf, (at) => at.toLocaleDateString(void 0, { month: "short", day: "numeric" })) };
32967
33002
  }
32968
33003
  return {
@@ -32998,14 +33033,14 @@ function TimelineView({
32998
33033
  className
32999
33034
  }) {
33000
33035
  const moves = useRecordMoves({ tableId, rows, onMoved });
33001
- const [zoom, setZoom] = useState90(initialZoom);
33036
+ const [zoom, setZoom] = useState91(initialZoom);
33002
33037
  usePersonTimeZone();
33003
33038
  const today = dayKeyOf(personWallNow());
33004
- const [anchor, setAnchor] = useState90(initialDate ?? today);
33039
+ const [anchor, setAnchor] = useState91(initialDate ?? today);
33005
33040
  const dates = useMemo53(() => offerableFields(fields, "date", { far: farFields }), [fields, farFields]);
33006
33041
  const has = (list, key) => key && list.some((f) => f.key === key) ? key : null;
33007
- const [picked, setPicked] = useState90({});
33008
- useEffect76(() => setPicked({}), [startKey, endKey, groupKey, colorKey]);
33042
+ const [picked, setPicked] = useState91({});
33043
+ useEffect77(() => setPicked({}), [startKey, endKey, groupKey, colorKey]);
33009
33044
  const named = (key) => key && fields.some((f) => f.key === key) ? key : null;
33010
33045
  const startChosen = "startKey" in picked ? picked.startKey ?? null : has(dates, startKey) ?? named(startKey) ?? onlyCandidate(dates);
33011
33046
  const endCandidates = useMemo53(() => dates.filter((f) => f.key !== startChosen), [dates, startChosen]);
@@ -33030,9 +33065,9 @@ function TimelineView({
33030
33065
  const canMove = (row) => mayDrag3(row.level) && !startWorkedOut;
33031
33066
  const colorOf = useRowColorBy(fields, colorChosen, style);
33032
33067
  const depField = useMemo53(() => dependencyFieldOf(fields, tableId), [fields, tableId]);
33033
- const knobClient = useOptionalRecordsClient13();
33034
- const [shiftDependents, setShiftDependents] = useState90(true);
33035
- useEffect76(() => {
33068
+ const knobClient = useOptionalRecordsClient14();
33069
+ const [shiftDependents, setShiftDependents] = useState91(true);
33070
+ useEffect77(() => {
33036
33071
  if (!depField || !knobClient) return;
33037
33072
  let live = true;
33038
33073
  void knobClient.timelineDependencyShift().then((got) => {
@@ -33047,15 +33082,15 @@ function TimelineView({
33047
33082
  const labels = useRecordLabels(labelFields);
33048
33083
  const titleOf = (row) => cardWords(row, titleField, labels).text;
33049
33084
  const groupOptions = useChoiceOptions(fields, groupField && isChoiceField(groupField) ? [groupField.key] : []).get(groupField?.key ?? "");
33050
- const [placedOver, setPlacedOver] = useState90(() => /* @__PURE__ */ new Map());
33051
- useEffect76(() => setPlacedOver(/* @__PURE__ */ new Map()), [rows]);
33085
+ const [placedOver, setPlacedOver] = useState91(() => /* @__PURE__ */ new Map());
33086
+ useEffect77(() => setPlacedOver(/* @__PURE__ */ new Map()), [rows]);
33052
33087
  const undoneCount = moves.undo.depth.forward;
33053
- useEffect76(() => {
33088
+ useEffect77(() => {
33054
33089
  if (undoneCount > 0) setPlacedOver(/* @__PURE__ */ new Map());
33055
33090
  }, [undoneCount]);
33056
33091
  const startOf = (row) => placedOver.has(row.id) ? placedOver.get(row.id).start : startField ? (row.document ?? {})[startField.key] : null;
33057
33092
  const endOf = (row) => !endField ? null : placedOver.has(row.id) ? placedOver.get(row.id).end : (row.document ?? {})[endField.key];
33058
- const [dragging, setDragging] = useState90(null);
33093
+ const [dragging, setDragging] = useState91(null);
33059
33094
  const { placed, unscheduled } = useMemo53(() => {
33060
33095
  const out = [];
33061
33096
  const without = [];
@@ -33194,14 +33229,15 @@ function TimelineView({
33194
33229
  void commit(row, patch, `${titleOf(row)} scheduled for ${calendarDayLabel(day2)}`);
33195
33230
  };
33196
33231
  const px = PX_PER_DAY[zoom];
33197
- const from = windowStart(anchor, zoom);
33232
+ const firstDay = useReaderWeekStart();
33233
+ const from = windowStart(anchor, zoom, firstDay);
33198
33234
  const days = WINDOW[zoom].days;
33199
33235
  const width = days * px;
33200
- const scale = useMemo53(() => scaleOf(from, days, zoom), [from, days, zoom]);
33236
+ const scale = useMemo53(() => scaleOf(from, days, zoom, firstDay), [from, days, zoom, firstDay]);
33201
33237
  const xOf = (day2) => daysBetween(from, day2) * px;
33202
33238
  const scroller = useRef45(null);
33203
33239
  const grouped = Boolean(groupField);
33204
- const [scrollX, setScrollX] = useState90(0);
33240
+ const [scrollX, setScrollX] = useState91(0);
33205
33241
  const frame = useRef45(null);
33206
33242
  const onScroll = () => {
33207
33243
  if (frame.current !== null) return;
@@ -33210,7 +33246,7 @@ function TimelineView({
33210
33246
  setScrollX(scroller.current?.scrollLeft ?? 0);
33211
33247
  });
33212
33248
  };
33213
- useEffect76(() => {
33249
+ useEffect77(() => {
33214
33250
  const el = scroller.current;
33215
33251
  if (!el) return;
33216
33252
  const label = el.querySelector("[data-timeline-label]")?.offsetWidth ?? 0;
@@ -33636,7 +33672,7 @@ function TimelineView({
33636
33672
  }
33637
33673
 
33638
33674
  // src/ViewNeeds.tsx
33639
- import { useEffect as useEffect77, useState as useState91 } from "react";
33675
+ import { useEffect as useEffect78, useState as useState92 } from "react";
33640
33676
  import { useFieldMutation as useFieldMutation6, useRecordsClient as useRecordsClient64, useTable as useTable17 } from "@ai-matrx/records/react";
33641
33677
  import { BasicInput as BasicInput20, Button as Button69, Label as Label18 } from "@ai-matrx/design-system";
33642
33678
  import { jsx as jsx112, jsxs as jsxs103 } from "react/jsx-runtime";
@@ -33657,7 +33693,7 @@ function useAskedColumnLands(layout, tableId, fields, chosen, offerable, onMade)
33657
33693
  const wanted = askedFor.get(askKey(tableId, layout));
33658
33694
  const landed = wanted && !chosen ? offerable(fields).find((f) => fieldName(f).trim().toLowerCase() === wanted.trim().toLowerCase()) : void 0;
33659
33695
  const key = landed?.key ?? null;
33660
- useEffect77(() => {
33696
+ useEffect78(() => {
33661
33697
  if (!key) return;
33662
33698
  askedFor.delete(askKey(tableId, layout));
33663
33699
  onMade(key);
@@ -33672,10 +33708,10 @@ function ViewNeeds({ layout, tableId, fields, onMade, className }) {
33672
33708
  const mutation = useFieldMutation6();
33673
33709
  const client = useRecordsClient64();
33674
33710
  const taken = fields.map((f) => fieldName(f));
33675
- const [label, setLabel] = useState91(() => freeColumnName(need?.starter.label ?? "", taken));
33676
- const [options, setOptions] = useState91(() => [...need?.starter.options ?? []]);
33677
- const [refused, setRefused] = useState91(null);
33678
- const [pendingId, setPendingId] = useState91(null);
33711
+ const [label, setLabel] = useState92(() => freeColumnName(need?.starter.label ?? "", taken));
33712
+ const [options, setOptions] = useState92(() => [...need?.starter.options ?? []]);
33713
+ const [refused, setRefused] = useState92(null);
33714
+ const [pendingId, setPendingId] = useState92(null);
33679
33715
  if (!need) return null;
33680
33716
  const name = label.trim() === "" ? need.starter.label : label.trim();
33681
33717
  const choices = options.map((o) => o.trim()).filter((o) => o !== "");
@@ -33769,8 +33805,8 @@ function ViewNeeds({ layout, tableId, fields, onMade, className }) {
33769
33805
  }
33770
33806
 
33771
33807
  // src/GalleryCover.tsx
33772
- import { useEffect as useEffect78, useState as useState92 } from "react";
33773
- import { useOptionalRecordsClient as useOptionalRecordsClient14 } from "@ai-matrx/records/react";
33808
+ import { useEffect as useEffect79, useState as useState93 } from "react";
33809
+ import { useOptionalRecordsClient as useOptionalRecordsClient15 } from "@ai-matrx/records/react";
33774
33810
  import { Fragment as Fragment45, jsx as jsx113 } from "react/jsx-runtime";
33775
33811
  function isImageAddress(value) {
33776
33812
  return typeof value === "string" && /^(https?:\/\/|\/|data:image\/)/i.test(value.trim());
@@ -33788,10 +33824,10 @@ function GalleryCover({ field: field2, value }) {
33788
33824
  return null;
33789
33825
  }
33790
33826
  function FileCover({ recordId }) {
33791
- const client = useOptionalRecordsClient14();
33827
+ const client = useOptionalRecordsClient15();
33792
33828
  const host = useRecordsUi();
33793
- const [read, setRead] = useState92(null);
33794
- useEffect78(() => {
33829
+ const [read, setRead] = useState93(null);
33830
+ useEffect79(() => {
33795
33831
  let cancelled = false;
33796
33832
  if (!client) {
33797
33833
  setRead({ fileId: recordId, name: "" });
@@ -34189,7 +34225,7 @@ function ListRow({
34189
34225
  }
34190
34226
 
34191
34227
  // src/ChartLayout.tsx
34192
- import { useEffect as useEffect82, useMemo as useMemo57, useState as useState96 } from "react";
34228
+ import { useEffect as useEffect83, useMemo as useMemo57, useState as useState97 } from "react";
34193
34229
  import { useRecordsClient as useRecordsClient65 } from "@ai-matrx/records/react";
34194
34230
  import { measureKey as measureKey4 } from "@ai-matrx/records";
34195
34231
  import { Select as Select16, SelectContent as SelectContent16, SelectItem as SelectItem16, SelectTrigger as SelectTrigger16, SelectValue as SelectValue16 } from "@ai-matrx/design-system";
@@ -34219,8 +34255,8 @@ import { cn as cn60 } from "@ai-matrx/design-system";
34219
34255
  import { formatCount as formatCount5 } from "@ai-matrx/kit/format";
34220
34256
 
34221
34257
  // src/linkWords.ts
34222
- import { useEffect as useEffect79, useMemo as useMemo55, useState as useState93 } from "react";
34223
- import { useOptionalRecordsClient as useOptionalRecordsClient15 } from "@ai-matrx/records/react";
34258
+ import { useEffect as useEffect80, useMemo as useMemo55, useState as useState94 } from "react";
34259
+ import { useOptionalRecordsClient as useOptionalRecordsClient16 } from "@ai-matrx/records/react";
34224
34260
 
34225
34261
  // src/charts.ts
34226
34262
  var CHART_KIND_LABEL = {
@@ -34430,14 +34466,14 @@ function bucketWindow2(groupKey, value) {
34430
34466
 
34431
34467
  // src/linkWords.ts
34432
34468
  function useLinkGroupNamer(block, tableId) {
34433
- const client = useOptionalRecordsClient15();
34469
+ const client = useOptionalRecordsClient16();
34434
34470
  const groupBy = block.kind === "stuck" ? [] : block.group_by ?? [];
34435
34471
  const rows = block.kind === "stuck" ? [] : block.rows ?? [];
34436
- const ask = JSON.stringify([tableId, groupBy, rows.map((r) => r.groups ?? null)]);
34437
- const [named, setNamed] = useState93({});
34438
- const [choices, setChoices] = useState93([]);
34472
+ const ask2 = JSON.stringify([tableId, groupBy, rows.map((r) => r.groups ?? null)]);
34473
+ const [named, setNamed] = useState94({});
34474
+ const [choices, setChoices] = useState94([]);
34439
34475
  const labels = useRecordLabels(choices);
34440
- useEffect79(() => {
34476
+ useEffect80(() => {
34441
34477
  if (!client || groupBy.length === 0 || rows.length === 0) return;
34442
34478
  let cancelled = false;
34443
34479
  void (async () => {
@@ -34464,7 +34500,7 @@ function useLinkGroupNamer(block, tableId) {
34464
34500
  return () => {
34465
34501
  cancelled = true;
34466
34502
  };
34467
- }, [client, ask]);
34503
+ }, [client, ask2]);
34468
34504
  return useMemo55(() => {
34469
34505
  if (Object.keys(named).length === 0 && choices.length === 0) return void 0;
34470
34506
  return (key, value) => {
@@ -34480,8 +34516,8 @@ function useLinkGroupNamer(block, tableId) {
34480
34516
  }
34481
34517
 
34482
34518
  // src/measureWords.ts
34483
- import { useEffect as useEffect80, useState as useState94 } from "react";
34484
- import { useOptionalRecordsClient as useOptionalRecordsClient16 } from "@ai-matrx/records/react";
34519
+ import { useEffect as useEffect81, useState as useState95 } from "react";
34520
+ import { useOptionalRecordsClient as useOptionalRecordsClient17 } from "@ai-matrx/records/react";
34485
34521
  import { humanizeIdentifier as humanizeIdentifier13 } from "@ai-matrx/kit/text-case";
34486
34522
  var OP_WORD = { sum: "Total", avg: "Average", min: "Lowest", max: "Highest" };
34487
34523
  function measureWords(key, fields) {
@@ -34496,10 +34532,10 @@ function measureWords(key, fields) {
34496
34532
  return word ? `${word} ${name.charAt(0).toLowerCase()}${name.slice(1)}` : `${humanizeIdentifier13(op2)} ${name}`;
34497
34533
  }
34498
34534
  function useMeasureWords(key, tableId) {
34499
- const client = useOptionalRecordsClient16();
34500
- const [fields, setFields] = useState94(null);
34535
+ const client = useOptionalRecordsClient17();
34536
+ const [fields, setFields] = useState95(null);
34501
34537
  const needs = key !== "count";
34502
- useEffect80(() => {
34538
+ useEffect81(() => {
34503
34539
  if (!client || !tableId || !needs) return;
34504
34540
  let cancelled = false;
34505
34541
  void client.fields({ table_id: tableId }).then((result) => {
@@ -34514,17 +34550,17 @@ function useMeasureWords(key, tableId) {
34514
34550
 
34515
34551
  // src/chartFrame.tsx
34516
34552
  import {
34517
- useEffect as useEffect81,
34553
+ useEffect as useEffect82,
34518
34554
  useId as useId4,
34519
34555
  useRef as useRef46,
34520
- useState as useState95
34556
+ useState as useState96
34521
34557
  } from "react";
34522
34558
  import { cn as cn59 } from "@ai-matrx/design-system";
34523
34559
  import { jsx as jsx116, jsxs as jsxs106 } from "react/jsx-runtime";
34524
34560
  function useMeasuredWidth(fallback = 480) {
34525
34561
  const ref = useRef46(null);
34526
- const [width, setWidth] = useState95(fallback);
34527
- useEffect81(() => {
34562
+ const [width, setWidth] = useState96(fallback);
34563
+ useEffect82(() => {
34528
34564
  const node = ref.current;
34529
34565
  if (!node) return;
34530
34566
  const apply = () => {
@@ -35139,12 +35175,12 @@ var isChartKind = (v) => v === "bar" || v === "line" || v === "donut";
35139
35175
  var isChartMeasure = (v) => v === "count" || v === "sum" || v === "avg";
35140
35176
  function chartQuestion(view, fields) {
35141
35177
  const kind = isChartKind(view.chartKind) ? view.chartKind : "bar";
35142
- const asked2 = isChartMeasure(view.chartMeasure) ? view.chartMeasure : "count";
35178
+ const asked3 = isChartMeasure(view.chartMeasure) ? view.chartMeasure : "count";
35143
35179
  const group = view.groupField ? fields.find((f) => f.key === view.groupField) : void 0;
35144
35180
  const measureField = view.measure ? fields.find((f) => f.key === view.measure) : void 0;
35145
- const needsField = asked2 !== "count";
35181
+ const needsField = asked3 !== "count";
35146
35182
  const fellBack = needsField && !measureField;
35147
- const measure = needsField && measureField ? { op: asked2, key: measureField.key } : { op: "count" };
35183
+ const measure = needsField && measureField ? { op: asked3, key: measureField.key } : { op: "count" };
35148
35184
  const dated = group ? DATE_TYPES.has(String(group.type)) : false;
35149
35185
  const bucket = group && dated && kind === "line" ? { key: group.key, by: "month" } : null;
35150
35186
  return { kind, groupBy: group && !bucket ? [group.key] : [], bucket, measure, fellBack };
@@ -35152,12 +35188,12 @@ function chartQuestion(view, fields) {
35152
35188
  function ChartLayout({ view, fields, filter, onChange, remembered }) {
35153
35189
  const client = useRecordsClient65();
35154
35190
  const q = useMemo57(() => chartQuestion(view, fields), [view, fields]);
35155
- const [state, setState] = useState96({ block: null, error: null });
35191
+ const [state, setState] = useState97({ block: null, error: null });
35156
35192
  const filterKey = JSON.stringify(filter ?? {});
35157
35193
  const qKey = JSON.stringify(q);
35158
- useEffect82(() => {
35194
+ useEffect83(() => {
35159
35195
  let cancelled = false;
35160
- const asked2 = JSON.parse(filterKey);
35196
+ const asked3 = JSON.parse(filterKey);
35161
35197
  const question = JSON.parse(qKey);
35162
35198
  void client.recordAggregate({
35163
35199
  table_id: view.subject,
@@ -35165,7 +35201,7 @@ function ChartLayout({ view, fields, filter, onChange, remembered }) {
35165
35201
  ...question.bucket ? { bucket: question.bucket } : {},
35166
35202
  measures: [question.measure],
35167
35203
  limit: 200,
35168
- ...Object.keys(asked2).length > 0 ? { filter: asked2 } : {}
35204
+ ...Object.keys(asked3).length > 0 ? { filter: asked3 } : {}
35169
35205
  }).then((answered) => {
35170
35206
  if (cancelled) return;
35171
35207
  if (!answered.ok) {
@@ -35229,9 +35265,9 @@ import { Fragment as Fragment47, jsx as jsx119, jsxs as jsxs109 } from "react/js
35229
35265
  var NO_FIELDS2 = [];
35230
35266
  function useViewRecords(view, pageSize = 200, filter, viewId) {
35231
35267
  const client = useRecordsClient66();
35232
- const [limit, setLimit] = useState97(pageSize);
35268
+ const [limit, setLimit] = useState98(pageSize);
35233
35269
  const questionKey = `${view.subject}|${stableFilterKey4(filter ?? null)}|${JSON.stringify(view.sorts ?? [])}`;
35234
- useEffect83(() => {
35270
+ useEffect84(() => {
35235
35271
  setLimit(pageSize);
35236
35272
  }, [questionKey, pageSize]);
35237
35273
  const storeSort = useMemo58(
@@ -35243,13 +35279,13 @@ function useViewRecords(view, pageSize = 200, filter, viewId) {
35243
35279
  ...filter ? { filter } : {},
35244
35280
  ...storeSort.length > 0 ? { sort: storeSort } : {}
35245
35281
  });
35246
- const [ruled, setRuled] = useState97({
35282
+ const [ruled, setRuled] = useState98({
35247
35283
  rows: [],
35248
35284
  loading: Boolean(view.ruleId),
35249
35285
  error: null
35250
35286
  });
35251
35287
  const ruleId = view.ruleId ?? null;
35252
- useEffect83(() => {
35288
+ useEffect84(() => {
35253
35289
  if (!ruleId) return;
35254
35290
  let cancelled = false;
35255
35291
  setRuled({ rows: [], loading: true, error: null });
@@ -35263,8 +35299,8 @@ function useViewRecords(view, pageSize = 200, filter, viewId) {
35263
35299
  cancelled = true;
35264
35300
  };
35265
35301
  }, [client, ruleId, pageSize]);
35266
- const asked2 = stableFilterKey4(filter ?? null);
35267
- const fromView = asked2 !== "{}" && (asked2 === stableFilterKey4(view.where ?? null) || asked2 === stableFilterKey4(view.filters ?? null));
35302
+ const asked3 = stableFilterKey4(filter ?? null);
35303
+ const fromView = asked3 !== "{}" && (asked3 === stableFilterKey4(view.where ?? null) || asked3 === stableFilterKey4(view.filters ?? null));
35268
35304
  const tableRows = useMemo58(() => table.data?.rows ?? [], [table.data]);
35269
35305
  const manual = view.order === "manual" && Boolean(viewId) && !ruleId;
35270
35306
  const hand = useHandOrderRows({
@@ -35316,7 +35352,7 @@ function useViewRecords(view, pageSize = 200, filter, viewId) {
35316
35352
  // sat over every board and gallery. A view of the whole table says nothing about it; a narrowed
35317
35353
  // one says how, in words a person uses.
35318
35354
  membership: [
35319
- ruleId ? "Showing the records this view's rule picks." : fromView ? "Showing the records this view's filter asks for." : asked2 !== "{}" ? "Showing only the records behind the number you clicked." : "",
35355
+ ruleId ? "Showing the records this view's rule picks." : fromView ? "Showing the records this view's filter asks for." : asked3 !== "{}" ? "Showing only the records behind the number you clicked." : "",
35320
35356
  manual ? HAND_ORDER_NOTE : ""
35321
35357
  ].filter(Boolean).join(" ")
35322
35358
  };
@@ -35363,9 +35399,9 @@ function ViewSwitcher({
35363
35399
  className
35364
35400
  }) {
35365
35401
  const pageSize = pageSizeAsked ?? (embedded ? EMBEDDED_PAGE_SIZE : 200);
35366
- const [layout, setLayout] = useState97(view.layout);
35367
- const [local, setLocal] = useState97({});
35368
- useEffect83(() => {
35402
+ const [layout, setLayout] = useState98(view.layout);
35403
+ const [local, setLocal] = useState98({});
35404
+ useEffect84(() => {
35369
35405
  setLayout(view.layout);
35370
35406
  setLocal({});
35371
35407
  }, [view.layout, view.name, view.subject]);
@@ -35461,8 +35497,8 @@ var UNUSUAL_FIELD_NOTE = "an unusual column to use here";
35461
35497
  function useFarFields(all) {
35462
35498
  const client = useRecordsClient66();
35463
35499
  const targets = lookupTargets(all).sort().join(",");
35464
- const [far, setFar] = useState97(() => /* @__PURE__ */ new Map());
35465
- useEffect83(() => {
35500
+ const [far, setFar] = useState98(() => /* @__PURE__ */ new Map());
35501
+ useEffect84(() => {
35466
35502
  let cancelled = false;
35467
35503
  const ids = targets ? targets.split(",") : [];
35468
35504
  if (ids.length === 0) {
@@ -35497,11 +35533,11 @@ function eligibleFieldFor(want, all, chosenKey, placing) {
35497
35533
  }
35498
35534
  function useStageField(tableId) {
35499
35535
  const client = useRecordsClient66();
35500
- const [stage, setStage] = useState97({
35536
+ const [stage, setStage] = useState98({
35501
35537
  asked: false,
35502
35538
  key: null
35503
35539
  });
35504
- useEffect83(() => {
35540
+ useEffect84(() => {
35505
35541
  let cancelled = false;
35506
35542
  setStage({ asked: false, key: null });
35507
35543
  void client.tableStageField({ table_id: tableId }).then((r) => {
@@ -35989,7 +36025,7 @@ function Kanban({
35989
36025
  for (const row of rows) for (const key of laneAxis.keysOf(row)) byLane.get(key)?.push(row);
35990
36026
  return laneAxis.names.map((name) => ({ name, rows: byLane.get(name) ?? [] })).filter((l) => !hideEmpty || l.rows.length > 0);
35991
36027
  }, [rows, laneAxis, hideEmpty]);
35992
- const [shutHere, setShutHere] = useState97([]);
36028
+ const [shutHere, setShutHere] = useState98([]);
35993
36029
  const shut = new Set(onLook ? board.boardLanesShut ?? [] : shutHere);
35994
36030
  const toggleLane = (name) => {
35995
36031
  const next = new Set(shut);
@@ -36331,8 +36367,8 @@ function RecordCard({
36331
36367
  }) {
36332
36368
  const host = useRecordsUi();
36333
36369
  const wanted = useMemo58(() => {
36334
- const asked2 = [field2 && pointsAtRecords(field2) ? field2 : null, parentField ?? null].filter((f) => f !== null);
36335
- return asked2.length > 0 ? asked2 : NO_FIELDS2;
36370
+ const asked3 = [field2 && pointsAtRecords(field2) ? field2 : null, parentField ?? null].filter((f) => f !== null);
36371
+ return asked3.length > 0 ? asked3 : NO_FIELDS2;
36336
36372
  }, [field2, parentField]);
36337
36373
  const labels = useRecordLabels(wanted);
36338
36374
  const { text: label, withheld } = cardWords(record, field2, labels);
@@ -36388,7 +36424,7 @@ function boardDefaultGroupField(eligible) {
36388
36424
  }
36389
36425
 
36390
36426
  // src/ArchivedView.tsx
36391
- import { useCallback as useCallback40, useEffect as useEffect84, useState as useState98 } from "react";
36427
+ import { useCallback as useCallback40, useEffect as useEffect85, useState as useState99 } from "react";
36392
36428
  import {
36393
36429
  ARCHIVE_LANES,
36394
36430
  ARCHIVE_LANE_LABEL,
@@ -36420,13 +36456,13 @@ function ArchivedView({
36420
36456
  const table = useTable19(tableId);
36421
36457
  const rights = useTableRights(table.data);
36422
36458
  const fields = useFields19(tableId);
36423
- const [lane, setLane] = useState98(laneFromHost ?? DEFAULT_ARCHIVE_LANE);
36424
- const [rows, setRows] = useState98([]);
36425
- const [loading, setLoading] = useState98(true);
36426
- const [error, setError] = useState98(null);
36427
- const [restoring, setRestoring] = useState98(null);
36428
- const [refusal3, setRefusal] = useState98(null);
36429
- useEffect84(() => {
36459
+ const [lane, setLane] = useState99(laneFromHost ?? DEFAULT_ARCHIVE_LANE);
36460
+ const [rows, setRows] = useState99([]);
36461
+ const [loading, setLoading] = useState99(true);
36462
+ const [error, setError] = useState99(null);
36463
+ const [restoring, setRestoring] = useState99(null);
36464
+ const [refusal3, setRefusal] = useState99(null);
36465
+ useEffect85(() => {
36430
36466
  if (laneFromHost) setLane(laneFromHost);
36431
36467
  }, [laneFromHost]);
36432
36468
  const read = useCallback40(async () => {
@@ -36441,7 +36477,7 @@ function ArchivedView({
36441
36477
  }
36442
36478
  setLoading(false);
36443
36479
  }, [client, tableId, lane, pageSize]);
36444
- useEffect84(() => {
36480
+ useEffect85(() => {
36445
36481
  void read();
36446
36482
  }, [read]);
36447
36483
  const pick = (next) => {
@@ -36528,10 +36564,10 @@ function retiredColumnLine(row) {
36528
36564
  }
36529
36565
  function RetiredColumns({ tableId, mayRestore, whyNot }) {
36530
36566
  const client = useRecordsClient67();
36531
- const [rows, setRows] = useState98(null);
36532
- const [error, setError] = useState98(null);
36533
- const [restoring, setRestoring] = useState98(null);
36534
- const [refusal3, setRefusal] = useState98(null);
36567
+ const [rows, setRows] = useState99(null);
36568
+ const [error, setError] = useState99(null);
36569
+ const [restoring, setRestoring] = useState99(null);
36570
+ const [refusal3, setRefusal] = useState99(null);
36535
36571
  const read = useCallback40(async () => {
36536
36572
  const answer = await client.fieldsRetired({ table_id: tableId });
36537
36573
  if (answer.ok) {
@@ -36542,7 +36578,7 @@ function RetiredColumns({ tableId, mayRestore, whyNot }) {
36542
36578
  setError(answer.error);
36543
36579
  }
36544
36580
  }, [client, tableId]);
36545
- useEffect84(() => {
36581
+ useEffect85(() => {
36546
36582
  void read();
36547
36583
  }, [read]);
36548
36584
  const restore = async (fieldId) => {
@@ -36587,7 +36623,7 @@ function RetiredColumns({ tableId, mayRestore, whyNot }) {
36587
36623
  }
36588
36624
 
36589
36625
  // src/ArchivedDisclosure.tsx
36590
- import { useCallback as useCallback41, useEffect as useEffect85, useState as useState99 } from "react";
36626
+ import { useCallback as useCallback41, useEffect as useEffect86, useState as useState100 } from "react";
36591
36627
  import {
36592
36628
  emptyPortalArchiveLine,
36593
36629
  portalConfirmLine,
@@ -36605,7 +36641,7 @@ function ArchivedDisclosure({
36605
36641
  children,
36606
36642
  className
36607
36643
  }) {
36608
- const [open, setOpen] = useState99(defaultOpen);
36644
+ const [open, setOpen] = useState100(defaultOpen);
36609
36645
  const toggle = () => {
36610
36646
  const next = !open;
36611
36647
  setOpen(next);
@@ -36639,13 +36675,13 @@ function ArchivedPortals({
36639
36675
  className
36640
36676
  }) {
36641
36677
  const client = useRecordsClient68();
36642
- const [rows, setRows] = useState99(null);
36643
- const [error, setError] = useState99(null);
36644
- const [confirming, setConfirming] = useState99(null);
36645
- const [typed2, setTyped] = useState99("");
36646
- const [restoring, setRestoring] = useState99(null);
36647
- const [refusal3, setRefusal] = useState99(null);
36648
- const [said2, setSaid] = useState99(null);
36678
+ const [rows, setRows] = useState100(null);
36679
+ const [error, setError] = useState100(null);
36680
+ const [confirming, setConfirming] = useState100(null);
36681
+ const [typed2, setTyped] = useState100("");
36682
+ const [restoring, setRestoring] = useState100(null);
36683
+ const [refusal3, setRefusal] = useState100(null);
36684
+ const [said2, setSaid] = useState100(null);
36649
36685
  const read = useCallback41(async () => {
36650
36686
  const answered = await client.listPortals({ archived: "archived" });
36651
36687
  if (answered.ok) {
@@ -36656,7 +36692,7 @@ function ArchivedPortals({
36656
36692
  setError(answered.error);
36657
36693
  }
36658
36694
  }, [client]);
36659
- useEffect85(() => {
36695
+ useEffect86(() => {
36660
36696
  void read();
36661
36697
  }, [read, refreshToken]);
36662
36698
  const restore = async (portal) => {
@@ -36772,7 +36808,7 @@ function ArchivedPortals({
36772
36808
  }
36773
36809
 
36774
36810
  // src/ViewBar.tsx
36775
- import { useCallback as useCallback43, useEffect as useEffect86, useRef as useRef48, useState as useState100 } from "react";
36811
+ import { useCallback as useCallback43, useEffect as useEffect87, useRef as useRef48, useState as useState101 } from "react";
36776
36812
  import { useRecordsClient as useRecordsClient69 } from "@ai-matrx/records/react";
36777
36813
  import { Badge as Badge15, Button as Button73, Input as Input6, Popover as Popover13, PopoverContent as PopoverContent13, PopoverTrigger as PopoverTrigger13, Skeleton as Skeleton15, cn as cn64 } from "@ai-matrx/design-system";
36778
36814
 
@@ -36834,18 +36870,18 @@ function ViewBar({ tableId, activeViewId, onActiveView, seed, settings, onViews,
36834
36870
  const table = useTable20(tableId);
36835
36871
  const rights = useTableRights(table.data);
36836
36872
  const notify = useRecordsUi().notify;
36837
- const [views, setViews] = useState100(() => initialViews ?? null);
36838
- const [error, setError] = useState100(null);
36839
- const [unavailable, setUnavailable] = useState100(false);
36840
- const [active, setActive] = useState100(() => {
36873
+ const [views, setViews] = useState101(() => initialViews ?? null);
36874
+ const [error, setError] = useState101(null);
36875
+ const [unavailable, setUnavailable] = useState101(false);
36876
+ const [active, setActive] = useState101(() => {
36841
36877
  if (!initialViews || initialViews.length === 0) return activeViewId ?? null;
36842
36878
  return (initialViews.find((v) => v.id === activeViewId) ?? defaultViewOf(initialViews) ?? initialViews[0]).id;
36843
36879
  });
36844
36880
  const readOnMount = useRef48(initialViews === void 0);
36845
- const [naming, setNaming] = useState100(false);
36846
- const [draftName, setDraftName] = useState100("");
36847
- const [open, setOpen] = useState100(false);
36848
- const [renaming, setRenaming] = useState100(null);
36881
+ const [naming, setNaming] = useState101(false);
36882
+ const [draftName, setDraftName] = useState101("");
36883
+ const [open, setOpen] = useState101(false);
36884
+ const [renaming, setRenaming] = useState101(null);
36849
36885
  const seedKey = JSON.stringify(seed ?? []);
36850
36886
  const readViews = useCallback43(async () => {
36851
36887
  const result = await client.views({ table_id: tableId });
@@ -36887,14 +36923,14 @@ function ViewBar({ tableId, activeViewId, onActiveView, seed, settings, onViews,
36887
36923
  setViews(mine);
36888
36924
  onViews?.(mine);
36889
36925
  }, [client, readViews, tableId, seedKey]);
36890
- useEffect86(() => {
36926
+ useEffect87(() => {
36891
36927
  if (!readOnMount.current) {
36892
36928
  readOnMount.current = true;
36893
36929
  return;
36894
36930
  }
36895
36931
  void load();
36896
36932
  }, [load]);
36897
- useEffect86(() => {
36933
+ useEffect87(() => {
36898
36934
  if (!views || views.length === 0) return;
36899
36935
  const chosen = views.find((v) => v.id === (activeViewId ?? active)) ?? defaultViewOf(views) ?? views[0];
36900
36936
  if (chosen.id !== active) setActive(chosen.id);
@@ -37122,7 +37158,7 @@ function ViewBar({ tableId, activeViewId, onActiveView, seed, settings, onViews,
37122
37158
  }
37123
37159
 
37124
37160
  // src/ProposalRow.tsx
37125
- import { useEffect as useEffect87, useRef as useRef49, useState as useState101 } from "react";
37161
+ import { useEffect as useEffect88, useRef as useRef49, useState as useState102 } from "react";
37126
37162
  import { useRecordsClient as useRecordsClient70 } from "@ai-matrx/records/react";
37127
37163
  import { Badge as Badge16, Button as Button74, cn as cn65 } from "@ai-matrx/design-system";
37128
37164
  import { jsx as jsx123, jsxs as jsxs113 } from "react/jsx-runtime";
@@ -37137,12 +37173,12 @@ function ProposalRow({
37137
37173
  className
37138
37174
  }) {
37139
37175
  const client = useRecordsClient70();
37140
- const [settled, setSettled] = useState101(outcome ?? null);
37141
- const [busy, setBusy] = useState101(false);
37142
- const [confirming, setConfirming] = useState101(false);
37176
+ const [settled, setSettled] = useState102(outcome ?? null);
37177
+ const [busy, setBusy] = useState102(false);
37178
+ const [confirming, setConfirming] = useState102(false);
37143
37179
  const drawnVersion = useRef49(null);
37144
37180
  const needsVersion = change.act === "update" && Boolean(change.record) && change.version === void 0 && !onApply && !settled;
37145
- useEffect87(() => {
37181
+ useEffect88(() => {
37146
37182
  if (needsVersion && change.record && !drawnVersion.current) drawnVersion.current = (0, recordVersions_exports.readVersionNow)(client, change.record);
37147
37183
  }, [needsVersion, change.record, client]);
37148
37184
  async function applyThroughTheStore() {
@@ -37230,14 +37266,14 @@ function ProposalRow({
37230
37266
  }
37231
37267
 
37232
37268
  // src/ActionInbox.tsx
37233
- import { useCallback as useCallback45, useEffect as useEffect89, useMemo as useMemo60, useRef as useRef50, useState as useState103 } from "react";
37269
+ import { useCallback as useCallback45, useEffect as useEffect90, useMemo as useMemo60, useRef as useRef50, useState as useState104 } from "react";
37234
37270
  import { useRecordsClient as useRecordsClient72 } from "@ai-matrx/records/react";
37235
37271
  import { Badge as Badge18, Button as Button76, Checkbox as Checkbox11, Skeleton as Skeleton17, cn as cn67 } from "@ai-matrx/design-system";
37236
37272
  import { toggleSelection as toggleSelection2 } from "@ai-matrx/design-system/data-table";
37237
37273
  import { formatAbsoluteDate, formatDurationMs } from "@ai-matrx/kit/format";
37238
37274
 
37239
37275
  // src/ChecklistRunner.tsx
37240
- import { useCallback as useCallback44, useEffect as useEffect88, useMemo as useMemo59, useState as useState102 } from "react";
37276
+ import { useCallback as useCallback44, useEffect as useEffect89, useMemo as useMemo59, useState as useState103 } from "react";
37241
37277
  import { useRecordsClient as useRecordsClient71, useTable as useTable21 } from "@ai-matrx/records/react";
37242
37278
  import { Badge as Badge17, BasicInput as BasicInput22, BasicTextarea as BasicTextarea9, Button as Button75, Skeleton as Skeleton16, cn as cn66 } from "@ai-matrx/design-system";
37243
37279
  import { humanizeIdentifier as humanizeIdentifier14 } from "@ai-matrx/kit/text-case";
@@ -37257,13 +37293,13 @@ function ChecklistRunner({
37257
37293
  const client = useRecordsClient71();
37258
37294
  const table = useTable21(tableId ?? null);
37259
37295
  const rights = useTableRights(table.data);
37260
- const [runs, setRuns] = useState102(null);
37261
- const [activeId, setActiveId] = useState102(runId ?? null);
37262
- const [steps, setSteps] = useState102(null);
37263
- const [templates, setTemplates] = useState102(null);
37264
- const [error, setError] = useState102(null);
37265
- const [busy, setBusy] = useState102(null);
37266
- const [said2, setSaid] = useState102(null);
37296
+ const [runs, setRuns] = useState103(null);
37297
+ const [activeId, setActiveId] = useState103(runId ?? null);
37298
+ const [steps, setSteps] = useState103(null);
37299
+ const [templates, setTemplates] = useState103(null);
37300
+ const [error, setError] = useState103(null);
37301
+ const [busy, setBusy] = useState103(null);
37302
+ const [said2, setSaid] = useState103(null);
37267
37303
  const mayStart = offerToStart ?? Boolean(recordId);
37268
37304
  const loadRuns = useCallback44(async () => {
37269
37305
  if (runId) {
@@ -37287,10 +37323,10 @@ function ChecklistRunner({
37287
37323
  (held) => held && answered.data.some((r) => r.run_id === held) ? held : answered.data[0]?.run_id ?? null
37288
37324
  );
37289
37325
  }, [client, includeClosed, recordId, runId, tableId]);
37290
- useEffect88(() => {
37326
+ useEffect89(() => {
37291
37327
  void loadRuns();
37292
37328
  }, [loadRuns]);
37293
- useEffect88(() => {
37329
+ useEffect89(() => {
37294
37330
  if (runId) setActiveId(runId);
37295
37331
  }, [runId]);
37296
37332
  const loadSteps = useCallback44(async () => {
@@ -37307,10 +37343,10 @@ function ChecklistRunner({
37307
37343
  setError(null);
37308
37344
  setSteps(answered.data);
37309
37345
  }, [client, activeId]);
37310
- useEffect88(() => {
37346
+ useEffect89(() => {
37311
37347
  void loadSteps();
37312
37348
  }, [loadSteps]);
37313
- useEffect88(() => {
37349
+ useEffect89(() => {
37314
37350
  if (!mayStart || !tableId) return;
37315
37351
  let cancelled = false;
37316
37352
  void client.checklistTemplates({ about_table_id: tableId, limit: 50 }).then((answered) => {
@@ -37442,9 +37478,9 @@ function StepRow({
37442
37478
  className
37443
37479
  }) {
37444
37480
  const host = useRecordsUi();
37445
- const [members, setMembers] = useState102(null);
37481
+ const [members, setMembers] = useState103(null);
37446
37482
  const unassigned = !step2.finished && !step2.assignee_user_id && Boolean(step2.role);
37447
- useEffect88(() => {
37483
+ useEffect89(() => {
37448
37484
  if (!unassigned || !onAssign || !host.members || members !== null) return;
37449
37485
  let alive = true;
37450
37486
  void host.members().then((roster) => {
@@ -37454,7 +37490,7 @@ function StepRow({
37454
37490
  alive = false;
37455
37491
  };
37456
37492
  }, [unassigned, onAssign, host, members]);
37457
- const [answer, setAnswer] = useState102("");
37493
+ const [answer, setAnswer] = useState103("");
37458
37494
  const key = step2.requires_key ?? (step2.requires === "note" ? "note" : null);
37459
37495
  const asksHere = step2.requires === "note" || step2.requires === "answer";
37460
37496
  const needsAnswer = asksHere && answer.trim().length === 0;
@@ -37548,9 +37584,9 @@ function StepRow({
37548
37584
  function useMyChecklistSteps(limit = 25) {
37549
37585
  const client = useRecordsClient71();
37550
37586
  const me = client.config.actor.user_id ?? null;
37551
- const [steps, setSteps] = useState102([]);
37552
- const [loading, setLoading] = useState102(true);
37553
- const [error, setError] = useState102(null);
37587
+ const [steps, setSteps] = useState103([]);
37588
+ const [loading, setLoading] = useState103(true);
37589
+ const [error, setError] = useState103(null);
37554
37590
  const refresh = useCallback44(async () => {
37555
37591
  if (!me) {
37556
37592
  setSteps([]);
@@ -37579,7 +37615,7 @@ function useMyChecklistSteps(limit = 25) {
37579
37615
  setSteps(held);
37580
37616
  setLoading(false);
37581
37617
  }, [client, limit, me]);
37582
- useEffect88(() => {
37618
+ useEffect89(() => {
37583
37619
  void refresh();
37584
37620
  }, [refresh]);
37585
37621
  return { steps, loading, error, refresh };
@@ -37592,12 +37628,12 @@ function MyChecklistSteps({
37592
37628
  }) {
37593
37629
  const client = useRecordsClient71();
37594
37630
  const { steps: held, loading, error, refresh } = useMyChecklistSteps();
37595
- useEffect88(() => {
37631
+ useEffect89(() => {
37596
37632
  onSteps?.(held.map((s) => s.step_id));
37597
37633
  }, [held, onSteps]);
37598
37634
  const steps = onlyIds ? held.filter((s) => onlyIds.has(s.step_id)) : held;
37599
- const [busy, setBusy] = useState102(null);
37600
- const [refusal3, setRefusal] = useState102(null);
37635
+ const [busy, setBusy] = useState103(null);
37636
+ const [refusal3, setRefusal] = useState103(null);
37601
37637
  const complete = useCallback44(
37602
37638
  async (step2, evidence) => {
37603
37639
  setBusy(step2.step_id);
@@ -37641,12 +37677,12 @@ function ChecklistsPanel({ tableId, onOpenRecord, className }) {
37641
37677
  const client = useRecordsClient71();
37642
37678
  const table = useTable21(tableId);
37643
37679
  const rights = useTableRights(table.data);
37644
- const [templates, setTemplates] = useState102(null);
37645
- const [runs, setRuns] = useState102(null);
37646
- const [error, setError] = useState102(null);
37647
- const [editing, setEditing] = useState102(null);
37648
- const [openRun, setOpenRun] = useState102(null);
37649
- const [archivedSaid, setArchivedSaid] = useState102(null);
37680
+ const [templates, setTemplates] = useState103(null);
37681
+ const [runs, setRuns] = useState103(null);
37682
+ const [error, setError] = useState103(null);
37683
+ const [editing, setEditing] = useState103(null);
37684
+ const [openRun, setOpenRun] = useState103(null);
37685
+ const [archivedSaid, setArchivedSaid] = useState103(null);
37650
37686
  const load = useCallback44(async () => {
37651
37687
  const [t, r] = await Promise.all([
37652
37688
  client.checklistTemplates({ about_table_id: tableId, limit: 100 }),
@@ -37661,7 +37697,7 @@ function ChecklistsPanel({ tableId, onOpenRecord, className }) {
37661
37697
  if (!r.ok) setRuns([]);
37662
37698
  else setRuns(r.data);
37663
37699
  }, [client, tableId]);
37664
- useEffect88(() => {
37700
+ useEffect89(() => {
37665
37701
  void load();
37666
37702
  }, [load]);
37667
37703
  if (templates === null) return /* @__PURE__ */ jsx124(Skeleton16, { className: cn66("h-40 w-full", className) });
@@ -37816,15 +37852,15 @@ function ChecklistTemplateEditor({
37816
37852
  className
37817
37853
  }) {
37818
37854
  const client = useRecordsClient71();
37819
- const [savedId, setSavedId] = useState102(templateId ?? null);
37820
- const [saved, setSaved] = useState102(false);
37821
- const [name, setName] = useState102("");
37822
- const [rows, setRows] = useState102([{ ...EMPTY_ROW }]);
37823
- const [refusal3, setRefusal] = useState102(null);
37824
- const [error, setError] = useState102(null);
37825
- const [busy, setBusy] = useState102(false);
37826
- const [loading, setLoading] = useState102(Boolean(templateId));
37827
- useEffect88(() => {
37855
+ const [savedId, setSavedId] = useState103(templateId ?? null);
37856
+ const [saved, setSaved] = useState103(false);
37857
+ const [name, setName] = useState103("");
37858
+ const [rows, setRows] = useState103([{ ...EMPTY_ROW }]);
37859
+ const [refusal3, setRefusal] = useState103(null);
37860
+ const [error, setError] = useState103(null);
37861
+ const [busy, setBusy] = useState103(false);
37862
+ const [loading, setLoading] = useState103(Boolean(templateId));
37863
+ useEffect89(() => {
37828
37864
  if (!templateId) return;
37829
37865
  let cancelled = false;
37830
37866
  void client.checklistTemplateShape({ template_id: templateId }).then((answered) => {
@@ -37861,8 +37897,8 @@ function ChecklistTemplateEditor({
37861
37897
  }),
37862
37898
  [aboutTableId, name, rows]
37863
37899
  );
37864
- useEffect88(() => setSaved(false), [spec]);
37865
- useEffect88(() => {
37900
+ useEffect89(() => setSaved(false), [spec]);
37901
+ useEffect89(() => {
37866
37902
  if (spec.steps.length === 0 || spec.name.length === 0) {
37867
37903
  setRefusal(null);
37868
37904
  return;
@@ -38124,25 +38160,25 @@ function ActionInbox({
38124
38160
  className
38125
38161
  }) {
38126
38162
  const client = useRecordsClient72();
38127
- const [showDecided, setShowDecided] = useState103(includeSettled);
38128
- const [groupBy, setGroupBy] = useState103(defaultGroupBy);
38129
- const [everyTable, setEveryTable] = useState103(false);
38130
- const [items, setItems] = useState103(null);
38131
- const [error, setError] = useState103(null);
38132
- const [outcome, setOutcome] = useState103({});
38133
- const [busy, setBusy] = useState103(null);
38134
- const [cursor, setCursor] = useState103(0);
38163
+ const [showDecided, setShowDecided] = useState104(includeSettled);
38164
+ const [groupBy, setGroupBy] = useState104(defaultGroupBy);
38165
+ const [everyTable, setEveryTable] = useState104(false);
38166
+ const [items, setItems] = useState104(null);
38167
+ const [error, setError] = useState104(null);
38168
+ const [outcome, setOutcome] = useState104({});
38169
+ const [busy, setBusy] = useState104(null);
38170
+ const [cursor, setCursor] = useState104(0);
38135
38171
  const listRef = useRef50(null);
38136
- const [selected, setSelected] = useState103(/* @__PURE__ */ new Set());
38172
+ const [selected, setSelected] = useState104(/* @__PURE__ */ new Set());
38137
38173
  const anchor = useRef50(null);
38138
- const [deciding, setDeciding] = useState103(false);
38139
- const [batchSaid, setBatchSaid] = useState103(null);
38140
- const [view, setView] = useState103("inbox");
38141
- const [counts, setCounts] = useState103(null);
38142
- const [snoozing, setSnoozing] = useState103(null);
38143
- const [pickAt, setPickAt] = useState103("");
38144
- const [said2, setSaid] = useState103(null);
38145
- const [stepIds, setStepIds] = useState103(/* @__PURE__ */ new Set());
38174
+ const [deciding, setDeciding] = useState104(false);
38175
+ const [batchSaid, setBatchSaid] = useState104(null);
38176
+ const [view, setView] = useState104("inbox");
38177
+ const [counts, setCounts] = useState104(null);
38178
+ const [snoozing, setSnoozing] = useState104(null);
38179
+ const [pickAt, setPickAt] = useState104("");
38180
+ const [said2, setSaid] = useState104(null);
38181
+ const [stepIds, setStepIds] = useState104(/* @__PURE__ */ new Set());
38146
38182
  const onSteps = useCallback45((ids) => setStepIds(new Set(ids)), []);
38147
38183
  const load = useCallback45(async () => {
38148
38184
  const [result, counted] = await Promise.all([
@@ -38158,7 +38194,7 @@ function ActionInbox({
38158
38194
  setError(null);
38159
38195
  setItems(result.data);
38160
38196
  }, [client, showDecided, view]);
38161
- useEffect89(() => {
38197
+ useEffect90(() => {
38162
38198
  void load();
38163
38199
  }, [load]);
38164
38200
  const narrowed = useMemo60(() => {
@@ -38173,10 +38209,10 @@ function ActionInbox({
38173
38209
  const groups = useMemo60(() => groupInbox(narrowed, groupBy), [narrowed, groupBy]);
38174
38210
  const shown4 = useMemo60(() => groups.flatMap((g) => g.items), [groups]);
38175
38211
  const elsewhere = (items?.length ?? 0) - narrowed.length;
38176
- useEffect89(() => {
38212
+ useEffect90(() => {
38177
38213
  if (cursor >= shown4.length) setCursor(Math.max(0, shown4.length - 1));
38178
38214
  }, [shown4.length, cursor]);
38179
- useEffect89(() => {
38215
+ useEffect90(() => {
38180
38216
  const list = listRef.current;
38181
38217
  const el = list?.querySelector(`[data-row="${cursor}"]`);
38182
38218
  if (list && el) scrollWithinList(list, el);
@@ -38197,12 +38233,12 @@ function ActionInbox({
38197
38233
  },
38198
38234
  [client, load]
38199
38235
  );
38200
- const [held, setHeld] = useState103({});
38236
+ const [held, setHeld] = useState104({});
38201
38237
  const holds2 = useRef50(/* @__PURE__ */ new Map());
38202
38238
  const lastHold = useRef50(null);
38203
38239
  const holdSeq = useRef50(0);
38204
- const [, tick] = useState103(0);
38205
- useEffect89(() => {
38240
+ const [, tick] = useState104(0);
38241
+ useEffect90(() => {
38206
38242
  if (Object.keys(held).length === 0) return;
38207
38243
  const t = setInterval(() => tick((n) => n + 1), 250);
38208
38244
  return () => clearInterval(t);
@@ -38247,7 +38283,7 @@ function ActionInbox({
38247
38283
  });
38248
38284
  setSaid({ text: entry.ids.length === 1 ? "Undone. It is waiting on you again, exactly as it was." : `Undone. All ${entry.ids.length} are waiting on you again, exactly as they were.`, undo: null });
38249
38285
  }, []);
38250
- useEffect89(() => {
38286
+ useEffect90(() => {
38251
38287
  const flush = () => {
38252
38288
  for (const entry of [...holds2.current.values()]) entry.commit();
38253
38289
  };
@@ -38258,7 +38294,7 @@ function ActionInbox({
38258
38294
  };
38259
38295
  }, []);
38260
38296
  const resumed = useRef50(false);
38261
- useEffect89(() => {
38297
+ useEffect90(() => {
38262
38298
  if (resumed.current || items === null || view !== "inbox") return;
38263
38299
  resumed.current = true;
38264
38300
  const kept = readHolds();
@@ -38878,7 +38914,7 @@ function ActionInbox({
38878
38914
  }
38879
38915
 
38880
38916
  // src/HistoryPanel.tsx
38881
- import { useCallback as useCallback46, useEffect as useEffect90, useRef as useRef51, useState as useState104 } from "react";
38917
+ import { useCallback as useCallback46, useEffect as useEffect91, useRef as useRef51, useState as useState105 } from "react";
38882
38918
  import {
38883
38919
  useFields as useFields20,
38884
38920
  useRecordChangeRevision,
@@ -38894,12 +38930,12 @@ function HistoryPanel({ tableId, recordId, onAskAboutField, className }) {
38894
38930
  const table = useTable22(tableId);
38895
38931
  const fields = useFields20(tableId);
38896
38932
  const rights = useTableRights(table.data);
38897
- const [entries, setEntries] = useState104(null);
38898
- const [error, setError] = useState104(null);
38899
- const [open, setOpen] = useState104(null);
38900
- const [pending, setPending] = useState104({ phase: "idle" });
38933
+ const [entries, setEntries] = useState105(null);
38934
+ const [error, setError] = useState105(null);
38935
+ const [open, setOpen] = useState105(null);
38936
+ const [pending, setPending] = useState105({ phase: "idle" });
38901
38937
  const seenAtPreview = useRef51(null);
38902
- const [said2, setSaid] = useState104(null);
38938
+ const [said2, setSaid] = useState105(null);
38903
38939
  const listRef = useRef51(null);
38904
38940
  const changed = useRecordChangeRevision(recordId);
38905
38941
  const load = useCallback46(async () => {
@@ -38911,7 +38947,7 @@ function HistoryPanel({ tableId, recordId, onAskAboutField, className }) {
38911
38947
  setError(null);
38912
38948
  setEntries(answered.data);
38913
38949
  }, [client, recordId, changed]);
38914
- useEffect90(() => {
38950
+ useEffect91(() => {
38915
38951
  void load();
38916
38952
  }, [load]);
38917
38953
  if (error) return /* @__PURE__ */ jsx126(RefusalNotice, { error, className });
@@ -38922,17 +38958,17 @@ function HistoryPanel({ tableId, recordId, onAskAboutField, className }) {
38922
38958
  async function startRestore(version, fieldKey) {
38923
38959
  setSaid(null);
38924
38960
  setPending({ phase: "asking", version, fieldKey });
38925
- const [asked2, seen] = await Promise.all([
38961
+ const [asked3, seen] = await Promise.all([
38926
38962
  client.restorePreview(fieldKey ? { record_id: recordId, version, field_key: fieldKey } : { record_id: recordId, version }),
38927
38963
  (0, recordVersions_exports.readVersionNow)(client, recordId)
38928
38964
  ]);
38929
38965
  seenAtPreview.current = seen;
38930
- if (!asked2.ok) {
38966
+ if (!asked3.ok) {
38931
38967
  setPending({ phase: "idle" });
38932
- setError(asked2.error);
38968
+ setError(asked3.error);
38933
38969
  return;
38934
38970
  }
38935
- setPending({ phase: "confirm", version, fieldKey, preview: asked2.data });
38971
+ setPending({ phase: "confirm", version, fieldKey, preview: asked3.data });
38936
38972
  }
38937
38973
  async function doRestore(version, fieldKey) {
38938
38974
  setPending({ phase: "writing", version, fieldKey });
@@ -39194,7 +39230,7 @@ function say(value, field2) {
39194
39230
  }
39195
39231
 
39196
39232
  // src/CommentThread.tsx
39197
- import { useCallback as useCallback47, useEffect as useEffect91, useMemo as useMemo61, useRef as useRef52, useState as useState105 } from "react";
39233
+ import { useCallback as useCallback47, useEffect as useEffect92, useMemo as useMemo61, useRef as useRef52, useState as useState106 } from "react";
39198
39234
  import {
39199
39235
  useFields as useFields21,
39200
39236
  useRecordsClient as useRecordsClient74,
@@ -39208,16 +39244,16 @@ function CommentThread({ tableId, recordId, fieldKey, className }) {
39208
39244
  const table = useTable23(tableId);
39209
39245
  const fields = useFields21(tableId);
39210
39246
  const host = useRecordsUi();
39211
- const [thread, setThread] = useState105(null);
39212
- const [error, setError] = useState105(null);
39213
- const [draft, setDraft] = useState105("");
39214
- const [replyTo, setReplyTo] = useState105(null);
39215
- const [busy, setBusy] = useState105(false);
39216
- const [said2, setSaid] = useState105(null);
39217
- const [showResolved, setShowResolved] = useState105(false);
39218
- const [people, setPeople] = useState105([]);
39219
- const [mentionQuery, setMentionQuery] = useState105(null);
39220
- const [picked, setPicked] = useState105([]);
39247
+ const [thread, setThread] = useState106(null);
39248
+ const [error, setError] = useState106(null);
39249
+ const [draft, setDraft] = useState106("");
39250
+ const [replyTo, setReplyTo] = useState106(null);
39251
+ const [busy, setBusy] = useState106(false);
39252
+ const [said2, setSaid] = useState106(null);
39253
+ const [showResolved, setShowResolved] = useState106(false);
39254
+ const [people, setPeople] = useState106([]);
39255
+ const [mentionQuery, setMentionQuery] = useState106(null);
39256
+ const [picked, setPicked] = useState106([]);
39221
39257
  const box = useRef52(null);
39222
39258
  const load = useCallback47(async () => {
39223
39259
  const answered = await client.commentThread({ record_id: recordId, include_resolved: showResolved });
@@ -39232,10 +39268,10 @@ function CommentThread({ tableId, recordId, fieldKey, className }) {
39232
39268
  mayResolve: answered.data.may_resolve
39233
39269
  });
39234
39270
  }, [client, recordId, showResolved]);
39235
- useEffect91(() => {
39271
+ useEffect92(() => {
39236
39272
  void load();
39237
39273
  }, [load]);
39238
- useEffect91(() => {
39274
+ useEffect92(() => {
39239
39275
  let alive = true;
39240
39276
  if (!host.members) return;
39241
39277
  void host.members().then((roster) => {
@@ -39438,7 +39474,7 @@ function Line2({
39438
39474
  }
39439
39475
 
39440
39476
  // src/FieldHistoryPanel.tsx
39441
- import { useCallback as useCallback48, useEffect as useEffect92, useRef as useRef53, useState as useState106 } from "react";
39477
+ import { useCallback as useCallback48, useEffect as useEffect93, useRef as useRef53, useState as useState107 } from "react";
39442
39478
  import {
39443
39479
  useFields as useFields22,
39444
39480
  useRecordsClient as useRecordsClient75,
@@ -39459,11 +39495,11 @@ function FieldHistoryPanel({
39459
39495
  const table = useTable24(tableId);
39460
39496
  const fields = useFields22(tableId);
39461
39497
  const rights = useTableRights(table.data);
39462
- const [rows, setRows] = useState106(null);
39463
- const [error, setError] = useState106(null);
39464
- const [pending, setPending] = useState106({ phase: "idle" });
39498
+ const [rows, setRows] = useState107(null);
39499
+ const [error, setError] = useState107(null);
39500
+ const [pending, setPending] = useState107({ phase: "idle" });
39465
39501
  const seenAtPreview = useRef53(null);
39466
- const [said2, setSaid] = useState106(null);
39502
+ const [said2, setSaid] = useState107(null);
39467
39503
  const load = useCallback48(async () => {
39468
39504
  const answered = await client.fieldHistory(
39469
39505
  recordId ? { table_id: tableId, field_key: fieldKey, record_id: recordId } : { table_id: tableId, field_key: fieldKey }
@@ -39475,7 +39511,7 @@ function FieldHistoryPanel({
39475
39511
  setError(null);
39476
39512
  setRows(answered.data);
39477
39513
  }, [client, tableId, fieldKey, recordId]);
39478
- useEffect92(() => {
39514
+ useEffect93(() => {
39479
39515
  void load();
39480
39516
  }, [load]);
39481
39517
  const label = (fields.data ?? []).find((f) => f.key === fieldKey)?.label || humanizeIdentifier17(fieldKey);
@@ -39484,17 +39520,17 @@ function FieldHistoryPanel({
39484
39520
  async function start(row) {
39485
39521
  setSaid(null);
39486
39522
  setPending({ phase: "asking", recordId: row.record_id, version: row.version });
39487
- const [asked2, seen] = await Promise.all([
39523
+ const [asked3, seen] = await Promise.all([
39488
39524
  client.restorePreview({ record_id: row.record_id, version: row.version, field_key: fieldKey }),
39489
39525
  (0, recordVersions_exports.readVersionNow)(client, row.record_id)
39490
39526
  ]);
39491
39527
  seenAtPreview.current = seen;
39492
- if (!asked2.ok) {
39528
+ if (!asked3.ok) {
39493
39529
  setPending({ phase: "idle" });
39494
- setError(asked2.error);
39530
+ setError(asked3.error);
39495
39531
  return;
39496
39532
  }
39497
- setPending({ phase: "confirm", recordId: row.record_id, version: row.version, preview: asked2.data });
39533
+ setPending({ phase: "confirm", recordId: row.record_id, version: row.version, preview: asked3.data });
39498
39534
  }
39499
39535
  async function confirm(recordOf2, version) {
39500
39536
  setPending({ phase: "writing", recordId: recordOf2, version });
@@ -39587,8 +39623,8 @@ function FieldHistoryPanel({
39587
39623
  import { FORM_FLOWS as FORM_FLOWS2, FORM_EMBEDS as FORM_EMBEDS2, formDeclareArgs as formDeclareArgs2, formFromSummary as formFromSummary4, formPresentation, formLookDocument as formLookDocument2, formLookFromDocument, submissionStamp as submissionStamp2, formEmbedSnippet as formEmbedSnippet2, formRoutes as formRoutes2, hiddenFromLink, endingsFromDocument, welcomeFromDocument, themeFromDocument } from "@ai-matrx/records/forms";
39588
39624
 
39589
39625
  // src/FormResultsPanel.tsx
39590
- import { useEffect as useEffect93, useMemo as useMemo62, useState as useState107 } from "react";
39591
- import { useFields as useFields23, useOptionalRecordsClient as useOptionalRecordsClient17 } from "@ai-matrx/records/react";
39626
+ import { useEffect as useEffect94, useMemo as useMemo62, useState as useState108 } from "react";
39627
+ import { useFields as useFields23, useOptionalRecordsClient as useOptionalRecordsClient18 } from "@ai-matrx/records/react";
39592
39628
  import { Button as Button80, Skeleton as Skeleton21, cn as cn71 } from "@ai-matrx/design-system";
39593
39629
  import { jsx as jsx129, jsxs as jsxs119 } from "react/jsx-runtime";
39594
39630
  var CHARTED_KINDS = /* @__PURE__ */ new Set(["select", "multi_select", "checkbox", "number", "currency", "percent", "member", "relation"]);
@@ -39611,12 +39647,12 @@ function answersBlock(question, title) {
39611
39647
  };
39612
39648
  }
39613
39649
  function FormResultsPanel({ form, className }) {
39614
- const client = useOptionalRecordsClient17();
39650
+ const client = useOptionalRecordsClient18();
39615
39651
  const fields = useFields23(form.subject);
39616
- const [results, setResults] = useState107(null);
39617
- const [error, setError] = useState107(null);
39618
- const [round, setRound] = useState107(0);
39619
- useEffect93(() => {
39652
+ const [results, setResults] = useState108(null);
39653
+ const [error, setError] = useState108(null);
39654
+ const [round, setRound] = useState108(0);
39655
+ useEffect94(() => {
39620
39656
  if (!client) {
39621
39657
  setError((0, refusals_exports.refusal)("not_supported", "Results are read from the record store, and this screen has none.", "Open the form inside the app."));
39622
39658
  return;
@@ -39714,7 +39750,7 @@ function FormResultsPanel({ form, className }) {
39714
39750
  }
39715
39751
 
39716
39752
  // src/PortalBuilder.tsx
39717
- import { useCallback as useCallback49, useEffect as useEffect94, useMemo as useMemo63, useRef as useRef54, useState as useState108 } from "react";
39753
+ import { useCallback as useCallback49, useEffect as useEffect95, useMemo as useMemo63, useRef as useRef54, useState as useState109 } from "react";
39718
39754
  import { useRecordsClient as useRecordsClient76, useTables as useTables4 } from "@ai-matrx/records/react";
39719
39755
  import { BasicInput as BasicInput23, Button as Button81, Checkbox as Checkbox12, Label as Label19, Separator as Separator10, Skeleton as Skeleton22, cn as cn72 } from "@ai-matrx/design-system";
39720
39756
  import { Fragment as Fragment51, jsx as jsx130, jsxs as jsxs120 } from "react/jsx-runtime";
@@ -39722,19 +39758,19 @@ var RESTATING_REPLACES = "Saving replaces what this portal shows: a table you un
39722
39758
  function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
39723
39759
  const client = useRecordsClient76();
39724
39760
  const tables = useTables4();
39725
- const [title, setTitle] = useState108("");
39726
- const [clientTableId, setClientTableId] = useState108(null);
39727
- const [exposures, setExposures] = useState108({});
39728
- const [fieldsByTable, setFieldsByTable] = useState108({});
39729
- const [error, setError] = useState108(null);
39730
- const [saving, setSaving] = useState108(false);
39731
- const [savedId, setSavedId] = useState108(portalId ?? null);
39732
- const [existing, setExisting] = useState108(null);
39733
- const [loading, setLoading] = useState108(Boolean(portalId));
39734
- const [inviteEmail, setInviteEmail] = useState108("");
39735
- const [inviteRecordId, setInviteRecordId] = useState108("");
39736
- const [inviting, setInviting] = useState108(false);
39737
- const [invitationSaid, setInvitationSaid] = useState108(null);
39761
+ const [title, setTitle] = useState109("");
39762
+ const [clientTableId, setClientTableId] = useState109(null);
39763
+ const [exposures, setExposures] = useState109({});
39764
+ const [fieldsByTable, setFieldsByTable] = useState109({});
39765
+ const [error, setError] = useState109(null);
39766
+ const [saving, setSaving] = useState109(false);
39767
+ const [savedId, setSavedId] = useState109(portalId ?? null);
39768
+ const [existing, setExisting] = useState109(null);
39769
+ const [loading, setLoading] = useState109(Boolean(portalId));
39770
+ const [inviteEmail, setInviteEmail] = useState109("");
39771
+ const [inviteRecordId, setInviteRecordId] = useState109("");
39772
+ const [inviting, setInviting] = useState109(false);
39773
+ const [invitationSaid, setInvitationSaid] = useState109(null);
39738
39774
  const loadFields = useCallback49(
39739
39775
  async (id, fresh = false) => {
39740
39776
  if (fieldsByTable[id] && !fresh) return;
@@ -39747,7 +39783,7 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
39747
39783
  },
39748
39784
  [client, fieldsByTable]
39749
39785
  );
39750
- useEffect94(() => {
39786
+ useEffect95(() => {
39751
39787
  if (!portalId) return;
39752
39788
  void (async () => {
39753
39789
  const answered = await client.portalCard({ portal_id: portalId });
@@ -39761,7 +39797,7 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
39761
39797
  setClientTableId(answered.data.client_table_id);
39762
39798
  })();
39763
39799
  }, [client, portalId]);
39764
- useEffect94(() => {
39800
+ useEffect95(() => {
39765
39801
  if (!tableId) return;
39766
39802
  setExposures(
39767
39803
  (prev) => prev[tableId] ? prev : {
@@ -39774,7 +39810,7 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
39774
39810
  const cameFromPeople = Boolean(
39775
39811
  tableId && (fieldsByTable[tableId] ?? []).some((f) => editorKindFor(f) === "email")
39776
39812
  );
39777
- useEffect94(() => {
39813
+ useEffect95(() => {
39778
39814
  if (!tableId || portalId || clientTableId !== null || !cameFromPeople) return;
39779
39815
  setClientTableId(tableId);
39780
39816
  setExposures((prev) => {
@@ -39789,7 +39825,7 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
39789
39825
  ),
39790
39826
  [fieldsByTable, clientTableId]
39791
39827
  );
39792
- useEffect94(() => {
39828
+ useEffect95(() => {
39793
39829
  for (const e of Object.values(exposures)) {
39794
39830
  if (!e.on || e.namesVia.trim() !== "") continue;
39795
39831
  const ties = tiesTo(e.tableId);
@@ -39803,7 +39839,7 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
39803
39839
  }));
39804
39840
  if (on) void loadFields(t.id);
39805
39841
  }
39806
- const [linking, setLinking] = useState108(null);
39842
+ const [linking, setLinking] = useState109(null);
39807
39843
  const linkingNow = useRef54(null);
39808
39844
  async function addLinkBack(id) {
39809
39845
  const clients = (tables.data ?? []).find((t) => t.id === clientTableId);
@@ -39832,7 +39868,7 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
39832
39868
  setLinking(null);
39833
39869
  }
39834
39870
  const autoLinked = useRef54(/* @__PURE__ */ new Set());
39835
- useEffect94(() => {
39871
+ useEffect95(() => {
39836
39872
  if (linking !== null || !clientTableId) return;
39837
39873
  for (const e of Object.values(exposures)) {
39838
39874
  if (!e.on || !fieldsByTable[e.tableId] || autoLinked.current.has(e.tableId)) continue;
@@ -40106,7 +40142,7 @@ function clientNoun(table) {
40106
40142
 
40107
40143
  // src/PortalsPanel.tsx
40108
40144
  import { copyText as copyText7 } from "@ai-matrx/kit/clipboard";
40109
- import { useCallback as useCallback50, useEffect as useEffect96, useMemo as useMemo65, useState as useState110 } from "react";
40145
+ import { useCallback as useCallback50, useEffect as useEffect97, useMemo as useMemo65, useState as useState111 } from "react";
40110
40146
  import { useRecordsClient as useRecordsClient78 } from "@ai-matrx/records/react";
40111
40147
  import {
40112
40148
  portalArchiveConsequence,
@@ -40117,7 +40153,7 @@ import {
40117
40153
  import { Badge as Badge22, BasicInput as BasicInput25, Button as Button83, Separator as Separator11, Skeleton as Skeleton23, cn as cn75 } from "@ai-matrx/design-system";
40118
40154
 
40119
40155
  // src/PortalLookEditor.tsx
40120
- import { useEffect as useEffect95, useMemo as useMemo64, useState as useState109 } from "react";
40156
+ import { useEffect as useEffect96, useMemo as useMemo64, useState as useState110 } from "react";
40121
40157
  import { useRecordsClient as useRecordsClient77 } from "@ai-matrx/records/react";
40122
40158
  import { BasicInput as BasicInput24, Button as Button82, cn as cn74 } from "@ai-matrx/design-system";
40123
40159
 
@@ -40194,18 +40230,18 @@ function candidateRows(card, available) {
40194
40230
  function PortalLookEditor({ card, onSaved, className }) {
40195
40231
  const client = useRecordsClient77();
40196
40232
  const stored = card.config?.style ?? {};
40197
- const [name, setName] = useState109(stored.display_name ?? "");
40198
- const [welcome, setWelcome] = useState109(stored.welcome ?? "");
40199
- const [logo, setLogo] = useState109(stored.logo_file_id ?? "");
40200
- const [accent, setAccent] = useState109(stored.accent ?? "");
40201
- const [links, setLinks] = useState109(stored.footer_links ?? []);
40202
- const [forms, setForms] = useState109(null);
40203
- const [busy, setBusy] = useState109(false);
40204
- const [error, setError] = useState109(null);
40205
- const [said2, setSaid] = useState109(null);
40206
- const [formsError, setFormsError] = useState109(null);
40207
- const [formsUnread, setFormsUnread] = useState109(false);
40208
- useEffect95(() => {
40233
+ const [name, setName] = useState110(stored.display_name ?? "");
40234
+ const [welcome, setWelcome] = useState110(stored.welcome ?? "");
40235
+ const [logo, setLogo] = useState110(stored.logo_file_id ?? "");
40236
+ const [accent, setAccent] = useState110(stored.accent ?? "");
40237
+ const [links, setLinks] = useState110(stored.footer_links ?? []);
40238
+ const [forms, setForms] = useState110(null);
40239
+ const [busy, setBusy] = useState110(false);
40240
+ const [error, setError] = useState110(null);
40241
+ const [said2, setSaid] = useState110(null);
40242
+ const [formsError, setFormsError] = useState110(null);
40243
+ const [formsUnread, setFormsUnread] = useState110(false);
40244
+ useEffect96(() => {
40209
40245
  let cancelled = false;
40210
40246
  void (async () => {
40211
40247
  try {
@@ -40451,16 +40487,16 @@ var PORTAL_SUGGESTION = "Let each of my customers sign in and see their own jobs
40451
40487
  function PortalsPanel({ tableId, activePortalId, className }) {
40452
40488
  const client = useRecordsClient78();
40453
40489
  const host = useRecordsUi();
40454
- const [portals, setPortals] = useState110(null);
40455
- const [exposures, setExposures] = useState110([]);
40456
- const [listError, setListError] = useState110(null);
40457
- const [openId, setOpenId] = useState110(activePortalId ?? null);
40458
- useEffect96(() => {
40490
+ const [portals, setPortals] = useState111(null);
40491
+ const [exposures, setExposures] = useState111([]);
40492
+ const [listError, setListError] = useState111(null);
40493
+ const [openId, setOpenId] = useState111(activePortalId ?? null);
40494
+ useEffect97(() => {
40459
40495
  if (activePortalId) setOpenId(activePortalId);
40460
40496
  }, [activePortalId]);
40461
- const [building, setBuilding] = useState110(false);
40462
- const [adding, setAdding] = useState110(null);
40463
- const [archiveToken, setArchiveToken] = useState110(0);
40497
+ const [building, setBuilding] = useState111(false);
40498
+ const [adding, setAdding] = useState111(null);
40499
+ const [archiveToken, setArchiveToken] = useState111(0);
40464
40500
  const load = useCallback50(async () => {
40465
40501
  const [answered, mapped] = await Promise.all([client.portals(), client.portalTables()]);
40466
40502
  if (!answered.ok) {
@@ -40473,7 +40509,7 @@ function PortalsPanel({ tableId, activePortalId, className }) {
40473
40509
  setPortals(answered.data);
40474
40510
  setExposures(mapped.ok ? mapped.data : []);
40475
40511
  }, [client]);
40476
- useEffect96(() => {
40512
+ useEffect97(() => {
40477
40513
  void load();
40478
40514
  }, [load]);
40479
40515
  if (portals === null) return /* @__PURE__ */ jsx133(Skeleton23, { className: cn75("h-32 w-full", className) });
@@ -40630,11 +40666,11 @@ function ArchivePortalControl({
40630
40666
  onArchived
40631
40667
  }) {
40632
40668
  const client = useRecordsClient78();
40633
- const [asking, setAsking] = useState110(false);
40634
- const [typed2, setTyped] = useState110("");
40635
- const [busy, setBusy] = useState110(false);
40636
- const [error, setError] = useState110(null);
40637
- const [said2, setSaid] = useState110(null);
40669
+ const [asking, setAsking] = useState111(false);
40670
+ const [typed2, setTyped] = useState111("");
40671
+ const [busy, setBusy] = useState111(false);
40672
+ const [error, setError] = useState111(null);
40673
+ const [said2, setSaid] = useState111(null);
40638
40674
  const go = async () => {
40639
40675
  setBusy(true);
40640
40676
  setError(null);
@@ -40701,8 +40737,8 @@ function ArchivePortalControl({
40701
40737
  ] });
40702
40738
  }
40703
40739
  function CopyLink({ url, what }) {
40704
- const [copied, setCopied] = useState110(false);
40705
- const [shown4, setShown] = useState110(false);
40740
+ const [copied, setCopied] = useState111(false);
40741
+ const [shown4, setShown] = useState111(false);
40706
40742
  return /* @__PURE__ */ jsxs123(Fragment52, { children: [
40707
40743
  /* @__PURE__ */ jsx133(
40708
40744
  Button83,
@@ -40736,8 +40772,8 @@ function PortalDetail({
40736
40772
  onChanged
40737
40773
  }) {
40738
40774
  const client = useRecordsClient78();
40739
- const [card, setCard] = useState110(null);
40740
- const [error, setError] = useState110(null);
40775
+ const [card, setCard] = useState111(null);
40776
+ const [error, setError] = useState111(null);
40741
40777
  const load = useCallback50(async () => {
40742
40778
  const answered = await client.portalCard({ portal_id: portalId });
40743
40779
  if (!answered.ok) {
@@ -40748,7 +40784,7 @@ function PortalDetail({
40748
40784
  setError(null);
40749
40785
  setCard(answered.data);
40750
40786
  }, [client, portalId]);
40751
- useEffect96(() => {
40787
+ useEffect97(() => {
40752
40788
  void load();
40753
40789
  }, [load]);
40754
40790
  const revoke = useCallback50(
@@ -40865,11 +40901,11 @@ function People({
40865
40901
  origin
40866
40902
  }) {
40867
40903
  const here = origin ?? (typeof window === "undefined" ? "" : window.location.origin);
40868
- const [askingToRevoke, setAskingToRevoke] = useState110(null);
40869
- const [busy, setBusy] = useState110(false);
40870
- const [said2, setSaid] = useState110(null);
40871
- const [error, setError] = useState110(null);
40872
- const [previewing, setPreviewing] = useState110(null);
40904
+ const [askingToRevoke, setAskingToRevoke] = useState111(null);
40905
+ const [busy, setBusy] = useState111(false);
40906
+ const [said2, setSaid] = useState111(null);
40907
+ const [error, setError] = useState111(null);
40908
+ const [previewing, setPreviewing] = useState111(null);
40873
40909
  const revoke = useCallback50(
40874
40910
  async (person) => {
40875
40911
  setBusy(true);
@@ -40953,10 +40989,10 @@ function Preview({
40953
40989
  onPreview
40954
40990
  }) {
40955
40991
  const first = card.tables[0];
40956
- const [which, setWhich] = useState110(first?.table_id ?? null);
40957
- const [rows, setRows] = useState110(null);
40958
- const [error, setError] = useState110(null);
40959
- useEffect96(() => {
40992
+ const [which, setWhich] = useState111(first?.table_id ?? null);
40993
+ const [rows, setRows] = useState111(null);
40994
+ const [error, setError] = useState111(null);
40995
+ useEffect97(() => {
40960
40996
  if (!which) return;
40961
40997
  let cancelled = false;
40962
40998
  setRows(null);
@@ -40994,15 +41030,15 @@ function Preview({
40994
41030
  }
40995
41031
  function Invite({ card, onInvited }) {
40996
41032
  const client = useRecordsClient78();
40997
- const [rows, setRows] = useState110(null);
40998
- const [clientTable, setClientTable] = useState110(null);
40999
- const [search, setSearch] = useState110("");
41000
- const [picked, setPicked] = useState110(null);
41001
- const [email, setEmail] = useState110("");
41002
- const [busy, setBusy] = useState110(false);
41003
- const [said2, setSaid] = useState110(null);
41004
- const [error, setError] = useState110(null);
41005
- useEffect96(() => {
41033
+ const [rows, setRows] = useState111(null);
41034
+ const [clientTable, setClientTable] = useState111(null);
41035
+ const [search, setSearch] = useState111("");
41036
+ const [picked, setPicked] = useState111(null);
41037
+ const [email, setEmail] = useState111("");
41038
+ const [busy, setBusy] = useState111(false);
41039
+ const [said2, setSaid] = useState111(null);
41040
+ const [error, setError] = useState111(null);
41041
+ useEffect97(() => {
41006
41042
  let cancelled = false;
41007
41043
  void client.list({ table_id: card.client_table_id, limit: 200 }).then((answered) => {
41008
41044
  if (cancelled) return;
@@ -41213,13 +41249,13 @@ function FormLookFrame({ look, title, children, contained = false, showOwnerHead
41213
41249
  }
41214
41250
 
41215
41251
  // src/DigestScheduler.tsx
41216
- import { useCallback as useCallback51, useEffect as useEffect97, useMemo as useMemo66, useState as useState111 } from "react";
41252
+ import { useCallback as useCallback51, useEffect as useEffect98, useMemo as useMemo66, useState as useState112 } from "react";
41217
41253
  import { useRecordsClient as useRecordsClient79, useTable as useTable25 } from "@ai-matrx/records/react";
41218
41254
  import { hasQuietHours } from "@ai-matrx/records";
41219
41255
  import { BasicInput as BasicInput26, Button as Button84, Checkbox as Checkbox13, Label as Label20, Separator as Separator12, Skeleton as Skeleton24, cn as cn77 } from "@ai-matrx/design-system";
41220
41256
 
41221
41257
  // src/scheduleWords.ts
41222
- var DAYS2 = {
41258
+ var DAYS3 = {
41223
41259
  mon: "Mondays",
41224
41260
  tue: "Tuesdays",
41225
41261
  wed: "Wednesdays",
@@ -41232,7 +41268,7 @@ function scheduleWords(schedule, tz) {
41232
41268
  const words2 = (schedule ?? "").trim().toLowerCase().split(/\s+/).filter(Boolean);
41233
41269
  if (words2.length === 0) return null;
41234
41270
  const time = words2.find((w) => /^\d{1,2}:\d{2}$/.test(w)) ?? null;
41235
- const day2 = words2.map((w) => DAYS2[w.slice(0, 3)]).find(Boolean) ?? null;
41271
+ const day2 = words2.map((w) => DAYS3[w.slice(0, 3)]).find(Boolean) ?? null;
41236
41272
  const zone2 = tz?.trim() ? `${tz.trim()} time` : "UTC";
41237
41273
  const at = time ? `at ${time.padStart(5, "0")}, ${zone2}` : null;
41238
41274
  return [day2, at].filter(Boolean).join(" ") || null;
@@ -41276,41 +41312,41 @@ function DigestScheduler({
41276
41312
  }) {
41277
41313
  const client = useRecordsClient79();
41278
41314
  const host = useRecordsUi();
41279
- const [views, setViews] = useState111(null);
41280
- const [cadences, setCadences] = useState111([]);
41281
- const [members, setMembers] = useState111(null);
41282
- const [error, setError] = useState111(null);
41315
+ const [views, setViews] = useState112(null);
41316
+ const [cadences, setCadences] = useState112([]);
41317
+ const [members, setMembers] = useState112(null);
41318
+ const [error, setError] = useState112(null);
41283
41319
  const was = scheduleParts(existing?.schedule);
41284
- const [viewId, setViewId] = useState111(
41320
+ const [viewId, setViewId] = useState112(
41285
41321
  existing?.saved_view_id ?? savedViewId ?? ""
41286
41322
  );
41287
- const [name, setName] = useState111(
41323
+ const [name, setName] = useState112(
41288
41324
  existing?.name ?? (subjectName?.trim() ? `${subjectName.trim()} summary` : "")
41289
41325
  );
41290
- const [cadence, setCadence] = useState111(
41326
+ const [cadence, setCadence] = useState112(
41291
41327
  ["hourly", "daily", "weekly"].includes(existing?.cadence ?? "") ? existing.cadence : "weekly"
41292
41328
  );
41293
- const [weekday, setWeekday] = useState111(was.day ?? "monday");
41294
- const [time, setTime] = useState111(was.time ?? "08:00");
41295
- const [timezone, setTimezone] = useState111(() => {
41329
+ const [weekday, setWeekday] = useState112(was.day ?? "monday");
41330
+ const [time, setTime] = useState112(was.time ?? "08:00");
41331
+ const [timezone, setTimezone] = useState112(() => {
41296
41332
  const kept = existing?.quiet_hours?.tz?.trim();
41297
41333
  return kept && kept.toUpperCase() !== "UTC" ? kept : ownTimeZone();
41298
41334
  });
41299
41335
  const table = useTable25(tableId);
41300
41336
  const tableName2 = table.data?.name?.trim() || null;
41301
- const [channel, setChannel] = useState111(
41337
+ const [channel, setChannel] = useState112(
41302
41338
  existing?.channel === "email" || existing?.channel === "sms" ? existing.channel : "in_app"
41303
41339
  );
41304
- const [quiet2, setQuiet] = useState111(hasQuietHours(existing?.quiet_hours));
41305
- const [quietFrom, setQuietFrom] = useState111(existing?.quiet_hours?.start ?? "22:00");
41306
- const [quietTo, setQuietTo] = useState111(existing?.quiet_hours?.end ?? "07:00");
41307
- const [recipients, setRecipients] = useState111(
41340
+ const [quiet2, setQuiet] = useState112(hasQuietHours(existing?.quiet_hours));
41341
+ const [quietFrom, setQuietFrom] = useState112(existing?.quiet_hours?.start ?? "22:00");
41342
+ const [quietTo, setQuietTo] = useState112(existing?.quiet_hours?.end ?? "07:00");
41343
+ const [recipients, setRecipients] = useState112(
41308
41344
  existing?.recipient_user_id ? [existing.recipient_user_id] : []
41309
41345
  );
41310
- const [saving, setSaving] = useState111(false);
41311
- const [outcomes, setOutcomes] = useState111(null);
41312
- const [preview, setPreview] = useState111(null);
41313
- const [previewing, setPreviewing] = useState111(false);
41346
+ const [saving, setSaving] = useState112(false);
41347
+ const [outcomes, setOutcomes] = useState112(null);
41348
+ const [preview, setPreview] = useState112(null);
41349
+ const [previewing, setPreviewing] = useState112(false);
41314
41350
  const load = useCallback51(async () => {
41315
41351
  const [saved, offered] = await Promise.all([
41316
41352
  // The store's own door onto `platform.saved_view`, narrowed in SQL to
@@ -41330,7 +41366,7 @@ function DigestScheduler({
41330
41366
  setMembers([]);
41331
41367
  }
41332
41368
  }, [client, tableId, host]);
41333
- useEffect97(() => {
41369
+ useEffect98(() => {
41334
41370
  void load();
41335
41371
  }, [load]);
41336
41372
  const schedule = useMemo66(() => {
@@ -41585,13 +41621,13 @@ function DigestScheduler({
41585
41621
  }
41586
41622
 
41587
41623
  // src/SubscriptionsPanel.tsx
41588
- import { useCallback as useCallback53, useEffect as useEffect99, useState as useState113 } from "react";
41624
+ import { useCallback as useCallback53, useEffect as useEffect100, useState as useState114 } from "react";
41589
41625
  import { useRecordsClient as useRecordsClient81 } from "@ai-matrx/records/react";
41590
41626
  import { hasQuietHours as hasQuietHours2 } from "@ai-matrx/records";
41591
41627
  import { Badge as Badge23, Button as Button86, Skeleton as Skeleton26, Switch as Switch4, cn as cn79 } from "@ai-matrx/design-system";
41592
41628
 
41593
41629
  // src/WebhooksPanel.tsx
41594
- import { useCallback as useCallback52, useEffect as useEffect98, useState as useState112 } from "react";
41630
+ import { useCallback as useCallback52, useEffect as useEffect99, useState as useState113 } from "react";
41595
41631
  import { useRecordsClient as useRecordsClient80, useTable as useTable26 } from "@ai-matrx/records/react";
41596
41632
  import { BasicInput as BasicInput27, Button as Button85, Checkbox as Checkbox14, ConfirmDialog as ConfirmDialog7, Label as Label21, Skeleton as Skeleton25, cn as cn78 } from "@ai-matrx/design-system";
41597
41633
  import { jsx as jsx136, jsxs as jsxs126 } from "react/jsx-runtime";
@@ -41615,16 +41651,16 @@ function WebhooksPanel({ tableId, className }) {
41615
41651
  const client = useRecordsClient80();
41616
41652
  const table = useTable26(tableId);
41617
41653
  const rights = useTableRights(table.data);
41618
- const [hooks, setHooks] = useState112(null);
41619
- const [error, setError] = useState112(null);
41620
- const [adding, setAdding] = useState112(false);
41621
- const [url, setUrl] = useState112("");
41622
- const [description, setDescription] = useState112("");
41623
- const [events, setEvents] = useState112(DEFAULT_EVENTS);
41624
- const [busy, setBusy] = useState112(false);
41625
- const [declared2, setDeclared] = useState112(null);
41626
- const [stopping, setStopping] = useState112(null);
41627
- const [readRefused, setReadRefused] = useState112(null);
41654
+ const [hooks, setHooks] = useState113(null);
41655
+ const [error, setError] = useState113(null);
41656
+ const [adding, setAdding] = useState113(false);
41657
+ const [url, setUrl] = useState113("");
41658
+ const [description, setDescription] = useState113("");
41659
+ const [events, setEvents] = useState113(DEFAULT_EVENTS);
41660
+ const [busy, setBusy] = useState113(false);
41661
+ const [declared2, setDeclared] = useState113(null);
41662
+ const [stopping, setStopping] = useState113(null);
41663
+ const [readRefused, setReadRefused] = useState113(null);
41628
41664
  const load = useCallback52(async () => {
41629
41665
  const answered = await client.tableWebhooks({ table_id: tableId });
41630
41666
  if (!answered.ok) {
@@ -41637,7 +41673,7 @@ function WebhooksPanel({ tableId, className }) {
41637
41673
  setError(null);
41638
41674
  setHooks(answered.data ?? []);
41639
41675
  }, [client, tableId]);
41640
- useEffect98(() => {
41676
+ useEffect99(() => {
41641
41677
  void load();
41642
41678
  }, [load]);
41643
41679
  const declare2 = async () => {
@@ -41808,12 +41844,12 @@ var CHANNEL_WORDS2 = SUBSCRIPTION_CHANNEL_LABEL;
41808
41844
  var DIGEST_SUGGESTION = "Email me a summary of this every Monday at 8 in the morning.";
41809
41845
  function SubscriptionsPanel({ tableId, activeRuleId, className }) {
41810
41846
  const client = useRecordsClient81();
41811
- const [rows, setRows] = useState113(null);
41812
- const [error, setError] = useState113(null);
41813
- const [busy, setBusy] = useState113(null);
41814
- const [preview, setPreview] = useState113(null);
41815
- const [scheduling, setScheduling] = useState113(false);
41816
- const [changing, setChanging] = useState113(null);
41847
+ const [rows, setRows] = useState114(null);
41848
+ const [error, setError] = useState114(null);
41849
+ const [busy, setBusy] = useState114(null);
41850
+ const [preview, setPreview] = useState114(null);
41851
+ const [scheduling, setScheduling] = useState114(false);
41852
+ const [changing, setChanging] = useState114(null);
41817
41853
  const host = useRecordsUi();
41818
41854
  const load = useCallback53(async () => {
41819
41855
  const answered = await client.subscriptions({ table_id: tableId });
@@ -41825,7 +41861,7 @@ function SubscriptionsPanel({ tableId, activeRuleId, className }) {
41825
41861
  setError(null);
41826
41862
  setRows(answered.data);
41827
41863
  }, [client, tableId]);
41828
- useEffect99(() => {
41864
+ useEffect100(() => {
41829
41865
  void load();
41830
41866
  }, [load]);
41831
41867
  const flip = useCallback53(
@@ -42016,7 +42052,7 @@ function SubscriptionsPanel({ tableId, activeRuleId, className }) {
42016
42052
  // src/FormBuilder.tsx
42017
42053
  import { copyText as copyText8 } from "@ai-matrx/kit/clipboard";
42018
42054
  import { ErrorBox as ErrorBox7 } from "@ai-matrx/design-system";
42019
- import { useCallback as useCallback55, useEffect as useEffect101, useMemo as useMemo68, useRef as useRef56, useState as useState116 } from "react";
42055
+ import { useCallback as useCallback55, useEffect as useEffect102, useMemo as useMemo68, useRef as useRef56, useState as useState117 } from "react";
42020
42056
  import { DndContext, KeyboardSensor, PointerSensor, closestCenter, useSensor, useSensors } from "@dnd-kit/core";
42021
42057
  import { SortableContext, arrayMove, sortableKeyboardCoordinates, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";
42022
42058
  import { CSS as CSS2 } from "@dnd-kit/utilities";
@@ -42033,7 +42069,7 @@ import {
42033
42069
  } from "@ai-matrx/design-system";
42034
42070
 
42035
42071
  // src/FormFlowEditor.tsx
42036
- import { useState as useState114 } from "react";
42072
+ import { useState as useState115 } from "react";
42037
42073
  import {
42038
42074
  BasicInput as BasicInput28,
42039
42075
  BasicTextarea as BasicTextarea10,
@@ -42142,7 +42178,7 @@ function QuestionLogic({
42142
42178
  const choiceFields = field2 && isChoiceField(field2) ? [field2] : [];
42143
42179
  const options = useChoiceOptions(choiceFields, choiceFields.map((f) => f.key));
42144
42180
  const choices = field2 ? (options.get(field2.key) ?? []).map((o) => ({ key: o.key, label: o.label })) : [];
42145
- const [answer, setAnswer] = useState114("");
42181
+ const [answer, setAnswer] = useState115("");
42146
42182
  const setJump = (i, part) => onChange({ jumps: jumps.map((j, k) => k === i ? { ...j, ...part } : j) });
42147
42183
  return /* @__PURE__ */ jsxs128("div", { className: "col-span-2 flex flex-col gap-1.5 text-xs", "data-records-form-logic": question.field, children: [
42148
42184
  jumps.map((jump, i) => /* @__PURE__ */ jsxs128("div", { className: "flex flex-col gap-1 rounded border border-dashed p-1.5", "data-records-form-jump": "", children: [
@@ -42212,7 +42248,7 @@ function parseHiddenFields(line) {
42212
42248
  return out;
42213
42249
  }
42214
42250
  function HiddenFieldsEditor({ value, onChange }) {
42215
- const [line, setLine] = useState114(value.join(", "));
42251
+ const [line, setLine] = useState115(value.join(", "));
42216
42252
  return /* @__PURE__ */ jsxs128("label", { className: "flex flex-col gap-1", "data-records-form-hidden-editor": "", children: [
42217
42253
  /* @__PURE__ */ jsx138(Label22, { className: "text-xs font-medium", children: "Hidden fields" }),
42218
42254
  /* @__PURE__ */ jsx138(
@@ -42263,8 +42299,8 @@ function ThemeEditor({
42263
42299
  var EMBED_LABELS = { inline: "Inline", popup: "Popup", slider: "Slider" };
42264
42300
  function EmbedSnippets({ url, label }) {
42265
42301
  const { copyText: copyText16 } = useClipboard();
42266
- const [kind, setKind] = useState114("inline");
42267
- const [copied, setCopied] = useState114(false);
42302
+ const [kind, setKind] = useState115("inline");
42303
+ const [copied, setCopied] = useState115(false);
42268
42304
  const snippet = formEmbedSnippet(kind, url, { label });
42269
42305
  return /* @__PURE__ */ jsxs128("section", { className: "flex flex-col gap-1.5 rounded border px-2.5 py-2", "aria-label": "Embed", "data-records-form-embed": "", children: [
42270
42306
  /* @__PURE__ */ jsxs128("div", { className: "flex items-center gap-2", children: [
@@ -42289,8 +42325,8 @@ function EmbedSnippets({ url, label }) {
42289
42325
  }
42290
42326
 
42291
42327
  // src/FormRunner.tsx
42292
- import { useCallback as useCallback54, useEffect as useEffect100, useMemo as useMemo67, useRef as useRef55, useState as useState115 } from "react";
42293
- import { useFields as useFields24, useOptionalRecordsClient as useOptionalRecordsClient18 } from "@ai-matrx/records/react";
42328
+ import { useCallback as useCallback54, useEffect as useEffect101, useMemo as useMemo67, useRef as useRef55, useState as useState116 } from "react";
42329
+ import { useFields as useFields24, useOptionalRecordsClient as useOptionalRecordsClient19 } from "@ai-matrx/records/react";
42294
42330
  import { Button as Button88, Label as Label23, Progress, Skeleton as Skeleton27, cn as cn80, formThemeClasses } from "@ai-matrx/design-system";
42295
42331
  import { answerRefusal, formRoutes, pipeAnswers, submissionStamp } from "@ai-matrx/records/forms";
42296
42332
  import { humanizeIdentifier as humanizeIdentifier18 } from "@ai-matrx/kit/text-case";
@@ -42305,7 +42341,7 @@ function FormRunner(props) {
42305
42341
  return /* @__PURE__ */ jsx139(ConnectedFormRunner, { ...props });
42306
42342
  }
42307
42343
  function ConnectedFormRunner(props) {
42308
- const client = useOptionalRecordsClient18();
42344
+ const client = useOptionalRecordsClient19();
42309
42345
  const fields = useFields24(props.form.subject);
42310
42346
  const { form, className } = props;
42311
42347
  const submit = useCallback54(
@@ -42395,18 +42431,18 @@ function FormStage({
42395
42431
  autoAdvance
42396
42432
  }) {
42397
42433
  const host = useRecordsUi();
42398
- const [answers, setAnswers] = useState115(() => ({ ...initialAnswers ?? {} }));
42399
- const [at, setAt] = useState115(0);
42400
- const [error, setError] = useState115(null);
42401
- const [refusal3, setRefusal] = useState115(null);
42402
- const [writing, setWriting] = useState115(false);
42403
- const [done, setDone] = useState115(null);
42404
- const [hidden, setHidden] = useState115({});
42405
- const [ending, setEnding] = useState115(null);
42406
- const [started, setStarted] = useState115(() => !form.welcome || resumed);
42434
+ const [answers, setAnswers] = useState116(() => ({ ...initialAnswers ?? {} }));
42435
+ const [at, setAt] = useState116(0);
42436
+ const [error, setError] = useState116(null);
42437
+ const [refusal3, setRefusal] = useState116(null);
42438
+ const [writing, setWriting] = useState116(false);
42439
+ const [done, setDone] = useState116(null);
42440
+ const [hidden, setHidden] = useState116({});
42441
+ const [ending, setEnding] = useState116(null);
42442
+ const [started, setStarted] = useState116(() => !form.welcome || resumed);
42407
42443
  const routes = formRoutes(form);
42408
- const [routeKnown, setRouteKnown] = useState115(() => !routes || !whichAsked);
42409
- const [stopped, setStopped] = useState115(null);
42444
+ const [routeKnown, setRouteKnown] = useState116(() => !routes || !whichAsked);
42445
+ const [stopped, setStopped] = useState116(null);
42410
42446
  const answersRef = useRef55(answers);
42411
42447
  answersRef.current = answers;
42412
42448
  const choose = autoAdvance ?? form.autoAdvance ?? true;
@@ -42429,7 +42465,7 @@ function FormStage({
42429
42465
  };
42430
42466
  });
42431
42467
  }, [fields, form.questions]);
42432
- useEffect100(() => {
42468
+ useEffect101(() => {
42433
42469
  if (!whichAsked) return;
42434
42470
  if (!routes) return;
42435
42471
  let cancelled = false;
@@ -42453,9 +42489,9 @@ function FormStage({
42453
42489
  }
42454
42490
  const next = {};
42455
42491
  let said2 = null;
42456
- for (const ask of told2.asks) {
42457
- next[ask.field] = ask.asked === false;
42458
- if (ask.said && !said2) said2 = ask.said;
42492
+ for (const ask2 of told2.asks) {
42493
+ next[ask2.field] = ask2.asked === false;
42494
+ if (ask2.said && !said2) said2 = ask2.said;
42459
42495
  }
42460
42496
  setHidden(next);
42461
42497
  setEnding(told2.ending ?? null);
@@ -42475,7 +42511,7 @@ function FormStage({
42475
42511
  }, [whichAsked, questions, answers]);
42476
42512
  const live = questions.filter((q) => !hidden[q.key]);
42477
42513
  const told = useRef55(answers);
42478
- useEffect100(() => {
42514
+ useEffect101(() => {
42479
42515
  if (told.current === answers) return;
42480
42516
  told.current = answers;
42481
42517
  onAnswersChange?.(answers);
@@ -42486,7 +42522,7 @@ function FormStage({
42486
42522
  return v === void 0 || v === null || v === "";
42487
42523
  })?.key ?? null : null
42488
42524
  );
42489
- useEffect100(() => {
42525
+ useEffect101(() => {
42490
42526
  const key = resumeAt.current;
42491
42527
  if (!key) return;
42492
42528
  const i = live.findIndex((q) => q.key === key);
@@ -42581,7 +42617,7 @@ function FormStage({
42581
42617
  return;
42582
42618
  }
42583
42619
  const next = {};
42584
- for (const ask of told2.asks) next[ask.field] = ask.asked === false;
42620
+ for (const ask2 of told2.asks) next[ask2.field] = ask2.asked === false;
42585
42621
  setHidden(next);
42586
42622
  setEnding(told2.ending ?? null);
42587
42623
  const onRoute = questions.filter((q) => !next[q.key]);
@@ -42595,9 +42631,9 @@ function FormStage({
42595
42631
  else void submit();
42596
42632
  }
42597
42633
  const routing = useRef55(false);
42598
- const [routingNow, setRoutingNow] = useState115(false);
42634
+ const [routingNow, setRoutingNow] = useState116(false);
42599
42635
  const typedAhead = useRef55("");
42600
- useEffect100(() => {
42636
+ useEffect101(() => {
42601
42637
  if (!routingNow) return;
42602
42638
  const hold = (event) => {
42603
42639
  if (!routing.current || event.metaKey || event.ctrlKey || event.altKey || event.isComposing) return;
@@ -42627,7 +42663,7 @@ function FormStage({
42627
42663
  }
42628
42664
  for (const key of held) target.dispatchEvent(new KeyboardEvent("keydown", { key, bubbles: true, cancelable: true }));
42629
42665
  }, [live, at]);
42630
- useEffect100(() => {
42666
+ useEffect101(() => {
42631
42667
  if (!routingNow) pourTypedAhead();
42632
42668
  }, [routingNow, at, pourTypedAhead]);
42633
42669
  const advanceRef = useRef55(advance);
@@ -42652,7 +42688,7 @@ function FormStage({
42652
42688
  if (event.shiftKey) retreat();
42653
42689
  else advance();
42654
42690
  }
42655
- useEffect100(() => {
42691
+ useEffect101(() => {
42656
42692
  const input = stage.current?.querySelector("[role='radio'][aria-checked='true']") ?? stage.current?.querySelector(
42657
42693
  "input:not([tabindex='-1']), textarea, select, [role='combobox'], [role='radio'], [role='checkbox']"
42658
42694
  );
@@ -42660,7 +42696,7 @@ function FormStage({
42660
42696
  pourTypedAhead();
42661
42697
  }, [index, done, started]);
42662
42698
  const startTold = useRef55(false);
42663
- useEffect100(() => {
42699
+ useEffect101(() => {
42664
42700
  if (startTold.current || !onStart) return;
42665
42701
  if (Object.values(answers).some((v) => v !== void 0 && v !== null && v !== "")) {
42666
42702
  startTold.current = true;
@@ -42668,7 +42704,7 @@ function FormStage({
42668
42704
  }
42669
42705
  }, [answers, onStart]);
42670
42706
  const shownTold = useRef55(/* @__PURE__ */ new Set());
42671
- useEffect100(() => {
42707
+ useEffect101(() => {
42672
42708
  if (!onQuestionShown || !started || done) return;
42673
42709
  for (const q of oneAtATime ? current ? [current] : [] : live) {
42674
42710
  if (shownTold.current.has(q.key)) continue;
@@ -42852,7 +42888,7 @@ function ThankYou({
42852
42888
  const title = rawTitle ? pipe(rawTitle) : rawTitle;
42853
42889
  const body = rawBody ? pipe(rawBody) : rawBody;
42854
42890
  const going = redirect !== null && done !== "preview";
42855
- useEffect100(() => {
42891
+ useEffect101(() => {
42856
42892
  if (!going || !redirect) return;
42857
42893
  const timer = window.setTimeout(() => window.location.assign(redirect), REDIRECT_AFTER_MS);
42858
42894
  return () => window.clearTimeout(timer);
@@ -42902,7 +42938,7 @@ function Question({
42902
42938
  upload
42903
42939
  }) {
42904
42940
  const host = useRecordsUi();
42905
- const [uploadError, setUploadError] = useState115(null);
42941
+ const [uploadError, setUploadError] = useState116(null);
42906
42942
  const field2 = question.field;
42907
42943
  if (!field2) return null;
42908
42944
  const id = `form-${field2.key}`;
@@ -43036,24 +43072,24 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, startWithOne,
43036
43072
  const table = useTable27(tableId);
43037
43073
  const rights = useTableRights(table.data);
43038
43074
  const fields = useFields25(tableId);
43039
- const [forms, setForms] = useState116(null);
43040
- const [error, setError] = useState116(null);
43041
- const [refused, setRefused] = useState116(null);
43042
- const [activeId, setActiveId] = useState116(activeFormId ?? null);
43043
- const [draft, setDraft] = useState116(null);
43044
- const [saving, setSaving] = useState116(false);
43045
- const [saved, setSaved] = useState116(null);
43046
- const [publishing, setPublishing] = useState116(false);
43047
- const [copied, setCopied] = useState116(false);
43048
- const [shownUrl, setShownUrl] = useState116(null);
43049
- const [lookOptions, setLookOptions] = useState116(null);
43050
- const [lookUnread, setLookUnread] = useState116(null);
43051
- const [orgKnobs, setOrgKnobs] = useState116(null);
43052
- const [restoredAt, setRestoredAt] = useState116(null);
43053
- const [showResults, setShowResults] = useState116(false);
43054
- const [adding, setAdding] = useState116(false);
43075
+ const [forms, setForms] = useState117(null);
43076
+ const [error, setError] = useState117(null);
43077
+ const [refused, setRefused] = useState117(null);
43078
+ const [activeId, setActiveId] = useState117(activeFormId ?? null);
43079
+ const [draft, setDraft] = useState117(null);
43080
+ const [saving, setSaving] = useState117(false);
43081
+ const [saved, setSaved] = useState117(null);
43082
+ const [publishing, setPublishing] = useState117(false);
43083
+ const [copied, setCopied] = useState117(false);
43084
+ const [shownUrl, setShownUrl] = useState117(null);
43085
+ const [lookOptions, setLookOptions] = useState117(null);
43086
+ const [lookUnread, setLookUnread] = useState117(null);
43087
+ const [orgKnobs, setOrgKnobs] = useState117(null);
43088
+ const [restoredAt, setRestoredAt] = useState117(null);
43089
+ const [showResults, setShowResults] = useState117(false);
43090
+ const [adding, setAdding] = useState117(false);
43055
43091
  const keysBeforeAdd = useRef56(null);
43056
- const [makeOnMount, setMakeOnMount] = useState116("waiting");
43092
+ const [makeOnMount, setMakeOnMount] = useState117("waiting");
43057
43093
  const publicOrigin = host.publicOrigin ?? (typeof window === "undefined" ? "" : window.location.origin);
43058
43094
  const load = useCallback55(async () => {
43059
43095
  const answered = await client.forms({ table_id: tableId });
@@ -43082,10 +43118,10 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, startWithOne,
43082
43118
  setError(null);
43083
43119
  setForms(mine);
43084
43120
  }, [client, tableId, seed, claimSeed]);
43085
- useEffect101(() => {
43121
+ useEffect102(() => {
43086
43122
  void load();
43087
43123
  }, [load]);
43088
- useEffect101(() => {
43124
+ useEffect102(() => {
43089
43125
  let cancelled = false;
43090
43126
  Promise.resolve().then(() => client.formKnobs()).then((r) => {
43091
43127
  if (!cancelled && r.ok) setOrgKnobs(r.data);
@@ -43094,7 +43130,7 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, startWithOne,
43094
43130
  cancelled = true;
43095
43131
  };
43096
43132
  }, [client]);
43097
- useEffect101(() => {
43133
+ useEffect102(() => {
43098
43134
  if (!forms || forms.length === 0) return;
43099
43135
  if (createOnMount && makeOnMount !== "made") return;
43100
43136
  const chosen = forms.find((f) => f.id === (activeFormId ?? activeId)) ?? forms[0];
@@ -43118,7 +43154,7 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, startWithOne,
43118
43154
  );
43119
43155
  const stored = useMemo68(() => draft ? (forms ?? []).find((f) => f.id === draft.id) ?? null : null, [draft, forms]);
43120
43156
  const dirty = Boolean(draft && stored && !sameForm(draft, stored));
43121
- useEffect101(() => {
43157
+ useEffect102(() => {
43122
43158
  if (!draft || !stored) return;
43123
43159
  const timer = window.setTimeout(() => {
43124
43160
  if (sameForm(draft, stored)) dropKeptDraft(draft.id);
@@ -43127,7 +43163,7 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, startWithOne,
43127
43163
  return () => window.clearTimeout(timer);
43128
43164
  }, [draft, stored]);
43129
43165
  const lookKey = draft ? JSON.stringify(formLookDocument(draft.look ?? null)) : null;
43130
- useEffect101(() => {
43166
+ useEffect102(() => {
43131
43167
  if (lookKey === null) return;
43132
43168
  let cancelled = false;
43133
43169
  const timer = window.setTimeout(() => {
@@ -43144,7 +43180,7 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, startWithOne,
43144
43180
  window.clearTimeout(timer);
43145
43181
  };
43146
43182
  }, [client, lookKey]);
43147
- useEffect101(() => {
43183
+ useEffect102(() => {
43148
43184
  const before = keysBeforeAdd.current;
43149
43185
  if (!before || !fields.data) return;
43150
43186
  const made = askableFields(fields.data).filter((f) => !before.has(f.key));
@@ -43241,10 +43277,10 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, startWithOne,
43241
43277
  await load();
43242
43278
  }
43243
43279
  async function create(name) {
43244
- const ask = askableFields(fields.data ?? []);
43245
- if (ask.length === 0) return false;
43280
+ const ask2 = askableFields(fields.data ?? []);
43281
+ if (ask2.length === 0) return false;
43246
43282
  const written = await client.formDeclare(
43247
- formDeclareArgs({ name, subject: tableId, questions: ask.map((f) => ({ field: f.key })) })
43283
+ formDeclareArgs({ name, subject: tableId, questions: ask2.map((f) => ({ field: f.key })) })
43248
43284
  );
43249
43285
  if (!written.ok) {
43250
43286
  setRefused(written.error);
@@ -43254,15 +43290,15 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, startWithOne,
43254
43290
  await load();
43255
43291
  return true;
43256
43292
  }
43257
- const [started, setStarted] = useState116(false);
43258
- useEffect101(() => {
43293
+ const [started, setStarted] = useState117(false);
43294
+ useEffect102(() => {
43259
43295
  if (!startWithOne || started || forms === null || forms.length > 0) return;
43260
43296
  if (askableFields(fields.data ?? []).length === 0) return;
43261
43297
  if (!table.data && !table.error) return;
43262
43298
  setStarted(true);
43263
43299
  void create(table.data?.name?.trim() ? `${table.data.name.trim()} form` : "Form 1");
43264
43300
  }, [startWithOne, started, forms, fields.data, create, table.data, table.error]);
43265
- useEffect101(() => {
43301
+ useEffect102(() => {
43266
43302
  if (!createOnMount || makeOnMount !== "waiting" || forms === null) return;
43267
43303
  if (!table.data && !table.error) return;
43268
43304
  if (askableFields(fields.data ?? []).length === 0) {
@@ -43682,7 +43718,7 @@ function QuestionList({
43682
43718
  );
43683
43719
  const askable = askableFields([...fields]);
43684
43720
  const unasked = askable.filter((f) => !draft.questions.some((q) => q.field === f.key));
43685
- const asked2 = draft.questions.map((q) => byKey.get(q.field)).filter((f) => Boolean(f)).map((f) => ({ id: String(f.id), key: f.key, label: draft.questions.find((q) => q.field === f.key)?.ask || fieldName(f), field: f }));
43721
+ const asked3 = draft.questions.map((q) => byKey.get(q.field)).filter((f) => Boolean(f)).map((f) => ({ id: String(f.id), key: f.key, label: draft.questions.find((q) => q.field === f.key)?.ask || fieldName(f), field: f }));
43686
43722
  const label = (key) => {
43687
43723
  const f = byKey.get(key);
43688
43724
  return draft.questions.find((q) => q.field === key)?.ask || (f ? fieldName(f) : key);
@@ -43707,8 +43743,8 @@ function QuestionList({
43707
43743
  question,
43708
43744
  field: byKey.get(question.field) ?? null,
43709
43745
  draft,
43710
- conditionFields: asked2.filter((f) => f.key !== question.field),
43711
- jumpFields: asked2,
43746
+ conditionFields: asked3.filter((f) => f.key !== question.field),
43747
+ jumpFields: asked3,
43712
43748
  label,
43713
43749
  onChange: (change) => onQuestion(index, change),
43714
43750
  onRemove: () => onQuestions(draft.questions.filter((q) => q.field !== question.field))
@@ -43754,7 +43790,7 @@ function QuestionRow({
43754
43790
  onRemove
43755
43791
  }) {
43756
43792
  const sortable = useSortable({ id: question.field });
43757
- const [open, setOpen] = useState116(true);
43793
+ const [open, setOpen] = useState117(true);
43758
43794
  const name = field2 ? fieldName(field2) : question.field;
43759
43795
  return /* @__PURE__ */ jsxs130(
43760
43796
  "div",
@@ -43848,13 +43884,13 @@ function NotifyOnAnswer({
43848
43884
  onNotify
43849
43885
  }) {
43850
43886
  const client = useRecordsClient82();
43851
- const [subs, setSubs] = useState116(null);
43852
- const [busy, setBusy] = useState116(false);
43853
- const [error, setError] = useState116(null);
43854
- const [said2, setSaid] = useState116(null);
43855
- const [url, setUrl] = useState116(notify?.webhookUrl ?? "");
43856
- useEffect101(() => setUrl(notify?.webhookUrl ?? ""), [notify?.webhookUrl]);
43857
- useEffect101(() => {
43887
+ const [subs, setSubs] = useState117(null);
43888
+ const [busy, setBusy] = useState117(false);
43889
+ const [error, setError] = useState117(null);
43890
+ const [said2, setSaid] = useState117(null);
43891
+ const [url, setUrl] = useState117(notify?.webhookUrl ?? "");
43892
+ useEffect102(() => setUrl(notify?.webhookUrl ?? ""), [notify?.webhookUrl]);
43893
+ useEffect102(() => {
43858
43894
  let cancelled = false;
43859
43895
  void client.subscriptions({ table_id: tableId }).then((r) => {
43860
43896
  if (!cancelled && r.ok) setSubs(r.data);
@@ -43985,7 +44021,7 @@ function NotifyOnAnswer({
43985
44021
  }
43986
44022
 
43987
44023
  // src/DocTemplate.tsx
43988
- import { useCallback as useCallback56, useEffect as useEffect102, useState as useState117 } from "react";
44024
+ import { useCallback as useCallback56, useEffect as useEffect103, useState as useState118 } from "react";
43989
44025
  import { useFields as useFields26, useRecordsClient as useRecordsClient83, useTable as useTable28 } from "@ai-matrx/records/react";
43990
44026
  import { BasicInput as BasicInput30, BasicTextarea as BasicTextarea12, Button as Button90, Label as Label25, Skeleton as Skeleton29, cn as cn82 } from "@ai-matrx/design-system";
43991
44027
  import { jsx as jsx141, jsxs as jsxs131 } from "react/jsx-runtime";
@@ -43995,13 +44031,13 @@ function DocTemplate({ tableId, seed, activeTemplateId, onActiveTemplate, classN
43995
44031
  const table = useTable28(tableId);
43996
44032
  const rights = useTableRights(table.data);
43997
44033
  const fields = useFields26(tableId);
43998
- const [templates, setTemplates] = useState117(null);
43999
- const [error, setError] = useState117(null);
44000
- const [activeId, setActiveId] = useState117(activeTemplateId ?? null);
44001
- const [draftName, setDraftName] = useState117("");
44002
- const [draftBody, setDraftBody] = useState117("");
44003
- const [unresolved, setUnresolved] = useState117([]);
44004
- const [saving, setSaving] = useState117(false);
44034
+ const [templates, setTemplates] = useState118(null);
44035
+ const [error, setError] = useState118(null);
44036
+ const [activeId, setActiveId] = useState118(activeTemplateId ?? null);
44037
+ const [draftName, setDraftName] = useState118("");
44038
+ const [draftBody, setDraftBody] = useState118("");
44039
+ const [unresolved, setUnresolved] = useState118([]);
44040
+ const [saving, setSaving] = useState118(false);
44005
44041
  const load = useCallback56(async () => {
44006
44042
  const held = await client.docTemplates({ table_id: tableId });
44007
44043
  if (!held.ok) {
@@ -44033,10 +44069,10 @@ function DocTemplate({ tableId, seed, activeTemplateId, onActiveTemplate, classN
44033
44069
  setError(null);
44034
44070
  setTemplates(rows);
44035
44071
  }, [client, tableId, seed, fields.data]);
44036
- useEffect102(() => {
44072
+ useEffect103(() => {
44037
44073
  void load();
44038
44074
  }, [load]);
44039
- useEffect102(() => {
44075
+ useEffect103(() => {
44040
44076
  if (!templates || templates.length === 0) return;
44041
44077
  const chosen = templates.find((t) => t.id === (activeTemplateId ?? activeId)) ?? templates[0];
44042
44078
  if (chosen.id !== activeId) setActiveId(chosen.id);
@@ -44044,7 +44080,7 @@ function DocTemplate({ tableId, seed, activeTemplateId, onActiveTemplate, classN
44044
44080
  setDraftBody(chosen.body);
44045
44081
  onActiveTemplate?.(chosen);
44046
44082
  }, [templates, activeTemplateId]);
44047
- useEffect102(() => {
44083
+ useEffect103(() => {
44048
44084
  let cancelled = false;
44049
44085
  if (draftBody.trim() === "") {
44050
44086
  setUnresolved([]);
@@ -44169,17 +44205,17 @@ function DocTemplate({ tableId, seed, activeTemplateId, onActiveTemplate, classN
44169
44205
  }
44170
44206
 
44171
44207
  // src/DocRender.tsx
44172
- import { useCallback as useCallback57, useEffect as useEffect103, useRef as useRef57, useState as useState118 } from "react";
44208
+ import { useCallback as useCallback57, useEffect as useEffect104, useRef as useRef57, useState as useState119 } from "react";
44173
44209
  import { useRecordsClient as useRecordsClient84 } from "@ai-matrx/records/react";
44174
44210
  import { Button as Button91, Skeleton as Skeleton30, cn as cn83 } from "@ai-matrx/design-system";
44175
44211
  import { jsx as jsx142, jsxs as jsxs132 } from "react/jsx-runtime";
44176
44212
  function DocRender({ templateId, recordId, filename, onRendered, className }) {
44177
44213
  const client = useRecordsClient84();
44178
- const [preview, setPreview] = useState118(null);
44179
- const [renders, setRenders] = useState118(null);
44180
- const [showing, setShowing] = useState118(null);
44181
- const [error, setError] = useState118(null);
44182
- const [busy, setBusy] = useState118(null);
44214
+ const [preview, setPreview] = useState119(null);
44215
+ const [renders, setRenders] = useState119(null);
44216
+ const [showing, setShowing] = useState119(null);
44217
+ const [error, setError] = useState119(null);
44218
+ const [busy, setBusy] = useState119(null);
44183
44219
  const paper = useRef57(null);
44184
44220
  const load = useCallback57(async () => {
44185
44221
  const [body, held] = await Promise.all([
@@ -44198,7 +44234,7 @@ function DocRender({ templateId, recordId, filename, onRendered, className }) {
44198
44234
  setPreview(body.data);
44199
44235
  setRenders(held.data.filter((r) => r.template_id === templateId));
44200
44236
  }, [client, templateId, recordId]);
44201
- useEffect103(() => {
44237
+ useEffect104(() => {
44202
44238
  void load();
44203
44239
  }, [load]);
44204
44240
  async function freeze() {
@@ -44285,7 +44321,7 @@ function DocRender({ templateId, recordId, filename, onRendered, className }) {
44285
44321
  }
44286
44322
 
44287
44323
  // src/SignBlock.tsx
44288
- import { useCallback as useCallback58, useEffect as useEffect104, useState as useState119 } from "react";
44324
+ import { useCallback as useCallback58, useEffect as useEffect105, useState as useState120 } from "react";
44289
44325
  import { useFields as useFields27, useRecordsClient as useRecordsClient85 } from "@ai-matrx/records/react";
44290
44326
  import { BasicInput as BasicInput31, Button as Button92, Skeleton as Skeleton31, cn as cn84 } from "@ai-matrx/design-system";
44291
44327
  import { useTable as useTable29 } from "@ai-matrx/records/react";
@@ -44295,11 +44331,11 @@ function SignBlock({ tableId, recordId, render, className }) {
44295
44331
  const table = useTable29(tableId);
44296
44332
  const rights = useTableRights(table.data);
44297
44333
  const fields = useFields27(tableId);
44298
- const [signatures, setSignatures] = useState119(null);
44299
- const [verdicts, setVerdicts] = useState119({});
44300
- const [error, setError] = useState119(null);
44301
- const [name, setName] = useState119("");
44302
- const [busy, setBusy] = useState119(false);
44334
+ const [signatures, setSignatures] = useState120(null);
44335
+ const [verdicts, setVerdicts] = useState120({});
44336
+ const [error, setError] = useState120(null);
44337
+ const [name, setName] = useState120("");
44338
+ const [busy, setBusy] = useState120(false);
44303
44339
  const load = useCallback58(async () => {
44304
44340
  const held = await client.docSignatures({ record_id: recordId });
44305
44341
  if (!held.ok) {
@@ -44315,7 +44351,7 @@ function SignBlock({ tableId, recordId, render, className }) {
44315
44351
  }
44316
44352
  setVerdicts(answers);
44317
44353
  }, [client, recordId]);
44318
- useEffect104(() => {
44354
+ useEffect105(() => {
44319
44355
  void load();
44320
44356
  }, [load]);
44321
44357
  async function sign(field2) {
@@ -44436,7 +44472,7 @@ function SignBlock({ tableId, recordId, render, className }) {
44436
44472
  }
44437
44473
 
44438
44474
  // src/NotifyRuleEditor.tsx
44439
- import { useCallback as useCallback59, useEffect as useEffect105, useState as useState120 } from "react";
44475
+ import { useCallback as useCallback59, useEffect as useEffect106, useState as useState121 } from "react";
44440
44476
  import { useRecordsClient as useRecordsClient86, useTable as useTable30 } from "@ai-matrx/records/react";
44441
44477
  import { hasQuietHours as hasQuietHours3 } from "@ai-matrx/records";
44442
44478
  import { Button as Button93, Skeleton as Skeleton32, cn as cn85 } from "@ai-matrx/design-system";
@@ -44448,12 +44484,12 @@ function NotifyRuleEditor({ tableId, seed, chosenRuleId, onChoose, className })
44448
44484
  const host = useRecordsUi();
44449
44485
  const table = useTable30(tableId);
44450
44486
  const rights = useTableRights(table.data);
44451
- const [subscriptions, setSubscriptions] = useState120(null);
44452
- const [cadences, setCadences] = useState120([]);
44453
- const [views, setViews] = useState120(null);
44454
- const [error, setError] = useState120(null);
44455
- const [busy, setBusy] = useState120(false);
44456
- const [stopping, setStopping] = useState120(null);
44487
+ const [subscriptions, setSubscriptions] = useState121(null);
44488
+ const [cadences, setCadences] = useState121([]);
44489
+ const [views, setViews] = useState121(null);
44490
+ const [error, setError] = useState121(null);
44491
+ const [busy, setBusy] = useState121(false);
44492
+ const [stopping, setStopping] = useState121(null);
44457
44493
  const load = useCallback59(async () => {
44458
44494
  const [held, offered] = await Promise.all([
44459
44495
  // THE PERSON'S OWN DOOR, not the notifier's. It answers what is addressed
@@ -44482,7 +44518,7 @@ function NotifyRuleEditor({ tableId, seed, chosenRuleId, onChoose, className })
44482
44518
  }
44483
44519
  setViews(listed.data.map((v) => ({ id: v.view_id, name: v.name })));
44484
44520
  }, [client, host, tableId]);
44485
- useEffect105(() => {
44521
+ useEffect106(() => {
44486
44522
  void load();
44487
44523
  }, [load]);
44488
44524
  const write = useCallback59(
@@ -44510,7 +44546,7 @@ function NotifyRuleEditor({ tableId, seed, chosenRuleId, onChoose, className })
44510
44546
  },
44511
44547
  [client, tableId]
44512
44548
  );
44513
- useEffect105(() => {
44549
+ useEffect106(() => {
44514
44550
  if (!subscriptions || !seed || seed.length === 0) return;
44515
44551
  const missing = seed.filter((s) => !subscriptions.some((held) => held.name === s.name));
44516
44552
  if (missing.length === 0) return;
@@ -44691,7 +44727,7 @@ function NotifyRuleEditor({ tableId, seed, chosenRuleId, onChoose, className })
44691
44727
  }
44692
44728
 
44693
44729
  // src/DashboardCanvas.tsx
44694
- import { useCallback as useCallback60, useEffect as useEffect107, useMemo as useMemo71, useState as useState123 } from "react";
44730
+ import { useCallback as useCallback60, useEffect as useEffect108, useMemo as useMemo71, useState as useState124 } from "react";
44695
44731
  import { useFields as useFields30, useRecordsClient as useRecordsClient88, useTable as useTable32 } from "@ai-matrx/records/react";
44696
44732
  import {
44697
44733
  BasicInput as BasicInput32,
@@ -44859,7 +44895,7 @@ function GridCell2({
44859
44895
  }
44860
44896
 
44861
44897
  // src/AddChart.tsx
44862
- import { useMemo as useMemo70, useState as useState122 } from "react";
44898
+ import { useMemo as useMemo70, useState as useState123 } from "react";
44863
44899
  import { useFields as useFields29, useRecordsClient as useRecordsClient87 } from "@ai-matrx/records/react";
44864
44900
  import {
44865
44901
  Button as Button95,
@@ -44871,7 +44907,7 @@ import {
44871
44907
  } from "@ai-matrx/design-system";
44872
44908
 
44873
44909
  // src/TablePickers.tsx
44874
- import { useEffect as useEffect106, useMemo as useMemo69, useState as useState121 } from "react";
44910
+ import { useEffect as useEffect107, useMemo as useMemo69, useState as useState122 } from "react";
44875
44911
  import { RecordsProvider as RecordsProvider2, useFields as useFields28, useRecords as useRecords7, useTable as useTable31 } from "@ai-matrx/records/react";
44876
44912
  import { Button as Button94, CreatablePicker as CreatablePicker2 } from "@ai-matrx/design-system";
44877
44913
 
@@ -44991,8 +45027,8 @@ function readTablesAnywhere(dataSource) {
44991
45027
  return read;
44992
45028
  }
44993
45029
  function useTablesAnywhere(dataSource) {
44994
- const [state, setState] = useState121({ loading: true, error: null, rows: [] });
44995
- useEffect106(() => {
45030
+ const [state, setState] = useState122({ loading: true, error: null, rows: [] });
45031
+ useEffect107(() => {
44996
45032
  let live = true;
44997
45033
  void readTablesAnywhere(dataSource).then((result) => {
44998
45034
  if (live) setState(result);
@@ -45069,7 +45105,7 @@ function ColumnValuesEditor({ tableId, value, onChange, disabled, addLabel }) {
45069
45105
  const all = useMemo69(() => fields.data ?? [], [fields.data]);
45070
45106
  const byKey = useMemo69(() => new Map(all.map((f) => [f.key, f])), [all]);
45071
45107
  const keys = Object.keys(value);
45072
- const [adding, setAdding] = useState121(false);
45108
+ const [adding, setAdding] = useState122(false);
45073
45109
  const optionsFor = (current) => all.filter((f) => f.key === current || !(f.key in value)).map((f) => ({ value: f.key, label: fieldName(f) }));
45074
45110
  const rename = (from, to) => {
45075
45111
  if (from === to) return;
@@ -45225,7 +45261,7 @@ function chartSpecFrom(args) {
45225
45261
  }
45226
45262
  function AddChart({ subject, onAdd, onClose }) {
45227
45263
  const client = useRecordsClient87();
45228
- const [tableId, setTableId] = useState122(subject);
45264
+ const [tableId, setTableId] = useState123(subject);
45229
45265
  const fields = useFields29(tableId);
45230
45266
  const all = useMemo70(() => onePerKey(fields.data ?? []), [fields.data]);
45231
45267
  const labels = useRecordLabels(all);
@@ -45233,11 +45269,11 @@ function AddChart({ subject, onAdd, onClose }) {
45233
45269
  const field2 = all.find((f) => f.key === key);
45234
45270
  return field2 ? scalarText(field2, value, labels) : String(value);
45235
45271
  };
45236
- const [measureKey5, setMeasureKey] = useState122("count");
45237
- const [splitKey, setSplitKey] = useState122("none");
45238
- const [kind, setKind] = useState122("auto");
45239
- const [filter, setFilter] = useState122({});
45240
- const [saving, setSaving] = useState122(false);
45272
+ const [measureKey5, setMeasureKey] = useState123("count");
45273
+ const [splitKey, setSplitKey] = useState123("none");
45274
+ const [kind, setKind] = useState123("auto");
45275
+ const [filter, setFilter] = useState123({});
45276
+ const [saving, setSaving] = useState123(false);
45241
45277
  const numbers = numberColumns(all);
45242
45278
  const choices = offerableFields(all, "choice");
45243
45279
  const dates = offerableFields(all, "date");
@@ -45384,20 +45420,20 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, createOnMount, on
45384
45420
  const table = useTable32(tableId);
45385
45421
  const rights = useTableRights(table.data);
45386
45422
  const fields = useFields30(tableId);
45387
- const [boards, setBoards] = useState123(null);
45388
- const [pages, setPages] = useState123([]);
45389
- const [error, setError] = useState123(null);
45390
- const [activeId, setActiveId] = useState123(activeDashboardId ?? null);
45391
- const [madeOnMount, setMadeOnMount] = useState123("waiting");
45392
- const [askingToRemove, setAskingToRemove] = useState123(null);
45393
- const [run, setRun] = useState123(null);
45394
- const [running, setRunning] = useState123(false);
45395
- const [question, setQuestion] = useState123("");
45396
- const [asking, setAsking] = useState123(false);
45397
- const [scheduling, setScheduling] = useState123(false);
45398
- const [arranging, setArranging] = useState123(false);
45399
- const [adding, setAdding] = useState123(false);
45400
- const [grain, setGrain] = useState123(null);
45423
+ const [boards, setBoards] = useState124(null);
45424
+ const [pages, setPages] = useState124([]);
45425
+ const [error, setError] = useState124(null);
45426
+ const [activeId, setActiveId] = useState124(activeDashboardId ?? null);
45427
+ const [madeOnMount, setMadeOnMount] = useState124("waiting");
45428
+ const [askingToRemove, setAskingToRemove] = useState124(null);
45429
+ const [run, setRun] = useState124(null);
45430
+ const [running, setRunning] = useState124(false);
45431
+ const [question, setQuestion] = useState124("");
45432
+ const [asking, setAsking] = useState124(false);
45433
+ const [scheduling, setScheduling] = useState124(false);
45434
+ const [arranging, setArranging] = useState124(false);
45435
+ const [adding, setAdding] = useState124(false);
45436
+ const [grain, setGrain] = useState124(null);
45401
45437
  const runArgs = (dashboard_id) => ({
45402
45438
  dashboard_id,
45403
45439
  ...filter ? { filter } : {},
@@ -45415,11 +45451,11 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, createOnMount, on
45415
45451
  setBoards(read);
45416
45452
  return read;
45417
45453
  }, [client, tableId]);
45418
- const [notKept, setNotKept] = useState123(null);
45419
- useEffect107(() => {
45454
+ const [notKept, setNotKept] = useState124(null);
45455
+ useEffect108(() => {
45420
45456
  void load();
45421
45457
  }, [load]);
45422
- useEffect107(() => {
45458
+ useEffect108(() => {
45423
45459
  if (!boards || boards.length === 0) return;
45424
45460
  if (createOnMount && madeOnMount !== "done") return;
45425
45461
  const chosen = boards.find((d) => d.id === (activeDashboardId ?? activeId)) ?? boards[0];
@@ -45427,7 +45463,7 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, createOnMount, on
45427
45463
  }, [boards, activeDashboardId, madeOnMount]);
45428
45464
  const board = useMemo71(() => boards?.find((d) => d.id === activeId) ?? null, [boards, activeId]);
45429
45465
  const filterKey = JSON.stringify(filter ?? {});
45430
- useEffect107(() => {
45466
+ useEffect108(() => {
45431
45467
  if (!activeId) {
45432
45468
  setRun(null);
45433
45469
  return;
@@ -45497,7 +45533,7 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, createOnMount, on
45497
45533
  ]
45498
45534
  );
45499
45535
  }
45500
- useEffect107(() => {
45536
+ useEffect108(() => {
45501
45537
  if (!createOnMount || madeOnMount !== "waiting" || boards === null || !fields.data) return;
45502
45538
  setMadeOnMount("making");
45503
45539
  void create().then(() => setMadeOnMount("done"));
@@ -45942,10 +45978,10 @@ function TargetControl({
45942
45978
  onChange
45943
45979
  }) {
45944
45980
  const saved = !block.target ? "none" : "field" in block.target && block.target.field ? "field" : "value";
45945
- const [mode, setMode] = useState123(saved);
45981
+ const [mode, setMode] = useState124(saved);
45946
45982
  const savedValue = block.target && "value" in block.target && typeof block.target.value === "number" ? block.target.value : null;
45947
- const [draft, setDraft] = useState123(savedValue === null ? "" : String(savedValue));
45948
- useEffect107(() => {
45983
+ const [draft, setDraft] = useState124(savedValue === null ? "" : String(savedValue));
45984
+ useEffect108(() => {
45949
45985
  setMode(saved);
45950
45986
  setDraft(savedValue === null ? "" : String(savedValue));
45951
45987
  }, [saved, savedValue]);
@@ -46013,7 +46049,7 @@ function TargetControl({
46013
46049
 
46014
46050
  // src/QuestionPanel.tsx
46015
46051
  import { copyText as copyText9 } from "@ai-matrx/kit/clipboard";
46016
- import { useEffect as useEffect108, useMemo as useMemo72, useRef as useRef59, useState as useState124 } from "react";
46052
+ import { useEffect as useEffect109, useMemo as useMemo72, useRef as useRef59, useState as useState125 } from "react";
46017
46053
  import { Badge as Badge24, BasicInput as BasicInput33, Button as Button97, Checkbox as Checkbox16, Label as Label26, Skeleton as Skeleton34, cn as cn88 } from "@ai-matrx/design-system";
46018
46054
  import { useFields as useFields31, useRecordsClient as useRecordsClient89 } from "@ai-matrx/records/react";
46019
46055
 
@@ -46067,9 +46103,9 @@ function QuestionPanel({ tableId, activeQuestionId, draft, className }) {
46067
46103
  const fields = useFields31(tableId);
46068
46104
  const all = useMemo72(() => fields.data ?? [], [fields.data]);
46069
46105
  const me = client.config.actor?.user_id ?? null;
46070
- const [hidden, setHidden] = useState124(null);
46071
- const [related, setRelated] = useState124({});
46072
- useEffect108(() => {
46106
+ const [hidden, setHidden] = useState125(null);
46107
+ const [related, setRelated] = useState125({});
46108
+ useEffect109(() => {
46073
46109
  if (all.length === 0) {
46074
46110
  if (!fields.loading) setHidden(/* @__PURE__ */ new Set());
46075
46111
  return;
@@ -46093,17 +46129,17 @@ function QuestionPanel({ tableId, activeQuestionId, draft, className }) {
46093
46129
  };
46094
46130
  }, [client, tableId, all, fields.loading]);
46095
46131
  const offered = useMemo72(() => hidden ? all.filter((f) => !hidden.has(f.key)) : [], [all, hidden]);
46096
- const [saved, setSaved] = useState124(null);
46097
- const [savedEpoch, setSavedEpoch] = useState124(0);
46098
- const [current, setCurrent] = useState124(null);
46099
- const [spec, setSpec] = useState124(question_exports.newQuestion);
46100
- const [name, setName] = useState124("");
46101
- const [shared, setShared] = useState124(true);
46102
- const [saveError, setSaveError] = useState124(null);
46103
- const [saving, setSaving] = useState124(false);
46104
- const [linkMissed, setLinkMissed] = useState124(false);
46132
+ const [saved, setSaved] = useState125(null);
46133
+ const [savedEpoch, setSavedEpoch] = useState125(0);
46134
+ const [current, setCurrent] = useState125(null);
46135
+ const [spec, setSpec] = useState125(question_exports.newQuestion);
46136
+ const [name, setName] = useState125("");
46137
+ const [shared, setShared] = useState125(true);
46138
+ const [saveError, setSaveError] = useState125(null);
46139
+ const [saving, setSaving] = useState125(false);
46140
+ const [linkMissed, setLinkMissed] = useState125(false);
46105
46141
  const openedFromLink = useRef59(false);
46106
- useEffect108(() => {
46142
+ useEffect109(() => {
46107
46143
  let live = true;
46108
46144
  void (0, question_exports.questionsOf)(client, tableId).then((answer2) => {
46109
46145
  if (!live) return;
@@ -46126,16 +46162,16 @@ function QuestionPanel({ tableId, activeQuestionId, draft, className }) {
46126
46162
  setShared(q ? q.shared : true);
46127
46163
  setSaveError(null);
46128
46164
  };
46129
- useEffect108(() => {
46165
+ useEffect109(() => {
46130
46166
  if (!draft) return;
46131
46167
  open(null);
46132
46168
  setSpec(draft);
46133
46169
  }, [draft]);
46134
46170
  const mine = !current || me !== null && current.createdBy === me;
46135
- const [answer, setAnswer] = useState124(null);
46136
- const [asking, setAsking] = useState124(false);
46171
+ const [answer, setAnswer] = useState125(null);
46172
+ const [asking, setAsking] = useState125(false);
46137
46173
  const specKey = JSON.stringify(spec);
46138
- useEffect108(() => {
46174
+ useEffect109(() => {
46139
46175
  if (all.length === 0) return;
46140
46176
  let live = true;
46141
46177
  setAsking(true);
@@ -46577,7 +46613,7 @@ function QuestionAnswerView({ tableId, spec, answer, fields, related = NO_RELATE
46577
46613
  }
46578
46614
 
46579
46615
  // src/TableAsk.tsx
46580
- import { useState as useState125 } from "react";
46616
+ import { useState as useState126 } from "react";
46581
46617
  import { BasicInput as BasicInput34, Button as Button98, Popover as Popover15, PopoverContent as PopoverContent15, PopoverTrigger as PopoverTrigger15, Skeleton as Skeleton35 } from "@ai-matrx/design-system";
46582
46618
  import { optionLabel as optionLabel4 } from "@ai-matrx/records";
46583
46619
  import { useFields as useFields32, useRecordsClient as useRecordsClient90 } from "@ai-matrx/records/react";
@@ -46800,10 +46836,10 @@ function TableAsk({ tableId, onOpenInQuestions }) {
46800
46836
  const client = useRecordsClient90();
46801
46837
  const fields = useFields32(tableId);
46802
46838
  const all = fields.data ?? [];
46803
- const [open, setOpen] = useState125(false);
46804
- const [words2, setWords] = useState125("");
46805
- const [said2, setSaid] = useState125({ kind: "idle" });
46806
- const ask = async () => {
46839
+ const [open, setOpen] = useState126(false);
46840
+ const [words2, setWords] = useState126("");
46841
+ const [said2, setSaid] = useState126({ kind: "idle" });
46842
+ const ask2 = async () => {
46807
46843
  if (words2.trim() === "" || all.length === 0) return;
46808
46844
  const choices = {};
46809
46845
  await Promise.all(
@@ -46827,7 +46863,7 @@ function TableAsk({ tableId, onOpenInQuestions }) {
46827
46863
  className: "flex items-center gap-1",
46828
46864
  onSubmit: (event) => {
46829
46865
  event.preventDefault();
46830
- void ask();
46866
+ void ask2();
46831
46867
  },
46832
46868
  children: [
46833
46869
  /* @__PURE__ */ jsx151(
@@ -46875,7 +46911,7 @@ function TableAsk({ tableId, onOpenInQuestions }) {
46875
46911
  }
46876
46912
 
46877
46913
  // src/PageScreen.tsx
46878
- import { useCallback as useCallback61, useEffect as useEffect109, useMemo as useMemo73, useState as useState126 } from "react";
46914
+ import { useCallback as useCallback61, useEffect as useEffect110, useMemo as useMemo73, useState as useState127 } from "react";
46879
46915
  import {
46880
46916
  useFields as useFields33,
46881
46917
  useRecordPage as useRecordPage3,
@@ -46901,18 +46937,18 @@ function PageScreen({
46901
46937
  const client = useRecordsClient91();
46902
46938
  const host = useRecordsUi();
46903
46939
  const organizationId = client.config.organizationId;
46904
- const [page, setPage] = useState126(null);
46905
- const [missing, setMissing] = useState126(false);
46906
- const [error, setError] = useState126(null);
46907
- const [level, setLevel] = useState126(null);
46908
- const [editing, setEditing] = useState126(startEditing);
46909
- const [run, setRun] = useState126(null);
46910
- const [saveError, setSaveError] = useState126(null);
46911
- const [askingToArchive, setAskingToArchive] = useState126(false);
46912
- const [selected, setSelected] = useState126({});
46913
- const [filterValues, setFilterValues] = useState126({});
46914
- const [mine, setMine] = useState126({});
46915
- const [making, setMaking] = useState126("waiting");
46940
+ const [page, setPage] = useState127(null);
46941
+ const [missing, setMissing] = useState127(false);
46942
+ const [error, setError] = useState127(null);
46943
+ const [level, setLevel] = useState127(null);
46944
+ const [editing, setEditing] = useState127(startEditing);
46945
+ const [run, setRun] = useState127(null);
46946
+ const [saveError, setSaveError] = useState127(null);
46947
+ const [askingToArchive, setAskingToArchive] = useState127(false);
46948
+ const [selected, setSelected] = useState127({});
46949
+ const [filterValues, setFilterValues] = useState127({});
46950
+ const [mine, setMine] = useState127({});
46951
+ const [making, setMaking] = useState127("waiting");
46916
46952
  const id = page?.id ?? pageId ?? null;
46917
46953
  const load = useCallback61(
46918
46954
  async (want) => {
@@ -46933,7 +46969,7 @@ function PageScreen({
46933
46969
  },
46934
46970
  [client]
46935
46971
  );
46936
- useEffect109(() => {
46972
+ useEffect110(() => {
46937
46973
  if (!newOnTable || pageId || making !== "waiting") return;
46938
46974
  setMaking("making");
46939
46975
  void client.dashboardDeclare({
@@ -46953,11 +46989,11 @@ function PageScreen({
46953
46989
  onCreated?.(made.data);
46954
46990
  });
46955
46991
  }, [client, newOnTable, pageId, making, load, onCreated]);
46956
- useEffect109(() => {
46992
+ useEffect110(() => {
46957
46993
  if (!pageId) return;
46958
46994
  void load(pageId);
46959
46995
  }, [pageId, load]);
46960
- useEffect109(() => {
46996
+ useEffect110(() => {
46961
46997
  if (!id) return;
46962
46998
  let live = true;
46963
46999
  void client.myLevels({ ids: [id], subject: "record" }).then((answered) => {
@@ -46969,7 +47005,7 @@ function PageScreen({
46969
47005
  }, [client, id]);
46970
47006
  const canEdit = level !== null && EDIT_LEVELS.has(level);
46971
47007
  const chartKey = page ? JSON.stringify(page.blocks.map((b) => b.id)) + page.version : "";
46972
- useEffect109(() => {
47008
+ useEffect110(() => {
46973
47009
  if (!page || page.blocks.length === 0) {
46974
47010
  setRun(null);
46975
47011
  return;
@@ -47214,8 +47250,8 @@ function AppletBlockView({ block }) {
47214
47250
  }
47215
47251
  function AppletPick({ value, onChange }) {
47216
47252
  const host = useRecordsUi();
47217
- const [options, setOptions] = useState126(null);
47218
- useEffect109(() => {
47253
+ const [options, setOptions] = useState127(null);
47254
+ useEffect110(() => {
47219
47255
  let live = true;
47220
47256
  host.applets?.list().then((apps) => live && setOptions(apps.map((a) => ({ value: a.id, label: a.name })))).catch(() => live && setOptions([]));
47221
47257
  return () => {
@@ -47251,8 +47287,8 @@ function ListBlockView({
47251
47287
  const table = useTable33(block.table_id);
47252
47288
  const fields = useFields33(block.table_id);
47253
47289
  const all = useMemo73(() => onePerKey3(fields.data ?? []), [fields.data]);
47254
- const [view, setView] = useState126(block.view_id ? "reading" : null);
47255
- useEffect109(() => {
47290
+ const [view, setView] = useState127(block.view_id ? "reading" : null);
47291
+ useEffect110(() => {
47256
47292
  if (!block.view_id) {
47257
47293
  setView(null);
47258
47294
  return;
@@ -47269,8 +47305,8 @@ function ListBlockView({
47269
47305
  };
47270
47306
  }, [client, block.table_id, block.view_id]);
47271
47307
  const meField = block.me_field ? all.find((f) => f.key === block.me_field) : void 0;
47272
- const [me, setMe] = useState126(null);
47273
- useEffect109(() => {
47308
+ const [me, setMe] = useState127(null);
47309
+ useEffect110(() => {
47274
47310
  if (!mine || !meField?.relation_target || !viewerUserId) {
47275
47311
  setMe(null);
47276
47312
  return;
@@ -47300,12 +47336,12 @@ function ListBlockView({
47300
47336
  ...sort.length > 0 ? { sort } : {}
47301
47337
  });
47302
47338
  const reload = page.reload;
47303
- useEffect109(() => onRecordChanged2(() => reload()), [reload]);
47339
+ useEffect110(() => onRecordChanged2(() => reload()), [reload]);
47304
47340
  const rows = nobodyIsMe ? [] : page.data?.rows ?? [];
47305
47341
  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);
47306
47342
  const firstId = rows[0]?.id ?? null;
47307
47343
  const stillThere = selected !== null && rows.some((r) => r.id === selected);
47308
- useEffect109(() => {
47344
+ useEffect110(() => {
47309
47345
  if (page.loading || waiting) return;
47310
47346
  if (!stillThere) onSelect(firstId);
47311
47347
  }, [firstId, stillThere, page.loading, waiting]);
@@ -47368,11 +47404,11 @@ function ActionButton2({ block, recordId }) {
47368
47404
  const client = useRecordsClient91();
47369
47405
  const actionsRead = useRowActions2(block.action_id ? block.table_id : null);
47370
47406
  const action3 = !block.action_id ? null : actionsRead.data ? actionsRead.data.actions.find((a) => a.id === block.action_id) ?? null : actionsRead.loading ? "reading" : null;
47371
- const [asking, setAsking] = useState126(false);
47372
- const [running, setRunning] = useState126(false);
47373
- const [done, setDone] = useState126(null);
47374
- const [error, setError] = useState126(null);
47375
- useEffect109(() => {
47407
+ const [asking, setAsking] = useState127(false);
47408
+ const [running, setRunning] = useState127(false);
47409
+ const [done, setDone] = useState127(null);
47410
+ const [error, setError] = useState127(null);
47411
+ useEffect110(() => {
47376
47412
  setDone(null);
47377
47413
  setError(null);
47378
47414
  setAsking(false);
@@ -47411,9 +47447,9 @@ function ActionButton2({ block, recordId }) {
47411
47447
  }
47412
47448
  function FormBlockView({ block }) {
47413
47449
  const client = useRecordsClient91();
47414
- const [form, setForm] = useState126("reading");
47415
- const [sent, setSent] = useState126(0);
47416
- useEffect109(() => {
47450
+ const [form, setForm] = useState127("reading");
47451
+ const [sent, setSent] = useState127(0);
47452
+ useEffect110(() => {
47417
47453
  if (!block.form_id) {
47418
47454
  setForm(null);
47419
47455
  return;
@@ -47538,10 +47574,10 @@ function FieldPick({
47538
47574
  }
47539
47575
  function ListSettings({ block, onChange }) {
47540
47576
  const client = useRecordsClient91();
47541
- const [views, setViews] = useState126([]);
47577
+ const [views, setViews] = useState127([]);
47542
47578
  const fields = useFields33(block.table_id);
47543
47579
  const all = onePerKey3(fields.data ?? []);
47544
- useEffect109(() => {
47580
+ useEffect110(() => {
47545
47581
  let live = true;
47546
47582
  void client.views({ table_id: block.table_id }).then((answered) => {
47547
47583
  if (live) setViews(answered.ok ? answered.data : []);
@@ -47617,8 +47653,8 @@ function ActionPicker({ tableId, value, onChange }) {
47617
47653
  }
47618
47654
  function FormPicker({ tableId, value, onChange }) {
47619
47655
  const client = useRecordsClient91();
47620
- const [forms, setForms] = useState126([]);
47621
- useEffect109(() => {
47656
+ const [forms, setForms] = useState127([]);
47657
+ useEffect110(() => {
47622
47658
  let live = true;
47623
47659
  void client.forms({ table_id: tableId }).then((answered) => {
47624
47660
  if (live) setForms(answered.ok ? answered.data : []);
@@ -47664,7 +47700,7 @@ function onePerKey3(all) {
47664
47700
 
47665
47701
  // src/FormsPanel.tsx
47666
47702
  import { copyText as copyText10 } from "@ai-matrx/kit/clipboard";
47667
- import { useCallback as useCallback62, useEffect as useEffect110, useState as useState127 } from "react";
47703
+ import { useCallback as useCallback62, useEffect as useEffect111, useState as useState128 } from "react";
47668
47704
  import { useRecordsClient as useRecordsClient92, useTable as useTable34 } from "@ai-matrx/records/react";
47669
47705
  import { publicFormPath as publicFormPath2 } from "@ai-matrx/records";
47670
47706
  import { Badge as Badge25, Button as Button100, Skeleton as Skeleton37, cn as cn90 } from "@ai-matrx/design-system";
@@ -47682,15 +47718,15 @@ function FormsPanel({ tableId, activeFormId, className }) {
47682
47718
  const host = useRecordsUi();
47683
47719
  const table = useTable34(tableId);
47684
47720
  const rights = useTableRights(table.data);
47685
- const [forms, setForms] = useState127(null);
47686
- const [error, setError] = useState127(null);
47687
- const [busy, setBusy] = useState127(null);
47688
- const [copied, setCopied] = useState127(null);
47689
- const [building, setBuilding] = useState127(false);
47690
- const [archivedSaid, setArchivedSaid] = useState127(null);
47721
+ const [forms, setForms] = useState128(null);
47722
+ const [error, setError] = useState128(null);
47723
+ const [busy, setBusy] = useState128(null);
47724
+ const [copied, setCopied] = useState128(null);
47725
+ const [building, setBuilding] = useState128(false);
47726
+ const [archivedSaid, setArchivedSaid] = useState128(null);
47691
47727
  const linked = activeFormId && forms !== null ? forms.find((f) => f.form_id === activeFormId) ?? null : null;
47692
47728
  const linkedMissing = Boolean(activeFormId) && forms !== null && linked === null;
47693
- useEffect110(() => {
47729
+ useEffect111(() => {
47694
47730
  if (linked && rights.structure) setBuilding(true);
47695
47731
  }, [linked, rights.structure]);
47696
47732
  const load = useCallback62(async () => {
@@ -47703,7 +47739,7 @@ function FormsPanel({ tableId, activeFormId, className }) {
47703
47739
  setError(null);
47704
47740
  setForms(answered.data);
47705
47741
  }, [client, tableId]);
47706
- useEffect110(() => {
47742
+ useEffect111(() => {
47707
47743
  void load();
47708
47744
  }, [load]);
47709
47745
  const toggle = useCallback62(
@@ -47720,7 +47756,7 @@ function FormsPanel({ tableId, activeFormId, className }) {
47720
47756
  },
47721
47757
  [client, load]
47722
47758
  );
47723
- const [shown4, setShown] = useState127(null);
47759
+ const [shown4, setShown] = useState128(null);
47724
47760
  const copy = useCallback62(async (url, formId) => {
47725
47761
  if (await copyText10(url)) {
47726
47762
  setCopied(formId);
@@ -47848,12 +47884,12 @@ function FormsPanel({ tableId, activeFormId, className }) {
47848
47884
  }
47849
47885
 
47850
47886
  // src/CaptureSheet.tsx
47851
- import { useCallback as useCallback64, useEffect as useEffect112, useRef as useRef61, useState as useState129 } from "react";
47887
+ import { useCallback as useCallback64, useEffect as useEffect113, useRef as useRef61, useState as useState130 } from "react";
47852
47888
  import { useFields as useFields34, useRecordsClient as useRecordsClient94, useTable as useTable35 } from "@ai-matrx/records/react";
47853
47889
  import { Button as Button102, Input as Input8, Skeleton as Skeleton39, Textarea as Textarea8, cn as cn92 } from "@ai-matrx/design-system";
47854
47890
 
47855
47891
  // src/CaptureRun.tsx
47856
- import { useCallback as useCallback63, useEffect as useEffect111, useMemo as useMemo74, useRef as useRef60, useState as useState128 } from "react";
47892
+ import { useCallback as useCallback63, useEffect as useEffect112, useMemo as useMemo74, useRef as useRef60, useState as useState129 } from "react";
47857
47893
  import {
47858
47894
  coerceTypedAnswer as coerceTypedAnswer3,
47859
47895
  coercionLabel,
@@ -47900,19 +47936,19 @@ function whereWeAre(timeoutMs = 4e3) {
47900
47936
  function CaptureRun({ sheetId, face: given, className }) {
47901
47937
  const client = useRecordsClient93();
47902
47938
  const host = useRecordsUi();
47903
- const [face, setFace] = useState128(given);
47904
- const [loadFailed, setLoadFailed] = useState128(null);
47905
- const [at, setAt] = useState128(0);
47906
- const [answers, setAnswers] = useState128({});
47907
- const [files, setFiles] = useState128({});
47908
- const [missing, setMissing] = useState128(null);
47909
- const [done, setDone] = useState128(null);
47910
- const [counts, setCounts] = useState128({ waiting: 0, sending: 0, refused: 0, landed: 0 });
47911
- const [items, setItems] = useState128([]);
47912
- const [lastSynced, setLastSynced] = useState128(null);
47913
- const [sending, setSending] = useState128(false);
47939
+ const [face, setFace] = useState129(given);
47940
+ const [loadFailed, setLoadFailed] = useState129(null);
47941
+ const [at, setAt] = useState129(0);
47942
+ const [answers, setAnswers] = useState129({});
47943
+ const [files, setFiles] = useState129({});
47944
+ const [missing, setMissing] = useState129(null);
47945
+ const [done, setDone] = useState129(null);
47946
+ const [counts, setCounts] = useState129({ waiting: 0, sending: 0, refused: 0, landed: 0 });
47947
+ const [items, setItems] = useState129([]);
47948
+ const [lastSynced, setLastSynced] = useState129(null);
47949
+ const [sending, setSending] = useState129(false);
47914
47950
  const queueRef = useRef60(null);
47915
- useEffect111(() => {
47951
+ useEffect112(() => {
47916
47952
  const q2 = openCaptureQueue({
47917
47953
  onChange: (c, all) => {
47918
47954
  setCounts(c);
@@ -47950,7 +47986,7 @@ function CaptureRun({ sheetId, face: given, className }) {
47950
47986
  void q2.sync().then(() => void q2.lastSyncedAt().then(setLastSynced));
47951
47987
  return () => q2.dispose();
47952
47988
  }, [client, host]);
47953
- useEffect111(() => {
47989
+ useEffect112(() => {
47954
47990
  if (given !== void 0) return;
47955
47991
  let cancelled = false;
47956
47992
  void client.captureOpen({ sheet_id: sheetId }).then((res) => {
@@ -47963,8 +47999,8 @@ function CaptureRun({ sheetId, face: given, className }) {
47963
47999
  };
47964
48000
  }, [client, given, sheetId]);
47965
48001
  const questions = useMemo74(() => {
47966
- const asked2 = face?.presentation?.questions ?? [];
47967
- if (asked2.length > 0) return asked2;
48002
+ const asked3 = face?.presentation?.questions ?? [];
48003
+ if (asked3.length > 0) return asked3;
47968
48004
  return (face?.fields ?? []).map((f) => ({
47969
48005
  field: f.key,
47970
48006
  ask: f.label ?? f.key,
@@ -48282,15 +48318,15 @@ function AdHocCaptureSheet({
48282
48318
  const host = useRecordsUi();
48283
48319
  const table = useTable35(tableId);
48284
48320
  const fields = useFields34(tableId);
48285
- const [mode, setMode] = useState129("reading");
48286
- const [reading, setReading] = useState129("");
48287
- const [note, setNote] = useState129("");
48288
- const [fileId, setFileId] = useState129(null);
48289
- const [pending, setPending] = useState129(null);
48290
- const [saved, setSaved] = useState129([]);
48291
- const [error, setError] = useState129(null);
48292
- const [uploadError, setUploadError] = useState129(null);
48293
- const [flushing, setFlushing] = useState129(false);
48321
+ const [mode, setMode] = useState130("reading");
48322
+ const [reading, setReading] = useState130("");
48323
+ const [note, setNote] = useState130("");
48324
+ const [fileId, setFileId] = useState130(null);
48325
+ const [pending, setPending] = useState130(null);
48326
+ const [saved, setSaved] = useState130([]);
48327
+ const [error, setError] = useState130(null);
48328
+ const [uploadError, setUploadError] = useState130(null);
48329
+ const [flushing, setFlushing] = useState130(false);
48294
48330
  const queue = useRef61([]);
48295
48331
  const keep = useCallback64(
48296
48332
  async (next) => {
@@ -48300,7 +48336,7 @@ function AdHocCaptureSheet({
48300
48336
  },
48301
48337
  [host]
48302
48338
  );
48303
- useEffect112(() => {
48339
+ useEffect113(() => {
48304
48340
  let cancelled = false;
48305
48341
  void (async () => {
48306
48342
  const held = host.captureQueue ? await host.captureQueue.load() : [];
@@ -48479,17 +48515,17 @@ function AdHocCaptureSheet({
48479
48515
  }
48480
48516
 
48481
48517
  // src/PortalShell.tsx
48482
- import { useCallback as useCallback65, useEffect as useEffect113, useState as useState130 } from "react";
48518
+ import { useCallback as useCallback65, useEffect as useEffect114, useState as useState131 } from "react";
48483
48519
  import { useRecordsClient as useRecordsClient95 } from "@ai-matrx/records/react";
48484
48520
  import { Button as Button103, Skeleton as Skeleton40, cn as cn93 } from "@ai-matrx/design-system";
48485
48521
  import { jsx as jsx156, jsxs as jsxs145 } from "react/jsx-runtime";
48486
48522
  function PortalShell({ tableId, form, resourceType = "record", className }) {
48487
48523
  const client = useRecordsClient95();
48488
- const [card, setCard] = useState130(null);
48489
- const [reach, setReach] = useState130(null);
48490
- const [error, setError] = useState130(null);
48491
- const [open, setOpen] = useState130(null);
48492
- const [sending, setSending] = useState130(false);
48524
+ const [card, setCard] = useState131(null);
48525
+ const [reach, setReach] = useState131(null);
48526
+ const [error, setError] = useState131(null);
48527
+ const [open, setOpen] = useState131(null);
48528
+ const [sending, setSending] = useState131(false);
48493
48529
  const load = useCallback65(async () => {
48494
48530
  const who = await client.externalPrincipalCard();
48495
48531
  if (!who.ok) {
@@ -48505,7 +48541,7 @@ function PortalShell({ tableId, form, resourceType = "record", className }) {
48505
48541
  }
48506
48542
  setReach(reached.data.map((row) => row.resource_id));
48507
48543
  }, [client, resourceType]);
48508
- useEffect113(() => {
48544
+ useEffect114(() => {
48509
48545
  void load();
48510
48546
  }, [load]);
48511
48547
  if (error) {
@@ -48564,8 +48600,8 @@ function PortalShell({ tableId, form, resourceType = "record", className }) {
48564
48600
  }
48565
48601
  function PortalRow({ tableId, recordId }) {
48566
48602
  const client = useRecordsClient95();
48567
- const [title, setTitle] = useState130(null);
48568
- useEffect113(() => {
48603
+ const [title, setTitle] = useState131(null);
48604
+ useEffect114(() => {
48569
48605
  let cancelled = false;
48570
48606
  void client.recordRead({ record_id: recordId }).then((answered) => {
48571
48607
  if (cancelled) return;
@@ -48585,19 +48621,19 @@ function PortalRow({ tableId, recordId }) {
48585
48621
  }
48586
48622
 
48587
48623
  // src/PublicViewPage.tsx
48588
- import { useCallback as useCallback66, useEffect as useEffect114, useState as useState131 } from "react";
48624
+ import { useCallback as useCallback66, useEffect as useEffect115, useState as useState132 } from "react";
48589
48625
  import { useRecordsClient as useRecordsClient96 } from "@ai-matrx/records/react";
48590
48626
  import { Skeleton as Skeleton41, cn as cn94 } from "@ai-matrx/design-system";
48591
48627
  import { publicReadOf } from "@ai-matrx/records/forms";
48592
48628
  import { jsx as jsx157, jsxs as jsxs146 } from "react/jsx-runtime";
48593
48629
  function PublicViewPage({ slug, className }) {
48594
48630
  const client = useRecordsClient96();
48595
- const [binding, setBinding] = useState131(null);
48596
- const [rows, setRows] = useState131(null);
48597
- const [fields, setFields] = useState131(null);
48598
- const [error, setError] = useState131(null);
48599
- const [plan, setPlan] = useState131(null);
48600
- const [gap, setGap] = useState131(null);
48631
+ const [binding, setBinding] = useState132(null);
48632
+ const [rows, setRows] = useState132(null);
48633
+ const [fields, setFields] = useState132(null);
48634
+ const [error, setError] = useState132(null);
48635
+ const [plan, setPlan] = useState132(null);
48636
+ const [gap, setGap] = useState132(null);
48601
48637
  const load = useCallback66(async () => {
48602
48638
  const notice = await client.worldPublishGapNotice();
48603
48639
  if (notice.ok) setGap(notice.data);
@@ -48648,7 +48684,7 @@ function PublicViewPage({ slug, className }) {
48648
48684
  }
48649
48685
  setRows([{ id: chosen.recordId, document: read.data.document, level: "viewer", hidden: read.data.hidden }]);
48650
48686
  }, [client, slug]);
48651
- useEffect114(() => {
48687
+ useEffect115(() => {
48652
48688
  void load();
48653
48689
  }, [load]);
48654
48690
  if (error) return /* @__PURE__ */ jsx157(RefusalNotice, { error, className });
@@ -48686,7 +48722,7 @@ function PublicRow({ row, fields }) {
48686
48722
 
48687
48723
  // src/EmbedFrame.tsx
48688
48724
  import { copyText as copyText11 } from "@ai-matrx/kit/clipboard";
48689
- import { useCallback as useCallback67, useEffect as useEffect115, useState as useState132 } from "react";
48725
+ import { useCallback as useCallback67, useEffect as useEffect116, useState as useState133 } from "react";
48690
48726
  import { useRecordsClient as useRecordsClient97 } from "@ai-matrx/records/react";
48691
48727
  import { Button as Button104, Input as Input9, Skeleton as Skeleton42, Textarea as Textarea9, cn as cn95 } from "@ai-matrx/design-system";
48692
48728
  import { useTable as useTable36 } from "@ai-matrx/records/react";
@@ -48703,11 +48739,11 @@ function EmbedFrame({
48703
48739
  const host = useRecordsUi();
48704
48740
  const table = useTable36(tableId);
48705
48741
  const rights = useTableRights(table.data);
48706
- const [origins, setOrigins] = useState132("");
48707
- const [secret, setSecret] = useState132(null);
48708
- const [tokenId, setTokenId] = useState132(null);
48709
- const [error, setError] = useState132(null);
48710
- const [busy, setBusy] = useState132(false);
48742
+ const [origins, setOrigins] = useState133("");
48743
+ const [secret, setSecret] = useState133(null);
48744
+ const [tokenId, setTokenId] = useState133(null);
48745
+ const [error, setError] = useState133(null);
48746
+ const [busy, setBusy] = useState133(false);
48711
48747
  const mode = formId ? "write" : "read";
48712
48748
  const parsed = origins.split(/[\s,]+/).map((o) => o.trim()).filter((o) => o.length > 0);
48713
48749
  const issue = useCallback67(async () => {
@@ -48794,12 +48830,12 @@ function EmbedFrame({
48794
48830
  }
48795
48831
  function useEmbedHandshake(args) {
48796
48832
  const client = useRecordsClient97();
48797
- const [binding, setBinding] = useState132(null);
48798
- const [error, setError] = useState132(null);
48799
- const [loading, setLoading] = useState132(true);
48833
+ const [binding, setBinding] = useState133(null);
48834
+ const [error, setError] = useState133(null);
48835
+ const [loading, setLoading] = useState133(true);
48800
48836
  const origin = args.origin ?? (typeof location === "undefined" ? "" : location.origin);
48801
48837
  const { secret, requiredMode } = args;
48802
- useEffect115(() => {
48838
+ useEffect116(() => {
48803
48839
  let cancelled = false;
48804
48840
  setLoading(true);
48805
48841
  setError(null);
@@ -48822,7 +48858,7 @@ function useEmbedHandshake(args) {
48822
48858
 
48823
48859
  // src/TablePage.tsx
48824
48860
  import { copyText as copyText15 } from "@ai-matrx/kit/clipboard";
48825
- import { useCallback as useCallback69, useEffect as useEffect118, useMemo as useMemo78, useRef as useRef62, useState as useState140 } from "react";
48861
+ import { useCallback as useCallback69, useEffect as useEffect119, useMemo as useMemo78, useRef as useRef62, useState as useState141 } from "react";
48826
48862
  import { archivedByLine as archivedByLine2 } from "@ai-matrx/records";
48827
48863
  import { tableShapeChanged as tableShapeChanged14, useFields as useFields37, useRecordsClient as useRecordsClient99, useSeededAnswer, useTable as useTable37, useTableArchive as useTableArchive2 } from "@ai-matrx/records/react";
48828
48864
  import {
@@ -48865,7 +48901,7 @@ function subscribeCalendarAction(args) {
48865
48901
 
48866
48902
  // src/CalendarSubscribe.tsx
48867
48903
  import { copyText as copyText12 } from "@ai-matrx/kit/clipboard";
48868
- import { useState as useState133 } from "react";
48904
+ import { useState as useState134 } from "react";
48869
48905
 
48870
48906
  // src/asRefusal.ts
48871
48907
  function asRefusal3(e, fallback) {
@@ -48878,7 +48914,7 @@ import { Button as Button105, Dialog as Dialog15, DialogContent as DialogContent
48878
48914
  import { jsx as jsx159, jsxs as jsxs148 } from "react/jsx-runtime";
48879
48915
  function CalendarLinkOnce({ url }) {
48880
48916
  const notify = useRecordsUi().notify;
48881
- const [copied, setCopied] = useState133(false);
48917
+ const [copied, setCopied] = useState134(false);
48882
48918
  const copy = async () => {
48883
48919
  if (await copyText12(url)) {
48884
48920
  setCopied(true);
@@ -48916,9 +48952,9 @@ function CalendarSubscribeDialog({
48916
48952
  open,
48917
48953
  onOpenChange
48918
48954
  }) {
48919
- const [url, setUrl] = useState133(null);
48920
- const [busy, setBusy] = useState133(false);
48921
- const [error, setError] = useState133(null);
48955
+ const [url, setUrl] = useState134(null);
48956
+ const [busy, setBusy] = useState134(false);
48957
+ const [error, setError] = useState134(null);
48922
48958
  const make = async () => {
48923
48959
  setBusy(true);
48924
48960
  setError(null);
@@ -49040,13 +49076,13 @@ async function copyViewMarkdown(args) {
49040
49076
  }
49041
49077
 
49042
49078
  // src/RecordPanel.tsx
49043
- import { Fragment as Fragment65, useState as useState134 } from "react";
49079
+ import { Fragment as Fragment65, useState as useState135 } from "react";
49044
49080
  import { Button as Button106, Separator as Separator13 } from "@ai-matrx/design-system";
49045
49081
  import { useFields as useFields35, useRecord as useRecord4 } from "@ai-matrx/records/react";
49046
49082
  import { Fragment as Fragment66, jsx as jsx160, jsxs as jsxs149 } from "react/jsx-runtime";
49047
49083
  function RecordPanel({ tableId, recordId, onClose, onAskAboutField, onPage = false }) {
49048
49084
  const host = useRecordsUi();
49049
- const [asking, setAsking] = useState134(null);
49085
+ const [asking, setAsking] = useState135(null);
49050
49086
  return /* @__PURE__ */ jsxs149("div", { className: "space-y-3", "data-record-panel": recordId, children: [
49051
49087
  /* @__PURE__ */ jsx160(Peek, { tableId, recordId, onPage, ...onClose ? { onClose } : {} }),
49052
49088
  onPage ? /* @__PURE__ */ jsxs149(Fragment66, { children: [
@@ -49124,7 +49160,7 @@ function LinkedLists({ tableId, recordId }) {
49124
49160
  }
49125
49161
  function RecordAsk({ tableId, recordId }) {
49126
49162
  const host = useRecordsUi();
49127
- const [open, setOpen] = useState134(false);
49163
+ const [open, setOpen] = useState135(false);
49128
49164
  if (!host.chat) return null;
49129
49165
  return /* @__PURE__ */ jsxs149("section", { className: "flex min-w-0 flex-col gap-1.5", "data-record-ask": open ? "open" : "", children: [
49130
49166
  /* @__PURE__ */ jsx160(Separator13, {}),
@@ -49133,7 +49169,7 @@ function RecordAsk({ tableId, recordId }) {
49133
49169
  }
49134
49170
 
49135
49171
  // src/breakDown.tsx
49136
- import { useMemo as useMemo75, useState as useState135 } from "react";
49172
+ import { useMemo as useMemo75, useState as useState136 } from "react";
49137
49173
  import {
49138
49174
  Button as Button107,
49139
49175
  Dialog as Dialog16,
@@ -49173,7 +49209,7 @@ function BreakDownDialog({
49173
49209
  const source = useMemo75(() => ({ kind: "table", id: tableId }), [tableId]);
49174
49210
  const { def } = useDrillDefinition(open ? source : null);
49175
49211
  const dimensions = useMemo75(() => drillDimensionsOf(def, NO_LABELS), [def]);
49176
- const [picked, setPicked] = useState135(null);
49212
+ const [picked, setPicked] = useState136(null);
49177
49213
  const key = picked ?? held?.field ?? dimensions[0]?.key ?? "";
49178
49214
  return /* @__PURE__ */ jsx161(Dialog16, { open, onOpenChange, children: /* @__PURE__ */ jsxs150(DialogContent16, { "data-break-down": "", className: "max-w-sm", children: [
49179
49215
  /* @__PURE__ */ jsx161(DialogHeader16, { children: /* @__PURE__ */ jsx161(DialogTitle16, { children: "Break down by" }) }),
@@ -49200,7 +49236,7 @@ function BreakDownDialog({
49200
49236
 
49201
49237
  // src/TableReference.tsx
49202
49238
  import { copyText as copyText14 } from "@ai-matrx/kit/clipboard";
49203
- import { useCallback as useCallback68, useMemo as useMemo76, useState as useState136 } from "react";
49239
+ import { useCallback as useCallback68, useMemo as useMemo76, useState as useState137 } from "react";
49204
49240
  import { useContentTransferCapabilities as useContentTransferCapabilities2 } from "@ai-matrx/alchemy/react/workspace";
49205
49241
  import { Button as Button108, Dialog as Dialog17, DialogContent as DialogContent17, DialogHeader as DialogHeader17, DialogTitle as DialogTitle17 } from "@ai-matrx/design-system";
49206
49242
  import { jsx as jsx162, jsxs as jsxs151 } from "react/jsx-runtime";
@@ -49228,7 +49264,7 @@ function TableReferenceDialog({
49228
49264
  }) {
49229
49265
  const port = useContentTransferCapabilities2().reference;
49230
49266
  const notify = useRecordsUi().notify;
49231
- const [copied, setCopied] = useState136(null);
49267
+ const [copied, setCopied] = useState137(null);
49232
49268
  const choices = useMemo76(
49233
49269
  () => tableReferenceChoices(table.id, tableName(table)).filter((c) => port?.supports(c.reference)),
49234
49270
  [table, port]
@@ -49257,7 +49293,7 @@ function TableReferenceDialog({
49257
49293
 
49258
49294
  // src/TableDuplicate.tsx
49259
49295
  import { formatCount as formatCount7 } from "@ai-matrx/kit/format";
49260
- import { useState as useState137 } from "react";
49296
+ import { useState as useState138 } from "react";
49261
49297
  import { tableShapeChanged as tableShapeChanged13, useRecordsClient as useRecordsClient98 } from "@ai-matrx/records/react";
49262
49298
  import { Button as Button109, Dialog as Dialog18, DialogContent as DialogContent18, DialogFooter as DialogFooter11, DialogHeader as DialogHeader18, DialogTitle as DialogTitle18, ErrorBox as ErrorBox8, Input as Input10, Switch as Switch5 } from "@ai-matrx/design-system";
49263
49299
  import { Fragment as Fragment67, jsx as jsx163, jsxs as jsxs152 } from "react/jsx-runtime";
@@ -49272,9 +49308,9 @@ function duplicateProgressWords(p) {
49272
49308
  function TableDuplicateDialog({ tableId, name, open, onOpenChange, onDuplicated }) {
49273
49309
  const client = useRecordsClient98();
49274
49310
  const host = useRecordsUi();
49275
- const [typed2, setTyped] = useState137(() => copyNameFor(name));
49276
- const [withRecords, setWithRecords] = useState137(true);
49277
- const [phase, setPhase] = useState137({ kind: "asking" });
49311
+ const [typed2, setTyped] = useState138(() => copyNameFor(name));
49312
+ const [withRecords, setWithRecords] = useState138(true);
49313
+ const [phase, setPhase] = useState138({ kind: "asking" });
49278
49314
  const problem = tableNameProblem(typed2);
49279
49315
  const copying = phase.kind === "copying";
49280
49316
  const close = (next) => {
@@ -49359,7 +49395,7 @@ function TableDuplicateDialog({ tableId, name, open, onOpenChange, onDuplicated
49359
49395
  }
49360
49396
 
49361
49397
  // src/ViewFilter.tsx
49362
- import { useEffect as useEffect116, useMemo as useMemo77, useState as useState138 } from "react";
49398
+ import { useEffect as useEffect117, useMemo as useMemo77, useState as useState139 } from "react";
49363
49399
  import { Button as Button110, Popover as Popover16, PopoverContent as PopoverContent16, PopoverTrigger as PopoverTrigger16 } from "@ai-matrx/design-system";
49364
49400
  import { useFields as useFields36 } from "@ai-matrx/records/react";
49365
49401
  import { jsx as jsx164, jsxs as jsxs153 } from "react/jsx-runtime";
@@ -49373,11 +49409,11 @@ function conditionCount(expr) {
49373
49409
  }
49374
49410
  function ViewFilter({ tableId, view, onApply, className }) {
49375
49411
  const fields = useFields36(tableId);
49376
- const [open, setOpen] = useState138(false);
49412
+ const [open, setOpen] = useState139(false);
49377
49413
  const saved = view?.where ?? null;
49378
- const [draft, setDraft] = useState138(saved);
49414
+ const [draft, setDraft] = useState139(saved);
49379
49415
  const savedKey = JSON.stringify(saved);
49380
- useEffect116(() => {
49416
+ useEffect117(() => {
49381
49417
  setDraft(saved);
49382
49418
  }, [view?.id, savedKey]);
49383
49419
  const conditionFields = useMemo77(
@@ -49552,7 +49588,7 @@ function phoneTableActions(actions) {
49552
49588
  }
49553
49589
 
49554
49590
  // src/toolbarFit.ts
49555
- import { useEffect as useEffect117, useState as useState139 } from "react";
49591
+ import { useEffect as useEffect118, useState as useState140 } from "react";
49556
49592
  var FOLDED_GUESS = { look: 104, chooser: 96, tools: 120 };
49557
49593
  var SLOT_MIN = 36;
49558
49594
  function toolbarFold(input) {
@@ -49609,8 +49645,8 @@ function rowNeeds(row) {
49609
49645
  return { needs: needs + gap * Math.max(0, pieces.length - 1), gap };
49610
49646
  }
49611
49647
  function useToolbarFit(row) {
49612
- const [fold, setFold] = useState139(0);
49613
- useEffect117(() => {
49648
+ const [fold, setFold] = useState140(0);
49649
+ useEffect118(() => {
49614
49650
  if (!row) return;
49615
49651
  const widths = {
49616
49652
  look: { full: null, folded: null },
@@ -49694,8 +49730,8 @@ function clippedEnds(scrollLeft, clientWidth, scrollWidth) {
49694
49730
  return start && end ? "both" : start ? "start" : end ? "end" : "none";
49695
49731
  }
49696
49732
  function useSlotScroll(slot) {
49697
- const [ends, setEnds] = useState139("none");
49698
- useEffect117(() => {
49733
+ const [ends, setEnds] = useState140("none");
49734
+ useEffect118(() => {
49699
49735
  if (!slot) return;
49700
49736
  let pending = 0;
49701
49737
  const read = () => {
@@ -49805,12 +49841,12 @@ function filterInWords(filter, fields) {
49805
49841
  return `${parts.slice(0, -1).join(", ")} and ${parts[parts.length - 1]}`;
49806
49842
  }
49807
49843
  function cameFromLine(label, groupField, question) {
49808
- const asked2 = (question ?? "").trim();
49809
- if (asked2 === "") {
49844
+ const asked3 = (question ?? "").trim();
49845
+ if (asked3 === "") {
49810
49846
  const grouped = groupField ? " grouped into the same columns the chart used" : "";
49811
49847
  return `You came here from \u201C${label}\u201D. This is every record in this table${grouped} \u2014 that number was counted over all of them.`;
49812
49848
  }
49813
- return `You came here from \u201C${label}\u201D. These are only the records that number counted: ${asked2}. Everything else in this table is being held back \u2014 clear the filter to see all of it.`;
49849
+ return `You came here from \u201C${label}\u201D. These are only the records that number counted: ${asked3}. Everything else in this table is being held back \u2014 clear the filter to see all of it.`;
49814
49850
  }
49815
49851
  var TABLE_IS_ARCHIVED = "This table is archived. Its records are kept exactly as they were, and bringing it back puts it in everyone's list again.";
49816
49852
  function TableNotHere({
@@ -49820,10 +49856,10 @@ function TableNotHere({
49820
49856
  className
49821
49857
  }) {
49822
49858
  const client = useRecordsClient99();
49823
- const [archived, setArchived] = useState140({ phase: "asking" });
49824
- const [restoring, setRestoring] = useState140(false);
49825
- const [refusal3, setRefusal] = useState140(null);
49826
- useEffect118(() => {
49859
+ const [archived, setArchived] = useState141({ phase: "asking" });
49860
+ const [restoring, setRestoring] = useState141(false);
49861
+ const [refusal3, setRefusal] = useState141(null);
49862
+ useEffect119(() => {
49827
49863
  let alive = true;
49828
49864
  void client.tableArchived({ table_id: tableId }).then((answered) => {
49829
49865
  if (!alive) return;
@@ -49944,11 +49980,11 @@ var SHARE_NOT_YOURS_LINE = "The link asked to open this table's sharing, and onl
49944
49980
  function openingView(activeView, activeDashboardId) {
49945
49981
  const named = pageViewFromParam(activeView);
49946
49982
  if (named === null) {
49947
- const asked2 = typeof activeView === "string" ? activeView.trim() : "";
49983
+ const asked3 = typeof activeView === "string" ? activeView.trim() : "";
49948
49984
  return {
49949
49985
  main: activeDashboardId ? "dashboards" : "records",
49950
49986
  layout: null,
49951
- unknown: asked2 === "" ? null : asked2
49987
+ unknown: asked3 === "" ? null : asked3
49952
49988
  };
49953
49989
  }
49954
49990
  if (named === "dashboards") return { main: "dashboards", layout: null, unknown: null };
@@ -50037,14 +50073,14 @@ function TablePage({
50037
50073
  }
50038
50074
  );
50039
50075
  const seededViews = seededOpening && (seedViews ?? [defaultView(tableId)]).every((spec) => seedIsSatisfied(spec, seededOpening.views)) ? seededOpening.views : void 0;
50040
- const [view, setView] = useState140(() => {
50076
+ const [view, setView] = useState141(() => {
50041
50077
  if (!seededViews || seededViews.length === 0) return null;
50042
- const asked2 = savedViewFromParam(activeView);
50043
- return seededViews.find((v) => v.id === asked2) ?? defaultViewOf(seededViews) ?? seededViews[0];
50078
+ const asked3 = savedViewFromParam(activeView);
50079
+ return seededViews.find((v) => v.id === asked3) ?? defaultViewOf(seededViews) ?? seededViews[0];
50044
50080
  });
50045
- const [looks, setLooks] = useState140(() => seededViews ? seededOpening?.looks : void 0);
50081
+ const [looks, setLooks] = useState141(() => seededViews ? seededOpening?.looks : void 0);
50046
50082
  const looksSeededFor = useRef62(seededViews && seededOpening ? tableId : null);
50047
- useEffect118(() => {
50083
+ useEffect119(() => {
50048
50084
  if (looksSeededFor.current === tableId) {
50049
50085
  looksSeededFor.current = null;
50050
50086
  return;
@@ -50061,37 +50097,37 @@ function TablePage({
50061
50097
  }, [client, tableId]);
50062
50098
  const look = view && looks ? looks[view.id] : void 0;
50063
50099
  const shown4 = view ? applyLook(view, look) : null;
50064
- const [viewsEpoch, setViewsEpoch] = useState140(0);
50100
+ const [viewsEpoch, setViewsEpoch] = useState141(0);
50065
50101
  const opening = openingRail(activeRecordId, activeRail);
50066
50102
  const recordsUi = useRecordsUi();
50067
50103
  const savedFromLink = savedViewFromParam(activeView);
50068
50104
  const questionsFromLink = questionsFromParam(activeView);
50069
50105
  const openedByPackage = openingView(savedFromLink || questionsFromLink ? null : activeView, activeDashboardId);
50070
50106
  const opened = questionsFromLink ? { ...openedByPackage, main: "questions" } : openedByPackage;
50071
- const [views, setViews] = useState140(() => seededViews);
50072
- const [pickedViewId, setPickedViewId] = useState140(savedFromLink);
50107
+ const [views, setViews] = useState141(() => seededViews);
50108
+ const [pickedViewId, setPickedViewId] = useState141(savedFromLink);
50073
50109
  const viewSeen = useRef62(null);
50074
- const [viewLinkMissed, setViewLinkMissed] = useState140(false);
50110
+ const [viewLinkMissed, setViewLinkMissed] = useState141(false);
50075
50111
  const railAsked = typeof activeRail === "string" ? activeRail.trim() : "";
50076
50112
  const railUnknown = railAsked !== "" && railFromParam(railAsked) === null ? railAsked : null;
50077
50113
  const shareFromLink = railFromParam(activeRail) === "share";
50078
50114
  const canShare = useCanShare();
50079
50115
  const itemFor = (which) => railFromParam(activeRail) === which ? activeItemId ?? null : null;
50080
- const [asking, setAsking] = useState140(null);
50081
- const [layoutFromLink, setLayoutFromLink] = useState140(opened.layout);
50082
- const [surface, setSurface] = useState140({
50116
+ const [asking, setAsking] = useState141(null);
50117
+ const [layoutFromLink, setLayoutFromLink] = useState141(opened.layout);
50118
+ const [surface, setSurface] = useState141({
50083
50119
  main: opened.main,
50084
50120
  rail: opening.rail
50085
50121
  });
50086
50122
  const { main, rail } = surface;
50087
- const [questionDraft, setQuestionDraft] = useState140(null);
50123
+ const [questionDraft, setQuestionDraft] = useState141(null);
50088
50124
  const setRail = (next) => setSurface((now) => ({ ...now, rail: next }));
50089
- const [importEpoch, setImportEpoch] = useState140(0);
50090
- const [openRecord, setOpenRecord] = useState140(opening.record);
50125
+ const [importEpoch, setImportEpoch] = useState141(0);
50126
+ const [openRecord, setOpenRecord] = useState141(opening.record);
50091
50127
  const phone = useIsMobile2();
50092
- const [shareAsked, setShareAsked] = useState140(0);
50128
+ const [shareAsked, setShareAsked] = useState141(0);
50093
50129
  const { open: renameOpen, setOpen: setRenameOpen, ask: askRename, menuContentProps: renameMenuProps } = useRenameFromMenu();
50094
- const [archiveAsked, setArchiveAsked] = useState140(0);
50130
+ const [archiveAsked, setArchiveAsked] = useState141(0);
50095
50131
  const pageArchive = useTableArchive2(tableId);
50096
50132
  const archiveRunning = useRef62(false);
50097
50133
  const archiveFromMenu = useCallback69(async () => {
@@ -50123,14 +50159,14 @@ function TablePage({
50123
50159
  archiveRunning.current = false;
50124
50160
  }
50125
50161
  }, [pageArchive, client, tableId, table.data, recordsUi.notify]);
50126
- const [moveAsked, setMoveAsked] = useState140(0);
50127
- const [duplicateOpen, setDuplicateOpen] = useState140(false);
50128
- const [referenceOpen, setReferenceOpen] = useState140(false);
50129
- const [subscribeOpen, setSubscribeOpen] = useState140(false);
50130
- const [breakDownOpen, setBreakDownOpen] = useState140(false);
50162
+ const [moveAsked, setMoveAsked] = useState141(0);
50163
+ const [duplicateOpen, setDuplicateOpen] = useState141(false);
50164
+ const [referenceOpen, setReferenceOpen] = useState141(false);
50165
+ const [subscribeOpen, setSubscribeOpen] = useState141(false);
50166
+ const [breakDownOpen, setBreakDownOpen] = useState141(false);
50131
50167
  const canGetReference = useCanGetReference();
50132
- const [toolbarSlot, setToolbarSlot] = useState140(null);
50133
- const [toolbarRow, setToolbarRow] = useState140(null);
50168
+ const [toolbarSlot, setToolbarSlot] = useState141(null);
50169
+ const [toolbarRow, setToolbarRow] = useState141(null);
50134
50170
  const toolbarFold2 = useToolbarFit(toolbarRow);
50135
50171
  const slotClipped = useSlotScroll(toolbarSlot);
50136
50172
  const embedded = pagePresentation2 === "embedded";
@@ -50155,7 +50191,7 @@ function TablePage({
50155
50191
  const skeletonFace = skeletonLayoutFor(
50156
50192
  faceUnknown && !layoutFromLink ? rememberedFace ?? shownLayout : shownLayout
50157
50193
  );
50158
- useEffect118(() => {
50194
+ useEffect119(() => {
50159
50195
  if (embedded || faceUnknown || main !== "records" || opened.layout || !table.data) return;
50160
50196
  rememberLayout(tableId, shownLayout);
50161
50197
  }, [embedded, faceUnknown, main, shownLayout, tableId, table.data !== void 0]);
@@ -50175,7 +50211,7 @@ function TablePage({
50175
50211
  const shownSignature = JSON.stringify(shownReport);
50176
50212
  const reportRef = useRef62(onShownViewChange);
50177
50213
  reportRef.current = onShownViewChange;
50178
- useEffect118(() => {
50214
+ useEffect119(() => {
50179
50215
  reportRef.current?.(JSON.parse(shownSignature));
50180
50216
  }, [shownSignature]);
50181
50217
  const pickLayout = (next) => {
@@ -50184,25 +50220,25 @@ function TablePage({
50184
50220
  onViewChanged?.(addressForView(view, next));
50185
50221
  void patchView({ layout: next });
50186
50222
  };
50187
- useEffect118(() => {
50223
+ useEffect119(() => {
50188
50224
  if (!activeRecordId) return;
50189
50225
  setOpenRecord(activeRecordId);
50190
50226
  setSurface((now) => ({ ...now, rail: "record" }));
50191
50227
  }, [activeRecordId]);
50192
- useEffect118(() => {
50228
+ useEffect119(() => {
50193
50229
  if (activeRecordId) return;
50194
50230
  const named = railFromParam(activeRail);
50195
50231
  if (named === null || named === "share") return;
50196
50232
  setSurface((now) => ({ ...now, rail: named }));
50197
50233
  }, [activeRail, activeRecordId]);
50198
- useEffect118(() => {
50234
+ useEffect119(() => {
50199
50235
  const named = pageViewFromParam(activeView);
50200
50236
  if (named === null) return;
50201
50237
  const isLayout = named !== "dashboards" && named !== "archived";
50202
50238
  setLayoutFromLink(isLayout ? named : null);
50203
50239
  setSurface((now) => ({ ...now, main: isLayout ? "records" : named }));
50204
50240
  }, [activeView]);
50205
- const [viewSaveRefused, setViewSaveRefused] = useState140(null);
50241
+ const [viewSaveRefused, setViewSaveRefused] = useState141(null);
50206
50242
  const viewLocked = view?.presentation?.locked === true;
50207
50243
  const unlockView = useCallback69(async () => {
50208
50244
  const current = view;
@@ -50221,14 +50257,14 @@ function TablePage({
50221
50257
  recordsUi.notify?.success(VIEW_LOCKED_REASON, { label: "Unlock", run: () => void unlockView() });
50222
50258
  }, [recordsUi.notify, unlockView]);
50223
50259
  const patchView = useCallback69(
50224
- async (asked2) => {
50260
+ async (asked3) => {
50225
50261
  const current = view;
50226
50262
  if (!current) return;
50227
50263
  if (viewLocked) {
50228
50264
  sayLocked();
50229
50265
  return;
50230
50266
  }
50231
- const part = lookPart(asked2);
50267
+ const part = lookPart(asked3);
50232
50268
  if (Object.keys(part).length === 0) return;
50233
50269
  const before = looks?.[current.id];
50234
50270
  const next = { ...before ?? {}, ...part };
@@ -50236,13 +50272,13 @@ function TablePage({
50236
50272
  setViewSaveRefused(null);
50237
50273
  const kept = await keepLook(client, tableId, current.id, next);
50238
50274
  if (kept.ok) return;
50239
- setViewSaveRefused({ error: kept.error, patch: asked2, lookBefore: before });
50275
+ setViewSaveRefused({ error: kept.error, patch: asked3, lookBefore: before });
50240
50276
  },
50241
50277
  [client, tableId, view, looks, viewLocked, sayLocked]
50242
50278
  );
50243
50279
  const arrival = useRef62(viewAddress ?? null);
50244
- const [gridQuery, setGridQuery] = useState140(null);
50245
- const [addressResetEpoch, setAddressResetEpoch] = useState140(0);
50280
+ const [gridQuery, setGridQuery] = useState141(null);
50281
+ const [addressResetEpoch, setAddressResetEpoch] = useState141(0);
50246
50282
  const reportGrid = useCallback69((q) => {
50247
50283
  const next = { sort: q.sort, filters: q.filters, search: q.search, page: q.page };
50248
50284
  setGridQuery((held) => sameViewAddress(held, next) ? held : next);
@@ -50252,7 +50288,7 @@ function TablePage({
50252
50288
  [reportGrid, addressResetEpoch]
50253
50289
  );
50254
50290
  const hiddenApplied = useRef62(false);
50255
- useEffect118(() => {
50291
+ useEffect119(() => {
50256
50292
  const hidden = arrival.current?.hidden;
50257
50293
  if (hiddenApplied.current || !view || !looks || !hidden || hidden.length === 0) return;
50258
50294
  hiddenApplied.current = true;
@@ -50275,7 +50311,7 @@ function TablePage({
50275
50311
  const addressReportRef = useRef62(onViewAddressChange);
50276
50312
  addressReportRef.current = onViewAddressChange;
50277
50313
  const addressSent = useRef62(null);
50278
- useEffect118(() => {
50314
+ useEffect119(() => {
50279
50315
  if (!addressReady) return;
50280
50316
  if (addressSent.current === null && addressSignature === JSON.stringify(viewAddressToParams(arrival.current))) {
50281
50317
  addressSent.current = addressSignature;
@@ -50287,9 +50323,9 @@ function TablePage({
50287
50323
  }, [addressReady, addressSignature]);
50288
50324
  const queryShowing = !isViewAddressEmpty({ ...gridQuery ?? {}, hidden: [] });
50289
50325
  const lookShowing = Boolean(view && looks && (lookDiffers(view, looks[view.id]) || queryShowing));
50290
- const [lookRefused, setLookRefused] = useState140(null);
50291
- const [namingLook, setNamingLook] = useState140(false);
50292
- const [lookName, setLookName] = useState140("");
50326
+ const [lookRefused, setLookRefused] = useState141(null);
50327
+ const [namingLook, setNamingLook] = useState141(false);
50328
+ const [lookName, setLookName] = useState141("");
50293
50329
  const resetLook = async () => {
50294
50330
  const current = view;
50295
50331
  setAddressResetEpoch((n) => n + 1);
@@ -50352,7 +50388,7 @@ function TablePage({
50352
50388
  setPickedViewId(written.data);
50353
50389
  setViewsEpoch((n) => n + 1);
50354
50390
  };
50355
- const [designateRefused, setDesignateRefused] = useState140(null);
50391
+ const [designateRefused, setDesignateRefused] = useState141(null);
50356
50392
  const opensAs = view?.isDefault ? view.layout : null;
50357
50393
  const canDesignate = Boolean(
50358
50394
  rights.organise && view && layoutShowing && layoutShowing !== opensAs && storeKeepsLayout2(layoutShowing)
@@ -50566,16 +50602,16 @@ function TablePage({
50566
50602
  actionsRef.current = actions;
50567
50603
  const onActionsRef = useRef62(onActions);
50568
50604
  onActionsRef.current = onActions;
50569
- useEffect118(() => {
50605
+ useEffect119(() => {
50570
50606
  onActionsRef.current?.(actionsRef.current);
50571
50607
  });
50572
- useEffect118(() => {
50608
+ useEffect119(() => {
50573
50609
  const onKey = (event) => {
50574
- const asked2 = objectActionForKey(actionsRef.current, event);
50575
- if (!asked2) return;
50610
+ const asked3 = objectActionForKey(actionsRef.current, event);
50611
+ if (!asked3) return;
50576
50612
  event.preventDefault();
50577
- if (asked2.disabledReason !== void 0) recordsUi.notify?.error(`${asked2.label.replace(/…$/, "")}: ${asked2.disabledReason}`);
50578
- else void asked2.run();
50613
+ if (asked3.disabledReason !== void 0) recordsUi.notify?.error(`${asked3.label.replace(/…$/, "")}: ${asked3.disabledReason}`);
50614
+ else void asked3.run();
50579
50615
  };
50580
50616
  window.addEventListener("keydown", onKey);
50581
50617
  return () => window.removeEventListener("keydown", onKey);
@@ -51108,8 +51144,8 @@ var PUBLIC_READ_ONLY = "Public \xB7 read only";
51108
51144
  function usePublicReadOnly(client, organizationId, tableId, table, rights) {
51109
51145
  const readOnly = rights.known && rights.read && !rights.write;
51110
51146
  const marked = table?.published_to_web;
51111
- const [isPublic, setIsPublic] = useState140(false);
51112
- useEffect118(() => {
51147
+ const [isPublic, setIsPublic] = useState141(false);
51148
+ useEffect119(() => {
51113
51149
  if (!readOnly || !table) {
51114
51150
  setIsPublic(false);
51115
51151
  return;
@@ -51135,7 +51171,7 @@ function usePublicReadOnly(client, organizationId, tableId, table, rights) {
51135
51171
  import { formatCount as formatCount8 } from "@ai-matrx/kit/format";
51136
51172
  import { TapTargetSearchGroup as TapTargetSearchGroup2, TooltipProvider } from "@ai-matrx/design-system";
51137
51173
  import { MatrxTableCardShowMore as MatrxTableCardShowMore3 } from "@ai-matrx/design-system/data-table";
51138
- import { useEffect as useEffect119, useMemo as useMemo79, useRef as useRef63, useState as useState141 } from "react";
51174
+ import { useEffect as useEffect120, useMemo as useMemo79, useRef as useRef63, useState as useState142 } from "react";
51139
51175
  import { Button as Button112, ErrorBox as ErrorBox9, Input as Input12, cn as cn98 } from "@ai-matrx/design-system";
51140
51176
  import { SEED_FRESH_MS, useRecordsClient as useRecordsClient100, useSeededAnswerAt } from "@ai-matrx/records/react";
51141
51177
  import { Fragment as Fragment69, jsx as jsx167, jsxs as jsxs156 } from "react/jsx-runtime";
@@ -51152,8 +51188,8 @@ function EntityBoard({ entity, groupBy, cardFields, onOpenRecord, className }) {
51152
51188
  () => cardFields ? entity.columns.filter((c) => cardFields.includes(c.key)) : entity.columns.filter((c) => c !== title && c !== column && c.type !== "choice").slice(0, 2),
51153
51189
  [cardFields, entity.columns, title, column]
51154
51190
  );
51155
- const [refused, setRefused] = useState141(null);
51156
- const [over, setOver] = useState141(null);
51191
+ const [refused, setRefused] = useState142(null);
51192
+ const [over, setOver] = useState142(null);
51157
51193
  if (entity.error) return /* @__PURE__ */ jsx167("p", { className: "px-1 py-3 text-xs text-muted-foreground", children: `This board could not be read: ${entity.error}` });
51158
51194
  if (!entity.loading && !column) {
51159
51195
  return /* @__PURE__ */ jsx167("p", { className: "px-1 py-3 text-xs text-muted-foreground", children: `${entity.label ?? "This table"} has no choice column to make a board of.` });
@@ -51236,16 +51272,16 @@ function blockOfAnswer(answer, base2, by) {
51236
51272
  function EntityChartBlock({ source, kind, by, measure, title, where, organization, centerValue, variant, className }) {
51237
51273
  const client = useRecordsClient100();
51238
51274
  const m = measure ?? { op: "count" };
51239
- const ask = JSON.stringify([source.token, by ?? null, m, where ?? null, organization ?? null]);
51275
+ const ask2 = JSON.stringify([source.token, by ?? null, m, where ?? null, organization ?? null]);
51240
51276
  const question = entityChartQuestion({ by, measure, where, organization });
51241
51277
  const measures = [m.op === "count" ? { op: "count" } : { op: m.op, key: m.of }];
51242
51278
  const base2 = { title: title ?? "", kind, measures, group_by: by ? [by] : [] };
51243
- const seeded = useSeededAnswerAt(`entity-chart:${ask}`, (c) => c.drillAsk({ source, question }));
51244
- const [block, setBlock] = useState141(() => seeded ? blockOfAnswer({ ok: true, data: seeded.data }, base2, by) : null);
51245
- const seededFor = useRef63(seeded ? { ask: `${ask}|${kind}|${title ?? ""}`, at: seeded.at } : null);
51246
- useEffect119(() => {
51279
+ const seeded = useSeededAnswerAt(`entity-chart:${ask2}`, (c) => c.drillAsk({ source, question }));
51280
+ const [block, setBlock] = useState142(() => seeded ? blockOfAnswer({ ok: true, data: seeded.data }, base2, by) : null);
51281
+ const seededFor = useRef63(seeded ? { ask: `${ask2}|${kind}|${title ?? ""}`, at: seeded.at } : null);
51282
+ useEffect120(() => {
51247
51283
  const held = seededFor.current;
51248
- if (held && held.ask === `${ask}|${kind}|${title ?? ""}` && Date.now() - held.at < SEED_FRESH_MS) return;
51284
+ if (held && held.ask === `${ask2}|${kind}|${title ?? ""}` && Date.now() - held.at < SEED_FRESH_MS) return;
51249
51285
  seededFor.current = null;
51250
51286
  let cancelled = false;
51251
51287
  void client.drillAsk({ source, question }).then((answer) => {
@@ -51255,7 +51291,7 @@ function EntityChartBlock({ source, kind, by, measure, title, where, organizatio
51255
51291
  return () => {
51256
51292
  cancelled = true;
51257
51293
  };
51258
- }, [client, ask, kind, title]);
51294
+ }, [client, ask2, kind, title]);
51259
51295
  if (!block) {
51260
51296
  return /* @__PURE__ */ jsx167(RecordsSkeleton, { layout: "chart", embedded: variant === "bare", ...className ? { className } : {} });
51261
51297
  }
@@ -51288,20 +51324,20 @@ function EntityTablePageBody({
51288
51324
  actions,
51289
51325
  className
51290
51326
  }) {
51291
- const [typed2, setTyped] = useState141("");
51327
+ const [typed2, setTyped] = useState142("");
51292
51328
  const term = searchOverride ?? typed2;
51293
51329
  const entity = useEntityTable(source.token, { pageSize, search: term });
51294
- const [layout, setLayout] = useState141(opened);
51295
- useEffect119(() => setLayout(opened), [opened]);
51330
+ const [layout, setLayout] = useState142(opened);
51331
+ useEffect120(() => setLayout(opened), [opened]);
51296
51332
  const choose = (next) => {
51297
51333
  setLayout(next);
51298
51334
  onLayoutChange?.(next);
51299
51335
  };
51300
51336
  const boardable = entityChoiceColumns(entity.columns).length > 0;
51301
51337
  const nameColumn = entityNameColumn(entity.columns);
51302
- const [naming, setNaming] = useState141(null);
51303
- const [adding, setAdding] = useState141(false);
51304
- const [addRefused, setAddRefused] = useState141(null);
51338
+ const [naming, setNaming] = useState142(null);
51339
+ const [adding, setAdding] = useState142(false);
51340
+ const [addRefused, setAddRefused] = useState142(null);
51305
51341
  const add = async () => {
51306
51342
  const name = (naming ?? "").trim();
51307
51343
  if (!name || !nameColumn || adding) return;
@@ -51313,7 +51349,7 @@ function EntityTablePageBody({
51313
51349
  setNaming(null);
51314
51350
  onOpenRecord?.(made.id);
51315
51351
  };
51316
- const [question, setQuestion] = useState141(() => questionFromGrouping(void 0));
51352
+ const [question, setQuestion] = useState142(() => questionFromGrouping(void 0));
51317
51353
  const { config: drill } = useDrill({
51318
51354
  source,
51319
51355
  question,
@@ -51418,7 +51454,7 @@ function TablePage2(props) {
51418
51454
  }
51419
51455
 
51420
51456
  // src/DataBindingPicker.tsx
51421
- import { useEffect as useEffect120, useMemo as useMemo80 } from "react";
51457
+ import { useEffect as useEffect121, useMemo as useMemo80 } from "react";
51422
51458
  import { isEntityReferenceConfig } from "@ai-matrx/records";
51423
51459
  import { useFields as useFields38, useTable as useTable38 } from "@ai-matrx/records/react";
51424
51460
  import { BasicInput as BasicInput36, Button as Button113, CreatablePicker as CreatablePicker3, cn as cn99 } from "@ai-matrx/design-system";
@@ -51514,7 +51550,7 @@ function BindingDetails({
51514
51550
  const fields = useFields38(tableId);
51515
51551
  const fieldList = useMemo80(() => fields.data ?? [], [fields.data]);
51516
51552
  const shape = binding.semantic_type;
51517
- useEffect120(() => {
51553
+ useEffect121(() => {
51518
51554
  if (disabled || shape === "value" || binding.transform || fields.loading || fieldList.length === 0) return;
51519
51555
  onChange({
51520
51556
  ...binding,
@@ -51736,7 +51772,7 @@ function RecordNameWords({ tableId, recordId }) {
51736
51772
  }
51737
51773
 
51738
51774
  // src/HeldChangeDecision.tsx
51739
- import { useEffect as useEffect121, useState as useState142 } from "react";
51775
+ import { useEffect as useEffect122, useState as useState143 } from "react";
51740
51776
  import { RecordsProvider as RecordsProvider3, useRecordsClient as useRecordsClient101 } from "@ai-matrx/records/react";
51741
51777
  import { Button as Button114 } from "@ai-matrx/design-system";
51742
51778
  import { jsx as jsx171, jsxs as jsxs159 } from "react/jsx-runtime";
@@ -51749,10 +51785,10 @@ function Decision({
51749
51785
  approveLabel
51750
51786
  }) {
51751
51787
  const client = useRecordsClient101();
51752
- const [may, setMay] = useState142(null);
51753
- const [busy, setBusy] = useState142(null);
51754
- const [error, setError] = useState142(null);
51755
- useEffect121(() => {
51788
+ const [may, setMay] = useState143(null);
51789
+ const [busy, setBusy] = useState143(null);
51790
+ const [error, setError] = useState143(null);
51791
+ useEffect122(() => {
51756
51792
  let live = true;
51757
51793
  void client.workApprovalMayDecide({ approval_id: approvalId }).then((res) => {
51758
51794
  if (!live) return;
@@ -51785,14 +51821,14 @@ function Decision({
51785
51821
  }
51786
51822
 
51787
51823
  // src/CalendarLinks.tsx
51788
- import { useCallback as useCallback70, useEffect as useEffect122, useState as useState143 } from "react";
51824
+ import { useCallback as useCallback70, useEffect as useEffect123, useState as useState144 } from "react";
51789
51825
  import { Button as Button115 } from "@ai-matrx/design-system";
51790
51826
  import { jsx as jsx172, jsxs as jsxs160 } from "react/jsx-runtime";
51791
51827
  var day = (iso) => iso ? new Date(iso).toLocaleDateString(void 0, { year: "numeric", month: "short", day: "numeric" }) : null;
51792
51828
  function CalendarLinks({ port }) {
51793
- const [rows, setRows] = useState143(null);
51794
- const [error, setError] = useState143(null);
51795
- const [fresh, setFresh] = useState143(null);
51829
+ const [rows, setRows] = useState144(null);
51830
+ const [error, setError] = useState144(null);
51831
+ const [fresh, setFresh] = useState144(null);
51796
51832
  const load = useCallback70(async () => {
51797
51833
  try {
51798
51834
  setRows(await port.list());
@@ -51801,7 +51837,7 @@ function CalendarLinks({ port }) {
51801
51837
  setError(asRefusal3(e, "The links could not be read"));
51802
51838
  }
51803
51839
  }, [port]);
51804
- useEffect122(() => {
51840
+ useEffect123(() => {
51805
51841
  void load();
51806
51842
  }, [load]);
51807
51843
  const act = async (run) => {
@@ -51866,7 +51902,7 @@ function CalendarLinks({ port }) {
51866
51902
  }
51867
51903
 
51868
51904
  // src/TemplatePreview.tsx
51869
- import { useEffect as useEffect123, useMemo as useMemo81, useState as useState144 } from "react";
51905
+ import { useEffect as useEffect124, useMemo as useMemo81, useState as useState145 } from "react";
51870
51906
  import { templatePreview } from "@ai-matrx/records/memory";
51871
51907
  import { useRecordsClient as useRecordsClient102 } from "@ai-matrx/records/react";
51872
51908
  import { formFromSummary as formFromSummary3 } from "@ai-matrx/records/forms";
@@ -51878,7 +51914,7 @@ function TemplatePreview({ spec, today, initialTable, host, aside, booking, clas
51878
51914
  const preview = useTemplatePreview(spec, today);
51879
51915
  const bound2 = useMemo81(() => ({ ...host, sayLevelNeeded: false }), [host]);
51880
51916
  const first = preview.tables.find((t) => t.token === initialTable) ?? preview.tables[0];
51881
- const [active, setActive] = useState144(first?.id ?? null);
51917
+ const [active, setActive] = useState145(first?.id ?? null);
51882
51918
  const table = preview.tables.find((t) => t.id === active) ?? first;
51883
51919
  if (!table) return null;
51884
51920
  return /* @__PURE__ */ jsxs161("div", { className: ["flex min-w-0 flex-col gap-3", className].filter(Boolean).join(" "), "data-template-preview": preview.tables.length, children: [
@@ -51916,9 +51952,9 @@ function TemplatePreview({ spec, today, initialTable, host, aside, booking, clas
51916
51952
  }
51917
51953
  function PreviewForms({ preview, booking }) {
51918
51954
  const client = useRecordsClient102();
51919
- const [forms, setForms] = useState144(null);
51920
- const [pages, setPages] = useState144([]);
51921
- useEffect123(() => {
51955
+ const [forms, setForms] = useState145(null);
51956
+ const [pages, setPages] = useState145([]);
51957
+ useEffect124(() => {
51922
51958
  let gone = false;
51923
51959
  void client.forms().then((answered) => {
51924
51960
  if (!gone) setForms(answered.ok ? answered.data.map(formFromSummary3) : []);