@nivaro/react 0.3.65 → 0.3.67

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