@nivaro/react 0.3.67 → 0.3.69

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 (32) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +7 -0
  4. package/dist/index.js +836 -835
  5. package/dist/shared/components/ConformanceView.js +34 -34
  6. package/dist/shared/components/ReportView.js +196 -196
  7. package/dist/shared/components/SlaRulesView.js +36 -36
  8. package/dist/shared/components/chat/ChatPanel.js +484 -487
  9. package/dist/shared/components/chat/ChatViews.js +66 -66
  10. package/dist/shared/components/chat/RoomParts.js +159 -157
  11. package/dist/shared/components/help-videos/editor/StatsTab.js +48 -47
  12. package/dist/shared/components/help-videos/editor/VersionsTab.js +17 -16
  13. package/dist/shared/components/imports/CollectionImportPanel.js +72 -72
  14. package/dist/shared/components/item-edit/FieldRenderer.js +186 -182
  15. package/dist/shared/components/item-edit/FieldRow.js +87 -87
  16. package/dist/shared/components/item-edit/FileDownloadCount.js +94 -0
  17. package/dist/shared/components/item-edit/FilePickerField.js +350 -349
  18. package/dist/shared/components/item-edit/RecordInsights.js +90 -91
  19. package/dist/shared/components/item-edit/SummaryPanel.js +31 -31
  20. package/dist/shared/components/layout-editor/assist/ExplainDiff.js +12 -12
  21. package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +175 -138
  22. package/dist/shared/components/layout-editor/inspector/RulesTab.js +53 -52
  23. package/dist/shared/components/panels/AddendumPanel.js +409 -411
  24. package/dist/shared/components/panels/CommentPanel.js +169 -162
  25. package/dist/shared/components/panels/PipelinePanel.js +75 -75
  26. package/dist/shared/components/panels/RevisionsPanel.js +103 -103
  27. package/dist/shared/components/queue/QueueWorklist.js +142 -141
  28. package/dist/shared/lib/activity-sentence.js +154 -144
  29. package/dist/shared/lib/format-value.js +15 -15
  30. package/dist/shared/lib/placement-behaviour.js +39 -31
  31. package/dist/shared/lib/utils.js +58 -53
  32. package/package.json +1 -1
@@ -1,15 +1,15 @@
1
1
  import { jsxs as i, Fragment as Ne, jsx as t } from "react/jsx-runtime";
2
- import { useQueryClient as Qe, useQuery as V, useQueries as De, useMutation as pe } from "@tanstack/react-query";
3
- import { FileDiff as Ze, ChevronDown as et, Paperclip as Ue, Loader2 as tt, Upload as rt } from "lucide-react";
4
- import { useState as j, useRef as Me, useEffect as Be, useMemo as oe, Fragment as Ce, useCallback as Ee, memo as nt } from "react";
2
+ import { useQueryClient as Ue, useQuery as V, useQueries as Te, useMutation as pe } from "@tanstack/react-query";
3
+ import { FileDiff as Ze, ChevronDown as et, Paperclip as Qe, Loader2 as tt, Upload as rt } from "lucide-react";
4
+ import { useState as O, useRef as Me, useEffect as Be, useMemo as oe, Fragment as Ce, useCallback as Ee, memo as nt } from "react";
5
5
  import { toast as z } from "sonner";
6
6
  import { useNivaroClient as xe, useItemEditAuth as at } from "../../context.js";
7
- import { get as Q, post as ve, del as lt } from "../../lib/commands.js";
7
+ import { get as U, post as ve, del as lt } from "../../lib/commands.js";
8
8
  import { sanitizeHtml as st } from "../../lib/sanitize-html.js";
9
9
  import { titleCase as fe } from "../../lib/utils.js";
10
- import { FilePreviewLightbox as it } from "../FilePreviewLightbox.js";
11
- import { DocumentAutofillButton as ot } from "../import/DocumentAutofillButton.js";
12
- import { FieldRenderer as dt } from "../item-edit/FieldRenderer.js";
10
+ import { DocumentAutofillButton as it } from "../import/DocumentAutofillButton.js";
11
+ import { FieldRenderer as ot } from "../item-edit/FieldRenderer.js";
12
+ import { useFileDownload as dt } from "../item-edit/file-download.js";
13
13
  import { evalClientFormula as ct } from "../item-edit/InlineTableField.js";
14
14
  import { parseRollupParentFilter as Le, matchesRollupFilter as mt, computeLiveRollup as Ie, parseRollupSources as Je } from "../item-edit/live-rollups.js";
15
15
  import { useLocalLiveRows as ut, LiveRowsContext as pt, O2MStagingContext as ft, useLiveRows as ht } from "../item-edit/O2MStagingContext.js";
@@ -24,46 +24,46 @@ import { AddendumLinesDiff as Ke } from "./AddendumLinesDiff.js";
24
24
  import { resolveAddendumAmounts as kt } from "./addendum-summary.js";
25
25
  const ye = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" }), _t = (r) => r.replace(/<[^>]+>/g, " ").replace(/&nbsp;/g, " ").replace(/\s+/g, " ").trim();
