@nivaro/react 0.3.104 → 0.3.106

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