@nivaro/react 0.3.57 → 0.3.58

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 (50) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +5 -1
  4. package/dist/shared/components/CollectionBrowserView.js +2633 -2590
  5. package/dist/shared/components/DataTable.js +247 -236
  6. package/dist/shared/components/ItemEditForm.js +1693 -1668
  7. package/dist/shared/components/ProfileView.js +716 -715
  8. package/dist/shared/components/RecordReadView.js +367 -364
  9. package/dist/shared/components/ReportView.js +64 -39
  10. package/dist/shared/components/alerts/AlertManagerView.js +284 -271
  11. package/dist/shared/components/cbv/row-focus.js +19 -0
  12. package/dist/shared/components/help-videos/HelpVideoPlayer.js +152 -147
  13. package/dist/shared/components/integrations/console/SignalCard.js +59 -59
  14. package/dist/shared/components/integrations/console/tone.js +52 -30
  15. package/dist/shared/components/item-edit/CatalogPickerField.js +525 -505
  16. package/dist/shared/components/item-edit/FieldRow.js +175 -173
  17. package/dist/shared/components/item-edit/InlineTableField.js +407 -402
  18. package/dist/shared/components/item-edit/M2MCombobox.js +313 -291
  19. package/dist/shared/components/item-edit/MidairCollisionDialog.js +1 -1
  20. package/dist/shared/components/item-edit/PlanGrid.js +826 -803
  21. package/dist/shared/components/item-edit/QuickCreateButton.js +115 -79
  22. package/dist/shared/components/item-edit/RecordLiveSync.js +77 -75
  23. package/dist/shared/components/item-edit/RelationCombobox.js +412 -328
  24. package/dist/shared/components/item-edit/RelationGroupedCombobox.js +147 -125
  25. package/dist/shared/components/item-edit/SummaryPanel.js +406 -392
  26. package/dist/shared/components/item-edit/option-disambiguate.js +44 -32
  27. package/dist/shared/components/item-edit/related-missing.js +45 -0
  28. package/dist/shared/components/item-edit/save-outcome.js +5 -5
  29. package/dist/shared/components/notifications/NotificationRulesEditor.js +130 -123
  30. package/dist/shared/components/panels/AccessDeniedPanel.js +52 -48
  31. package/dist/shared/components/panels/ItemLockBanner.js +2 -3
  32. package/dist/shared/components/panels/PipelinePanel.js +1027 -978
  33. package/dist/shared/components/panels/RevisionsPanel.js +4 -1
  34. package/dist/shared/components/panels/TaskPanel.js +265 -249
  35. package/dist/shared/components/panels/landing-state.js +27 -0
  36. package/dist/shared/components/pipeline/PipelineEditorView.js +86 -78
  37. package/dist/shared/components/profile/AiMemoryCard.js +12 -10
  38. package/dist/shared/components/queue/OwnerAvatars.js +80 -41
  39. package/dist/shared/components/queue/QueueQuickFilters.js +48 -48
  40. package/dist/shared/components/queue/QueueWorklist.js +357 -358
  41. package/dist/shared/components/queue/group-sums.js +27 -0
  42. package/dist/shared/components/widgets/ReviewListWidget.js +186 -168
  43. package/dist/shared/lib/back-closes.js +25 -0
  44. package/dist/shared/lib/form-usage-beacon.js +7 -7
  45. package/dist/shared/lib/list-page-memory.js +41 -0
  46. package/dist/shared/lib/live.js +44 -44
  47. package/dist/shared/lib/own-writes.js +76 -28
  48. package/dist/shared/lib/request-gate.js +110 -109
  49. package/dist/shared/lib/validation-rules.js +34 -19
  50. package/package.json +1 -1
