@nivaro/react 0.3.46 → 0.3.48

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.
Files changed (57) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +248 -16
  4. package/dist/index.js +679 -659
  5. package/dist/shared/components/CollectionBrowserView.js +813 -826
  6. package/dist/shared/components/ErrorNotice.js +169 -0
  7. package/dist/shared/components/ErrorSurface.js +23 -17
  8. package/dist/shared/components/ListLoadError.js +8 -29
  9. package/dist/shared/components/LoadErrorNote.js +38 -21
  10. package/dist/shared/components/QueryErrorState.js +8 -11
  11. package/dist/shared/components/ReportView.js +1320 -1291
  12. package/dist/shared/components/chat/ChannelArchive.js +60 -60
  13. package/dist/shared/components/chat/ChannelExtras.js +74 -74
  14. package/dist/shared/components/chat/ChatPanel.js +368 -367
  15. package/dist/shared/components/command-center/PeekPanel.js +33 -32
  16. package/dist/shared/components/command-center/panels/BoardSettings.js +41 -40
  17. package/dist/shared/components/command-center/panels/PeoplePanel.js +32 -31
  18. package/dist/shared/components/help-videos/editor/ClipsPanel.js +49 -48
  19. package/dist/shared/components/help-videos/editor/PublishButton.js +37 -36
  20. package/dist/shared/components/help-videos/editor/StatsTab.js +45 -44
  21. package/dist/shared/components/help-videos/editor/VersionsTab.js +29 -28
  22. package/dist/shared/components/help-videos/library/AuthorRolesButton.js +19 -18
  23. package/dist/shared/components/help-videos/library/HelpVideoLibrary.js +132 -129
  24. package/dist/shared/components/help-videos/library/LearningPathsPanel.js +42 -41
  25. package/dist/shared/components/help-videos/settings/HouseStyleButton.js +21 -20
  26. package/dist/shared/components/help-videos/settings/RenderSettingsButton.js +22 -21
  27. package/dist/shared/components/import/DocumentAutofillButton.js +24 -20
  28. package/dist/shared/components/import/ImportFromFileButton.js +61 -60
  29. package/dist/shared/components/imports/ImportStalenessControl.js +20 -21
  30. package/dist/shared/components/imports/NewImportDialog.js +29 -28
  31. package/dist/shared/components/imports/RunDetailSheet.js +63 -63
  32. package/dist/shared/components/item-edit/FieldRow.js +329 -329
  33. package/dist/shared/components/item-edit/InlineTableField.js +898 -898
  34. package/dist/shared/components/item-edit/PersonalDefaultControl.js +57 -56
  35. package/dist/shared/components/item-edit/PlanGrid.js +220 -221
  36. package/dist/shared/components/item-edit/RecordGrantTools.js +49 -48
  37. package/dist/shared/components/item-edit/placement-behaviour.js +68 -67
  38. package/dist/shared/components/layout-editor/inspector/ColumnFit.js +24 -23
  39. package/dist/shared/components/layout-editor/inspector/PickerPreview.js +17 -16
  40. package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +41 -41
  41. package/dist/shared/components/layout-editor/outputs/output-api.js +33 -31
  42. package/dist/shared/components/layout-editor/overview/overview-api.js +84 -83
  43. package/dist/shared/components/layout-editor/useLayoutDraft.js +47 -42
  44. package/dist/shared/components/monitoring/InactiveUserLinksView.js +10 -9
  45. package/dist/shared/components/panels/SlaClock.js +35 -36
  46. package/dist/shared/components/pipeline/PipelineEditorView.js +311 -312
  47. package/dist/shared/components/pipeline/TeamSuggestions.js +31 -30
  48. package/dist/shared/components/profile/AgentsPanel.js +73 -72
  49. package/dist/shared/components/profile/MailSuppressedPill.js +22 -21
  50. package/dist/shared/components/support/SupportRequestDialog.js +85 -81
  51. package/dist/shared/components/support/SupportView.js +94 -87
  52. package/dist/shared/lib/autofill-poll.js +21 -18
  53. package/dist/shared/lib/error-actions.js +85 -0
  54. package/dist/shared/lib/error-message.js +223 -82
  55. package/dist/shared/lib/error-toast.js +71 -13
  56. package/dist/shared/lib/safe-error.js +136 -38
  57. package/package.json +1 -1
@@ -7,13 +7,14 @@ import { useNivaroClient as sa, useParentDraft as ra, useItemEditAuth as oa } fr
7
7
  import { get as ue, post as lt } from "../../lib/commands.js";
8
8
  import { useAfterIdle as ia } from "../../lib/defer.js";
9
9
  import { evaluateNumeric as et } from "../../lib/expression.js";
10
- import { cn as I, formatRelative as da } from "../../lib/utils.js";
10
+ import { userErrorMessage as da } from "../../lib/safe-error.js";
11
+ import { cn as I, formatRelative as ca } from "../../lib/utils.js";
11
12
  import { Popover as rt, PopoverTrigger as ot, PopoverContent as it } from "../ui/popover.js";
12
- import { resolveCompareEndpoint as ca, useCompareSeries as ua, compareColumnClosed as pa, planLabel as Et, closedThroughLabel as ma, CompareProposalBanner as ha, CompareStripChips as fa, GridStatChip as Ct, monthLabel as nt, extraSeriesValue as ve, SeriesFigurePopover as _t, monthLabelLong as Re, unitWord as xa } from "./CompareSeries.js";
13
- import { useO2MStaging as ga, useLiveRows as ya } from "./O2MStagingContext.js";
14
- import { usePlanGridHost as ba } from "./PlanGridHost.js";
15
- import { RowHistorySheet as ka } from "./RowHistorySheet.js";
16
- import { RowWatchButton as va } from "./RowWatchButton.js";
13
+ import { resolveCompareEndpoint as ua, useCompareSeries as pa, compareColumnClosed as ma, planLabel as Et, closedThroughLabel as ha, CompareProposalBanner as fa, CompareStripChips as xa, GridStatChip as Ct, monthLabel as nt, extraSeriesValue as ve, SeriesFigurePopover as _t, monthLabelLong as Re, unitWord as ga } from "./CompareSeries.js";
14
+ import { useO2MStaging as ya, useLiveRows as ba } from "./O2MStagingContext.js";
15
+ import { usePlanGridHost as ka } from "./PlanGridHost.js";
16
+ import { RowHistorySheet as va } from "./RowHistorySheet.js";
17
+ import { RowWatchButton as Na } from "./RowWatchButton.js";
17
18
  const Ke = "unclassified", B = (_) => Number(_) || 0, E = (_) => Math.round(_ * 100) / 100;