26
26
  function ze(r) {
27
- const m = Number(r);
28
- return !r || Number.isNaN(m) || m === 0 ? null : /* @__PURE__ */ i(
27
+ const c = Number(r);
28
+ return !r || Number.isNaN(c) || c === 0 ? null : /* @__PURE__ */ i(
29
29
  "span",
30
30
  {
31
- className: D(
31
+ className: T(
32
32
  "inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-medium tabular-nums",
33
- m > 0 ? "bg-emerald-50 text-emerald-700 dark:bg-emerald-500/10 dark:text-emerald-400" : "bg-red-50 text-red-600 dark:bg-red-500/10 dark:text-red-400"
33
+ c > 0 ? "bg-emerald-50 text-emerald-700 dark:bg-emerald-500/10 dark:text-emerald-400" : "bg-red-50 text-red-600 dark:bg-red-500/10 dark:text-red-400"
34
34
  ),
35
35
  children: [
36
- m > 0 ? "+" : "−",
37
- ye.format(Math.abs(m))
36
+ c > 0 ? "+" : "−",
37
+ ye.format(Math.abs(c))
38
38
  ]
39
39
  }
40
40
  );
41
41
  }
42
42
  function wt({ amounts: r }) {
43
- const { previous: m, next: v, change: k } = r, N = k != null && k !== 0, h = [
43
+ const { previous: c, next: N, change: h } = r, k = h != null && h !== 0, u = [
44
44
  {
45
45
  label: "Previous",
46
- value: m == null ? "—" : ye.format(m),
46
+ value: c == null ? "—" : ye.format(c),
47
47
  className: "text-slate-500 dark:text-slate-400"
48
48
  },
49
49
  {
50
50
  label: "New",
51
- value: v == null ? "—" : ye.format(v),
51
+ value: N == null ? "—" : ye.format(N),
52
52
  className: "font-semibold text-foreground"
53
53
  },
54
54
  {
55
55
  label: "Change",
56
- value: k == null ? "—" : N ? `${k > 0 ? "+" : "−"}${ye.format(Math.abs(k))}` : "No change",
57
- className: N ? k > 0 ? "font-semibold text-emerald-600 dark:text-emerald-400" : "font-semibold text-red-600 dark:text-red-400" : "text-slate-500 dark:text-slate-400"
56
+ value: h == null ? "—" : k ? `${h > 0 ? "+" : "−"}${ye.format(Math.abs(h))}` : "No change",
57
+ className: k ? h > 0 ? "font-semibold text-emerald-600 dark:text-emerald-400" : "font-semibold text-red-600 dark:text-red-400" : "text-slate-500 dark:text-slate-400"
58
58
  }
59
59
  ];
60
- return /* @__PURE__ */ t("div", { className: "flex flex-wrap items-start gap-x-8 gap-y-2", children: h.map((p) => /* @__PURE__ */ i("div", { className: "min-w-0", children: [
61
- /* @__PURE__ */ t("p", { className: D("text-[13px] leading-5 tabular-nums", p.className), children: p.value }),
62
- /* @__PURE__ */ t("p", { className: "text-[11px] leading-4 text-slate-400 dark:text-slate-500", children: p.label })
63
- ] }, p.label)) });
60
+ return /* @__PURE__ */ t("div", { className: "flex flex-wrap items-start gap-x-8 gap-y-2", children: u.map((x) => /* @__PURE__ */ i("div", { className: "min-w-0", children: [
61
+ /* @__PURE__ */ t("p", { className: T("text-[13px] leading-5 tabular-nums", x.className), children: x.value }),
62
+ /* @__PURE__ */ t("p", { className: "text-[11px] leading-4 text-slate-400 dark:text-slate-500", children: x.label })
63
+ ] }, x.label)) });
64
64
  }
65
65
  const We = "grid grid-cols-1 items-baseline text-[12.5px] sm:grid-cols-[140px_minmax(0,1fr)] sm:gap-x-6 sm:gap-y-2.5", de = "text-[12px] text-slate-500 dark:text-slate-400", ce = "mb-2.5 min-w-0 text-slate-700 sm:mb-0 dark:text-slate-200";
66
- function D(...r) {
66
+ function T(...r) {
67
67
  return r.filter(Boolean).join(" ");
68
68
  }
69
69
  const Ae = {
@@ -87,41 +87,41 @@ const Ae = {
87
87
  badge: "bg-amber-50 text-amber-700 dark:bg-amber-500/10 dark:text-amber-400",
88
88
  dot: "bg-amber-500"
89
89
  }
90
- }, Ct = (r, m) => Math.round(Number(r) * 100) === Math.round(Number(m) * 100);
91
- function St(r, m, v) {
92
- if (!v || r.computed_type !== "rollup" || !r.computed_formula) return r;
93
- const k = Ie(Je(r.computed_formula), v.rows);
94
- return k === null || m != null && Ct(m, k) ? r : {
90
+ }, Ct = (r, c) => Math.round(Number(r) * 100) === Math.round(Number(c) * 100);
91
+ function St(r, c, N) {
92
+ if (!N || r.computed_type !== "rollup" || !r.computed_formula) return r;
93
+ const h = Ie(Je(r.computed_formula), N.rows);
94
+ return h === null || c != null && Ct(c, h) ? r : {
95
95
  ...r,
96
96
  options: {
97
97
  ...r.options ?? {},
98
- __live_delta: { original: m, live: k }
98
+ __live_delta: { original: c, live: h }
99
99
  }
100
100
  };
101
101
  }
102
- function Ft({
102
+ function $t({
103
103
  current: r,
104
- value: m,
105
- onChange: v,
106
- currentLabel: k,
107
- newLabel: N
104
+ value: c,
105
+ onChange: N,
106
+ currentLabel: h,
107
+ newLabel: k
108
108
  }) {
109
- const [h, p] = j(() => {
110
- const g = Number(m);
111
- return !Number.isFinite(g) || Math.round(g * 100) === Math.round(r * 100) ? "" : String(Math.round((g - r) * 100) / 100);
112
- }), _ = h.trim() === "" ? 0 : Number(h), f = Number.isFinite(_), F = f ? Math.round((r + _) * 100) / 100 : r, c = (g) => g.toLocaleString("en-US", { style: "currency", currency: "USD" });
109
+ const [u, x] = O(() => {
110
+ const v = Number(c);
111
+ return !Number.isFinite(v) || Math.round(v * 100) === Math.round(r * 100) ? "" : String(Math.round((v - r) * 100) / 100);
112
+ }), _ = u.trim() === "" ? 0 : Number(u), f = Number.isFinite(_), $ = f ? Math.round((r + _) * 100) / 100 : r, m = (v) => v.toLocaleString("en-US", { style: "currency", currency: "USD" });
113
113
  return /* @__PURE__ */ i("div", { className: "space-y-1.5", children: [
114
114
  /* @__PURE__ */ i("div", { className: "flex items-center gap-0", children: [
115
115
  /* @__PURE__ */ t("span", { className: "flex h-9 items-center rounded-l-md border border-r-0 border-slate-200 bg-slate-50 px-2.5 text-[13px] text-slate-500 dark:border-border dark:bg-muted", children: "$" }),
116
116
  /* @__PURE__ */ t(
117
117
  Pe,
118
118
  {
119
- value: h,
120
- onChange: (g) => {
121
- const C = g.target.value;
122
- p(C);
123
- const w = C.trim() === "" ? 0 : Number(C);
124
- Number.isFinite(w) && v(Math.round((r + w) * 100) / 100);
119
+ value: u,
120
+ onChange: (v) => {
121
+ const w = v.target.value;
122
+ x(w);
123
+ const S = w.trim() === "" ? 0 : Number(w);
124
+ Number.isFinite(S) && N(Math.round((r + S) * 100) / 100);
125
125
  },
126
126
  placeholder: "Negative numbers to decrease",
127
127
  className: "h-9 rounded-l-none text-[13px]"
@@ -130,22 +130,22 @@ function Ft({
130
130
  ] }),
131
131
  /* @__PURE__ */ i("p", { className: "text-[12px]", children: [
132
132
  /* @__PURE__ */ i("span", { className: "font-medium text-slate-600 dark:text-slate-300", children: [
133
- k ?? "Current REQ Amount",
133
+ h ?? "Current REQ Amount",
134
134
  ":"
135
135
  ] }),
136
136
  " ",
137
- /* @__PURE__ */ t("span", { className: "tabular-nums text-slate-700 dark:text-slate-200", children: c(r) }),
137
+ /* @__PURE__ */ t("span", { className: "tabular-nums text-slate-700 dark:text-slate-200", children: m(r) }),
138
138
  /* @__PURE__ */ t("span", { className: "mx-2 text-slate-300", children: "·" }),
139
139
  /* @__PURE__ */ i("span", { className: "font-medium text-slate-600 dark:text-slate-300", children: [
140
- N ?? "New REQ Total",
140
+ k ?? "New REQ Total",
141
141
  ":"
142
142
  ] }),
143
143
  " ",
144
144
  /* @__PURE__ */ t(
145
145
  "span",
146
146
  {
147
- className: "tabular-nums font-semibold " + (F > r ? "text-emerald-600 dark:text-emerald-400" : F < r ? "text-red-600 dark:text-red-400" : "text-slate-700 dark:text-slate-200"),
148
- children: c(F)
147
+ className: "tabular-nums font-semibold " + ($ > r ? "text-emerald-600 dark:text-emerald-400" : $ < r ? "text-red-600 dark:text-red-400" : "text-slate-700 dark:text-slate-200"),
148
+ children: m($)
149
149
  }
150
150
  ),
151
151
  !f && /* @__PURE__ */ t("span", { className: "ml-2 text-[11px] text-red-500", children: "Enter a number" })
@@ -153,122 +153,122 @@ function Ft({
153
153
  ] });
154
154
  }
155
155
  const qt = nt(function({
156
- configuredFields: m,
157
- fieldMap: v,
158
- formData: k,
159
- onFieldChange: N,
160
- relations: h,
161
- collection: p,
156
+ configuredFields: c,
157
+ fieldMap: N,
158
+ formData: h,
159
+ onFieldChange: k,
160
+ relations: u,
161
+ collection: x,
162
162
  prefillParentId: _,
163
163
  parentData: f
164
164
  }) {
165
- const F = ht();
166
- return m.length === 0 ? /* @__PURE__ */ t("div", { className: "rounded-lg border border-dashed border-slate-200 bg-slate-50 px-4 py-6 text-center dark:border-border dark:bg-muted/30", children: /* @__PURE__ */ t("p", { className: "text-[12px] text-slate-400 dark:text-slate-500", children: "No fields configured for addendum. Set up the field list in Data Model → Layouts → Addendum Form." }) }) : /* @__PURE__ */ i("div", { className: "border-t border-slate-100 dark:border-border pt-3", children: [
165
+ const $ = ht();
166
+ return c.length === 0 ? /* @__PURE__ */ t("div", { className: "rounded-lg border border-dashed border-slate-200 bg-slate-50 px-4 py-6 text-center dark:border-border dark:bg-muted/30", children: /* @__PURE__ */ t("p", { className: "text-[12px] text-slate-400 dark:text-slate-500", children: "No fields configured for addendum. Set up the field list in Data Model → Layouts → Addendum Form." }) }) : /* @__PURE__ */ i("div", { className: "border-t border-slate-100 dark:border-border pt-3", children: [
167
167
  /* @__PURE__ */ t("p", { className: "mb-3 text-[11px] font-semibold uppercase tracking-wide text-slate-400 dark:text-slate-500", children: "Proposed changes" }),
168
- /* @__PURE__ */ t("div", { className: "space-y-3", children: m.map((c) => {
169
- const g = v[c.field], C = c.label_override ?? fe((g == null ? void 0 : g.field) ?? c.field);
170
- if (!g)
168
+ /* @__PURE__ */ t("div", { className: "space-y-3", children: c.map((m) => {
169
+ const v = N[m.field], w = m.label_override ?? fe((v == null ? void 0 : v.field) ?? m.field);
170
+ if (!v)
171
171
  return /* @__PURE__ */ i("div", { children: [
172
- /* @__PURE__ */ t(he, { className: "mb-1 block text-[11px] font-medium text-slate-600 dark:text-slate-400", children: C }),
172
+ /* @__PURE__ */ t(he, { className: "mb-1 block text-[11px] font-medium text-slate-600 dark:text-slate-400", children: w }),
173
173
  /* @__PURE__ */ t(
174
174
  Pe,
175
175
  {
176
- value: String(k[c.field] ?? ""),
177
- onChange: (R) => N(c.field, R.target.value),
176
+ value: String(h[m.field] ?? ""),
177
+ onChange: (j) => k(m.field, j.target.value),
178
178
  className: "h-8 text-[12px]"
179
179
  }
180
180
  )
181
- ] }, c.field);
182
- const T = (typeof c.overrides == "string" ? (() => {
181
+ ] }, m.field);
182
+ const D = (typeof m.overrides == "string" ? (() => {
183
183
  try {
184
- return JSON.parse(c.overrides);
184
+ return JSON.parse(m.overrides);
185
185
  } catch {
186
186
  return {};
187
187
  }
188
- })() : c.overrides ?? {}).options ?? {};
189
- if (T.entry_mode === "delta") {
190
- const R = Number((f == null ? void 0 : f[c.field]) ?? 0);
188
+ })() : m.overrides ?? {}).options ?? {};
189
+ if (D.entry_mode === "delta") {
190
+ const j = Number((f == null ? void 0 : f[m.field]) ?? 0);
191
191
  return /* @__PURE__ */ i("div", { children: [
192
- /* @__PURE__ */ t(he, { className: "mb-1 block text-[11px] font-medium text-slate-600 dark:text-slate-400", children: C }),
192
+ /* @__PURE__ */ t(he, { className: "mb-1 block text-[11px] font-medium text-slate-600 dark:text-slate-400", children: w }),
193
193
  /* @__PURE__ */ t(
194
- Ft,
194
+ $t,
195
195
  {
196
- current: Number.isFinite(R) ? R : 0,
197
- value: k[c.field],
198
- onChange: (P) => N(c.field, P),
199
- currentLabel: typeof T.current_label == "string" ? T.current_label : void 0,
200
- newLabel: typeof T.new_label == "string" ? T.new_label : void 0
196
+ current: Number.isFinite(j) ? j : 0,
197
+ value: h[m.field],
198
+ onChange: (P) => k(m.field, P),
199
+ currentLabel: typeof D.current_label == "string" ? D.current_label : void 0,
200
+ newLabel: typeof D.new_label == "string" ? D.new_label : void 0
201
201
  }
202
202
  )
203
- ] }, c.field);
203
+ ] }, m.field);
204
204
  }
205
205
  return /* @__PURE__ */ i("div", { children: [
206
- /* @__PURE__ */ t(he, { className: "mb-1 block text-[11px] font-medium text-slate-600 dark:text-slate-400", children: C }),
206
+ /* @__PURE__ */ t(he, { className: "mb-1 block text-[11px] font-medium text-slate-600 dark:text-slate-400", children: w }),
207
207
  /* @__PURE__ */ t(
208
- dt,
208
+ ot,
209
209
  {
210
- field: St(g, k[c.field], F),
211
- value: k[c.field],
212
- onChange: (R) => N(c.field, R),
213
- relations: h,
214
- collection: p,
210
+ field: St(v, h[m.field], $),
211
+ value: h[m.field],
212
+ onChange: (j) => k(m.field, j),
213
+ relations: u,
214
+ collection: x,
215
215
  itemId: "new",
216
216
  prefillParentId: _
217
217
  }
218
218
  )
219
- ] }, c.field);
219
+ ] }, m.field);
220
220
  }) })
221
221
  ] });
222
222
  });
223
- function $t({ addendumId: r }) {
224
- const m = xe(), { data: v, isLoading: k } = V({
223
+ function Ft({ addendumId: r }) {
224
+ const c = xe(), { data: N, isLoading: h } = V({
225
225
  queryKey: ["pipeline-instance", "nivaro_addendums", r],
226
- queryFn: () => m.request(Q(`/pipelines/instance/nivaro_addendums/${r}`)).then((p) => p.data),
226
+ queryFn: () => c.request(U(`/pipelines/instance/nivaro_addendums/${r}`)).then((x) => x.data),
227
227
  staleTime: 1e4
228
228
  });
229
- if (k) return /* @__PURE__ */ t(le, { className: "h-8 w-full" });
230
- if (!(v != null && v.instance))
229
+ if (h) return /* @__PURE__ */ t(le, { className: "h-8 w-full" });
230
+ if (!(N != null && N.instance))
231
231
  return /* @__PURE__ */ t("p", { className: "text-[12px] text-slate-400 italic", children: "No workflow instance found." });
232
- const { instance: N } = v, h = N.current_state_obj;
232
+ const { instance: k } = N, u = k.current_state_obj;
233
233
  return /* @__PURE__ */ i("div", { className: "space-y-3", children: [
234
- h && /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
234
+ u && /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
235
235
  /* @__PURE__ */ t("span", { className: "text-[11px] text-slate-500", children: "Current state:" }),
236
236
  /* @__PURE__ */ t(
237
237
  "span",
238
238
  {
239
239
  className: "inline-flex items-center rounded-full px-2.5 py-0.5 text-[11px] font-medium",
240
240
  style: {
241
- backgroundColor: h.color ? `${h.color}22` : "#f1f5f9",
242
- color: h.color ?? "#475569",
243
- border: `1px solid ${h.color ? `${h.color}44` : "#e2e8f0"}`
241
+ backgroundColor: u.color ? `${u.color}22` : "#f1f5f9",
242
+ color: u.color ?? "#475569",
243
+ border: `1px solid ${u.color ? `${u.color}44` : "#e2e8f0"}`
244
244
  },
245
- children: h.label
245
+ children: u.label
246
246
  }
247
247
  )
248
248
  ] }),
249
- N.completed_at && /* @__PURE__ */ t("p", { className: "text-[11px] text-slate-400 italic", children: "Workflow complete." })
249
+ k.completed_at && /* @__PURE__ */ t("p", { className: "text-[11px] text-slate-400 italic", children: "Workflow complete." })
250
250
  ] });
251
251
  }
252
252
  function At({
253
253
  collection: r,
254
- itemId: m,
255
- assignments: v,
256
- workflowTemplateId: k,
257
- resolvedLayoutId: N,
258
- fields: h,
259
- relations: p,
254
+ itemId: c,
255
+ assignments: N,
256
+ workflowTemplateId: h,
257
+ resolvedLayoutId: k,
258
+ fields: u,
259
+ relations: x,
260
260
  parentData: _,
261
261
  onClose: f,
262
- onCreated: F
262
+ onCreated: $
263
263
  }) {
264
- const c = xe(), g = v.filter(
264
+ const m = xe(), v = N.filter(
265
265
  (a) => !String(a.field).startsWith("__") && (a.is_visible || a.is_visible === 1)
266
- ), [C, w] = j(""), [T, R] = j(""), [P, J] = j([]), [ee, A] = j(0), G = Me(null), M = async (a) => {
266
+ ), [w, S] = O(""), [D, j] = O(""), [P, J] = O([]), [ee, A] = O(0), G = Me(null), M = async (a) => {
267
267
  if (a.length !== 0) {
268
268
  A((s) => s + a.length);
269
269
  for (const s of a)
270
270
  try {
271
- const d = await c.upload(s);
271
+ const d = await m.upload(s);
272
272
  J((o) => [...o, { id: String(d.id), name: s.name }]);
273
273
  } catch {
274
274
  z.error(`Failed to upload ${s.name}`);
@@ -276,9 +276,9 @@ function At({
276
276
  A((d) => d - 1);
277
277
  }
278
278
  }
279
- }, [te, E] = j(() => {
279
+ }, [te, E] = O(() => {
280
280
  const a = {};
281
- for (const s of g) {
281
+ for (const s of v) {
282
282
  const d = typeof s.overrides == "string" ? (() => {
283
283
  try {
284
284
  return JSON.parse(s.overrides);
@@ -291,112 +291,112 @@ function At({
291
291
  return a;
292
292
  }), me = oe(() => {
293
293
  const a = {};
294
- for (const s of h) a[s.field] = s;
294
+ for (const s of u) a[s.field] = s;
295
295
  return a;
296
- }, [h]), X = Ee((a, s) => {
296
+ }, [u]), X = Ee((a, s) => {
297
297
  E((d) => ({ ...d, [a]: s }));
298
298
  }, []), W = Ee(
299
299
  (a) => {
300
- E((s) => ({ ...s, ...a.values })), !C.trim() && a.summary && w(a.summary.slice(0, 120));
300
+ E((s) => ({ ...s, ...a.values })), !w.trim() && a.summary && S(a.summary.slice(0, 120));
301
301
  for (const [s, d] of Object.entries(a.lines_by_alias)) {
302
- const o = p.find(
303
- (S) => S.one_collection === r && !S.junction_field && (S.one_field === s || S.many_collection === s)
302
+ const o = x.find(
303
+ (C) => C.one_collection === r && !C.junction_field && (C.one_field === s || C.many_collection === s)
304
304
  );
305
305
  if (!(o != null && o.many_collection) || !o.many_field) continue;
306
- const x = o.many_field, y = `${o.many_collection}.${x}`;
307
- L((S) => {
308
- const q = new Map(S);
306
+ const b = o.many_field, y = `${o.many_collection}.${b}`;
307
+ L((C) => {
308
+ const q = new Map(C);
309
309
  return q.set(y, [
310
310
  ...q.get(y) ?? [],
311
- ...d.map((ae) => ({ ...ae.values, [x]: m }))
311
+ ...d.map((ae) => ({ ...ae.values, [b]: c }))
312
312
  ]), q;
313
313
  });
314
314
  }
315
315
  a.file_id && J((s) => [...s, { id: a.file_id, name: a.document_name }]);
316
316
  },
317
- [r, m, p, C]
318
- ), [Y, L] = j(
317
+ [r, c, x, w]
318
+ ), [Y, L] = O(
319
319
  /* @__PURE__ */ new Map()
320
- ), [re, se] = j(/* @__PURE__ */ new Map()), [ne, ie] = j(/* @__PURE__ */ new Map()), Z = Me(Y);
320
+ ), [re, se] = O(/* @__PURE__ */ new Map()), [ne, ie] = O(/* @__PURE__ */ new Map()), Z = Me(Y);
321
321
  Be(() => {
322
322
  Z.current = Y;
323
323
  }, [Y]);
324
- const U = ut(), O = oe(
324
+ const Q = ut(), R = oe(
325
325
  () => ({
326
326
  getPendingRows: (a, s) => Y.get(`${a}.${s}`) ?? [],
327
327
  queueRow: (a, s, d) => L((o) => {
328
- const x = new Map(o), y = `${a}.${s}`;
329
- return x.set(y, [...x.get(y) ?? [], d]), x;
328
+ const b = new Map(o), y = `${a}.${s}`;
329
+ return b.set(y, [...b.get(y) ?? [], d]), b;
330
330
  }),
331
331
  removeRow: (a, s, d) => L((o) => {
332
- const x = new Map(o), y = `${a}.${s}`, S = [...x.get(y) ?? []];
333
- return S.splice(d, 1), x.set(y, S), x;
332
+ const b = new Map(o), y = `${a}.${s}`, C = [...b.get(y) ?? []];
333
+ return C.splice(d, 1), b.set(y, C), b;
334
334
  }),
335
- updateRow: (a, s, d, o) => L((x) => {
336
- const y = new Map(x), S = `${a}.${s}`, q = [...y.get(S) ?? []];
337
- return q[d] = { ...q[d], ...o }, y.set(S, q), y;
335
+ updateRow: (a, s, d, o) => L((b) => {
336
+ const y = new Map(b), C = `${a}.${s}`, q = [...y.get(C) ?? []];
337
+ return q[d] = { ...q[d], ...o }, y.set(C, q), y;
338
338
  }),
339
- reorderRows: (a, s, d, o) => L((x) => {
340
- const y = new Map(x), S = `${a}.${s}`, q = [...y.get(S) ?? []], [ae] = q.splice(d, 1);
341
- return q.splice(o, 0, ae), y.set(S, q), y;
339
+ reorderRows: (a, s, d, o) => L((b) => {
340
+ const y = new Map(b), C = `${a}.${s}`, q = [...y.get(C) ?? []], [ae] = q.splice(d, 1);
341
+ return q.splice(o, 0, ae), y.set(C, q), y;
342
342
  }),
343
343
  getPendingEdits: (a, s) => re.get(`${a}.${s}`) ?? /* @__PURE__ */ new Map(),
344
344
  getPendingDeletes: (a, s) => ne.get(`${a}.${s}`) ?? /* @__PURE__ */ new Set(),
345
- queueEdit: (a, s, d, o) => se((x) => {
346
- const y = new Map(x), S = `${a}.${s}`, q = new Map(y.get(S) ?? []);
347
- return q.set(d, { ...q.get(d) ?? {}, ...o }), y.set(S, q), y;
345
+ queueEdit: (a, s, d, o) => se((b) => {
346
+ const y = new Map(b), C = `${a}.${s}`, q = new Map(y.get(C) ?? []);
347
+ return q.set(d, { ...q.get(d) ?? {}, ...o }), y.set(C, q), y;
348
348
  }),
349
349
  queueDelete: (a, s, d) => ie((o) => {
350
- const x = new Map(o), y = `${a}.${s}`;
351
- return x.set(y, /* @__PURE__ */ new Set([...x.get(y) ?? [], d])), x;
350
+ const b = new Map(o), y = `${a}.${s}`;
351
+ return b.set(y, /* @__PURE__ */ new Set([...b.get(y) ?? [], d])), b;
352
352
  }),
353
353
  cancelPendingEdit: (a, s, d) => se((o) => {
354
- const x = new Map(o), y = `${a}.${s}`, S = new Map(x.get(y) ?? []);
355
- return S.delete(d), x.set(y, S), x;
354
+ const b = new Map(o), y = `${a}.${s}`, C = new Map(b.get(y) ?? []);
355
+ return C.delete(d), b.set(y, C), b;
356
356
  }),
357
357
  cancelPendingDelete: (a, s, d) => ie((o) => {
358
- const x = new Map(o), y = `${a}.${s}`, S = new Set(x.get(y) ?? []);
359
- return S.delete(d), x.set(y, S), x;
358
+ const b = new Map(o), y = `${a}.${s}`, C = new Set(b.get(y) ?? []);
359
+ return C.delete(d), b.set(y, C), b;
360
360
  })
361
361
  }),
362
362
  [Y, re, ne]
363
- ), u = pe({
363
+ ), p = pe({
364
364
  mutationFn: () => {
365
365
  const a = {};
366
366
  for (const [s, d] of Object.entries(te)) {
367
367
  const o = me[s];
368
368
  (o == null ? void 0 : o.computed_type) === "rollup" || (o == null ? void 0 : o.computed_type) === "write" || d !== void 0 && String(d ?? "") !== String(_[s] ?? "") && (a[s] = d);
369
369
  }
370
- for (const s of g) {
371
- const d = p.find(
370
+ for (const s of v) {
371
+ const d = x.find(
372
372
  (o) => o.one_collection === r && !o.junction_field && (o.one_field === s.field || o.many_collection === s.field)
373
373
  );
374
374
  if (d != null && d.many_collection && d.many_field) {
375
- const o = (Z.current.get(`${d.many_collection}.${d.many_field}`) ?? []).map(({ __prefilled: x, ...y }) => y);
375
+ const o = (Z.current.get(`${d.many_collection}.${d.many_field}`) ?? []).map(({ __prefilled: b, ...y }) => y);
376
376
  o.length > 0 && (a[s.field] = o);
377
377
  }
378
378
  }
379
- return c.request(
379
+ return m.request(
380
380
  ve("/addendums", {
381
381
  parent_collection: r,
382
- parent_id: m,
383
- title: C.trim(),
384
- description: T.trim() || void 0,
385
- workflow_template_id: k ?? void 0,
386
- addendum_layout_id: N,
382
+ parent_id: c,
383
+ title: w.trim(),
384
+ description: D.trim() || void 0,
385
+ workflow_template_id: h ?? void 0,
386
+ addendum_layout_id: k,
387
387
  data: a,
388
- fields_schema: g.map((s) => s.field),
388
+ fields_schema: v.map((s) => s.field),
389
389
  attachments: P.length > 0 ? P.map((s) => s.id) : void 0
390
390
  })
391
391
  );
392
392
  },
393
393
  onSuccess: (a) => {
394
394
  var s;
395
- z.success("Addendum created"), F(((s = a == null ? void 0 : a.data) == null ? void 0 : s.id) != null ? String(a.data.id) : null), f();
395
+ z.success("Addendum created"), $(((s = a == null ? void 0 : a.data) == null ? void 0 : s.id) != null ? String(a.data.id) : null), f();
396
396
  },
397
397
  onError: () => z.error("Failed to create addendum")
398
398
  });
399
- return /* @__PURE__ */ t(pt.Provider, { value: U, children: /* @__PURE__ */ t(ft.Provider, { value: O, children: /* @__PURE__ */ i("div", { className: "flex h-full flex-col", children: [
399
+ return /* @__PURE__ */ t(pt.Provider, { value: Q, children: /* @__PURE__ */ t(ft.Provider, { value: R, children: /* @__PURE__ */ i("div", { className: "flex h-full flex-col", children: [
400
400
  /* @__PURE__ */ i(gt, { className: "shrink-0 border-b border-slate-200 px-5 py-4 dark:border-border", children: [
401
401
  /* @__PURE__ */ t(vt, { className: "text-[14px] font-semibold text-slate-900 dark:text-slate-100", children: "New Addendum" }),
402
402
  /* @__PURE__ */ t("p", { className: "mt-0.5 text-[12px] text-slate-500 dark:text-slate-400", children: "Propose changes to this record. Fields are pre-filled with current values — edit what's changing." })
@@ -411,8 +411,8 @@ function At({
411
411
  /* @__PURE__ */ t(
412
412
  Pe,
413
413
  {
414
- value: C,
415
- onChange: (a) => w(a.target.value),
414
+ value: w,
415
+ onChange: (a) => S(a.target.value),
416
416
  className: "h-8 text-[12px]",
417
417
  placeholder: "Brief description of this addendum",
418
418
  autoFocus: !0
@@ -424,8 +424,8 @@ function At({
424
424
  /* @__PURE__ */ t(
425
425
  yt,
426
426
  {
427
- value: T,
428
- onChange: (a) => R(a.target.value),
427
+ value: D,
428
+ onChange: (a) => j(a.target.value),
429
429
  rows: 2,
430
430
  className: "text-[12px]",
431
431
  placeholder: "Why is this change needed?"
@@ -452,7 +452,7 @@ function At({
452
452
  {
453
453
  className: "inline-flex max-w-[240px] items-center gap-1 rounded border border-slate-200 bg-slate-50 px-2 py-1 text-[11px] text-slate-700 dark:border-border dark:bg-muted dark:text-slate-200",
454
454
  children: [
455
- /* @__PURE__ */ t(Ue, { className: "h-3 w-3 shrink-0 text-slate-400" }),
455
+ /* @__PURE__ */ t(Qe, { className: "h-3 w-3 shrink-0 text-slate-400" }),
456
456
  /* @__PURE__ */ t("span", { className: "truncate", children: a.name }),
457
457
  /* @__PURE__ */ t(
458
458
  "button",
@@ -484,10 +484,10 @@ function At({
484
484
  }
485
485
  ),
486
486
  /* @__PURE__ */ t(
487
- ot,
487
+ it,
488
488
  {
489
489
  collection: r,
490
- layoutId: N,
490
+ layoutId: k,
491
491
  label: "Fill from document",
492
492
  onApply: W,
493
493
  className: "h-7 px-2.5 text-[11px]"
@@ -500,13 +500,13 @@ function At({
500
500
  qt,
501
501
  {
502
502
  parentData: _,
503
- configuredFields: g,
503
+ configuredFields: v,
504
504
  fieldMap: me,
505
505
  formData: te,
506
506
  onFieldChange: X,
507
- relations: p,
507
+ relations: x,
508
508
  collection: r,
509
- prefillParentId: m
509
+ prefillParentId: c
510
510
  }
511
511
  )
512
512
  ] }),
@@ -517,49 +517,49 @@ function At({
517
517
  {
518
518
  size: "sm",
519
519
  className: "h-8 bg-nvr-cyan text-[12px] font-medium text-white hover:bg-nvr-cyan/90",
520
- disabled: !C.trim() || u.isPending,
521
- onClick: () => u.mutate(),
522
- children: u.isPending ? "Creating…" : "Create Addendum"
520
+ disabled: !w.trim() || p.isPending,
521
+ onClick: () => p.mutate(),
522
+ children: p.isPending ? "Creating…" : "Create Addendum"
523
523
  }
524
524
  )
525
525
  ] })
526
526
  ] }) }) });
527
527
  }
528
528
  function Mt({ addendum: r }) {
529
- var F;
530
- const m = xe(), v = [r.created_by, r.approved_by].filter(Boolean), { data: k = {} } = V({
531
- queryKey: ["addendum-users", ...v.sort()],
529
+ var $;
530
+ const c = xe(), N = [r.created_by, r.approved_by].filter(Boolean), { data: h = {} } = V({
531
+ queryKey: ["addendum-users", ...N.sort()],
532
532
  queryFn: async () => {
533
- const c = await m.request(
534
- Q("/items/nivaro_users", {
535
- filter: JSON.stringify({ id: { _in: v } }),
533
+ const m = await c.request(
534
+ U("/items/nivaro_users", {
535
+ filter: JSON.stringify({ id: { _in: N } }),
536
536
  fields: "id,first_name,last_name"
537
537
  })
538
- ).then((g) => g.data ?? []);
538
+ ).then((v) => v.data ?? []);
539
539
  return Object.fromEntries(
540
- c.map((g) => [
541
- String(g.id).toUpperCase(),
542
- [g.first_name, g.last_name].filter(Boolean).join(" ")
540
+ m.map((v) => [
541
+ String(v.id).toUpperCase(),
542
+ [v.first_name, v.last_name].filter(Boolean).join(" ")
543
543
  ])
544
544
  );
545
545
  },
546
- enabled: v.length > 0,
546
+ enabled: N.length > 0,
547
547
  staleTime: 3e5
548
- }), N = (c) => c && k[String(c).toUpperCase()] || null, h = (c) => c ? new Date(c).toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" }) : null, p = N(r.created_by), _ = N(r.approved_by), f = [];
548
+ }), k = (m) => m && h[String(m).toUpperCase()] || null, u = (m) => m ? new Date(m).toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" }) : null, x = k(r.created_by), _ = k(r.approved_by), f = [];
549
549
  return r.timeline_impact_days != null && Number(r.timeline_impact_days) !== 0 && f.push({
550
550
  label: "Timeline impact",
551
551
  value: `${r.timeline_impact_days > 0 ? "+" : ""}${r.timeline_impact_days} days`
552
552
  }), r.created_at && f.push({
553
553
  label: "Created",
554
- value: [h(r.created_at), p].filter(Boolean).join(" · ")
554
+ value: [u(r.created_at), x].filter(Boolean).join(" · ")
555
555
  }), r.status === "approved" && (r.approved_at || _) && f.push({
556
556
  label: "Approved",
557
- value: [h(r.approved_at), _].filter(Boolean).join(" · ")
558
- }), f.length === 0 && !r.description && !((F = r.attachments) != null && F.length) ? null : /* @__PURE__ */ i("dl", { className: D(We, "px-4 py-3.5"), children: [
559
- f.map((c) => /* @__PURE__ */ i(Ce, { children: [
560
- /* @__PURE__ */ t("dt", { className: de, children: c.label }),
561
- /* @__PURE__ */ t("dd", { className: ce, children: c.value })
562
- ] }, c.label)),
557
+ value: [u(r.approved_at), _].filter(Boolean).join(" · ")
558
+ }), f.length === 0 && !r.description && !(($ = r.attachments) != null && $.length) ? null : /* @__PURE__ */ i("dl", { className: T(We, "px-4 py-3.5"), children: [
559
+ f.map((m) => /* @__PURE__ */ i(Ce, { children: [
560
+ /* @__PURE__ */ t("dt", { className: de, children: m.label }),
561
+ /* @__PURE__ */ t("dd", { className: ce, children: m.value })
562
+ ] }, m.label)),
563
563
  r.description && /* @__PURE__ */ i(Ne, { children: [
564
564
  /* @__PURE__ */ t("dt", { className: de, children: "Justification" }),
565
565
  /* @__PURE__ */ t("dd", { className: ce, children: /^\s*</.test(r.description) ? /* @__PURE__ */ t(
@@ -574,114 +574,112 @@ function Mt({ addendum: r }) {
574
574
  ] });
575
575
  }
576
576
  function Pt({ ids: r }) {
577
- const m = xe(), [v, k] = j(null), N = Array.isArray(r) ? r.filter(Boolean) : [], { data: h = [] } = V({
578
- queryKey: ["addendum-files", ...N],
577
+ const c = xe(), N = dt(), h = Array.isArray(r) ? r.filter(Boolean) : [], { data: k = [] } = V({
578
+ queryKey: ["addendum-files", ...h],
579
579
  queryFn: () => Promise.all(
580
- N.map(
581
- (p) => m.request(Q(`/files/${p}/meta`)).then((_) => {
582
- var f, F, c, g, C, w;
580
+ h.map(
581
+ (u) => c.request(U(`/files/${u}/meta`)).then((x) => {
582
+ var _, f, $, m, v, w;
583
583
  return {
584
- id: p,
585
- filename: ((f = _.data) == null ? void 0 : f.filename_download) ?? ((F = _.data) == null ? void 0 : F.filename) ?? ((c = _.data) == null ? void 0 : c.title) ?? null,
586
- size: ((g = _.data) == null ? void 0 : g.filesize) ?? null,
587
- type: ((C = _.data) == null ? void 0 : C.type) ?? null,
588
- missing: !!((w = _.data) != null && w.missing_at)
584
+ id: u,
585
+ filename: ((_ = x.data) == null ? void 0 : _.filename_download) ?? ((f = x.data) == null ? void 0 : f.filename) ?? (($ = x.data) == null ? void 0 : $.title) ?? null,
586
+ size: ((m = x.data) == null ? void 0 : m.filesize) ?? null,
587
+ type: ((v = x.data) == null ? void 0 : v.type) ?? null,
588
+ missing: !!((w = x.data) != null && w.missing_at)
589
589
  };
590
- }).catch(() => ({ id: p, filename: null, size: null, type: null, missing: !1 }))
590
+ }).catch(() => ({ id: u, filename: null, size: null, type: null, missing: !1 }))
591
591
  )
592
592
  ),
593
- enabled: N.length > 0,
593
+ enabled: h.length > 0,
594
594
  staleTime: 3e5
595
595
  });
596
- return N.length === 0 ? null : /* @__PURE__ */ i(Ne, { children: [
596
+ return h.length === 0 ? null : /* @__PURE__ */ i(Ne, { children: [
597
597
  /* @__PURE__ */ t("dt", { className: de, children: "Attachments" }),
598
- /* @__PURE__ */ i("dd", { className: D(ce, "flex flex-wrap gap-x-4 gap-y-1"), children: [
599
- v && /* @__PURE__ */ t(it, { file: v, onClose: () => k(null) }),
600
- h.length === 0 && /* @__PURE__ */ i("span", { className: "text-slate-400 dark:text-slate-500", children: [
601
- N.length,
598
+ /* @__PURE__ */ i("dd", { className: T(ce, "flex flex-wrap gap-x-4 gap-y-1"), children: [
599
+ k.length === 0 && /* @__PURE__ */ i("span", { className: "text-slate-400 dark:text-slate-500", children: [
600
+ h.length,
602
601
  " ",
603
- N.length === 1 ? "file" : "files",
602
+ h.length === 1 ? "file" : "files",
604
603
  "…"
605
604
  ] }),
606
- h.map((p) => /* @__PURE__ */ i(
607
- "button",
608
- {
609
- type: "button",
610
- onClick: () => k({
611
- id: p.id,
612
- url: m.fileUrl(p.id),
613
- name: p.filename ?? `File ${p.id.slice(0, 8)}…`,
614
- type: p.type,
615
- size: p.size
616
- }),
617
- className: "inline-flex min-w-0 items-center gap-1.5 rounded text-slate-700 underline-offset-2 transition-colors hover:text-nvr-cyan hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/40 dark:text-slate-200",
618
- children: [
619
- p.missing && /* @__PURE__ */ t(
620
- "span",
621
- {
622
- className: "rounded bg-red-500/10 px-1 py-px text-[9px] font-semibold uppercase tracking-wide text-red-600 dark:text-red-400",
623
- title: "The stored file is missing from storage — preview/download will fail. Re-upload it.",
624
- children: "missing"
625
- }
626
- ),
627
- /* @__PURE__ */ t(Ue, { className: "h-3 w-3 shrink-0 text-slate-400" }),
628
- /* @__PURE__ */ t("span", { className: "max-w-[320px] truncate", children: p.filename ?? `File ${p.id.slice(0, 8)}…` })
629
- ]
630
- },
631
- p.id
605
+ k.map((u) => (
606
+ // Every file click downloads (2026-11-08): no in-app preview.
607
+ /* @__PURE__ */ i(
608
+ "a",
609
+ {
610
+ href: `${c.fileUrl(u.id)}?download=1`,
611
+ download: u.filename || !0,
612
+ onClick: N(`${c.fileUrl(u.id)}?download=1`, u.filename),
613
+ title: "Download",
614
+ className: "inline-flex min-w-0 items-center gap-1.5 rounded text-slate-700 underline-offset-2 transition-colors hover:text-nvr-cyan hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/40 dark:text-slate-200",
615
+ children: [
616
+ u.missing && /* @__PURE__ */ t(
617
+ "span",
618
+ {
619
+ className: "rounded bg-red-500/10 px-1 py-px text-[9px] font-semibold uppercase tracking-wide text-red-600 dark:text-red-400",
620
+ title: "The stored file is missing from storage — preview/download will fail. Re-upload it.",
621
+ children: "missing"
622
+ }
623
+ ),
624
+ /* @__PURE__ */ t(Qe, { className: "h-3 w-3 shrink-0 text-slate-400" }),
625
+ /* @__PURE__ */ t("span", { className: "max-w-[320px] truncate", children: u.filename ?? `File ${u.id.slice(0, 8)}…` })
626
+ ]
627
+ },
628
+ u.id
629
+ )
632
630
  ))
633
631
  ] })
634
632
  ] });
635
633
  }
636
634
  function jt({
637
635
  addendum: r,
638
- configuredFields: m,
639
- onRefresh: v,
640
- isActive: k,
641
- relations: N = [],
642
- parentCollection: h,
643
- parentId: p,
636
+ configuredFields: c,
637
+ onRefresh: N,
638
+ isActive: h,
639
+ relations: k = [],
640
+ parentCollection: u,
641
+ parentId: x,
644
642
  fieldMap: _ = {}
645
643
  }) {
646
644
  var je, Re;
647
- const f = xe(), [F, c] = j(!1), g = r.workflow_template_id && ["draft", "review"].includes(r.status) ? "in approvals" : r.status, C = g === "in approvals" ? Ae.review : Ae[r.status] ?? Ae.draft, w = r.data ?? {}, R = Object.keys(w).filter((e) => Array.isArray(w[e])).map((e) => m.find((n) => n.field === e) ?? { field: e }).map((e) => {
648
- const n = N.find(
649
- (l) => l.one_collection === h && !l.junction_field && (l.one_field === e.field || l.many_collection === e.field)
645
+ const f = xe(), [$, m] = O(!1), v = r.workflow_template_id && ["draft", "review"].includes(r.status) ? "in approvals" : r.status, w = v === "in approvals" ? Ae.review : Ae[r.status] ?? Ae.draft, S = r.data ?? {}, j = Object.keys(S).filter((e) => Array.isArray(S[e])).map((e) => c.find((n) => n.field === e) ?? { field: e }).map((e) => {
646
+ const n = k.find(
647
+ (l) => l.one_collection === u && !l.junction_field && (l.one_field === e.field || l.many_collection === e.field)
650
648
  );
651
649
  return { field: e.field, rel: n };
652
650
  }).filter((e) => {
653
651
  var n, l;
654
652
  return ((n = e.rel) == null ? void 0 : n.many_collection) && ((l = e.rel) == null ? void 0 : l.many_field);
655
- }), P = De({
656
- queries: R.map(({ rel: e }) => ({
657
- queryKey: ["o2m-rows", e.many_collection, e.many_field, p],
653
+ }), P = Te({
654
+ queries: j.map(({ rel: e }) => ({
655
+ queryKey: ["o2m-rows", e.many_collection, e.many_field, x],
658
656
  queryFn: () => f.request(
659
- Q(`/items/${e.many_collection}`, {
660
- filter: JSON.stringify({ [e.many_field]: { _eq: p } }),
657
+ U(`/items/${e.many_collection}`, {
658
+ filter: JSON.stringify({ [e.many_field]: { _eq: x } }),
661
659
  limit: 200
662
660
  })
663
661
  ).then((n) => n.data ?? []),
664
662
  staleTime: 3e4,
665
- enabled: !!p
663
+ enabled: !!x
666
664
  }))
667
665
  }), J = ["approved", "reverted"].includes(r.status), { data: ee } = V({
668
666
  queryKey: ["addendum-lines", r.id],
669
- queryFn: () => f.request(Q(`/addendums/${r.id}/lines`)).then((e) => e.data ?? {}),
670
- enabled: F && J,
667
+ queryFn: () => f.request(U(`/addendums/${r.id}/lines`)).then((e) => e.data ?? {}),
668
+ enabled: $ && J,
671
669
  staleTime: 6e4
672
670
  }), A = Object.fromEntries(
673
671
  P.map((e, n) => [
674
- R[n].field,
672
+ j[n].field,
675
673
  e.data ?? null
676
674
  ])
677
675
  ), G = pe({
678
676
  mutationFn: () => f.request(ve(`/addendums/${r.id}/approve`)),
679
677
  onSuccess: () => {
680
- v(), z.success("Addendum approved — changes applied to record");
678
+ N(), z.success("Addendum approved — changes applied to record");
681
679
  },
682
680
  onError: (e) => {
683
- var l, b;
684
- const n = (b = (l = e == null ? void 0 : e.response) == null ? void 0 : l.data) == null ? void 0 : b.error;
681
+ var l, g;
682
+ const n = (g = (l = e == null ? void 0 : e.response) == null ? void 0 : l.data) == null ? void 0 : g.error;
685
683
  z.error(n ?? "Failed to approve");
686
684
  }
687
685
  }), M = pe({
@@ -690,84 +688,84 @@ function jt({
690
688
  Y(), z.success("Addendum reverted — the record is back to its pre-approval values");
691
689
  },
692
690
  onError: (e) => {
693
- var l, b;
694
- const n = (b = (l = e == null ? void 0 : e.response) == null ? void 0 : l.data) == null ? void 0 : b.error;
691
+ var l, g;
692
+ const n = (g = (l = e == null ? void 0 : e.response) == null ? void 0 : l.data) == null ? void 0 : g.error;
695
693
  z.error(n ?? "Failed to revert", { duration: 1e4 });
696
694
  }
697
- }), [te, E] = j(!1), [me, X] = j(!1), W = Qe(), Y = () => {
698
- v(), W.invalidateQueries({ queryKey: ["addendums"] }), W.invalidateQueries({ queryKey: ["item-actions"] }), W.invalidateQueries({ queryKey: ["ext-item-actions"] }), W.invalidateQueries({ queryKey: ["pipeline-all-owners"] }), W.invalidateQueries({ queryKey: ["item"] }), W.invalidateQueries({ queryKey: ["o2m-rows"] }), W.invalidateQueries({ queryKey: ["pipeline-instance"] });
695
+ }), [te, E] = O(!1), [me, X] = O(!1), W = Ue(), Y = () => {
696
+ N(), W.invalidateQueries({ queryKey: ["addendums"] }), W.invalidateQueries({ queryKey: ["item-actions"] }), W.invalidateQueries({ queryKey: ["ext-item-actions"] }), W.invalidateQueries({ queryKey: ["pipeline-all-owners"] }), W.invalidateQueries({ queryKey: ["item"] }), W.invalidateQueries({ queryKey: ["o2m-rows"] }), W.invalidateQueries({ queryKey: ["pipeline-instance"] });
699
697
  }, L = pe({
700
698
  mutationFn: () => f.request(lt(`/addendums/${r.id}`)),
701
699
  onSuccess: () => {
702
700
  Y(), z.success("Addendum deleted");
703
701
  },
704
702
  onError: (e) => {
705
- var l, b;
706
- const n = (b = (l = e == null ? void 0 : e.response) == null ? void 0 : l.data) == null ? void 0 : b.error;
703
+ var l, g;
704
+ const n = (g = (l = e == null ? void 0 : e.response) == null ? void 0 : l.data) == null ? void 0 : g.error;
707
705
  z.error(n ?? "Failed to delete", { duration: 1e4 });
708
706
  }
709
707
  }), { isAdmin: re } = at(), se = pe({
710
708
  mutationFn: () => f.request(ve(`/addendums/${r.id}/reject`)),
711
709
  onSuccess: () => {
712
- v(), z.success("Addendum rejected");
710
+ N(), z.success("Addendum rejected");
713
711
  },
714
712
  onError: () => z.error("Failed to reject")
715
713
  }), ne = pe({
716
714
  mutationFn: () => f.request(ve(`/addendums/${r.id}/submit`)),
717
715
  onSuccess: () => {
718
- v(), z.success("Submitted for review");
716
+ N(), z.success("Submitted for review");
719
717
  },
720
718
  onError: () => z.error("Failed to submit")
721
- }), ie = m.filter((e) => w[e.field] !== void 0), Z = (e) => e.computed_type === "rollup" ? Je(e.computed_formula) : [], U = (e) => {
722
- const n = N.find(
723
- (l) => l.one_collection === h && l.many_collection === e.related_collection && l.many_field === e.fk_field && !l.junction_field
719
+ }), ie = c.filter((e) => S[e.field] !== void 0), Z = (e) => e.computed_type === "rollup" ? Je(e.computed_formula) : [], Q = (e) => {
720
+ const n = k.find(
721
+ (l) => l.one_collection === u && l.many_collection === e.related_collection && l.many_field === e.fk_field && !l.junction_field
724
722
  );
725
723
  return n ? n.one_field ?? n.many_collection : null;
726
- }, O = oe(
724
+ }, R = oe(
727
725
  () => Object.values(_).filter((e) => {
728
726
  const n = Z(e);
729
727
  return n.length > 0 && !n.some((l) => l.recursive) && n.every((l) => {
730
- const b = U(l);
731
- return !!b && Array.isArray(w[b]);
728
+ const g = Q(l);
729
+ return !!g && Array.isArray(S[g]);
732
730
  });
733
731
  }),
734
732
  // biome-ignore lint/correctness/useExhaustiveDependencies: helpers close over relations/parentCollection
735
- [_, w, N, h]
736
- ), u = oe(
733
+ [_, S, k, u]
734
+ ), p = oe(
737
735
  () => [
738
736
  ...new Set(
739
- O.flatMap((e) => Z(e).map((n) => n.related_collection))
737
+ R.flatMap((e) => Z(e).map((n) => n.related_collection))
740
738
  )
741
739
  ],
742
- [O]
743
- ), a = De({
744
- queries: u.map((e) => ({
740
+ [R]
741
+ ), a = Te({
742
+ queries: p.map((e) => ({
745
743
  queryKey: ["field-config", e, null],
746
- queryFn: () => f.request(Q(`/field-config/${e}`)).then((n) => n.data ?? []),
744
+ queryFn: () => f.request(U(`/field-config/${e}`)).then((n) => n.data ?? []),
747
745
  staleTime: 6e4
748
746
  }))
749
747
  }), s = a.map((e) => e.dataUpdatedAt).join(","), d = ie.filter((e) => {
750
- const n = w[e.field];
751
- return n != null && typeof n == "object" || n == null ? !1 : !N.some(
752
- (l) => l.one_collection === h && (l.one_field === e.field || l.many_collection === e.field)
748
+ const n = S[e.field];
749
+ return n != null && typeof n == "object" || n == null ? !1 : !k.some(
750
+ (l) => l.one_collection === u && (l.one_field === e.field || l.many_collection === e.field)
753
751
  );
754
752
  }), { data: o } = V({
755
753
  queryKey: [
756
754
  "addendum-current",
757
- h,
758
- p,
755
+ u,
756
+ x,
759
757
  d.map((e) => e.field).join(","),
760
- O.map((e) => e.field).join(",")
758
+ R.map((e) => e.field).join(",")
761
759
  ],
762
760
  queryFn: () => f.request(
763
- Q(`/items/${h}/${p}`, {
761
+ U(`/items/${u}/${x}`, {
764
762
  fields: [
765
763
  .../* @__PURE__ */ new Set([
766
764
  "id",
767
765
  ...d.map((e) => e.field),
768
766
  // The rollups themselves (current figure) plus any parent_filter
769
767
  // columns that decide whether the rollup applies to this record.
770
- ...O.flatMap((e) => [
768
+ ...R.flatMap((e) => [
771
769
  e.field,
772
770
  ...Object.keys(Le(e.computed_formula) ?? {})
773
771
  ])
@@ -775,52 +773,52 @@ function jt({
775
773
  ].join(",")
776
774
  })
777
775
  ).then((e) => e.data ?? null).catch(() => null),
778
- enabled: !!h && !!p && (d.length > 0 || O.length > 0),
776
+ enabled: !!u && !!x && (d.length > 0 || R.length > 0),
779
777
  staleTime: 15e3
780
- }), x = oe(() => {
778
+ }), b = oe(() => {
781
779
  const e = /* @__PURE__ */ new Map(), n = new Map(
782
- u.map((l, b) => {
783
- var $;
780
+ p.map((l, g) => {
781
+ var F;
784
782
  return [
785
783
  l,
786
- ($ = a[b]) == null ? void 0 : $.data
784
+ (F = a[g]) == null ? void 0 : F.data
787
785
  ];
788
786
  })
789
787
  );
790
- for (const l of O) {
791
- const b = Le(l.computed_formula);
792
- if (b && o && !mt(o, b)) continue;
793
- const $ = /* @__PURE__ */ new Map();
788
+ for (const l of R) {
789
+ const g = Le(l.computed_formula);
790
+ if (g && o && !mt(o, g)) continue;
791
+ const F = /* @__PURE__ */ new Map();
794
792
  let H = !0;
795
793
  for (const B of Z(l)) {
796
- const ge = U(B), ue = n.get(B.related_collection);
794
+ const ge = Q(B), ue = n.get(B.related_collection);
797
795
  if (!ge || !ue) {
798
796
  H = !1;
799
797
  break;
800
798
  }
801
- const Ge = ue.filter((we) => we.computed_type === "write" && !!we.computed_formula), Xe = w[ge].map((we) => {
802
- const $e = { ...we };
799
+ const Ge = ue.filter((we) => we.computed_type === "write" && !!we.computed_formula), Xe = S[ge].map((we) => {
800
+ const Fe = { ...we };
803
801
  for (const Oe of Ge) {
804
- const Te = ct(String(Oe.computed_formula), $e);
805
- Te !== null && ($e[Oe.field] = Te);
802
+ const De = ct(String(Oe.computed_formula), Fe);
803
+ De !== null && (Fe[Oe.field] = De);
806
804
  }
807
- return $e;
805
+ return Fe;
808
806
  });
809
- $.set(`${B.related_collection}.${B.fk_field}`, Xe);
807
+ F.set(`${B.related_collection}.${B.fk_field}`, Xe);
810
808
  }
811
809
  if (!H) continue;
812
- const K = Ie(Z(l), $);
810
+ const K = Ie(Z(l), F);
813
811
  K !== null && e.set(l.field, Math.round(K * 100) / 100);
814
812
  }
815
813
  return e;
816
- }, [O, u, s, w, o]), y = (e, n) => n ? e.filter((l) => {
817
- const b = n.find(($) => String($.id) === String(l.id));
818
- return b ? Object.keys(l).some(
819
- ($) => $ !== "id" && String(l[$] ?? "") !== String(b[$] ?? "")
814
+ }, [R, p, s, S, o]), y = (e, n) => n ? e.filter((l) => {
815
+ const g = n.find((F) => String(F.id) === String(l.id));
816
+ return g ? Object.keys(l).some(
817
+ (F) => F !== "id" && String(l[F] ?? "") !== String(g[F] ?? "")
820
818
  ) : !0;
821
819
  }).length : e.length, q = [
822
820
  ...ie.filter((e) => {
823
- const n = w[e.field];
821
+ const n = S[e.field];
824
822
  if (n == null || n === "") return !1;
825
823
  if (Array.isArray(n))
826
824
  return y(n, A[e.field]) > 0;
@@ -829,50 +827,50 @@ function jt({
829
827
  }).map((e) => ({
830
828
  field: e.field,
831
829
  label_override: e.label_override ?? null,
832
- value: w[e.field]
830
+ value: S[e.field]
833
831
  })),
834
- ...O.flatMap(
835
- (e) => x.has(e.field) && !(o && o[e.field] != null && Number(o[e.field]) === x.get(e.field)) ? [
832
+ ...R.flatMap(
833
+ (e) => b.has(e.field) && !(o && o[e.field] != null && Number(o[e.field]) === b.get(e.field)) ? [
836
834
  {
837
835
  field: e.field,
838
836
  label_override: e.label ?? null,
839
- value: x.get(e.field)
837
+ value: b.get(e.field)
840
838
  }
841
839
  ] : []
842
840
  )
843
841
  ], ae = q.length, He = (e, n) => {
844
- var b;
845
- const l = (b = _[e]) == null ? void 0 : b.type;
842
+ var g;
843
+ const l = (g = _[e]) == null ? void 0 : g.type;
846
844
  return l && ["integer", "bigInteger", "decimal", "float", "number"].includes(l) ? !0 : n != null && n !== "" && !Array.isArray(n) && !Number.isNaN(Number(n));
847
845
  }, Se = (e) => {
848
846
  var l;
849
847
  const n = (l = _[e]) == null ? void 0 : l.options;
850
848
  return n && typeof n == "object" && n.format === "currency" ? !0 : /amount|cost|price|total|budget|spend/i.test(e);
851
- }, Fe = (e, n) => Se(e) ? ye.format(Number(n)) : new Intl.NumberFormat("en-US").format(Number(n)), Ve = oe(() => {
849
+ }, $e = (e, n) => Se(e) ? ye.format(Number(n)) : new Intl.NumberFormat("en-US").format(Number(n)), Ve = oe(() => {
852
850
  if (r.cost_impact != null && Number(r.cost_impact) !== 0 || !o) return null;
853
851
  for (const e of d) {
854
852
  if (!Se(e.field)) continue;
855
- const n = Number(w[e.field]), l = Number(o[e.field]);
853
+ const n = Number(S[e.field]), l = Number(o[e.field]);
856
854
  if (!Number.isNaN(n) && !Number.isNaN(l) && n !== l) return n - l;
857
855
  }
858
856
  return null;
859
- }, [r.cost_impact, o, d, w]), ke = oe(() => {
857
+ }, [r.cost_impact, o, d, S]), ke = oe(() => {
860
858
  if (!o) return null;
861
859
  const e = [
862
- ...d.map((n) => [n.field, Number(w[n.field])]),
863
- ...x.entries()
860
+ ...d.map((n) => [n.field, Number(S[n.field])]),
861
+ ...b.entries()
864
862
  ].flatMap(([n, l]) => {
865
- const b = o[n];
866
- return !Se(n) || b == null || b === "" ? [] : Number.isNaN(Number(b)) || Number.isNaN(l) ? [] : [{ field: n, previous: Number(b), next: l }];
863
+ const g = o[n];
864
+ return !Se(n) || g == null || g === "" ? [] : Number.isNaN(Number(g)) || Number.isNaN(l) ? [] : [{ field: n, previous: Number(g), next: l }];
867
865
  });
868
866
  return e.find((n) => n.previous !== n.next) ?? e[0] ?? null;
869
- }, [o, d, w, x]), _e = kt(r, ke), qe = _e.previous != null || _e.next != null || _e.change != null, be = qe ? (ke == null ? void 0 : ke.field) ?? null : null, Ye = be ? ((je = q.find((e) => e.field === be)) == null ? void 0 : je.label_override) ?? ((Re = _[be]) == null ? void 0 : Re.label) ?? fe(be) : "Amount";
867
+ }, [o, d, S, b]), _e = kt(r, ke), qe = _e.previous != null || _e.next != null || _e.change != null, be = qe ? (ke == null ? void 0 : ke.field) ?? null : null, Ye = be ? ((je = q.find((e) => e.field === be)) == null ? void 0 : je.label_override) ?? ((Re = _[be]) == null ? void 0 : Re.label) ?? fe(be) : "Amount";
870
868
  return /* @__PURE__ */ i(
871
869
  "div",
872
870
  {
873
- className: D(
871
+ className: T(
874
872
  "overflow-hidden rounded-lg border bg-white transition-shadow hover:shadow-sm dark:bg-card",
875
- k ? "border-amber-300 dark:border-amber-500/40" : "border-slate-200 dark:border-border"
873
+ h ? "border-amber-300 dark:border-amber-500/40" : "border-slate-200 dark:border-border"
876
874
  ),
877
875
  children: [
878
876
  /* @__PURE__ */ i(
@@ -880,20 +878,20 @@ function jt({
880
878
  {
881
879
  type: "button",
882
880
  className: "flex w-full items-start gap-3 px-4 py-3 text-left",
883
- onClick: () => c((e) => !e),
881
+ onClick: () => m((e) => !e),
884
882
  children: [
885
- /* @__PURE__ */ t("span", { className: D("mt-0.5 h-2 w-2 shrink-0 rounded-full", C.dot) }),
883
+ /* @__PURE__ */ t("span", { className: T("mt-0.5 h-2 w-2 shrink-0 rounded-full", w.dot) }),
886
884
  /* @__PURE__ */ i("div", { className: "flex-1 min-w-0", children: [
887
885
  /* @__PURE__ */ i("div", { className: "flex items-center gap-2 flex-wrap", children: [
888
886
  /* @__PURE__ */ t("span", { className: "text-[13px] font-semibold text-slate-800 dark:text-slate-100 truncate", children: r.title }),
889
887
  /* @__PURE__ */ t(
890
888
  "span",
891
889
  {
892
- className: D(
890
+ className: T(
893
891
  "inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-medium",
894
- C.badge
892
+ w.badge
895
893
  ),
896
- children: g
894
+ children: v
897
895
  }
898
896
  ),
899
897
  ae > 0 && /* @__PURE__ */ i("span", { className: "text-[11px] text-slate-400 dark:text-slate-500", children: [
@@ -904,14 +902,14 @@ function jt({
904
902
  ] }),
905
903
  ze(r.cost_impact) ?? ze(Ve)
906
904
  ] }),
907
- r.description && !F && /* @__PURE__ */ t("p", { className: "mt-0.5 text-[12px] text-slate-500 dark:text-slate-400 line-clamp-1", children: _t(r.description) })
905
+ r.description && !$ && /* @__PURE__ */ t("p", { className: "mt-0.5 text-[12px] text-slate-500 dark:text-slate-400 line-clamp-1", children: _t(r.description) })
908
906
  ] }),
909
907
  /* @__PURE__ */ t(
910
908
  "span",
911
909
  {
912
- className: D(
910
+ className: T(
913
911
  "shrink-0 text-[10px] text-slate-400 transition-transform",
914
- F && "rotate-180"
912
+ $ && "rotate-180"
915
913
  ),
916
914
  children: "▾"
917
915
  }
@@ -919,7 +917,7 @@ function jt({
919
917
  ]
920
918
  }
921
919
  ),
922
- F && /* @__PURE__ */ i("div", { className: "border-t border-slate-100 dark:border-border", children: [
920
+ $ && /* @__PURE__ */ i("div", { className: "border-t border-slate-100 dark:border-border", children: [
923
921
  /* @__PURE__ */ t(Mt, { addendum: r }),
924
922
  (ae > 0 || qe) && /* @__PURE__ */ i("section", { className: "border-t border-slate-100 px-4 py-3.5 dark:border-border", children: [
925
923
  /* @__PURE__ */ t("h4", { className: "mb-3 text-[12.5px] font-semibold text-slate-800 dark:text-slate-100", children: J ? "Changes" : "Proposed changes" }),
@@ -929,7 +927,7 @@ function jt({
929
927
  /* @__PURE__ */ t("dd", { className: ce, children: /* @__PURE__ */ t(wt, { amounts: _e }) })
930
928
  ] }),
931
929
  q.map((e) => {
932
- var b;
930
+ var g;
933
931
  const n = e.value;
934
932
  if (e.field === be || Array.isArray(n) && A[e.field]) return null;
935
933
  let l;
@@ -940,23 +938,23 @@ function jt({
940
938
  else if (typeof n == "object")
941
939
  l = JSON.stringify(n).slice(0, 60);
942
940
  else if (He(e.field, n)) {
943
- const $ = Number(n), H = o == null ? void 0 : o[e.field], K = H != null && H !== "" && !Number.isNaN(Number(H)) ? Number(H) : null, B = K != null ? $ - K : 0;
941
+ const F = Number(n), H = o == null ? void 0 : o[e.field], K = H != null && H !== "" && !Number.isNaN(Number(H)) ? Number(H) : null, B = K != null ? F - K : 0;
944
942
  l = /* @__PURE__ */ i("span", { className: "inline-flex flex-wrap items-baseline gap-x-1.5 tabular-nums", children: [
945
- K != null && K !== $ && /* @__PURE__ */ t("span", { className: "text-slate-400 line-through decoration-slate-300 dark:text-slate-500 dark:decoration-slate-600", children: Fe(e.field, K) }),
943
+ K != null && K !== F && /* @__PURE__ */ t("span", { className: "text-slate-400 line-through decoration-slate-300 dark:text-slate-500 dark:decoration-slate-600", children: $e(e.field, K) }),
946
944
  /* @__PURE__ */ i("span", { className: "font-medium text-foreground", children: [
947
- K != null && K !== $ && /* @__PURE__ */ t("span", { className: "mr-1 font-normal text-slate-400", "aria-hidden": "true", children: "→" }),
948
- Fe(e.field, $)
945
+ K != null && K !== F && /* @__PURE__ */ t("span", { className: "mr-1 font-normal text-slate-400", "aria-hidden": "true", children: "→" }),
946
+ $e(e.field, F)
949
947
  ] }),
950
948
  B !== 0 && /* @__PURE__ */ i(
951
949
  "span",
952
950
  {
953
- className: D(
951
+ className: T(
954
952
  "rounded-full px-1.5 py-px text-[10px] font-medium",
955
953
  B > 0 ? "bg-emerald-50 text-emerald-700 dark:bg-emerald-500/10 dark:text-emerald-400" : "bg-red-50 text-red-600 dark:bg-red-500/10 dark:text-red-400"
956
954
  ),
957
955
  children: [
958
956
  B > 0 ? "+" : "−",
959
- Fe(e.field, Math.abs(B))
957
+ $e(e.field, Math.abs(B))
960
958
  ]
961
959
  }
962
960
  )
@@ -964,12 +962,12 @@ function jt({
964
962
  } else
965
963
  l = String(n);
966
964
  return /* @__PURE__ */ i(Ce, { children: [
967
- /* @__PURE__ */ t("dt", { className: de, children: e.label_override ?? ((b = _[e.field]) == null ? void 0 : b.label) ?? fe(e.field) }),
968
- /* @__PURE__ */ t("dd", { className: D(ce, "break-words"), children: l })
965
+ /* @__PURE__ */ t("dt", { className: de, children: e.label_override ?? ((g = _[e.field]) == null ? void 0 : g.label) ?? fe(e.field) }),
966
+ /* @__PURE__ */ t("dd", { className: T(ce, "break-words"), children: l })
969
967
  ] }, e.field);
970
968
  }),
971
969
  J && Object.entries(ee ?? {}).map(([e, n]) => {
972
- var l, b;
970
+ var l, g;
973
971
  return /* @__PURE__ */ i(Ce, { children: [
974
972
  /* @__PURE__ */ t("dt", { className: de, children: ((l = _[e]) == null ? void 0 : l.label) ?? fe(e) }),
975
973
  /* @__PURE__ */ t("dd", { className: ce, children: /* @__PURE__ */ t(
@@ -981,17 +979,17 @@ function jt({
981
979
  proposed: n.after,
982
980
  original: n.before,
983
981
  ignoreMissing: !0,
984
- label: ((b = _[e]) == null ? void 0 : b.label) ?? fe(e)
982
+ label: ((g = _[e]) == null ? void 0 : g.label) ?? fe(e)
985
983
  }
986
984
  ) })
987
985
  ] }, `applied-${e}`);
988
986
  }),
989
- R.map(({ field: e, rel: n }) => {
987
+ j.map(({ field: e, rel: n }) => {
990
988
  var B, ge;
991
- const l = w[e], b = R.findIndex((ue) => ue.field === e), $ = A[e] ?? ((B = P[b]) != null && B.isLoading ? null : []);
992
- if (J || !Array.isArray(l) || !$ || !(n != null && n.many_collection) || !n.many_field)
989
+ const l = S[e], g = j.findIndex((ue) => ue.field === e), F = A[e] ?? ((B = P[g]) != null && B.isLoading ? null : []);
990
+ if (J || !Array.isArray(l) || !F || !(n != null && n.many_collection) || !n.many_field)
993
991
  return null;
994
- const H = m.find((ue) => ue.field === e), K = (H == null ? void 0 : H.label_override) ?? ((ge = _[e]) == null ? void 0 : ge.label) ?? fe(e);
992
+ const H = c.find((ue) => ue.field === e), K = (H == null ? void 0 : H.label_override) ?? ((ge = _[e]) == null ? void 0 : ge.label) ?? fe(e);
995
993
  return /* @__PURE__ */ i(Ce, { children: [
996
994
  /* @__PURE__ */ t("dt", { className: de, children: K }),
997
995
  /* @__PURE__ */ t("dd", { className: ce, children: /* @__PURE__ */ t(
@@ -1001,7 +999,7 @@ function jt({
1001
999
  childCollection: n.many_collection,
1002
1000
  fkField: n.many_field,
1003
1001
  proposed: l,
1004
- original: $,
1002
+ original: F,
1005
1003
  label: K
1006
1004
  }
1007
1005
  ) })
@@ -1011,7 +1009,7 @@ function jt({
1011
1009
  ] }),
1012
1010
  r.workflow_template_id && /* @__PURE__ */ i("div", { className: "border-t border-slate-100 dark:border-border px-4 py-3.5", children: [
1013
1011
  /* @__PURE__ */ t("h4", { className: "mb-3 text-[12.5px] font-semibold text-slate-800 dark:text-slate-100", children: "Workflow" }),
1014
- /* @__PURE__ */ t($t, { addendumId: r.id }),
1012
+ /* @__PURE__ */ t(Ft, { addendumId: r.id }),
1015
1013
  re && /* @__PURE__ */ t("div", { className: "mt-2 flex items-center justify-end gap-2", children: r.status === "approved" ? r.legacy_id != null ? null : te ? /* @__PURE__ */ i("span", { className: "flex items-center gap-1.5", children: [
1016
1014
  /* @__PURE__ */ t("span", { className: "text-[11px] text-amber-600 dark:text-amber-400", children: "Roll every applied change back?" }),
1017
1015
  /* @__PURE__ */ t(
@@ -1159,62 +1157,62 @@ function jt({
1159
1157
  }
1160
1158
  function ar({
1161
1159
  collection: r,
1162
- item: m,
1163
- addendumLayoutId: v,
1164
- canCreate: k = !0,
1165
- onActiveCountChange: N,
1166
- onApplied: h,
1167
- onCreated: p,
1160
+ item: c,
1161
+ addendumLayoutId: N,
1162
+ canCreate: h = !0,
1163
+ onActiveCountChange: k,
1164
+ onApplied: u,
1165
+ onCreated: x,
1168
1166
  defaultExpanded: _ = !0
1169
1167
  }) {
1170
- const f = xe(), F = Qe(), [c, g] = j(!1), [C, w] = j(!_), [T, R] = j(!1), {
1168
+ const f = xe(), $ = Ue(), [m, v] = O(!1), [w, S] = O(!_), [D, j] = O(!1), {
1171
1169
  data: P = [],
1172
1170
  isLoading: J,
1173
1171
  refetch: ee
1174
1172
  } = V({
1175
- queryKey: ["addendums", r, m],
1176
- queryFn: () => f.request(Q(`/addendums/${r}/${m}`)).then((u) => u.data ?? []),
1173
+ queryKey: ["addendums", r, c],
1174
+ queryFn: () => f.request(U(`/addendums/${r}/${c}`)).then((p) => p.data ?? []),
1177
1175
  // The form reads this key first (staleTime 30 s); with none here the panel,
1178
1176
  // mounting just after, counted that answer stale and fetched it again.
1179
1177
  // Live sync and the panel's own writes invalidate it.
1180
1178
  staleTime: 3e4
1181
1179
  }), { data: A, isLoading: G } = V({
1182
- queryKey: ["addendum-layout", r, v ?? "default"],
1180
+ queryKey: ["addendum-layout", r, N ?? "default"],
1183
1181
  queryFn: async () => {
1184
- const u = await f.request(Q("/collection-layouts", { collection: r })).then((a) => (a.data ?? []).filter((s) => s.layout_type === "addendum"));
1185
- return v != null ? u.find((a) => a.id === v) ?? null : u[0] ?? null;
1182
+ const p = await f.request(U("/collection-layouts", { collection: r })).then((a) => (a.data ?? []).filter((s) => s.layout_type === "addendum"));
1183
+ return N != null ? p.find((a) => a.id === N) ?? null : p[0] ?? null;
1186
1184
  },
1187
1185
  staleTime: 300 * 1e3
1188
- }), M = v ?? (A == null ? void 0 : A.id) ?? null, te = !!M && (c || P.length > 0), { data: E = [], isPending: me } = V({
1186
+ }), M = N ?? (A == null ? void 0 : A.id) ?? null, te = !!M && (m || P.length > 0), { data: E = [], isPending: me } = V({
1189
1187
  queryKey: ["addendum-layout-assignments", M],
1190
1188
  queryFn: () => M ? f.request(
1191
- Q(`/collection-layouts/${M}/assignments`)
1192
- ).then((u) => u.data ?? []) : Promise.resolve([]),
1189
+ U(`/collection-layouts/${M}/assignments`)
1190
+ ).then((p) => p.data ?? []) : Promise.resolve([]),
1193
1191
  enabled: te,
1194
1192
  staleTime: 300 * 1e3
1195
1193
  }), { data: X = [], isPending: W } = V({
1196
1194
  queryKey: ["collection-fields", r, M],
1197
1195
  queryFn: () => f.request(
1198
- Q(
1196
+ U(
1199
1197
  `/field-config/${r}`,
1200
1198
  M ? { layout_id: String(M) } : void 0
1201
1199
  )
1202
- ).then((u) => u.data ?? []),
1200
+ ).then((p) => p.data ?? []),
1203
1201
  enabled: te,
1204
1202
  staleTime: 300 * 1e3
1205
- }), Y = c && M != null && (me || W), { data: L = [] } = V({
1203
+ }), Y = m && M != null && (me || W), { data: L = [] } = V({
1206
1204
  queryKey: ["relations", r],
1207
- queryFn: () => f.request(Q(`/data-model/relations/for/${r}`)).then((u) => u.data ?? []),
1205
+ queryFn: () => f.request(U(`/data-model/relations/for/${r}`)).then((p) => p.data ?? []),
1208
1206
  staleTime: 300 * 1e3
1209
1207
  }), { data: re, isLoading: se } = V({
1210
- queryKey: ["item", r, m],
1211
- queryFn: () => f.request(Q(`/items/${r}/${m}`)).then((u) => u.data ?? {}),
1212
- enabled: c,
1208
+ queryKey: ["item", r, c],
1209
+ queryFn: () => f.request(U(`/items/${r}/${c}`)).then((p) => p.data ?? {}),
1210
+ enabled: m,
1213
1211
  staleTime: 0
1214
1212
  }), ne = () => {
1215
- F.invalidateQueries({ queryKey: ["addendums", r, m] }), ee(), h == null || h();
1216
- }, ie = (u) => {
1217
- F.invalidateQueries({ queryKey: ["addendums", r, m] }), ee();
1213
+ $.invalidateQueries({ queryKey: ["addendums", r, c] }), ee(), u == null || u();
1214
+ }, ie = (p) => {
1215
+ $.invalidateQueries({ queryKey: ["addendums", r, c] }), ee();
1218
1216
  const a = E.find((d) => String(d.field) === "__pdf__");
1219
1217
  let s = null;
1220
1218
  if (a != null && a.overrides)
@@ -1223,67 +1221,67 @@ function ar({
1223
1221
  } catch {
1224
1222
  s = null;
1225
1223
  }
1226
- p == null || p({ id: u, pdfSlot: s });
1224
+ x == null || x({ id: p, pdfSlot: s });
1227
1225
  }, Z = E.filter(
1228
- (u) => !String(u.field).startsWith("__") && (u.is_visible || u.is_visible === 1)
1229
- ), U = P.filter(
1230
- (u) => !["approved", "rejected", "reverted"].includes(u.status)
1231
- ).length, O = Me(N);
1232
- return O.current = N, Be(() => {
1233
- var u;
1234
- (u = O.current) == null || u.call(O, U);
1235
- }, [U]), !k && (J || P.length === 0) ? null : /* @__PURE__ */ i(Ne, { children: [
1226
+ (p) => !String(p.field).startsWith("__") && (p.is_visible || p.is_visible === 1)
1227
+ ), Q = P.filter(
1228
+ (p) => !["approved", "rejected", "reverted"].includes(p.status)
1229
+ ).length, R = Me(k);
1230
+ return R.current = k, Be(() => {
1231
+ var p;
1232
+ (p = R.current) == null || p.call(R, Q);
1233
+ }, [Q]), !h && (J || P.length === 0) ? null : /* @__PURE__ */ i(Ne, { children: [
1236
1234
  /* @__PURE__ */ i(
1237
1235
  "div",
1238
1236
  {
1239
- className: D(
1237
+ className: T(
1240
1238
  "overflow-hidden rounded-xl border bg-white dark:bg-card",
1241
- U > 0 ? "border-amber-300 dark:border-amber-500/40" : "border-slate-200 dark:border-border"
1239
+ Q > 0 ? "border-amber-300 dark:border-amber-500/40" : "border-slate-200 dark:border-border"
1242
1240
  ),
1243
1241
  children: [
1244
1242
  /* @__PURE__ */ i(
1245
1243
  "div",
1246
1244
  {
1247
- className: D(
1245
+ className: T(
1248
1246
  "flex items-center justify-between px-4 py-3 cursor-pointer select-none",
1249
- !C && (U > 0 ? "border-b border-amber-200 dark:border-amber-500/30" : "border-b border-slate-200 dark:border-border")
1247
+ !w && (Q > 0 ? "border-b border-amber-200 dark:border-amber-500/30" : "border-b border-slate-200 dark:border-border")
1250
1248
  ),
1251
- onClick: () => w((u) => !u),
1249
+ onClick: () => S((p) => !p),
1252
1250
  children: [
1253
1251
  /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
1254
1252
  /* @__PURE__ */ t(Ze, { className: "h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500" }),
1255
1253
  /* @__PURE__ */ t("h3", { className: "text-[13px] font-medium text-slate-800 dark:text-slate-200", children: "Addendums" }),
1256
- U > 0 && /* @__PURE__ */ i("span", { className: "inline-flex items-center gap-1 rounded-full bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-700 border border-amber-200 dark:bg-amber-500/10 dark:text-amber-400 dark:border-amber-500/20", children: [
1254
+ Q > 0 && /* @__PURE__ */ i("span", { className: "inline-flex items-center gap-1 rounded-full bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-700 border border-amber-200 dark:bg-amber-500/10 dark:text-amber-400 dark:border-amber-500/20", children: [
1257
1255
  /* @__PURE__ */ t("span", { className: "h-1.5 w-1.5 rounded-full bg-amber-400 animate-pulse" }),
1258
- U,
1256
+ Q,
1259
1257
  " in review"
1260
1258
  ] }),
1261
- P.length >= 2 && !C && /* @__PURE__ */ t(
1259
+ P.length >= 2 && !w && /* @__PURE__ */ t(
1262
1260
  "button",
1263
1261
  {
1264
1262
  type: "button",
1265
- onClick: (u) => {
1266
- u.stopPropagation(), R((a) => !a);
1263
+ onClick: (p) => {
1264
+ p.stopPropagation(), j((a) => !a);
1267
1265
  },
1268
- className: D(
1266
+ className: T(
1269
1267
  "ml-1 rounded-md border px-2 py-0.5 text-[11px] font-medium transition-colors",
1270
- T ? "border-nvr-cyan bg-nvr-cyan/10 text-[#0b7ea6] dark:text-nvr-cyan" : "border-slate-200 text-slate-500 hover:border-slate-400 hover:text-slate-700 dark:border-border dark:text-slate-400"
1268
+ D ? "border-nvr-cyan bg-nvr-cyan/10 text-[#0b7ea6] dark:text-nvr-cyan" : "border-slate-200 text-slate-500 hover:border-slate-400 hover:text-slate-700 dark:border-border dark:text-slate-400"
1271
1269
  ),
1272
1270
  "data-tip": "Every addendum side by side — amount moved, fields touched, lines changed, running total",
1273
- "aria-pressed": T,
1274
- children: T ? "Cards" : "Compare"
1271
+ "aria-pressed": D,
1272
+ children: D ? "Cards" : "Compare"
1275
1273
  }
1276
1274
  )
1277
1275
  ] }),
1278
1276
  /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
1279
- k && (!(A != null && A.single_active_addendum) || U === 0) && /* @__PURE__ */ t(
1277
+ h && (!(A != null && A.single_active_addendum) || Q === 0) && /* @__PURE__ */ t(
1280
1278
  I,
1281
1279
  {
1282
1280
  size: "sm",
1283
1281
  variant: "outline",
1284
1282
  className: "h-7 text-[12px]",
1285
- onClick: (u) => {
1286
- u.stopPropagation(), g(!0);
1283
+ onClick: (p) => {
1284
+ p.stopPropagation(), v(!0);
1287
1285
  },
1288
1286
  children: "+ New Addendum"
1289
1287
  }
@@ -1291,9 +1289,9 @@ function ar({
1291
1289
  /* @__PURE__ */ t(
1292
1290
  et,
1293
1291
  {
1294
- className: D(
1292
+ className: T(
1295
1293
  "h-3.5 w-3.5 shrink-0 text-slate-400 transition-transform duration-150",
1296
- C && "-rotate-90"
1294
+ w && "-rotate-90"
1297
1295
  )
1298
1296
  }
1299
1297
  )
@@ -1301,61 +1299,61 @@ function ar({
1301
1299
  ]
1302
1300
  }
1303
1301
  ),
1304
- !C && !A && !G && /* @__PURE__ */ i("div", { className: "px-4 py-4 text-center", children: [
1302
+ !w && !A && !G && /* @__PURE__ */ i("div", { className: "px-4 py-4 text-center", children: [
1305
1303
  /* @__PURE__ */ t("p", { className: "text-[12px] text-slate-400", children: "No addendum form configured." }),
1306
1304
  /* @__PURE__ */ t("p", { className: "text-[11px] text-slate-300 dark:text-slate-600", children: 'Create an "Addendum Form" layout in Data Model → Layouts to enable addendum creation.' })
1307
1305
  ] }),
1308
- !C && (A || G) && (J ? /* @__PURE__ */ i("div", { className: "p-4 space-y-2", children: [
1306
+ !w && (A || G) && (J ? /* @__PURE__ */ i("div", { className: "p-4 space-y-2", children: [
1309
1307
  /* @__PURE__ */ t(le, { className: "h-12 w-full" }),
1310
1308
  /* @__PURE__ */ t(le, { className: "h-12 w-full" })
1311
1309
  ] }) : P.length === 0 ? /* @__PURE__ */ i("div", { className: "px-4 py-8 text-center", children: [
1312
1310
  /* @__PURE__ */ t("p", { className: "text-[12px] text-slate-400 dark:text-slate-500", children: "No addendum attached to this record" }),
1313
1311
  /* @__PURE__ */ t("p", { className: "mt-0.5 text-[11px] text-slate-300 dark:text-slate-600", children: "Addendums propose changes that go through a review process before being applied." })
1314
- ] }) : T && P.length >= 2 ? /* @__PURE__ */ t("div", { className: "p-3", children: /* @__PURE__ */ t(
1312
+ ] }) : D && P.length >= 2 ? /* @__PURE__ */ t("div", { className: "p-3", children: /* @__PURE__ */ t(
1315
1313
  Nt,
1316
1314
  {
1317
1315
  client: f,
1318
1316
  addendums: P,
1319
1317
  parentCollection: r,
1320
- parentId: m,
1318
+ parentId: c,
1321
1319
  relations: L,
1322
- fieldMap: Object.fromEntries(X.map((u) => [u.field, u]))
1320
+ fieldMap: Object.fromEntries(X.map((p) => [p.field, p]))
1323
1321
  }
1324
- ) }) : /* @__PURE__ */ t("div", { className: "p-3 space-y-2", children: P.map((u) => /* @__PURE__ */ t(
1322
+ ) }) : /* @__PURE__ */ t("div", { className: "p-3 space-y-2", children: P.map((p) => /* @__PURE__ */ t(
1325
1323
  jt,
1326
1324
  {
1327
- addendum: u,
1325
+ addendum: p,
1328
1326
  configuredFields: Z,
1329
1327
  onRefresh: ne,
1330
- isActive: !["approved", "rejected", "reverted"].includes(u.status),
1328
+ isActive: !["approved", "rejected", "reverted"].includes(p.status),
1331
1329
  relations: L,
1332
1330
  parentCollection: r,
1333
- parentId: m,
1331
+ parentId: c,
1334
1332
  fieldMap: Object.fromEntries(X.map((a) => [a.field, a]))
1335
1333
  },
1336
- u.id
1334
+ p.id
1337
1335
  )) }))
1338
1336
  ]
1339
1337
  }
1340
1338
  ),
1341
- /* @__PURE__ */ t(xt, { open: c, onOpenChange: g, children: /* @__PURE__ */ t(bt, { side: "right", className: "w-[80vw] sm:max-w-[80vw] p-0 flex flex-col", children: c && (se || Y) ? /* @__PURE__ */ i("div", { className: "flex flex-col gap-3 p-6", children: [
1339
+ /* @__PURE__ */ t(xt, { open: m, onOpenChange: v, children: /* @__PURE__ */ t(bt, { side: "right", className: "w-[80vw] sm:max-w-[80vw] p-0 flex flex-col", children: m && (se || Y) ? /* @__PURE__ */ i("div", { className: "flex flex-col gap-3 p-6", children: [
1342
1340
  /* @__PURE__ */ t(le, { className: "h-6 w-48" }),
1343
1341
  /* @__PURE__ */ t(le, { className: "h-9 w-full" }),
1344
1342
  /* @__PURE__ */ t(le, { className: "h-9 w-full" }),
1345
1343
  /* @__PURE__ */ t(le, { className: "h-9 w-full" }),
1346
1344
  /* @__PURE__ */ t(le, { className: "h-9 w-3/4" })
1347
- ] }) : c && re ? /* @__PURE__ */ t(
1345
+ ] }) : m && re ? /* @__PURE__ */ t(
1348
1346
  At,
1349
1347
  {
1350
1348
  collection: r,
1351
- itemId: m,
1349
+ itemId: c,
1352
1350
  assignments: E,
1353
1351
  workflowTemplateId: (A == null ? void 0 : A.workflow_template_id) ?? null,
1354
1352
  resolvedLayoutId: M,
1355
1353
  fields: X,
1356
1354
  relations: L,
1357
1355
  parentData: re,
1358
- onClose: () => g(!1),
1356
+ onClose: () => v(!1),
1359
1357
  onCreated: ie
1360
1358
  }
1361
1359
  ) : null }) })