@nivaro/react 0.3.63 → 0.3.65

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