@nivaro/react 0.3.144 → 0.3.146

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,242 +1,260 @@
1
- import { jsxs as o, jsx as n } from "react/jsx-runtime";
2
- import { useQuery as S, useQueryClient as Z, useMutation as I } from "@tanstack/react-query";
3
- import { useState as f, useMemo as J, useEffect as ee } from "react";
4
- import { useNivaroClient as W } from "../../context.js";
5
- import { get as G, post as q } from "../../lib/commands.js";
6
- import { useAfterIdle as te } from "../../lib/defer.js";
7
- import { queryKeys as re } from "../../lib/query-keys.js";
8
- import { hasRecordExtras as ne } from "../../lib/system-collections.js";
9
- import { formatRelative as ae, formatDateTime as ie, cn as K, titleCase as de } from "../../lib/utils.js";
10
- function oe(t, r, a = !0) {
11
- const u = W(), i = a && ne(t), { data: p } = S({
12
- queryKey: ["record-integrity", t, r],
1
+ import { jsxs as s, jsx as a } from "react/jsx-runtime";
2
+ import { useQuery as L, useQueryClient as ee, useMutation as M } from "@tanstack/react-query";
3
+ import { useState as f, useMemo as te, useEffect as re } from "react";
4
+ import { useNivaroClient as T } from "../../context.js";
5
+ import { get as X, post as K } from "../../lib/commands.js";
6
+ import { useAfterIdle as ne } from "../../lib/defer.js";
7
+ import { queryKeys as ae } from "../../lib/query-keys.js";
8
+ import { hasRecordExtras as ie } from "../../lib/system-collections.js";
9
+ import { formatRelative as oe, formatDateTime as de, cn as O, titleCase as se } from "../../lib/utils.js";
10
+ function le(r, t, n = !0) {
11
+ const l = T(), i = n && ie(r), { data: g } = L({
12
+ queryKey: ["record-integrity", r, t],
13
13
  enabled: i,
14
- queryFn: () => u.request(
15
- G(`/config-conformance/record/${t}/${encodeURIComponent(r)}`)
16
- ).then((d) => d.data).catch(() => ({ enabled: !1, findings: [] })),
14
+ queryFn: () => l.request(
15
+ X(`/config-conformance/record/${r}/${encodeURIComponent(t)}`)
16
+ ).then((o) => o.data).catch(() => ({ enabled: !1, findings: [] })),
17
17
  staleTime: 5 * 6e4
18
- }), h = te(2e3), { data: m, isFetching: k } = S({
19
- queryKey: ["record-integrity", t, r, "live"],
20
- enabled: i && h,
21
- queryFn: () => u.request(
22
- q(`/config-conformance/record/${t}/${encodeURIComponent(r)}/check`, {})
23
- ).then((d) => d.data).catch(() => null),
18
+ }), p = ne(2e3), { data: m, isFetching: h } = L({
19
+ queryKey: ["record-integrity", r, t, "live"],
20
+ enabled: i && p,
21
+ queryFn: () => l.request(
22
+ K(`/config-conformance/record/${r}/${encodeURIComponent(t)}/check`, {})
23
+ ).then((o) => o.data).catch(() => null),
24
24
  staleTime: 6e4,
25
25
  // Never spin the banner on a background refetch storm — one live check per
26
26
  // mount / invalidation is the contract.
27
27
  refetchOnWindowFocus: !1
28
28
  });
29
- return { data: m ?? p, checking: k };
29
+ return { data: m ?? g, checking: h };
30
30
  }
31
- const se = "nvr:own-record-writes";
32
- function H(t) {
33
- var a;
34
- const r = [];
35
- for (const u of t.writes ?? []) {
36
- const i = u;
37
- i && typeof i.collection == "string" && i.item_id != null && i.item_id !== "" && r.push({ collection: i.collection, id: String(i.item_id) });
31
+ const ce = "nvr:own-record-writes";
32
+ function Y(r) {
33
+ var n;
34
+ const t = [];
35
+ for (const l of r.writes ?? []) {
36
+ const i = l;
37
+ i && typeof i.collection == "string" && i.item_id != null && i.item_id !== "" && t.push({ collection: i.collection, id: String(i.item_id) });
38
38
  }
39
- return (a = t.pick) != null && a.collection && t.pick.item_id && r.push({ collection: t.pick.collection, id: String(t.pick.item_id) }), r;
39
+ return (n = r.pick) != null && n.collection && r.pick.item_id && t.push({ collection: r.pick.collection, id: String(r.pick.item_id) }), t;
40
40
  }
41
- function Y(t) {
42
- t.length === 0 || typeof window > "u" || window.dispatchEvent(
43
- new CustomEvent(se, { detail: { writes: t } })
41
+ function z(r) {
42
+ r.length === 0 || typeof window > "u" || window.dispatchEvent(
43
+ new CustomEvent(ce, { detail: { writes: r } })
44
44
  );
45
45
  }
46
- function le(t, r) {
47
- var u;
48
- const a = r == null ? void 0 : r.find((i) => i.field === t);
49
- return ((u = a == null ? void 0 : a.label) == null ? void 0 : u.trim()) || de(t);
46
+ function ue(r, t) {
47
+ var l;
48
+ const n = t == null ? void 0 : t.find((i) => i.field === r);
49
+ return ((l = n == null ? void 0 : n.label) == null ? void 0 : l.trim()) || se(r);
50
50
  }
51
- function ye(t) {
52
- const r = /* @__PURE__ */ new Map();
53
- for (const a of t ?? []) {
54
- const u = r.get(a.field) ?? [];
55
- u.push(a), r.set(a.field, u);
51
+ function we(r) {
52
+ const t = /* @__PURE__ */ new Map();
53
+ for (const n of r ?? []) {
54
+ const l = t.get(n.field) ?? [];
55
+ l.push(n), t.set(n.field, l);
56
56
  }
57
- return r;
57
+ return t;
58
58
  }
59
- const z = {
59
+ const G = {
60
60
  high: { dot: "bg-emerald-500", text: "Confident" },
61
61
  medium: { dot: "bg-amber-500", text: "Likely" },
62
62
  low: { dot: "bg-slate-400", text: "Manual" }
63
63
  };
64
- function ve({
65
- collection: t,
66
- itemId: r,
67
- onJumpToField: a
64
+ function Ce({
65
+ collection: r,
66
+ itemId: t,
67
+ onJumpToField: n
68
68
  }) {
69
- var R;
70
- const u = W(), i = Z(), [p, h] = f(!1), [m, k] = f(null), { data: d, checking: E } = oe(t, r), { data: y } = S({
71
- queryKey: re.fieldConfig(t, null),
72
- queryFn: () => u.request(G(`/field-config/${t}`)).then((l) => l.data ?? []),
73
- enabled: !!((R = d == null ? void 0 : d.findings) != null && R.length),
69
+ var N;
70
+ const l = T(), i = ee(), [g, p] = f(!1), [m, h] = f(null), { data: o, checking: E } = le(r, t), { data: P } = L({
71
+ queryKey: ae.fieldConfig(r, null),
72
+ queryFn: () => l.request(X(`/field-config/${r}`)).then((d) => d.data ?? []),
73
+ enabled: !!((N = o == null ? void 0 : o.findings) != null && N.length),
74
74
  staleTime: 6e4
75
- }), L = () => {
76
- i.invalidateQueries({ queryKey: ["record-integrity", t, r] }), i.invalidateQueries({ queryKey: ["item", t, r] }), i.invalidateQueries({ queryKey: ["rrv-record", t, r] }), i.invalidateQueries({ queryKey: ["o2m-rows"] }), i.invalidateQueries({ queryKey: ["revisions"] });
75
+ }), v = () => {
76
+ i.invalidateQueries({ queryKey: ["record-integrity", r, t] }), i.invalidateQueries({ queryKey: ["integrity-proposals", r, t] }), i.invalidateQueries({ queryKey: ["item", r, t] }), i.invalidateQueries({ queryKey: ["rrv-record", r, t] }), i.invalidateQueries({ queryKey: ["o2m-rows"] }), i.invalidateQueries({ queryKey: ["revisions"] });
77
77
  };
78
- if (!(d != null && d.enabled) || d.findings.length === 0) return null;
79
- const v = d.findings.length;
80
- return /* @__PURE__ */ o(
78
+ if (!(o != null && o.enabled) || o.findings.length === 0) return null;
79
+ const R = o.findings.length;
80
+ return /* @__PURE__ */ s(
81
81
  "div",
82
82
  {
83
83
  "data-record-integrity": !0,
84
84
  className: "nvr-expand-in rounded-lg border border-amber-200 bg-amber-50 px-4 py-2.5 dark:border-amber-500/30 dark:bg-amber-400/10",
85
85
  children: [
86
- /* @__PURE__ */ o("div", { className: "flex items-center gap-2", children: [
87
- /* @__PURE__ */ o("span", { className: "text-[12.5px] font-medium text-amber-800 dark:text-amber-300", children: [
88
- v,
86
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
87
+ /* @__PURE__ */ s("span", { className: "text-[12.5px] font-medium text-amber-800 dark:text-amber-300", children: [
88
+ R,
89
89
  " data integrity issue",
90
- v === 1 ? "" : "s",
90
+ R === 1 ? "" : "s",
91
91
  " on this record"
92
92
  ] }),
93
- d.live ? /* @__PURE__ */ n(
93
+ o.live ? /* @__PURE__ */ a(
94
94
  "span",
95
95
  {
96
96
  className: "text-[11px] text-amber-600/80 dark:text-amber-400/70",
97
97
  "data-integrity-checked": "live",
98
98
  children: "checked just now"
99
99
  }
100
- ) : E ? /* @__PURE__ */ n(
100
+ ) : E ? /* @__PURE__ */ a(
101
101
  "span",
102
102
  {
103
103
  className: "text-[11px] text-amber-600/80 dark:text-amber-400/70",
104
104
  "data-integrity-checked": "checking",
105
105
  children: "checking…"
106
106
  }
107
- ) : d.checked_at ? /* @__PURE__ */ o(
107
+ ) : o.checked_at ? /* @__PURE__ */ s(
108
108
  "span",
109
109
  {
110
110
  className: "text-[11px] text-amber-600/80 dark:text-amber-400/70",
111
111
  "data-integrity-checked": "stored",
112
- title: ie(d.checked_at),
112
+ title: de(o.checked_at),
113
113
  children: [
114
114
  "checked ",
115
- ae(d.checked_at)
115
+ oe(o.checked_at)
116
116
  ]
117
117
  }
118
118
  ) : null,
119
- /* @__PURE__ */ n(
119
+ /* @__PURE__ */ a(
120
120
  "button",
121
121
  {
122
122
  type: "button",
123
- onClick: () => h((l) => !l),
123
+ onClick: () => p((d) => !d),
124
124
  className: "ml-auto text-[11.5px] font-medium text-amber-700 underline decoration-dotted underline-offset-2 dark:text-amber-300",
125
- children: p ? "Hide" : "View"
125
+ children: g ? "Hide" : "View"
126
126
  }
127
127
  )
128
128
  ] }),
129
- p && /* @__PURE__ */ n("div", { className: "mt-1.5 space-y-1", children: d.findings.map((l, b) => /* @__PURE__ */ o("div", { children: [
130
- /* @__PURE__ */ o("div", { className: "flex items-baseline gap-2 text-[12px]", children: [
131
- /* @__PURE__ */ n(
129
+ g && /* @__PURE__ */ a("div", { className: "mt-1.5 space-y-1", children: o.findings.map((d) => /* @__PURE__ */ s("div", { children: [
130
+ /* @__PURE__ */ s("div", { className: "flex items-baseline gap-2 text-[12px]", children: [
131
+ /* @__PURE__ */ a(
132
132
  "button",
133
133
  {
134
134
  type: "button",
135
- onClick: () => a == null ? void 0 : a(l.field),
136
- "data-integrity-field": l.field,
135
+ onClick: () => n == null ? void 0 : n(d.field),
136
+ "data-integrity-field": d.field,
137
137
  className: "shrink-0 text-[11.5px] font-medium text-amber-700 underline decoration-dotted underline-offset-2 dark:text-amber-300",
138
- children: le(l.field, y)
138
+ children: ue(d.field, P)
139
139
  }
140
140
  ),
141
- /* @__PURE__ */ n("span", { className: "min-w-0 flex-1 text-amber-800 dark:text-amber-200/90", children: l.message }),
142
- l.fixable && /* @__PURE__ */ n(
141
+ /* @__PURE__ */ a("span", { className: "min-w-0 flex-1 text-amber-800 dark:text-amber-200/90", children: d.message }),
142
+ d.fixable && /* @__PURE__ */ a(
143
143
  "button",
144
144
  {
145
145
  type: "button",
146
- onClick: () => k((g) => g === b ? null : b),
147
- className: K(
146
+ onClick: () => h((w) => w === k(d) ? null : k(d)),
147
+ className: O(
148
148
  "shrink-0 rounded px-2 py-0.5 text-[10.5px] font-semibold transition-colors",
149
- m === b ? "bg-amber-200 text-amber-900 dark:bg-amber-400/30 dark:text-amber-100" : "bg-amber-600 text-white hover:bg-amber-700"
149
+ m === k(d) ? "bg-amber-200 text-amber-900 dark:bg-amber-400/30 dark:text-amber-100" : "bg-amber-600 text-white hover:bg-amber-700"
150
150
  ),
151
- children: m === b ? "Close" : "Fix…"
151
+ children: m === k(d) ? "Close" : "Fix…"
152
152
  }
153
153
  )
154
154
  ] }),
155
- m === b && /* @__PURE__ */ n(
156
- ce,
155
+ m === k(d) && /* @__PURE__ */ a(
156
+ me,
157
157
  {
158
- collection: t,
159
- itemId: r,
160
- finding: l,
161
- onApplied: L,
162
- onClose: () => k(null)
163
- }
158
+ collection: r,
159
+ itemId: t,
160
+ finding: d,
161
+ onApplied: v,
162
+ onClose: () => h(null)
163
+ },
164
+ k(d)
164
165
  )
165
- ] }, `${l.field}|${l.rule}|${b}`)) })
166
+ ] }, k(d))) })
166
167
  ]
167
168
  }
168
169
  );
169
170
  }
170
- function ce({
171
- collection: t,
172
- itemId: r,
173
- finding: a,
174
- onApplied: u,
171
+ function me({
172
+ collection: r,
173
+ itemId: t,
174
+ finding: n,
175
+ onApplied: l,
175
176
  onClose: i
176
177
  }) {
177
- const p = W(), h = `/config-conformance/record/${t}/${encodeURIComponent(r)}`, m = { field: a.field, rule: a.rule, message: a.message }, { data: k, isLoading: d, error: E } = S({
178
- queryKey: ["integrity-proposals", t, r, a.field, a.rule],
179
- queryFn: () => p.request(q(`${h}/proposals`, m)).then((e) => e.data.proposals),
178
+ const g = T(), p = `/config-conformance/record/${r}/${encodeURIComponent(t)}`, m = { field: n.field, rule: n.rule, message: n.message }, { data: h, isLoading: o, error: E, refetch: P } = L({
179
+ // The message is part of the finding: one field and rule can carry several findings
180
+ // ("Line 1: …", "Line 2: …"), each with its own proposals.
181
+ queryKey: [
182
+ "integrity-proposals",
183
+ r,
184
+ t,
185
+ n.field,
186
+ n.rule,
187
+ n.message
188
+ ],
189
+ queryFn: () => g.request(K(`${p}/proposals`, m)).then((e) => e.data.proposals),
180
190
  staleTime: 6e4
181
- }), [y, L] = f([]), [v, R] = f({}), [l, b] = f(""), [g, M] = f(null), [j, D] = f(0), [T, N] = f(null), [B, X] = f(null), [_, O] = f(null), V = J(() => [...k ?? [], ...y], [k, y]);
182
- ee(() => {
183
- if (!g || g.undo.length === 0) return;
184
- D(30);
185
- const e = setInterval(() => D((c) => c <= 1 ? 0 : c - 1), 1e3);
191
+ }), [v, R] = f([]), [N, d] = f({}), [w, Z] = f(""), [b, j] = f(null), [D, I] = f(0), [B, y] = f(null), [V, J] = f(null), [_, A] = f(null), H = te(() => [...h ?? [], ...v], [h, v]);
192
+ re(() => {
193
+ if (!b || b.undo.length === 0) return;
194
+ I(30);
195
+ const e = setInterval(() => I((u) => u <= 1 ? 0 : u - 1), 1e3);
186
196
  return () => clearInterval(e);
187
- }, [g]);
188
- const A = I({
189
- mutationFn: (e) => p.request(
190
- q(`${h}/fix`, {
197
+ }, [b]);
198
+ const F = M({
199
+ mutationFn: (e) => g.request(
200
+ K(`${p}/fix`, {
191
201
  ...m,
192
202
  proposal_id: e.id,
193
- choice: e.kind === "pick" ? v[e.id] : void 0
203
+ choice: e.kind === "pick" ? N[e.id] : void 0
194
204
  })
195
205
  ),
196
- onSuccess: (e, c) => {
197
- var C, $, s;
198
- N(null), Y(H(c)), X(c);
199
- const x = e.data, w = ((C = x.failed) == null ? void 0 : C.length) ?? 0;
200
- M({
201
- text: c.kind === "notify" ? `Sent to ${(($ = c.notify) == null ? void 0 : $.name) ?? "the owner"} as a task.` : `${x.applied} write${x.applied === 1 ? "" : "s"} applied${w ? ` — ${w} failed: ${((s = x.failed[0]) == null ? void 0 : s.error) ?? ""}` : ""}.`,
206
+ onSuccess: (e, u) => {
207
+ var q, $, c;
208
+ y(null), z(Y(u)), J(u);
209
+ const x = e.data, C = ((q = x.failed) == null ? void 0 : q.length) ?? 0;
210
+ j({
211
+ text: u.kind === "notify" ? `Sent to ${(($ = u.notify) == null ? void 0 : $.name) ?? "the owner"} as a task.` : `${x.applied} write${x.applied === 1 ? "" : "s"} applied${C ? ` — ${C} failed: ${((c = x.failed[0]) == null ? void 0 : c.error) ?? ""}` : ""}.`,
202
212
  undo: x.undo ?? []
203
- }), u();
213
+ }), l();
204
214
  },
205
- onError: (e) => N(F(e))
206
- }), P = I({
207
- mutationFn: (e) => p.request(q(`${h}/fix`, { ...m, undo: e })),
215
+ onError: (e) => {
216
+ if (xe(e) === 409) {
217
+ A(null), y(
218
+ "The record changed, so these suggestions were refreshed. Check them and apply again."
219
+ ), P();
220
+ return;
221
+ }
222
+ y(S(e));
223
+ }
224
+ }), Q = M({
225
+ mutationFn: (e) => g.request(K(`${p}/fix`, { ...m, undo: e })),
208
226
  onSuccess: () => {
209
- B && Y(H(B)), M({ text: "Undone.", undo: [] }), u();
227
+ V && z(Y(V)), j({ text: "Undone.", undo: [] }), l();
210
228
  },
211
- onError: (e) => N(F(e))
212
- }), Q = I({
213
- mutationFn: () => p.request(q(`${h}/proposals/ai`, m)).then((e) => e.data.proposal),
229
+ onError: (e) => y(S(e))
230
+ }), U = M({
231
+ mutationFn: () => g.request(K(`${p}/proposals/ai`, m)).then((e) => e.data.proposal),
214
232
  onSuccess: (e) => {
215
- N(null), L((c) => c.some((x) => x.id === e.id) ? c : [...c, e]);
233
+ y(null), R((u) => u.some((x) => x.id === e.id) ? u : [...u, e]);
216
234
  },
217
- onError: (e) => N(F(e))
235
+ onError: (e) => y(S(e))
218
236
  });
219
- return /* @__PURE__ */ o(
237
+ return /* @__PURE__ */ s(
220
238
  "div",
221
239
  {
222
240
  "data-integrity-proposals": !0,
223
241
  className: "mt-1.5 rounded-md border border-amber-200/80 bg-white/70 px-3 py-2 dark:border-amber-500/20 dark:bg-black/20",
224
242
  children: [
225
- d && /* @__PURE__ */ n("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: "Working out what would fix this…" }),
226
- E && /* @__PURE__ */ n("p", { className: "text-[11.5px] text-red-600 dark:text-red-400", children: F(E) }),
227
- g ? /* @__PURE__ */ o("div", { className: "flex flex-wrap items-center gap-2 text-[11.5px]", children: [
228
- /* @__PURE__ */ n("span", { className: "font-medium text-emerald-700 dark:text-emerald-400", children: g.text }),
229
- g.undo.length > 0 && j > 0 && /* @__PURE__ */ n(
243
+ o && /* @__PURE__ */ a("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: "Working out what would fix this…" }),
244
+ E && /* @__PURE__ */ a("p", { className: "text-[11.5px] text-red-600 dark:text-red-400", children: S(E) }),
245
+ b ? /* @__PURE__ */ s("div", { className: "flex flex-wrap items-center gap-2 text-[11.5px]", children: [
246
+ /* @__PURE__ */ a("span", { className: "font-medium text-emerald-700 dark:text-emerald-400", children: b.text }),
247
+ b.undo.length > 0 && D > 0 && /* @__PURE__ */ a(
230
248
  "button",
231
249
  {
232
250
  type: "button",
233
- disabled: P.isPending,
234
- onClick: () => P.mutate(g.undo),
251
+ disabled: Q.isPending,
252
+ onClick: () => Q.mutate(b.undo),
235
253
  className: "rounded border border-slate-300 px-2 py-0.5 text-[11px] font-medium text-slate-700 hover:bg-slate-50 disabled:opacity-50 dark:border-border dark:text-foreground dark:hover:bg-muted",
236
- children: P.isPending ? "Undoing…" : `Undo (${j}s)`
254
+ children: Q.isPending ? "Undoing…" : `Undo (${D}s)`
237
255
  }
238
256
  ),
239
- /* @__PURE__ */ n(
257
+ /* @__PURE__ */ a(
240
258
  "button",
241
259
  {
242
260
  type: "button",
@@ -245,33 +263,33 @@ function ce({
245
263
  children: "Done"
246
264
  }
247
265
  )
248
- ] }) : !d && /* @__PURE__ */ o("div", { className: "space-y-1.5", children: [
249
- V.length === 0 && /* @__PURE__ */ n("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: "Nothing on this record can derive a value — fix it by hand on the form." }),
250
- V.map((e) => {
251
- var C, $;
252
- const c = z[e.confidence] ?? z.low, x = v[e.id], w = (e.choices ?? []).filter(
253
- (s) => !l || s.label.toLowerCase().includes(l.toLowerCase())
266
+ ] }) : !o && /* @__PURE__ */ s("div", { className: "space-y-1.5", children: [
267
+ H.length === 0 && /* @__PURE__ */ a("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: "Nothing on this record can derive a value — fix it by hand on the form." }),
268
+ H.map((e) => {
269
+ var q, $;
270
+ const u = G[e.confidence] ?? G.low, x = N[e.id], C = (e.choices ?? []).filter(
271
+ (c) => !w || c.label.toLowerCase().includes(w.toLowerCase())
254
272
  );
255
- return /* @__PURE__ */ n(
273
+ return /* @__PURE__ */ a(
256
274
  "div",
257
275
  {
258
276
  className: "rounded border border-slate-200/80 bg-white px-2.5 py-1.5 dark:border-border dark:bg-card",
259
- children: /* @__PURE__ */ o("div", { className: "flex items-start gap-2", children: [
260
- /* @__PURE__ */ n(
277
+ children: /* @__PURE__ */ s("div", { className: "flex items-start gap-2", children: [
278
+ /* @__PURE__ */ a(
261
279
  "span",
262
280
  {
263
- className: K("mt-1.5 h-2 w-2 shrink-0 rounded-full", c.dot),
264
- title: c.text,
265
- "data-tip": c.text
281
+ className: O("mt-1.5 h-2 w-2 shrink-0 rounded-full", u.dot),
282
+ title: u.text,
283
+ "data-tip": u.text
266
284
  }
267
285
  ),
268
- /* @__PURE__ */ o("div", { className: "min-w-0 flex-1", children: [
269
- /* @__PURE__ */ o("p", { className: "text-[12px] font-medium text-slate-800 dark:text-foreground", children: [
286
+ /* @__PURE__ */ s("div", { className: "min-w-0 flex-1", children: [
287
+ /* @__PURE__ */ s("p", { className: "text-[12px] font-medium text-slate-800 dark:text-foreground", children: [
270
288
  e.label,
271
- /* @__PURE__ */ n("span", { className: "ml-1.5 text-[10px] font-normal uppercase tracking-wide text-slate-400", children: e.kind === "ai" ? "AI" : c.text })
289
+ /* @__PURE__ */ a("span", { className: "ml-1.5 text-[10px] font-normal uppercase tracking-wide text-slate-400", children: e.kind === "ai" ? "AI" : u.text })
272
290
  ] }),
273
- /* @__PURE__ */ n("p", { className: "text-[11px] leading-snug text-slate-500 dark:text-muted-foreground", children: e.basis }),
274
- e.confirm && _ === e.id && /* @__PURE__ */ o(
291
+ /* @__PURE__ */ a("p", { className: "text-[11px] leading-snug text-slate-500 dark:text-muted-foreground", children: e.basis }),
292
+ e.confirm && _ === e.id && /* @__PURE__ */ s(
275
293
  "p",
276
294
  {
277
295
  role: "alert",
@@ -280,11 +298,11 @@ function ce({
280
298
  children: [
281
299
  e.confirm,
282
300
  " ",
283
- /* @__PURE__ */ n(
301
+ /* @__PURE__ */ a(
284
302
  "button",
285
303
  {
286
304
  type: "button",
287
- onClick: () => O(null),
305
+ onClick: () => A(null),
288
306
  className: "font-normal text-slate-600 underline underline-offset-2 hover:text-slate-900 dark:text-muted-foreground dark:hover:text-foreground",
289
307
  children: "Keep it"
290
308
  }
@@ -292,74 +310,74 @@ function ce({
292
310
  ]
293
311
  }
294
312
  ),
295
- e.preview.length > 0 && /* @__PURE__ */ o("div", { className: "mt-1 flex flex-wrap gap-1", children: [
296
- e.preview.slice(0, 8).map((s, U) => /* @__PURE__ */ o(
313
+ e.preview.length > 0 && /* @__PURE__ */ s("div", { className: "mt-1 flex flex-wrap gap-1", children: [
314
+ e.preview.slice(0, 8).map((c, W) => /* @__PURE__ */ s(
297
315
  "span",
298
316
  {
299
317
  className: "rounded bg-slate-100 px-1.5 py-0.5 text-[10.5px] text-slate-700 dark:bg-muted dark:text-foreground",
300
318
  children: [
301
- s.label,
319
+ c.label,
302
320
  ": ",
303
- /* @__PURE__ */ n("span", { className: "line-through opacity-60", children: s.from }),
321
+ /* @__PURE__ */ a("span", { className: "line-through opacity-60", children: c.from }),
304
322
  " ",
305
323
  "→ ",
306
- /* @__PURE__ */ n("span", { className: "font-medium", children: s.to })
324
+ /* @__PURE__ */ a("span", { className: "font-medium", children: c.to })
307
325
  ]
308
326
  },
309
- `${s.item_id}|${s.field}|${U}`
327
+ `${c.item_id}|${c.field}|${W}`
310
328
  )),
311
- e.preview.length > 8 && /* @__PURE__ */ o("span", { className: "text-[10.5px] text-slate-400", children: [
329
+ e.preview.length > 8 && /* @__PURE__ */ s("span", { className: "text-[10.5px] text-slate-400", children: [
312
330
  "+",
313
331
  e.preview.length - 8,
314
332
  " more"
315
333
  ] })
316
334
  ] }),
317
- e.kind === "pick" && /* @__PURE__ */ o("div", { className: "mt-1.5", children: [
318
- (((C = e.choices) == null ? void 0 : C.length) ?? 0) > 8 && /* @__PURE__ */ n(
335
+ e.kind === "pick" && /* @__PURE__ */ s("div", { className: "mt-1.5", children: [
336
+ (((q = e.choices) == null ? void 0 : q.length) ?? 0) > 8 && /* @__PURE__ */ a(
319
337
  "input",
320
338
  {
321
- value: l,
322
- onChange: (s) => b(s.target.value),
339
+ value: w,
340
+ onChange: (c) => Z(c.target.value),
323
341
  placeholder: "Filter options…",
324
342
  className: "mb-1 h-6 w-full rounded border border-slate-200 bg-white px-2 text-[11px] dark:border-border dark:bg-background"
325
343
  }
326
344
  ),
327
- /* @__PURE__ */ o("div", { className: "flex max-h-36 flex-wrap gap-1 overflow-y-auto", children: [
328
- w.map((s) => /* @__PURE__ */ n(
345
+ /* @__PURE__ */ s("div", { className: "flex max-h-36 flex-wrap gap-1 overflow-y-auto", children: [
346
+ C.map((c) => /* @__PURE__ */ a(
329
347
  "button",
330
348
  {
331
349
  type: "button",
332
- onClick: () => R((U) => ({ ...U, [e.id]: s.id })),
333
- className: K(
350
+ onClick: () => d((W) => ({ ...W, [e.id]: c.id })),
351
+ className: O(
334
352
  "rounded border px-1.5 py-0.5 text-[11px] transition-colors",
335
- x === s.id ? "border-nvr-cyan bg-nvr-cyan/10 text-slate-900 dark:text-foreground" : "border-slate-200 text-slate-700 hover:bg-muted dark:border-border dark:text-foreground"
353
+ x === c.id ? "border-nvr-cyan bg-nvr-cyan/10 text-slate-900 dark:text-foreground" : "border-slate-200 text-slate-700 hover:bg-muted dark:border-border dark:text-foreground"
336
354
  ),
337
- children: s.label
355
+ children: c.label
338
356
  },
339
- s.id
357
+ c.id
340
358
  )),
341
- w.length === 0 && /* @__PURE__ */ n("span", { className: "text-[11px] text-slate-400", children: "No options match." })
359
+ C.length === 0 && /* @__PURE__ */ a("span", { className: "text-[11px] text-slate-400", children: "No options match." })
342
360
  ] })
343
361
  ] })
344
362
  ] }),
345
- /* @__PURE__ */ n(
363
+ /* @__PURE__ */ a(
346
364
  "button",
347
365
  {
348
366
  type: "button",
349
- disabled: A.isPending || e.kind === "pick" && !x,
367
+ disabled: F.isPending || e.kind === "pick" && !x,
350
368
  "data-integrity-apply": e.id,
351
369
  onClick: () => {
352
370
  if (e.confirm && _ !== e.id) {
353
- O(e.id);
371
+ A(e.id);
354
372
  return;
355
373
  }
356
- O(null), A.mutate(e);
374
+ A(null), F.mutate(e);
357
375
  },
358
- className: K(
376
+ className: O(
359
377
  "shrink-0 rounded px-2 py-0.5 text-[10.5px] font-semibold text-white transition-colors disabled:opacity-50",
360
378
  e.confirm && _ === e.id ? "bg-red-600 hover:bg-red-700" : e.kind === "notify" ? "bg-slate-600 hover:bg-slate-700" : "bg-nvr-cyan hover:bg-nvr-cyan-dark"
361
379
  ),
362
- children: A.isPending && (($ = A.variables) == null ? void 0 : $.id) === e.id ? "Applying…" : e.confirm && _ === e.id ? "Yes, remove" : e.kind === "notify" ? "Send" : e.confirm ? "Remove" : "Apply"
380
+ children: F.isPending && (($ = F.variables) == null ? void 0 : $.id) === e.id ? "Applying…" : e.confirm && _ === e.id ? "Yes, remove" : e.kind === "notify" ? "Send" : e.confirm ? "Remove" : "Apply"
363
381
  }
364
382
  )
365
383
  ] })
@@ -367,18 +385,18 @@ function ce({
367
385
  e.id
368
386
  );
369
387
  }),
370
- /* @__PURE__ */ o("div", { className: "flex items-center gap-2 pt-0.5", children: [
371
- !y.some((e) => e.kind === "ai") && /* @__PURE__ */ n(
388
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-2 pt-0.5", children: [
389
+ !v.some((e) => e.kind === "ai") && /* @__PURE__ */ a(
372
390
  "button",
373
391
  {
374
392
  type: "button",
375
- disabled: Q.isPending,
376
- onClick: () => Q.mutate(),
393
+ disabled: U.isPending,
394
+ onClick: () => U.mutate(),
377
395
  className: "text-[11px] font-medium text-slate-600 underline decoration-dotted underline-offset-2 hover:text-slate-900 disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground",
378
- children: Q.isPending ? "Asking AI…" : "Ask AI for a suggestion"
396
+ children: U.isPending ? "Asking AI…" : "Ask AI for a suggestion"
379
397
  }
380
398
  ),
381
- /* @__PURE__ */ n(
399
+ /* @__PURE__ */ a(
382
400
  "button",
383
401
  {
384
402
  type: "button",
@@ -388,22 +406,31 @@ function ce({
388
406
  }
389
407
  )
390
408
  ] }),
391
- T && /* @__PURE__ */ n("p", { className: "text-[11px] text-red-600 dark:text-red-400", children: T })
409
+ B && /* @__PURE__ */ a("p", { className: "text-[11px] text-red-600 dark:text-red-400", children: B })
392
410
  ] })
393
411
  ]
394
412
  }
395
413
  );
396
414
  }
397
- function F(t) {
398
- var a;
399
- const r = t;
400
- return String(((a = r == null ? void 0 : r.response) == null ? void 0 : a.error) ?? (r == null ? void 0 : r.message) ?? "Request failed");
415
+ function k(r) {
416
+ return `${r.field}|${r.rule}|${r.message ?? ""}`;
417
+ }
418
+ function xe(r) {
419
+ var l;
420
+ const t = r, n = (t == null ? void 0 : t.status) ?? (t == null ? void 0 : t.statusCode) ?? ((l = t == null ? void 0 : t.response) == null ? void 0 : l.status);
421
+ return typeof n == "number" ? n : null;
422
+ }
423
+ function S(r) {
424
+ var n;
425
+ const t = r;
426
+ return String(((n = t == null ? void 0 : t.response) == null ? void 0 : n.error) ?? (t == null ? void 0 : t.message) ?? "Request failed");
401
427
  }
402
428
  export {
403
- se as OWN_RECORD_WRITES_EVENT,
404
- ve as RecordIntegrityBanner,
405
- le as findingFieldLabel,
406
- ye as integrityByField,
407
- H as ownWritesOf,
408
- oe as useRecordIntegrity
429
+ ce as OWN_RECORD_WRITES_EVENT,
430
+ Ce as RecordIntegrityBanner,
431
+ ue as findingFieldLabel,
432
+ k as findingKey,
433
+ we as integrityByField,
434
+ Y as ownWritesOf,
435
+ le as useRecordIntegrity
409
436
  };