@nivaro/react 0.3.56 → 0.3.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +9 -2
  4. package/dist/shared/components/CollectionBrowserView.js +2827 -2750
  5. package/dist/shared/components/DataTable.js +247 -236
  6. package/dist/shared/components/ItemEditForm.js +1693 -1668
  7. package/dist/shared/components/ProfileView.js +716 -715
  8. package/dist/shared/components/RecordReadView.js +367 -364
  9. package/dist/shared/components/ReportView.js +64 -39
  10. package/dist/shared/components/alerts/AlertManagerView.js +284 -271
  11. package/dist/shared/components/cbv/row-focus.js +19 -0
  12. package/dist/shared/components/help-videos/HelpVideoPlayer.js +152 -147
  13. package/dist/shared/components/integrations/console/SignalCard.js +59 -59
  14. package/dist/shared/components/integrations/console/tone.js +52 -30
  15. package/dist/shared/components/item-edit/CatalogPickerField.js +525 -505
  16. package/dist/shared/components/item-edit/FieldRow.js +175 -173
  17. package/dist/shared/components/item-edit/InlineTableField.js +407 -402
  18. package/dist/shared/components/item-edit/M2MCombobox.js +313 -291
  19. package/dist/shared/components/item-edit/MidairCollisionDialog.js +1 -1
  20. package/dist/shared/components/item-edit/PlanGrid.js +826 -803
  21. package/dist/shared/components/item-edit/QuickCreateButton.js +115 -79
  22. package/dist/shared/components/item-edit/RecordLiveSync.js +77 -75
  23. package/dist/shared/components/item-edit/RelationCombobox.js +412 -328
  24. package/dist/shared/components/item-edit/RelationGroupedCombobox.js +147 -125
  25. package/dist/shared/components/item-edit/SummaryPanel.js +406 -392
  26. package/dist/shared/components/item-edit/option-disambiguate.js +44 -32
  27. package/dist/shared/components/item-edit/related-missing.js +45 -0
  28. package/dist/shared/components/item-edit/save-outcome.js +5 -5
  29. package/dist/shared/components/notifications/NotificationRulesEditor.js +130 -123
  30. package/dist/shared/components/panels/AccessDeniedPanel.js +52 -48
  31. package/dist/shared/components/panels/ItemLockBanner.js +2 -3
  32. package/dist/shared/components/panels/PipelinePanel.js +1027 -978
  33. package/dist/shared/components/panels/RevisionsPanel.js +4 -1
  34. package/dist/shared/components/panels/TaskPanel.js +265 -249
  35. package/dist/shared/components/panels/landing-state.js +27 -0
  36. package/dist/shared/components/pipeline/PipelineEditorView.js +86 -78
  37. package/dist/shared/components/profile/AiMemoryCard.js +12 -10
  38. package/dist/shared/components/queue/OwnerAvatars.js +80 -41
  39. package/dist/shared/components/queue/QueueItemSheet.js +111 -111
  40. package/dist/shared/components/queue/QueueQuickFilters.js +48 -48
  41. package/dist/shared/components/queue/QueueWorklist.js +975 -964
  42. package/dist/shared/components/queue/group-sums.js +27 -0
  43. package/dist/shared/components/queue/live-state-aspect.js +7 -3
  44. package/dist/shared/components/queue/path-label.js +14 -0
  45. package/dist/shared/components/widgets/ReviewListWidget.js +186 -168
  46. package/dist/shared/lib/back-closes.js +25 -0
  47. package/dist/shared/lib/cbv-page-warm.js +36 -0
  48. package/dist/shared/lib/form-usage-beacon.js +7 -7
  49. package/dist/shared/lib/list-page-memory.js +41 -0
  50. package/dist/shared/lib/live.js +44 -44
  51. package/dist/shared/lib/own-writes.js +76 -28
  52. package/dist/shared/lib/record-ref.js +78 -53
  53. package/dist/shared/lib/request-gate.js +110 -109
  54. package/dist/shared/lib/validation-rules.js +34 -19
  55. package/package.json +1 -1