18
19
  function D(_) {
19
20
  const n = Math.abs(_ - Math.round(_)) < 5e-3;
@@ -27,25 +28,25 @@ function D(_) {
27
28
  function Tt(_) {
28
29
  const n = _.replace(/[$,\s]/g, "");
29
30
  if (n === "" || n === "-" || n === "—") return 0;
30
- const c = /^\(.*\)$/.test(n), x = Number(c ? n.slice(1, -1) : n);
31
- return Number.isFinite(x) ? E(c ? -x : x) : null;
31
+ const p = /^\(.*\)$/.test(n), y = Number(p ? n.slice(1, -1) : n);
32
+ return Number.isFinite(y) ? E(p ? -y : y) : null;
32
33
  }
33
- function Na(_) {
34
- const { column: n, actual: c, openColumns: x, mode: o } = _, $ = _.targetRow != null, M = E(B(_.row[n]) - c), K = { [n]: E(c) }, F = _.targetRow ?? _.row, L = $ ? {} : K;
35
- if (o === "none" || Math.abs(M) < 5e-3 || x.length === 0)
34
+ function wa(_) {
35
+ const { column: n, actual: p, openColumns: y, mode: o } = _, $ = _.targetRow != null, M = E(B(_.row[n]) - p), K = { [n]: E(p) }, F = _.targetRow ?? _.row, L = $ ? {} : K;
36
+ if (o === "none" || Math.abs(M) < 5e-3 || y.length === 0)
36
37
  return { patch: K, moved: 0, unabsorbed: o === "none" ? 0 : M, targets: [] };
37
38
  let f, b;
38
- if (o === "next" ? (f = [x[0]], b = [1]) : o === "weighted" ? (f = x.filter((g) => B(F[g]) > 5e-3), b = f.map((g) => B(F[g])), f.length === 0 && $ && M > 0 && (f = x, b = f.map(() => 1))) : (f = x, b = f.map(() => 1)), f.length === 0) return { patch: K, moved: 0, unabsorbed: M, targets: [] };
39
- const C = b.reduce((g, j) => g + j, 0) || 1;
39
+ if (o === "next" ? (f = [y[0]], b = [1]) : o === "weighted" ? (f = y.filter((x) => B(F[x]) > 5e-3), b = f.map((x) => B(F[x])), f.length === 0 && $ && M > 0 && (f = y, b = f.map(() => 1))) : (f = y, b = f.map(() => 1)), f.length === 0) return { patch: K, moved: 0, unabsorbed: M, targets: [] };
40
+ const C = b.reduce((x, j) => x + j, 0) || 1;
40
41
  let k = M;
41
- if (f.forEach((g, j) => {
42
- const v = j === f.length - 1 ? k : E(M * b[j] / C), y = Math.max(0, E(B(F[g]) + v)), i = E(y - B(F[g]));
43
- L[g] = y, k = E(k - i);
42
+ if (f.forEach((x, j) => {
43
+ const v = j === f.length - 1 ? k : E(M * b[j] / C), g = Math.max(0, E(B(F[x]) + v)), i = E(g - B(F[x]));
44
+ L[x] = g, k = E(k - i);
44
45
  }), Math.abs(k) >= 5e-3 && k < 0)
45
- for (const g of f) {
46
+ for (const x of f) {
46
47
  if (Math.abs(k) < 5e-3) break;
47
- const j = Math.min(L[g], -k);
48
- L[g] = E(L[g] - j), k = E(k + j);
48
+ const j = Math.min(L[x], -k);
49
+ L[x] = E(L[x] - j), k = E(k + j);
49
50
  }
50
51
  return $ ? {
51
52
  patch: K,
@@ -56,11 +57,11 @@ function Na(_) {
56
57
  } : { patch: L, moved: E(M - k), unabsorbed: k, targets: f };
57
58
  }
58
59
  const St = 176, Ot = 112, Lt = 128, xe = "sticky left-0 z-[2] bg-white dark:bg-[hsl(var(--card))] border-r border-slate-200 dark:border-border", ge = "sticky right-0 z-[2] bg-white dark:bg-[hsl(var(--card))] border-l border-slate-200 dark:border-border", Ne = "bg-slate-50 dark:bg-white/[0.035]";
59
- function Wa(_) {
60
+ function Qa(_) {
60
61
  const {
61
62
  relatedCollection: n,
62
- manyField: c,
63
- parentId: x,
63
+ manyField: p,
64
+ parentId: y,
64
65
  config: o,
65
66
  compareSeries: $,
66
67
  stats: M,
@@ -69,24 +70,24 @@ function Wa(_) {
69
70
  readOnly: L = !1,
70
71
  showHistory: f = !0,
71
72
  emptyLabel: b
72
- } = _, C = sa(), k = Yt(), g = ga(), j = ya(), T = ra(), v = T == null ? void 0 : T.draft, { isAdmin: y } = oa(), i = !x || x === "new", U = !L && !!g, m = o.value_fields, R = o.total_field ?? null, {
73
+ } = _, C = sa(), k = Yt(), x = ya(), j = ba(), T = ra(), v = T == null ? void 0 : T.draft, { isAdmin: g } = oa(), i = !y || y === "new", U = !L && !!x, m = o.value_fields, R = o.total_field ?? null, {
73
74
  data: q = [],
74
75
  isLoading: oe,
75
76
  dataUpdatedAt: be
76
77
  } = ce({
77
- queryKey: ["o2m-rows", n, c, x, ""],
78
+ queryKey: ["o2m-rows", n, p, y, ""],
78
79
  queryFn: () => C.request(
79
- ue(`/items/${n}`, { filter: JSON.stringify({ [c]: { _eq: x } }), limit: 200 })
80
+ ue(`/items/${n}`, { filter: JSON.stringify({ [p]: { _eq: y } }), limit: 200 })
80
81
  ).then((e) => e.data ?? []),
81
82
  enabled: !i,
82
83
  staleTime: 3e4
83
84
  }), P = ia(2e3), { data: le = {} } = ce({
84
- queryKey: ["o2m-cell-provenance", n, c, x, be],
85
+ queryKey: ["o2m-cell-provenance", n, p, y, be],
85
86
  queryFn: () => C.request(
86
87
  ue("/revisions/o2m-cell-provenance", {
87
88
  collection: n,
88
- many_field: c,
89
- parent_id: x
89
+ many_field: p,
90
+ parent_id: y
90
91
  })
91
92
  ).then((e) => e.data ?? {}),
92
93
  enabled: P && f && !i && q.length > 0,
@@ -112,16 +113,16 @@ function Wa(_) {
112
113
  []
113
114
  );
114
115
  const Ee = G(
115
- () => $ != null && $.endpoint ? ca($.endpoint, v) : null,
116
+ () => $ != null && $.endpoint ? ua($.endpoint, v) : null,
116
117
  [$ == null ? void 0 : $.endpoint, v]
117
- ), Be = ua({
118
+ ), Be = pa({
118
119
  client: C,
119
120
  endpoint: Ee,
120
121
  enabled: !!$ && !i
121
- }), u = $ && !i ? Be.data ?? null : null, me = G(() => !o.split_endpoint || i ? null : o.split_endpoint.replace(
122
+ }), c = $ && !i ? Be.data ?? null : null, me = G(() => !o.split_endpoint || i ? null : o.split_endpoint.replace(
122
123
  /\$parent\.([A-Za-z_][A-Za-z0-9_]*)/g,
123
- (e, a) => String(a === "id" ? x : (v == null ? void 0 : v[a]) ?? "")
124
- ), [o.split_endpoint, i, x, v]), Ie = G(() => ["plan-grid-split-info", me], [me]), { data: ie = null } = ce({
124
+ (e, a) => String(a === "id" ? y : (v == null ? void 0 : v[a]) ?? "")
125
+ ), [o.split_endpoint, i, y, v]), Ie = G(() => ["plan-grid-split-info", me], [me]), { data: ie = null } = ce({
125
126
  queryKey: Ie,
126
127
  queryFn: () => C.request(ue(me)).then((e) => e.data ?? null).catch(() => null),
127
128
  enabled: !!me,
@@ -139,19 +140,19 @@ function Wa(_) {
139
140
  }), we = ee(
140
141
  (e) => e === Ke ? o.unclassified_label ?? "Unclassified" : dt[e] ?? `#${e}`,
141
142
  [dt, o.unclassified_label]
142
- ), De = G(() => (o.categories ?? []).map(String), [o.categories]), ct = (g == null ? void 0 : g.getPendingRows(n, c)) ?? [], Te = g == null ? void 0 : g.getPendingEdits(n, c), qe = g == null ? void 0 : g.getPendingDeletes(n, c), Z = G(() => {
143
+ ), De = G(() => (o.categories ?? []).map(String), [o.categories]), ct = (x == null ? void 0 : x.getPendingRows(n, p)) ?? [], Te = x == null ? void 0 : x.getPendingEdits(n, p), qe = x == null ? void 0 : x.getPendingDeletes(n, p), Z = G(() => {
143
144
  const e = [], a = (l) => l && typeof l == "object" && "id" in l ? l.id : l;
144
145
  for (const l of q) {
145
146
  const s = String(l.id);
146
147
  if (qe != null && qe.has(s)) continue;
147
- const r = Te == null ? void 0 : Te.get(s), p = r ? { ...l, ...r } : l, O = a(p[o.category_field]);
148
+ const r = Te == null ? void 0 : Te.get(s), u = r ? { ...l, ...r } : l, O = a(u[o.category_field]);
148
149
  e.push({
149
150
  uid: `s:${s}`,
150
151
  id: s,
151
152
  pendingIndex: null,
152
- key: String(a(p[o.key_field]) ?? ""),
153
+ key: String(a(u[o.key_field]) ?? ""),
153
154
  cat: O == null || O === "" ? null : String(O),
154
- values: p,
155
+ values: u,
155
156
  edited: !!r && Object.keys(r).some((H) => !H.startsWith("_")),
156
157
  isNew: !1
157
158
  });
@@ -181,32 +182,32 @@ function Wa(_) {
181
182
  }
182
183
  for (const a of e.values())
183
184
  a.cats.length && (a.mode = "split", a.cats.sort((l, s) => {
184
- const r = De.indexOf(l.cat), p = De.indexOf(s.cat);
185
- return (r < 0 ? 99 : r) - (p < 0 ? 99 : p);
185
+ const r = De.indexOf(l.cat), u = De.indexOf(s.cat);
186
+ return (r < 0 ? 99 : r) - (u < 0 ? 99 : u);
186
187
  }));
187
- for (const a of (u == null ? void 0 : u.rows) ?? []) {
188
+ for (const a of (c == null ? void 0 : c.rows) ?? []) {
188
189
  const l = String(a.key);
189
190
  e.has(l) || m.some((s) => Math.abs(B(a.values[s])) >= 5e-3) && e.set(l, { key: l, mode: "ghost", top: null, cats: [] });
190
191
  }
191
192
  return [...e.values()].sort(
192
193
  (a, l) => Number(a.key) - Number(l.key) || a.key.localeCompare(l.key)
193
194
  );
194
- }, [Z, u, m, De]), $e = G(
195
+ }, [Z, c, m, De]), $e = G(
195
196
  () => Z.map((e) => R ? { ...e.values, [R]: Y(e.values) } : e.values),
196
197
  [Z, R, Y]
197
198
  ), he = j == null ? void 0 : j.report;
198
199
  ye(() => {
199
200
  if (he) {
200
201
  if (oe) {
201
- he(n, c, null);
202
+ he(n, p, null);
202
203
  return;
203
204
  }
204
- he(n, c, $e);
205
+ he(n, p, $e);
205
206
  }
206
- }, [he, n, c, $e, oe]);
207
+ }, [he, n, p, $e, oe]);
207
208
  const ut = Me(() => {
208
209
  });
209
- ut.current = () => he == null ? void 0 : he(n, c, null), ye(() => () => ut.current(), []);
210
+ ut.current = () => he == null ? void 0 : he(n, p, null), ye(() => () => ut.current(), []);
210
211
  const Ce = ee(
211
212
  (e) => {
212
213
  if (e.startsWith("$parent.")) return (v == null ? void 0 : v[e.slice(8)]) ?? 0;
@@ -235,25 +236,25 @@ function Wa(_) {
235
236
  left: E(e.cap - a)
236
237
  };
237
238
  }) : [], [ie, Z, Y]), J = ee(
238
- (e, a) => pa(u, e, a),
239
- [u]
239
+ (e, a) => ma(c, e, a),
240
+ [c]
240
241
  ), Pe = ee(
241
- (e, a) => !U || J(e, a) && !!(u != null && u.closed_locked) && !y,
242
- [U, J, u == null ? void 0 : u.closed_locked, y]
242
+ (e, a) => !U || J(e, a) && !!(c != null && c.closed_locked) && !g,
243
+ [U, J, c == null ? void 0 : c.closed_locked, g]
243
244
  ), Se = ee(
244
245
  (e, a, l) => {
245
- var p, O, H;
246
- const s = u == null ? void 0 : u.rows.find((A) => String(A.key) === e);
246
+ var u, O, H;
247
+ const s = c == null ? void 0 : c.rows.find((A) => String(A.key) === e);
247
248
  if (!s) return { value: 0, details: [] };
248
- if (a == null) return { value: B(s.values[l]), details: ((p = s.details) == null ? void 0 : p[l]) ?? [] };
249
+ if (a == null) return { value: B(s.values[l]), details: ((u = s.details) == null ? void 0 : u[l]) ?? [] };
249
250
  const r = (O = s.by_category) == null ? void 0 : O[a];
250
251
  return { value: B(r == null ? void 0 : r.values[l]), details: ((H = r == null ? void 0 : r.details) == null ? void 0 : H[l]) ?? [] };
251
252
  },
252
- [u]
253
+ [c]
253
254
  ), [mt, He] = W(null), X = ee(
254
255
  (e, a, l, s) => {
255
- if (!g) return !1;
256
- const r = (s == null ? void 0 : s.credit) ?? 0, p = { ...e.values, ...a }, O = Y(e.values), H = Y(p);
256
+ if (!x) return !1;
257
+ const r = (s == null ? void 0 : s.credit) ?? 0, u = { ...e.values, ...a }, O = Y(e.values), H = Y(u);
257
258
  if (H - r > O + 5e-3) {
258
259
  if (K) {
259
260
  const A = et(K.cap, Ce), S = E(Ue - O + H - r);
@@ -273,64 +274,64 @@ function Wa(_) {
273
274
  }
274
275
  }
275
276
  }
276
- return He(null), e.id ? g.queueEdit(n, c, e.id, {
277
+ return He(null), e.id ? x.queueEdit(n, p, e.id, {
277
278
  ...a,
278
279
  ...l ? { _change_reason: l } : {},
279
280
  ...s != null && s.early ? { __flush_early: !0 } : {}
280
- }) : e.pendingIndex != null && g.updateRow(n, c, e.pendingIndex, {
281
+ }) : e.pendingIndex != null && x.updateRow(n, p, e.pendingIndex, {
281
282
  ...e.values,
282
283
  ...a,
283
284
  ...l ? { _change_reason: l } : {}
284
285
  }), !0;
285
286
  },
286
- [g, Y, K, Ce, Ue, _e, n, c]
287
+ [x, Y, K, Ce, Ue, _e, n, p]
287
288
  ), Oe = ee(
288
289
  (e, a, l, s) => {
289
- g && g.queueRow(n, c, {
290
+ x && x.queueRow(n, p, {
290
291
  [o.key_field]: e,
291
292
  ...s != null ? { [o.category_field]: /^\d+$/.test(s) ? Number(s) : s } : {},
292
293
  ...Object.fromEntries(m.map((r) => [r, (a == null ? void 0 : a[r]) ?? 0])),
293
294
  ...l ? { _change_reason: l } : {}
294
295
  });
295
296
  },
296
- [g, n, c, o.key_field, o.category_field, m]
297
+ [x, n, p, o.key_field, o.category_field, m]
297
298
  ), { data: We } = ce({
298
299
  queryKey: ["plan-grid-keys", o.key_collection],
299
300
  queryFn: () => C.request(
300
301
  ue(`/items/${o.key_collection}`, { fields: "id", sort: "-id", limit: 200 })
301
302
  ).then((e) => (e.data ?? []).map((a) => a.id)),
302
- enabled: !!o.key_collection && !!(u != null && u.closed_through),
303
+ enabled: !!o.key_collection && !!(c != null && c.closed_through),
303
304
  staleTime: 10 * 6e4
304
305
  }), ze = ee(
305
306
  (e, a) => {
306
307
  const l = Number(e);
307
308
  if (!Number.isInteger(l)) return null;
308
- const s = String(l + 1), r = m.filter((A) => !J(s, A)), p = re.find((A) => A.key === s);
309
+ const s = String(l + 1), r = m.filter((A) => !J(s, A)), u = re.find((A) => A.key === s);
309
310
  let O = null, H = null;
310
- return o.key_collection && We && !We.some((A) => String(A) === s) ? H = `${s} is not set up yet` : r.length === 0 ? H = `${s} has no open period either` : (p == null ? void 0 : p.mode) === "split" ? a == null ? H = `${s} is planned by category and this line is not` : O = p.cats.find((A) => A.cat === a) ?? null : (p == null ? void 0 : p.mode) === "top" && (a != null ? H = `${s} is planned as one line and this one is by category` : O = p.top), { key: s, cat: a, openColumns: r, row: O, blocked: H };
311
+ return o.key_collection && We && !We.some((A) => String(A) === s) ? H = `${s} is not set up yet` : r.length === 0 ? H = `${s} has no open period either` : (u == null ? void 0 : u.mode) === "split" ? a == null ? H = `${s} is planned by category and this line is not` : O = u.cats.find((A) => A.cat === a) ?? null : (u == null ? void 0 : u.mode) === "top" && (a != null ? H = `${s} is planned as one line and this one is by category` : O = u.top), { key: s, cat: a, openColumns: r, row: O, blocked: H };
311
312
  },
312
313
  [m, J, re, o.key_collection, We]
313
314
  ), Qe = ee(
314
315
  (e, a, l, s) => {
315
316
  if (!s || Object.keys(s.patch).length === 0) return X(e, a, l);
316
- const r = E(Y({ ...e.values, ...a }) - Y(e.values)), p = s.target.row, O = E(
317
- Y({ ...(p == null ? void 0 : p.values) ?? {}, ...s.patch }) - Y((p == null ? void 0 : p.values) ?? {})
317
+ const r = E(Y({ ...e.values, ...a }) - Y(e.values)), u = s.target.row, O = E(
318
+ Y({ ...(u == null ? void 0 : u.values) ?? {}, ...s.patch }) - Y((u == null ? void 0 : u.values) ?? {})
318
319
  );
319
- return r <= 0 ? p ? X(p, s.patch, l, { credit: -r }) ? X(e, a, l, { early: !0 }) : !1 : O > -r + 5e-3 || !X(e, a, l, { early: !0 }) ? !1 : (Oe(Number(s.target.key), s.patch, l, s.target.cat), !0) : p ? X(e, a, l, { credit: -O }) ? X(p, s.patch, l, { early: !0 }) : !1 : X(e, a, l);
320
+ return r <= 0 ? u ? X(u, s.patch, l, { credit: -r }) ? X(e, a, l, { early: !0 }) : !1 : O > -r + 5e-3 || !X(e, a, l, { early: !0 }) ? !1 : (Oe(Number(s.target.key), s.patch, l, s.target.cat), !0) : u ? X(e, a, l, { credit: -O }) ? X(u, s.patch, l, { early: !0 }) : !1 : X(e, a, l);
320
321
  },
321
322
  [X, Y, Oe]
322
323
  ), jt = ee(
323
324
  (e) => {
324
- if (!g) return;
325
+ if (!x) return;
325
326
  const a = [...e.top ? [e.top] : [], ...e.cats];
326
327
  for (const l of a.filter((s) => s.pendingIndex != null).sort((s, r) => (r.pendingIndex ?? 0) - (s.pendingIndex ?? 0)))
327
- g.removeRow(n, c, l.pendingIndex);
328
- for (const l of a) l.id && g.queueDelete(n, c, l.id);
328
+ x.removeRow(n, p, l.pendingIndex);
329
+ for (const l of a) l.id && x.queueDelete(n, p, l.id);
329
330
  },
330
- [g, n, c]
331
+ [x, n, p]
331
332
  ), Ft = ee(() => {
332
- k.invalidateQueries({ queryKey: ["o2m-rows", n, c, x] }), k.invalidateQueries({ queryKey: Ie }), Ee && k.invalidateQueries({ queryKey: ["o2m-compare", Ee] });
333
- }, [k, n, c, x, Ie, Ee]), Ve = Me(null), fe = G(() => {
333
+ k.invalidateQueries({ queryKey: ["o2m-rows", n, p, y] }), k.invalidateQueries({ queryKey: Ie }), Ee && k.invalidateQueries({ queryKey: ["o2m-compare", Ee] });
334
+ }, [k, n, p, y, Ie, Ee]), Ve = Me(null), fe = G(() => {
334
335
  const e = [];
335
336
  for (const a of re)
336
337
  if (a.mode === "top" && a.top && e.push(a.top.uid), a.mode === "split") for (const l of a.cats) e.push(l.uid);
@@ -341,22 +342,22 @@ function Wa(_) {
341
342
  return l ? (l.focus(), l.select(), !0) : !1;
342
343
  }, []), ft = ee(
343
344
  (e, a, l, s) => {
344
- let r = fe.indexOf(e), p = m.indexOf(a);
345
+ let r = fe.indexOf(e), u = m.indexOf(a);
345
346
  for (let O = 0; O < 40; O++)
346
- if (r += l, p += s, r < 0 || r >= fe.length || p < 0 || p >= m.length || ht(fe[r], m[p])) return;
347
+ if (r += l, u += s, r < 0 || r >= fe.length || u < 0 || u >= m.length || ht(fe[r], m[u])) return;
347
348
  },
348
349
  [fe, m, ht]
349
350
  ), xt = ee(
350
351
  (e, a, l) => {
351
352
  const s = l.replace(/\r/g, "").split(`
352
- `).filter((H) => H.trim() !== ""), r = fe.indexOf(e.uid), p = m.indexOf(a);
353
+ `).filter((H) => H.trim() !== ""), r = fe.indexOf(e.uid), u = m.indexOf(a);
353
354
  let O = 0;
354
355
  s.forEach((H, A) => {
355
356
  const S = Z.find((te) => te.uid === fe[r + A]);
356
357
  if (!S) return;
357
358
  const Q = {};
358
359
  H.split(" ").forEach((te, h) => {
359
- const w = m[p + h];
360
+ const w = m[u + h];
360
361
  if (!w || Pe(S.key, w)) return;
361
362
  const ae = Tt(te);
362
363
  ae == null || ae < 0 || (Q[w] = ae);
@@ -374,11 +375,11 @@ function Wa(_) {
374
375
  Je.current = null;
375
376
  }, 8e3), gt((r) => {
376
377
  if (!r.has(s.key)) return r;
377
- const p = new Set(r);
378
- return p.delete(s.key), p;
378
+ const u = new Set(r);
379
+ return u.delete(s.key), u;
379
380
  }), window.setTimeout(() => {
380
- var p;
381
- const r = (p = Ve.current) == null ? void 0 : p.querySelector(`[data-o2m-row="${n}:${s.id}"]`);
381
+ var u;
382
+ const r = (u = Ve.current) == null ? void 0 : u.querySelector(`[data-o2m-row="${n}:${s.id}"]`);
382
383
  r && (r.scrollIntoView({ block: "center", behavior: "smooth" }), r.classList.remove("nvr-row-flash"), r.offsetWidth, r.classList.add("nvr-row-flash"));
383
384
  }, 60)));
384
385
  };
@@ -387,17 +388,17 @@ function Wa(_) {
387
388
  const [Kt, Bt] = W(() => {
388
389
  try {
389
390
  return new Set(
390
- JSON.parse(localStorage.getItem(`nvr_pg_dismissed:${n}:${x}`) ?? "[]")
391
+ JSON.parse(localStorage.getItem(`nvr_pg_dismissed:${n}:${y}`) ?? "[]")
391
392
  );
392
393
  } catch {
393
394
  return /* @__PURE__ */ new Set();
394
395
  }
395
- }), yt = ((u == null ? void 0 : u.proposals) ?? []).filter((e) => !Kt.has(e.id)), bt = (e, a) => {
396
+ }), yt = ((c == null ? void 0 : c.proposals) ?? []).filter((e) => !Kt.has(e.id)), bt = (e, a) => {
396
397
  Bt((l) => {
397
398
  const s = new Set(l).add(e.id);
398
399
  if (a)
399
400
  try {
400
- localStorage.setItem(`nvr_pg_dismissed:${n}:${x}`, JSON.stringify([...s]));
401
+ localStorage.setItem(`nvr_pg_dismissed:${n}:${y}`, JSON.stringify([...s]));
401
402
  } catch {
402
403
  }
403
404
  return s;
@@ -407,33 +408,33 @@ function Wa(_) {
407
408
  for (const l of e.rows) {
408
409
  const s = String(l.key), r = re.find((S) => S.key === s);
409
410
  if ((r == null ? void 0 : r.mode) === "split" != (l.category != null)) continue;
410
- const p = e.mode === "add", O = Object.fromEntries(
411
+ const u = e.mode === "add", O = Object.fromEntries(
411
412
  Object.entries(l.values).filter(
412
- ([S, Q]) => m.includes(S) && !J(s, S) && (p ? B(Q) !== 0 : B(Q) > 0)
413
+ ([S, Q]) => m.includes(S) && !J(s, S) && (u ? B(Q) !== 0 : B(Q) > 0)
413
414
  )
414
415
  ), H = (S) => Object.fromEntries(
415
416
  Object.entries(O).map(([Q, te]) => [Q, Math.max(0, E(B(S == null ? void 0 : S[Q]) + B(te)))]).filter(([Q, te]) => Math.abs(te - B(S == null ? void 0 : S[Q])) >= 5e-3)
416
417
  ), A = l.category != null ? r == null ? void 0 : r.cats.find((S) => String(S.cat) === String(l.category)) : null;
417
418
  if (l.category != null) {
418
419
  if (!A) continue;
419
- const S = p ? H(A.values) : Object.fromEntries(Object.entries(O).filter(([Q]) => B(A.values[Q]) === 0));
420
+ const S = u ? H(A.values) : Object.fromEntries(Object.entries(O).filter(([Q]) => B(A.values[Q]) === 0));
420
421
  Object.keys(S).length && X(A, S, e.change_reason) && (a += Object.keys(S).length);
421
422
  } else if (r != null && r.top) {
422
- const S = p ? H(r.top.values) : Object.fromEntries(Object.entries(O).filter(([Q]) => {
423
+ const S = u ? H(r.top.values) : Object.fromEntries(Object.entries(O).filter(([Q]) => {
423
424
  var te;
424
425
  return B((te = r.top) == null ? void 0 : te.values[Q]) === 0;
425
426
  }));
426
427
  Object.keys(S).length && X(r.top, S, e.change_reason) && (a += Object.keys(S).length);
427
- } else Object.keys(O).length && !(p && Object.values(O).every((S) => B(S) < 0)) && (Oe(l.key, p ? H(void 0) : O, e.change_reason), a += Object.keys(O).length);
428
+ } else Object.keys(O).length && !(u && Object.values(O).every((S) => B(S) < 0)) && (Oe(l.key, u ? H(void 0) : O, e.change_reason), a += Object.keys(O).length);
428
429
  }
429
430
  a ? de.success(
430
431
  `${e.label}: ${a} ${a === 1 ? "figure" : "figures"} staged — Save to keep them`
431
432
  ) : de.message(
432
433
  e.mode === "add" ? "Nothing to move — no open period could take it" : "Nothing to fill — those periods already hold a figure"
433
434
  ), bt(e, !1);
434
- }, [V, Ge] = W(null), je = ba(), Ze = V && (je != null && je.renderRowHistory) ? je.renderRowHistory({
435
+ }, [V, Ge] = W(null), je = ka(), Ze = V && (je != null && je.renderRowHistory) ? je.renderRowHistory({
435
436
  collection: n,
436
- parentId: x,
437
+ parentId: y,
437
438
  rowId: V.id,
438
439
  key: V.key,
439
440
  category: V.cat,
@@ -451,7 +452,7 @@ function Wa(_) {
451
452
  queryFn: () => C.request(ue(`/field-config/${n}`)).then((e) => e.data ?? []),
452
453
  enabled: !!V,
453
454
  staleTime: 5 * 6e4
454
- }), [Ye, Ht] = W(!1), vt = re.some((e) => e.mode === "split"), Fe = Et(u), ke = (u == null ? void 0 : u.label) ?? ($ == null ? void 0 : $.label) ?? "Actual", Ae = ma(u == null ? void 0 : u.closed_through), Le = u != null && u.closed_through ? Number(u.closed_through.split("-")[0]) : null, Wt = G(() => {
455
+ }), [Ye, Ht] = W(!1), vt = re.some((e) => e.mode === "split"), Fe = Et(c), ke = (c == null ? void 0 : c.label) ?? ($ == null ? void 0 : $.label) ?? "Actual", Ae = ha(c == null ? void 0 : c.closed_through), Le = c != null && c.closed_through ? Number(c.closed_through.split("-")[0]) : null, Wt = G(() => {
455
456
  if (Le == null) return null;
456
457
  const e = m.filter((a) => J(String(Le), a));
457
458
  return e[e.length - 1] ?? null;
@@ -461,10 +462,10 @@ function Wa(_) {
461
462
  ), Qt = F ? et(F, Ce) : null, Vt = (e) => {
462
463
  let a = Qt ?? 0;
463
464
  if (e.cat != null) {
464
- const p = _e.find((O) => O.id === e.cat);
465
- p && (a = Math.min(a, p.left));
465
+ const u = _e.find((O) => O.id === e.cat);
466
+ u && (a = Math.min(a, u.left));
466
467
  }
467
- const l = m.filter((p) => !J(e.key, p) && B(e.values[p]) === 0);
468
+ const l = m.filter((u) => !J(e.key, u) && B(e.values[u]) === 0);
468
469
  if (a < 5e-3 || l.length === 0) {
469
470
  de.message(
470
471
  a < 5e-3 ? "Nothing is left to spread" : "No empty open periods on this line"
@@ -472,15 +473,15 @@ function Wa(_) {
472
473
  return;
473
474
  }
474
475
  const s = Math.floor(a / l.length * 100) / 100, r = {};
475
- l.forEach((p, O) => {
476
- r[p] = O === l.length - 1 ? E(a - s * (l.length - 1)) : s;
476
+ l.forEach((u, O) => {
477
+ r[u] = O === l.length - 1 ? E(a - s * (l.length - 1)) : s;
477
478
  }), X(e, r) && de.success(`${D(a)} spread over ${l.length} open periods`);
478
479
  }, Xe = G(() => {
479
480
  const e = {}, a = {};
480
481
  for (const l of m)
481
- e[l] = E(Z.reduce((s, r) => s + B(r.values[l]), 0)), a[l] = E(((u == null ? void 0 : u.rows) ?? []).reduce((s, r) => s + B(r.values[l]), 0));
482
+ e[l] = E(Z.reduce((s, r) => s + B(r.values[l]), 0)), a[l] = E(((c == null ? void 0 : c.rows) ?? []).reduce((s, r) => s + B(r.values[l]), 0));
482
483
  return { planBy: e, actualBy: a };
483
- }, [m, Z, u]), Jt = St + m.length * Ot + Lt;
484
+ }, [m, Z, c]), Jt = St + m.length * Ot + Lt;
484
485
  return !i && oe ? /* @__PURE__ */ t("div", { className: "space-y-1.5", "data-plan-grid-loading": !0, children: [0, 1, 2].map((e) => /* @__PURE__ */ t(
485
486
  "div",
486
487
  {
@@ -489,8 +490,8 @@ function Wa(_) {
489
490
  },
490
491
  e
491
492
  )) }) : /* @__PURE__ */ d("div", { ref: Ve, "data-plan-grid": n, className: "min-w-0", children: [
492
- u && yt.length > 0 && U && /* @__PURE__ */ t(
493
- ha,
493
+ c && yt.length > 0 && U && /* @__PURE__ */ t(
494
+ fa,
494
495
  {
495
496
  proposals: yt,
496
497
  onApply: It,
@@ -499,9 +500,9 @@ function Wa(_) {
499
500
  ),
500
501
  (pt.length > 0 || $) && /* @__PURE__ */ d("div", { className: "mb-2 flex flex-wrap items-center gap-1.5", "data-o2m-stats": !0, children: [
501
502
  /* @__PURE__ */ t(
502
- fa,
503
+ xa,
503
504
  {
504
- data: u,
505
+ data: c,
505
506
  loading: !!$ && !i && Be.isLoading,
506
507
  error: !!$ && !i && Be.isError
507
508
  }
@@ -585,7 +586,7 @@ function Wa(_) {
585
586
  "span",
586
587
  {
587
588
  "data-plan-grid-lock": !0,
588
- "data-tip": `Closed through ${Ae ?? ""}${u != null && u.closed_rule ? ` — ${u.closed_rule}` : ""}`,
589
+ "data-tip": `Closed through ${Ae ?? ""}${c != null && c.closed_rule ? ` — ${c.closed_rule}` : ""}`,
589
590
  className: "inline-flex",
590
591
  children: /* @__PURE__ */ t(
591
592
  Xt,
@@ -629,9 +630,9 @@ function Wa(_) {
629
630
  const l = !At.has(e.key), s = (h) => {
630
631
  var w;
631
632
  return e.mode === "split" ? E(e.cats.reduce((ae, Gt) => ae + B(Gt.values[h]), 0)) : B((w = e.top) == null ? void 0 : w.values[h]);
632
- }, r = E(m.reduce((h, w) => h + s(w), 0)), p = m.some(
633
+ }, r = E(m.reduce((h, w) => h + s(w), 0)), u = m.some(
633
634
  (h) => Math.abs(Se(e.key, Ke, h).value) >= 5e-3
634
- ), O = ((u == null ? void 0 : u.series) ?? []).filter(
635
+ ), O = ((c == null ? void 0 : c.series) ?? []).filter(
635
636
  (h) => m.some((w) => Math.abs(ve(h, e.key, w) ?? 0) >= 5e-3)
636
637
  ), H = m.some((h) => Math.abs(Se(e.key, null, h).value) >= 5e-3), A = (((S = e.top) == null ? void 0 : S.edited) || ((Q = e.top) == null ? void 0 : Q.isNew) || e.cats.some((h) => h.edited || h.isNew)) ?? !1;
637
638
  return /* @__PURE__ */ d(
@@ -675,7 +676,7 @@ function Wa(_) {
675
676
  ),
676
677
  /* @__PURE__ */ t("span", { className: "ml-auto text-[10.5px] font-medium text-slate-500 dark:text-slate-400", children: e.mode === "ghost" ? "" : Fe }),
677
678
  U && e.mode !== "ghost" && /* @__PURE__ */ t(
678
- Ca,
679
+ _a,
679
680
  {
680
681
  block: e,
681
682
  config: o,
@@ -737,7 +738,7 @@ function Wa(_) {
737
738
  prov: ne(e.top, h),
738
739
  cellKey: z(e.top, h),
739
740
  locked: Pe(e.key, h),
740
- lockedTip: w ? (u == null ? void 0 : u.closed_locked_message) ?? "This period is closed" : void 0,
741
+ lockedTip: w ? (c == null ? void 0 : c.closed_locked_message) ?? "This period is closed" : void 0,
741
742
  onCommit: (ae) => X(e.top, { [h]: ae }),
742
743
  onMove: ft,
743
744
  onPaste: xt
@@ -758,14 +759,14 @@ function Wa(_) {
758
759
  ]
759
760
  }
760
761
  ),
761
- u && /* @__PURE__ */ t(
762
+ c && /* @__PURE__ */ t(
762
763
  at,
763
764
  {
764
765
  label: ke,
765
766
  blockKey: e.key,
766
767
  cat: null,
767
768
  cols: m,
768
- compare: u,
769
+ compare: c,
769
770
  planOf: s,
770
771
  actualFor: Se,
771
772
  isClosed: J,
@@ -833,7 +834,7 @@ function Wa(_) {
833
834
  }
834
835
  )
835
836
  ] }, h.key)),
836
- e.mode === "split" && l && e.cats.map((h) => /* @__PURE__ */ d(wa, { children: [
837
+ e.mode === "split" && l && e.cats.map((h) => /* @__PURE__ */ d($a, { children: [
837
838
  /* @__PURE__ */ d(
838
839
  "tr",
839
840
  {
@@ -854,7 +855,7 @@ function Wa(_) {
854
855
  prov: ne(h, w),
855
856
  cellKey: z(h, w),
856
857
  locked: Pe(e.key, w),
857
- lockedTip: J(e.key, w) ? (u == null ? void 0 : u.closed_locked_message) ?? "This period is closed" : void 0,
858
+ lockedTip: J(e.key, w) ? (c == null ? void 0 : c.closed_locked_message) ?? "This period is closed" : void 0,
858
859
  onCommit: (ae) => X(h, { [w]: ae }),
859
860
  onMove: ft,
860
861
  onPaste: xt
@@ -874,14 +875,14 @@ function Wa(_) {
874
875
  ]
875
876
  }
876
877
  ),
877
- u && H && /* @__PURE__ */ t(
878
+ c && H && /* @__PURE__ */ t(
878
879
  at,
879
880
  {
880
881
  label: ke,
881
882
  blockKey: e.key,
882
883
  cat: h.cat,
883
884
  cols: m,
884
- compare: u,
885
+ compare: c,
885
886
  planOf: (w) => B(h.values[w]),
886
887
  actualFor: Se,
887
888
  isClosed: J,
@@ -893,7 +894,7 @@ function Wa(_) {
893
894
  }
894
895
  )
895
896
  ] }, h.uid)),
896
- e.mode === "split" && l && u && p && /* @__PURE__ */ t(
897
+ e.mode === "split" && l && c && u && /* @__PURE__ */ t(
897
898
  at,
898
899
  {
899
900
  label: `${we(Ke)} · ${ke.toLowerCase()}`,
@@ -901,7 +902,7 @@ function Wa(_) {
901
902
  blockKey: e.key,
902
903
  cat: Ke,
903
904
  cols: m,
904
- compare: u,
905
+ compare: c,
905
906
  planOf: () => 0,
906
907
  actualFor: Se,
907
908
  isClosed: J,
@@ -943,7 +944,7 @@ function Wa(_) {
943
944
  }
944
945
  )
945
946
  ] }),
946
- u && /* @__PURE__ */ d("tr", { children: [
947
+ c && /* @__PURE__ */ d("tr", { children: [
947
948
  /* @__PURE__ */ t("td", { className: I(xe, "px-2 pb-1.5 pt-0"), children: /* @__PURE__ */ t("span", { className: "block text-right text-[10.5px] font-medium text-slate-500 dark:text-slate-400", children: ke }) }),
948
949
  m.map((e) => /* @__PURE__ */ t(
949
950
  "td",
@@ -981,7 +982,7 @@ function Wa(_) {
981
982
  ),
982
983
  U && /* @__PURE__ */ d("div", { className: "mt-2 flex items-center gap-2", children: [
983
984
  /* @__PURE__ */ t(
984
- Oa,
985
+ La,
985
986
  {
986
987
  config: o,
987
988
  client: C,
@@ -990,11 +991,11 @@ function Wa(_) {
990
991
  label: `Add ${tt(o.key_field).toLowerCase()}`
991
992
  }
992
993
  ),
993
- (u == null ? void 0 : u.closed_locked) && !y && Ae && /* @__PURE__ */ t("span", { className: "text-[11.5px] text-slate-500 dark:text-slate-400", children: `Periods through ${Ae} are closed — open a highlighted ${ke.toLowerCase()} figure to reconcile one.` })
994
+ (c == null ? void 0 : c.closed_locked) && !g && Ae && /* @__PURE__ */ t("span", { className: "text-[11.5px] text-slate-500 dark:text-slate-400", children: `Periods through ${Ae} are closed — open a highlighted ${ke.toLowerCase()} figure to reconcile one.` })
994
995
  ] }),
995
996
  Ze,
996
997
  V && Ze == null && /* @__PURE__ */ t(
997
- ka,
998
+ va,
998
999
  {
999
1000
  open: !0,
1000
1001
  onOpenChange: (e) => {
@@ -1007,7 +1008,7 @@ function Wa(_) {
1007
1008
  displayCols: kt.filter(
1008
1009
  (e) => m.includes(e.field) || e.field === o.category_field
1009
1010
  ),
1010
- parentField: c,
1011
+ parentField: p,
1011
1012
  m2oRelMap: /* @__PURE__ */ new Map(),
1012
1013
  relations: [],
1013
1014
  collection: n,
@@ -1023,14 +1024,14 @@ function Wa(_) {
1023
1024
  function tt(_) {
1024
1025
  return _.replace(/_/g, " ").replace(/^\w/, (n) => n.toUpperCase());
1025
1026
  }
1026
- function wa(_) {
1027
+ function $a(_) {
1027
1028
  return /* @__PURE__ */ t(Zt, { children: _.children });
1028
1029
  }
1029
1030
  function se(_) {
1030
1031
  return Math.abs(_.n) < 5e-3 ? /* @__PURE__ */ t("span", { className: "text-slate-400 dark:text-slate-500", children: "—" }) : /* @__PURE__ */ t("span", { children: D(_.n) });
1031
1032
  }
1032
1033
  function Mt(_) {
1033
- const { row: n, col: c, closed: x, locked: o, lockedTip: $, prov: M, cellKey: K, onCommit: F, onMove: L, onPaste: f } = _, b = B(n.values[c]), C = M ? `${Re(c)} · changed ${da(M.at)} by ${M.who}${M.reason ? `
1034
+ const { row: n, col: p, closed: y, locked: o, lockedTip: $, prov: M, cellKey: K, onCommit: F, onMove: L, onPaste: f } = _, b = B(n.values[p]), C = M ? `${Re(p)} · changed ${ca(M.at)} by ${M.who}${M.reason ? `
1034
1035
  Reason: “${M.reason}”` : ""}` : void 0, k = M != null && M.reason ? /* @__PURE__ */ t(
1035
1036
  "span",
1036
1037
  {
@@ -1038,18 +1039,18 @@ Reason: “${M.reason}”` : ""}` : void 0, k = M != null && M.reason ? /* @__PU
1038
1039
  "data-cell-reason": !0,
1039
1040
  className: "pointer-events-none absolute left-0 top-0 h-0 w-0 border-r-[6px] border-t-[6px] border-r-transparent border-t-nvr-cyan"
1040
1041
  }
1041
- ) : null, [g, j] = W(null), T = Me(!1);
1042
+ ) : null, [x, j] = W(null), T = Me(!1);
1042
1043
  if (o)
1043
1044
  return /* @__PURE__ */ d(
1044
1045
  "td",
1045
1046
  {
1046
- "data-plan-locked": x ? "closed" : "readonly",
1047
+ "data-plan-locked": y ? "closed" : "readonly",
1047
1048
  "data-tip": [$, C].filter(Boolean).join(`
1048
1049
  `) || void 0,
1049
1050
  "data-grid-cell": K,
1050
1051
  className: I(
1051
1052
  "relative px-2.5 py-1 text-right text-slate-700 dark:text-slate-200",
1052
- x && Ne
1053
+ y && Ne
1053
1054
  ),
1054
1055
  children: [
1055
1056
  k,
@@ -1058,22 +1059,22 @@ Reason: “${M.reason}”` : ""}` : void 0, k = M != null && M.reason ? /* @__PU
1058
1059
  }
1059
1060
  );
1060
1061
  const v = () => {
1061
- if (g == null) return;
1062
- const y = Tt(g);
1062
+ if (x == null) return;
1063
+ const g = Tt(x);
1063
1064
  if (j(null), T.current) {
1064
1065
  T.current = !1;
1065
1066
  return;
1066
1067
  }
1067
- if (y == null || y < 0) {
1068
+ if (g == null || g < 0) {
1068
1069
  de.error("Enter an amount of zero or more");
1069
1070
  return;
1070
1071
  }
1071
- Math.abs(y - b) < 5e-3 || F(y);
1072
+ Math.abs(g - b) < 5e-3 || F(g);
1072
1073
  };
1073
1074
  return /* @__PURE__ */ d(
1074
1075
  "td",
1075
1076
  {
1076
- className: I("relative p-0", x && Ne),
1077
+ className: I("relative p-0", y && Ne),
1077
1078
  "data-grid-cell": K,
1078
1079
  "data-tip": C,
1079
1080
  children: [
@@ -1081,23 +1082,23 @@ Reason: “${M.reason}”` : ""}` : void 0, k = M != null && M.reason ? /* @__PU
1081
1082
  /* @__PURE__ */ t(
1082
1083
  "input",
1083
1084
  {
1084
- "data-pg-cell": `${n.uid}:${c}`,
1085
- "aria-label": `${Re(c)} ${n.key}`,
1085
+ "data-pg-cell": `${n.uid}:${p}`,
1086
+ "aria-label": `${Re(p)} ${n.key}`,
1086
1087
  inputMode: "decimal",
1087
- value: g ?? (b === 0 ? "" : D(b)),
1088
+ value: x ?? (b === 0 ? "" : D(b)),
1088
1089
  placeholder: "—",
1089
- onFocus: (y) => {
1090
- j(b === 0 ? "" : String(b)), requestAnimationFrame(() => y.target.select());
1090
+ onFocus: (g) => {
1091
+ j(b === 0 ? "" : String(b)), requestAnimationFrame(() => g.target.select());
1091
1092
  },
1092
- onChange: (y) => j(y.target.value),
1093
+ onChange: (g) => j(g.target.value),
1093
1094
  onBlur: v,
1094
- onPaste: (y) => {
1095
- const i = y.clipboardData.getData("text");
1096
- /[\t\n]/.test(i.trim()) && (y.preventDefault(), T.current = !0, y.target.blur(), f(n, c, i));
1095
+ onPaste: (g) => {
1096
+ const i = g.clipboardData.getData("text");
1097
+ /[\t\n]/.test(i.trim()) && (g.preventDefault(), T.current = !0, g.target.blur(), f(n, p, i));
1097
1098
  },
1098
- onKeyDown: (y) => {
1099
- const i = y.currentTarget, U = i.selectionStart === 0 && i.selectionEnd === 0, m = i.selectionStart === i.value.length && i.selectionEnd === i.value.length;
1100
- y.key === "Enter" || y.key === "ArrowDown" ? (y.preventDefault(), v(), L(n.uid, c, 1, 0)) : y.key === "ArrowUp" ? (y.preventDefault(), v(), L(n.uid, c, -1, 0)) : y.key === "ArrowLeft" && U ? (y.preventDefault(), v(), L(n.uid, c, 0, -1)) : y.key === "ArrowRight" && m ? (y.preventDefault(), v(), L(n.uid, c, 0, 1)) : y.key === "Escape" && (T.current = !0, i.blur());
1099
+ onKeyDown: (g) => {
1100
+ const i = g.currentTarget, U = i.selectionStart === 0 && i.selectionEnd === 0, m = i.selectionStart === i.value.length && i.selectionEnd === i.value.length;
1101
+ g.key === "Enter" || g.key === "ArrowDown" ? (g.preventDefault(), v(), L(n.uid, p, 1, 0)) : g.key === "ArrowUp" ? (g.preventDefault(), v(), L(n.uid, p, -1, 0)) : g.key === "ArrowLeft" && U ? (g.preventDefault(), v(), L(n.uid, p, 0, -1)) : g.key === "ArrowRight" && m ? (g.preventDefault(), v(), L(n.uid, p, 0, 1)) : g.key === "Escape" && (T.current = !0, i.blur());
1101
1102
  },
1102
1103
  className: "h-[30px] w-full bg-transparent px-2.5 text-right text-[12px] tabular-nums text-slate-900 outline-none placeholder:text-slate-400 hover:bg-muted/60 focus:bg-white focus:shadow-[inset_0_0_0_2px_rgb(var(--nvr-cyan-rgb))] dark:text-slate-100 dark:placeholder:text-slate-500 dark:focus:bg-[hsl(var(--background))]"
1103
1104
  }
@@ -1109,8 +1110,8 @@ Reason: “${M.reason}”` : ""}` : void 0, k = M != null && M.reason ? /* @__PU
1109
1110
  function at(_) {
1110
1111
  const {
1111
1112
  label: n,
1112
- tip: c,
1113
- blockKey: x,
1113
+ tip: p,
1114
+ blockKey: y,
1114
1115
  cat: o,
1115
1116
  cols: $,
1116
1117
  compare: M,
@@ -1121,41 +1122,41 @@ function at(_) {
1121
1122
  canReconcile: b,
1122
1123
  onReconcile: C,
1123
1124
  carryFor: k,
1124
- plain: g
1125
- } = _, j = E($.reduce((T, v) => T + F(x, o, v).value, 0));
1125
+ plain: x
1126
+ } = _, j = E($.reduce((T, v) => T + F(y, o, v).value, 0));
1126
1127
  return /* @__PURE__ */ d("tr", { "data-plan-actual": o ?? "all", children: [
1127
1128
  /* @__PURE__ */ t("td", { className: I(xe, "px-2 pb-1 pt-0"), children: /* @__PURE__ */ t(
1128
1129
  "span",
1129
1130
  {
1130
- "data-tip": c,
1131
+ "data-tip": p,
1131
1132
  className: "block text-right text-[10.5px] font-medium text-slate-500 dark:text-slate-400",
1132
1133
  children: n
1133
1134
  }
1134
1135
  ) }),
1135
1136
  $.map((T) => {
1136
- const v = L(x, T), y = F(x, o, T), i = K(T), U = !g && v && Math.abs(y.value - i) >= 5e-3, m = !g && !v && y.value > i + 5e-3;
1137
+ const v = L(y, T), g = F(y, o, T), i = K(T), U = !x && v && Math.abs(g.value - i) >= 5e-3, m = !x && !v && g.value > i + 5e-3;
1137
1138
  return /* @__PURE__ */ t(
1138
1139
  "td",
1139
1140
  {
1140
1141
  "data-compare-cell": T,
1141
1142
  className: I("px-2.5 pb-1 pt-0 text-right text-[11.5px]", v && Ne),
1142
- children: Math.abs(y.value) < 5e-3 && !U ? /* @__PURE__ */ t("span", { className: "text-slate-400 dark:text-slate-500", children: "—" }) : /* @__PURE__ */ t(
1143
- $a,
1143
+ children: Math.abs(g.value) < 5e-3 && !U ? /* @__PURE__ */ t("span", { className: "text-slate-400 dark:text-slate-500", children: "—" }) : /* @__PURE__ */ t(
1144
+ Ca,
1144
1145
  {
1145
- title: `${Re(T)} ${x}`,
1146
+ title: `${Re(T)} ${y}`,
1146
1147
  compare: M,
1147
1148
  actualName: n,
1148
- actual: y.value,
1149
+ actual: g.value,
1149
1150
  planned: i,
1150
1151
  closed: v,
1151
- plain: !!g,
1152
- details: y.details,
1152
+ plain: !!x,
1153
+ details: g.details,
1153
1154
  tone: U ? "warn" : m ? "danger" : "neutral",
1154
1155
  reconcile: U && b && f ? {
1155
1156
  row: f,
1156
1157
  column: T,
1157
- openColumns: $.filter((R) => !L(x, R)),
1158
- carry: (k == null ? void 0 : k(x, o)) ?? null,
1158
+ openColumns: $.filter((R) => !L(y, R)),
1159
+ carry: (k == null ? void 0 : k(y, o)) ?? null,
1159
1160
  onApply: (R, q, oe) => C(f, R, q, oe)
1160
1161
  } : null
1161
1162
  }
@@ -1181,12 +1182,12 @@ const Rt = {
1181
1182
  danger: "text-red-700 dark:text-red-300 font-medium",
1182
1183
  neutral: "text-slate-600 dark:text-slate-300"
1183
1184
  };
1184
- function $a(_) {
1185
+ function Ca(_) {
1185
1186
  var z, ne;
1186
- const { title: n, compare: c, actualName: x, actual: o, planned: $, closed: M, plain: K, details: F, tone: L, reconcile: f } = _, [b, C] = W(!1), [k, g] = W("next"), [j, T] = W(""), v = Et(c), y = E($ - o), i = f && f.openColumns.length === 0 && f.carry && !f.carry.blocked ? f.carry : null, U = f && f.openColumns.length === 0 ? ((z = f.carry) == null ? void 0 : z.blocked) ?? null : null, m = i ? ((ne = i.row) == null ? void 0 : ne.values) ?? {} : (f == null ? void 0 : f.row.values) ?? {}, R = i ? i.openColumns : (f == null ? void 0 : f.openColumns) ?? [], q = G(
1187
+ const { title: n, compare: p, actualName: y, actual: o, planned: $, closed: M, plain: K, details: F, tone: L, reconcile: f } = _, [b, C] = W(!1), [k, x] = W("next"), [j, T] = W(""), v = Et(p), g = E($ - o), i = f && f.openColumns.length === 0 && f.carry && !f.carry.blocked ? f.carry : null, U = f && f.openColumns.length === 0 ? ((z = f.carry) == null ? void 0 : z.blocked) ?? null : null, m = i ? ((ne = i.row) == null ? void 0 : ne.values) ?? {} : (f == null ? void 0 : f.row.values) ?? {}, R = i ? i.openColumns : (f == null ? void 0 : f.openColumns) ?? [], q = G(
1187
1188
  () => {
1188
1189
  var N;
1189
- return f ? Na({
1190
+ return f ? wa({
1190
1191
  row: f.row.values,
1191
1192
  column: f.column,
1192
1193
  actual: o,
@@ -1197,11 +1198,11 @@ function $a(_) {
1197
1198
  },
1198
1199
  [f, i, o, k]
1199
1200
  ), oe = q ? q.targetPatch ?? q.patch : {}, be = R.some((N) => B(m[N]) > 5e-3), P = G(() => {
1200
- const N = `Reconciled ${n} to ${x.toLowerCase()} (${D(o)})`;
1201
+ const N = `Reconciled ${n} to ${y.toLowerCase()} (${D(o)})`;
1201
1202
  if (!q || Math.abs(q.moved) < 5e-3) return N;
1202
1203
  const pe = `${q.targets.length === 1 ? Re(q.targets[0]) : `${q.targets.length} open periods`}${i ? ` ${i.key}` : ""}`;
1203
1204
  return q.moved > 0 ? `${N} — moved ${D(q.moved)} to ${pe}` : `${N} — took ${D(-q.moved)} from ${pe}`;
1204
- }, [n, x, o, q, i]);
1205
+ }, [n, y, o, q, i]);
1205
1206
  ye(() => {
1206
1207
  b && T(P);
1207
1208
  }, [b, P]);
@@ -1247,7 +1248,7 @@ function $a(_) {
1247
1248
  /* @__PURE__ */ t("dd", { className: "font-medium text-slate-800 dark:text-slate-100", children: D($) })
1248
1249
  ] }),
1249
1250
  /* @__PURE__ */ d("div", { children: [
1250
- /* @__PURE__ */ t("dt", { className: "text-[10.5px] text-slate-500 dark:text-slate-400", children: x }),
1251
+ /* @__PURE__ */ t("dt", { className: "text-[10.5px] text-slate-500 dark:text-slate-400", children: y }),
1251
1252
  /* @__PURE__ */ t("dd", { className: "font-medium text-slate-800 dark:text-slate-100", children: D(o) })
1252
1253
  ] }),
1253
1254
  !K && /* @__PURE__ */ d("div", { children: [
@@ -1257,9 +1258,9 @@ function $a(_) {
1257
1258
  {
1258
1259
  className: I(
1259
1260
  "font-medium",
1260
- Math.abs(y) < 5e-3 ? "text-slate-800 dark:text-slate-100" : Rt[L === "neutral" ? "neutral" : L]
1261
+ Math.abs(g) < 5e-3 ? "text-slate-800 dark:text-slate-100" : Rt[L === "neutral" ? "neutral" : L]
1261
1262
  ),
1262
- children: D(y)
1263
+ children: D(g)
1263
1264
  }
1264
1265
  )
1265
1266
  ] })
@@ -1272,14 +1273,14 @@ function $a(_) {
1272
1273
  ] }),
1273
1274
  /* @__PURE__ */ t("span", { className: "tabular-nums text-slate-800 dark:text-slate-100", children: D(N.amount) })
1274
1275
  ] }, String(N.id))) }),
1275
- F.length === 0 && /* @__PURE__ */ t("p", { className: "px-3 py-2 text-slate-500 dark:text-slate-400", children: `No ${xa(c, 2)} behind this figure.` }),
1276
+ F.length === 0 && /* @__PURE__ */ t("p", { className: "px-3 py-2 text-slate-500 dark:text-slate-400", children: `No ${ga(p, 2)} behind this figure.` }),
1276
1277
  f && q && /* @__PURE__ */ d(
1277
1278
  "div",
1278
1279
  {
1279
1280
  className: "border-t border-slate-200 px-3 py-2 dark:border-border",
1280
1281
  "data-plan-reconcile": !0,
1281
1282
  children: [
1282
- /* @__PURE__ */ t("p", { className: "font-medium text-slate-900 dark:text-slate-100", children: `Set the ${v.toLowerCase()} to ${D(o)} and put the ${D(Math.abs(y))} ${y > 0 ? "left over" : "shortfall"}…` }),
1283
+ /* @__PURE__ */ t("p", { className: "font-medium text-slate-900 dark:text-slate-100", children: `Set the ${v.toLowerCase()} to ${D(o)} and put the ${D(Math.abs(g))} ${g > 0 ? "left over" : "shortfall"}…` }),
1283
1284
  /* @__PURE__ */ t(
1284
1285
  "div",
1285
1286
  {
@@ -1302,7 +1303,7 @@ function $a(_) {
1302
1303
  "data-plan-reconcile-mode": N.key,
1303
1304
  disabled: N.disabled,
1304
1305
  checked: k === N.key,
1305
- onChange: () => g(N.key),
1306
+ onChange: () => x(N.key),
1306
1307
  className: "accent-[rgb(var(--nvr-cyan-rgb))]"
1307
1308
  }
1308
1309
  ),
@@ -1374,11 +1375,11 @@ function $a(_) {
1374
1375
  ] })
1375
1376
  ] });
1376
1377
  }
1377
- function Ca(_) {
1378
+ function _a(_) {
1378
1379
  const {
1379
1380
  block: n,
1380
- config: c,
1381
- canSplit: x,
1381
+ config: p,
1382
+ canSplit: y,
1382
1383
  splitUnavailable: o,
1383
1384
  splitBase: $,
1384
1385
  client: M,
@@ -1389,10 +1390,10 @@ function Ca(_) {
1389
1390
  onSpread: b,
1390
1391
  onRemove: C,
1391
1392
  onDone: k,
1392
- rc: g
1393
- } = _, [j, T] = W(!1), [v, y] = W("menu");
1393
+ rc: x
1394
+ } = _, [j, T] = W(!1), [v, g] = W("menu");
1394
1395
  ye(() => {
1395
- j && y("menu");
1396
+ j && g("menu");
1396
1397
  }, [j]);
1397
1398
  const i = [...n.top ? [n.top] : [], ...n.cats], U = i.some((R) => R.edited || R.isNew), m = "flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-[12.5px] text-slate-700 hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50 dark:text-slate-200";
1398
1399
  return /* @__PURE__ */ d(rt, { open: j, onOpenChange: T, children: [
@@ -1414,24 +1415,24 @@ function Ca(_) {
1414
1415
  className: I("p-1.5", v === "split" ? "w-[440px]" : "w-[300px]"),
1415
1416
  children: [
1416
1417
  v === "menu" && /* @__PURE__ */ d("div", { children: [
1417
- n.mode === "top" && x && /* @__PURE__ */ d(
1418
+ n.mode === "top" && y && /* @__PURE__ */ d(
1418
1419
  "button",
1419
1420
  {
1420
1421
  type: "button",
1421
1422
  "data-plan-split": n.key,
1422
1423
  disabled: U,
1423
- onClick: () => y("split"),
1424
+ onClick: () => g("split"),
1424
1425
  className: m,
1425
1426
  children: [
1426
1427
  /* @__PURE__ */ t($t, { className: "h-3.5 w-3.5" }),
1427
- c.split_label ?? "Plan by category"
1428
+ p.split_label ?? "Plan by category"
1428
1429
  ]
1429
1430
  }
1430
1431
  ),
1431
- n.mode === "top" && !x && o && /* @__PURE__ */ d("div", { "data-plan-split-unavailable": !0, className: "px-2 py-1.5", children: [
1432
+ n.mode === "top" && !y && o && /* @__PURE__ */ d("div", { "data-plan-split-unavailable": !0, className: "px-2 py-1.5", children: [
1432
1433
  /* @__PURE__ */ d("p", { className: "flex items-center gap-2 text-[12.5px] text-slate-400 dark:text-slate-500", children: [
1433
1434
  /* @__PURE__ */ t($t, { className: "h-3.5 w-3.5" }),
1434
- c.split_label ?? "Plan by category"
1435
+ p.split_label ?? "Plan by category"
1435
1436
  ] }),
1436
1437
  /* @__PURE__ */ t("p", { className: "mt-0.5 pl-[22px] text-[11px] text-slate-500 dark:text-slate-400", children: o })
1437
1438
  ] }),
@@ -1441,15 +1442,15 @@ function Ca(_) {
1441
1442
  type: "button",
1442
1443
  "data-plan-merge": n.key,
1443
1444
  disabled: U,
1444
- onClick: () => y("merge"),
1445
+ onClick: () => g("merge"),
1445
1446
  className: m,
1446
1447
  children: [
1447
1448
  /* @__PURE__ */ t(ta, { className: "h-3.5 w-3.5" }),
1448
- c.merge_label ?? "Merge back to one line"
1449
+ p.merge_label ?? "Merge back to one line"
1449
1450
  ]
1450
1451
  }
1451
1452
  ),
1452
- U && (n.mode === "split" || x) && /* @__PURE__ */ t("p", { className: "px-2 pb-1 text-[11px] text-slate-500 dark:text-slate-400", children: "Save your changes to this block first." }),
1453
+ U && (n.mode === "split" || y) && /* @__PURE__ */ t("p", { className: "px-2 pb-1 text-[11px] text-slate-500 dark:text-slate-400", children: "Save your changes to this block first." }),
1453
1454
  b && i.map((R) => /* @__PURE__ */ d(
1454
1455
  "button",
1455
1456
  {
@@ -1482,9 +1483,9 @@ function Ca(_) {
1482
1483
  }
1483
1484
  ),
1484
1485
  /* @__PURE__ */ t(
1485
- va,
1486
+ Na,
1486
1487
  {
1487
- collection: g,
1488
+ collection: x,
1488
1489
  rowId: R.id,
1489
1490
  rowLabel: `${n.key}${R.cat ? ` ${F(R.cat)}` : ""}`
1490
1491
  }
@@ -1495,7 +1496,7 @@ function Ca(_) {
1495
1496
  {
1496
1497
  type: "button",
1497
1498
  "data-plan-remove": n.key,
1498
- onClick: () => y("remove"),
1499
+ onClick: () => g("remove"),
1499
1500
  className: I(m, "text-red-700 dark:text-red-300"),
1500
1501
  children: [
1501
1502
  /* @__PURE__ */ t(la, { className: "h-3.5 w-3.5" }),
@@ -1511,7 +1512,7 @@ function Ca(_) {
1511
1512
  "button",
1512
1513
  {
1513
1514
  type: "button",
1514
- onClick: () => y("menu"),
1515
+ onClick: () => g("menu"),
1515
1516
  className: "rounded-md px-2.5 py-1 text-[12px] text-slate-600 hover:bg-muted dark:text-slate-300",
1516
1517
  children: "Keep it"
1517
1518
  }
@@ -1531,27 +1532,27 @@ function Ca(_) {
1531
1532
  ] })
1532
1533
  ] }),
1533
1534
  v === "split" && $ && n.top && /* @__PURE__ */ t(
1534
- _a,
1535
+ Sa,
1535
1536
  {
1536
1537
  block: n,
1537
- config: c,
1538
+ config: p,
1538
1539
  splitBase: $,
1539
1540
  client: M,
1540
1541
  cols: K,
1541
- onCancel: () => y("menu"),
1542
+ onCancel: () => g("menu"),
1542
1543
  onDone: () => {
1543
1544
  T(!1), k();
1544
1545
  }
1545
1546
  }
1546
1547
  ),
1547
1548
  v === "merge" && $ && /* @__PURE__ */ t(
1548
- Sa,
1549
+ Oa,
1549
1550
  {
1550
1551
  block: n,
1551
- config: c,
1552
+ config: p,
1552
1553
  splitBase: $,
1553
1554
  client: M,
1554
- onCancel: () => y("menu"),
1555
+ onCancel: () => g("menu"),
1555
1556
  onDone: () => {
1556
1557
  T(!1), k();
1557
1558
  }
@@ -1563,55 +1564,53 @@ function Ca(_) {
1563
1564
  ] });
1564
1565
  }
1565
1566
  function st(_) {
1566
- var c, x;
1567
- const n = _;
1568
- return ((c = n == null ? void 0 : n.response) == null ? void 0 : c.error) ?? ((x = n == null ? void 0 : n.response) == null ? void 0 : x.message) ?? (n == null ? void 0 : n.message) ?? "Something went wrong";
1567
+ return da(_, "Something went wrong");
1569
1568
  }
1570
- function _a(_) {
1569
+ function Sa(_) {
1571
1570
  var oe, be;
1572
- const { block: n, config: c, splitBase: x, client: o, cols: $, onCancel: M, onDone: K } = _, F = Number.isFinite(Number(n.key)) ? Number(n.key) : n.key, [L, f] = W(null), [b, C] = W(null), [k, g] = W(null), [j, T] = W(!1), [v, y] = W(""), i = JSON.stringify(L);
1571
+ const { block: n, config: p, splitBase: y, client: o, cols: $, onCancel: M, onDone: K } = _, F = Number.isFinite(Number(n.key)) ? Number(n.key) : n.key, [L, f] = W(null), [b, C] = W(null), [k, x] = W(null), [j, T] = W(!1), [v, g] = W(""), i = JSON.stringify(L);
1573
1572
  ye(() => {
1574
1573
  let P = !0;
1575
1574
  const le = window.setTimeout(
1576
1575
  () => {
1577
1576
  o.request(
1578
- lt(`${x}/split`, {
1579
- [c.key_field]: F,
1577
+ lt(`${y}/split`, {
1578
+ [p.key_field]: F,
1580
1579
  preview: !0,
1581
1580
  ...L ? { shares: L } : {}
1582
1581
  })
1583
1582
  ).then((z) => {
1584
- P && (C(z.data), g(null), L || f(
1583
+ P && (C(z.data), x(null), L || f(
1585
1584
  Object.fromEntries(
1586
1585
  z.data.categories.map((ne) => [String(ne.id), Math.round(ne.share * 1e3) / 10])
1587
1586
  )
1588
1587
  ));
1589
- }).catch((z) => P && g(st(z)));
1588
+ }).catch((z) => P && x(st(z)));
1590
1589
  },
1591
1590
  L ? 250 : 0
1592
1591
  );
1593
1592
  return () => {
1594
1593
  P = !1, window.clearTimeout(le);
1595
1594
  };
1596
- }, [i, x]);
1595
+ }, [i, y]);
1597
1596
  const U = (b == null ? void 0 : b.categories.map((P) => P.label).join(" / ")) ?? "", m = `Split the ${n.key} plan into ${U}`, R = async () => {
1598
1597
  T(!0);
1599
1598
  try {
1600
1599
  await o.request(
1601
- lt(`${x}/split`, {
1602
- [c.key_field]: F,
1600
+ lt(`${y}/split`, {
1601
+ [p.key_field]: F,
1603
1602
  shares: L ?? void 0,
1604
1603
  reason: v.trim() || m
1605
1604
  })
1606
1605
  ), de.success(`${n.key} is now planned by ${U}`), K();
1607
1606
  } catch (P) {
1608
- g(st(P));
1607
+ x(st(P));
1609
1608
  } finally {
1610
1609
  T(!1);
1611
1610
  }
1612
1611
  }, q = (P) => E($.reduce((le, z) => le + B(P[z]), 0));
1613
1612
  return /* @__PURE__ */ d("div", { className: "p-1.5", "data-plan-split-pane": !0, children: [
1614
- /* @__PURE__ */ t("p", { className: "text-[12.5px] font-semibold text-slate-900 dark:text-slate-100", children: `${c.split_label ?? "Plan by category"} · ${n.key}` }),
1613
+ /* @__PURE__ */ t("p", { className: "text-[12.5px] font-semibold text-slate-900 dark:text-slate-100", children: `${p.split_label ?? "Plan by category"} · ${n.key}` }),
1615
1614
  /* @__PURE__ */ t("p", { className: "mt-0.5 text-[11.5px] text-slate-600 dark:text-slate-300", children: "Every period is divided by these shares. Closed periods keep their totals; open ones can be changed in the grid afterwards." }),
1616
1615
  !b && !k && /* @__PURE__ */ t(
1617
1616
  "div",
@@ -1672,7 +1671,7 @@ function _a(_) {
1672
1671
  /* @__PURE__ */ t("td", { className: "py-1 text-right text-slate-500 dark:text-slate-400", children: D(P.cap) })
1673
1672
  ] }, String(P.id))),
1674
1673
  /* @__PURE__ */ d("tr", { className: "border-t border-slate-200 font-medium dark:border-border", children: [
1675
- /* @__PURE__ */ t("td", { className: "py-1 text-slate-800 dark:text-slate-100", children: c.total_label ?? "Total" }),
1674
+ /* @__PURE__ */ t("td", { className: "py-1 text-slate-800 dark:text-slate-100", children: p.total_label ?? "Total" }),
1676
1675
  /* @__PURE__ */ t("td", {}),
1677
1676
  /* @__PURE__ */ t("td", { className: "py-1 text-right text-slate-800 dark:text-slate-100", children: D(q(b.original)) }),
1678
1677
  /* @__PURE__ */ t("td", {})
@@ -1692,7 +1691,7 @@ function _a(_) {
1692
1691
  "textarea",
1693
1692
  {
1694
1693
  value: v,
1695
- onChange: (P) => y(P.target.value),
1694
+ onChange: (P) => g(P.target.value),
1696
1695
  placeholder: m,
1697
1696
  rows: 2,
1698
1697
  "aria-label": "Reason",
@@ -1723,10 +1722,10 @@ function _a(_) {
1723
1722
  ] })
1724
1723
  ] });
1725
1724
  }
1726
- function Sa(_) {
1727
- const { block: n, config: c, splitBase: x, client: o, onCancel: $, onDone: M } = _, K = Number.isFinite(Number(n.key)) ? Number(n.key) : n.key, [F, L] = W(""), [f, b] = W(!1), [C, k] = W(null), g = `Merged the ${n.key} plan back to one line`;
1725
+ function Oa(_) {
1726
+ const { block: n, config: p, splitBase: y, client: o, onCancel: $, onDone: M } = _, K = Number.isFinite(Number(n.key)) ? Number(n.key) : n.key, [F, L] = W(""), [f, b] = W(!1), [C, k] = W(null), x = `Merged the ${n.key} plan back to one line`;
1728
1727
  return /* @__PURE__ */ d("div", { className: "p-1.5", "data-plan-merge-pane": !0, children: [
1729
- /* @__PURE__ */ t("p", { className: "text-[12.5px] font-semibold text-slate-900 dark:text-slate-100", children: `${c.merge_label ?? "Merge back to one line"} · ${n.key}` }),
1728
+ /* @__PURE__ */ t("p", { className: "text-[12.5px] font-semibold text-slate-900 dark:text-slate-100", children: `${p.merge_label ?? "Merge back to one line"} · ${n.key}` }),
1730
1729
  /* @__PURE__ */ t("p", { className: "mt-0.5 text-[11.5px] text-slate-600 dark:text-slate-300", children: "The category lines are added together, period by period. Their history stays on the record." }),
1731
1730
  C && /* @__PURE__ */ t("p", { role: "alert", className: "mt-1.5 text-[11.5px] font-medium text-red-700 dark:text-red-300", children: C }),
1732
1731
  /* @__PURE__ */ t(
@@ -1734,7 +1733,7 @@ function Sa(_) {
1734
1733
  {
1735
1734
  value: F,
1736
1735
  onChange: (j) => L(j.target.value),
1737
- placeholder: g,
1736
+ placeholder: x,
1738
1737
  rows: 2,
1739
1738
  "aria-label": "Reason",
1740
1739
  className: "mt-2 w-full resize-none rounded-md border border-slate-200 bg-background px-2 py-1 text-[12px] text-slate-800 outline-none focus:border-slate-400 dark:border-border dark:text-slate-100"
@@ -1760,9 +1759,9 @@ function Sa(_) {
1760
1759
  b(!0);
1761
1760
  try {
1762
1761
  await o.request(
1763
- lt(`${x}/merge`, {
1764
- [c.key_field]: K,
1765
- reason: F.trim() || g
1762
+ lt(`${y}/merge`, {
1763
+ [p.key_field]: K,
1764
+ reason: F.trim() || x
1766
1765
  })
1767
1766
  ), de.success(`${n.key} is one line again`), M();
1768
1767
  } catch (j) {
@@ -1778,15 +1777,15 @@ function Sa(_) {
1778
1777
  ] })
1779
1778
  ] });
1780
1779
  }
1781
- function Oa(_) {
1782
- const { config: n, client: c, used: x, onAdd: o, label: $ } = _, [M, K] = W(!1), [F, L] = W(""), { data: f = [] } = ce({
1780
+ function La(_) {
1781
+ const { config: n, client: p, used: y, onAdd: o, label: $ } = _, [M, K] = W(!1), [F, L] = W(""), { data: f = [] } = ce({
1783
1782
  queryKey: ["plan-grid-keys", n.key_collection],
1784
- queryFn: () => c.request(
1783
+ queryFn: () => p.request(
1785
1784
  ue(`/items/${n.key_collection}`, { fields: "id", sort: "-id", limit: 200 })
1786
1785
  ).then((C) => (C.data ?? []).map((k) => k.id)),
1787
1786
  enabled: M && !!n.key_collection,
1788
1787
  staleTime: 10 * 6e4
1789
- }), b = f.filter((C) => !x.has(String(C)));
1788
+ }), b = f.filter((C) => !y.has(String(C)));
1790
1789
  return /* @__PURE__ */ d(rt, { open: M, onOpenChange: K, children: [
1791
1790
  /* @__PURE__ */ t(ot, { asChild: !0, children: /* @__PURE__ */ d(
1792
1791
  "button",
@@ -1820,7 +1819,7 @@ function Oa(_) {
1820
1819
  onSubmit: (C) => {
1821
1820
  C.preventDefault();
1822
1821
  const k = F.trim();
1823
- !k || x.has(k) || (o(Number.isFinite(Number(k)) ? Number(k) : k), L(""), K(!1));
1822
+ !k || y.has(k) || (o(Number.isFinite(Number(k)) ? Number(k) : k), L(""), K(!1));
1824
1823
  },
1825
1824
  children: /* @__PURE__ */ t(
1826
1825
  "input",
@@ -1836,8 +1835,8 @@ function Oa(_) {
1836
1835
  ] });
1837
1836
  }
1838
1837
  export {
1839
- Wa as PlanGridField,
1838
+ Qa as PlanGridField,
1840
1839
  D as fmtFigure,
1841
1840
  Tt as parseFigure,
1842
- Na as reconcilePatch
1841
+ wa as reconcilePatch
1843
1842
  };