@@ -1,192 +1,202 @@
1
- import { jsx as t, jsxs as d, Fragment as Xt } from "react/jsx-runtime";
2
- import { useQueryClient as ea, useQuery as ce } from "@tanstack/react-query";
3
- import { ChevronDown as $t, ChevronRight as Ct, Lock as ta, MoreHorizontal as aa, Split as St, Undo2 as la, History as na, Trash2 as ra, Plus as sa } from "lucide-react";
4
- import { useRef as $e, useEffect as pe, useMemo as G, useCallback as ee, useState as H } from "react";
5
- import { toast as de } from "sonner";
6
- import { useNivaroClient as oa, useParentDraft as ia, useItemEditAuth as da } from "../../context.js";
7
- import { get as ue, post as rt } from "../../lib/commands.js";
8
- import { useAfterIdle as ca } from "../../lib/defer.js";
9
- import { evaluateNumeric as at } from "../../lib/expression.js";
10
- import { userErrorMessage as ua } from "../../lib/safe-error.js";
11
- import { cn as B, formatRelative as pa } from "../../lib/utils.js";
12
- import { NumberDraftInput as ma } from "../ui/number-draft-input.js";
13
- import { Popover as it, PopoverTrigger as dt, PopoverContent as ct } from "../ui/popover.js";
14
- import { resolveCompareEndpoint as ha, useCompareSeries as fa, compareColumnClosed as xa, planLabel as Pt, closedThroughLabel as ga, CompareProposalBanner as ya, CompareStripChips as ba, GridStatChip as _t, monthLabel as st, extraSeriesValue as we, SeriesFigurePopover as Ot, monthLabelLong as Ee, unitWord as ka } from "./CompareSeries.js";
15
- import { useO2MStaging as va, useLiveRows as Na } from "./O2MStagingContext.js";
16
- import { usePlanGridHost as wa } from "./PlanGridHost.js";
17
- import { RowHistorySheet as $a } from "./RowHistorySheet.js";
18
- import { RowWatchButton as Ca } from "./RowWatchButton.js";
19
- const Ie = "unclassified", I = (v) => Number(v) || 0, T = (v) => Math.round(v * 100) / 100;
20
- function D(v) {
21
- const n = Math.abs(v - Math.round(v)) < 5e-3;
22
- return v.toLocaleString("en-US", {
1
+ import { jsx as t, jsxs as d, Fragment as ta } from "react/jsx-runtime";
2
+ import { useQueryClient as aa, useQuery as pe } from "@tanstack/react-query";
3
+ import { ChevronDown as St, ChevronRight as _t, Lock as la, MoreHorizontal as na, Split as Ot, Undo2 as ra, History as sa, Trash2 as oa, Plus as ia } from "lucide-react";
4
+ import { useRef as ke, useEffect as ce, useMemo as G, useCallback as ee, useState as H } from "react";
5
+ import { toast as ue } from "sonner";
6
+ import { useNivaroClient as da, useParentDraft as ca, useItemEditAuth as ua } from "../../context.js";
7
+ import { get as me, post as st } from "../../lib/commands.js";
8
+ import { useAfterIdle as pa } from "../../lib/defer.js";
9
+ import { evaluateNumeric as lt } from "../../lib/expression.js";
10
+ import { userErrorMessage as ma } from "../../lib/safe-error.js";
11
+ import { cn as D, formatRelative as ha } from "../../lib/utils.js";
12
+ import { NumberDraftInput as fa } from "../ui/number-draft-input.js";
13
+ import { Popover as dt, PopoverTrigger as ct, PopoverContent as ut } from "../ui/popover.js";
14
+ import { resolveCompareEndpoint as xa, useCompareSeries as ga, compareColumnClosed as ya, planLabel as jt, closedThroughLabel as ba, CompareProposalBanner as ka, CompareStripChips as va, GridStatChip as Lt, monthLabel as ot, extraSeriesValue as Ce, SeriesFigurePopover as Rt, monthLabelLong as Ee, unitWord as Na } from "./CompareSeries.js";
15
+ import { useO2MStaging as wa, useLiveRows as $a } from "./O2MStagingContext.js";
16
+ import { usePlanGridHost as Ca } from "./PlanGridHost.js";
17
+ import { RowHistorySheet as Sa } from "./RowHistorySheet.js";
18
+ import { RowWatchButton as _a } from "./RowWatchButton.js";
19
+ const De = "unclassified", I = (k) => Number(k) || 0, E = (k) => Math.round(k * 100) / 100;
20
+ function z(k) {
21
+ const n = Math.abs(k - Math.round(k)) < 5e-3;
22
+ return k.toLocaleString("en-US", {
23
23
  style: "currency",
24
24
  currency: "USD",
25
25
  minimumFractionDigits: n ? 0 : 2,
26
26
  maximumFractionDigits: n ? 0 : 2
27
27
  });
28
28
  }
29
- function qt(v) {
30
- const n = v.replace(/[$,\s]/g, "");
29
+ function At(k) {
30
+ const n = k.replace(/[$,\s]/g, "");
31
31
  if (n === "" || n === "-" || n === "—") return 0;
32
- const p = /^\(.*\)$/.test(n), g = Number(p ? n.slice(1, -1) : n);
33
- return Number.isFinite(g) ? T(p ? -g : g) : null;
32
+ const g = /^\(.*\)$/.test(n), h = Number(g ? n.slice(1, -1) : n);
33
+ return Number.isFinite(h) ? E(g ? -h : h) : null;
34
34
  }
35
- function Sa(v, n) {
36
- return v[0] === "item" && v.length >= 3 && String(v[2]) === String(n);
35
+ function Oa(k, n) {
36
+ return k[0] === "item" && k.length >= 3 && String(k[2]) === String(n);
37
37
  }
38
- function _a(v) {
39
- const { column: n, actual: p, openColumns: g, mode: o } = v, C = v.targetRow != null, R = T(I(v.row[n]) - p), K = { [n]: T(p) }, F = v.targetRow ?? v.row, L = C ? {} : K;
40
- if (o === "none" || Math.abs(R) < 5e-3 || g.length === 0)
41
- return { patch: K, moved: 0, unabsorbed: o === "none" ? 0 : R, targets: [] };
42
- let f, k;
43
- if (o === "next" ? (f = [g[0]], k = [1]) : o === "weighted" ? (f = g.filter((x) => I(F[x]) > 5e-3), k = f.map((x) => I(F[x])), f.length === 0 && C && R > 0 && (f = g, k = f.map(() => 1))) : (f = g, k = f.map(() => 1)), f.length === 0) return { patch: K, moved: 0, unabsorbed: R, targets: [] };
44
- const S = k.reduce((x, j) => x + j, 0) || 1;
45
- let b = R;
46
- if (f.forEach((x, j) => {
47
- const N = j === f.length - 1 ? b : T(R * k[j] / S), y = Math.max(0, T(I(F[x]) + N)), i = T(y - I(F[x]));
48
- L[x] = y, b = T(b - i);
49
- }), Math.abs(b) >= 5e-3 && b < 0)
50
- for (const x of f) {
51
- if (Math.abs(b) < 5e-3) break;
52
- const j = Math.min(L[x], -b);
53
- L[x] = T(L[x] - j), b = T(b + j);
38
+ function La(k) {
39
+ const { column: n, actual: g, openColumns: h, mode: i } = k, N = k.targetRow != null, B = E(I(k.row[n]) - g), R = { [n]: E(g) }, j = k.targetRow ?? k.row, L = N ? {} : R;
40
+ if (i === "none" || Math.abs(B) < 5e-3 || h.length === 0)
41
+ return { patch: R, moved: 0, unabsorbed: i === "none" ? 0 : B, targets: [] };
42
+ let u, v;
43
+ if (i === "next" ? (u = [h[0]], v = [1]) : i === "weighted" ? (u = h.filter((x) => I(j[x]) > 5e-3), v = u.map((x) => I(j[x])), u.length === 0 && N && B > 0 && (u = h, v = u.map(() => 1))) : (u = h, v = u.map(() => 1)), u.length === 0) return { patch: R, moved: 0, unabsorbed: B, targets: [] };
44
+ const b = v.reduce((x, A) => x + A, 0) || 1;
45
+ let y = B;
46
+ if (u.forEach((x, A) => {
47
+ const C = A === u.length - 1 ? y : E(B * v[A] / b), T = Math.max(0, E(I(j[x]) + C)), s = E(T - I(j[x]));
48
+ L[x] = T, y = E(y - s);
49
+ }), Math.abs(y) >= 5e-3 && y < 0)
50
+ for (const x of u) {
51
+ if (Math.abs(y) < 5e-3) break;
52
+ const A = Math.min(L[x], -y);
53
+ L[x] = E(L[x] - A), y = E(y + A);
54
54
  }
55
- return C ? {
56
- patch: K,
55
+ return N ? {
56
+ patch: R,
57
57
  targetPatch: L,
58
- moved: T(R - b),
59
- unabsorbed: b,
60
- targets: f
61
- } : { patch: L, moved: T(R - b), unabsorbed: b, targets: f };
58
+ moved: E(B - y),
59
+ unabsorbed: y,
60
+ targets: u
61
+ } : { patch: L, moved: E(B - y), unabsorbed: y, targets: u };
62
62
  }
63
- const Lt = 176, Rt = 112, Mt = 128, be = "sticky left-0 z-[2] bg-white dark:bg-[hsl(var(--card))] border-r border-slate-200 dark:border-border", ke = "sticky right-0 z-[2] bg-white dark:bg-[hsl(var(--card))] border-l border-slate-200 dark:border-border", Ce = "bg-slate-50 dark:bg-white/[0.035]";
64
- function Ya(v) {
63
+ const Mt = 176, Tt = 112, Et = 128, ve = "sticky left-0 z-[2] bg-white dark:bg-[hsl(var(--card))] border-r border-slate-200 dark:border-border", Ne = "sticky right-0 z-[2] bg-white dark:bg-[hsl(var(--card))] border-l border-slate-200 dark:border-border", Se = "bg-slate-50 dark:bg-white/[0.035]";
64
+ function el(k) {
65
65
  const {
66
66
  relatedCollection: n,
67
- manyField: p,
68
- parentId: g,
69
- config: o,
70
- compareSeries: C,
71
- stats: R,
72
- sumCap: K,
73
- remaining: F,
67
+ manyField: g,
68
+ parentId: h,
69
+ config: i,
70
+ compareSeries: N,
71
+ stats: B,
72
+ sumCap: R,
73
+ remaining: j,
74
74
  readOnly: L = !1,
75
- showHistory: f = !0,
76
- emptyLabel: k
77
- } = v, S = oa(), b = ea(), x = va(), j = Na(), E = ia(), N = E == null ? void 0 : E.draft, { isAdmin: y } = da(), i = !g || g === "new", z = !L && !!x, m = o.value_fields, M = o.total_field ?? null, {
75
+ showHistory: u = !0,
76
+ emptyLabel: v
77
+ } = k, b = da(), y = aa(), x = wa(), A = $a(), F = ca(), C = F == null ? void 0 : F.draft, { isAdmin: T } = ua(), s = !h || h === "new", M = !L && !!x, f = i.value_fields, O = i.total_field ?? null, {
78
78
  data: P = [],
79
- isLoading: se,
80
- dataUpdatedAt: ve
81
- } = ce({
82
- queryKey: ["o2m-rows", n, p, g, ""],
83
- queryFn: () => S.request(
84
- ue(`/items/${n}`, { filter: JSON.stringify({ [p]: { _eq: g } }), limit: 200 })
79
+ isLoading: oe,
80
+ dataUpdatedAt: re
81
+ } = pe({
82
+ queryKey: ["o2m-rows", n, g, h, ""],
83
+ queryFn: () => b.request(
84
+ me(`/items/${n}`, { filter: JSON.stringify({ [g]: { _eq: h } }), limit: 200 })
85
85
  ).then((e) => e.data ?? []),
86
- enabled: !i,
86
+ enabled: !s,
87
87
  staleTime: 3e4
88
- }), q = ca(2e3), { data: le = {} } = ce({
89
- queryKey: ["o2m-cell-provenance", n, p, g, ve],
90
- queryFn: () => S.request(
91
- ue("/revisions/o2m-cell-provenance", {
88
+ }), q = pa(2e3), { data: le = {} } = pe({
89
+ queryKey: ["o2m-cell-provenance", n, g, h, re],
90
+ queryFn: () => b.request(
91
+ me("/revisions/o2m-cell-provenance", {
92
92
  collection: n,
93
- many_field: p,
94
- parent_id: g
93
+ many_field: g,
94
+ parent_id: h
95
95
  })
96
96
  ).then((e) => e.data ?? {}),
97
- enabled: q && f && !i && P.length > 0,
97
+ enabled: q && u && !s && P.length > 0,
98
98
  staleTime: 6e4,
99
99
  placeholderData: (e) => e
100
- }), V = (e, a) => e.id ? `${n}:${e.id}:${a}` : void 0, oe = (e, a) => {
100
+ }), V = (e, a) => e.id ? `${n}:${e.id}:${a}` : void 0, ie = (e, a) => {
101
101
  var l;
102
102
  return e.id && !e.edited ? (l = le[e.id]) == null ? void 0 : l[a] : void 0;
103
- }, w = $e(null), me = (e, a) => {
103
+ }, w = ke(null), he = (e, a) => {
104
104
  !e || typeof window > "u" || window.dispatchEvent(new CustomEvent("nvr:cell-editing", { detail: { cell: e, state: a } }));
105
- }, jt = (e) => {
106
- var l, r, s;
107
- const a = ((s = (r = (l = e.target) == null ? void 0 : l.closest) == null ? void 0 : r.call(l, "[data-grid-cell]")) == null ? void 0 : s.getAttribute("data-grid-cell")) ?? null;
108
- a !== w.current && (w.current && me(w.current, "end"), w.current = a, a && me(a, "start"));
109
105
  }, Ft = (e) => {
106
+ var l, r, o;
107
+ const a = ((o = (r = (l = e.target) == null ? void 0 : l.closest) == null ? void 0 : r.call(l, "[data-grid-cell]")) == null ? void 0 : o.getAttribute("data-grid-cell")) ?? null;
108
+ a !== w.current && (w.current && he(w.current, "end"), w.current = a, a && he(a, "start"));
109
+ }, Kt = (e) => {
110
110
  var a, l;
111
- (l = (a = e.relatedTarget) == null ? void 0 : a.closest) != null && l.call(a, "[data-grid-cell]") || (w.current && me(w.current, "end"), w.current = null);
111
+ (l = (a = e.relatedTarget) == null ? void 0 : a.closest) != null && l.call(a, "[data-grid-cell]") || (w.current && he(w.current, "end"), w.current = null);
112
112
  };
113
- pe(
113
+ ce(
114
114
  () => () => {
115
- w.current && me(w.current, "end");
115
+ w.current && he(w.current, "end");
116
116
  },
117
117
  []
118
118
  );
119
119
  const Pe = G(
120
- () => C != null && C.endpoint ? ha(C.endpoint, N) : null,
121
- [C == null ? void 0 : C.endpoint, N]
122
- ), Be = fa({
123
- client: S,
120
+ () => N != null && N.endpoint ? xa(N.endpoint, C) : null,
121
+ [N == null ? void 0 : N.endpoint, C]
122
+ ), qe = ga({
123
+ client: b,
124
124
  endpoint: Pe,
125
- enabled: !!C && !i
126
- }), c = C && !i ? Be.data ?? null : null, he = G(() => !o.split_endpoint || i ? null : o.split_endpoint.replace(
125
+ enabled: !!N && !s
126
+ }), c = N && !s ? qe.data ?? null : null, pt = qe.refetch, je = ke(0);
127
+ ce(() => {
128
+ if (!(!re || !N || s)) {
129
+ if (je.current === 0) {
130
+ je.current = re;
131
+ return;
132
+ }
133
+ re !== je.current && (je.current = re, pt());
134
+ }
135
+ }, [re, pt, N, s]);
136
+ const fe = G(() => !i.split_endpoint || s ? null : i.split_endpoint.replace(
127
137
  /\$parent\.([A-Za-z_][A-Za-z0-9_]*)/g,
128
- (e, a) => String(a === "id" ? g : (N == null ? void 0 : N[a]) ?? "")
129
- ), [o.split_endpoint, i, g, N]), De = G(() => ["plan-grid-split-info", he], [he]), { data: ie = null } = ce({
130
- queryKey: De,
131
- queryFn: () => S.request(ue(he)).then((e) => e.data ?? null).catch(() => null),
132
- enabled: !!he,
138
+ (e, a) => String(a === "id" ? h : (C == null ? void 0 : C[a]) ?? "")
139
+ ), [i.split_endpoint, s, h, C]), ze = G(() => ["plan-grid-split-info", fe], [fe]), { data: de = null } = pe({
140
+ queryKey: ze,
141
+ queryFn: () => b.request(me(fe)).then((e) => e.data ?? null).catch(() => null),
142
+ enabled: !!fe,
133
143
  staleTime: 3e4
134
- }), { data: ut = {} } = ce({
135
- queryKey: ["plan-grid-categories", o.category_collection, o.category_label_field],
144
+ }), { data: mt = {} } = pe({
145
+ queryKey: ["plan-grid-categories", i.category_collection, i.category_label_field],
136
146
  queryFn: async () => {
137
- const e = o.category_label_field ?? "name", a = await S.request(
138
- ue(`/items/${o.category_collection}`, { fields: `id,${e}`, limit: 100 })
147
+ const e = i.category_label_field ?? "name", a = await b.request(
148
+ me(`/items/${i.category_collection}`, { fields: `id,${e}`, limit: 100 })
139
149
  );
140
150
  return Object.fromEntries((a.data ?? []).map((l) => [String(l.id), String(l[e] ?? l.id)]));
141
151
  },
142
- enabled: !!o.category_collection,
152
+ enabled: !!i.category_collection,
143
153
  staleTime: 10 * 6e4
144
- }), Se = ee(
145
- (e) => e === Ie ? o.unclassified_label ?? "Unclassified" : ut[e] ?? `#${e}`,
146
- [ut, o.unclassified_label]
147
- ), ze = G(() => (o.categories ?? []).map(String), [o.categories]), Ue = (x == null ? void 0 : x.getPendingRows(n, p)) ?? [], fe = x == null ? void 0 : x.getPendingEdits(n, p), xe = x == null ? void 0 : x.getPendingDeletes(n, p), qe = Ue.length + ((fe == null ? void 0 : fe.size) ?? 0) + ((xe == null ? void 0 : xe.size) ?? 0), pt = $e(qe);
148
- pe(() => {
149
- const e = pt.current;
150
- if (pt.current = qe, i || !(e > 0 && qe === 0)) return;
151
- const a = () => void b.invalidateQueries({ predicate: (r) => Sa(r.queryKey, g) });
154
+ }), we = ee(
155
+ (e) => e === De ? i.unclassified_label ?? "Unclassified" : mt[e] ?? `#${e}`,
156
+ [mt, i.unclassified_label]
157
+ ), Ue = G(() => (i.categories ?? []).map(String), [i.categories]), He = (x == null ? void 0 : x.getPendingRows(n, g)) ?? [], xe = x == null ? void 0 : x.getPendingEdits(n, g), ge = x == null ? void 0 : x.getPendingDeletes(n, g), Ae = He.length + ((xe == null ? void 0 : xe.size) ?? 0) + ((ge == null ? void 0 : ge.size) ?? 0), ht = ke(Ae);
158
+ ce(() => {
159
+ const e = ht.current;
160
+ if (ht.current = Ae, s || !(e > 0 && Ae === 0)) return;
161
+ const a = () => void y.invalidateQueries({ predicate: (r) => Oa(r.queryKey, h) });
152
162
  a();
153
163
  const l = setTimeout(a, 2e3);
154
164
  return () => clearTimeout(l);
155
- }, [qe, i, g, b]);
165
+ }, [Ae, s, h, y]);
156
166
  const Z = G(() => {
157
167
  const e = [], a = (l) => l && typeof l == "object" && "id" in l ? l.id : l;
158
168
  for (const l of P) {
159
169
  const r = String(l.id);
160
- if (xe != null && xe.has(r)) continue;
161
- const s = fe == null ? void 0 : fe.get(r), u = s ? { ...l, ...s } : l, O = a(u[o.category_field]);
170
+ if (ge != null && ge.has(r)) continue;
171
+ const o = xe == null ? void 0 : xe.get(r), p = o ? { ...l, ...o } : l, _ = a(p[i.category_field]);
162
172
  e.push({
163
173
  uid: `s:${r}`,
164
174
  id: r,
165
175
  pendingIndex: null,
166
- key: String(a(u[o.key_field]) ?? ""),
167
- cat: O == null || O === "" ? null : String(O),
168
- values: u,
169
- edited: !!s && Object.keys(s).some((U) => !U.startsWith("_")),
176
+ key: String(a(p[i.key_field]) ?? ""),
177
+ cat: _ == null || _ === "" ? null : String(_),
178
+ values: p,
179
+ edited: !!o && Object.keys(o).some((U) => !U.startsWith("_")),
170
180
  isNew: !1
171
181
  });
172
182
  }
173
- return Ue.forEach((l, r) => {
174
- const s = a(l[o.category_field]);
183
+ return He.forEach((l, r) => {
184
+ const o = a(l[i.category_field]);
175
185
  e.push({
176
186
  uid: `p:${r}`,
177
187
  id: null,
178
188
  pendingIndex: r,
179
- key: String(a(l[o.key_field]) ?? ""),
180
- cat: s == null || s === "" ? null : String(s),
189
+ key: String(a(l[i.key_field]) ?? ""),
190
+ cat: o == null || o === "" ? null : String(o),
181
191
  values: l,
182
192
  edited: !1,
183
193
  isNew: !0
184
194
  });
185
195
  }), e;
186
- }, [P, Ue, fe, xe, o.key_field, o.category_field]), Y = ee(
187
- (e) => T(m.reduce((a, l) => a + I(e[l]), 0)),
188
- [m]
189
- ), re = G(() => {
196
+ }, [P, He, xe, ge, i.key_field, i.category_field]), Y = ee(
197
+ (e) => E(f.reduce((a, l) => a + I(e[l]), 0)),
198
+ [f]
199
+ ), se = G(() => {
190
200
  const e = /* @__PURE__ */ new Map();
191
201
  for (const a of Z) {
192
202
  if (!a.key) continue;
@@ -195,50 +205,50 @@ function Ya(v) {
195
205
  }
196
206
  for (const a of e.values())
197
207
  a.cats.length && (a.mode = "split", a.cats.sort((l, r) => {
198
- const s = ze.indexOf(l.cat), u = ze.indexOf(r.cat);
199
- return (s < 0 ? 99 : s) - (u < 0 ? 99 : u);
208
+ const o = Ue.indexOf(l.cat), p = Ue.indexOf(r.cat);
209
+ return (o < 0 ? 99 : o) - (p < 0 ? 99 : p);
200
210
  }));
201
211
  for (const a of (c == null ? void 0 : c.rows) ?? []) {
202
212
  const l = String(a.key);
203
- e.has(l) || m.some((r) => Math.abs(I(a.values[r])) >= 5e-3) && e.set(l, { key: l, mode: "ghost", top: null, cats: [] });
213
+ e.has(l) || f.some((r) => Math.abs(I(a.values[r])) >= 5e-3) && e.set(l, { key: l, mode: "ghost", top: null, cats: [] });
204
214
  }
205
215
  return [...e.values()].sort(
206
216
  (a, l) => Number(a.key) - Number(l.key) || a.key.localeCompare(l.key)
207
217
  );
208
- }, [Z, c, m, ze]), _e = G(
209
- () => Z.map((e) => M ? { ...e.values, [M]: Y(e.values) } : e.values),
210
- [Z, M, Y]
211
- ), ge = j == null ? void 0 : j.report;
212
- pe(() => {
213
- if (ge) {
214
- if (se) {
215
- ge(n, p, null);
218
+ }, [Z, c, f, Ue]), _e = G(
219
+ () => Z.map((e) => O ? { ...e.values, [O]: Y(e.values) } : e.values),
220
+ [Z, O, Y]
221
+ ), ye = A == null ? void 0 : A.report;
222
+ ce(() => {
223
+ if (ye) {
224
+ if (oe) {
225
+ ye(n, g, null);
216
226
  return;
217
227
  }
218
- ge(n, p, _e);
228
+ ye(n, g, _e);
219
229
  }
220
- }, [ge, n, p, _e, se]);
221
- const mt = $e(() => {
230
+ }, [ye, n, g, _e, oe]);
231
+ const ft = ke(() => {
222
232
  });
223
- mt.current = () => ge == null ? void 0 : ge(n, p, null), pe(() => () => mt.current(), []);
233
+ ft.current = () => ye == null ? void 0 : ye(n, g, null), ce(() => () => ft.current(), []);
224
234
  const Oe = ee(
225
235
  (e) => {
226
- if (e.startsWith("$parent.")) return (N == null ? void 0 : N[e.slice(8)]) ?? 0;
236
+ if (e.startsWith("$parent.")) return (C == null ? void 0 : C[e.slice(8)]) ?? 0;
227
237
  if (e.startsWith("$sum.")) {
228
238
  const a = e.slice(5);
229
239
  return _e.reduce((l, r) => l + I(r[a]), 0);
230
240
  }
231
- return e === "$count" ? _e.length : N == null ? void 0 : N[e];
241
+ return e === "$count" ? _e.length : C == null ? void 0 : C[e];
232
242
  },
233
- [N, _e]
234
- ), ht = G(
235
- () => (R ?? []).map((e) => ({ ...e, result: at(e.value, Oe) })),
236
- [R, Oe]
237
- ), He = G(
238
- () => T(Z.reduce((e, a) => e + Y(a.values), 0)),
243
+ [C, _e]
244
+ ), xt = G(
245
+ () => (B ?? []).map((e) => ({ ...e, result: lt(e.value, Oe) })),
246
+ [B, Oe]
247
+ ), We = G(
248
+ () => E(Z.reduce((e, a) => e + Y(a.values), 0)),
239
249
  [Z, Y]
240
- ), Le = G(() => ie ? ie.categories.filter((e) => e.cap > 5e-3 || Z.some((a) => a.cat === String(e.id))).map((e) => {
241
- const a = T(
250
+ ), Le = G(() => de ? de.categories.filter((e) => e.cap > 5e-3 || Z.some((a) => a.cat === String(e.id))).map((e) => {
251
+ const a = E(
242
252
  Z.filter((l) => l.cat === String(e.id)).reduce((l, r) => l + Y(r.values), 0)
243
253
  );
244
254
  return {
@@ -246,282 +256,282 @@ function Ya(v) {
246
256
  label: e.label,
247
257
  cap: e.cap,
248
258
  planned: a,
249
- left: T(e.cap - a)
259
+ left: E(e.cap - a)
250
260
  };
251
- }) : [], [ie, Z, Y]), J = ee(
252
- (e, a) => xa(c, e, a),
261
+ }) : [], [de, Z, Y]), J = ee(
262
+ (e, a) => ya(c, e, a),
253
263
  [c]
254
- ), je = ee(
255
- (e, a) => !z || J(e, a) && !!(c != null && c.closed_locked) && !y,
256
- [z, J, c == null ? void 0 : c.closed_locked, y]
264
+ ), Fe = ee(
265
+ (e, a) => !M || J(e, a) && !!(c != null && c.closed_locked) && !T,
266
+ [M, J, c == null ? void 0 : c.closed_locked, T]
257
267
  ), Re = ee(
258
268
  (e, a, l) => {
259
- var u, O, U;
260
- const r = c == null ? void 0 : c.rows.find((A) => String(A.key) === e);
269
+ var p, _, U;
270
+ const r = c == null ? void 0 : c.rows.find((K) => String(K.key) === e);
261
271
  if (!r) return { value: 0, details: [] };
262
- if (a == null) return { value: I(r.values[l]), details: ((u = r.details) == null ? void 0 : u[l]) ?? [] };
263
- const s = (O = r.by_category) == null ? void 0 : O[a];
264
- return { value: I(s == null ? void 0 : s.values[l]), details: ((U = s == null ? void 0 : s.details) == null ? void 0 : U[l]) ?? [] };
272
+ if (a == null) return { value: I(r.values[l]), details: ((p = r.details) == null ? void 0 : p[l]) ?? [] };
273
+ const o = (_ = r.by_category) == null ? void 0 : _[a];
274
+ return { value: I(o == null ? void 0 : o.values[l]), details: ((U = o == null ? void 0 : o.details) == null ? void 0 : U[l]) ?? [] };
265
275
  },
266
276
  [c]
267
- ), [ft, We] = H(null), X = ee(
277
+ ), [gt, Qe] = H(null), X = ee(
268
278
  (e, a, l, r) => {
269
279
  if (!x) return !1;
270
- const s = (r == null ? void 0 : r.credit) ?? 0, u = { ...e.values, ...a }, O = Y(e.values), U = Y(u);
271
- if (U - s > O + 5e-3) {
272
- if (K) {
273
- const A = at(K.cap, Oe), _ = T(He - O + U - s);
274
- if (A != null && _ > A + 5e-3)
275
- return We(
276
- `${K.message ?? `${K.label ?? "The total"} cannot exceed ${D(A)}`} — this would reach ${D(_)}, ${D(T(_ - A))} over.`
280
+ const o = (r == null ? void 0 : r.credit) ?? 0, p = { ...e.values, ...a }, _ = Y(e.values), U = Y(p);
281
+ if (U - o > _ + 5e-3) {
282
+ if (R) {
283
+ const K = lt(R.cap, Oe), S = E(We - _ + U - o);
284
+ if (K != null && S > K + 5e-3)
285
+ return Qe(
286
+ `${R.message ?? `${R.label ?? "The total"} cannot exceed ${z(K)}`} — this would reach ${z(S)}, ${z(E(S - K))} over.`
277
287
  ), !1;
278
288
  }
279
289
  if (e.cat != null) {
280
- const A = Le.find((_) => _.id === e.cat);
281
- if (A) {
282
- const _ = T(A.planned - O + U - s);
283
- if (_ > A.cap + 5e-3)
284
- return We(
285
- `${A.label} would reach ${D(_)} — ${D(T(_ - A.cap))} over its ${D(A.cap)}.`
290
+ const K = Le.find((S) => S.id === e.cat);
291
+ if (K) {
292
+ const S = E(K.planned - _ + U - o);
293
+ if (S > K.cap + 5e-3)
294
+ return Qe(
295
+ `${K.label} would reach ${z(S)} — ${z(E(S - K.cap))} over its ${z(K.cap)}.`
286
296
  ), !1;
287
297
  }
288
298
  }
289
299
  }
290
- return We(null), e.id ? x.queueEdit(n, p, e.id, {
300
+ return Qe(null), e.id ? x.queueEdit(n, g, e.id, {
291
301
  ...a,
292
302
  ...l ? { _change_reason: l } : {},
293
303
  ...r != null && r.early ? { __flush_early: !0 } : {}
294
- }) : e.pendingIndex != null && x.updateRow(n, p, e.pendingIndex, {
304
+ }) : e.pendingIndex != null && x.updateRow(n, g, e.pendingIndex, {
295
305
  ...e.values,
296
306
  ...a,
297
307
  ...l ? { _change_reason: l } : {}
298
308
  }), !0;
299
309
  },
300
- [x, Y, K, Oe, He, Le, n, p]
310
+ [x, Y, R, Oe, We, Le, n, g]
301
311
  ), Me = ee(
302
312
  (e, a, l, r) => {
303
- x && x.queueRow(n, p, {
304
- [o.key_field]: e,
305
- ...r != null ? { [o.category_field]: /^\d+$/.test(r) ? Number(r) : r } : {},
306
- ...Object.fromEntries(m.map((s) => [s, (a == null ? void 0 : a[s]) ?? 0])),
313
+ x && x.queueRow(n, g, {
314
+ [i.key_field]: e,
315
+ ...r != null ? { [i.category_field]: /^\d+$/.test(r) ? Number(r) : r } : {},
316
+ ...Object.fromEntries(f.map((o) => [o, (a == null ? void 0 : a[o]) ?? 0])),
307
317
  ...l ? { _change_reason: l } : {}
308
318
  });
309
319
  },
310
- [x, n, p, o.key_field, o.category_field, m]
311
- ), { data: Qe } = ce({
312
- queryKey: ["plan-grid-keys", o.key_collection],
313
- queryFn: () => S.request(
314
- ue(`/items/${o.key_collection}`, { fields: "id", sort: "-id", limit: 200 })
320
+ [x, n, g, i.key_field, i.category_field, f]
321
+ ), { data: Ve } = pe({
322
+ queryKey: ["plan-grid-keys", i.key_collection],
323
+ queryFn: () => b.request(
324
+ me(`/items/${i.key_collection}`, { fields: "id", sort: "-id", limit: 200 })
315
325
  ).then((e) => (e.data ?? []).map((a) => a.id)),
316
- enabled: !!o.key_collection && !!(c != null && c.closed_through),
326
+ enabled: !!i.key_collection && !!(c != null && c.closed_through),
317
327
  staleTime: 10 * 6e4
318
- }), Ve = ee(
328
+ }), Je = ee(
319
329
  (e, a) => {
320
330
  const l = Number(e);
321
331
  if (!Number.isInteger(l)) return null;
322
- const r = String(l + 1), s = m.filter((A) => !J(r, A)), u = re.find((A) => A.key === r);
323
- let O = null, U = null;
324
- return o.key_collection && Qe && !Qe.some((A) => String(A) === r) ? U = `${r} is not set up yet` : s.length === 0 ? U = `${r} has no open period either` : (u == null ? void 0 : u.mode) === "split" ? a == null ? U = `${r} 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 ? U = `${r} is planned as one line and this one is by category` : O = u.top), { key: r, cat: a, openColumns: s, row: O, blocked: U };
332
+ const r = String(l + 1), o = f.filter((K) => !J(r, K)), p = se.find((K) => K.key === r);
333
+ let _ = null, U = null;
334
+ return i.key_collection && Ve && !Ve.some((K) => String(K) === r) ? U = `${r} is not set up yet` : o.length === 0 ? U = `${r} has no open period either` : (p == null ? void 0 : p.mode) === "split" ? a == null ? U = `${r} is planned by category and this line is not` : _ = p.cats.find((K) => K.cat === a) ?? null : (p == null ? void 0 : p.mode) === "top" && (a != null ? U = `${r} is planned as one line and this one is by category` : _ = p.top), { key: r, cat: a, openColumns: o, row: _, blocked: U };
325
335
  },
326
- [m, J, re, o.key_collection, Qe]
327
- ), Je = ee(
336
+ [f, J, se, i.key_collection, Ve]
337
+ ), Ge = ee(
328
338
  (e, a, l, r) => {
329
339
  if (!r || Object.keys(r.patch).length === 0) return X(e, a, l);
330
- const s = T(Y({ ...e.values, ...a }) - Y(e.values)), u = r.target.row, O = T(
331
- Y({ ...(u == null ? void 0 : u.values) ?? {}, ...r.patch }) - Y((u == null ? void 0 : u.values) ?? {})
340
+ const o = E(Y({ ...e.values, ...a }) - Y(e.values)), p = r.target.row, _ = E(
341
+ Y({ ...(p == null ? void 0 : p.values) ?? {}, ...r.patch }) - Y((p == null ? void 0 : p.values) ?? {})
332
342
  );
333
- return s <= 0 ? u ? X(u, r.patch, l, { credit: -s }) ? X(e, a, l, { early: !0 }) : !1 : O > -s + 5e-3 || !X(e, a, l, { early: !0 }) ? !1 : (Me(Number(r.target.key), r.patch, l, r.target.cat), !0) : u ? X(e, a, l, { credit: -O }) ? X(u, r.patch, l, { early: !0 }) : !1 : X(e, a, l);
343
+ return o <= 0 ? p ? X(p, r.patch, l, { credit: -o }) ? X(e, a, l, { early: !0 }) : !1 : _ > -o + 5e-3 || !X(e, a, l, { early: !0 }) ? !1 : (Me(Number(r.target.key), r.patch, l, r.target.cat), !0) : p ? X(e, a, l, { credit: -_ }) ? X(p, r.patch, l, { early: !0 }) : !1 : X(e, a, l);
334
344
  },
335
345
  [X, Y, Me]
336
- ), At = ee(
346
+ ), It = ee(
337
347
  (e) => {
338
348
  if (!x) return;
339
349
  const a = [...e.top ? [e.top] : [], ...e.cats];
340
- for (const l of a.filter((r) => r.pendingIndex != null).sort((r, s) => (s.pendingIndex ?? 0) - (r.pendingIndex ?? 0)))
341
- x.removeRow(n, p, l.pendingIndex);
342
- for (const l of a) l.id && x.queueDelete(n, p, l.id);
350
+ for (const l of a.filter((r) => r.pendingIndex != null).sort((r, o) => (o.pendingIndex ?? 0) - (r.pendingIndex ?? 0)))
351
+ x.removeRow(n, g, l.pendingIndex);
352
+ for (const l of a) l.id && x.queueDelete(n, g, l.id);
343
353
  },
344
- [x, n, p]
345
- ), Kt = ee(() => {
346
- b.invalidateQueries({ queryKey: ["o2m-rows", n, p, g] }), b.invalidateQueries({ queryKey: De }), Pe && b.invalidateQueries({ queryKey: ["o2m-compare", Pe] });
347
- }, [b, n, p, g, De, Pe]), Ge = $e(null), ye = G(() => {
354
+ [x, n, g]
355
+ ), Bt = ee(() => {
356
+ y.invalidateQueries({ queryKey: ["o2m-rows", n, g, h] }), y.invalidateQueries({ queryKey: ze }), Pe && y.invalidateQueries({ queryKey: ["o2m-compare", Pe] });
357
+ }, [y, n, g, h, ze, Pe]), Ze = ke(null), be = G(() => {
348
358
  const e = [];
349
- for (const a of re)
359
+ for (const a of se)
350
360
  if (a.mode === "top" && a.top && e.push(a.top.uid), a.mode === "split") for (const l of a.cats) e.push(l.uid);
351
361
  return e;
352
- }, [re]), xt = ee((e, a) => {
362
+ }, [se]), yt = ee((e, a) => {
353
363
  var r;
354
- const l = (r = Ge.current) == null ? void 0 : r.querySelector(`[data-pg-cell="${e}:${a}"]`);
364
+ const l = (r = Ze.current) == null ? void 0 : r.querySelector(`[data-pg-cell="${e}:${a}"]`);
355
365
  return l ? (l.focus(), l.select(), !0) : !1;
356
- }, []), gt = ee(
366
+ }, []), bt = ee(
357
367
  (e, a, l, r) => {
358
- let s = ye.indexOf(e), u = m.indexOf(a);
359
- for (let O = 0; O < 40; O++)
360
- if (s += l, u += r, s < 0 || s >= ye.length || u < 0 || u >= m.length || xt(ye[s], m[u])) return;
368
+ let o = be.indexOf(e), p = f.indexOf(a);
369
+ for (let _ = 0; _ < 40; _++)
370
+ if (o += l, p += r, o < 0 || o >= be.length || p < 0 || p >= f.length || yt(be[o], f[p])) return;
361
371
  },
362
- [ye, m, xt]
363
- ), yt = ee(
372
+ [be, f, yt]
373
+ ), kt = ee(
364
374
  (e, a, l) => {
365
375
  const r = l.replace(/\r/g, "").split(`
366
- `).filter((U) => U.trim() !== ""), s = ye.indexOf(e.uid), u = m.indexOf(a);
367
- let O = 0;
368
- r.forEach((U, A) => {
369
- const _ = Z.find((te) => te.uid === ye[s + A]);
370
- if (!_) return;
376
+ `).filter((U) => U.trim() !== ""), o = be.indexOf(e.uid), p = f.indexOf(a);
377
+ let _ = 0;
378
+ r.forEach((U, K) => {
379
+ const S = Z.find((te) => te.uid === be[o + K]);
380
+ if (!S) return;
371
381
  const W = {};
372
- U.split(" ").forEach((te, h) => {
373
- const $ = m[u + h];
374
- if (!$ || je(_.key, $)) return;
375
- const ae = qt(te);
382
+ U.split(" ").forEach((te, m) => {
383
+ const $ = f[p + m];
384
+ if (!$ || Fe(S.key, $)) return;
385
+ const ae = At(te);
376
386
  ae == null || ae < 0 || (W[$] = ae);
377
- }), Object.keys(W).length && X(_, W) && (O += Object.keys(W).length);
378
- }), O && de.success(`Pasted ${O} ${O === 1 ? "figure" : "figures"}`);
387
+ }), Object.keys(W).length && X(S, W) && (_ += Object.keys(W).length);
388
+ }), _ && ue.success(`Pasted ${_} ${_ === 1 ? "figure" : "figures"}`);
379
389
  },
380
- [ye, m, Z, je, X]
381
- ), [It, bt] = H(/* @__PURE__ */ new Set()), Ze = $e(null);
382
- pe(() => {
390
+ [be, f, Z, Fe, X]
391
+ ), [Dt, vt] = H(/* @__PURE__ */ new Set()), Ye = ke(null);
392
+ ce(() => {
383
393
  const e = (a) => {
384
394
  const l = a.detail;
385
395
  if (!l || l.collection !== n || l.rowId == null) return;
386
- const r = Z.find((s) => s.id === String(l.rowId));
387
- r && (l.handled = !0, Ze.current !== r.id && (Ze.current = r.id, window.setTimeout(() => {
388
- Ze.current = null;
389
- }, 8e3), bt((s) => {
390
- if (!s.has(r.key)) return s;
391
- const u = new Set(s);
392
- return u.delete(r.key), u;
396
+ const r = Z.find((o) => o.id === String(l.rowId));
397
+ r && (l.handled = !0, Ye.current !== r.id && (Ye.current = r.id, window.setTimeout(() => {
398
+ Ye.current = null;
399
+ }, 8e3), vt((o) => {
400
+ if (!o.has(r.key)) return o;
401
+ const p = new Set(o);
402
+ return p.delete(r.key), p;
393
403
  }), window.setTimeout(() => {
394
- var u;
395
- const s = (u = Ge.current) == null ? void 0 : u.querySelector(`[data-o2m-row="${n}:${r.id}"]`);
396
- s && (s.scrollIntoView({ block: "center", behavior: "smooth" }), s.classList.remove("nvr-row-flash"), s.offsetWidth, s.classList.add("nvr-row-flash"));
404
+ var p;
405
+ const o = (p = Ze.current) == null ? void 0 : p.querySelector(`[data-o2m-row="${n}:${r.id}"]`);
406
+ o && (o.scrollIntoView({ block: "center", behavior: "smooth" }), o.classList.remove("nvr-row-flash"), o.offsetWidth, o.classList.add("nvr-row-flash"));
397
407
  }, 60)));
398
408
  };
399
409
  return window.addEventListener("nvr:grid-open-row", e), () => window.removeEventListener("nvr:grid-open-row", e);
400
410
  }, [n, Z]);
401
- const [Bt, Dt] = H(() => {
411
+ const [zt, Ut] = H(() => {
402
412
  try {
403
413
  return new Set(
404
- JSON.parse(localStorage.getItem(`nvr_pg_dismissed:${n}:${g}`) ?? "[]")
414
+ JSON.parse(localStorage.getItem(`nvr_pg_dismissed:${n}:${h}`) ?? "[]")
405
415
  );
406
416
  } catch {
407
417
  return /* @__PURE__ */ new Set();
408
418
  }
409
- }), kt = ((c == null ? void 0 : c.proposals) ?? []).filter((e) => !Bt.has(e.id)), vt = (e, a) => {
410
- Dt((l) => {
419
+ }), Nt = ((c == null ? void 0 : c.proposals) ?? []).filter((e) => !zt.has(e.id)), wt = (e, a) => {
420
+ Ut((l) => {
411
421
  const r = new Set(l).add(e.id);
412
422
  if (a)
413
423
  try {
414
- localStorage.setItem(`nvr_pg_dismissed:${n}:${g}`, JSON.stringify([...r]));
424
+ localStorage.setItem(`nvr_pg_dismissed:${n}:${h}`, JSON.stringify([...r]));
415
425
  } catch {
416
426
  }
417
427
  return r;
418
428
  });
419
- }, zt = (e) => {
429
+ }, Ht = (e) => {
420
430
  let a = 0;
421
431
  for (const l of e.rows) {
422
- const r = String(l.key), s = re.find((_) => _.key === r);
423
- if ((s == null ? void 0 : s.mode) === "split" != (l.category != null)) continue;
424
- const u = e.mode === "add", O = Object.fromEntries(
432
+ const r = String(l.key), o = se.find((S) => S.key === r);
433
+ if ((o == null ? void 0 : o.mode) === "split" != (l.category != null)) continue;
434
+ const p = e.mode === "add", _ = Object.fromEntries(
425
435
  Object.entries(l.values).filter(
426
- ([_, W]) => m.includes(_) && !J(r, _) && (u ? I(W) !== 0 : I(W) > 0)
436
+ ([S, W]) => f.includes(S) && !J(r, S) && (p ? I(W) !== 0 : I(W) > 0)
427
437
  )
428
- ), U = (_) => Object.fromEntries(
429
- Object.entries(O).map(([W, te]) => [W, Math.max(0, T(I(_ == null ? void 0 : _[W]) + I(te)))]).filter(([W, te]) => Math.abs(te - I(_ == null ? void 0 : _[W])) >= 5e-3)
430
- ), A = l.category != null ? s == null ? void 0 : s.cats.find((_) => String(_.cat) === String(l.category)) : null;
438
+ ), U = (S) => Object.fromEntries(
439
+ Object.entries(_).map(([W, te]) => [W, Math.max(0, E(I(S == null ? void 0 : S[W]) + I(te)))]).filter(([W, te]) => Math.abs(te - I(S == null ? void 0 : S[W])) >= 5e-3)
440
+ ), K = l.category != null ? o == null ? void 0 : o.cats.find((S) => String(S.cat) === String(l.category)) : null;
431
441
  if (l.category != null) {
432
- if (!A) continue;
433
- const _ = u ? U(A.values) : Object.fromEntries(Object.entries(O).filter(([W]) => I(A.values[W]) === 0));
434
- Object.keys(_).length && X(A, _, e.change_reason) && (a += Object.keys(_).length);
435
- } else if (s != null && s.top) {
436
- const _ = u ? U(s.top.values) : Object.fromEntries(Object.entries(O).filter(([W]) => {
442
+ if (!K) continue;
443
+ const S = p ? U(K.values) : Object.fromEntries(Object.entries(_).filter(([W]) => I(K.values[W]) === 0));
444
+ Object.keys(S).length && X(K, S, e.change_reason) && (a += Object.keys(S).length);
445
+ } else if (o != null && o.top) {
446
+ const S = p ? U(o.top.values) : Object.fromEntries(Object.entries(_).filter(([W]) => {
437
447
  var te;
438
- return I((te = s.top) == null ? void 0 : te.values[W]) === 0;
448
+ return I((te = o.top) == null ? void 0 : te.values[W]) === 0;
439
449
  }));
440
- Object.keys(_).length && X(s.top, _, e.change_reason) && (a += Object.keys(_).length);
441
- } else Object.keys(O).length && !(u && Object.values(O).every((_) => I(_) < 0)) && (Me(l.key, u ? U(void 0) : O, e.change_reason), a += Object.keys(O).length);
450
+ Object.keys(S).length && X(o.top, S, e.change_reason) && (a += Object.keys(S).length);
451
+ } else Object.keys(_).length && !(p && Object.values(_).every((S) => I(S) < 0)) && (Me(l.key, p ? U(void 0) : _, e.change_reason), a += Object.keys(_).length);
442
452
  }
443
- a ? de.success(
453
+ a ? ue.success(
444
454
  `${e.label}: ${a} ${a === 1 ? "figure" : "figures"} staged — Save to keep them`
445
- ) : de.message(
455
+ ) : ue.message(
446
456
  e.mode === "add" ? "Nothing to move — no open period could take it" : "Nothing to fill — those periods already hold a figure"
447
- ), vt(e, !1);
448
- }, [Q, Ye] = H(null), Fe = wa(), Xe = Q && (Fe != null && Fe.renderRowHistory) ? Fe.renderRowHistory({
457
+ ), wt(e, !1);
458
+ }, [Q, Xe] = H(null), Ke = Ca(), et = Q && (Ke != null && Ke.renderRowHistory) ? Ke.renderRowHistory({
449
459
  collection: n,
450
- parentId: g,
460
+ parentId: h,
451
461
  rowId: Q.id,
452
462
  key: Q.key,
453
463
  category: Q.cat,
454
- categoryLabel: (e) => Se(String(e)),
455
- onClose: () => Ye(null)
456
- }) : null, { data: Ut = [], isLoading: Ht } = ce({
464
+ categoryLabel: (e) => we(String(e)),
465
+ onClose: () => Xe(null)
466
+ }) : null, { data: Wt = [], isLoading: Qt } = pe({
457
467
  queryKey: ["o2m-row-revisions", n, Q == null ? void 0 : Q.id],
458
- queryFn: () => S.request(
459
- ue("/revisions", { collection: n, item: String(Q == null ? void 0 : Q.id) })
468
+ queryFn: () => b.request(
469
+ me("/revisions", { collection: n, item: String(Q == null ? void 0 : Q.id) })
460
470
  ).then((e) => e.data ?? []),
461
- enabled: !!(Q != null && Q.id) && Xe == null,
471
+ enabled: !!(Q != null && Q.id) && et == null,
462
472
  staleTime: 15e3
463
- }), { data: Nt = [] } = ce({
473
+ }), { data: $t = [] } = pe({
464
474
  queryKey: ["plan-grid-fields", n],
465
- queryFn: () => S.request(ue(`/field-config/${n}`)).then((e) => e.data ?? []),
475
+ queryFn: () => b.request(me(`/field-config/${n}`)).then((e) => e.data ?? []),
466
476
  enabled: !!Q,
467
477
  staleTime: 5 * 6e4
468
- }), [et, Wt] = H(!1), wt = re.some((e) => e.mode === "split"), Ae = Pt(c), Ne = (c == null ? void 0 : c.label) ?? (C == null ? void 0 : C.label) ?? "Actual", Ke = ga(c == null ? void 0 : c.closed_through), Te = c != null && c.closed_through ? Number(c.closed_through.split("-")[0]) : null, Qt = G(() => {
478
+ }), [tt, Vt] = H(!1), Ct = se.some((e) => e.mode === "split"), Ie = jt(c), $e = (c == null ? void 0 : c.label) ?? (N == null ? void 0 : N.label) ?? "Actual", Be = ba(c == null ? void 0 : c.closed_through), Te = c != null && c.closed_through ? Number(c.closed_through.split("-")[0]) : null, Jt = G(() => {
469
479
  if (Te == null) return null;
470
- const e = m.filter((a) => J(String(Te), a));
480
+ const e = f.filter((a) => J(String(Te), a));
471
481
  return e[e.length - 1] ?? null;
472
- }, [Te, m, J]), Vt = G(
473
- () => new Set(re.filter((e) => e.mode !== "ghost").map((e) => e.key)),
474
- [re]
475
- ), Jt = F ? at(F, Oe) : null, Gt = (e) => {
476
- let a = Jt ?? 0;
482
+ }, [Te, f, J]), Gt = G(
483
+ () => new Set(se.filter((e) => e.mode !== "ghost").map((e) => e.key)),
484
+ [se]
485
+ ), Zt = j ? lt(j, Oe) : null, Yt = (e) => {
486
+ let a = Zt ?? 0;
477
487
  if (e.cat != null) {
478
- const u = Le.find((O) => O.id === e.cat);
479
- u && (a = Math.min(a, u.left));
488
+ const p = Le.find((_) => _.id === e.cat);
489
+ p && (a = Math.min(a, p.left));
480
490
  }
481
- const l = m.filter((u) => !J(e.key, u) && I(e.values[u]) === 0);
491
+ const l = f.filter((p) => !J(e.key, p) && I(e.values[p]) === 0);
482
492
  if (a < 5e-3 || l.length === 0) {
483
- de.message(
493
+ ue.message(
484
494
  a < 5e-3 ? "Nothing is left to spread" : "No empty open periods on this line"
485
495
  );
486
496
  return;
487
497
  }
488
- const r = Math.floor(a / l.length * 100) / 100, s = {};
489
- l.forEach((u, O) => {
490
- s[u] = O === l.length - 1 ? T(a - r * (l.length - 1)) : r;
491
- }), X(e, s) && de.success(`${D(a)} spread over ${l.length} open periods`);
492
- }, tt = G(() => {
498
+ const r = Math.floor(a / l.length * 100) / 100, o = {};
499
+ l.forEach((p, _) => {
500
+ o[p] = _ === l.length - 1 ? E(a - r * (l.length - 1)) : r;
501
+ }), X(e, o) && ue.success(`${z(a)} spread over ${l.length} open periods`);
502
+ }, at = G(() => {
493
503
  const e = {}, a = {};
494
- for (const l of m)
495
- e[l] = T(Z.reduce((r, s) => r + I(s.values[l]), 0)), a[l] = T(((c == null ? void 0 : c.rows) ?? []).reduce((r, s) => r + I(s.values[l]), 0));
504
+ for (const l of f)
505
+ e[l] = E(Z.reduce((r, o) => r + I(o.values[l]), 0)), a[l] = E(((c == null ? void 0 : c.rows) ?? []).reduce((r, o) => r + I(o.values[l]), 0));
496
506
  return { planBy: e, actualBy: a };
497
- }, [m, Z, c]), Zt = Lt + m.length * Rt + Mt;
498
- return !i && se ? /* @__PURE__ */ t("div", { className: "space-y-1.5", "data-plan-grid-loading": !0, children: [0, 1, 2].map((e) => /* @__PURE__ */ t(
507
+ }, [f, Z, c]), Xt = Mt + f.length * Tt + Et;
508
+ return !s && oe ? /* @__PURE__ */ t("div", { className: "space-y-1.5", "data-plan-grid-loading": !0, children: [0, 1, 2].map((e) => /* @__PURE__ */ t(
499
509
  "div",
500
510
  {
501
511
  className: "h-8 animate-pulse rounded",
502
512
  style: { background: "hsl(var(--nvr-skeleton))" }
503
513
  },
504
514
  e
505
- )) }) : /* @__PURE__ */ d("div", { ref: Ge, "data-plan-grid": n, className: "min-w-0", children: [
506
- c && kt.length > 0 && z && /* @__PURE__ */ t(
507
- ya,
515
+ )) }) : /* @__PURE__ */ d("div", { ref: Ze, "data-plan-grid": n, className: "min-w-0", children: [
516
+ c && Nt.length > 0 && M && /* @__PURE__ */ t(
517
+ ka,
508
518
  {
509
- proposals: kt,
510
- onApply: zt,
511
- onDismiss: (e) => vt(e, !0)
519
+ proposals: Nt,
520
+ onApply: Ht,
521
+ onDismiss: (e) => wt(e, !0)
512
522
  }
513
523
  ),
514
- (ht.length > 0 || C) && /* @__PURE__ */ d("div", { className: "mb-2 flex flex-wrap items-center gap-1.5", "data-o2m-stats": !0, children: [
524
+ (xt.length > 0 || N) && /* @__PURE__ */ d("div", { className: "mb-2 flex flex-wrap items-center gap-1.5", "data-o2m-stats": !0, children: [
515
525
  /* @__PURE__ */ t(
516
- ba,
526
+ va,
517
527
  {
518
528
  data: c,
519
- loading: !!C && !i && Be.isLoading,
520
- error: !!C && !i && Be.isError
529
+ loading: !!N && !s && qe.isLoading,
530
+ error: !!N && !s && qe.isError
521
531
  }
522
532
  ),
523
- ht.map((e) => /* @__PURE__ */ t(
524
- _t,
533
+ xt.map((e) => /* @__PURE__ */ t(
534
+ Lt,
525
535
  {
526
536
  label: e.label,
527
537
  value: e.result,
@@ -530,26 +540,26 @@ function Ya(v) {
530
540
  },
531
541
  e.label
532
542
  )),
533
- Le.length > 1 && wt && /* @__PURE__ */ d(
543
+ Le.length > 1 && Ct && /* @__PURE__ */ d(
534
544
  "button",
535
545
  {
536
546
  type: "button",
537
547
  "data-plan-grid-categories-toggle": !0,
538
- "aria-expanded": et,
539
- onClick: () => Wt((e) => !e),
548
+ "aria-expanded": tt,
549
+ onClick: () => Vt((e) => !e),
540
550
  className: "inline-flex h-[28px] items-center gap-1 rounded-md px-2 text-[11.5px] font-medium text-slate-600 hover:bg-muted dark:text-slate-300",
541
551
  children: [
542
- et ? /* @__PURE__ */ t($t, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t(Ct, { className: "h-3.5 w-3.5" }),
552
+ tt ? /* @__PURE__ */ t(St, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t(_t, { className: "h-3.5 w-3.5" }),
543
553
  "By category"
544
554
  ]
545
555
  }
546
556
  )
547
557
  ] }),
548
- et && wt && /* @__PURE__ */ t("div", { className: "mb-2 flex flex-wrap gap-1.5", "data-plan-grid-categories": !0, children: Le.map((e) => /* @__PURE__ */ t(
549
- _t,
558
+ tt && Ct && /* @__PURE__ */ t("div", { className: "mb-2 flex flex-wrap gap-1.5", "data-plan-grid-categories": !0, children: Le.map((e) => /* @__PURE__ */ t(
559
+ Lt,
550
560
  {
551
561
  dataKey: `category:${e.id}`,
552
- label: `${e.label} left of ${D(e.cap)}`,
562
+ label: `${e.label} left of ${z(e.cap)}`,
553
563
  value: e.left,
554
564
  format: "currency",
555
565
  negative: e.left < -5e-3
@@ -561,56 +571,56 @@ function Ya(v) {
561
571
  {
562
572
  className: "overflow-x-auto rounded-lg border border-slate-200 dark:border-border",
563
573
  "data-plan-grid-scroll": !0,
564
- onFocusCapture: jt,
565
- onBlurCapture: Ft,
574
+ onFocusCapture: Ft,
575
+ onBlurCapture: Kt,
566
576
  children: /* @__PURE__ */ d(
567
577
  "table",
568
578
  {
569
579
  className: "border-separate border-spacing-0 text-[12px] tabular-nums",
570
- style: { width: "100%", minWidth: Zt, tableLayout: "fixed" },
580
+ style: { width: "100%", minWidth: Xt, tableLayout: "fixed" },
571
581
  children: [
572
582
  /* @__PURE__ */ d("colgroup", { children: [
573
- /* @__PURE__ */ t("col", { style: { width: Lt } }),
574
- m.map((e) => /* @__PURE__ */ t("col", { style: { width: Rt } }, e)),
575
- /* @__PURE__ */ t("col", { style: { width: Mt } })
583
+ /* @__PURE__ */ t("col", { style: { width: Mt } }),
584
+ f.map((e) => /* @__PURE__ */ t("col", { style: { width: Tt } }, e)),
585
+ /* @__PURE__ */ t("col", { style: { width: Et } })
576
586
  ] }),
577
587
  /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ d("tr", { children: [
578
588
  /* @__PURE__ */ t(
579
589
  "th",
580
590
  {
581
- className: B(
582
- be,
591
+ className: D(
592
+ ve,
583
593
  "z-[3] border-b px-3 py-1.5 text-left text-[10.5px] font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400"
584
594
  ),
585
- children: lt(o.key_field)
595
+ children: nt(i.key_field)
586
596
  }
587
597
  ),
588
- m.map((e) => {
598
+ f.map((e) => {
589
599
  const a = Te != null && J(String(Te), e);
590
600
  return /* @__PURE__ */ t(
591
601
  "th",
592
602
  {
593
- className: B(
603
+ className: D(
594
604
  "border-b border-slate-200 px-2.5 py-1.5 text-right text-[10.5px] font-semibold uppercase tracking-wide text-slate-500 dark:border-border dark:text-slate-400",
595
- a && Ce
605
+ a && Se
596
606
  ),
597
607
  children: /* @__PURE__ */ d("span", { className: "inline-flex items-center justify-end gap-1", children: [
598
- e === Qt && /* @__PURE__ */ t(
608
+ e === Jt && /* @__PURE__ */ t(
599
609
  "span",
600
610
  {
601
611
  "data-plan-grid-lock": !0,
602
- "data-tip": `Closed through ${Ke ?? ""}${c != null && c.closed_rule ? ` — ${c.closed_rule}` : ""}`,
612
+ "data-tip": `Closed through ${Be ?? ""}${c != null && c.closed_rule ? ` — ${c.closed_rule}` : ""}`,
603
613
  className: "inline-flex",
604
614
  children: /* @__PURE__ */ t(
605
- ta,
615
+ la,
606
616
  {
607
617
  className: "h-3 w-3",
608
- "aria-label": `Closed through ${Ke ?? ""}`
618
+ "aria-label": `Closed through ${Be ?? ""}`
609
619
  }
610
620
  )
611
621
  }
612
622
  ),
613
- st(e)
623
+ ot(e)
614
624
  ] })
615
625
  },
616
626
  e
@@ -619,67 +629,67 @@ function Ya(v) {
619
629
  /* @__PURE__ */ t(
620
630
  "th",
621
631
  {
622
- className: B(
623
- ke,
632
+ className: D(
633
+ Ne,
624
634
  "z-[3] border-b px-3 py-1.5 text-right text-[10.5px] font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400"
625
635
  ),
626
- children: o.total_label ?? "Total"
636
+ children: i.total_label ?? "Total"
627
637
  }
628
638
  )
629
639
  ] }) }),
630
- re.length === 0 && /* @__PURE__ */ t("tbody", { children: /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ d(
640
+ se.length === 0 && /* @__PURE__ */ t("tbody", { children: /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ d(
631
641
  "td",
632
642
  {
633
- colSpan: m.length + 2,
643
+ colSpan: f.length + 2,
634
644
  className: "px-3 py-6 text-[12.5px] text-slate-500 dark:text-slate-400",
635
645
  children: [
636
- `No ${(k ?? "rows").toLowerCase()} yet.`,
637
- z ? ` Add a ${lt(o.key_field).toLowerCase()} to start planning.` : ""
646
+ `No ${(v ?? "rows").toLowerCase()} yet.`,
647
+ M ? ` Add a ${nt(i.key_field).toLowerCase()} to start planning.` : ""
638
648
  ]
639
649
  }
640
650
  ) }) }),
641
- re.map((e, a) => {
642
- var _, W, te;
643
- const l = !It.has(e.key), r = (h) => {
651
+ se.map((e, a) => {
652
+ var S, W, te;
653
+ const l = !Dt.has(e.key), r = (m) => {
644
654
  var $;
645
- return e.mode === "split" ? T(e.cats.reduce((ae, Yt) => ae + I(Yt.values[h]), 0)) : I(($ = e.top) == null ? void 0 : $.values[h]);
646
- }, s = T(m.reduce((h, $) => h + r($), 0)), u = m.some(
647
- (h) => Math.abs(Re(e.key, Ie, h).value) >= 5e-3
648
- ), O = ((c == null ? void 0 : c.series) ?? []).filter(
649
- (h) => m.some(($) => Math.abs(we(h, e.key, $) ?? 0) >= 5e-3)
650
- ), U = m.some((h) => Math.abs(Re(e.key, null, h).value) >= 5e-3), A = (((_ = e.top) == null ? void 0 : _.edited) || ((W = e.top) == null ? void 0 : W.isNew) || e.cats.some((h) => h.edited || h.isNew)) ?? !1;
655
+ return e.mode === "split" ? E(e.cats.reduce((ae, ea) => ae + I(ea.values[m]), 0)) : I(($ = e.top) == null ? void 0 : $.values[m]);
656
+ }, o = E(f.reduce((m, $) => m + r($), 0)), p = f.some(
657
+ (m) => Math.abs(Re(e.key, De, m).value) >= 5e-3
658
+ ), _ = ((c == null ? void 0 : c.series) ?? []).filter(
659
+ (m) => f.some(($) => Math.abs(Ce(m, e.key, $) ?? 0) >= 5e-3)
660
+ ), U = f.some((m) => Math.abs(Re(e.key, null, m).value) >= 5e-3), K = (((S = e.top) == null ? void 0 : S.edited) || ((W = e.top) == null ? void 0 : W.isNew) || e.cats.some((m) => m.edited || m.isNew)) ?? !1;
651
661
  return /* @__PURE__ */ d(
652
662
  "tbody",
653
663
  {
654
664
  "data-plan-block": e.key,
655
665
  "data-plan-mode": e.mode,
656
- className: B(a > 0 && "pg-block"),
666
+ className: D(a > 0 && "pg-block"),
657
667
  children: [
658
668
  /* @__PURE__ */ d(
659
669
  "tr",
660
670
  {
661
671
  "data-o2m-row": (te = e.top) != null && te.id ? `${n}:${e.top.id}` : void 0,
662
- className: B(
672
+ className: D(
663
673
  a > 0 && "[&>td]:border-t [&>td]:border-slate-200 dark:[&>td]:border-border"
664
674
  ),
665
675
  children: [
666
- /* @__PURE__ */ t("td", { className: B(be, "px-2 py-1"), children: /* @__PURE__ */ d("div", { className: "flex items-center gap-1", children: [
676
+ /* @__PURE__ */ t("td", { className: D(ve, "px-2 py-1"), children: /* @__PURE__ */ d("div", { className: "flex items-center gap-1", children: [
667
677
  e.mode === "split" ? /* @__PURE__ */ t(
668
678
  "button",
669
679
  {
670
680
  type: "button",
671
681
  "aria-expanded": l,
672
682
  "aria-label": `${l ? "Collapse" : "Expand"} ${e.key}`,
673
- onClick: () => bt((h) => {
674
- const $ = new Set(h);
683
+ onClick: () => vt((m) => {
684
+ const $ = new Set(m);
675
685
  return $.has(e.key) ? $.delete(e.key) : $.add(e.key), $;
676
686
  }),
677
687
  className: "rounded p-0.5 text-slate-500 hover:bg-muted",
678
- children: l ? /* @__PURE__ */ t($t, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t(Ct, { className: "h-3.5 w-3.5" })
688
+ children: l ? /* @__PURE__ */ t(St, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t(_t, { className: "h-3.5 w-3.5" })
679
689
  }
680
690
  ) : /* @__PURE__ */ t("span", { className: "w-[18px]" }),
681
691
  /* @__PURE__ */ t("span", { className: "text-[13px] font-semibold text-slate-900 dark:text-slate-100", children: e.key }),
682
- A && /* @__PURE__ */ t(
692
+ K && /* @__PURE__ */ t(
683
693
  "span",
684
694
  {
685
695
  "data-plan-edited": !0,
@@ -687,26 +697,26 @@ function Ya(v) {
687
697
  className: "h-1.5 w-1.5 rounded-full bg-amber-500"
688
698
  }
689
699
  ),
690
- /* @__PURE__ */ t("span", { className: "ml-auto text-[10.5px] font-medium text-slate-500 dark:text-slate-400", children: e.mode === "ghost" ? "" : Ae }),
691
- z && e.mode !== "ghost" && /* @__PURE__ */ t(
692
- Ra,
700
+ /* @__PURE__ */ t("span", { className: "ml-auto text-[10.5px] font-medium text-slate-500 dark:text-slate-400", children: e.mode === "ghost" ? "" : Ie }),
701
+ M && e.mode !== "ghost" && /* @__PURE__ */ t(
702
+ Ta,
693
703
  {
694
704
  block: e,
695
- config: o,
696
- canSplit: !!he && !!(ie != null && ie.can_split) && !i,
697
- splitUnavailable: he && ie && !ie.can_split && !i ? (() => {
698
- const h = ie.categories.filter(($) => $.cap > 5e-3);
699
- return h.length === 1 ? `Every line on this record is ${h[0].label} — there is nothing to split between.` : "This record has no categorised lines yet — add lines first.";
705
+ config: i,
706
+ canSplit: !!fe && !!(de != null && de.can_split) && !s,
707
+ splitUnavailable: fe && de && !de.can_split && !s ? (() => {
708
+ const m = de.categories.filter(($) => $.cap > 5e-3);
709
+ return m.length === 1 ? `Every line on this record is ${m[0].label} — there is nothing to split between.` : "This record has no categorised lines yet — add lines first.";
700
710
  })() : null,
701
- splitBase: he,
702
- client: S,
703
- cols: m,
704
- catLabel: Se,
705
- showHistory: f,
706
- onHistory: Ye,
707
- onSpread: F ? Gt : null,
708
- onRemove: () => At(e),
709
- onDone: Kt,
711
+ splitBase: fe,
712
+ client: b,
713
+ cols: f,
714
+ catLabel: we,
715
+ showHistory: u,
716
+ onHistory: Xe,
717
+ onSpread: j ? Yt : null,
718
+ onRemove: () => It(e),
719
+ onDone: Bt,
710
720
  rc: n
711
721
  }
712
722
  )
@@ -714,11 +724,11 @@ function Ya(v) {
714
724
  e.mode === "ghost" ? /* @__PURE__ */ d(
715
725
  "td",
716
726
  {
717
- colSpan: m.length,
727
+ colSpan: f.length,
718
728
  className: "px-3 py-1 text-[12px] text-slate-500 dark:text-slate-400",
719
729
  children: [
720
- `No ${Ae.toLowerCase()} for ${e.key}`,
721
- z && /* @__PURE__ */ t(
730
+ `No ${Ie.toLowerCase()} for ${e.key}`,
731
+ M && /* @__PURE__ */ t(
722
732
  "button",
723
733
  {
724
734
  type: "button",
@@ -730,88 +740,88 @@ function Ya(v) {
730
740
  )
731
741
  ]
732
742
  }
733
- ) : m.map((h) => {
734
- const $ = J(e.key, h);
743
+ ) : f.map((m) => {
744
+ const $ = J(e.key, m);
735
745
  return e.mode === "split" ? /* @__PURE__ */ t(
736
746
  "td",
737
747
  {
738
- className: B(
748
+ className: D(
739
749
  "px-2.5 py-1 text-right font-semibold text-slate-900 dark:text-slate-100",
740
- $ && Ce
750
+ $ && Se
741
751
  ),
742
- children: /* @__PURE__ */ t(ne, { n: r(h) })
752
+ children: /* @__PURE__ */ t(ne, { n: r(m) })
743
753
  },
744
- h
754
+ m
745
755
  ) : /* @__PURE__ */ t(
746
- Tt,
756
+ Pt,
747
757
  {
748
758
  row: e.top,
749
- col: h,
759
+ col: m,
750
760
  closed: $,
751
- prov: oe(e.top, h),
752
- cellKey: V(e.top, h),
753
- locked: je(e.key, h),
761
+ prov: ie(e.top, m),
762
+ cellKey: V(e.top, m),
763
+ locked: Fe(e.key, m),
754
764
  lockedTip: $ ? (c == null ? void 0 : c.closed_locked_message) ?? "This period is closed" : void 0,
755
- onCommit: (ae) => X(e.top, { [h]: ae }),
756
- onMove: gt,
757
- onPaste: yt
765
+ onCommit: (ae) => X(e.top, { [m]: ae }),
766
+ onMove: bt,
767
+ onPaste: kt
758
768
  },
759
- h
769
+ m
760
770
  );
761
771
  }),
762
772
  /* @__PURE__ */ t(
763
773
  "td",
764
774
  {
765
- className: B(
766
- ke,
775
+ className: D(
776
+ Ne,
767
777
  "px-3 py-1 text-right font-semibold text-slate-900 dark:text-slate-100"
768
778
  ),
769
- children: e.mode === "ghost" ? "" : /* @__PURE__ */ t(ne, { n: s })
779
+ children: e.mode === "ghost" ? "" : /* @__PURE__ */ t(ne, { n: o })
770
780
  }
771
781
  )
772
782
  ]
773
783
  }
774
784
  ),
775
785
  c && /* @__PURE__ */ t(
776
- nt,
786
+ rt,
777
787
  {
778
- label: Ne,
788
+ label: $e,
779
789
  blockKey: e.key,
780
790
  cat: null,
781
- cols: m,
791
+ cols: f,
782
792
  compare: c,
783
793
  planOf: r,
784
794
  actualFor: Re,
785
795
  isClosed: J,
786
796
  row: e.mode === "top" ? e.top : null,
787
- canReconcile: z && e.mode === "top",
788
- onReconcile: Je,
789
- carryFor: Ve
797
+ canReconcile: M && e.mode === "top",
798
+ onReconcile: Ge,
799
+ carryFor: Je
790
800
  }
791
801
  ),
792
- e.mode !== "split" && O.map((h) => /* @__PURE__ */ d("tr", { "data-compare-series": h.key, children: [
793
- /* @__PURE__ */ t("td", { className: B(be, "px-2 py-0.5"), children: /* @__PURE__ */ t(
802
+ e.mode !== "split" && _.map((m) => /* @__PURE__ */ d("tr", { "data-compare-series": m.key, children: [
803
+ /* @__PURE__ */ t("td", { className: D(ve, "px-2 py-0.5"), children: /* @__PURE__ */ t(
794
804
  "span",
795
805
  {
796
- "data-tip": h.hint ?? "",
806
+ "data-tip": m.hint ?? "",
797
807
  className: "block pl-[22px] text-right text-[10.5px] font-medium text-slate-500 dark:text-slate-400",
798
- children: h.label
808
+ children: m.label
799
809
  }
800
810
  ) }),
801
- m.map(($) => /* @__PURE__ */ t(
811
+ f.map(($) => /* @__PURE__ */ t(
802
812
  "td",
803
813
  {
804
- className: B(
814
+ className: D(
805
815
  "px-2.5 py-0.5 text-right text-[11.5px] text-slate-500 dark:text-slate-400",
806
- J(e.key, $) && Ce
816
+ J(e.key, $) && Se
807
817
  ),
808
- children: Math.abs(we(h, e.key, $) ?? 0) >= 5e-3 ? /* @__PURE__ */ t(
809
- Ot,
818
+ children: Math.abs(Ce(m, e.key, $) ?? 0) >= 5e-3 ? /* @__PURE__ */ t(
819
+ Rt,
810
820
  {
811
- series: h,
812
- value: we(h, e.key, $) ?? 0,
821
+ series: m,
822
+ value: Ce(m, e.key, $) ?? 0,
813
823
  periodLabel: `${Ee($)} ${e.key}`,
814
- children: /* @__PURE__ */ t(ne, { n: we(h, e.key, $) ?? 0, muted: !0 })
824
+ children: /* @__PURE__ */ t(ne, { n: Ce(m, e.key, $) ?? 0, muted: !0 })
815
825
  }
816
826
  ) : /* @__PURE__ */ t(ne, { n: 0, muted: !0 })
817
827
  },
@@ -820,24 +830,24 @@ function Ya(v) {
820
830
  /* @__PURE__ */ t(
821
831
  "td",
822
832
  {
823
- className: B(
824
- ke,
833
+ className: D(
834
+ Ne,
825
835
  "px-3 py-0.5 text-right text-[11.5px] text-slate-500 dark:text-slate-400"
826
836
  ),
827
837
  children: /* @__PURE__ */ t(
828
- Ot,
838
+ Rt,
829
839
  {
830
- series: h,
831
- value: T(
832
- m.reduce(($, ae) => $ + (we(h, e.key, ae) ?? 0), 0)
840
+ series: m,
841
+ value: E(
842
+ f.reduce(($, ae) => $ + (Ce(m, e.key, ae) ?? 0), 0)
833
843
  ),
834
844
  periodLabel: String(e.key),
835
845
  whole: !0,
836
846
  children: /* @__PURE__ */ t(
837
847
  ne,
838
848
  {
839
- n: T(
840
- m.reduce(($, ae) => $ + (we(h, e.key, ae) ?? 0), 0)
849
+ n: E(
850
+ f.reduce(($, ae) => $ + (Ce(m, e.key, ae) ?? 0), 0)
841
851
  ),
842
852
  muted: !0
843
853
  }
@@ -846,83 +856,84 @@ function Ya(v) {
846
856
  )
847
857
  }
848
858
  )
849
- ] }, h.key)),
850
- e.mode === "split" && l && e.cats.map((h) => /* @__PURE__ */ d(Oa, { children: [
859
+ ] }, m.key)),
860
+ e.mode === "split" && l && e.cats.map((m) => /* @__PURE__ */ d(Ra, { children: [
851
861
  /* @__PURE__ */ d(
852
862
  "tr",
853
863
  {
854
- "data-o2m-row": h.id ? `${n}:${h.id}` : void 0,
855
- "data-plan-category": h.cat ?? "",
864
+ "data-o2m-row": m.id ? `${n}:${m.id}` : void 0,
865
+ "data-plan-category": m.cat ?? "",
856
866
  children: [
857
- /* @__PURE__ */ t("td", { className: B(be, "px-2 py-1"), children: /* @__PURE__ */ d("div", { className: "flex items-center gap-1 pl-[22px]", children: [
858
- /* @__PURE__ */ t("span", { className: "truncate text-[12.5px] font-medium text-slate-800 dark:text-slate-100", children: Se(h.cat) }),
859
- (h.edited || h.isNew) && /* @__PURE__ */ t("span", { className: "h-1.5 w-1.5 rounded-full bg-amber-500" }),
860
- /* @__PURE__ */ t("span", { className: "ml-auto text-[10.5px] font-medium text-slate-500 dark:text-slate-400", children: Ae })
867
+ /* @__PURE__ */ t("td", { className: D(ve, "px-2 py-1"), children: /* @__PURE__ */ d("div", { className: "flex items-center gap-1 pl-[22px]", children: [
868
+ /* @__PURE__ */ t("span", { className: "truncate text-[12.5px] font-medium text-slate-800 dark:text-slate-100", children: we(m.cat) }),
869
+ (m.edited || m.isNew) && /* @__PURE__ */ t("span", { className: "h-1.5 w-1.5 rounded-full bg-amber-500" }),
870
+ /* @__PURE__ */ t("span", { className: "ml-auto text-[10.5px] font-medium text-slate-500 dark:text-slate-400", children: Ie })
861
871
  ] }) }),
862
- m.map(($) => /* @__PURE__ */ t(
863
- Tt,
872
+ f.map(($) => /* @__PURE__ */ t(
873
+ Pt,
864
874
  {
865
- row: h,
875
+ row: m,
876
+ rowLabel: m.cat != null ? we(String(m.cat)) : void 0,
866
877
  col: $,
867
878
  closed: J(e.key, $),
868
- prov: oe(h, $),
869
- cellKey: V(h, $),
870
- locked: je(e.key, $),
879
+ prov: ie(m, $),
880
+ cellKey: V(m, $),
881
+ locked: Fe(e.key, $),
871
882
  lockedTip: J(e.key, $) ? (c == null ? void 0 : c.closed_locked_message) ?? "This period is closed" : void 0,
872
- onCommit: (ae) => X(h, { [$]: ae }),
873
- onMove: gt,
874
- onPaste: yt
883
+ onCommit: (ae) => X(m, { [$]: ae }),
884
+ onMove: bt,
885
+ onPaste: kt
875
886
  },
876
887
  $
877
888
  )),
878
889
  /* @__PURE__ */ t(
879
890
  "td",
880
891
  {
881
- className: B(
882
- ke,
892
+ className: D(
893
+ Ne,
883
894
  "px-3 py-1 text-right font-medium text-slate-800 dark:text-slate-100"
884
895
  ),
885
- children: /* @__PURE__ */ t(ne, { n: Y(h.values) })
896
+ children: /* @__PURE__ */ t(ne, { n: Y(m.values) })
886
897
  }
887
898
  )
888
899
  ]
889
900
  }
890
901
  ),
891
902
  c && U && /* @__PURE__ */ t(
892
- nt,
903
+ rt,
893
904
  {
894
- label: Ne,
905
+ label: $e,
895
906
  blockKey: e.key,
896
- cat: h.cat,
897
- cols: m,
907
+ cat: m.cat,
908
+ cols: f,
898
909
  compare: c,
899
- planOf: ($) => I(h.values[$]),
910
+ planOf: ($) => I(m.values[$]),
900
911
  actualFor: Re,
901
912
  isClosed: J,
902
- row: h,
903
- canReconcile: z,
904
- onReconcile: Je,
905
- carryFor: Ve,
913
+ row: m,
914
+ canReconcile: M,
915
+ onReconcile: Ge,
916
+ carryFor: Je,
906
917
  indent: !0
907
918
  }
908
919
  )
909
- ] }, h.uid)),
910
- e.mode === "split" && l && c && u && /* @__PURE__ */ t(
911
- nt,
920
+ ] }, m.uid)),
921
+ e.mode === "split" && l && c && p && /* @__PURE__ */ t(
922
+ rt,
912
923
  {
913
- label: `${Se(Ie)} · ${Ne.toLowerCase()}`,
914
- tip: `${Ne} the source could not place in a category — it counts in the ${e.key} total only.`,
924
+ label: `${we(De)} · ${$e.toLowerCase()}`,
925
+ tip: `${$e} the source could not place in a category — it counts in the ${e.key} total only.`,
915
926
  blockKey: e.key,
916
- cat: Ie,
917
- cols: m,
927
+ cat: De,
928
+ cols: f,
918
929
  compare: c,
919
930
  planOf: () => 0,
920
931
  actualFor: Re,
921
932
  isClosed: J,
922
933
  row: null,
923
934
  canReconcile: !1,
924
- onReconcile: Je,
925
- carryFor: Ve,
935
+ onReconcile: Ge,
936
+ carryFor: Je,
926
937
  indent: !0,
927
938
  plain: !0
928
939
  }
@@ -932,49 +943,49 @@ function Ya(v) {
932
943
  e.key
933
944
  );
934
945
  }),
935
- re.length > 1 && /* @__PURE__ */ d("tfoot", { children: [
946
+ se.length > 1 && /* @__PURE__ */ d("tfoot", { children: [
936
947
  /* @__PURE__ */ d("tr", { className: "[&>td]:border-t [&>td]:border-slate-300 dark:[&>td]:border-border", children: [
937
- /* @__PURE__ */ t("td", { className: B(be, "px-2 py-1.5"), children: /* @__PURE__ */ d("div", { className: "flex items-center pl-[22px]", children: [
948
+ /* @__PURE__ */ t("td", { className: D(ve, "px-2 py-1.5"), children: /* @__PURE__ */ d("div", { className: "flex items-center pl-[22px]", children: [
938
949
  /* @__PURE__ */ t("span", { className: "text-[12px] font-semibold text-slate-900 dark:text-slate-100", children: "All" }),
939
- /* @__PURE__ */ t("span", { className: "ml-auto text-[10.5px] font-medium text-slate-500 dark:text-slate-400", children: Ae })
950
+ /* @__PURE__ */ t("span", { className: "ml-auto text-[10.5px] font-medium text-slate-500 dark:text-slate-400", children: Ie })
940
951
  ] }) }),
941
- m.map((e) => /* @__PURE__ */ t(
952
+ f.map((e) => /* @__PURE__ */ t(
942
953
  "td",
943
954
  {
944
955
  className: "px-2.5 py-1.5 text-right font-semibold text-slate-900 dark:text-slate-100",
945
- children: /* @__PURE__ */ t(ne, { n: tt.planBy[e] })
956
+ children: /* @__PURE__ */ t(ne, { n: at.planBy[e] })
946
957
  },
947
958
  e
948
959
  )),
949
960
  /* @__PURE__ */ t(
950
961
  "td",
951
962
  {
952
- className: B(
953
- ke,
963
+ className: D(
964
+ Ne,
954
965
  "px-3 py-1.5 text-right font-semibold text-slate-900 dark:text-slate-100"
955
966
  ),
956
- children: /* @__PURE__ */ t(ne, { n: He })
967
+ children: /* @__PURE__ */ t(ne, { n: We })
957
968
  }
958
969
  )
959
970
  ] }),
960
971
  c && /* @__PURE__ */ d("tr", { children: [
961
- /* @__PURE__ */ t("td", { className: B(be, "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: Ne }) }),
962
- m.map((e) => /* @__PURE__ */ t(
972
+ /* @__PURE__ */ t("td", { className: D(ve, "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: $e }) }),
973
+ f.map((e) => /* @__PURE__ */ t(
963
974
  "td",
964
975
  {
965
976
  className: "px-2.5 pb-1.5 pt-0 text-right text-[11.5px] text-slate-600 dark:text-slate-300",
966
- children: /* @__PURE__ */ t(ne, { n: tt.actualBy[e], muted: !0 })
977
+ children: /* @__PURE__ */ t(ne, { n: at.actualBy[e], muted: !0 })
967
978
  },
968
979
  e
969
980
  )),
970
981
  /* @__PURE__ */ t(
971
982
  "td",
972
983
  {
973
- className: B(
974
- ke,
984
+ className: D(
985
+ Ne,
975
986
  "px-3 pb-1.5 pt-0 text-right text-[11.5px] text-slate-600 dark:text-slate-300"
976
987
  ),
977
- children: /* @__PURE__ */ t(ne, { n: T(m.reduce((e, a) => e + tt.actualBy[a], 0)), muted: !0 })
988
+ children: /* @__PURE__ */ t(ne, { n: E(f.reduce((e, a) => e + at.actualBy[a], 0)), muted: !0 })
978
989
  }
979
990
  )
980
991
  ] })
@@ -984,49 +995,49 @@ function Ya(v) {
984
995
  )
985
996
  }
986
997
  ),
987
- ft && /* @__PURE__ */ t(
998
+ gt && /* @__PURE__ */ t(
988
999
  "p",
989
1000
  {
990
1001
  role: "alert",
991
1002
  "data-plan-grid-notice": !0,
992
1003
  className: "mt-1.5 text-[12px] font-medium text-red-700 dark:text-red-300",
993
- children: ft
1004
+ children: gt
994
1005
  }
995
1006
  ),
996
- z && /* @__PURE__ */ d("div", { className: "mt-2 flex items-center gap-2", children: [
1007
+ M && /* @__PURE__ */ d("div", { className: "mt-2 flex items-center gap-2", children: [
997
1008
  /* @__PURE__ */ t(
998
- Ea,
1009
+ qa,
999
1010
  {
1000
- config: o,
1001
- client: S,
1002
- used: Vt,
1011
+ config: i,
1012
+ client: b,
1013
+ used: Gt,
1003
1014
  onAdd: (e) => Me(e),
1004
- label: `Add ${lt(o.key_field).toLowerCase()}`
1015
+ label: `Add ${nt(i.key_field).toLowerCase()}`
1005
1016
  }
1006
1017
  ),
1007
- (c == null ? void 0 : c.closed_locked) && !y && Ke && /* @__PURE__ */ t("span", { className: "text-[11.5px] text-slate-500 dark:text-slate-400", children: `Periods through ${Ke} are closed — open a highlighted ${Ne.toLowerCase()} figure to reconcile one.` })
1018
+ (c == null ? void 0 : c.closed_locked) && !T && Be && /* @__PURE__ */ t("span", { className: "text-[11.5px] text-slate-500 dark:text-slate-400", children: `Periods through ${Be} are closed — open a highlighted ${$e.toLowerCase()} figure to reconcile one.` })
1008
1019
  ] }),
1009
- Xe,
1010
- Q && Xe == null && /* @__PURE__ */ t(
1011
- $a,
1020
+ et,
1021
+ Q && et == null && /* @__PURE__ */ t(
1022
+ Sa,
1012
1023
  {
1013
1024
  open: !0,
1014
1025
  onOpenChange: (e) => {
1015
- e || Ye(null);
1026
+ e || Xe(null);
1016
1027
  },
1017
- rowTitle: `${Q.key}${Q.cat ? ` · ${Se(Q.cat)}` : ""}`,
1018
- revisions: Ut,
1019
- loading: Ht,
1020
- fields: Nt,
1021
- displayCols: Nt.filter(
1022
- (e) => m.includes(e.field) || e.field === o.category_field
1028
+ rowTitle: `${Q.key}${Q.cat ? ` · ${we(Q.cat)}` : ""}`,
1029
+ revisions: Wt,
1030
+ loading: Qt,
1031
+ fields: $t,
1032
+ displayCols: $t.filter(
1033
+ (e) => f.includes(e.field) || e.field === i.category_field
1023
1034
  ),
1024
- parentField: p,
1035
+ parentField: g,
1025
1036
  m2oRelMap: /* @__PURE__ */ new Map(),
1026
1037
  relations: [],
1027
1038
  collection: n,
1028
1039
  m2oDisplays: {},
1029
- client: S,
1040
+ client: b,
1030
1041
  allowRestore: !1,
1031
1042
  onRestore: () => {
1032
1043
  }
@@ -1034,84 +1045,96 @@ function Ya(v) {
1034
1045
  )
1035
1046
  ] });
1036
1047
  }
1037
- function lt(v) {
1038
- return v.replace(/_/g, " ").replace(/^\w/, (n) => n.toUpperCase());
1048
+ function nt(k) {
1049
+ return k.replace(/_/g, " ").replace(/^\w/, (n) => n.toUpperCase());
1039
1050
  }
1040
- function Oa(v) {
1041
- return /* @__PURE__ */ t(Xt, { children: v.children });
1051
+ function Ra(k) {
1052
+ return /* @__PURE__ */ t(ta, { children: k.children });
1042
1053
  }
1043
- function ne(v) {
1044
- return Math.abs(v.n) < 5e-3 ? /* @__PURE__ */ t("span", { className: "text-slate-400 dark:text-slate-500", children: "—" }) : /* @__PURE__ */ t("span", { children: D(v.n) });
1054
+ function ne(k) {
1055
+ return Math.abs(k.n) < 5e-3 ? /* @__PURE__ */ t("span", { className: "text-slate-400 dark:text-slate-500", children: "—" }) : /* @__PURE__ */ t("span", { children: z(k.n) });
1045
1056
  }
1046
- function Tt(v) {
1047
- const { row: n, col: p, closed: g, locked: o, lockedTip: C, prov: R, cellKey: K, onCommit: F, onMove: L, onPaste: f } = v, k = I(n.values[p]), S = R ? `${Ee(p)} · changed ${pa(R.at)} by ${R.who}${R.reason ? `
1048
- Reason: “${R.reason}”` : ""}` : void 0, b = R != null && R.reason ? /* @__PURE__ */ t(
1057
+ function Pt(k) {
1058
+ const {
1059
+ row: n,
1060
+ rowLabel: g,
1061
+ col: h,
1062
+ closed: i,
1063
+ locked: N,
1064
+ lockedTip: B,
1065
+ prov: R,
1066
+ cellKey: j,
1067
+ onCommit: L,
1068
+ onMove: u,
1069
+ onPaste: v
1070
+ } = k, b = I(n.values[h]), y = R ? `${Ee(h)} · changed ${ha(R.at)} by ${R.who}${R.reason ? `
1071
+ Reason: “${R.reason}”` : ""}` : void 0, x = R != null && R.reason ? /* @__PURE__ */ t(
1049
1072
  "span",
1050
1073
  {
1051
1074
  "aria-hidden": "true",
1052
1075
  "data-cell-reason": !0,
1053
1076
  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"
1054
1077
  }
1055
- ) : null, [x, j] = H(null), E = $e(!1);
1056
- if (o)
1078
+ ) : null, [A, F] = H(null), C = ke(!1);
1079
+ if (N)
1057
1080
  return /* @__PURE__ */ d(
1058
1081
  "td",
1059
1082
  {
1060
- "data-plan-locked": g ? "closed" : "readonly",
1061
- "data-tip": [C, S].filter(Boolean).join(`
1083
+ "data-plan-locked": i ? "closed" : "readonly",
1084
+ "data-tip": [B, y].filter(Boolean).join(`
1062
1085
  `) || void 0,
1063
- "data-grid-cell": K,
1064
- className: B(
1086
+ "data-grid-cell": j,
1087
+ className: D(
1065
1088
  "relative px-2.5 py-1 text-right text-slate-700 dark:text-slate-200",
1066
- g && Ce
1089
+ i && Se
1067
1090
  ),
1068
1091
  children: [
1069
- b,
1070
- /* @__PURE__ */ t(ne, { n: k })
1092
+ x,
1093
+ /* @__PURE__ */ t(ne, { n: b })
1071
1094
  ]
1072
1095
  }
1073
1096
  );
1074
- const N = () => {
1075
- if (x == null) return;
1076
- const y = qt(x);
1077
- if (j(null), E.current) {
1078
- E.current = !1;
1097
+ const T = () => {
1098
+ if (A == null) return;
1099
+ const s = At(A);
1100
+ if (F(null), C.current) {
1101
+ C.current = !1;
1079
1102
  return;
1080
1103
  }
1081
- if (y == null || y < 0) {
1082
- de.error("Enter an amount of zero or more");
1104
+ if (s == null || s < 0) {
1105
+ ue.error("Enter an amount of zero or more");
1083
1106
  return;
1084
1107
  }
1085
- Math.abs(y - k) < 5e-3 || F(y);
1108
+ Math.abs(s - b) < 5e-3 || L(s);
1086
1109
  };
1087
1110
  return /* @__PURE__ */ d(
1088
1111
  "td",
1089
1112
  {
1090
- className: B("relative p-0", g && Ce),
1091
- "data-grid-cell": K,
1092
- "data-tip": S,
1113
+ className: D("relative p-0", i && Se),
1114
+ "data-grid-cell": j,
1115
+ "data-tip": y,
1093
1116
  children: [
1094
- b,
1117
+ x,
1095
1118
  /* @__PURE__ */ t(
1096
1119
  "input",
1097
1120
  {
1098
- "data-pg-cell": `${n.uid}:${p}`,
1099
- "aria-label": `${Ee(p)} ${n.key}`,
1121
+ "data-pg-cell": `${n.uid}:${h}`,
1122
+ "aria-label": `${Ee(h)} ${n.key}${g ? ` · ${g}` : ""}`,
1100
1123
  inputMode: "decimal",
1101
- value: x ?? (k === 0 ? "" : D(k)),
1124
+ value: A ?? (b === 0 ? "" : z(b)),
1102
1125
  placeholder: "—",
1103
- onFocus: (y) => {
1104
- j(k === 0 ? "" : String(k)), requestAnimationFrame(() => y.target.select());
1126
+ onFocus: (s) => {
1127
+ F(b === 0 ? "" : String(b)), requestAnimationFrame(() => s.target.select());
1105
1128
  },
1106
- onChange: (y) => j(y.target.value),
1107
- onBlur: N,
1108
- onPaste: (y) => {
1109
- const i = y.clipboardData.getData("text");
1110
- /[\t\n]/.test(i.trim()) && (y.preventDefault(), E.current = !0, y.target.blur(), f(n, p, i));
1129
+ onChange: (s) => F(s.target.value),
1130
+ onBlur: T,
1131
+ onPaste: (s) => {
1132
+ const M = s.clipboardData.getData("text");
1133
+ /[\t\n]/.test(M.trim()) && (s.preventDefault(), C.current = !0, s.target.blur(), v(n, h, M));
1111
1134
  },
1112
- onKeyDown: (y) => {
1113
- const i = y.currentTarget, z = i.selectionStart === 0 && i.selectionEnd === 0, m = i.selectionStart === i.value.length && i.selectionEnd === i.value.length;
1114
- y.key === "Enter" || y.key === "ArrowDown" ? (y.preventDefault(), N(), L(n.uid, p, 1, 0)) : y.key === "ArrowUp" ? (y.preventDefault(), N(), L(n.uid, p, -1, 0)) : y.key === "ArrowLeft" && z ? (y.preventDefault(), N(), L(n.uid, p, 0, -1)) : y.key === "ArrowRight" && m ? (y.preventDefault(), N(), L(n.uid, p, 0, 1)) : y.key === "Escape" && (E.current = !0, i.blur());
1135
+ onKeyDown: (s) => {
1136
+ const M = s.currentTarget, f = M.selectionStart === 0 && M.selectionEnd === 0, O = M.selectionStart === M.value.length && M.selectionEnd === M.value.length;
1137
+ s.key === "Enter" || s.key === "ArrowDown" ? (s.preventDefault(), T(), u(n.uid, h, 1, 0)) : s.key === "ArrowUp" ? (s.preventDefault(), T(), u(n.uid, h, -1, 0)) : s.key === "ArrowLeft" && f ? (s.preventDefault(), T(), u(n.uid, h, 0, -1)) : s.key === "ArrowRight" && O ? (s.preventDefault(), T(), u(n.uid, h, 0, 1)) : s.key === "Escape" && (C.current = !0, M.blur());
1115
1138
  },
1116
1139
  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))]"
1117
1140
  }
@@ -1120,180 +1143,180 @@ Reason: “${R.reason}”` : ""}` : void 0, b = R != null && R.reason ? /* @__PU
1120
1143
  }
1121
1144
  );
1122
1145
  }
1123
- function nt(v) {
1146
+ function rt(k) {
1124
1147
  const {
1125
1148
  label: n,
1126
- tip: p,
1127
- blockKey: g,
1128
- cat: o,
1129
- cols: C,
1130
- compare: R,
1131
- planOf: K,
1132
- actualFor: F,
1149
+ tip: g,
1150
+ blockKey: h,
1151
+ cat: i,
1152
+ cols: N,
1153
+ compare: B,
1154
+ planOf: R,
1155
+ actualFor: j,
1133
1156
  isClosed: L,
1134
- row: f,
1135
- canReconcile: k,
1136
- onReconcile: S,
1137
- carryFor: b,
1157
+ row: u,
1158
+ canReconcile: v,
1159
+ onReconcile: b,
1160
+ carryFor: y,
1138
1161
  plain: x
1139
- } = v, j = T(C.reduce((E, N) => E + F(g, o, N).value, 0));
1140
- return /* @__PURE__ */ d("tr", { "data-plan-actual": o ?? "all", children: [
1141
- /* @__PURE__ */ t("td", { className: B(be, "px-2 pb-1 pt-0"), children: /* @__PURE__ */ t(
1162
+ } = k, A = E(N.reduce((F, C) => F + j(h, i, C).value, 0));
1163
+ return /* @__PURE__ */ d("tr", { "data-plan-actual": i ?? "all", children: [
1164
+ /* @__PURE__ */ t("td", { className: D(ve, "px-2 pb-1 pt-0"), children: /* @__PURE__ */ t(
1142
1165
  "span",
1143
1166
  {
1144
- "data-tip": p,
1167
+ "data-tip": g,
1145
1168
  className: "block text-right text-[10.5px] font-medium text-slate-500 dark:text-slate-400",
1146
1169
  children: n
1147
1170
  }
1148
1171
  ) }),
1149
- C.map((E) => {
1150
- const N = L(g, E), y = F(g, o, E), i = K(E), z = !x && N && Math.abs(y.value - i) >= 5e-3, m = !x && !N && y.value > i + 5e-3;
1172
+ N.map((F) => {
1173
+ const C = L(h, F), T = j(h, i, F), s = R(F), M = !x && C && Math.abs(T.value - s) >= 5e-3, f = !x && !C && T.value > s + 5e-3;
1151
1174
  return /* @__PURE__ */ t(
1152
1175
  "td",
1153
1176
  {
1154
- "data-compare-cell": E,
1155
- className: B("px-2.5 pb-1 pt-0 text-right text-[11.5px]", N && Ce),
1156
- children: Math.abs(y.value) < 5e-3 && !z ? /* @__PURE__ */ t("span", { className: "text-slate-400 dark:text-slate-500", children: "—" }) : /* @__PURE__ */ t(
1157
- La,
1177
+ "data-compare-cell": F,
1178
+ className: D("px-2.5 pb-1 pt-0 text-right text-[11.5px]", C && Se),
1179
+ children: Math.abs(T.value) < 5e-3 && !M ? /* @__PURE__ */ t("span", { className: "text-slate-400 dark:text-slate-500", children: "—" }) : /* @__PURE__ */ t(
1180
+ Ma,
1158
1181
  {
1159
- title: `${Ee(E)} ${g}`,
1160
- compare: R,
1182
+ title: `${Ee(F)} ${h}`,
1183
+ compare: B,
1161
1184
  actualName: n,
1162
- actual: y.value,
1163
- planned: i,
1164
- closed: N,
1185
+ actual: T.value,
1186
+ planned: s,
1187
+ closed: C,
1165
1188
  plain: !!x,
1166
- details: y.details,
1167
- tone: z ? "warn" : m ? "danger" : "neutral",
1168
- reconcile: z && k && f ? {
1169
- row: f,
1170
- column: E,
1171
- openColumns: C.filter((M) => !L(g, M)),
1172
- carry: (b == null ? void 0 : b(g, o)) ?? null,
1173
- onApply: (M, P, se) => S(f, M, P, se)
1189
+ details: T.details,
1190
+ tone: M ? "warn" : f ? "danger" : "neutral",
1191
+ reconcile: M && v && u ? {
1192
+ row: u,
1193
+ column: F,
1194
+ openColumns: N.filter((O) => !L(h, O)),
1195
+ carry: (y == null ? void 0 : y(h, i)) ?? null,
1196
+ onApply: (O, P, oe) => b(u, O, P, oe)
1174
1197
  } : null
1175
1198
  }
1176
1199
  )
1177
1200
  },
1178
- E
1201
+ F
1179
1202
  );
1180
1203
  }),
1181
1204
  /* @__PURE__ */ t(
1182
1205
  "td",
1183
1206
  {
1184
- className: B(
1185
- ke,
1207
+ className: D(
1208
+ Ne,
1186
1209
  "px-3 pb-1 pt-0 text-right text-[11.5px] text-slate-600 dark:text-slate-300"
1187
1210
  ),
1188
- children: /* @__PURE__ */ t(ne, { n: j, muted: !0 })
1211
+ children: /* @__PURE__ */ t(ne, { n: A, muted: !0 })
1189
1212
  }
1190
1213
  )
1191
1214
  ] });
1192
1215
  }
1193
- const Et = {
1216
+ const qt = {
1194
1217
  warn: "text-amber-700 dark:text-amber-300 font-medium",
1195
1218
  danger: "text-red-700 dark:text-red-300 font-medium",
1196
1219
  neutral: "text-slate-600 dark:text-slate-300"
1197
1220
  };
1198
- function La(v) {
1199
- var V, oe;
1200
- const { title: n, compare: p, actualName: g, actual: o, planned: C, closed: R, plain: K, details: F, tone: L, reconcile: f } = v, [k, S] = H(!1), [b, x] = H("next"), [j, E] = H(""), N = Pt(p), y = T(C - o), i = f && f.openColumns.length === 0 && f.carry && !f.carry.blocked ? f.carry : null, z = f && f.openColumns.length === 0 ? ((V = f.carry) == null ? void 0 : V.blocked) ?? null : null, m = i ? ((oe = i.row) == null ? void 0 : oe.values) ?? {} : (f == null ? void 0 : f.row.values) ?? {}, M = i ? i.openColumns : (f == null ? void 0 : f.openColumns) ?? [], P = G(
1221
+ function Ma(k) {
1222
+ var V, ie;
1223
+ const { title: n, compare: g, actualName: h, actual: i, planned: N, closed: B, plain: R, details: j, tone: L, reconcile: u } = k, [v, b] = H(!1), [y, x] = H("next"), [A, F] = H(""), C = jt(g), T = E(N - i), s = u && u.openColumns.length === 0 && u.carry && !u.carry.blocked ? u.carry : null, M = u && u.openColumns.length === 0 ? ((V = u.carry) == null ? void 0 : V.blocked) ?? null : null, f = s ? ((ie = s.row) == null ? void 0 : ie.values) ?? {} : (u == null ? void 0 : u.row.values) ?? {}, O = s ? s.openColumns : (u == null ? void 0 : u.openColumns) ?? [], P = G(
1201
1224
  () => {
1202
1225
  var w;
1203
- return f ? _a({
1204
- row: f.row.values,
1205
- column: f.column,
1206
- actual: o,
1207
- openColumns: i ? i.openColumns : f.openColumns,
1208
- mode: b,
1209
- ...i ? { targetRow: ((w = i.row) == null ? void 0 : w.values) ?? {} } : {}
1226
+ return u ? La({
1227
+ row: u.row.values,
1228
+ column: u.column,
1229
+ actual: i,
1230
+ openColumns: s ? s.openColumns : u.openColumns,
1231
+ mode: y,
1232
+ ...s ? { targetRow: ((w = s.row) == null ? void 0 : w.values) ?? {} } : {}
1210
1233
  }) : null;
1211
1234
  },
1212
- [f, i, o, b]
1213
- ), se = P ? P.targetPatch ?? P.patch : {}, ve = M.some((w) => I(m[w]) > 5e-3), q = G(() => {
1214
- const w = `Reconciled ${n} to ${g.toLowerCase()} (${D(o)})`;
1235
+ [u, s, i, y]
1236
+ ), oe = P ? P.targetPatch ?? P.patch : {}, re = O.some((w) => I(f[w]) > 5e-3), q = G(() => {
1237
+ const w = `Reconciled ${n} to ${h.toLowerCase()} (${z(i)})`;
1215
1238
  if (!P || Math.abs(P.moved) < 5e-3) return w;
1216
- const me = `${P.targets.length === 1 ? Ee(P.targets[0]) : `${P.targets.length} open periods`}${i ? ` ${i.key}` : ""}`;
1217
- return P.moved > 0 ? `${w} — moved ${D(P.moved)} to ${me}` : `${w} — took ${D(-P.moved)} from ${me}`;
1218
- }, [n, g, o, P, i]);
1219
- pe(() => {
1220
- k && E(q);
1221
- }, [k, q]);
1222
- const le = f ? [
1239
+ const he = `${P.targets.length === 1 ? Ee(P.targets[0]) : `${P.targets.length} open periods`}${s ? ` ${s.key}` : ""}`;
1240
+ return P.moved > 0 ? `${w} — moved ${z(P.moved)} to ${he}` : `${w} — took ${z(-P.moved)} from ${he}`;
1241
+ }, [n, h, i, P, s]);
1242
+ ce(() => {
1243
+ v && F(q);
1244
+ }, [v, q]);
1245
+ const le = u ? [
1223
1246
  {
1224
1247
  key: "next",
1225
- label: M[0] ? `Next open period (${st(M[0])}${i ? ` ${i.key}` : ""})` : "Next open period",
1226
- disabled: M.length === 0
1248
+ label: O[0] ? `Next open period (${ot(O[0])}${s ? ` ${s.key}` : ""})` : "Next open period",
1249
+ disabled: O.length === 0
1227
1250
  },
1228
1251
  {
1229
1252
  key: "even",
1230
- label: i ? `Evenly over ${i.key}'s open periods` : "Evenly over every open period",
1231
- disabled: M.length === 0
1253
+ label: s ? `Evenly over ${s.key}'s open periods` : "Evenly over every open period",
1254
+ disabled: O.length === 0
1232
1255
  },
1233
1256
  {
1234
1257
  key: "weighted",
1235
- label: i ? `In proportion to the ${N.toLowerCase()} already in ${i.key}` : `In proportion to the ${N.toLowerCase()} already there`,
1236
- disabled: !ve
1258
+ label: s ? `In proportion to the ${C.toLowerCase()} already in ${s.key}` : `In proportion to the ${C.toLowerCase()} already there`,
1259
+ disabled: !re
1237
1260
  },
1238
1261
  { key: "none", label: "Nowhere — drop it from the plan" }
1239
1262
  ] : [];
1240
- return /* @__PURE__ */ d(it, { open: k, onOpenChange: S, children: [
1241
- /* @__PURE__ */ t(dt, { asChild: !0, children: /* @__PURE__ */ t(
1263
+ return /* @__PURE__ */ d(dt, { open: v, onOpenChange: b, children: [
1264
+ /* @__PURE__ */ t(ct, { asChild: !0, children: /* @__PURE__ */ t(
1242
1265
  "button",
1243
1266
  {
1244
1267
  type: "button",
1245
1268
  "data-compare-details": !0,
1246
1269
  "data-tip": "",
1247
1270
  "data-plan-off": L === "warn" ? "true" : void 0,
1248
- className: B(
1271
+ className: D(
1249
1272
  "rounded px-0.5 underline-offset-2 hover:underline focus-visible:underline",
1250
- Et[L]
1273
+ qt[L]
1251
1274
  ),
1252
- children: D(o)
1275
+ children: z(i)
1253
1276
  }
1254
1277
  ) }),
1255
- /* @__PURE__ */ d(ct, { align: "end", sideOffset: 6, className: "w-[360px] p-0 text-[12px]", children: [
1278
+ /* @__PURE__ */ d(ut, { align: "end", sideOffset: 6, className: "w-[360px] p-0 text-[12px]", children: [
1256
1279
  /* @__PURE__ */ d("div", { className: "border-b border-slate-200 px-3 py-2 dark:border-border", children: [
1257
1280
  /* @__PURE__ */ t("p", { className: "text-[12.5px] font-semibold text-slate-900 dark:text-slate-100", children: n }),
1258
1281
  /* @__PURE__ */ d("dl", { className: "mt-1 grid grid-cols-3 gap-2 tabular-nums", children: [
1259
- !K && /* @__PURE__ */ d("div", { children: [
1260
- /* @__PURE__ */ t("dt", { className: "text-[10.5px] text-slate-500 dark:text-slate-400", children: N }),
1261
- /* @__PURE__ */ t("dd", { className: "font-medium text-slate-800 dark:text-slate-100", children: D(C) })
1282
+ !R && /* @__PURE__ */ d("div", { children: [
1283
+ /* @__PURE__ */ t("dt", { className: "text-[10.5px] text-slate-500 dark:text-slate-400", children: C }),
1284
+ /* @__PURE__ */ t("dd", { className: "font-medium text-slate-800 dark:text-slate-100", children: z(N) })
1262
1285
  ] }),
1263
1286
  /* @__PURE__ */ d("div", { children: [
1264
- /* @__PURE__ */ t("dt", { className: "text-[10.5px] text-slate-500 dark:text-slate-400", children: g }),
1265
- /* @__PURE__ */ t("dd", { className: "font-medium text-slate-800 dark:text-slate-100", children: D(o) })
1287
+ /* @__PURE__ */ t("dt", { className: "text-[10.5px] text-slate-500 dark:text-slate-400", children: h }),
1288
+ /* @__PURE__ */ t("dd", { className: "font-medium text-slate-800 dark:text-slate-100", children: z(i) })
1266
1289
  ] }),
1267
- !K && /* @__PURE__ */ d("div", { children: [
1268
- /* @__PURE__ */ t("dt", { className: "text-[10.5px] text-slate-500 dark:text-slate-400", children: R ? "Difference" : "Still to come" }),
1290
+ !R && /* @__PURE__ */ d("div", { children: [
1291
+ /* @__PURE__ */ t("dt", { className: "text-[10.5px] text-slate-500 dark:text-slate-400", children: B ? "Difference" : "Still to come" }),
1269
1292
  /* @__PURE__ */ t(
1270
1293
  "dd",
1271
1294
  {
1272
- className: B(
1295
+ className: D(
1273
1296
  "font-medium",
1274
- Math.abs(y) < 5e-3 ? "text-slate-800 dark:text-slate-100" : Et[L === "neutral" ? "neutral" : L]
1297
+ Math.abs(T) < 5e-3 ? "text-slate-800 dark:text-slate-100" : qt[L === "neutral" ? "neutral" : L]
1275
1298
  ),
1276
- children: D(y)
1299
+ children: z(T)
1277
1300
  }
1278
1301
  )
1279
1302
  ] })
1280
1303
  ] })
1281
1304
  ] }),
1282
- F.length > 0 && /* @__PURE__ */ t("ul", { className: "max-h-[168px] overflow-y-auto px-3 py-1.5", children: F.map((w) => /* @__PURE__ */ d("li", { className: "flex items-baseline gap-2 py-0.5", children: [
1305
+ j.length > 0 && /* @__PURE__ */ t("ul", { className: "max-h-[168px] overflow-y-auto px-3 py-1.5", children: j.map((w) => /* @__PURE__ */ d("li", { className: "flex items-baseline gap-2 py-0.5", children: [
1283
1306
  /* @__PURE__ */ d("span", { className: "min-w-0 flex-1 truncate text-slate-700 dark:text-slate-200", children: [
1284
1307
  w.label,
1285
1308
  w.sub ? /* @__PURE__ */ t("span", { className: "text-slate-500 dark:text-slate-400", children: ` · ${w.sub}` }) : null
1286
1309
  ] }),
1287
- /* @__PURE__ */ t("span", { className: "tabular-nums text-slate-800 dark:text-slate-100", children: D(w.amount) })
1310
+ /* @__PURE__ */ t("span", { className: "tabular-nums text-slate-800 dark:text-slate-100", children: z(w.amount) })
1288
1311
  ] }, String(w.id))) }),
1289
- F.length === 0 && /* @__PURE__ */ t("p", { className: "px-3 py-2 text-slate-500 dark:text-slate-400", children: `No ${ka(p, 2)} behind this figure.` }),
1290
- f && P && /* @__PURE__ */ d(
1312
+ j.length === 0 && /* @__PURE__ */ t("p", { className: "px-3 py-2 text-slate-500 dark:text-slate-400", children: `No ${Na(g, 2)} behind this figure.` }),
1313
+ u && P && /* @__PURE__ */ d(
1291
1314
  "div",
1292
1315
  {
1293
1316
  className: "border-t border-slate-200 px-3 py-2 dark:border-border",
1294
1317
  "data-plan-reconcile": !0,
1295
1318
  children: [
1296
- /* @__PURE__ */ t("p", { className: "font-medium text-slate-900 dark:text-slate-100", children: `Set the ${N.toLowerCase()} to ${D(o)} and put the ${D(Math.abs(y))} ${y > 0 ? "left over" : "shortfall"}…` }),
1319
+ /* @__PURE__ */ t("p", { className: "font-medium text-slate-900 dark:text-slate-100", children: `Set the ${C.toLowerCase()} to ${z(i)} and put the ${z(Math.abs(T))} ${T > 0 ? "left over" : "shortfall"}…` }),
1297
1320
  /* @__PURE__ */ t(
1298
1321
  "div",
1299
1322
  {
@@ -1303,7 +1326,7 @@ function La(v) {
1303
1326
  children: le.map((w) => /* @__PURE__ */ d(
1304
1327
  "label",
1305
1328
  {
1306
- className: B(
1329
+ className: D(
1307
1330
  "flex cursor-pointer items-center gap-2",
1308
1331
  w.disabled && "cursor-not-allowed opacity-50"
1309
1332
  ),
@@ -1315,7 +1338,7 @@ function La(v) {
1315
1338
  name: "pg-reconcile",
1316
1339
  "data-plan-reconcile-mode": w.key,
1317
1340
  disabled: w.disabled,
1318
- checked: b === w.key,
1341
+ checked: y === w.key,
1319
1342
  onChange: () => x(w.key),
1320
1343
  className: "accent-[rgb(var(--nvr-cyan-rgb))]"
1321
1344
  }
@@ -1327,20 +1350,20 @@ function La(v) {
1327
1350
  ))
1328
1351
  }
1329
1352
  ),
1330
- i && b !== "none" && /* @__PURE__ */ t(
1353
+ s && y !== "none" && /* @__PURE__ */ t(
1331
1354
  "p",
1332
1355
  {
1333
1356
  className: "mt-1.5 text-[11.5px] text-slate-600 dark:text-slate-300",
1334
- "data-plan-reconcile-carry": i.key,
1335
- children: i.row ? `Every period of this row is closed, so it goes to ${i.key}.` : `Every period of this row is closed and ${i.key} has no row for this line — one is added, and shows as pending until you save.`
1357
+ "data-plan-reconcile-carry": s.key,
1358
+ children: s.row ? `Every period of this row is closed, so it goes to ${s.key}.` : `Every period of this row is closed and ${s.key} has no row for this line — one is added, and shows as pending until you save.`
1336
1359
  }
1337
1360
  ),
1338
- z && /* @__PURE__ */ t(
1361
+ M && /* @__PURE__ */ t(
1339
1362
  "p",
1340
1363
  {
1341
1364
  className: "mt-1.5 text-[11.5px] text-amber-700 dark:text-amber-300",
1342
1365
  "data-plan-reconcile-blocked": !0,
1343
- children: `Every period of this row is closed, and ${z} — the difference can only be dropped from here.`
1366
+ children: `Every period of this row is closed, and ${M} — the difference can only be dropped from here.`
1344
1367
  }
1345
1368
  ),
1346
1369
  P.targets.length > 0 && /* @__PURE__ */ d(
@@ -1350,18 +1373,18 @@ function La(v) {
1350
1373
  "data-plan-reconcile-preview": !0,
1351
1374
  children: [
1352
1375
  P.targets.slice(0, 6).map(
1353
- (w) => `${st(w)}${i ? ` ${i.key}` : ""} ${D(I(m[w]))} → ${D(se[w])}`
1376
+ (w) => `${ot(w)}${s ? ` ${s.key}` : ""} ${z(I(f[w]))} → ${z(oe[w])}`
1354
1377
  ).join(" · "),
1355
1378
  P.targets.length > 6 ? ` · +${P.targets.length - 6} more` : ""
1356
1379
  ]
1357
1380
  }
1358
1381
  ),
1359
- b !== "none" && Math.abs(P.unabsorbed) >= 5e-3 && /* @__PURE__ */ t("p", { className: "mt-1 text-[11.5px] text-amber-700 dark:text-amber-300", children: `${D(Math.abs(P.unabsorbed))} has nowhere to go — it leaves the ${N.toLowerCase()}.` }),
1382
+ y !== "none" && Math.abs(P.unabsorbed) >= 5e-3 && /* @__PURE__ */ t("p", { className: "mt-1 text-[11.5px] text-amber-700 dark:text-amber-300", children: `${z(Math.abs(P.unabsorbed))} has nowhere to go — it leaves the ${C.toLowerCase()}.` }),
1360
1383
  /* @__PURE__ */ t(
1361
1384
  "textarea",
1362
1385
  {
1363
- value: j,
1364
- onChange: (w) => E(w.target.value),
1386
+ value: A,
1387
+ onChange: (w) => F(w.target.value),
1365
1388
  rows: 2,
1366
1389
  "aria-label": "Reason",
1367
1390
  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"
@@ -1373,10 +1396,10 @@ function La(v) {
1373
1396
  type: "button",
1374
1397
  "data-plan-reconcile-apply": !0,
1375
1398
  onClick: () => {
1376
- const w = i && P.targetPatch && Object.keys(P.targetPatch).length > 0 ? { target: i, patch: P.targetPatch } : void 0;
1377
- f.onApply(P.patch, j.trim() || q, w) && (de.success(
1378
- w ? `Reconcile staged across ${n.split(" ").pop()} and ${i == null ? void 0 : i.key} — Save to keep it` : "Reconcile staged — Save to keep it"
1379
- ), S(!1));
1399
+ const w = s && P.targetPatch && Object.keys(P.targetPatch).length > 0 ? { target: s, patch: P.targetPatch } : void 0;
1400
+ u.onApply(P.patch, A.trim() || q, w) && (ue.success(
1401
+ w ? `Reconcile staged across ${n.split(" ").pop()} and ${s == null ? void 0 : s.key} — Save to keep it` : "Reconcile staged — Save to keep it"
1402
+ ), b(!1));
1380
1403
  },
1381
1404
  className: "rounded-md bg-nvr-cyan px-3 py-1 text-[12px] font-medium text-white",
1382
1405
  children: "Stage it"
@@ -1388,144 +1411,144 @@ function La(v) {
1388
1411
  ] })
1389
1412
  ] });
1390
1413
  }
1391
- function Ra(v) {
1414
+ function Ta(k) {
1392
1415
  const {
1393
1416
  block: n,
1394
- config: p,
1395
- canSplit: g,
1396
- splitUnavailable: o,
1397
- splitBase: C,
1398
- client: R,
1399
- cols: K,
1400
- catLabel: F,
1417
+ config: g,
1418
+ canSplit: h,
1419
+ splitUnavailable: i,
1420
+ splitBase: N,
1421
+ client: B,
1422
+ cols: R,
1423
+ catLabel: j,
1401
1424
  showHistory: L,
1402
- onHistory: f,
1403
- onSpread: k,
1404
- onRemove: S,
1405
- onDone: b,
1425
+ onHistory: u,
1426
+ onSpread: v,
1427
+ onRemove: b,
1428
+ onDone: y,
1406
1429
  rc: x
1407
- } = v, [j, E] = H(!1), [N, y] = H("menu");
1408
- pe(() => {
1409
- j && y("menu");
1410
- }, [j]);
1411
- const i = [...n.top ? [n.top] : [], ...n.cats], z = i.some((M) => M.edited || M.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";
1412
- return /* @__PURE__ */ d(it, { open: j, onOpenChange: E, children: [
1413
- /* @__PURE__ */ t(dt, { asChild: !0, children: /* @__PURE__ */ t(
1430
+ } = k, [A, F] = H(!1), [C, T] = H("menu");
1431
+ ce(() => {
1432
+ A && T("menu");
1433
+ }, [A]);
1434
+ const s = [...n.top ? [n.top] : [], ...n.cats], M = s.some((O) => O.edited || O.isNew), f = "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";
1435
+ return /* @__PURE__ */ d(dt, { open: A, onOpenChange: F, children: [
1436
+ /* @__PURE__ */ t(ct, { asChild: !0, children: /* @__PURE__ */ t(
1414
1437
  "button",
1415
1438
  {
1416
1439
  type: "button",
1417
1440
  "data-plan-menu": n.key,
1418
1441
  "aria-label": `Actions for ${n.key}`,
1419
1442
  className: "rounded p-0.5 text-slate-500 hover:bg-muted hover:text-slate-800 dark:hover:text-slate-100",
1420
- children: /* @__PURE__ */ t(aa, { className: "h-3.5 w-3.5" })
1443
+ children: /* @__PURE__ */ t(na, { className: "h-3.5 w-3.5" })
1421
1444
  }
1422
1445
  ) }),
1423
1446
  /* @__PURE__ */ d(
1424
- ct,
1447
+ ut,
1425
1448
  {
1426
1449
  align: "start",
1427
1450
  sideOffset: 6,
1428
- className: B("p-1.5", N === "split" ? "w-[440px]" : "w-[300px]"),
1451
+ className: D("p-1.5", C === "split" ? "w-[440px]" : "w-[300px]"),
1429
1452
  children: [
1430
- N === "menu" && /* @__PURE__ */ d("div", { children: [
1431
- n.mode === "top" && g && /* @__PURE__ */ d(
1453
+ C === "menu" && /* @__PURE__ */ d("div", { children: [
1454
+ n.mode === "top" && h && /* @__PURE__ */ d(
1432
1455
  "button",
1433
1456
  {
1434
1457
  type: "button",
1435
1458
  "data-plan-split": n.key,
1436
- disabled: z,
1437
- onClick: () => y("split"),
1438
- className: m,
1459
+ disabled: M,
1460
+ onClick: () => T("split"),
1461
+ className: f,
1439
1462
  children: [
1440
- /* @__PURE__ */ t(St, { className: "h-3.5 w-3.5" }),
1441
- p.split_label ?? "Plan by category"
1463
+ /* @__PURE__ */ t(Ot, { className: "h-3.5 w-3.5" }),
1464
+ g.split_label ?? "Plan by category"
1442
1465
  ]
1443
1466
  }
1444
1467
  ),
1445
- n.mode === "top" && !g && o && /* @__PURE__ */ d("div", { "data-plan-split-unavailable": !0, className: "px-2 py-1.5", children: [
1468
+ n.mode === "top" && !h && i && /* @__PURE__ */ d("div", { "data-plan-split-unavailable": !0, className: "px-2 py-1.5", children: [
1446
1469
  /* @__PURE__ */ d("p", { className: "flex items-center gap-2 text-[12.5px] text-slate-400 dark:text-slate-500", children: [
1447
- /* @__PURE__ */ t(St, { className: "h-3.5 w-3.5" }),
1448
- p.split_label ?? "Plan by category"
1470
+ /* @__PURE__ */ t(Ot, { className: "h-3.5 w-3.5" }),
1471
+ g.split_label ?? "Plan by category"
1449
1472
  ] }),
1450
- /* @__PURE__ */ t("p", { className: "mt-0.5 pl-[22px] text-[11px] text-slate-500 dark:text-slate-400", children: o })
1473
+ /* @__PURE__ */ t("p", { className: "mt-0.5 pl-[22px] text-[11px] text-slate-500 dark:text-slate-400", children: i })
1451
1474
  ] }),
1452
- n.mode === "split" && C && /* @__PURE__ */ d(
1475
+ n.mode === "split" && N && /* @__PURE__ */ d(
1453
1476
  "button",
1454
1477
  {
1455
1478
  type: "button",
1456
1479
  "data-plan-merge": n.key,
1457
- disabled: z,
1458
- onClick: () => y("merge"),
1459
- className: m,
1480
+ disabled: M,
1481
+ onClick: () => T("merge"),
1482
+ className: f,
1460
1483
  children: [
1461
- /* @__PURE__ */ t(la, { className: "h-3.5 w-3.5" }),
1462
- p.merge_label ?? "Merge back to one line"
1484
+ /* @__PURE__ */ t(ra, { className: "h-3.5 w-3.5" }),
1485
+ g.merge_label ?? "Merge back to one line"
1463
1486
  ]
1464
1487
  }
1465
1488
  ),
1466
- z && (n.mode === "split" || g) && /* @__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." }),
1467
- k && i.map((M) => /* @__PURE__ */ d(
1489
+ M && (n.mode === "split" || h) && /* @__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." }),
1490
+ v && s.map((O) => /* @__PURE__ */ d(
1468
1491
  "button",
1469
1492
  {
1470
1493
  type: "button",
1471
- "data-plan-spread": M.uid,
1494
+ "data-plan-spread": O.uid,
1472
1495
  onClick: () => {
1473
- k(M), E(!1);
1496
+ v(O), F(!1);
1474
1497
  },
1475
- className: m,
1498
+ className: f,
1476
1499
  children: [
1477
1500
  /* @__PURE__ */ t("span", { className: "w-3.5" }),
1478
- `Spread what is left${M.cat ? ` · ${F(M.cat)}` : ""}`
1501
+ `Spread what is left${O.cat ? ` · ${j(O.cat)}` : ""}`
1479
1502
  ]
1480
1503
  },
1481
- M.uid
1504
+ O.uid
1482
1505
  )),
1483
- L && i.filter((M) => M.id).map((M) => /* @__PURE__ */ d("div", { className: "flex items-center", children: [
1506
+ L && s.filter((O) => O.id).map((O) => /* @__PURE__ */ d("div", { className: "flex items-center", children: [
1484
1507
  /* @__PURE__ */ d(
1485
1508
  "button",
1486
1509
  {
1487
1510
  type: "button",
1488
1511
  onClick: () => {
1489
- f(M), E(!1);
1512
+ u(O), F(!1);
1490
1513
  },
1491
- className: m,
1514
+ className: f,
1492
1515
  children: [
1493
- /* @__PURE__ */ t(na, { className: "h-3.5 w-3.5" }),
1494
- `History${M.cat ? ` · ${F(M.cat)}` : ""}`
1516
+ /* @__PURE__ */ t(sa, { className: "h-3.5 w-3.5" }),
1517
+ `History${O.cat ? ` · ${j(O.cat)}` : ""}`
1495
1518
  ]
1496
1519
  }
1497
1520
  ),
1498
1521
  /* @__PURE__ */ t(
1499
- Ca,
1522
+ _a,
1500
1523
  {
1501
1524
  collection: x,
1502
- rowId: M.id,
1503
- rowLabel: `${n.key}${M.cat ? ` ${F(M.cat)}` : ""}`
1525
+ rowId: O.id,
1526
+ rowLabel: `${n.key}${O.cat ? ` ${j(O.cat)}` : ""}`
1504
1527
  }
1505
1528
  )
1506
- ] }, M.uid)),
1529
+ ] }, O.uid)),
1507
1530
  /* @__PURE__ */ d(
1508
1531
  "button",
1509
1532
  {
1510
1533
  type: "button",
1511
1534
  "data-plan-remove": n.key,
1512
- onClick: () => y("remove"),
1513
- className: B(m, "text-red-700 dark:text-red-300"),
1535
+ onClick: () => T("remove"),
1536
+ className: D(f, "text-red-700 dark:text-red-300"),
1514
1537
  children: [
1515
- /* @__PURE__ */ t(ra, { className: "h-3.5 w-3.5" }),
1538
+ /* @__PURE__ */ t(oa, { className: "h-3.5 w-3.5" }),
1516
1539
  `Remove ${n.key}`
1517
1540
  ]
1518
1541
  }
1519
1542
  )
1520
1543
  ] }),
1521
- N === "remove" && /* @__PURE__ */ d("div", { className: "p-1.5", children: [
1544
+ C === "remove" && /* @__PURE__ */ d("div", { className: "p-1.5", children: [
1522
1545
  /* @__PURE__ */ t("p", { className: "text-[12.5px] text-slate-700 dark:text-slate-200", children: `Remove the ${n.key} plan? It leaves with the next Save.` }),
1523
1546
  /* @__PURE__ */ d("div", { className: "mt-2 flex justify-end gap-2", children: [
1524
1547
  /* @__PURE__ */ t(
1525
1548
  "button",
1526
1549
  {
1527
1550
  type: "button",
1528
- onClick: () => y("menu"),
1551
+ onClick: () => T("menu"),
1529
1552
  className: "rounded-md px-2.5 py-1 text-[12px] text-slate-600 hover:bg-muted dark:text-slate-300",
1530
1553
  children: "Keep it"
1531
1554
  }
@@ -1536,7 +1559,7 @@ function Ra(v) {
1536
1559
  type: "button",
1537
1560
  "data-plan-remove-confirm": !0,
1538
1561
  onClick: () => {
1539
- S(), E(!1);
1562
+ b(), F(!1);
1540
1563
  },
1541
1564
  className: "rounded-md bg-red-600 px-2.5 py-1 text-[12px] font-medium text-white",
1542
1565
  children: "Remove"
@@ -1544,30 +1567,30 @@ function Ra(v) {
1544
1567
  )
1545
1568
  ] })
1546
1569
  ] }),
1547
- N === "split" && C && n.top && /* @__PURE__ */ t(
1548
- Ma,
1570
+ C === "split" && N && n.top && /* @__PURE__ */ t(
1571
+ Ea,
1549
1572
  {
1550
1573
  block: n,
1551
- config: p,
1552
- splitBase: C,
1553
- client: R,
1554
- cols: K,
1555
- onCancel: () => y("menu"),
1574
+ config: g,
1575
+ splitBase: N,
1576
+ client: B,
1577
+ cols: R,
1578
+ onCancel: () => T("menu"),
1556
1579
  onDone: () => {
1557
- E(!1), b();
1580
+ F(!1), y();
1558
1581
  }
1559
1582
  }
1560
1583
  ),
1561
- N === "merge" && C && /* @__PURE__ */ t(
1562
- Ta,
1584
+ C === "merge" && N && /* @__PURE__ */ t(
1585
+ Pa,
1563
1586
  {
1564
1587
  block: n,
1565
- config: p,
1566
- splitBase: C,
1567
- client: R,
1568
- onCancel: () => y("menu"),
1588
+ config: g,
1589
+ splitBase: N,
1590
+ client: B,
1591
+ onCancel: () => T("menu"),
1569
1592
  onDone: () => {
1570
- E(!1), b();
1593
+ F(!1), y();
1571
1594
  }
1572
1595
  }
1573
1596
  )
@@ -1576,68 +1599,68 @@ function Ra(v) {
1576
1599
  )
1577
1600
  ] });
1578
1601
  }
1579
- function ot(v) {
1580
- return ua(v, "Something went wrong");
1602
+ function it(k) {
1603
+ return ma(k, "Something went wrong");
1581
1604
  }
1582
- function Ma(v) {
1583
- var se, ve;
1584
- const { block: n, config: p, splitBase: g, client: o, cols: C, onCancel: R, onDone: K } = v, F = Number.isFinite(Number(n.key)) ? Number(n.key) : n.key, [L, f] = H(null), [k, S] = H(null), [b, x] = H(null), [j, E] = H(!1), [N, y] = H(""), i = JSON.stringify(L);
1585
- pe(() => {
1605
+ function Ea(k) {
1606
+ var oe, re;
1607
+ const { block: n, config: g, splitBase: h, client: i, cols: N, onCancel: B, onDone: R } = k, j = Number.isFinite(Number(n.key)) ? Number(n.key) : n.key, [L, u] = H(null), [v, b] = H(null), [y, x] = H(null), [A, F] = H(!1), [C, T] = H(""), s = JSON.stringify(L);
1608
+ ce(() => {
1586
1609
  let q = !0;
1587
1610
  const le = window.setTimeout(
1588
1611
  () => {
1589
- o.request(
1590
- rt(`${g}/split`, {
1591
- [p.key_field]: F,
1612
+ i.request(
1613
+ st(`${h}/split`, {
1614
+ [g.key_field]: j,
1592
1615
  preview: !0,
1593
1616
  ...L ? { shares: L } : {}
1594
1617
  })
1595
1618
  ).then((V) => {
1596
- q && (S(V.data), x(null), L || f(
1619
+ q && (b(V.data), x(null), L || u(
1597
1620
  Object.fromEntries(
1598
- V.data.categories.map((oe) => [String(oe.id), Math.round(oe.share * 1e3) / 10])
1621
+ V.data.categories.map((ie) => [String(ie.id), Math.round(ie.share * 1e3) / 10])
1599
1622
  )
1600
1623
  ));
1601
- }).catch((V) => q && x(ot(V)));
1624
+ }).catch((V) => q && x(it(V)));
1602
1625
  },
1603
1626
  L ? 250 : 0
1604
1627
  );
1605
1628
  return () => {
1606
1629
  q = !1, window.clearTimeout(le);
1607
1630
  };
1608
- }, [i, g]);
1609
- const z = (k == null ? void 0 : k.categories.map((q) => q.label).join(" / ")) ?? "", m = `Split the ${n.key} plan into ${z}`, M = async () => {
1610
- E(!0);
1631
+ }, [s, h]);
1632
+ const M = (v == null ? void 0 : v.categories.map((q) => q.label).join(" / ")) ?? "", f = `Split the ${n.key} plan into ${M}`, O = async () => {
1633
+ F(!0);
1611
1634
  try {
1612
- await o.request(
1613
- rt(`${g}/split`, {
1614
- [p.key_field]: F,
1635
+ await i.request(
1636
+ st(`${h}/split`, {
1637
+ [g.key_field]: j,
1615
1638
  shares: L ?? void 0,
1616
- reason: N.trim() || m
1639
+ reason: C.trim() || f
1617
1640
  })
1618
- ), de.success(`${n.key} is now planned by ${z}`), K();
1641
+ ), ue.success(`${n.key} is now planned by ${M}`), R();
1619
1642
  } catch (q) {
1620
- x(ot(q));
1643
+ x(it(q));
1621
1644
  } finally {
1622
- E(!1);
1645
+ F(!1);
1623
1646
  }
1624
- }, P = (q) => T(C.reduce((le, V) => le + I(q[V]), 0));
1647
+ }, P = (q) => E(N.reduce((le, V) => le + I(q[V]), 0));
1625
1648
  return /* @__PURE__ */ d("div", { className: "p-1.5", "data-plan-split-pane": !0, children: [
1626
- /* @__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}` }),
1649
+ /* @__PURE__ */ t("p", { className: "text-[12.5px] font-semibold text-slate-900 dark:text-slate-100", children: `${g.split_label ?? "Plan by category"} · ${n.key}` }),
1627
1650
  /* @__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." }),
1628
- !k && !b && /* @__PURE__ */ t(
1651
+ !v && !y && /* @__PURE__ */ t(
1629
1652
  "div",
1630
1653
  {
1631
1654
  className: "mt-2 h-16 animate-pulse rounded",
1632
1655
  style: { background: "hsl(var(--nvr-skeleton))" }
1633
1656
  }
1634
1657
  ),
1635
- k && (((se = k.share_sets) == null ? void 0 : se.length) ?? 0) > 1 && /* @__PURE__ */ d("div", { className: "mt-2 flex flex-wrap items-center gap-1", "data-plan-share-sets": !0, children: [
1658
+ v && (((oe = v.share_sets) == null ? void 0 : oe.length) ?? 0) > 1 && /* @__PURE__ */ d("div", { className: "mt-2 flex flex-wrap items-center gap-1", "data-plan-share-sets": !0, children: [
1636
1659
  /* @__PURE__ */ t("span", { className: "text-[11px] text-slate-500 dark:text-slate-400", children: "Shares from" }),
1637
- (ve = k.share_sets) == null ? void 0 : ve.map((q) => {
1660
+ (re = v.share_sets) == null ? void 0 : re.map((q) => {
1638
1661
  const le = Object.fromEntries(
1639
- Object.entries(q.shares).map(([oe, w]) => [oe, Math.round(w * 1e3) / 10])
1640
- ), V = JSON.stringify(le) === i;
1662
+ Object.entries(q.shares).map(([ie, w]) => [ie, Math.round(w * 1e3) / 10])
1663
+ ), V = JSON.stringify(le) === s;
1641
1664
  return /* @__PURE__ */ t(
1642
1665
  "button",
1643
1666
  {
@@ -1645,7 +1668,7 @@ function Ma(v) {
1645
1668
  "data-plan-share-set": q.key,
1646
1669
  "aria-pressed": V,
1647
1670
  "data-tip": q.hint ?? "",
1648
- onClick: () => f(le),
1671
+ onClick: () => u(le),
1649
1672
  className: `h-6 rounded-md border px-1.5 text-[11px] font-medium ${V ? "border-transparent bg-nvr-cyan text-white" : "border-slate-200 text-slate-600 hover:bg-muted dark:border-border dark:text-slate-300"}`,
1650
1673
  children: q.label
1651
1674
  },
@@ -1653,7 +1676,7 @@ function Ma(v) {
1653
1676
  );
1654
1677
  })
1655
1678
  ] }),
1656
- k && /* @__PURE__ */ d("table", { className: "mt-2 w-full text-[12px] tabular-nums", children: [
1679
+ v && /* @__PURE__ */ d("table", { className: "mt-2 w-full text-[12px] tabular-nums", children: [
1657
1680
  /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ d("tr", { className: "text-left text-[10.5px] text-slate-500 dark:text-slate-400", children: [
1658
1681
  /* @__PURE__ */ t("th", { className: "py-1 font-medium", children: "Category" }),
1659
1682
  /* @__PURE__ */ t("th", { className: "py-1 text-right font-medium", children: "Share" }),
@@ -1661,11 +1684,11 @@ function Ma(v) {
1661
1684
  /* @__PURE__ */ t("th", { className: "py-1 text-right font-medium", children: "Ceiling" })
1662
1685
  ] }) }),
1663
1686
  /* @__PURE__ */ d("tbody", { children: [
1664
- k.categories.map((q) => /* @__PURE__ */ d("tr", { className: "border-t border-slate-100 dark:border-border", children: [
1687
+ v.categories.map((q) => /* @__PURE__ */ d("tr", { className: "border-t border-slate-100 dark:border-border", children: [
1665
1688
  /* @__PURE__ */ t("td", { className: "py-1 text-slate-800 dark:text-slate-100", children: q.label }),
1666
1689
  /* @__PURE__ */ d("td", { className: "py-1 text-right", children: [
1667
1690
  /* @__PURE__ */ t(
1668
- ma,
1691
+ fa,
1669
1692
  {
1670
1693
  bare: !0,
1671
1694
  type: "text",
@@ -1673,38 +1696,38 @@ function Ma(v) {
1673
1696
  "data-plan-share": String(q.id),
1674
1697
  "aria-label": `${q.label} share`,
1675
1698
  value: (L == null ? void 0 : L[String(q.id)]) ?? "",
1676
- onValue: (le) => f((V) => ({ ...V ?? {}, [String(q.id)]: le ?? 0 })),
1699
+ onValue: (le) => u((V) => ({ ...V ?? {}, [String(q.id)]: le ?? 0 })),
1677
1700
  className: "h-6 w-16 rounded border border-slate-200 bg-background px-1.5 text-right text-[12px] outline-none focus:border-slate-400 dark:border-border"
1678
1701
  }
1679
1702
  ),
1680
1703
  /* @__PURE__ */ t("span", { className: "ml-0.5 text-slate-500", children: "%" })
1681
1704
  ] }),
1682
- /* @__PURE__ */ t("td", { className: "py-1 text-right text-slate-800 dark:text-slate-100", children: D(P(q.values)) }),
1683
- /* @__PURE__ */ t("td", { className: "py-1 text-right text-slate-500 dark:text-slate-400", children: D(q.cap) })
1705
+ /* @__PURE__ */ t("td", { className: "py-1 text-right text-slate-800 dark:text-slate-100", children: z(P(q.values)) }),
1706
+ /* @__PURE__ */ t("td", { className: "py-1 text-right text-slate-500 dark:text-slate-400", children: z(q.cap) })
1684
1707
  ] }, String(q.id))),
1685
1708
  /* @__PURE__ */ d("tr", { className: "border-t border-slate-200 font-medium dark:border-border", children: [
1686
- /* @__PURE__ */ t("td", { className: "py-1 text-slate-800 dark:text-slate-100", children: p.total_label ?? "Total" }),
1709
+ /* @__PURE__ */ t("td", { className: "py-1 text-slate-800 dark:text-slate-100", children: g.total_label ?? "Total" }),
1687
1710
  /* @__PURE__ */ t("td", {}),
1688
- /* @__PURE__ */ t("td", { className: "py-1 text-right text-slate-800 dark:text-slate-100", children: D(P(k.original)) }),
1711
+ /* @__PURE__ */ t("td", { className: "py-1 text-right text-slate-800 dark:text-slate-100", children: z(P(v.original)) }),
1689
1712
  /* @__PURE__ */ t("td", {})
1690
1713
  ] })
1691
1714
  ] })
1692
1715
  ] }),
1693
- (b || (k == null ? void 0 : k.blocked)) && /* @__PURE__ */ t(
1716
+ (y || (v == null ? void 0 : v.blocked)) && /* @__PURE__ */ t(
1694
1717
  "p",
1695
1718
  {
1696
1719
  role: "alert",
1697
1720
  "data-plan-split-blocked": !0,
1698
1721
  className: "mt-1.5 text-[11.5px] font-medium text-red-700 dark:text-red-300",
1699
- children: b ?? (k == null ? void 0 : k.blocked)
1722
+ children: y ?? (v == null ? void 0 : v.blocked)
1700
1723
  }
1701
1724
  ),
1702
1725
  /* @__PURE__ */ t(
1703
1726
  "textarea",
1704
1727
  {
1705
- value: N,
1706
- onChange: (q) => y(q.target.value),
1707
- placeholder: m,
1728
+ value: C,
1729
+ onChange: (q) => T(q.target.value),
1730
+ placeholder: f,
1708
1731
  rows: 2,
1709
1732
  "aria-label": "Reason",
1710
1733
  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"
@@ -1715,7 +1738,7 @@ function Ma(v) {
1715
1738
  "button",
1716
1739
  {
1717
1740
  type: "button",
1718
- onClick: R,
1741
+ onClick: B,
1719
1742
  className: "rounded-md px-2.5 py-1 text-[12px] text-slate-600 hover:bg-muted dark:text-slate-300",
1720
1743
  children: "Back"
1721
1744
  }
@@ -1725,26 +1748,26 @@ function Ma(v) {
1725
1748
  {
1726
1749
  type: "button",
1727
1750
  "data-plan-split-apply": !0,
1728
- disabled: j || !k || !!k.blocked,
1729
- onClick: M,
1751
+ disabled: A || !v || !!v.blocked,
1752
+ onClick: O,
1730
1753
  className: "rounded-md bg-nvr-cyan px-3 py-1 text-[12px] font-medium text-white disabled:opacity-50",
1731
- children: j ? "Splitting…" : "Split it"
1754
+ children: A ? "Splitting…" : "Split it"
1732
1755
  }
1733
1756
  )
1734
1757
  ] })
1735
1758
  ] });
1736
1759
  }
1737
- function Ta(v) {
1738
- const { block: n, config: p, splitBase: g, client: o, onCancel: C, onDone: R } = v, K = Number.isFinite(Number(n.key)) ? Number(n.key) : n.key, [F, L] = H(""), [f, k] = H(!1), [S, b] = H(null), x = `Merged the ${n.key} plan back to one line`;
1760
+ function Pa(k) {
1761
+ const { block: n, config: g, splitBase: h, client: i, onCancel: N, onDone: B } = k, R = Number.isFinite(Number(n.key)) ? Number(n.key) : n.key, [j, L] = H(""), [u, v] = H(!1), [b, y] = H(null), x = `Merged the ${n.key} plan back to one line`;
1739
1762
  return /* @__PURE__ */ d("div", { className: "p-1.5", "data-plan-merge-pane": !0, children: [
1740
- /* @__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}` }),
1763
+ /* @__PURE__ */ t("p", { className: "text-[12.5px] font-semibold text-slate-900 dark:text-slate-100", children: `${g.merge_label ?? "Merge back to one line"} · ${n.key}` }),
1741
1764
  /* @__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." }),
1742
- S && /* @__PURE__ */ t("p", { role: "alert", className: "mt-1.5 text-[11.5px] font-medium text-red-700 dark:text-red-300", children: S }),
1765
+ b && /* @__PURE__ */ t("p", { role: "alert", className: "mt-1.5 text-[11.5px] font-medium text-red-700 dark:text-red-300", children: b }),
1743
1766
  /* @__PURE__ */ t(
1744
1767
  "textarea",
1745
1768
  {
1746
- value: F,
1747
- onChange: (j) => L(j.target.value),
1769
+ value: j,
1770
+ onChange: (A) => L(A.target.value),
1748
1771
  placeholder: x,
1749
1772
  rows: 2,
1750
1773
  "aria-label": "Reason",
@@ -1756,7 +1779,7 @@ function Ta(v) {
1756
1779
  "button",
1757
1780
  {
1758
1781
  type: "button",
1759
- onClick: C,
1782
+ onClick: N,
1760
1783
  className: "rounded-md px-2.5 py-1 text-[12px] text-slate-600 hover:bg-muted dark:text-slate-300",
1761
1784
  children: "Back"
1762
1785
  }
@@ -1766,79 +1789,79 @@ function Ta(v) {
1766
1789
  {
1767
1790
  type: "button",
1768
1791
  "data-plan-merge-apply": !0,
1769
- disabled: f,
1792
+ disabled: u,
1770
1793
  onClick: async () => {
1771
- k(!0);
1794
+ v(!0);
1772
1795
  try {
1773
- await o.request(
1774
- rt(`${g}/merge`, {
1775
- [p.key_field]: K,
1776
- reason: F.trim() || x
1796
+ await i.request(
1797
+ st(`${h}/merge`, {
1798
+ [g.key_field]: R,
1799
+ reason: j.trim() || x
1777
1800
  })
1778
- ), de.success(`${n.key} is one line again`), R();
1779
- } catch (j) {
1780
- b(ot(j));
1801
+ ), ue.success(`${n.key} is one line again`), B();
1802
+ } catch (A) {
1803
+ y(it(A));
1781
1804
  } finally {
1782
- k(!1);
1805
+ v(!1);
1783
1806
  }
1784
1807
  },
1785
1808
  className: "rounded-md bg-nvr-cyan px-3 py-1 text-[12px] font-medium text-white disabled:opacity-50",
1786
- children: f ? "Merging…" : "Merge it"
1809
+ children: u ? "Merging…" : "Merge it"
1787
1810
  }
1788
1811
  )
1789
1812
  ] })
1790
1813
  ] });
1791
1814
  }
1792
- function Ea(v) {
1793
- const { config: n, client: p, used: g, onAdd: o, label: C } = v, [R, K] = H(!1), [F, L] = H(""), { data: f = [] } = ce({
1815
+ function qa(k) {
1816
+ const { config: n, client: g, used: h, onAdd: i, label: N } = k, [B, R] = H(!1), [j, L] = H(""), { data: u = [] } = pe({
1794
1817
  queryKey: ["plan-grid-keys", n.key_collection],
1795
- queryFn: () => p.request(
1796
- ue(`/items/${n.key_collection}`, { fields: "id", sort: "-id", limit: 200 })
1797
- ).then((S) => (S.data ?? []).map((b) => b.id)),
1798
- enabled: R && !!n.key_collection,
1818
+ queryFn: () => g.request(
1819
+ me(`/items/${n.key_collection}`, { fields: "id", sort: "-id", limit: 200 })
1820
+ ).then((b) => (b.data ?? []).map((y) => y.id)),
1821
+ enabled: B && !!n.key_collection,
1799
1822
  staleTime: 10 * 6e4
1800
- }), k = f.filter((S) => !g.has(String(S)));
1801
- return /* @__PURE__ */ d(it, { open: R, onOpenChange: K, children: [
1802
- /* @__PURE__ */ t(dt, { asChild: !0, children: /* @__PURE__ */ d(
1823
+ }), v = u.filter((b) => !h.has(String(b)));
1824
+ return /* @__PURE__ */ d(dt, { open: B, onOpenChange: R, children: [
1825
+ /* @__PURE__ */ t(ct, { asChild: !0, children: /* @__PURE__ */ d(
1803
1826
  "button",
1804
1827
  {
1805
1828
  type: "button",
1806
1829
  "data-plan-add": !0,
1807
1830
  className: "inline-flex h-7 items-center gap-1 rounded-md border border-slate-200 px-2 text-[12px] font-medium text-slate-700 hover:bg-muted dark:border-border dark:text-slate-200",
1808
1831
  children: [
1809
- /* @__PURE__ */ t(sa, { className: "h-3.5 w-3.5" }),
1810
- C
1832
+ /* @__PURE__ */ t(ia, { className: "h-3.5 w-3.5" }),
1833
+ N
1811
1834
  ]
1812
1835
  }
1813
1836
  ) }),
1814
- /* @__PURE__ */ t(ct, { align: "start", sideOffset: 6, className: "w-[200px] p-1.5", children: n.key_collection ? /* @__PURE__ */ d("ul", { className: "max-h-[220px] overflow-y-auto", children: [
1815
- k.length === 0 && /* @__PURE__ */ t("li", { className: "px-2 py-1.5 text-[12px] text-slate-500", children: "Every one is already here." }),
1816
- k.map((S) => /* @__PURE__ */ t("li", { children: /* @__PURE__ */ t(
1837
+ /* @__PURE__ */ t(ut, { align: "start", sideOffset: 6, className: "w-[200px] p-1.5", children: n.key_collection ? /* @__PURE__ */ d("ul", { className: "max-h-[220px] overflow-y-auto", children: [
1838
+ v.length === 0 && /* @__PURE__ */ t("li", { className: "px-2 py-1.5 text-[12px] text-slate-500", children: "Every one is already here." }),
1839
+ v.map((b) => /* @__PURE__ */ t("li", { children: /* @__PURE__ */ t(
1817
1840
  "button",
1818
1841
  {
1819
1842
  type: "button",
1820
- "data-plan-add-key": String(S),
1843
+ "data-plan-add-key": String(b),
1821
1844
  onClick: () => {
1822
- o(S), K(!1);
1845
+ i(b), R(!1);
1823
1846
  },
1824
1847
  className: "w-full rounded px-2 py-1.5 text-left text-[12.5px] text-slate-700 hover:bg-muted dark:text-slate-200",
1825
- children: String(S)
1848
+ children: String(b)
1826
1849
  }
1827
- ) }, String(S)))
1850
+ ) }, String(b)))
1828
1851
  ] }) : /* @__PURE__ */ t(
1829
1852
  "form",
1830
1853
  {
1831
- onSubmit: (S) => {
1832
- S.preventDefault();
1833
- const b = F.trim();
1834
- !b || g.has(b) || (o(Number.isFinite(Number(b)) ? Number(b) : b), L(""), K(!1));
1854
+ onSubmit: (b) => {
1855
+ b.preventDefault();
1856
+ const y = j.trim();
1857
+ !y || h.has(y) || (i(Number.isFinite(Number(y)) ? Number(y) : y), L(""), R(!1));
1835
1858
  },
1836
1859
  children: /* @__PURE__ */ t(
1837
1860
  "input",
1838
1861
  {
1839
- value: F,
1840
- onChange: (S) => L(S.target.value),
1841
- "aria-label": C,
1862
+ value: j,
1863
+ onChange: (b) => L(b.target.value),
1864
+ "aria-label": N,
1842
1865
  className: "h-7 w-full rounded border border-slate-200 bg-background px-2 text-[12.5px] outline-none focus:border-slate-400 dark:border-border"
1843
1866
  }
1844
1867
  )
@@ -1847,9 +1870,9 @@ function Ea(v) {
1847
1870
  ] });
1848
1871
  }
1849
1872
  export {
1850
- Ya as PlanGridField,
1851
- D as fmtFigure,
1852
- Sa as isParentItemKey,
1853
- qt as parseFigure,
1854
- _a as reconcilePatch
1873
+ el as PlanGridField,
1874
+ z as fmtFigure,
1875
+ Oa as isParentItemKey,
1876
+ At as parseFigure,
1877
+ La as reconcilePatch
1855
1878
  };