@nivaro/react 0.3.34 → 0.3.35

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,30 +1,31 @@
1
- import { jsxs as c, jsx as n } from "react/jsx-runtime";
2
- import { useQueryClient as Ke, useQueries as pt, useQuery as ie, useMutation as ht } from "@tanstack/react-query";
3
- import { Info as xt, Loader2 as ft, Sparkles as yt, Lock as bt, SlidersHorizontal as gt, MoreHorizontal as vt, History as wt, BellRing as kt, Bell as _t, Sigma as Nt } from "lucide-react";
4
- import { memo as Ft, useState as be, useRef as R, useId as Ct, useEffect as ae, useCallback as Oe } from "react";
5
- import { toast as K } from "sonner";
6
- import { useParentDraft as Lt, useNivaroClient as oe } from "../../context.js";
7
- import { showsAiButton as Rt, AUTOFILL_CHECK_KEY as St, readAiFill as $t } from "../../lib/ai-fill.js";
8
- import { get as U, del as Tt, post as ye } from "../../lib/commands.js";
9
- import { titleCase as fe, cn as A } from "../../lib/utils.js";
10
- import { GlossaryLabel as De } from "../ai/GlossaryText.js";
11
- import { Label as qt } from "../ui/label.js";
1
+ import { jsxs as c, jsx as r } from "react/jsx-runtime";
2
+ import { useQueryClient as We, useQueries as xt, useQuery as le, useMutation as ft } from "@tanstack/react-query";
3
+ import { Info as yt, Loader2 as bt, Sparkles as gt, Lock as vt, SlidersHorizontal as wt, History as kt, BellRing as _t, Bell as Nt, Sigma as Ft } from "lucide-react";
4
+ import { memo as Ct, useState as we, useRef as R, useId as Lt, useEffect as ae, useCallback as Me } from "react";
5
+ import { toast as U } from "sonner";
6
+ import { useParentDraft as Rt, useNivaroClient as oe } from "../../context.js";
7
+ import { showsAiButton as St, AUTOFILL_CHECK_KEY as $t, readAiFill as qt } from "../../lib/ai-fill.js";
8
+ import { get as H, del as Tt, post as ve } from "../../lib/commands.js";
9
+ import { titleCase as ge, cn as D } from "../../lib/utils.js";
10
+ import { GlossaryLabel as Ke } from "../ai/GlossaryText.js";
11
+ import { Label as At } from "../ui/label.js";
12
12
  import { TooltipProvider as ee, Tooltip as te, TooltipTrigger as ne, TooltipContent as re } from "../ui/tooltip.js";
13
- import { useAddendumFields as At } from "./AddendumFieldContext.js";
13
+ import { useAddendumFields as Et } from "./AddendumFieldContext.js";
14
14
  import { AutoIdPreviewField as Pt } from "./AutoIdPreviewField.js";