@@ -1,212 +1,235 @@
1
- import { jsxs as u, jsx as s } from "react/jsx-runtime";
2
- import { useQuery as S } from "@tanstack/react-query";
3
- import { ChevronDown as $e, Loader2 as B, AlertTriangle as ze, Search as He, X as Ye, Check as Ce } from "lucide-react";
4
- import { useState as $, useRef as I, useEffect as j, useLayoutEffect as We, useMemo as K } from "react";
5
- import { createPortal as je } from "react-dom";
6
- import { useNivaroClient as ae, useItemEditAuth as Xe, useStaleFieldReporter as Ge } from "../../context.js";
7
- import { get as R, post as Ve } from "../../lib/commands.js";
8
- import { compareByMatch as Ze } from "../../lib/picker-rank.js";
9
- import { useRecordReader as Re } from "../../lib/record-loader.js";
10
- import { useOnlineUsers as Qe } from "../../lib/use-online-users.js";
11
- import { SearchHighlight as Be } from "../SearchHighlight.js";
12
- import { UserAvatar as et } from "../UserAvatar.js";
13
- import { userOptionFilter as tt, cn as J } from "../../lib/utils.js";
14
- import { applyDisplayTemplate as k } from "./helpers.js";
15
- import { collidingIds as rt, disambiguators as nt } from "./option-disambiguate.js";
16
- import { usePickerMissReport as st } from "./picker-miss.js";
17
- import { useLatestSearch as it, narrowLocally as ot } from "./picker-search.js";
18
- function at(n) {
19
- return n.replace(/\(.*$/, "").trim().split(/\s+/).map((r) => r[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() || "?";
1
+ import { jsxs as h, jsx as s } from "react/jsx-runtime";
2
+ import { useQuery as C } from "@tanstack/react-query";
3
+ import { ChevronDown as Ve, Loader2 as ce, AlertTriangle as ft, Search as mt, X as pt, Check as We } from "lucide-react";
4
+ import { useState as E, useRef as j, useEffect as L, useId as gt, useLayoutEffect as bt, useMemo as T } from "react";
5
+ import { createPortal as Ge } from "react-dom";
6
+ import { useNivaroClient as Le, useItemEditAuth as ht, useStaleFieldReporter as xt } from "../../context.js";
7
+ import { get as P, post as yt } from "../../lib/commands.js";
8
+ import { compareByMatch as wt } from "../../lib/picker-rank.js";
9
+ import { useRecordReader as Ze } from "../../lib/record-loader.js";
10
+ import { useOnlineUsers as vt } from "../../lib/use-online-users.js";
11
+ import { SearchHighlight as kt } from "../SearchHighlight.js";
12
+ import { UserAvatar as Nt } from "../UserAvatar.js";
13
+ import { userOptionFilter as St, matchesAllTokens as _t, cn as O } from "../../lib/utils.js";
14
+ import { applyDisplayTemplate as S } from "./helpers.js";
15
+ import { collidingIds as Lt, disambiguators as qt, isNamelessLabel as X, NAMELESS_LABEL as ee } from "./option-disambiguate.js";
16
+ import { usePickerMissReport as $t } from "./picker-miss.js";
17
+ import { useLatestSearch as Ct, narrowLocally as Et } from "./picker-search.js";
18
+ import { retryRelatedRead as Rt, RelatedMissingLabel as Dt } from "./related-missing.js";
19
+ function It(o) {
20
+ return o.replace(/\(.*$/, "").trim().split(/\s+/).map((n) => n[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() || "?";
20
21
  }
21
- function lt(n) {
22
- const [r, d] = $(null), y = {
23
- onMouseEnter: (g) => {
24
- if (!n) return;
25
- const p = g.currentTarget.getBoundingClientRect(), m = window.innerHeight - p.bottom < 80;
26
- d({ x: p.left, y: m ? p.top - 58 : p.bottom + 4 });
22
+ function At(o) {
23
+ const [n, f] = E(null), y = {
24
+ onMouseEnter: (w) => {
25
+ if (!o) return;
26
+ const x = w.currentTarget.getBoundingClientRect(), p = window.innerHeight - x.bottom < 80;
27
+ f({ x: x.left, y: p ? x.top - 58 : x.bottom + 4 });
27
28
  },
28
- onMouseLeave: () => d(null)
29
- }, _ = n && r ? je(
29
+ onMouseLeave: () => f(null)
30
+ }, R = o && n ? Ge(
30
31
  /* @__PURE__ */ s(
31
32
  "div",
32
33
  {
33
- style: { position: "fixed", left: r.x, top: r.y, zIndex: 130 },
34
+ style: { position: "fixed", left: n.x, top: n.y, zIndex: 130 },
34
35
  className: "pointer-events-none max-w-[300px] rounded-md border border-amber-200 bg-amber-50 px-2.5 py-1.5 text-[11.5px] leading-snug text-amber-800 shadow-md dark:border-amber-500/40 dark:bg-[#2a2113] dark:text-amber-300",
35
36
  children: "Current value is not an available option — clear to pick another"
36
37
  }
37
38
  ),
38
39
  document.body
39
40
  ) : null;
40
- return { bind: y, tip: _ };
41
+ return { bind: y, tip: R };
41
42
  }
42
- function Le(n, r) {
43
- return n == null || n === "" || r == null || r === "" ? !1 : String(n) === String(r);
43
+ function Xe(o, n) {
44
+ return o == null || o === "" || n == null || n === "" ? !1 : String(o) === String(n);
44
45
  }
45
- function dt({
46
- collection: n,
47
- value: r,
48
- onChange: d,
46
+ function Kt({
47
+ collection: o,
48
+ value: n,
49
+ onChange: f,
49
50
  disabled: y,
50
- placeholder: _,
51
- extraFilter: g,
52
- autoSelectSingle: p,
53
- optionSort: m,
54
- requiredParent: F,
55
- facets: o,
56
- fieldKey: C,
57
- narrowedBy: a,
58
- pinned: f,
59
- missPlacement: q,
60
- defaultOpen: Fe,
61
- onClose: le
51
+ placeholder: R,
52
+ extraFilter: w,
53
+ autoSelectSingle: x,
54
+ optionSort: p,
55
+ requiredParent: U,
56
+ facets: l,
57
+ fieldKey: D,
58
+ narrowedBy: i,
59
+ pinned: d,
60
+ missPlacement: I,
61
+ defaultOpen: Qe,
62
+ onClose: qe
62
63
  }) {
63
- const T = ae(), de = Re(), [c, P] = $(Fe ?? !1), [v, ce] = $(""), z = I(le);
64
- z.current = le;
65
- const ue = I(c);
66
- j(() => {
64
+ const H = Le(), $e = Ze(), [c, A] = E(Qe ?? !1), [u, de] = E(""), te = j(qe);
65
+ te.current = qe;
66
+ const Ce = j(c);
67
+ L(() => {
67
68
  var e;
68
- ue.current && !c && ((e = z.current) == null || e.call(z)), ue.current = c;
69
+ Ce.current && !c && ((e = te.current) == null || e.call(te)), Ce.current = c;
69
70
  }, [c]);
70
- const [Te, Ee] = $(!1), L = it(v, Te), me = I(null), H = I(null);
71
- j(() => {
71
+ const [Be, et] = E(!1), M = Ct(u, Be), Ee = j(null), J = j(null), ue = j(null), ne = j(null), fe = gt(), [Re, F] = E(-1);
72
+ L(() => {
72
73
  c ? setTimeout(() => {
73
74
  var e;
74
- return (e = me.current) == null ? void 0 : e.focus();
75
- }, 30) : ce("");
76
- }, [c]), j(() => {
75
+ return (e = Ee.current) == null ? void 0 : e.focus();
76
+ }, 30) : de("");
77
+ }, [c]);
78
+ const me = () => {
79
+ var e;
80
+ A(!1), (e = ne.current) == null || e.focus();
81
+ };
82
+ L(() => {
83
+ if (!c) return;
84
+ const e = (r) => {
85
+ var N, _, B;
86
+ if (r.key !== "Escape") return;
87
+ const t = document.activeElement;
88
+ (t === document.body || t && ((N = ue.current) != null && N.contains(t) || (_ = J.current) != null && _.contains(t))) && (r.preventDefault(), r.stopPropagation(), A(!1), (B = ne.current) == null || B.focus());
89
+ };
90
+ return window.addEventListener("keydown", e, !0), () => window.removeEventListener("keydown", e, !0);
91
+ }, [c]), L(() => {
77
92
  if (!c) return;
78
- const e = (i) => {
79
- var l;
80
- const t = i.target;
81
- (l = t == null ? void 0 : t.closest) != null && l.call(t, "[data-nvr-combobox-panel]") || H.current && !H.current.contains(i.target) && P(!1);
93
+ const e = (r) => {
94
+ var a, N;
95
+ const t = r.target;
96
+ !t || t === document.body || (a = t.closest) != null && a.call(t, "[data-nvr-combobox-panel]") || (N = J.current) != null && N.contains(t) || A(!1);
97
+ };
98
+ return document.addEventListener("focusin", e), () => document.removeEventListener("focusin", e);
99
+ }, [c]), L(() => {
100
+ if (!c) return;
101
+ const e = (r) => {
102
+ var a;
103
+ const t = r.target;
104
+ (a = t == null ? void 0 : t.closest) != null && a.call(t, "[data-nvr-combobox-panel]") || J.current && !J.current.contains(r.target) && A(!1);
82
105
  };
83
106
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
84
107
  }, [c]);
85
- const [pe, ee] = $(null), [fe, Oe] = $(null);
86
- We(() => {
108
+ const [De, pe] = E(null), [Ie, tt] = E(null);
109
+ bt(() => {
87
110
  if (!c) {
88
- ee(null);
111
+ pe(null);
89
112
  return;
90
113
  }
91
114
  const e = () => {
92
- const i = H.current;
93
- if (!i) return;
94
- const t = i.getBoundingClientRect(), l = i.closest('[role="dialog"]') ?? document.body;
95
- Oe(l);
96
- const Ne = window.innerHeight - t.bottom < 340 && t.top > window.innerHeight - t.bottom, ke = t.left, Se = Ne ? t.top - 4 : t.bottom + 4, _e = {
115
+ const r = J.current;
116
+ if (!r) return;
117
+ const t = r.getBoundingClientRect(), a = r.closest('[role="dialog"]') ?? document.body;
118
+ tt(a);
119
+ const N = window.innerHeight - t.bottom < 340 && t.top > window.innerHeight - t.bottom, _ = t.left, B = N ? t.top - 4 : t.bottom + 4, ze = {
97
120
  minWidth: t.width,
98
121
  zIndex: 120,
99
- ...Ne ? { transform: "translateY(-100%)" } : {}
122
+ ...N ? { transform: "translateY(-100%)" } : {}
100
123
  };
101
- if (l === document.body)
102
- ee({ position: "fixed", left: ke, top: Se, ..._e });
124
+ if (a === document.body)
125
+ pe({ position: "fixed", left: _, top: B, ...ze });
103
126
  else {
104
- const qe = l.getBoundingClientRect();
105
- ee({ position: "absolute", left: ke - qe.left, top: Se - qe.top, ..._e });
127
+ const Ye = a.getBoundingClientRect();
128
+ pe({ position: "absolute", left: _ - Ye.left, top: B - Ye.top, ...ze });
106
129
  }
107
130
  };
108
131
  return e(), window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
109
132
  window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
110
133
  };
111
134
  }, [c]);
112
- const { data: te, isPending: Ie } = S({
113
- queryKey: ["col-meta", n],
114
- queryFn: () => T.request(R(`/collections/${n}`)).then((e) => e.data),
135
+ const { data: ge, isPending: nt } = C({
136
+ queryKey: ["col-meta", o],
137
+ queryFn: () => H.request(P(`/collections/${o}`)).then((e) => e.data),
115
138
  staleTime: 3e5,
116
139
  retry: !1
117
- }), [re, Ke] = $({}), { data: he = [] } = S({
118
- queryKey: ["collection-meta", n],
119
- queryFn: () => T.request(
120
- R(`/collections/${n}`)
140
+ }), [be, rt] = E({}), { data: Ae = [] } = C({
141
+ queryKey: ["collection-meta", o],
142
+ queryFn: () => H.request(
143
+ P(`/collections/${o}`)
121
144
  ).then(
122
145
  (e) => {
123
- var i;
124
- return ((i = e.data) == null ? void 0 : i.relations) ?? [];
146
+ var r;
147
+ return ((r = e.data) == null ? void 0 : r.relations) ?? [];
125
148
  }
126
149
  ),
127
- enabled: !!(o != null && o.length),
150
+ enabled: !!(l != null && l.length),
128
151
  staleTime: 10 * 6e4
129
- }), Pe = K(() => {
152
+ }), ot = T(() => {
130
153
  const e = {};
131
- for (const i of o ?? []) {
132
- const t = he.find(
133
- (l) => l.many_collection === n && l.many_field === i.field && !l.junction_field
154
+ for (const r of l ?? []) {
155
+ const t = Ae.find(
156
+ (a) => a.many_collection === o && a.many_field === r.field && !a.junction_field
134
157
  );
135
- t != null && t.one_collection && (e[i.field] = t.one_collection);
158
+ t != null && t.one_collection && (e[r.field] = t.one_collection);
136
159
  }
137
160
  return e;
138
- }, [o, he, n]), E = n === "nivaro_users", Ue = Qe(E), ge = Xe().isAdmin, ne = K(() => {
161
+ }, [l, Ae, o]), z = o === "nivaro_users", st = vt(z), Ke = ht().isAdmin, he = T(() => {
139
162
  const e = [];
140
- E && e.push(tt(ge)), g && e.push(g);
141
- for (const [i, t] of Object.entries(re))
142
- t != null && t !== "" && e.push({ [i]: { _eq: t } });
163
+ z && e.push(St(Ke)), w && e.push(w);
164
+ for (const [r, t] of Object.entries(be))
165
+ t != null && t !== "" && e.push({ [r]: { _eq: t } });
143
166
  if (e.length !== 0)
144
167
  return e.length === 1 ? e[0] : { _and: e };
145
- }, [g, re, ge]), Y = (te == null ? void 0 : te.display_template) ?? (E ? "{{first_name}} {{last_name}} ({{email}})" : null), b = K(() => {
146
- if (!Y) return;
147
- const e = [...Y.matchAll(/\{\{([\w.]+)\}\}/g)].map((i) => i[1]);
168
+ }, [w, be, Ke]), re = (ge == null ? void 0 : ge.display_template) ?? (z ? "{{first_name}} {{last_name}} ({{email}})" : null), v = T(() => {
169
+ if (!re) return;
170
+ const e = [...re.matchAll(/\{\{([\w.]+)\}\}/g)].map((r) => r[1]);
148
171
  if (e.length)
149
172
  return ["id", ...e].join(",");
150
- }, [Y]), N = ne ? JSON.stringify(ne) : void 0, U = m && !/^-?label$/.test(m) ? m : void 0, {
151
- data: h,
152
- isFetching: O,
153
- isPlaceholderData: be
154
- } = S({
173
+ }, [re]), q = he ? JSON.stringify(he) : void 0, Y = p && !/^-?label$/.test(p) ? p : void 0, {
174
+ data: g,
175
+ isFetching: V,
176
+ isPlaceholderData: je
177
+ } = C({
155
178
  queryKey: [
156
179
  "relation-opts",
157
- n,
158
- L,
159
- N,
160
- b,
161
- U ?? ""
180
+ o,
181
+ M,
182
+ q,
183
+ v,
184
+ Y ?? ""
162
185
  ],
163
- queryFn: () => T.request(
164
- R(`/items/${n}`, {
186
+ queryFn: () => H.request(
187
+ P(`/items/${o}`, {
165
188
  limit: 200,
166
189
  picker: "1",
167
- ...L ? { search: L } : {},
168
- ...N ? { filter: N } : {},
169
- ...b ? { fields: b } : {},
170
- ...U ? { sort: U } : {}
190
+ ...M ? { search: M } : {},
191
+ ...q ? { filter: q } : {},
192
+ ...v ? { fields: v } : {},
193
+ ...Y ? { sort: Y } : {}
171
194
  })
172
195
  ).then((e) => e.data ?? []),
173
196
  // Wait for the display template: it decides `fields`, and starting before
174
197
  // it lands sent the whole first page twice.
175
- enabled: c && !Ie,
176
- staleTime: N ? 0 : 3e4,
198
+ enabled: c && !nt,
199
+ staleTime: q ? 0 : 3e4,
177
200
  // A new SEARCH keeps the previous answer on screen (narrowed locally below)
178
201
  // instead of blanking the list behind a spinner. A changed filter, sort or
179
202
  // template never does — those rows may no longer be allowed.
180
- placeholderData: (e, i) => {
181
- const t = i == null ? void 0 : i.queryKey;
203
+ placeholderData: (e, r) => {
204
+ const t = r == null ? void 0 : r.queryKey;
182
205
  if (!(!e || !t))
183
- return t[1] === n && t[3] === N && t[4] === b && t[5] === (U ?? "") ? e : void 0;
206
+ return t[1] === o && t[3] === q && t[4] === v && t[5] === (Y ?? "") ? e : void 0;
184
207
  }
185
208
  });
186
- j(() => Ee(O), [O]), st({
187
- placement: q,
209
+ L(() => et(V), [V]), $t({
210
+ placement: I,
188
211
  open: c,
189
- search: L,
190
- settled: !O && !be && h !== void 0,
191
- count: (h == null ? void 0 : h.length) ?? 0
212
+ search: M,
213
+ settled: !V && !je && g !== void 0,
214
+ count: (g == null ? void 0 : g.length) ?? 0
192
215
  });
193
- const { data: W, isLoading: Ae } = S({
194
- queryKey: ["relation-single", n, String(r), b],
195
- queryFn: () => de(n, r, b),
196
- enabled: !!r,
216
+ const { data: oe, isLoading: it } = C({
217
+ queryKey: ["relation-single", o, String(n), v],
218
+ queryFn: () => $e(o, n, v),
219
+ enabled: !!n,
197
220
  staleTime: 6e4
198
- }), x = (f == null ? void 0 : f.id) != null && f.id !== "" ? String(f.id) : null, { data: A } = S({
199
- queryKey: ["relation-single", n, x ?? "", b],
200
- queryFn: () => de(n, x, b).catch(
221
+ }), k = (d == null ? void 0 : d.id) != null && d.id !== "" ? String(d.id) : null, { data: K } = C({
222
+ queryKey: ["relation-single", o, k ?? "", v],
223
+ queryFn: () => $e(o, k, v).catch(
201
224
  () => null
202
225
  ),
203
- enabled: !!x && c,
226
+ enabled: !!k && c,
204
227
  staleTime: 6e4
205
- }), Me = JSON.stringify(g ? { _and: [{ id: { _eq: r } }, g] } : { id: { _eq: r } }), { data: X } = S({
206
- queryKey: ["relation-avail", n, String(r), N],
207
- queryFn: () => T.request(
208
- R(`/items/${n}`, {
209
- filter: Me,
228
+ }), at = JSON.stringify(w ? { _and: [{ id: { _eq: n } }, w] } : { id: { _eq: n } }), { data: se } = C({
229
+ queryKey: ["relation-avail", o, String(n), q],
230
+ queryFn: () => H.request(
231
+ P(`/items/${o}`, {
232
+ filter: at,
210
233
  picker: "1",
211
234
  limit: 1,
212
235
  fields: "id"
@@ -215,145 +238,191 @@ function dt({
215
238
  // The pinned option is offered OUTSIDE the option filter (a type's generic
216
239
  // item is excluded from the general list on purpose), so a value that IS
217
240
  // the pin is available by construction — never probe it, never flag it.
218
- enabled: !!r && !!W && String(r) !== x,
241
+ enabled: !!n && !!oe && String(n) !== k,
219
242
  staleTime: 3e4
220
- }), M = !!r && String(r) !== x && X !== void 0 && X.length === 0, G = I(null), se = I(!1), xe = `${n}|${N ?? ""}`, De = () => {
221
- se.current = !0, G.current = xe, d(null);
222
- }, V = r == null || r === "";
223
- j(() => {
224
- V || (se.current = !1);
225
- }, [V]), j(() => {
226
- if (!p || y || !V || se.current) return;
227
- const e = xe;
228
- G.current !== e && (G.current = e, T.request(
229
- R(`/items/${n}`, {
243
+ }), G = !!n && String(n) !== k && se !== void 0 && se.length === 0, ie = j(null), xe = j(!1), Te = `${o}|${q ?? ""}`, lt = () => {
244
+ xe.current = !0, ie.current = Te, f(null);
245
+ }, ae = n == null || n === "";
246
+ L(() => {
247
+ ae || (xe.current = !1);
248
+ }, [ae]), L(() => {
249
+ if (!x || y || !ae || xe.current) return;
250
+ const e = Te;
251
+ ie.current !== e && (ie.current = e, H.request(
252
+ P(`/items/${o}`, {
230
253
  limit: 2,
231
254
  picker: "1",
232
255
  fields: "id",
233
- ...N ? { filter: N } : {}
256
+ ...q ? { filter: q } : {}
234
257
  })
235
- ).then((i) => {
236
- var l;
237
- const t = i.data ?? [];
238
- t.length === 1 && ((l = t[0]) == null ? void 0 : l.id) != null && d(t[0].id);
258
+ ).then((r) => {
259
+ var a;
260
+ const t = r.data ?? [];
261
+ t.length === 1 && ((a = t[0]) == null ? void 0 : a.id) != null && f(t[0].id);
239
262
  }).catch(() => {
240
- G.current = null;
263
+ ie.current = null;
241
264
  }));
242
- }, [p, y, V, n, N]);
243
- const w = Y, ye = r && W ? k(w, W) : null, ie = !be && v === L, Z = K(
244
- () => ot(
245
- h ?? [],
246
- (e) => k(w, e) || `#${e.id}`,
265
+ }, [x, y, ae, o, q]);
266
+ const m = re, ye = n && oe ? S(m, oe) : null, we = ye === null ? null : X(ye) ? ee : ye, ve = !je && u === M, ke = T(
267
+ () => Et(
268
+ g ?? [],
269
+ (e) => S(m, e) || `#${e.id}`,
247
270
  // The server also reads a joined code by its parts ("2026-NNO-POWER"
248
271
  // finds 2026-WEST-NNO-HE-POWERING, services/search-synonyms.ts), so
249
272
  // the list narrowed while that search is out does too.
250
- v.replace(/[-_/]+/g, " "),
251
- ie
273
+ u.replace(/[-_/]+/g, " "),
274
+ ve
252
275
  ),
253
- [h, w, v, ie]
254
- ), Q = K(
255
- () => rt(h ?? [], (e) => k(w, e) || `#${e.id}`),
256
- [h, w]
257
- ), { data: D } = S({
258
- queryKey: ["relation-opts-dups", n, Q.join(",")],
259
- queryFn: () => T.request(
260
- R(`/items/${n}`, {
261
- limit: Q.length,
276
+ [g, m, u, ve]
277
+ ), le = T(
278
+ () => Lt(g ?? [], (e) => S(m, e) || `#${e.id}`),
279
+ [g, m]
280
+ ), { data: Z } = C({
281
+ queryKey: ["relation-opts-dups", o, le.join(",")],
282
+ queryFn: () => H.request(
283
+ P(`/items/${o}`, {
284
+ limit: le.length,
262
285
  picker: "1",
263
- filter: JSON.stringify({ id: { _in: Q } }),
286
+ filter: JSON.stringify({ id: { _in: le } }),
264
287
  fields: "*"
265
288
  })
266
289
  ).then((e) => e.data ?? []),
267
- enabled: c && Q.length > 0 && !E,
290
+ enabled: c && le.length > 0 && !z,
268
291
  staleTime: 6e4
269
- }), we = K(() => {
270
- if (!(D != null && D.length)) return /* @__PURE__ */ new Map();
292
+ }), Me = T(() => {
293
+ if (!(Z != null && Z.length)) return /* @__PURE__ */ new Map();
271
294
  const e = new Map(
272
- (h ?? []).map((t) => [
295
+ (g ?? []).map((t) => [
273
296
  String(t.id),
274
- (k(w, t) || `#${t.id}`).trim().toLowerCase()
297
+ (S(m, t) || `#${t.id}`).trim().toLowerCase()
275
298
  ])
276
- ), i = /* @__PURE__ */ new Map();
277
- for (const t of D) {
278
- const l = e.get(String(t.id));
279
- l !== void 0 && i.set(l, [...i.get(l) ?? [], t]);
299
+ ), r = /* @__PURE__ */ new Map();
300
+ for (const t of Z) {
301
+ const a = e.get(String(t.id));
302
+ a !== void 0 && r.set(a, [...r.get(a) ?? [], t]);
280
303
  }
281
- return nt(
282
- [...i.values()],
283
- ((b == null ? void 0 : b.split(",")) ?? []).map((t) => t.split(".")[0])
304
+ return qt(
305
+ [...r.values()],
306
+ ((v == null ? void 0 : v.split(",")) ?? []).map((t) => t.split(".")[0])
284
307
  );
285
- }, [D, h, w, b]), Je = !!r && Ae && !W, ve = lt(M), oe = Ge();
286
- return j(() => {
287
- !oe || !C || X === void 0 || oe(C, M);
288
- }, [oe, C, M, X]), F ? /* @__PURE__ */ u(
308
+ }, [Z, g, m, v]), ct = !!n && it && !oe, Fe = At(G), Oe = T(
309
+ () => (g ?? []).some((e) => !X(S(m, e))),
310
+ [g, m]
311
+ ), Q = T(
312
+ () => (Y ? [...ke] : [...ke].sort(
313
+ (e, r) => wt(
314
+ S(m, e),
315
+ S(m, r),
316
+ u,
317
+ p === "-label"
318
+ )
319
+ )).filter((e) => !k || String(e.id) !== k).filter(
320
+ (e) => !Oe || String(e.id) === String(n) || !X(S(m, e))
321
+ ),
322
+ [ke, Y, m, u, p, k, n, Oe]
323
+ ), Pe = K && !X(S(m, K)) ? S(m, K) : ee, Ne = !!k && (!u.trim() || _t(
324
+ `${K ? Pe : ""} ${(d == null ? void 0 : d.tag) ?? "Default"}`,
325
+ u.replace(/[-_/]+/g, " ")
326
+ )), W = Ne ? 1 : 0, $ = W + Q.length, b = Re >= $ ? $ - 1 : Re;
327
+ L(() => {
328
+ F(c && u.trim() ? W : -1);
329
+ }, [c, u, W]);
330
+ const Se = (e) => `${fe}-opt-${e}`, Ue = () => {
331
+ const e = (K == null ? void 0 : K.id) ?? (d == null ? void 0 : d.id);
332
+ Xe(n, e) || f(e), me();
333
+ }, He = (e) => {
334
+ Xe(n, e.id) || f(e.id), me();
335
+ }, Je = (e) => {
336
+ e < 0 || e >= $ || (e < W ? Ue() : He(Q[e - W]));
337
+ };
338
+ L(() => {
339
+ var r, t;
340
+ if (!c || b < 0) return;
341
+ const e = (r = ue.current) == null ? void 0 : r.querySelector(`[data-nav-index="${b}"]`);
342
+ (t = e == null ? void 0 : e.scrollIntoView) == null || t.call(e, { block: "nearest" });
343
+ }, [c, b]);
344
+ const dt = (e) => {
345
+ var r;
346
+ e.key === "ArrowDown" ? (e.preventDefault(), $ > 0 && F(b < 0 ? 0 : Math.min(b + 1, $ - 1))) : e.key === "ArrowUp" ? (e.preventDefault(), $ > 0 && F(b <= 0 ? 0 : b - 1)) : e.key === "Home" && $ > 0 && !u ? (e.preventDefault(), F(0)) : e.key === "End" && $ > 0 && !u ? (e.preventDefault(), F($ - 1)) : e.key === "Enter" ? (e.preventDefault(), b >= 0 ? Je(b) : $ === 1 && Je(0)) : e.key === "Tab" && (A(!1), (r = ne.current) == null || r.focus());
347
+ }, ut = (e) => {
348
+ y || (!c && (e.key === "ArrowDown" || e.key === "ArrowUp") ? (e.preventDefault(), A(!0)) : !c && e.key.length === 1 && e.key !== " " && !e.ctrlKey && !e.metaKey && !e.altKey && (e.preventDefault(), A(!0), de(e.key)));
349
+ }, _e = xt();
350
+ return L(() => {
351
+ !_e || !D || se === void 0 || _e(D, G);
352
+ }, [_e, D, G, se]), U ? /* @__PURE__ */ h(
289
353
  "button",
290
354
  {
291
355
  type: "button",
292
356
  disabled: !0,
293
357
  className: "flex h-9 w-full items-center justify-between gap-2 rounded-md border border-input bg-background px-3 text-sm text-left opacity-50 cursor-not-allowed",
294
358
  children: [
295
- /* @__PURE__ */ u("span", { className: "truncate text-muted-foreground", children: [
359
+ /* @__PURE__ */ h("span", { className: "truncate text-muted-foreground", children: [
296
360
  "Select ",
297
- F,
361
+ U,
298
362
  " first"
299
363
  ] }),
300
- /* @__PURE__ */ s($e, { className: "h-4 w-4 shrink-0 opacity-50" })
364
+ /* @__PURE__ */ s(Ve, { className: "h-4 w-4 shrink-0 opacity-50" })
301
365
  ]
302
366
  }
303
367
  ) : (
304
368
  // Stale tooltip binds on the WRAPPER: a disabled trigger button swallows
305
369
  // mouse events, so a locked-but-stale field would never show the hint.
306
- /* @__PURE__ */ u("div", { ref: H, className: "relative", ...ve.bind, children: [
307
- /* @__PURE__ */ u(
370
+ /* @__PURE__ */ h("div", { ref: J, className: "relative", ...Fe.bind, children: [
371
+ /* @__PURE__ */ h(
308
372
  "button",
309
373
  {
374
+ ref: ne,
310
375
  type: "button",
311
376
  disabled: y,
312
- onClick: () => P((e) => !e),
313
- className: J(
314
- "flex h-9 w-full items-center justify-between gap-2 rounded-md border bg-background px-3 text-sm text-left hover:bg-muted disabled:pointer-events-none disabled:opacity-50",
315
- M ? "border-amber-300 dark:border-amber-600" : "border-input"
377
+ "aria-haspopup": "listbox",
378
+ "aria-expanded": c,
379
+ onClick: () => A((e) => !e),
380
+ onKeyDown: ut,
381
+ className: O(
382
+ "flex h-9 w-full items-center justify-between gap-2 rounded-md border bg-background px-3 text-sm text-left hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/60 disabled:pointer-events-none disabled:opacity-50",
383
+ G ? "border-amber-300 dark:border-amber-600" : "border-input"
316
384
  ),
317
385
  children: [
318
- Je ? /* @__PURE__ */ s(B, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground" }) : /* @__PURE__ */ u(
386
+ ct ? /* @__PURE__ */ s(ce, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground" }) : /* @__PURE__ */ h(
319
387
  "span",
320
388
  {
321
- className: J(
389
+ className: O(
322
390
  "flex items-center gap-1.5 truncate min-w-0",
323
- !ye && "text-muted-foreground"
391
+ (!we || we === ee) && "text-muted-foreground"
324
392
  ),
325
393
  children: [
326
- M && /* @__PURE__ */ s(ze, { className: "h-3.5 w-3.5 shrink-0 text-amber-500" }),
327
- /* @__PURE__ */ s("span", { className: "truncate", children: ye ?? _ ?? "Select…" })
394
+ G && /* @__PURE__ */ s(ft, { className: "h-3.5 w-3.5 shrink-0 text-amber-500" }),
395
+ /* @__PURE__ */ s("span", { className: "truncate", children: we ?? R ?? "Select…" })
328
396
  ]
329
397
  }
330
398
  ),
331
- /* @__PURE__ */ s($e, { className: "h-4 w-4 shrink-0 opacity-50" })
399
+ /* @__PURE__ */ s(Ve, { className: "h-4 w-4 shrink-0 opacity-50" })
332
400
  ]
333
401
  }
334
402
  ),
335
- ve.tip,
336
- c && pe && fe && je(
337
- /* @__PURE__ */ u(
403
+ Fe.tip,
404
+ c && De && Ie && Ge(
405
+ /* @__PURE__ */ h(
338
406
  "div",
339
407
  {
408
+ ref: ue,
340
409
  "data-nvr-combobox-panel": "",
341
- style: pe,
342
- className: J(
410
+ style: De,
411
+ className: O(
343
412
  "nvr-pop-in rounded-md border border-border bg-popover shadow-md",
344
- o != null && o.length ? "w-[560px] max-w-[92vw]" : "min-w-[240px] w-max max-w-[360px]"
413
+ l != null && l.length ? "w-[560px] max-w-[92vw]" : "min-w-[240px] w-max max-w-[360px]"
345
414
  ),
346
415
  children: [
347
- !!(o != null && o.length) && /* @__PURE__ */ s("div", { className: "grid grid-cols-2 gap-2 border-b border-border bg-slate-50/60 p-2 dark:bg-muted/40", children: o.map((e) => {
348
- const i = Pe[e.field];
349
- return i ? /* @__PURE__ */ u("div", { children: [
416
+ !!(l != null && l.length) && /* @__PURE__ */ s("div", { className: "grid grid-cols-2 gap-2 border-b border-border bg-slate-50/60 p-2 dark:bg-muted/40", children: l.map((e) => {
417
+ const r = ot[e.field];
418
+ return r ? /* @__PURE__ */ h("div", { children: [
350
419
  /* @__PURE__ */ s("p", { className: "mb-0.5 text-[10px] font-medium uppercase tracking-wide text-slate-400", children: e.label ?? e.field }),
351
420
  /* @__PURE__ */ s(
352
- dt,
421
+ Kt,
353
422
  {
354
- collection: i,
355
- value: re[e.field] ?? null,
356
- onChange: (t) => Ke((l) => ({ ...l, [e.field]: t })),
423
+ collection: r,
424
+ value: be[e.field] ?? null,
425
+ onChange: (t) => rt((a) => ({ ...a, [e.field]: t })),
357
426
  placeholder: "Any",
358
427
  optionSort: e.sort,
359
428
  extraFilter: e.filter
@@ -361,142 +430,155 @@ function dt({
361
430
  )
362
431
  ] }, e.field) : null;
363
432
  }) }),
364
- /* @__PURE__ */ u("div", { className: "flex items-center border-b px-3", children: [
365
- /* @__PURE__ */ s(He, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
433
+ /* @__PURE__ */ h("div", { className: "flex items-center border-b px-3", children: [
434
+ /* @__PURE__ */ s(mt, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
366
435
  /* @__PURE__ */ s(
367
436
  "input",
368
437
  {
369
- ref: me,
370
- value: v,
371
- onChange: (e) => ce(e.target.value),
438
+ ref: Ee,
439
+ value: u,
440
+ onChange: (e) => de(e.target.value),
441
+ onKeyDown: dt,
442
+ role: "combobox",
443
+ "aria-expanded": !0,
444
+ "aria-autocomplete": "list",
445
+ "aria-controls": `${fe}-list`,
446
+ "aria-activedescendant": b >= 0 ? Se(b) : void 0,
372
447
  placeholder: "Search…",
373
448
  className: "flex h-9 w-full bg-transparent py-3 text-[13px] outline-none placeholder:text-muted-foreground"
374
449
  }
375
450
  ),
376
- O && h !== void 0 && /* @__PURE__ */ s(
377
- B,
451
+ V && g !== void 0 && /* @__PURE__ */ s(
452
+ ce,
378
453
  {
379
454
  "data-picker-searching": !0,
380
455
  className: "ml-2 h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground"
381
456
  }
382
457
  )
383
458
  ] }),
384
- /* @__PURE__ */ u("div", { className: "max-h-52 overflow-y-auto py-1", children: [
385
- !!r && !y && /* @__PURE__ */ u(
459
+ /* @__PURE__ */ h("div", { id: `${fe}-list`, role: "listbox", className: "max-h-52 overflow-y-auto py-1", children: [
460
+ !!n && !y && /* @__PURE__ */ h(
386
461
  "button",
387
462
  {
388
463
  type: "button",
464
+ tabIndex: -1,
389
465
  onClick: () => {
390
- De(), P(!1);
466
+ lt(), me();
391
467
  },
392
468
  className: "flex w-full items-center gap-2 px-3 py-1.5 text-[13px] text-slate-500 hover:bg-muted border-b border-slate-100 dark:text-slate-400 dark:border-border",
393
469
  children: [
394
- /* @__PURE__ */ s(Ye, { className: "h-3.5 w-3.5 text-slate-400" }),
470
+ /* @__PURE__ */ s(pt, { className: "h-3.5 w-3.5 text-slate-400" }),
395
471
  "Clear selection"
396
472
  ]
397
473
  }
398
474
  ),
399
- x && /* @__PURE__ */ u(
475
+ Ne && /* @__PURE__ */ h(
400
476
  "button",
401
477
  {
402
478
  type: "button",
479
+ tabIndex: -1,
480
+ id: Se(0),
481
+ role: "option",
482
+ "aria-selected": String(n) === k,
483
+ "data-nav-index": 0,
403
484
  "data-nvr-pinned-option": !0,
404
- onClick: () => {
405
- const e = (A == null ? void 0 : A.id) ?? (f == null ? void 0 : f.id);
406
- Le(r, e) || d(e), P(!1);
407
- },
408
- className: "flex w-full items-center gap-2 border-b border-slate-100 bg-nvr-cyan/5 px-3 py-1.5 text-left text-[13px] hover:bg-nvr-cyan/10 dark:border-border",
485
+ onClick: Ue,
486
+ onMouseMove: () => b !== 0 && F(0),
487
+ className: O(
488
+ "flex w-full items-center gap-2 border-b border-slate-100 px-3 py-1.5 text-left text-[13px] hover:bg-nvr-cyan/10 dark:border-border",
489
+ b === 0 ? "bg-nvr-cyan/10" : "bg-nvr-cyan/5"
490
+ ),
409
491
  children: [
410
492
  /* @__PURE__ */ s(
411
493
  "div",
412
494
  {
413
- className: J(
495
+ className: O(
414
496
  "flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
415
- String(r) === x ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
497
+ String(n) === k ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
416
498
  ),
417
- children: String(r) === x && /* @__PURE__ */ s(Ce, { className: "h-2.5 w-2.5 text-white" })
499
+ children: String(n) === k && /* @__PURE__ */ s(We, { className: "h-2.5 w-2.5 text-white" })
418
500
  }
419
501
  ),
420
- /* @__PURE__ */ s("span", { className: "min-w-0 flex-1 truncate", children: A ? k(w, A) || `#${x}` : `#${x}` }),
421
- /* @__PURE__ */ s("span", { className: "shrink-0 rounded bg-nvr-cyan/15 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-slate-700 dark:text-foreground", children: (f == null ? void 0 : f.tag) ?? "Default" })
502
+ /* @__PURE__ */ s("span", { className: "min-w-0 flex-1 truncate", children: K === void 0 ? "Loading…" : Pe }),
503
+ /* @__PURE__ */ s("span", { className: "shrink-0 rounded bg-nvr-cyan/15 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-slate-700 dark:text-foreground", children: (d == null ? void 0 : d.tag) ?? "Default" })
422
504
  ]
423
505
  }
424
506
  ),
425
- h === void 0 && O ? /* @__PURE__ */ s("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ s(B, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : Z.length === 0 && !ie ? /* @__PURE__ */ s("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children: "Searching…" }) : Z.length === 0 ? a && a.labels.length > 0 && !v.trim() ? /* @__PURE__ */ u("div", { className: "px-3 py-2 text-[12px] leading-5 text-muted-foreground", children: [
426
- /* @__PURE__ */ u("p", { children: [
507
+ g === void 0 && V ? /* @__PURE__ */ s("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ s(ce, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : Q.length === 0 && !ve ? /* @__PURE__ */ s("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children: "Searching…" }) : Q.length === 0 ? Ne && u.trim() ? null : i && i.labels.length > 0 && !u.trim() ? /* @__PURE__ */ h("div", { className: "px-3 py-2 text-[12px] leading-5 text-muted-foreground", children: [
508
+ /* @__PURE__ */ h("p", { children: [
427
509
  "No options for",
428
510
  " ",
429
- /* @__PURE__ */ s("span", { className: "font-medium text-foreground", children: a.labels.join(" · ") }),
430
- a.onClear ? " — clear one to widen the list:" : "."
511
+ /* @__PURE__ */ s("span", { className: "font-medium text-foreground", children: i.labels.join(" · ") }),
512
+ i.onClear ? " — clear one to widen the list:" : "."
431
513
  ] }),
432
- a.onClear && /* @__PURE__ */ s("div", { className: "mt-1.5 flex flex-wrap gap-1.5", children: a.keys.map(
433
- (e, i) => a.clearable && !a.clearable.includes(e) ? null : /* @__PURE__ */ u(
514
+ i.onClear && /* @__PURE__ */ s("div", { className: "mt-1.5 flex flex-wrap gap-1.5", children: i.keys.map(
515
+ (e, r) => i.clearable && !i.clearable.includes(e) ? null : /* @__PURE__ */ h(
434
516
  "button",
435
517
  {
436
518
  type: "button",
437
519
  onClick: (t) => {
438
- var l;
439
- t.stopPropagation(), (l = a.onClear) == null || l.call(a, e);
520
+ var a;
521
+ t.stopPropagation(), (a = i.onClear) == null || a.call(i, e);
440
522
  },
441
523
  className: "rounded-md border border-border bg-background px-2 py-0.5 text-[11.5px] font-medium text-foreground transition-colors duration-150 hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan",
442
524
  children: [
443
525
  "Clear ",
444
- a.labels[i] ?? e
526
+ i.labels[r] ?? e
445
527
  ]
446
528
  },
447
529
  e
448
530
  )
449
531
  ) })
450
- ] }) : /* @__PURE__ */ s("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children: v.trim() ? `No results for “${v.trim()}”` : "No results" }) : (U ? [...Z] : [...Z].sort(
451
- (e, i) => Ze(
452
- k(w, e),
453
- k(w, i),
454
- v,
455
- m === "-label"
456
- )
457
- )).filter((e) => !x || String(e.id) !== x).map((e) => {
458
- const i = k(w, e) || `#${e.id}`, t = String(e.id) === String(r);
459
- return /* @__PURE__ */ u(
532
+ ] }) : /* @__PURE__ */ s("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children: u.trim() ? `No results for “${u.trim()}”` : "No results" }) : Q.map((e, r) => {
533
+ const t = S(m, e), a = X(t) ? ee : t, N = String(e.id) === String(n), _ = r + W;
534
+ return /* @__PURE__ */ h(
460
535
  "button",
461
536
  {
462
537
  type: "button",
463
- onClick: () => {
464
- Le(r, e.id) || d(e.id), P(!1);
465
- },
466
- className: "flex w-full items-center gap-2 px-3 py-1.5 text-[13px] text-left hover:bg-muted",
538
+ tabIndex: -1,
539
+ id: Se(_),
540
+ role: "option",
541
+ "aria-selected": N,
542
+ "data-nav-index": _,
543
+ onClick: () => He(e),
544
+ onMouseMove: () => b !== _ && F(_),
545
+ className: O(
546
+ "flex w-full items-center gap-2 px-3 py-1.5 text-[13px] text-left hover:bg-muted",
547
+ b === _ && "bg-muted"
548
+ ),
467
549
  children: [
468
550
  /* @__PURE__ */ s(
469
551
  "div",
470
552
  {
471
- className: J(
553
+ className: O(
472
554
  "flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
473
- t ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
555
+ N ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
474
556
  ),
475
- children: t && /* @__PURE__ */ s(Ce, { className: "h-2.5 w-2.5 text-white" })
557
+ children: N && /* @__PURE__ */ s(We, { className: "h-2.5 w-2.5 text-white" })
476
558
  }
477
559
  ),
478
- E && /* @__PURE__ */ s(
479
- et,
560
+ z && /* @__PURE__ */ s(
561
+ Nt,
480
562
  {
481
563
  userId: e.id,
482
564
  className: "h-4 w-4",
483
- fallback: /* @__PURE__ */ s("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/20 text-[8px] font-bold text-nvr-navy dark:text-nvr-cyan", children: at(i) })
565
+ fallback: /* @__PURE__ */ s("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/20 text-[8px] font-bold text-nvr-navy dark:text-nvr-cyan", children: It(a) })
484
566
  }
485
567
  ),
486
- E && Ue.has(String(e.id).toUpperCase()) && /* @__PURE__ */ s(
568
+ z && st.has(String(e.id).toUpperCase()) && /* @__PURE__ */ s(
487
569
  "span",
488
570
  {
489
571
  className: "h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500",
490
572
  "data-tip": "Online now"
491
573
  }
492
574
  ),
493
- /* @__PURE__ */ s(Be, { text: i, query: v }),
494
- we.has(String(e.id)) && /* @__PURE__ */ s(
575
+ /* @__PURE__ */ s(kt, { text: a, query: u }),
576
+ Me.has(String(e.id)) && /* @__PURE__ */ s(
495
577
  "span",
496
578
  {
497
579
  className: "ml-auto max-w-[45%] shrink-0 truncate pl-2 text-[11.5px] text-muted-foreground",
498
580
  "data-option-detail": !0,
499
- children: we.get(String(e.id))
581
+ children: Me.get(String(e.id))
500
582
  }
501
583
  )
502
584
  ]
@@ -505,107 +587,109 @@ function dt({
505
587
  );
506
588
  })
507
589
  ] }),
508
- !O && /* @__PURE__ */ s(
509
- ct,
590
+ !V && /* @__PURE__ */ s(
591
+ jt,
510
592
  {
511
- collection: n,
512
- search: L,
513
- filter: ne,
514
- narrowedLabels: (a == null ? void 0 : a.labels) ?? [],
515
- auto: (h ?? []).length === 0 && !!L
593
+ collection: o,
594
+ search: M,
595
+ filter: he,
596
+ narrowedLabels: (i == null ? void 0 : i.labels) ?? [],
597
+ auto: (g ?? []).length === 0 && !!M
516
598
  }
517
599
  )
518
600
  ]
519
601
  }
520
602
  ),
521
- fe
603
+ Ie
522
604
  )
523
605
  ] })
524
606
  );
525
607
  }
526
- function ct({
527
- collection: n,
528
- search: r,
529
- filter: d,
608
+ function jt({
609
+ collection: o,
610
+ search: n,
611
+ filter: f,
530
612
  narrowedLabels: y,
531
- auto: _
613
+ auto: R
532
614
  }) {
533
- const g = ae(), [p, m] = $(!1), F = d ? JSON.stringify(d) : "", { data: o, isFetching: C } = S({
534
- queryKey: ["picker-narrowing", n, r, F],
535
- queryFn: () => g.request(
536
- Ve("/picker-narrowing", { collection: n, search: r, filter: d ?? null })
537
- ).then((q) => q.data),
538
- enabled: p || _,
615
+ const w = Le(), [x, p] = E(!1), U = f ? JSON.stringify(f) : "", { data: l, isFetching: D } = C({
616
+ queryKey: ["picker-narrowing", o, n, U],
617
+ queryFn: () => w.request(
618
+ yt("/picker-narrowing", { collection: o, search: n, filter: f ?? null })
619
+ ).then((I) => I.data),
620
+ enabled: x || R,
539
621
  staleTime: 3e4,
540
622
  retry: !1
541
623
  });
542
- if (!p && !_)
624
+ if (!x && !R)
543
625
  return /* @__PURE__ */ s(
544
626
  "button",
545
627
  {
546
628
  type: "button",
547
- onClick: (q) => {
548
- q.stopPropagation(), m(!0);
629
+ onClick: (I) => {
630
+ I.stopPropagation(), p(!0);
549
631
  },
550
632
  className: "w-full border-t border-border px-3 py-1.5 text-left text-[11px] text-muted-foreground hover:text-foreground",
551
633
  "data-picker-narrowing-ask": !0,
552
634
  children: "Missing something?"
553
635
  }
554
636
  );
555
- if (C && !o)
637
+ if (D && !l)
556
638
  return /* @__PURE__ */ s("p", { className: "border-t border-border px-3 py-1.5 text-[11px] text-muted-foreground", children: "Checking what narrows this list…" });
557
- if (!o) return null;
558
- const a = [], f = r ? `match “${r}”` : "exist";
559
- return o.by_field_filter > 0 && a.push(
560
- `${o.by_field_filter.toLocaleString()} more ${f} but this field only offers ${y.length ? `records that fit ${y.join(" · ")}` : "records its filter allows"}.`
561
- ), o.by_exclusions > 0 && a.push(
562
- `${o.by_exclusions.toLocaleString()} ${o.by_exclusions === 1 ? "is" : "are"} hidden from pickers by an admin.`
563
- ), o.scopes.length > 0 && a.push(`Your ${o.scopes.join(", ")} access narrows what you can pick here.`), o.row_filter && a.push("Your role only sees some of these records."), a.length === 0 && a.push(
564
- r ? `Nothing else you can see matches “${r}”.` : "Nothing narrows this list — every record you can see is offered."
639
+ if (!l) return null;
640
+ const i = [], d = n ? `match “${n}”` : "exist";
641
+ return l.by_field_filter > 0 && i.push(
642
+ `${l.by_field_filter.toLocaleString()} more ${d} but this field only offers ${y.length ? `records that fit ${y.join(" · ")}` : "records its filter allows"}.`
643
+ ), l.by_exclusions > 0 && i.push(
644
+ `${l.by_exclusions.toLocaleString()} ${l.by_exclusions === 1 ? "is" : "are"} hidden from pickers by an admin.`
645
+ ), l.scopes.length > 0 && i.push(`Your ${l.scopes.join(", ")} access narrows what you can pick here.`), l.row_filter && i.push("Your role only sees some of these records."), i.length === 0 && i.push(
646
+ n ? `Nothing else you can see matches “${n}”.` : "Nothing narrows this list — every record you can see is offered."
565
647
  ), /* @__PURE__ */ s(
566
648
  "div",
567
649
  {
568
650
  className: "space-y-0.5 border-t border-border px-3 py-1.5 text-[11px] leading-4 text-muted-foreground",
569
651
  "data-picker-narrowing": !0,
570
- "data-picker-narrowing-field": o.by_field_filter,
571
- "data-picker-narrowing-excluded": o.by_exclusions,
572
- children: a.map((q) => /* @__PURE__ */ s("p", { children: q }, q))
652
+ "data-picker-narrowing-field": l.by_field_filter,
653
+ "data-picker-narrowing-excluded": l.by_exclusions,
654
+ children: i.map((I) => /* @__PURE__ */ s("p", { children: I }, I))
573
655
  }
574
656
  );
575
657
  }
576
- function Ct({
577
- collection: n,
578
- id: r,
579
- displayTemplate: d
658
+ function tn({
659
+ collection: o,
660
+ id: n,
661
+ displayTemplate: f
580
662
  }) {
581
- const y = ae(), _ = Re(), g = n === "nivaro_files" || n === "directus_files", p = (() => {
582
- if (!d || !d.includes(".")) return null;
583
- const o = [...d.matchAll(/\{\{([^}]+)\}\}/g)].map((C) => C[1].trim());
584
- return o.length > 0 ? ["id", ...o].join(",") : null;
585
- })(), { data: m, isLoading: F } = S({
586
- queryKey: ["relation-single", n, String(r), p ?? ""],
587
- queryFn: () => g ? (
663
+ const y = Le(), R = Ze(), w = o === "nivaro_files" || o === "directus_files", x = (() => {
664
+ if (!f || !f.includes(".")) return null;
665
+ const i = [...f.matchAll(/\{\{([^}]+)\}\}/g)].map((d) => d[1].trim());
666
+ return i.length > 0 ? ["id", ...i].join(",") : null;
667
+ })(), { data: p, isLoading: U, error: l } = C({
668
+ queryKey: ["relation-single", o, String(n), x ?? ""],
669
+ queryFn: () => w ? (
588
670
  // The file's row, not its bytes: GET /files/:id downloads the whole
589
671
  // file (twice with the retry, 404 when storage lost it) only to read
590
672
  // its name, and a missing object left the raw id as the label.
591
673
  y.request(
592
- R(`/files/${encodeURIComponent(String(r))}/meta`)
593
- ).then((o) => o.data)
594
- ) : _(n, r, p),
595
- enabled: !!r && !!n,
596
- staleTime: 6e4
674
+ P(`/files/${encodeURIComponent(String(n))}/meta`)
675
+ ).then((i) => i.data)
676
+ ) : R(o, n, x),
677
+ enabled: !!n && !!o,
678
+ staleTime: 6e4,
679
+ retry: Rt
597
680
  });
598
- if (F) return /* @__PURE__ */ s(B, { className: "h-3 w-3 animate-spin text-slate-400" });
599
- if (!m) return /* @__PURE__ */ s("span", { children: String(r ?? "") });
600
- if (g) {
601
- const o = m.title || m.filename_download || m.filename_disk || String(r);
602
- return /* @__PURE__ */ s("span", { children: o });
681
+ if (U) return /* @__PURE__ */ s(ce, { className: "h-3 w-3 animate-spin text-slate-400" });
682
+ if (!p) return n == null || n === "" ? null : /* @__PURE__ */ s(Dt, { error: l });
683
+ if (w) {
684
+ const i = p.title || p.filename_download || p.filename_disk || String(n);
685
+ return /* @__PURE__ */ s("span", { children: i });
603
686
  }
604
- return /* @__PURE__ */ s("span", { children: k(d, m) });
687
+ const D = S(f, p);
688
+ return X(D) ? /* @__PURE__ */ s("span", { className: "italic text-muted-foreground", children: ee }) : /* @__PURE__ */ s("span", { children: D });
605
689
  }
606
690
  export {
607
- Ct as RelatedItemLabel,
608
- dt as RelationCombobox,
609
- Le as isSamePick,
610
- lt as useStaleTip
691
+ tn as RelatedItemLabel,
692
+ Kt as RelationCombobox,
693
+ Xe as isSamePick,
694
+ At as useStaleTip
611
695
  };