15
- import { FOCUSABLE as Be } from "./entry/entry-keys.js";
16
- import { useFieldAffordances as Et, useFieldContextMenu as jt, usePresenceSoftLock as Mt, LockReasonBadge as Ot, PresenceSoftLockStrip as Dt, RemoteChangeGhost as Bt } from "./FieldAffordances.js";
17
- import { FieldRenderer as Ht } from "./FieldRenderer.js";
18
- import { FormHelpVideoButton as Kt } from "./FormHelpVideoButton.js";
19
- import { getCascadeFilters as Ut, SYSTEM_FIELDS as Wt, parseJson as zt, buildCascadeFilter as Vt, CascadeEffectController as Gt } from "./helpers.js";
20
- import { isDerivedForRecord as Qt } from "./live-rollups.js";
21
- import { useM2MStaging as Yt } from "./M2MStagingContext.js";
22
- import { PersonalDefaultPill as Jt, PersonalDefaultHint as It } from "./PersonalDefaultPill.js";
23
- import { isDisplayFormulaRow as He, usePlacementTextContext as Xt, placementFieldText as Zt, fieldCounterConfig as en, fieldIsRecommended as tn, RecommendedMarker as nn, RepeatLastButton as rn, DisplayFormulaValue as an, FieldCounter as on } from "./placement-behaviour.js";
24
- import { keepIfEqual as ln, jsonEqual as sn } from "./render-stability.js";
25
- import { usePersonalDefaultsApi as dn } from "./usePersonalDefaults.js";
26
- import { resolveOptionFilterTokens as cn } from "../../lib/option-filter-tokens.js";
27
- const un = /* @__PURE__ */ new Set(["integer", "float", "decimal", "bigInteger", "number"]), mn = /* @__PURE__ */ new Set(["string", "text", "richtext", "textarea", "markdown", "json", "csv"]), pn = /* @__PURE__ */ new Set([
15
+ import { FOCUSABLE as Ue } from "./entry/entry-keys.js";
16
+ import { useFieldAffordances as jt, useFieldContextMenu as Dt, usePresenceSoftLock as Ot, LockReasonBadge as Bt, PresenceSoftLockStrip as Mt, RemoteChangeGhost as Kt } from "./FieldAffordances.js";
17
+ import { FieldRenderer as Ut } from "./FieldRenderer.js";
18
+ import { FormHelpVideoButton as Ht } from "./FormHelpVideoButton.js";
19
+ import { getCascadeFilters as Wt, SYSTEM_FIELDS as Vt, parseJson as zt, buildCascadeFilter as Gt, CascadeEffectController as Qt } from "./helpers.js";
20
+ import { isDerivedForRecord as Yt } from "./live-rollups.js";
21
+ import { useM2MStaging as Jt } from "./M2MStagingContext.js";
22
+ import { personalDefaultSlotFor as Xt, PersonalDefaultSlot as Zt } from "./PersonalDefaultControl.js";
23
+ import { PersonalDefaultHint as It } from "./PersonalDefaultPill.js";
24
+ import { isDisplayFormulaRow as He, usePlacementTextContext as en, placementFieldText as tn, fieldCounterConfig as nn, fieldIsRecommended as rn, RecommendedMarker as ln, RepeatLastButton as an, DisplayFormulaValue as on, FieldCounter as sn } from "./placement-behaviour.js";
25
+ import { keepIfEqual as dn, jsonEqual as cn } from "./render-stability.js";
26
+ import { usePersonalDefaultsApi as un } from "./usePersonalDefaults.js";
27
+ import { resolveOptionFilterTokens as mn } from "../../lib/option-filter-tokens.js";
28
+ const pn = /* @__PURE__ */ new Set(["integer", "float", "decimal", "bigInteger", "number"]), hn = /* @__PURE__ */ new Set(["string", "text", "richtext", "textarea", "markdown", "json", "csv"]), xn = /* @__PURE__ */ new Set([
28
29
  "input",
29
30
  "textarea",
30
31
  "wysiwyg",
@@ -32,7 +33,7 @@ const un = /* @__PURE__ */ new Set(["integer", "float", "decimal", "bigInteger",
32
33
  "input-rich-text-html",
33
34
  "rich_text",
34
35
  "extension-editorjs"
35
- ]), hn = /* @__PURE__ */ new Set([
36
+ ]), fn = /* @__PURE__ */ new Set([
36
37
  "relation-m2o",
37
38
  "relation-m2m",
38
39
  "select-multiple-m2m",
@@ -43,24 +44,24 @@ const un = /* @__PURE__ */ new Set(["integer", "float", "decimal", "bigInteger",
43
44
  "file",
44
45
  "files",
45
46
  "image"
46
- ]), xn = /* @__PURE__ */ new Set(["file", "file-image", "files-m2m", "files", "image"]);
47
- function fn(d) {
47
+ ]), yn = /* @__PURE__ */ new Set(["file", "file-image", "files-m2m", "files", "image"]);
48
+ function bn(d) {
48
49
  const e = d.interface ?? "";
49
- return hn.has(e) || e.startsWith("relation-") || e.endsWith("-m2o") || e.endsWith("-m2m") ? !1 : !!(mn.has(d.type ?? "") || pn.has(e) || !e && d.type && !un.has(d.type));
50
+ return fn.has(e) || e.startsWith("relation-") || e.endsWith("-m2o") || e.endsWith("-m2m") ? !1 : !!(hn.has(d.type ?? "") || xn.has(e) || !e && d.type && !pn.has(d.type));
50
51
  }
51
- function yn(d, e, m, h) {
52
+ function gn(d, e, m, p) {
52
53
  const f = oe();
53
- return ie({
54
+ return le({
54
55
  queryKey: ["field-lineage", d, e, m],
55
56
  queryFn: () => f.request(
56
- U(`/lineage/${d}/${encodeURIComponent(e)}/${m}`)
57
- ).then((l) => l.data),
58
- enabled: h,
57
+ H(`/lineage/${d}/${encodeURIComponent(e)}/${m}`)
58
+ ).then((i) => i.data),
59
+ enabled: p,
59
60
  staleTime: 3e4
60
61
  });
61
62
  }
62
- function Qn(d, e = "rows") {
63
- var i, N, b;
63
+ function Xn(d, e = "rows") {
64
+ var l, N, b;
64
65
  if (d && (d.kind === "write" || d.kind === "read") && d.formula) {
65
66
  const u = (y) => typeof y == "number" ? y.toLocaleString(void 0, { maximumFractionDigits: 2 }) : y == null || y === "" ? "∅" : String(y);
66
67
  return `= ${d.formula.replace(/item\.([A-Za-z_][A-Za-z0-9_]*)/g, (y, a) => {
@@ -69,63 +70,63 @@ function Qn(d, e = "rows") {
69
70
  }).replace(/\s*-\s*/g, " − ").replace(/\s*\*\s*/g, " × ").replace(/\s*\/\s*/g, " ÷ ")}`;
70
71
  }
71
72
  if (!d || d.kind !== "rollup") return null;
72
- const m = (d.sources ?? []).reduce((u, o) => u + o.rows.length, 0), h = (d.sources ?? []).reduce((u, o) => {
73
+ const m = (d.sources ?? []).reduce((u, o) => u + o.rows.length, 0), p = (d.sources ?? []).reduce((u, o) => {
73
74
  var y;
74
75
  return u + (((y = o.excluded) == null ? void 0 : y.length) ?? 0);
75
- }, 0), f = (b = (N = (i = (d.sources ?? []).find((u) => {
76
+ }, 0), f = (b = (N = (l = (d.sources ?? []).find((u) => {
76
77
  var o;
77
78
  return (o = u.excluded) == null ? void 0 : o.length;
78
- })) == null ? void 0 : i.excluded) == null ? void 0 : N[0]) == null ? void 0 : b.reason, l = [`= ${m} ${m === 1 ? e.replace(/s$/, "") : e}`];
79
- return h && l.push(
80
- `${h} excluded${f ? ` (${f.replace(/^does not match: /, "")})` : ""}`
81
- ), l.join(" · ");
79
+ })) == null ? void 0 : l.excluded) == null ? void 0 : N[0]) == null ? void 0 : b.reason, i = [`= ${m} ${m === 1 ? e.replace(/s$/, "") : e}`];
80
+ return p && i.push(
81
+ `${p} excluded${f ? ` (${f.replace(/^does not match: /, "")})` : ""}`
82
+ ), i.join(" · ");
82
83
  }
83
- function bn({
84
+ function vn({
84
85
  collection: d,
85
86
  itemId: e,
86
87
  field: m
87
88
  }) {
88
- const [h, f] = be(!1), l = R(null), { data: i, isLoading: N } = yn(d, e, m, h);
89
+ const [p, f] = we(!1), i = R(null), { data: l, isLoading: N } = gn(d, e, m, p);
89
90
  ae(() => {
90
- if (!h) return;
91
+ if (!p) return;
91
92
  const o = (y) => {
92
93
  var a;
93
- (a = l.current) != null && a.contains(y.target) || f(!1);
94
+ (a = i.current) != null && a.contains(y.target) || f(!1);
94
95
  };
95
96
  return window.addEventListener("mousedown", o), () => window.removeEventListener("mousedown", o);
96
- }, [h]);
97
- const b = (o) => o == null ? "—" : Number(o).toLocaleString(void 0, { maximumFractionDigits: 2 }), u = (i == null ? void 0 : i.stored_value) != null ? Number(i.stored_value) : null;
98
- return /* @__PURE__ */ c("div", { ref: l, className: "relative inline-flex", children: [
99
- /* @__PURE__ */ n(
97
+ }, [p]);
98
+ const b = (o) => o == null ? "—" : Number(o).toLocaleString(void 0, { maximumFractionDigits: 2 }), u = (l == null ? void 0 : l.stored_value) != null ? Number(l.stored_value) : null;
99
+ return /* @__PURE__ */ c("div", { ref: i, className: "relative inline-flex", children: [
100
+ /* @__PURE__ */ r(
100
101
  "button",
101
102
  {
102
103
  type: "button",
103
104
  onClick: () => f((o) => !o),
104
105
  title: "Where does this number come from?",
105
- className: A(
106
+ className: D(
106
107
  "inline-flex items-center rounded p-0.5 transition-opacity",
107
- h ? "text-nvr-cyan opacity-100" : "text-slate-400 hover:text-nvr-cyan dark:text-slate-300 dark:hover:text-nvr-cyan"
108
+ p ? "text-nvr-cyan opacity-100" : "text-slate-400 hover:text-nvr-cyan dark:text-slate-300 dark:hover:text-nvr-cyan"
108
109
  ),
109
110
  "data-field-lineage": !0,
110
- children: /* @__PURE__ */ n(Nt, { className: "h-3 w-3" })
111
+ children: /* @__PURE__ */ r(Ft, { className: "h-3 w-3" })
111
112
  }
112
113
  ),
113
- h && /* @__PURE__ */ c("div", { className: "absolute left-0 top-full z-40 mt-1 max-h-[340px] w-[360px] overflow-y-auto rounded-lg border border-slate-200 bg-white p-2 shadow-lg dark:border-border dark:bg-card", children: [
114
- /* @__PURE__ */ n("p", { className: "mb-1 px-1 text-[10px] font-semibold uppercase tracking-wide text-slate-400", children: "Where this number comes from" }),
115
- N && /* @__PURE__ */ n("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "Loading…" }),
116
- (i == null ? void 0 : i.kind) === "write" && /* @__PURE__ */ c("div", { className: "space-y-1 px-1 py-1", children: [
117
- /* @__PURE__ */ n("p", { className: "font-mono text-[11px] text-slate-600 dark:text-slate-300", children: i.formula }),
118
- Object.entries(i.inputs ?? {}).map(([o, y]) => /* @__PURE__ */ c("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
119
- /* @__PURE__ */ n("span", { className: "font-mono", children: o }),
114
+ p && /* @__PURE__ */ c("div", { className: "absolute left-0 top-full z-40 mt-1 max-h-[340px] w-[360px] overflow-y-auto rounded-lg border border-slate-200 bg-white p-2 shadow-lg dark:border-border dark:bg-card", children: [
115
+ /* @__PURE__ */ r("p", { className: "mb-1 px-1 text-[10px] font-semibold uppercase tracking-wide text-slate-400", children: "Where this number comes from" }),
116
+ N && /* @__PURE__ */ r("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "Loading…" }),
117
+ (l == null ? void 0 : l.kind) === "write" && /* @__PURE__ */ c("div", { className: "space-y-1 px-1 py-1", children: [
118
+ /* @__PURE__ */ r("p", { className: "font-mono text-[11px] text-slate-600 dark:text-slate-300", children: l.formula }),
119
+ Object.entries(l.inputs ?? {}).map(([o, y]) => /* @__PURE__ */ c("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
120
+ /* @__PURE__ */ r("span", { className: "font-mono", children: o }),
120
121
  " = ",
121
122
  b(y)
122
123
  ] }, o)),
123
124
  /* @__PURE__ */ c("p", { className: "pt-1 text-[11.5px] font-medium text-slate-700 dark:text-slate-200", children: [
124
125
  "= ",
125
- b(i.stored_value)
126
+ b(l.stored_value)
126
127
  ] })
127
128
  ] }),
128
- (i == null ? void 0 : i.kind) === "rollup" && (i.sources ?? []).map((o, y) => {
129
+ (l == null ? void 0 : l.kind) === "rollup" && (l.sources ?? []).map((o, y) => {
129
130
  var a;
130
131
  return /* @__PURE__ */ c("div", { className: "mb-1.5", children: [
131
132
  /* @__PURE__ */ c("p", { className: "px-1 text-[10.5px] text-slate-400", children: [
@@ -135,16 +136,16 @@ function bn({
135
136
  o.collection,
136
137
  o.filtered ? " (filtered)" : ""
137
138
  ] }),
138
- o.error && /* @__PURE__ */ n("p", { className: "px-1 py-1 text-[11.5px] text-amber-600 dark:text-amber-400", children: o.error }),
139
- o.note && /* @__PURE__ */ n("p", { className: "px-1 py-1 text-[11.5px] text-slate-400", children: o.note }),
140
- o.rows.length > 0 && /* @__PURE__ */ n("div", { className: "mt-0.5 space-y-px", children: o.rows.map((x) => /* @__PURE__ */ c(
139
+ o.error && /* @__PURE__ */ r("p", { className: "px-1 py-1 text-[11.5px] text-amber-600 dark:text-amber-400", children: o.error }),
140
+ o.note && /* @__PURE__ */ r("p", { className: "px-1 py-1 text-[11.5px] text-slate-400", children: o.note }),
141
+ o.rows.length > 0 && /* @__PURE__ */ r("div", { className: "mt-0.5 space-y-px", children: o.rows.map((x) => /* @__PURE__ */ c(
141
142
  "div",
142
143
  {
143
144
  className: "flex items-baseline gap-2 rounded px-1 py-0.5 text-[11.5px] hover:bg-slate-50 dark:hover:bg-muted",
144
145
  children: [
145
- /* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate text-slate-600 dark:text-slate-300", children: x.label }),
146
- /* @__PURE__ */ n("span", { className: "shrink-0 font-mono tabular-nums text-slate-800 dark:text-slate-100", children: b(x.value) }),
147
- /* @__PURE__ */ n(
146
+ /* @__PURE__ */ r("span", { className: "min-w-0 flex-1 truncate text-slate-600 dark:text-slate-300", children: x.label }),
147
+ /* @__PURE__ */ r("span", { className: "shrink-0 font-mono tabular-nums text-slate-800 dark:text-slate-100", children: b(x.value) }),
148
+ /* @__PURE__ */ r(
148
149
  "span",
149
150
  {
150
151
  className: "w-[88px] shrink-0 truncate text-right text-[10px] text-slate-400",
@@ -156,7 +157,7 @@ function bn({
156
157
  },
157
158
  x.id
158
159
  )) }),
159
- o.truncated && /* @__PURE__ */ n("p", { className: "px-1 pt-0.5 text-[10.5px] text-amber-600 dark:text-amber-400", children: "Showing the first 200 rows — the subtotal covers only these." }),
160
+ o.truncated && /* @__PURE__ */ r("p", { className: "px-1 pt-0.5 text-[10.5px] text-amber-600 dark:text-amber-400", children: "Showing the first 200 rows — the subtotal covers only these." }),
160
161
  o.subtotal != null && /* @__PURE__ */ c("p", { className: "border-t border-slate-100 px-1 pt-1 text-right text-[11.5px] font-medium text-slate-700 dark:border-border dark:text-slate-200", children: [
161
162
  "subtotal ",
162
163
  b(o.subtotal)
@@ -173,8 +174,8 @@ function bn({
173
174
  {
174
175
  className: "flex items-baseline gap-2 px-0.5 text-[11px] text-slate-400",
175
176
  children: [
176
- /* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate line-through decoration-slate-300", children: x.label }),
177
- /* @__PURE__ */ n("span", { className: "shrink-0 font-mono tabular-nums", children: b(x.value) })
177
+ /* @__PURE__ */ r("span", { className: "min-w-0 flex-1 truncate line-through decoration-slate-300", children: x.label }),
178
+ /* @__PURE__ */ r("span", { className: "shrink-0 font-mono tabular-nums", children: b(x.value) })
178
179
  ]
179
180
  },
180
181
  x.id
@@ -187,64 +188,64 @@ function bn({
187
188
  ] })
188
189
  ] }, y);
189
190
  }),
190
- (i == null ? void 0 : i.kind) === "rollup" && u != null && /* @__PURE__ */ c("p", { className: "px-1 pt-0.5 text-right text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
191
+ (l == null ? void 0 : l.kind) === "rollup" && u != null && /* @__PURE__ */ c("p", { className: "px-1 pt-0.5 text-right text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
191
192
  "stored ",
192
193
  b(u),
193
194
  (() => {
194
- const o = (i.sources ?? []).reduce((a, x) => a + (x.subtotal ?? 0), 0);
195
- return (i.sources ?? []).some((a) => a.truncated) ? null : Math.abs(o - u) < 0.01 ? /* @__PURE__ */ n("span", { className: "ml-1 text-emerald-600 dark:text-emerald-400", children: "✓ matches" }) : /* @__PURE__ */ n("span", { className: "ml-1 text-amber-600 dark:text-amber-400", children: "✕ differs from contributions" });
195
+ const o = (l.sources ?? []).reduce((a, x) => a + (x.subtotal ?? 0), 0);
196
+ return (l.sources ?? []).some((a) => a.truncated) ? null : Math.abs(o - u) < 0.01 ? /* @__PURE__ */ r("span", { className: "ml-1 text-emerald-600 dark:text-emerald-400", children: "✓ matches" }) : /* @__PURE__ */ r("span", { className: "ml-1 text-amber-600 dark:text-amber-400", children: "✕ differs from contributions" });
196
197
  })()
197
198
  ] })
198
199
  ] })
199
200
  ] });
200
201
  }
201
- function gn({
202
+ function wn({
202
203
  collection: d,
203
204
  itemId: e,
204
205
  field: m,
205
- formatValue: h,
206
+ formatValue: p,
206
207
  onRestore: f
207
208
  }) {
208
- const l = oe(), [i, N] = be(!1), b = R(null), { data: u, isLoading: o } = ie({
209
+ const i = oe(), [l, N] = we(!1), b = R(null), { data: u, isLoading: o } = le({
209
210
  queryKey: ["field-value-history", d, e, m],
210
- queryFn: () => l.request(U(`/field-history/${d}/${encodeURIComponent(e)}/${m}`)).then((a) => a.data ?? []),
211
- enabled: i,
211
+ queryFn: () => i.request(H(`/field-history/${d}/${encodeURIComponent(e)}/${m}`)).then((a) => a.data ?? []),
212
+ enabled: l,
212
213
  staleTime: 6e4
213
214
  });
214
215
  ae(() => {
215
- if (!i) return;
216
+ if (!l) return;
216
217
  const a = (x) => {
217
218
  var W;
218
219
  (W = b.current) != null && W.contains(x.target) || N(!1);
219
220
  };
220
221
  return window.addEventListener("mousedown", a), () => window.removeEventListener("mousedown", a);
221
- }, [i]);
222
- const y = (a, x) => x || (a == null || a === "" ? "—" : h ? h(a) : typeof a == "boolean" || a === "true" || a === "false" ? a === !0 || a === "true" ? "Yes" : "No" : typeof a == "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(a) ? new Date(a).toLocaleString() : typeof a == "object" ? JSON.stringify(a).slice(0, 60) : String(a).slice(0, 80));
222
+ }, [l]);
223
+ const y = (a, x) => x || (a == null || a === "" ? "—" : p ? p(a) : typeof a == "boolean" || a === "true" || a === "false" ? a === !0 || a === "true" ? "Yes" : "No" : typeof a == "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(a) ? new Date(a).toLocaleString() : typeof a == "object" ? JSON.stringify(a).slice(0, 60) : String(a).slice(0, 80));
223
224
  return /* @__PURE__ */ c("div", { ref: b, className: "relative inline-flex", children: [
224
- /* @__PURE__ */ n(
225
+ /* @__PURE__ */ r(
225
226
  "button",
226
227
  {
227
228
  type: "button",
228
229
  onClick: () => N((a) => !a),
229
230
  title: "Value history",
230
- className: A(
231
+ className: D(
231
232
  "inline-flex items-center rounded p-0.5 transition-opacity",
232
- i ? "text-nvr-cyan opacity-100" : "text-slate-400 hover:text-nvr-cyan dark:text-slate-300 dark:hover:text-nvr-cyan"
233
+ l ? "text-nvr-cyan opacity-100" : "text-slate-400 hover:text-nvr-cyan dark:text-slate-300 dark:hover:text-nvr-cyan"
233
234
  ),
234
235
  "data-field-history": !0,
235
- children: /* @__PURE__ */ n(wt, { className: "h-3 w-3" })
236
+ children: /* @__PURE__ */ r(kt, { className: "h-3 w-3" })
236
237
  }
237
238
  ),
238
- i && /* @__PURE__ */ c("div", { className: "absolute left-0 top-full z-40 mt-1 max-h-64 w-[300px] overflow-y-auto rounded-lg border border-slate-200 bg-white p-2 shadow-lg dark:border-border dark:bg-card", children: [
239
- /* @__PURE__ */ n("p", { className: "mb-1 px-1 text-[10px] font-semibold uppercase tracking-wide text-slate-400", children: "Value history" }),
240
- o ? /* @__PURE__ */ n("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "Loading…" }) : (u ?? []).length === 0 ? /* @__PURE__ */ n("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "No recorded changes for this field." }) : /* @__PURE__ */ n("div", { className: "space-y-1", children: (u ?? []).map((a, x) => /* @__PURE__ */ c(
239
+ l && /* @__PURE__ */ c("div", { className: "absolute left-0 top-full z-40 mt-1 max-h-64 w-[300px] overflow-y-auto rounded-lg border border-slate-200 bg-white p-2 shadow-lg dark:border-border dark:bg-card", children: [
240
+ /* @__PURE__ */ r("p", { className: "mb-1 px-1 text-[10px] font-semibold uppercase tracking-wide text-slate-400", children: "Value history" }),
241
+ o ? /* @__PURE__ */ r("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "Loading…" }) : (u ?? []).length === 0 ? /* @__PURE__ */ r("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "No recorded changes for this field." }) : /* @__PURE__ */ r("div", { className: "space-y-1", children: (u ?? []).map((a, x) => /* @__PURE__ */ c(
241
242
  "div",
242
243
  {
243
244
  className: "rounded px-1 py-1 text-[11.5px] leading-snug hover:bg-slate-50 dark:hover:bg-muted",
244
245
  children: [
245
246
  /* @__PURE__ */ c("span", { className: "flex items-baseline justify-between gap-2", children: [
246
- /* @__PURE__ */ n("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: y(a.value, a.display) }),
247
- f && x > 0 && /* @__PURE__ */ n(
247
+ /* @__PURE__ */ r("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: y(a.value, a.display) }),
248
+ f && x > 0 && /* @__PURE__ */ r(
248
249
  "button",
249
250
  {
250
251
  type: "button",
@@ -260,7 +261,7 @@ function gn({
260
261
  a.action === "create" ? "initial value" : "changed",
261
262
  a.timestamp ? ` · ${new Date(a.timestamp).toLocaleString()}` : "",
262
263
  a.user_name ? ` · ${a.user_name}` : "",
263
- a.origin && a.origin.kind !== "user" && /* @__PURE__ */ n(
264
+ a.origin && a.origin.kind !== "user" && /* @__PURE__ */ r(
264
265
  "span",
265
266
  {
266
267
  className: a.origin.kind === "integration" ? "ml-1 rounded bg-purple-500/10 px-1 py-px text-[9.5px] font-medium text-purple-700 dark:text-purple-400" : a.origin.kind === "import" ? "ml-1 rounded bg-sky-500/10 px-1 py-px text-[9.5px] font-medium text-sky-700 dark:text-sky-400" : "ml-1 rounded bg-amber-500/10 px-1 py-px text-[9.5px] font-medium text-amber-700 dark:text-amber-400",
@@ -280,34 +281,34 @@ function gn({
280
281
  ] })
281
282
  ] });
282
283
  }
283
- function vn({
284
+ function kn({
284
285
  collection: d,
285
286
  itemId: e,
286
287
  field: m
287
288
  }) {
288
- const h = oe(), f = Ke(), { data: l } = ie({
289
+ const p = oe(), f = We(), { data: i } = le({
289
290
  queryKey: ["field-watch-config"],
290
- queryFn: () => h.request(U("/field-watches/config")).then((o) => o.data).catch(() => ({ enabled: !1 })),
291
+ queryFn: () => p.request(H("/field-watches/config")).then((o) => o.data).catch(() => ({ enabled: !1 })),
291
292
  staleTime: 5 * 6e4
292
- }), i = ["field-watch-self", d, e], { data: N = [] } = ie({
293
- queryKey: i,
294
- queryFn: () => h.request(U("/field-watches/self", { collection: d, item_id: e })).then((o) => o.data ?? []).catch(() => []),
295
- enabled: !!(l != null && l.enabled),
293
+ }), l = ["field-watch-self", d, e], { data: N = [] } = le({
294
+ queryKey: l,
295
+ queryFn: () => p.request(H("/field-watches/self", { collection: d, item_id: e })).then((o) => o.data ?? []).catch(() => []),
296
+ enabled: !!(i != null && i.enabled),
296
297
  staleTime: 6e4
297
- }), b = N.includes(m), u = ht({
298
- mutationFn: () => b ? h.request(
298
+ }), b = N.includes(m), u = ft({
299
+ mutationFn: () => b ? p.request(
299
300
  Tt(
300
301
  `/field-watches/self?collection=${encodeURIComponent(d)}&field=${encodeURIComponent(m)}&item_id=${encodeURIComponent(e)}`
301
302
  )
302
- ) : h.request(ye("/field-watches/self", { collection: d, field: m, item_id: e })),
303
+ ) : p.request(ve("/field-watches/self", { collection: d, field: m, item_id: e })),
303
304
  onSuccess: () => {
304
- f.invalidateQueries({ queryKey: i }), K.success(
305
+ f.invalidateQueries({ queryKey: l }), U.success(
305
306
  b ? "No longer watching this field" : "Watching — you will be notified when it changes"
306
307
  );
307
308
  },
308
- onError: () => K.error("Could not update the watch")
309
+ onError: () => U.error("Could not update the watch")
309
310
  });
310
- return l != null && l.enabled ? /* @__PURE__ */ n(
311
+ return i != null && i.enabled ? /* @__PURE__ */ r(
311
312
  "button",
312
313
  {
313
314
  type: "button",
@@ -315,22 +316,22 @@ function vn({
315
316
  title: b ? "Stop watching this field on this record" : "Watch this field on this record",
316
317
  "data-field-watch": m,
317
318
  className: `rounded p-0.5 transition-colors ${b ? "text-nvr-navy dark:text-nvr-cyan" : "text-slate-300 hover:text-slate-500"}`,
318
- children: b ? /* @__PURE__ */ n(kt, { className: "h-3 w-3" }) : /* @__PURE__ */ n(_t, { className: "h-3 w-3" })
319
+ children: b ? /* @__PURE__ */ r(_t, { className: "h-3 w-3" }) : /* @__PURE__ */ r(Nt, { className: "h-3 w-3" })
319
320
  }
320
321
  ) : null;
321
322
  }
322
- function wn(d) {
323
+ function _n(d) {
323
324
  return d ? d.querySelector(
324
325
  'input:not([type=hidden]), textarea, [role="combobox"], [contenteditable="true"]'
325
326
  ) ?? d.querySelector("button") : null;
326
327
  }
327
- const Yn = Ft(function({
328
+ const Zn = Ct(function({
328
329
  field: e,
329
330
  draft: m,
330
- onChange: h,
331
+ onChange: p,
331
332
  relations: f,
332
- collection: l,
333
- itemId: i,
333
+ collection: i,
334
+ itemId: l,
334
335
  error: N,
335
336
  visible: b,
336
337
  locked: u,
@@ -339,222 +340,223 @@ const Yn = Ft(function({
339
340
  onCountChange: a,
340
341
  swapButton: x,
341
342
  swapContent: W,
342
- forceVisible: Ue,
343
- autoFillTick: le
343
+ forceVisible: Ve,
344
+ autoFillTick: ie
344
345
  }) {
345
- var Ee, je, Me;
346
- const z = xn.has(e.interface ?? ""), C = Lt(), g = Yt(), ge = Ke(), se = oe(), [ve, V] = be(!1), s = Et(), G = R(null), Q = Ct(), de = R(null), we = R(!1);
346
+ var De, Oe, Be;
347
+ const V = yn.has(e.interface ?? ""), C = Rt(), g = Jt(), ke = We(), se = oe(), [_e, z] = we(!1), s = jt(), G = R(null), Q = Lt(), de = R(null), Ne = R(!1);
347
348
  ae(() => {
348
- const t = we.current ? wn(de.current) : null;
349
+ const t = Ne.current ? _n(de.current) : null;
349
350
  if (!t || t.hasAttribute("aria-label")) return;
350
351
  t.id || (t.id = `${Q}-control`);
351
- const r = t.tagName === "BUTTON" ? `${Q} ${t.id}` : Q;
352
- t.getAttribute("aria-labelledby") !== r && t.setAttribute("aria-labelledby", r);
352
+ const n = t.tagName === "BUTTON" ? `${Q} ${t.id}` : Q;
353
+ t.getAttribute("aria-labelledby") !== n && t.setAttribute("aria-labelledby", n);
353
354
  });
354
- const ke = u && !z, _e = R(null);
355
+ const Fe = u && !V, Ce = R(null);
355
356
  ae(() => {
356
- const t = _e.current;
357
+ const t = Ce.current;
357
358
  if (!t) return;
358
- if (!ke) {
359
+ if (!Fe) {
359
360
  t.removeAttribute("inert");
360
361
  return;
361
362
  }
362
- const r = typeof document < "u" ? document.activeElement : null;
363
- r instanceof HTMLElement && t.contains(r) && r.blur(), t.setAttribute("inert", "");
364
- }, [ke, le]);
365
- const Y = e.field, Ne = Oe(
363
+ const n = typeof document < "u" ? document.activeElement : null;
364
+ n instanceof HTMLElement && t.contains(n) && n.blur(), t.setAttribute("inert", "");
365
+ }, [Fe, ie]);
366
+ const Y = e.field, Le = Me(
366
367
  (t) => {
367
- u || h(Y, t);
368
+ u || p(Y, t);
368
369
  },
369
- [u, h, Y]
370
- ), We = Oe(
370
+ [u, p, Y]
371
+ ), ze = Me(
371
372
  (t) => a == null ? void 0 : a(Y, t),
372
373
  [a, Y]
373
- ), ze = R(void 0), Fe = R(void 0), Ce = R(void 0), {
374
- onContextMenu: Ve,
375
- onKeyDown: Ge,
376
- menu: Qe,
377
- openFrom: Ye,
378
- isOpen: Le,
379
- hasFieldItems: Je
380
- } = jt({
374
+ ), Ge = R(void 0), Re = R(void 0), Se = R(void 0), $e = !u && !e.readonly && !e.computed_formula && !(e.hidden && !e.layout_assigned) && !He(e), {
375
+ onContextMenu: Qe,
376
+ onKeyDown: Ye,
377
+ menu: Je,
378
+ confirmSaveFrom: Xe,
379
+ openedBy: ce
380
+ } = Dt({
381
381
  wrapperRef: G,
382
382
  field: e,
383
383
  value: m[e.field],
384
384
  relations: f,
385
- collection: l,
386
- itemId: i,
385
+ collection: i,
386
+ itemId: l,
387
387
  openRelated: s == null ? void 0 : s.openRelated,
388
- // Only a field the person can edit here may carry a personal default.
389
- editable: !u && !e.readonly && !e.computed_formula && !(e.hidden && !e.layout_assigned) && !He(e)
390
- }), P = Mt(G), Ie = Xt(), Re = s == null ? void 0 : s.remoteChanges[e.field], O = s == null ? void 0 : s.lockReasons[e.field], T = s == null ? void 0 : s.applyToLines[e.field], L = dn(), Se = (L == null ? void 0 : L.applied(e.field)) ?? !1, $e = (L == null ? void 0 : L.hintFor(e.field)) ?? null, J = Rt(e._overrides, o, fn(e)), ce = !!(s != null && s.fromAutofill) && !!e._overrides && e._overrides[St] === !0;
391
- async function Xe() {
388
+ editable: $e
389
+ }), A = Ot(G), Ze = en(), qe = s == null ? void 0 : s.remoteChanges[e.field], O = s == null ? void 0 : s.lockReasons[e.field], q = s == null ? void 0 : s.applyToLines[e.field], L = un(), Ie = (L == null ? void 0 : L.applied(e.field)) ?? !1, Te = (L == null ? void 0 : L.hintFor(e.field)) ?? null, ue = Xt(L, e.field, $e), me = () => {
390
+ var t, n;
391
+ return ((t = de.current) == null ? void 0 : t.querySelector(Ue)) ?? ((n = G.current) == null ? void 0 : n.querySelector(Ue));
392
+ }, J = St(e._overrides, o, bn(e)), pe = !!(s != null && s.fromAutofill) && !!e._overrides && e._overrides[$t] === !0;
393
+ async function et() {
392
394
  var t;
393
- if (J.perField) return Ze();
394
- V(!0);
395
+ if (J.perField) return tt();
396
+ z(!0);
395
397
  try {
396
- const r = await se.request(
397
- ye("/ai/generate", {
398
- collection: l,
399
- item_id: i !== "new" ? i : void 0,
398
+ const n = await se.request(
399
+ ve("/ai/generate", {
400
+ collection: i,
401
+ item_id: l !== "new" ? l : void 0,
400
402
  field: e.field
401
403
  })
402
404
  );
403
- ((t = r.data) == null ? void 0 : t.value) != null && h(e.field, r.data.value);
405
+ ((t = n.data) == null ? void 0 : t.value) != null && p(e.field, n.data.value);
404
406
  } catch {
405
407
  } finally {
406
- V(!1);
408
+ z(!1);
407
409
  }
408
410
  }
409
- async function Ze() {
410
- var r, p, k, M, q, F;
411
+ async function tt() {
412
+ var n, h, k, j, T, F;
411
413
  const t = {};
412
- for (const v of ((r = $t(e._overrides)) == null ? void 0 : r.tokens) ?? []) v in m && (t[v] = m[v]);
413
- V(!0);
414
+ for (const v of ((n = qt(e._overrides)) == null ? void 0 : n.tokens) ?? []) v in m && (t[v] = m[v]);
415
+ z(!0);
414
416
  try {
415
417
  const v = await se.request(
416
- ye("/ai/field-fill", {
417
- collection: l,
418
+ ve("/ai/field-fill", {
419
+ collection: i,
418
420
  layout_id: (s == null ? void 0 : s.layoutId) ?? null,
419
421
  field: e.field,
420
- item_id: i && i !== "new" ? i : null,
422
+ item_id: l && l !== "new" ? l : null,
421
423
  values: t
422
424
  })
423
- ), _ = (p = v.data) == null ? void 0 : p.value;
424
- typeof _ == "string" && _ !== "" ? h(e.field, _) : K.info("The AI had nothing to write here"), (M = (k = v.data) == null ? void 0 : k.missing) != null && M.length && K.info(`Filled without ${v.data.missing.join(", ")} (empty or not visible to you)`);
425
+ ), _ = (h = v.data) == null ? void 0 : h.value;
426
+ typeof _ == "string" && _ !== "" ? p(e.field, _) : U.info("The AI had nothing to write here"), (j = (k = v.data) == null ? void 0 : k.missing) != null && j.length && U.info(`Filled without ${v.data.missing.join(", ")} (empty or not visible to you)`);
425
427
  } catch (v) {
426
428
  const _ = v;
427
- K.error(((F = (q = _ == null ? void 0 : _.response) == null ? void 0 : q.data) == null ? void 0 : F.error) ?? (_ == null ? void 0 : _.message) ?? "AI fill failed");
429
+ U.error(((F = (T = _ == null ? void 0 : _.response) == null ? void 0 : T.data) == null ? void 0 : F.error) ?? (_ == null ? void 0 : _.message) ?? "AI fill failed");
428
430
  } finally {
429
- V(!1);
431
+ z(!1);
430
432
  }
431
433
  }
432
- const E = Ut(e.dependency_config), Te = E.flatMap((t) => {
433
- const r = f.find(
434
- (k) => k.one_collection === l && k.one_field === t.parent_field
434
+ const E = Wt(e.dependency_config), Ae = E.flatMap((t) => {
435
+ const n = f.find(
436
+ (k) => k.one_collection === i && k.one_field === t.parent_field
435
437
  );
436
- if (!r) return [];
437
- if (r.junction_field) return [{ rule: t, rel: r }];
438
- const p = f.find(
439
- (k) => k.many_collection === r.many_collection && k.id !== r.id
438
+ if (!n) return [];
439
+ if (n.junction_field) return [{ rule: t, rel: n }];
440
+ const h = f.find(
441
+ (k) => k.many_collection === n.many_collection && k.id !== n.id
440
442
  );
441
- return p != null && p.many_field ? [{ rule: t, rel: { ...r, junction_field: p.many_field } }] : [];
442
- }), et = pt({
443
- queries: Te.map(({ rel: t }) => ({
444
- queryKey: ["m2m-items", t.many_collection, t.many_field, i],
443
+ return h != null && h.many_field ? [{ rule: t, rel: { ...n, junction_field: h.many_field } }] : [];
444
+ }), nt = xt({
445
+ queries: Ae.map(({ rel: t }) => ({
446
+ queryKey: ["m2m-items", t.many_collection, t.many_field, l],
445
447
  queryFn: () => se.request(
446
- U(`/items/${t.many_collection}`, {
447
- filter: JSON.stringify({ [t.many_field]: { _eq: i } }),
448
+ H(`/items/${t.many_collection}`, {
449
+ filter: JSON.stringify({ [t.many_field]: { _eq: l } }),
448
450
  limit: 200,
449
451
  fields: `id,${t.junction_field}`
450
452
  })
451
- ).then((r) => r.data ?? []),
452
- enabled: !!i && i !== "new",
453
+ ).then((n) => n.data ?? []),
454
+ enabled: !!l && l !== "new",
453
455
  staleTime: 3e4
454
456
  }))
455
- }), tt = Object.fromEntries(
456
- Te.map(({ rule: t, rel: r }, p) => {
457
- var q;
458
- const k = r.one_field ?? `${r.many_collection}.${r.junction_field}`, M = (g == null ? void 0 : g.getStagedUnlinks(k)) ?? /* @__PURE__ */ new Set();
457
+ }), rt = Object.fromEntries(
458
+ Ae.map(({ rule: t, rel: n }, h) => {
459
+ var T;
460
+ const k = n.one_field ?? `${n.many_collection}.${n.junction_field}`, j = (g == null ? void 0 : g.getStagedUnlinks(k)) ?? /* @__PURE__ */ new Set();
459
461
  return [
460
462
  t.parent_field,
461
- (((q = et[p]) == null ? void 0 : q.data) ?? []).filter((F) => !M.has(F.id)).map((F) => F[r.junction_field])
463
+ (((T = nt[h]) == null ? void 0 : T.data) ?? []).filter((F) => !j.has(F.id)).map((F) => F[n.junction_field])
462
464
  ];
463
465
  })
464
- ), I = At()[e.field] ?? [];
465
- if (!Ue && (!b || !e.layout_assigned && (e.hidden || Wt.has(e.field))))
466
+ ), X = Et()[e.field] ?? [];
467
+ if (!Ve && (!b || !e.layout_assigned && (e.hidden || Vt.has(e.field))))
466
468
  return null;
467
- const ue = m[e.field] ?? null, X = Zt(e, Ie), S = X.label ?? fe(e.field);
468
- we.current = S !== "";
469
- const j = He(e), qe = j ? null : en(e), nt = !j && !u && !e.readonly && ((Ee = e._overrides) == null ? void 0 : Ee.repeat_last) === !0, rt = Qt(e, m), it = (Me = (je = zt(e.options)) == null ? void 0 : je.auto_id) == null ? void 0 : Me.pattern, w = (() => {
469
+ const he = m[e.field] ?? null, Z = tn(e, Ze), S = Z.label ?? ge(e.field);
470
+ Ne.current = S !== "";
471
+ const P = He(e), Ee = P ? null : nn(e), lt = !P && !u && !e.readonly && ((De = e._overrides) == null ? void 0 : De.repeat_last) === !0, at = Yt(e, m), ot = (Be = (Oe = zt(e.options)) == null ? void 0 : Oe.auto_id) == null ? void 0 : Be.pattern, w = (() => {
470
472
  const t = f.find(
471
- (p) => p.one_collection === l && p.one_field === e.field
473
+ (h) => h.one_collection === i && h.one_field === e.field
472
474
  );
473
475
  if (!t) return null;
474
476
  if (t.junction_field) return t;
475
- const r = f.find(
476
- (p) => p.many_collection === t.many_collection && p.id !== t.id
477
+ const n = f.find(
478
+ (h) => h.many_collection === t.many_collection && h.id !== t.id
477
479
  );
478
- return r ? { ...t, junction_field: r.many_field } : null;
479
- })(), me = w ? null : f.find((t) => t.many_collection === l && t.many_field === e.field) ?? null, pe = w ? f.find(
480
+ return n ? { ...t, junction_field: n.many_field } : null;
481
+ })(), xe = w ? null : f.find((t) => t.many_collection === i && t.many_field === e.field) ?? null, fe = w ? f.find(
480
482
  (t) => t.many_collection === w.many_collection && t.many_field === w.junction_field && t.id !== w.id
481
- ) ?? null : null, D = w ? w.one_field ?? `${w.many_collection}.${w.junction_field}` : null, Ae = D ? (g == null ? void 0 : g.getStagedLinks(D)) ?? [] : [], at = w ? (ge.getQueryData([
483
+ ) ?? null : null, B = w ? w.one_field ?? `${w.many_collection}.${w.junction_field}` : null, Pe = B ? (g == null ? void 0 : g.getStagedLinks(B)) ?? [] : [], it = w ? (ke.getQueryData([
482
484
  "m2m-items",
483
485
  w.many_collection,
484
486
  w.many_field,
485
- i
486
- ]) ?? []).map((t) => t[w.junction_field]) : [], ot = w ? Ae[0] ?? at[0] ?? null : ue, lt = (pe == null ? void 0 : pe.one_collection) ?? (me == null ? void 0 : me.one_collection) ?? void 0, Z = (t) => {
487
- var r;
488
- return ((C == null ? void 0 : C.collection) === l ? (r = C == null ? void 0 : C.fieldLabels) == null ? void 0 : r[t] : void 0) ?? fe(String(t));
489
- }, $ = Vt({
487
+ l
488
+ ]) ?? []).map((t) => t[w.junction_field]) : [], st = w ? Pe[0] ?? it[0] ?? null : he, dt = (fe == null ? void 0 : fe.one_collection) ?? (xe == null ? void 0 : xe.one_collection) ?? void 0, I = (t) => {
489
+ var n;
490
+ return ((C == null ? void 0 : C.collection) === i ? (n = C == null ? void 0 : C.fieldLabels) == null ? void 0 : n[t] : void 0) ?? ge(String(t));
491
+ }, $ = Gt({
490
492
  rules: E,
491
493
  // A parent whose value THIS field's own pick derived must not narrow this
492
494
  // field's options — otherwise picking a region locks the region picker
493
495
  // into the zone the pick itself filled, and cross-zone changes read as
494
496
  // "No results".
495
497
  skipParent: (t) => {
496
- var r;
497
- return ((r = g == null ? void 0 : g.getDerivedOrigin) == null ? void 0 : r.call(g, t)) === e.field;
498
+ var n;
499
+ return ((n = g == null ? void 0 : g.getDerivedOrigin) == null ? void 0 : n.call(g, t)) === e.field;
498
500
  },
499
501
  parentValue: (t) => {
500
502
  if (m[t] != null) return m[t];
501
- const r = f.find((v) => v.one_collection === l && v.one_field === t);
502
- if (!r) return null;
503
- let p = r;
504
- if (!p.junction_field) {
503
+ const n = f.find((v) => v.one_collection === i && v.one_field === t);
504
+ if (!n) return null;
505
+ let h = n;
506
+ if (!h.junction_field) {
505
507
  const v = f.find(
506
- (_) => _.many_collection === r.many_collection && _.id !== r.id
508
+ (_) => _.many_collection === n.many_collection && _.id !== n.id
507
509
  );
508
- if (v != null && v.many_field) p = { ...r, junction_field: v.many_field };
510
+ if (v != null && v.many_field) h = { ...n, junction_field: v.many_field };
509
511
  else return null;
510
512
  }
511
- const k = p.one_field ?? `${p.many_collection}.${p.junction_field}`, M = (g == null ? void 0 : g.getStagedLinks(k)) ?? [], q = tt[t] ?? [], F = [...new Set([...M, ...q].map((v) => String(v)))];
513
+ const k = h.one_field ?? `${h.many_collection}.${h.junction_field}`, j = (g == null ? void 0 : g.getStagedLinks(k)) ?? [], T = rt[t] ?? [], F = [...new Set([...j, ...T].map((v) => String(v)))];
512
514
  return F.length === 0 ? null : F.length === 1 ? F[0] : F;
513
515
  },
514
516
  parentOptionFilter: (t) => {
515
- var p;
516
- const r = (C == null ? void 0 : C.collection) === l ? (p = C.fieldOptionFilters) == null ? void 0 : p[t] : void 0;
517
- return r ? cn(r, m, i) : void 0;
517
+ var h;
518
+ const n = (C == null ? void 0 : C.collection) === i ? (h = C.fieldOptionFilters) == null ? void 0 : h[t] : void 0;
519
+ return n ? mn(n, m, l) : void 0;
518
520
  }
519
- }), B = $.filter ? ln(ze, $.filter, sn) : $.filter, H = $.satisfiedParents.map(Z), he = $.satisfiedParents, st = $.unsatisfiedParents.length ? Z($.unsatisfiedParents[0]) : null, xe = $.missingRequiredParents, Pe = xe.length ? Z(xe[0]) : null;
520
- function dt() {
521
- const t = Ce.current;
521
+ }), M = $.filter ? dn(Ge, $.filter, cn) : $.filter, K = $.satisfiedParents.map(I), ye = $.satisfiedParents, ct = $.unsatisfiedParents.length ? I($.unsatisfiedParents[0]) : null, be = $.missingRequiredParents, je = be.length ? I(be[0]) : null;
522
+ function ut() {
523
+ const t = Se.current;
522
524
  if (t && t.src === e) return t.value;
523
- const r = { ...e, readonly: !0 };
524
- return Ce.current = { src: e, value: r }, r;
525
+ const n = { ...e, readonly: !0 };
526
+ return Se.current = { src: e, value: n }, n;
525
527
  }
526
- function ct() {
527
- const t = JSON.stringify([H, he]), r = Fe.current;
528
- if (r && r.sig === t && r.onChange === h) return r.value;
529
- const p = {
530
- labels: H,
531
- keys: he,
532
- onClear: (k) => h(k, null)
528
+ function mt() {
529
+ const t = JSON.stringify([K, ye]), n = Re.current;
530
+ if (n && n.sig === t && n.onChange === p) return n.value;
531
+ const h = {
532
+ labels: K,
533
+ keys: ye,
534
+ onClear: (k) => p(k, null)
533
535
  };
534
- return Fe.current = { sig: t, onChange: h, value: p }, p;
536
+ return Re.current = { sig: t, onChange: p, value: h }, h;
535
537
  }
536
- function ut() {
537
- for (const t of he) {
538
- const r = document.querySelector(`[data-field="${t}"]`);
539
- r && (r.scrollIntoView({ behavior: "smooth", block: "center" }), r.style.transition = "box-shadow 0.15s ease", r.style.boxShadow = "0 0 0 2px rgb(var(--nvr-cyan-rgb, 0 206 255)), 0 0 0 5px rgb(var(--nvr-cyan-rgb, 0 206 255) / 0.25)", r.style.borderRadius = "12px", setTimeout(() => {
540
- r.style.boxShadow = "none", setTimeout(() => {
541
- r.style.transition = "", r.style.borderRadius = "";
538
+ function pt() {
539
+ for (const t of ye) {
540
+ const n = document.querySelector(`[data-field="${t}"]`);
541
+ n && (n.scrollIntoView({ behavior: "smooth", block: "center" }), n.style.transition = "box-shadow 0.15s ease", n.style.boxShadow = "0 0 0 2px rgb(var(--nvr-cyan-rgb, 0 206 255)), 0 0 0 5px rgb(var(--nvr-cyan-rgb, 0 206 255) / 0.25)", n.style.borderRadius = "12px", setTimeout(() => {
542
+ n.style.boxShadow = "none", setTimeout(() => {
543
+ n.style.transition = "", n.style.borderRadius = "";
542
544
  }, 300);
543
545
  }, 900));
544
546
  }
545
547
  }
546
- const mt = () => {
547
- if (w && D) {
548
- for (const r of Ae) g == null || g.unstageLink(D, r);
549
- const t = ge.getQueryData([
548
+ const ht = () => {
549
+ if (w && B) {
550
+ for (const n of Pe) g == null || g.unstageLink(B, n);
551
+ const t = ke.getQueryData([
550
552
  "m2m-items",
551
553
  w.many_collection,
552
554
  w.many_field,
553
- i
555
+ l
554
556
  ]) ?? [];
555
- for (const r of t) g == null || g.stageUnlink(D, r.id);
557
+ for (const n of t) g == null || g.stageUnlink(B, n.id);
556
558
  } else
557
- h(e.field, null);
559
+ p(e.field, null);
558
560
  };
559
561
  return (
560
562
  // biome-ignore lint/a11y/noStaticElementInteractions: the wrapper only hosts the field context menu (right-click / Shift+F10); the inputs inside stay the controls
@@ -563,266 +565,270 @@ const Yn = Ft(function({
563
565
  {
564
566
  ref: G,
565
567
  "data-field": e.field,
566
- "data-field-collection": l,
568
+ "data-field-collection": i,
567
569
  "data-field-interface": e.interface ?? void 0,
568
- "data-autofill-check": ce ? "" : void 0,
569
- className: A(
570
+ "data-autofill-check": pe ? "" : void 0,
571
+ className: D(
570
572
  "group/fieldrow space-y-1.5",
571
- ce && "rounded-md bg-amber-50/60 p-1.5 ring-1 ring-amber-300 dark:bg-amber-500/10 dark:ring-amber-500/40"
573
+ pe && "rounded-md bg-amber-50/60 p-1.5 ring-1 ring-amber-300 dark:bg-amber-500/10 dark:ring-amber-500/40"
572
574
  ),
573
- onContextMenu: Ve,
574
- onKeyDown: Ge,
575
- onFocusCapture: P.onFocusCapture,
575
+ onContextMenu: Qe,
576
+ onKeyDown: Ye,
577
+ onFocusCapture: A.onFocusCapture,
576
578
  children: [
577
- Qe,
578
- E.length > 0 && /* @__PURE__ */ n(
579
- Gt,
579
+ Je,
580
+ E.length > 0 && /* @__PURE__ */ r(
581
+ Qt,
580
582
  {
581
583
  cascadeRules: E,
582
- cascadeFilter: B,
583
- currentValue: ot,
584
- relatedCollection: lt,
585
- missingRequiredParents: xe,
586
- onClear: mt
584
+ cascadeFilter: M,
585
+ currentValue: st,
586
+ relatedCollection: dt,
587
+ missingRequiredParents: be,
588
+ onClear: ht
587
589
  }
588
590
  ),
589
- (S !== "" || I.length > 0) && /* @__PURE__ */ c("div", { className: "flex flex-wrap items-center gap-1.5 min-h-[1.5rem]", children: [
590
- S !== "" && /* @__PURE__ */ c(qt, { id: Q, "data-field-label": !0, className: "text-sm font-medium", children: [
591
- /* @__PURE__ */ n(De, { text: S, collection: l }),
592
- e.required && /* @__PURE__ */ n("span", { className: "ml-0.5 text-destructive", children: "*" }),
593
- tn(e) && /* @__PURE__ */ n(nn, {})
594
- ] }),
595
- X.note && /* @__PURE__ */ n(ee, { delayDuration: 100, children: /* @__PURE__ */ c(te, { children: [
596
- /* @__PURE__ */ n(ne, { asChild: !0, children: /* @__PURE__ */ n(xt, { className: "h-3.5 w-3.5 shrink-0 cursor-help text-slate-400 hover:text-slate-600" }) }),
597
- /* @__PURE__ */ n(re, { side: "top", className: "max-w-[240px] text-[12px]", children: (s == null ? void 0 : s.glossaryHelp) === !1 ? X.note : /* @__PURE__ */ n(De, { text: X.note, collection: l }) })
598
- ] }) }),
599
- !j && i && i !== "new" && /* @__PURE__ */ n(
600
- gn,
601
- {
602
- collection: l,
603
- itemId: i,
604
- field: e.field,
605
- onRestore: e.readonly ? void 0 : (t) => h(e.field, t)
606
- }
607
- ),
608
- !j && i && i !== "new" && /* @__PURE__ */ n(vn, { collection: l, itemId: i, field: e.field }),
609
- i && i !== "new" && rt && /* @__PURE__ */ n(bn, { collection: l, itemId: i, field: e.field }),
610
- nt && /* @__PURE__ */ n(
611
- rn,
612
- {
613
- collection: l,
614
- itemId: i,
615
- field: e.field,
616
- label: S || fe(e.field),
617
- onFill: (t) => h(e.field, t)
618
- }
619
- ),
620
- !j && J.show && !(J.perField && (u || e.readonly)) && /* @__PURE__ */ c(
621
- "button",
622
- {
623
- type: "button",
624
- onClick: Xe,
625
- disabled: ve,
626
- "data-ai-fill": J.perField ? e.field : void 0,
627
- className: "inline-flex items-center gap-0.5 rounded px-1 py-0.5 text-[10px] font-medium text-nvr-cyan hover:bg-nvr-cyan/10 disabled:opacity-50 transition-colors",
628
- title: "Generate with AI",
629
- children: [
630
- ve ? /* @__PURE__ */ n(ft, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ n(yt, { className: "h-3 w-3" }),
631
- "AI"
632
- ]
633
- }
634
- ),
635
- ce && /* @__PURE__ */ n(
636
- "span",
637
- {
638
- "data-tip": "People often change what the AI read from the document here — check it",
639
- className: "inline-flex items-center rounded px-1.5 py-0.5 text-[10.5px] font-medium text-amber-800 bg-amber-100 dark:bg-amber-500/15 dark:text-amber-200",
640
- children: "Check this"
641
- }
642
- ),
643
- Se && /* @__PURE__ */ n(
644
- Jt,
645
- {
646
- field: e.field,
647
- label: S,
648
- onUndo: () => {
649
- L == null || L.undo(e.field), requestAnimationFrame(() => {
650
- var r, p;
651
- const t = ((r = de.current) == null ? void 0 : r.querySelector(Be)) ?? ((p = G.current) == null ? void 0 : p.querySelector(Be));
652
- t == null || t.focus();
653
- });
654
- }
655
- }
656
- ),
657
- x,
658
- T && !u && !e.readonly && /* @__PURE__ */ c(
659
- "button",
660
- {
661
- type: "button",
662
- onClick: () => T.onApply(m[e.field] ?? null),
663
- disabled: m[e.field] == null || m[e.field] === "" || T.count === 0,
664
- "data-apply-to-lines": e.field,
665
- "data-tip": T.count === 0 ? "No lines yet — add lines first" : m[e.field] == null || m[e.field] === "" ? "Pick a value first" : T.count != null ? `Copy this value onto all ${T.count} lines (staged until you save)` : "Copy this value onto every line (staged until you save)",
666
- className: "inline-flex items-center gap-1 rounded border border-nvr-cyan/40 px-1.5 py-0.5 text-[10.5px] font-medium text-[#0e7490] transition-colors hover:bg-nvr-cyan/10 disabled:cursor-not-allowed disabled:opacity-40 dark:text-nvr-cyan",
667
- children: [
668
- T.label ?? "Apply to lines",
669
- " ↓"
670
- ]
671
- }
672
- ),
673
- I.length > 0 && /* @__PURE__ */ n(ee, { delayDuration: 100, children: /* @__PURE__ */ c(te, { children: [
674
- /* @__PURE__ */ n(ne, { asChild: !0, children: /* @__PURE__ */ c("span", { className: "inline-flex items-center gap-1 rounded-full bg-amber-50 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 border border-amber-200 dark:bg-amber-500/10 dark:text-amber-400 dark:border-amber-500/20 cursor-default", children: [
675
- /* @__PURE__ */ n("span", { className: "h-1.5 w-1.5 rounded-full bg-amber-400 shrink-0" }),
676
- "addendum"
677
- ] }) }),
678
- /* @__PURE__ */ c(re, { side: "top", className: "max-w-[220px] text-[12px]", children: [
679
- /* @__PURE__ */ c("p", { className: "font-medium mb-1", children: [
680
- "In active addendum",
681
- I.length > 1 ? "s" : "",
682
- ":"
591
+ (S !== "" || X.length > 0) && /* @__PURE__ */ c(
592
+ "div",
593
+ {
594
+ className: "flex flex-wrap items-center gap-1.5 min-h-[1.5rem]",
595
+ "data-pd-row": ue ? "" : void 0,
596
+ children: [
597
+ S !== "" && /* @__PURE__ */ c(At, { id: Q, "data-field-label": !0, className: "text-sm font-medium", children: [
598
+ /* @__PURE__ */ r(Ke, { text: S, collection: i }),
599
+ e.required && /* @__PURE__ */ r("span", { className: "ml-0.5 text-destructive", children: "*" }),
600
+ rn(e) && /* @__PURE__ */ r(ln, {})
683
601
  ] }),
684
- I.map((t) => /* @__PURE__ */ c("p", { className: "text-slate-400", children: [
685
- t.title,
686
- " ",
687
- /* @__PURE__ */ c("span", { className: "capitalize", children: [
688
- "(",
689
- t.status,
690
- ")"
691
- ] })
692
- ] }, t.id))
693
- ] })
694
- ] }) }),
695
- /* @__PURE__ */ n(
696
- Kt,
697
- {
698
- collection: l,
699
- kind: "field",
700
- name: e.field,
701
- label: S
702
- }
703
- ),
704
- (u || e.readonly) && O ? /* @__PURE__ */ n(Ot, { reason: O, onHover: s == null ? void 0 : s.onLockHover }) : u ? /* @__PURE__ */ n(ee, { delayDuration: 200, children: /* @__PURE__ */ c(te, { children: [
705
- /* @__PURE__ */ n(ne, { asChild: !0, children: /* @__PURE__ */ n("span", { className: "inline-flex items-center text-amber-400 dark:text-amber-500", children: /* @__PURE__ */ n(bt, { className: "h-3 w-3" }) }) }),
706
- /* @__PURE__ */ n(re, { side: "top", className: "text-[12px]", children: "This field is locked" })
707
- ] }) }) : null,
708
- E.length > 0 && (() => {
709
- const t = !!B && Object.keys(B).length > 0 && H.length > 0, r = E.map(
710
- (p) => Z(String(p.parent_field))
711
- );
712
- return /* @__PURE__ */ n(ee, { delayDuration: 100, children: /* @__PURE__ */ c(te, { children: [
713
- /* @__PURE__ */ n(ne, { asChild: !0, children: /* @__PURE__ */ n(
602
+ Z.note && /* @__PURE__ */ r(ee, { delayDuration: 100, children: /* @__PURE__ */ c(te, { children: [
603
+ /* @__PURE__ */ r(ne, { asChild: !0, children: /* @__PURE__ */ r(yt, { className: "h-3.5 w-3.5 shrink-0 cursor-help text-slate-400 hover:text-slate-600" }) }),
604
+ /* @__PURE__ */ r(re, { side: "top", className: "max-w-[240px] text-[12px]", children: (s == null ? void 0 : s.glossaryHelp) === !1 ? Z.note : /* @__PURE__ */ r(Ke, { text: Z.note, collection: i }) })
605
+ ] }) }),
606
+ !P && l && l !== "new" && /* @__PURE__ */ r(
607
+ wn,
608
+ {
609
+ collection: i,
610
+ itemId: l,
611
+ field: e.field,
612
+ onRestore: e.readonly ? void 0 : (t) => p(e.field, t)
613
+ }
614
+ ),
615
+ !P && l && l !== "new" && /* @__PURE__ */ r(kn, { collection: i, itemId: l, field: e.field }),
616
+ l && l !== "new" && at && /* @__PURE__ */ r(vn, { collection: i, itemId: l, field: e.field }),
617
+ lt && /* @__PURE__ */ r(
618
+ an,
619
+ {
620
+ collection: i,
621
+ itemId: l,
622
+ field: e.field,
623
+ label: S || ge(e.field),
624
+ onFill: (t) => p(e.field, t)
625
+ }
626
+ ),
627
+ !P && J.show && !(J.perField && (u || e.readonly)) && /* @__PURE__ */ c(
714
628
  "button",
715
629
  {
716
630
  type: "button",
717
- "aria-label": `Show the fields that narrow ${S || "this list"}`,
718
- onClick: ut,
719
- className: A(
720
- "inline-flex items-center transition-colors",
721
- t ? "text-nvr-cyan hover:text-nvr-cyan" : "text-slate-300 hover:text-nvr-cyan dark:text-slate-600 dark:hover:text-nvr-cyan"
722
- ),
723
- children: /* @__PURE__ */ n(gt, { className: "h-3 w-3" })
631
+ onClick: et,
632
+ disabled: _e,
633
+ "data-ai-fill": J.perField ? e.field : void 0,
634
+ className: "inline-flex items-center gap-0.5 rounded px-1 py-0.5 text-[10px] font-medium text-nvr-cyan hover:bg-nvr-cyan/10 disabled:opacity-50 transition-colors",
635
+ title: "Generate with AI",
636
+ children: [
637
+ _e ? /* @__PURE__ */ r(bt, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ r(gt, { className: "h-3 w-3" }),
638
+ "AI"
639
+ ]
724
640
  }
725
- ) }),
726
- /* @__PURE__ */ n(re, { side: "top", className: "text-[12px]", children: t ? `Filtered by ${H.join(", ")} — click to highlight` : `Options filter by ${r.join(", ")} once set` })
727
- ] }) });
728
- })(),
729
- Je && // The field menu for touch and pointer people (right-click / Shift+F10 still work).
730
- // Shown on hover, focus and touch; opacity (not `hidden`) keeps its slot and its tab stop.
731
- /* @__PURE__ */ n(
732
- "button",
733
- {
734
- type: "button",
735
- "data-field-menu-trigger": e.field,
736
- "aria-label": "Field options",
737
- "aria-haspopup": "menu",
738
- "aria-expanded": Le,
739
- "data-tip": "Field options",
740
- onClick: (t) => Ye(t.currentTarget),
741
- className: A(
742
- "inline-flex h-5 w-5 items-center justify-center rounded text-slate-500 opacity-0 transition-[opacity,color,background-color] duration-150 hover:bg-muted hover:text-slate-800 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/40 group-hover/fieldrow:opacity-100 group-focus-within/fieldrow:opacity-100 [@media(hover:none)]:opacity-100 dark:text-slate-400 dark:hover:text-slate-100",
743
- Le && "opacity-100"
744
641
  ),
745
- children: /* @__PURE__ */ n(vt, { className: "h-3.5 w-3.5", "aria-hidden": !0 })
746
- }
747
- )
748
- ] }),
749
- P.editor && !u && /* @__PURE__ */ n(
750
- Dt,
642
+ pe && /* @__PURE__ */ r(
643
+ "span",
644
+ {
645
+ "data-tip": "People often change what the AI read from the document here — check it",
646
+ className: "inline-flex items-center rounded px-1.5 py-0.5 text-[10.5px] font-medium text-amber-800 bg-amber-100 dark:bg-amber-500/15 dark:text-amber-200",
647
+ children: "Check this"
648
+ }
649
+ ),
650
+ x,
651
+ q && !u && !e.readonly && /* @__PURE__ */ c(
652
+ "button",
653
+ {
654
+ type: "button",
655
+ onClick: () => q.onApply(m[e.field] ?? null),
656
+ disabled: m[e.field] == null || m[e.field] === "" || q.count === 0,
657
+ "data-apply-to-lines": e.field,
658
+ "data-tip": q.count === 0 ? "No lines yet — add lines first" : m[e.field] == null || m[e.field] === "" ? "Pick a value first" : q.count != null ? `Copy this value onto all ${q.count} lines (staged until you save)` : "Copy this value onto every line (staged until you save)",
659
+ className: "inline-flex items-center gap-1 rounded border border-nvr-cyan/40 px-1.5 py-0.5 text-[10.5px] font-medium text-[#0e7490] transition-colors hover:bg-nvr-cyan/10 disabled:cursor-not-allowed disabled:opacity-40 dark:text-nvr-cyan",
660
+ children: [
661
+ q.label ?? "Apply to lines",
662
+ " ↓"
663
+ ]
664
+ }
665
+ ),
666
+ X.length > 0 && /* @__PURE__ */ r(ee, { delayDuration: 100, children: /* @__PURE__ */ c(te, { children: [
667
+ /* @__PURE__ */ r(ne, { asChild: !0, children: /* @__PURE__ */ c("span", { className: "inline-flex items-center gap-1 rounded-full bg-amber-50 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 border border-amber-200 dark:bg-amber-500/10 dark:text-amber-400 dark:border-amber-500/20 cursor-default", children: [
668
+ /* @__PURE__ */ r("span", { className: "h-1.5 w-1.5 rounded-full bg-amber-400 shrink-0" }),
669
+ "addendum"
670
+ ] }) }),
671
+ /* @__PURE__ */ c(re, { side: "top", className: "max-w-[220px] text-[12px]", children: [
672
+ /* @__PURE__ */ c("p", { className: "font-medium mb-1", children: [
673
+ "In active addendum",
674
+ X.length > 1 ? "s" : "",
675
+ ":"
676
+ ] }),
677
+ X.map((t) => /* @__PURE__ */ c("p", { className: "text-slate-400", children: [
678
+ t.title,
679
+ " ",
680
+ /* @__PURE__ */ c("span", { className: "capitalize", children: [
681
+ "(",
682
+ t.status,
683
+ ")"
684
+ ] })
685
+ ] }, t.id))
686
+ ] })
687
+ ] }) }),
688
+ /* @__PURE__ */ r(
689
+ Ht,
690
+ {
691
+ collection: i,
692
+ kind: "field",
693
+ name: e.field,
694
+ label: S
695
+ }
696
+ ),
697
+ (u || e.readonly) && O ? /* @__PURE__ */ r(Bt, { reason: O, onHover: s == null ? void 0 : s.onLockHover }) : u ? /* @__PURE__ */ r(ee, { delayDuration: 200, children: /* @__PURE__ */ c(te, { children: [
698
+ /* @__PURE__ */ r(ne, { asChild: !0, children: /* @__PURE__ */ r("span", { className: "inline-flex items-center text-amber-400 dark:text-amber-500", children: /* @__PURE__ */ r(vt, { className: "h-3 w-3" }) }) }),
699
+ /* @__PURE__ */ r(re, { side: "top", className: "text-[12px]", children: "This field is locked" })
700
+ ] }) }) : null,
701
+ E.length > 0 && (() => {
702
+ const t = !!M && Object.keys(M).length > 0 && K.length > 0, n = E.map(
703
+ (h) => I(String(h.parent_field))
704
+ );
705
+ return /* @__PURE__ */ r(ee, { delayDuration: 100, children: /* @__PURE__ */ c(te, { children: [
706
+ /* @__PURE__ */ r(ne, { asChild: !0, children: /* @__PURE__ */ r(
707
+ "button",
708
+ {
709
+ type: "button",
710
+ "aria-label": `Show the fields that narrow ${S || "this list"}`,
711
+ onClick: pt,
712
+ className: D(
713
+ "inline-flex items-center transition-colors",
714
+ t ? "text-nvr-cyan hover:text-nvr-cyan" : "text-slate-300 hover:text-nvr-cyan dark:text-slate-600 dark:hover:text-nvr-cyan"
715
+ ),
716
+ children: /* @__PURE__ */ r(wt, { className: "h-3 w-3" })
717
+ }
718
+ ) }),
719
+ /* @__PURE__ */ r(re, { side: "top", className: "text-[12px]", children: t ? `Filtered by ${K.join(", ")} — click to highlight` : `Options filter by ${n.join(", ")} once set` })
720
+ ] }) });
721
+ })(),
722
+ ue && // Right-anchored: the personal-default control flush with the field's right edge
723
+ // (it carries Make / Update / Clear itself — no ⋯ button; right-click and
724
+ // Shift+F10 still open the field menu). The slot keeps one box whatever it shows,
725
+ // so nothing to its left moves.
726
+ /* @__PURE__ */ r("span", { className: "ml-auto inline-flex shrink-0 items-center gap-1", children: /* @__PURE__ */ r(
727
+ Zt,
728
+ {
729
+ field: e.field,
730
+ label: S,
731
+ state: ue,
732
+ confirmOpen: ce === "make" || ce === "update" ? ce : null,
733
+ onConfirm: (t, n) => (
734
+ // After a save the button becomes "Your default": focus goes to the field.
735
+ Xe(t, me, n)
736
+ ),
737
+ onUndo: () => {
738
+ L == null || L.undo(e.field), requestAnimationFrame(() => {
739
+ var t;
740
+ return (t = me()) == null ? void 0 : t.focus();
741
+ });
742
+ },
743
+ onCleared: () => (
744
+ // The Clear button is gone (and not a tab stop): focus goes to the field.
745
+ requestAnimationFrame(() => {
746
+ var t;
747
+ return (t = me()) == null ? void 0 : t.focus();
748
+ })
749
+ )
750
+ }
751
+ ) })
752
+ ]
753
+ }
754
+ ),
755
+ A.editor && !u && /* @__PURE__ */ r(
756
+ Mt,
751
757
  {
752
- editor: P.editor,
753
- confirming: P.confirming,
754
- onConfirm: P.confirm,
755
- onCancel: P.cancel
758
+ editor: A.editor,
759
+ confirming: A.confirming,
760
+ onConfirm: A.confirm,
761
+ onCancel: A.cancel
756
762
  }
757
763
  ),
758
- W ?? /* @__PURE__ */ n(
764
+ W ?? /* @__PURE__ */ r(
759
765
  "div",
760
766
  {
761
767
  ref: de,
762
- className: A(u && !z && "cursor-not-allowed"),
768
+ className: D(u && !V && "cursor-not-allowed"),
763
769
  "data-tip": (u || e.readonly) && O ? O : void 0,
764
770
  onPointerEnter: (u || e.readonly) && O ? s == null ? void 0 : s.onLockHover : void 0,
765
- children: /* @__PURE__ */ n(
771
+ children: /* @__PURE__ */ r(
766
772
  "div",
767
773
  {
768
- ref: _e,
769
- className: A(
774
+ ref: Ce,
775
+ className: D(
770
776
  // A locked FILE field stays interactive: its chips keep the
771
777
  // download link and preview click (the component itself hides
772
778
  // upload/replace/remove when readonly) — blocking pointer events
773
779
  // made attachments unopenable on every locked form (addendum
774
780
  // view, terminal states).
775
- u && !z && "pointer-events-none opacity-60",
781
+ u && !V && "pointer-events-none opacity-60",
776
782
  // The ring lands with a 2px shake so the eye finds the field;
777
783
  // the animation runs once when the class is added.
778
784
  N && "nvr-shake ring-1 ring-red-400 rounded-md",
779
- le && "nvr-autofill-glow"
785
+ ie && "nvr-autofill-glow"
780
786
  ),
781
- children: j ? /* @__PURE__ */ n(an, { field: e, values: m }) : it ? /* @__PURE__ */ n(
787
+ children: P ? /* @__PURE__ */ r(on, { field: e, values: m }) : ot ? /* @__PURE__ */ r(
782
788
  Pt,
783
789
  {
784
- collection: l,
790
+ collection: i,
785
791
  field: e,
786
792
  draft: m,
787
- itemId: i
793
+ itemId: l
788
794
  }
789
795
  ) : y ? y({
790
796
  field: e,
791
- value: ue,
792
- onChange: Ne,
797
+ value: he,
798
+ onChange: Le,
793
799
  disabled: u,
794
- collection: l,
795
- itemId: i,
800
+ collection: i,
801
+ itemId: l,
796
802
  relations: f,
797
- cascadeFilter: B,
798
- unsatisfiedParentLabel: st,
799
- requiredParentLabel: Pe
800
- }) : /* @__PURE__ */ n(
801
- Ht,
803
+ cascadeFilter: M,
804
+ unsatisfiedParentLabel: ct,
805
+ requiredParentLabel: je
806
+ }) : /* @__PURE__ */ r(
807
+ Ut,
802
808
  {
803
- field: u && z ? dt() : e,
804
- value: ue,
805
- onChange: Ne,
809
+ field: u && V ? ut() : e,
810
+ value: he,
811
+ onChange: Le,
806
812
  relations: f,
807
- collection: l,
808
- itemId: i,
809
- cascadeFilter: B,
810
- requiredParentLabel: Pe,
811
- narrowedBy: H.length > 0 ? ct() : void 0,
812
- onCountChange: a ? We : void 0
813
+ collection: i,
814
+ itemId: l,
815
+ cascadeFilter: M,
816
+ requiredParentLabel: je,
817
+ narrowedBy: K.length > 0 ? mt() : void 0,
818
+ onCountChange: a ? ze : void 0
813
819
  }
814
820
  )
815
821
  },
816
- le ?? 0
822
+ ie ?? 0
817
823
  )
818
824
  }
819
825
  ),
820
- qe && /* @__PURE__ */ n(on, { value: m[e.field], config: qe }),
821
- $e && !Se && /* @__PURE__ */ n(It, { field: e.field, text: $e }),
822
- Re && /* @__PURE__ */ n(
823
- Bt,
826
+ Ee && /* @__PURE__ */ r(sn, { value: m[e.field], config: Ee }),
827
+ Te && !Ie && /* @__PURE__ */ r(It, { field: e.field, text: Te }),
828
+ qe && /* @__PURE__ */ r(
829
+ Kt,
824
830
  {
825
- change: Re,
831
+ change: qe,
826
832
  onDismiss: () => s == null ? void 0 : s.dismissRemoteChange(e.field),
827
833
  onTakeTheirs: s != null && s.takeRemoteChange ? () => {
828
834
  var t;
@@ -836,7 +842,7 @@ const Yn = Ft(function({
836
842
  );
837
843
  });
838
844
  export {
839
- Yn as FieldRow,
840
- Qn as lineageSummary,
841
- yn as useFieldLineage
845
+ Zn as FieldRow,
846
+ Xn as lineageSummary,
847
+ gn as useFieldLineage
842
848
  };