@nivaro/react 0.3.15 → 0.3.16

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 (34) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +127 -6
  4. package/dist/index.js +736 -734
  5. package/dist/shared/components/CollectionBrowserView.js +2344 -2309
  6. package/dist/shared/components/ItemEditForm.js +3773 -3604
  7. package/dist/shared/components/RecordGridEditor.js +319 -282
  8. package/dist/shared/components/RecordReadView.js +202 -200
  9. package/dist/shared/components/cbv/unknown-fields.js +18 -8
  10. package/dist/shared/components/import/DocumentAutofillButton.js +148 -142
  11. package/dist/shared/components/item-edit/CatalogPickerField.js +264 -276
  12. package/dist/shared/components/item-edit/FieldRenderer.js +136 -133
  13. package/dist/shared/components/item-edit/FieldRow.js +198 -184
  14. package/dist/shared/components/item-edit/HeaderTools.js +107 -99
  15. package/dist/shared/components/item-edit/InlineTableField.js +138 -136
  16. package/dist/shared/components/item-edit/RecordLiveSync.js +1 -0
  17. package/dist/shared/components/item-edit/RelationCombobox.js +30 -23
  18. package/dist/shared/components/item-edit/SummaryPanel.js +334 -294
  19. package/dist/shared/components/item-edit/column-length.js +12 -0
  20. package/dist/shared/components/panels/AccessDeniedPanel.js +47 -37
  21. package/dist/shared/components/panels/ItemLockBanner.js +307 -285
  22. package/dist/shared/components/panels/PipelinePanel.js +486 -465
  23. package/dist/shared/components/panels/RevisionsPanel.js +210 -204
  24. package/dist/shared/components/profile/DelegationCard.js +178 -121
  25. package/dist/shared/components/profile/PersonActivity.js +152 -139
  26. package/dist/shared/components/queue/QueueWorklist.js +668 -659
  27. package/dist/shared/components/queue/transition-note.js +90 -0
  28. package/dist/shared/components/support/SupportRequestDialog.js +100 -89
  29. package/dist/shared/components/support/TicketDetailSheet.js +104 -91
  30. package/dist/shared/lib/autofill-runs.js +33 -26
  31. package/dist/shared/lib/draft-store.js +40 -24
  32. package/dist/shared/lib/live-queries.js +10 -9
  33. package/dist/shared/lib/restore-skipped.js +10 -0
  34. package/package.json +1 -1
@@ -1,24 +1,24 @@
1
1
  import { jsxs as m, jsx as n, Fragment as qt } from "react/jsx-runtime";
2
- import { useQueryClient as Tr, useQuery as z, useQueries as $t } from "@tanstack/react-query";
3
- import { Search as it, Loader2 as ae, ChevronRight as jt, Star as Be, AlertTriangle as ze, AlertCircle as St, X as lt, ChevronDown as Or } from "lucide-react";
2
+ import { useQueryClient as $r, useQuery as z, useQueries as $t } from "@tanstack/react-query";
3
+ import { Search as it, Loader2 as ae, ChevronRight as jt, Star as Be, AlertTriangle as ze, AlertCircle as St, X as lt, ChevronDown as jr } from "lucide-react";
4
4
  import { useState as Y, useRef as Ve, useMemo as O, useEffect as je, Fragment as Je } from "react";
5
- import { createPortal as Rr } from "react-dom";
6
- import { useNivaroClient as Ft, useParentDraft as Pr, useReimportHandler as Er } from "../../context.js";
7
- import { canOpenCatalogItem as nr, openCatalogItem as sr } from "../../lib/catalog-item-open.js";
8
- import { get as R, del as Lr, patch as Yt, post as Zt } from "../../lib/commands.js";
9
- import { evaluateBoolean as Ar } from "../../lib/expression.js";
10
- import { useLiveRefetchInterval as Cr } from "../../lib/live-queries.js";
11
- import { submissionLineErrors as Kr, normalizeIdent as Jr } from "../../lib/submission-errors.js";
12
- import { titleCase as I, cn as B, matchesAllTokens as Qr } from "../../lib/utils.js";
13
- import { ImportFromFileButton as zr } from "../import/ImportFromFileButton.js";
14
- import { Popover as Gt, PopoverAnchor as Xt, PopoverContent as er } from "../ui/popover.js";
5
+ import { createPortal as Fr } from "react-dom";
6
+ import { useNivaroClient as Ft, useParentDraft as Tr, useReimportHandler as Or } from "../../context.js";
7
+ import { canOpenCatalogItem as er, openCatalogItem as tr } from "../../lib/catalog-item-open.js";
8
+ import { get as R, del as Rr, patch as Yt, post as Zt } from "../../lib/commands.js";
9
+ import { evaluateBoolean as Pr } from "../../lib/expression.js";
10
+ import { useLiveRefetchInterval as Er } from "../../lib/live-queries.js";
11
+ import { submissionLineErrors as Lr, normalizeIdent as Ar } from "../../lib/submission-errors.js";
12
+ import { titleCase as I, cn as B, matchesAllTokens as Cr } from "../../lib/utils.js";
13
+ import { ImportFromFileButton as Kr } from "../import/ImportFromFileButton.js";
14
+ import { Popover as Jr, PopoverAnchor as Qr, PopoverContent as zr } from "../ui/popover.js";
15
15
  import { applyDisplayTemplate as Fe } from "./helpers.js";
16
16
  import { evalClientFormula as Qe } from "./InlineTableField.js";
17
- import { isIntegerFieldType as Br, checkNumberEntry as tr, mergePendingQtyRow as Vr, lineRuleErrors as Dr } from "./line-qty.js";
18
- import { resolveM2MRelatedCollection as Ur } from "./M2MCombobox.js";
17
+ import { isIntegerFieldType as Br, checkNumberEntry as Gt, mergePendingQtyRow as Vr, lineRuleErrors as Ur } from "./line-qty.js";
18
+ import { resolveM2MRelatedCollection as Dr } from "./M2MCombobox.js";
19
19
  import { useO2MStaging as Hr } from "./O2MStagingContext.js";
20
20
  import { RelationCombobox as Mr } from "./RelationCombobox.js";
21
- const ar = (f, y) => {
21
+ const rr = (f, y) => {
22
22
  let _ = f;
23
23
  for (const q of y.split(".")) {
24
24
  if (_ == null || typeof _ != "object") return;
@@ -34,7 +34,7 @@ async function ot(f, y, _) {
34
34
  }
35
35
  return q;
36
36
  }
37
- function De(f, y) {
37
+ function Ue(f, y) {
38
38
  const _ = {};
39
39
  let q = !1;
40
40
  const l = (g) => {
@@ -55,23 +55,23 @@ function De(f, y) {
55
55
  } else h && typeof h == "object" ? _[g] = l(h) : _[g] = { _eq: h };
56
56
  return q ? null : _;
57
57
  }
58
- function rr(f, y) {
58
+ function Xt(f, y) {
59
59
  if (!f) return !0;
60
60
  for (const [_, q] of Object.entries(f)) {
61
61
  const l = y == null ? void 0 : y[_], g = l == null ? null : String(l), h = q && typeof q == "object" ? q : { _eq: q };
62
- for (const [$, b] of Object.entries(h))
62
+ for (const [$, p] of Object.entries(h))
63
63
  switch ($) {
64
64
  case "_eq":
65
- if (g !== String(b)) return !1;
65
+ if (g !== String(p)) return !1;
66
66
  break;
67
67
  case "_neq":
68
- if (g === String(b)) return !1;
68
+ if (g === String(p)) return !1;
69
69
  break;
70
70
  case "_in":
71
- if (!Array.isArray(b) || !b.map(String).includes(g ?? "")) return !1;
71
+ if (!Array.isArray(p) || !p.map(String).includes(g ?? "")) return !1;
72
72
  break;
73
73
  case "_nin":
74
- if (Array.isArray(b) && b.map(String).includes(g ?? "")) return !1;
74
+ if (Array.isArray(p) && p.map(String).includes(g ?? "")) return !1;
75
75
  break;
76
76
  case "_null":
77
77
  if (g !== null) return !1;
@@ -95,7 +95,7 @@ function yn({
95
95
  readOnly: g = !1
96
96
  }) {
97
97
  var Ht, Mt, Wt;
98
- const h = Ft(), $ = Tr(), b = Hr(), P = Pr(), Z = Er(), U = l.editable_fields ?? [], E = _ === "new", V = l.qty_field ?? "quantity", [oe, ne] = Y(/* @__PURE__ */ new Set()), ge = Ve(!1), [C, ye] = Y(""), [pe, G] = Y({}), [se, v] = Y(/* @__PURE__ */ new Set()), [T, F] = Y({}), [W, L] = Y({}), { data: K = [], isPending: de } = z({
98
+ const h = Ft(), $ = $r(), p = Hr(), P = Tr(), Z = Or(), D = l.editable_fields ?? [], E = _ === "new", V = l.qty_field ?? "quantity", [oe, ne] = Y(/* @__PURE__ */ new Set()), ge = Ve(!1), [C, ye] = Y(""), [be, G] = Y({}), [se, v] = Y(/* @__PURE__ */ new Set()), [T, F] = Y({}), [W, L] = Y({}), { data: K = [], isPending: de } = z({
99
99
  queryKey: ["collection-relations", f],
100
100
  queryFn: () => h.request(R(`/collections/${f}`)).then((e) => {
101
101
  var t;
@@ -110,14 +110,14 @@ function yn({
110
110
  )) == null ? void 0 : e.one_collection) ?? null;
111
111
  },
112
112
  [K, f, l.item_field]
113
- ), { data: be = [] } = z({
113
+ ), { data: pe = [] } = z({
114
114
  queryKey: ["field-config", f, null],
115
115
  queryFn: () => h.request(R(`/field-config/${f}`)).then((e) => e.data ?? []),
116
116
  staleTime: 6e4
117
- }), _e = ((Ht = be.find((e) => e.field === V)) == null ? void 0 : Ht.type) ?? null, Oe = (e, t, r) => {
117
+ }), _e = ((Ht = pe.find((e) => e.field === V)) == null ? void 0 : Ht.type) ?? null, Oe = (e, t, r) => {
118
118
  var s;
119
- return ((s = Dr(
120
- be.filter((c) => c.field === e).map((c) => ({
119
+ return ((s = Ur(
120
+ pe.filter((c) => c.field === e).map((c) => ({
121
121
  field: c.field,
122
122
  label: c.label || I(c.field),
123
123
  type: c.type,
@@ -138,7 +138,7 @@ function yn({
138
138
  return ((X == null ? void 0 : X.relations) ?? []).find(
139
139
  (t) => t.one_collection === x && t.one_field === e && !!t.junction_field
140
140
  ) ?? null;
141
- }, [X, x, l.section_by]), ce = (A == null ? void 0 : A.many_collection) ?? null, { data: Ue = [] } = z({
141
+ }, [X, x, l.section_by]), ce = (A == null ? void 0 : A.many_collection) ?? null, { data: De = [] } = z({
142
142
  queryKey: ["collection-relations", ce],
143
143
  queryFn: () => h.request(R(`/collections/${ce}`)).then((e) => {
144
144
  var t;
@@ -148,9 +148,9 @@ function yn({
148
148
  staleTime: 10 * 6e4
149
149
  }), Q = O(() => {
150
150
  if (!(A != null && A.many_field) || !ce) return null;
151
- const e = String(A.junction_field), t = Ue.find(
151
+ const e = String(A.junction_field), t = De.find(
152
152
  (s) => s.many_collection === ce && s.many_field === e
153
- ), r = Ur(t);
153
+ ), r = Dr(t);
154
154
  return r ? {
155
155
  junction: ce,
156
156
  fkToItem: A.many_field,
@@ -158,13 +158,13 @@ function yn({
158
158
  target: r,
159
159
  labelPath: l.section_by.split(".").slice(1).join(".") || "id"
160
160
  } : null;
161
- }, [A, ce, Ue, l.section_by]), te = P == null ? void 0 : P.draft, { resolvedFilter: Te, resolvedSectionFilter: he, resolvedLinkFilter: a, missingParents: k } = O(() => {
161
+ }, [A, ce, De, l.section_by]), te = P == null ? void 0 : P.draft, { resolvedFilter: Te, resolvedSectionFilter: he, resolvedLinkFilter: a, missingParents: k } = O(() => {
162
162
  const e = [], t = (o) => {
163
163
  if (typeof o == "string" && o.startsWith("$parent.")) {
164
- const i = o.slice(8), p = te == null ? void 0 : te[i];
165
- return p == null || p === "" ? (e.push(i), o) : p;
164
+ const i = o.slice(8), b = te == null ? void 0 : te[i];
165
+ return b == null || b === "" ? (e.push(i), o) : b;
166
166
  }
167
- return Array.isArray(o) ? o.map(t) : o && typeof o == "object" ? Object.fromEntries(Object.entries(o).map(([i, p]) => [i, t(p)])) : o;
167
+ return Array.isArray(o) ? o.map(t) : o && typeof o == "object" ? Object.fromEntries(Object.entries(o).map(([i, b]) => [i, t(b)])) : o;
168
168
  }, r = l.filter ? t(l.filter) : void 0, s = l.section_filter ? t(l.section_filter) : void 0, c = l.link_filter ? t(l.link_filter) : void 0;
169
169
  return {
170
170
  resolvedFilter: r,
@@ -172,7 +172,7 @@ function yn({
172
172
  resolvedLinkFilter: c,
173
173
  missingParents: [...new Set(e)]
174
174
  };
175
- }, [l.filter, l.section_filter, l.link_filter, te]), D = O(() => {
175
+ }, [l.filter, l.section_filter, l.link_filter, te]), U = O(() => {
176
176
  if (!A || !he && !a) return Te;
177
177
  const e = {
178
178
  ...he ?? {},
@@ -186,14 +186,14 @@ function yn({
186
186
  for (const t of Object.values(l.copy_fields ?? {})) e.add(t);
187
187
  for (const t of l.columns ?? []) e.add(t.field);
188
188
  return [...e].join(",");
189
- }, [ee, X, A, l.section_by, l.copy_fields, l.columns]), re = JSON.stringify(D ?? null), { data: M = [], isLoading: H } = z(
189
+ }, [ee, X, A, l.section_by, l.copy_fields, l.columns]), re = JSON.stringify(U ?? null), { data: M = [], isLoading: H } = z(
190
190
  {
191
191
  queryKey: ["catalog-picker", x, J, re],
192
192
  queryFn: () => h.request(
193
193
  R(`/items/${x}`, {
194
194
  limit: Wr,
195
195
  fields: J,
196
- ...D ? { filter: JSON.stringify(D) } : {}
196
+ ...U ? { filter: JSON.stringify(U) } : {}
197
197
  })
198
198
  ).then((e) => e.data ?? []),
199
199
  // Wait for the catalog meta: a to-many section path both narrows this
@@ -210,12 +210,12 @@ function yn({
210
210
  ...he ? { filter: JSON.stringify(he) } : {}
211
211
  })).map((r) => ({
212
212
  id: String(r.id),
213
- name: String(ar(r, e.labelPath) ?? "").trim()
213
+ name: String(rr(r, e.labelPath) ?? "").trim()
214
214
  }));
215
215
  },
216
216
  enabled: !!Q && k.length === 0,
217
217
  staleTime: 6e4
218
- }), Re = O(() => me.map((e) => e.id), [me]), { data: Tt = [], isLoading: ir } = z({
218
+ }), Re = O(() => me.map((e) => e.id), [me]), { data: Tt = [], isLoading: nr } = z({
219
219
  queryKey: [
220
220
  "catalog-section-links",
221
221
  Q == null ? void 0 : Q.junction,
@@ -247,7 +247,7 @@ function yn({
247
247
  c.includes(s) || c.push(s), t.set(r.item, c);
248
248
  }
249
249
  return t;
250
- }, [me, Tt]), He = !!A && (!Q || ke || Re.length > 0 && ir), Me = O(() => {
250
+ }, [me, Tt]), He = !!A && (!Q || ke || Re.length > 0 && nr), Me = O(() => {
251
251
  const e = /* @__PURE__ */ new Map();
252
252
  for (const t of M) e.set(String(t.id), t);
253
253
  return e;
@@ -261,13 +261,13 @@ function yn({
261
261
  ).then((e) => e.data ?? []),
262
262
  enabled: !E,
263
263
  staleTime: 15e3
264
- }), Pe = !E && !!b, Ne = b ? b.getPendingRows(f, y) : [], We = Pe ? b.getPendingEdits(f, y) : /* @__PURE__ */ new Map(), lr = JSON.stringify([...We.entries()]), Ie = O(
264
+ }), Pe = !E && !!p, Ne = p ? p.getPendingRows(f, y) : [], We = Pe ? p.getPendingEdits(f, y) : /* @__PURE__ */ new Map(), sr = JSON.stringify([...We.entries()]), Ie = O(
265
265
  () => We.size === 0 ? we : we.map((e) => {
266
266
  const t = We.get(String(e.id));
267
267
  return t ? { ...e, ...t } : e;
268
268
  }),
269
- [we, lr]
270
- ), Ye = !E && b ? b.getPendingDeletes(f, y) : /* @__PURE__ */ new Set(), Ee = O(() => {
269
+ [we, sr]
270
+ ), Ye = !E && p ? p.getPendingDeletes(f, y) : /* @__PURE__ */ new Set(), Ee = O(() => {
271
271
  const e = /* @__PURE__ */ new Map();
272
272
  for (const t of Ie) {
273
273
  const r = t[l.item_field];
@@ -330,7 +330,7 @@ function yn({
330
330
  }
331
331
  }
332
332
  }
333
- const [or, Lt] = Y(!1), At = Ve(null), ct = (e) => l.favorites ? /* @__PURE__ */ n(
333
+ const [ar, Lt] = Y(!1), At = Ve(null), ct = (e) => l.favorites ? /* @__PURE__ */ n(
334
334
  "button",
335
335
  {
336
336
  type: "button",
@@ -350,29 +350,29 @@ function yn({
350
350
  }
351
351
  )
352
352
  }
353
- ) : null, [mt, dr] = Y("");
353
+ ) : null, [mt, ir] = Y("");
354
354
  je(() => {
355
- const e = setTimeout(() => dr(C), 300);
355
+ const e = setTimeout(() => ir(C), 300);
356
356
  return () => clearTimeout(e);
357
357
  }, [C]);
358
- const cr = O(() => {
358
+ const lr = O(() => {
359
359
  var t;
360
360
  const e = (t = [...(ee ?? "").matchAll(/\{\{([\w.]+)\}\}/g)][0]) == null ? void 0 : t[1];
361
361
  return e && !e.includes(".") ? e : "id";
362
- }, [ee]), { data: mr = [], isFetching: ut } = z({
362
+ }, [ee]), { data: or = [], isFetching: ut } = z({
363
363
  queryKey: ["catalog-full-search", x, J, mt],
364
364
  queryFn: () => h.request(
365
365
  R(`/items/${x}`, {
366
366
  search: mt,
367
367
  fields: J,
368
368
  limit: 25,
369
- sort: cr
369
+ sort: lr
370
370
  })
371
371
  ).then((e) => e.data ?? []),
372
372
  enabled: !!x && mt.trim().length > 0,
373
373
  staleTime: 3e4,
374
374
  placeholderData: (e) => e
375
- }), Se = mr, et = O(() => {
375
+ }), Se = or, et = O(() => {
376
376
  const e = /* @__PURE__ */ new Set();
377
377
  for (const t of M) e.add(String(t.id));
378
378
  for (const t of le) e.add(t.key);
@@ -381,7 +381,7 @@ function yn({
381
381
  return [...e];
382
382
  }, [M, le, xe, Se]), Ct = $t({
383
383
  queries: (l.related_columns ?? []).map((e) => {
384
- const t = De(e.match, te);
384
+ const t = Ue(e.match, te);
385
385
  return {
386
386
  queryKey: [
387
387
  "catalog-related",
@@ -394,12 +394,12 @@ function yn({
394
394
  const r = {}, s = e.aggregate === "sum", c = s ? 150 : 400;
395
395
  for (let o = 0; o < et.length; o += c) {
396
396
  const i = et.slice(o, o + c);
397
- let p = 1;
397
+ let b = 1;
398
398
  for (; ; ) {
399
399
  const d = await h.request(
400
400
  R(`/items/${e.collection}`, {
401
401
  limit: s ? 1e3 : i.length,
402
- ...s ? { page: p } : {},
402
+ ...s ? { page: b } : {},
403
403
  fields: `${e.item_field},${e.value_field}`,
404
404
  filter: JSON.stringify({ ...t, [e.item_field]: { _in: i } })
405
405
  })
@@ -414,7 +414,7 @@ function yn({
414
414
  r[String(w)] = u[e.value_field];
415
415
  }
416
416
  if (!s || d.length < 1e3) break;
417
- p += 1;
417
+ b += 1;
418
418
  }
419
419
  }
420
420
  return r;
@@ -428,19 +428,19 @@ function yn({
428
428
  const r = (l.related_columns ?? []).findIndex((o) => o.key === e);
429
429
  if (r !== -1)
430
430
  return (c = (s = Ct[r]) == null ? void 0 : s.data) == null ? void 0 : c[t];
431
- }, pt = (e) => {
432
- var p;
431
+ }, bt = (e) => {
432
+ var b;
433
433
  const t = l.qty_warning;
434
434
  if (!t) return null;
435
435
  const r = fe(e) ?? 0;
436
436
  if (r <= 0) return null;
437
437
  const s = (l.related_columns ?? []).findIndex((d) => d.key === t.column);
438
438
  if (s === -1) return null;
439
- const c = (p = Ct[s]) == null ? void 0 : p.data;
439
+ const c = (b = Ct[s]) == null ? void 0 : b.data;
440
440
  if (c === void 0) return null;
441
441
  const o = c[e], i = o == null || o === "" ? 0 : Number(o);
442
442
  return Number.isNaN(i) ? null : r > i ? { available: i, qty: r } : null;
443
- }, ur = (e) => {
443
+ }, dr = (e) => {
444
444
  const t = l.row_flags ?? [];
445
445
  if (t.length === 0) return [];
446
446
  const r = [];
@@ -448,30 +448,30 @@ function yn({
448
448
  if (!(!(s != null && s.when) || !s.label))
449
449
  try {
450
450
  const c = s.when.replace(/\{\{\s*([A-Za-z_][A-Za-z0-9_.]*)\s*\}\}/g, "$1");
451
- Ar(c, e) && r.push(s.label);
451
+ Pr(c, e) && r.push(s.label);
452
452
  } catch {
453
453
  }
454
454
  return r;
455
- }, bt = l.qty_warning ? l.qty_warning.label ?? ((Mt = (l.related_columns ?? []).find((e) => {
455
+ }, pt = l.qty_warning ? l.qty_warning.label ?? ((Mt = (l.related_columns ?? []).find((e) => {
456
456
  var t;
457
457
  return e.key === ((t = l.qty_warning) == null ? void 0 : t.column);
458
- })) == null ? void 0 : Mt.label) ?? I(l.qty_warning.column) : "", fr = !!l.submission_errors, tt = O(
458
+ })) == null ? void 0 : Mt.label) ?? I(l.qty_warning.column) : "", cr = !!l.submission_errors, tt = O(
459
459
  () => {
460
460
  var e;
461
461
  return typeof l.submission_errors == "object" && Array.isArray((e = l.submission_errors) == null ? void 0 : e.match_fields) ? l.submission_errors.match_fields.filter((t) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(t)) : [];
462
462
  },
463
463
  [l.submission_errors]
464
- ), pr = Cr(6e4), { data: Kt } = z({
464
+ ), mr = Er(6e4), { data: Kt } = z({
465
465
  queryKey: ["erp-submissions", q ?? "", String(_)],
466
466
  queryFn: () => h.request(R(`/erp-submissions/${q}/${encodeURIComponent(_)}`)).then((e) => e.data ?? []),
467
- enabled: fr && !E && !!q,
467
+ enabled: cr && !E && !!q,
468
468
  staleTime: 15e3,
469
- refetchInterval: pr
469
+ refetchInterval: mr
470
470
  }), ht = O(() => {
471
471
  const e = (Kt ?? [])[0];
472
- return !e || e.status !== "failed" ? null : Kr(e.payload, e.last_error);
473
- }, [Kt]), br = le.map((e) => e.key).join(","), { data: xt } = z({
474
- queryKey: ["catalog-suberr-idents", x, tt.join(","), br],
472
+ return !e || e.status !== "failed" ? null : Lr(e.payload, e.last_error);
473
+ }, [Kt]), ur = le.map((e) => e.key).join(","), { data: xt } = z({
474
+ queryKey: ["catalog-suberr-idents", x, tt.join(","), ur],
475
475
  queryFn: async () => {
476
476
  const e = le.map((r) => r.key);
477
477
  if (e.length === 0) return {};
@@ -486,19 +486,19 @@ function yn({
486
486
  },
487
487
  enabled: !!x && !!ht && tt.length > 0 && le.length > 0,
488
488
  staleTime: 6e4
489
- }), hr = (e) => {
489
+ }), fr = (e) => {
490
490
  if (!ht) return null;
491
491
  const t = xt == null ? void 0 : xt[e], r = [
492
- Ut(e),
492
+ Dt(e),
493
493
  ...tt.map((s) => {
494
494
  const c = (t == null ? void 0 : t[s]) ?? qe(e)[s];
495
495
  return c != null && c !== "" ? String(c) : null;
496
496
  })
497
- ].filter((s) => !!s).map(Jr);
497
+ ].filter((s) => !!s).map(Ar);
498
498
  return ht.reasonFor(r);
499
- }, rt = l.summary_fields ?? [], xr = we.map((e) => String(e.id)).join(","), gr = $t({
499
+ }, rt = l.summary_fields ?? [], br = we.map((e) => String(e.id)).join(","), pr = $t({
500
500
  queries: rt.filter((e) => e.m2m).map((e) => ({
501
- queryKey: ["catalog-summary-m2m", e.field, e.m2m.junction, xr],
501
+ queryKey: ["catalog-summary-m2m", e.field, e.m2m.junction, br],
502
502
  queryFn: async () => {
503
503
  const t = we.map((u) => String(u.id));
504
504
  if (t.length === 0) return {};
@@ -514,9 +514,9 @@ function yn({
514
514
  fields: `id,${o}`,
515
515
  filter: JSON.stringify({ id: { _in: c } })
516
516
  })
517
- ).then((u) => u.data ?? []).catch(() => []) : [], p = new Map(i.map((u) => [String(u.id), String(u[o] ?? u.id)])), d = {};
517
+ ).then((u) => u.data ?? []).catch(() => []) : [], b = new Map(i.map((u) => [String(u.id), String(u[o] ?? u.id)])), d = {};
518
518
  for (const u of s) {
519
- const w = String(u[r.fk_to_child]), j = p.get(String(u[r.related_field]));
519
+ const w = String(u[r.fk_to_child]), j = b.get(String(u[r.related_field]));
520
520
  j && (d[w] = d[w] ? `${d[w]}, ${j}` : j);
521
521
  }
522
522
  return d;
@@ -524,16 +524,16 @@ function yn({
524
524
  enabled: !E && we.length > 0,
525
525
  staleTime: 15e3
526
526
  }))
527
- }), yr = (e, t) => {
527
+ }), hr = (e, t) => {
528
528
  var c, o;
529
529
  if (!e.m2m) return t.row[e.field];
530
530
  const r = rt.filter((i) => i.m2m).findIndex((i) => i.field === e.field);
531
531
  if (r === -1) return;
532
532
  const s = t.row.id;
533
533
  if (s != null)
534
- return (o = (c = gr[r]) == null ? void 0 : c.data) == null ? void 0 : o[String(s)];
535
- }, kr = !!((Wt = l.fulfilment) != null && Wt.shipped_field) && (l.fulfilment.show_when ? rr(l.fulfilment.show_when, te) : !0), wr = (e) => {
536
- if (!kr || !l.fulfilment) return null;
534
+ return (o = (c = pr[r]) == null ? void 0 : c.data) == null ? void 0 : o[String(s)];
535
+ }, xr = !!((Wt = l.fulfilment) != null && Wt.shipped_field) && (l.fulfilment.show_when ? Xt(l.fulfilment.show_when, te) : !0), gr = (e) => {
536
+ if (!xr || !l.fulfilment) return null;
537
537
  const t = Number(e[l.fulfilment.qty_field ?? V] ?? 0) || 0, r = Number(e[l.fulfilment.shipped_field] ?? 0) || 0, s = t > 0 && r >= t ? {
538
538
  dot: "bg-emerald-500",
539
539
  text: "text-emerald-700 dark:text-emerald-400",
@@ -559,7 +559,7 @@ function yn({
559
559
  ]
560
560
  }
561
561
  );
562
- }, Jt = l.columns ?? [], Qt = l.related_columns ?? [], gt = Jt.filter((e) => !e.summary_only), yt = Qt.filter((e) => !e.summary_only), zt = Jt.filter((e) => !e.sections_only), Bt = Qt.filter((e) => !e.sections_only), Vt = gt.length > 0 || yt.length > 0, kt = Ve(null), Dt = (e) => {
562
+ }, Jt = l.columns ?? [], Qt = l.related_columns ?? [], gt = Jt.filter((e) => !e.summary_only), yt = Qt.filter((e) => !e.summary_only), zt = Jt.filter((e) => !e.sections_only), Bt = Qt.filter((e) => !e.sections_only), Vt = gt.length > 0 || yt.length > 0, kt = Ve(null), Ut = (e) => {
563
563
  let t = e.parentElement;
564
564
  for (; t; ) {
565
565
  const r = getComputedStyle(t);
@@ -569,14 +569,14 @@ function yn({
569
569
  }
570
570
  t = t.parentElement;
571
571
  }
572
- }, Nr = (e) => {
573
- kt.current = e, e && Dt(e);
572
+ }, yr = (e) => {
573
+ kt.current = e, e && Ut(e);
574
574
  };
575
575
  je(() => {
576
576
  let e = 0;
577
577
  const t = () => {
578
578
  e || (e = requestAnimationFrame(() => {
579
- e = 0, kt.current && Dt(kt.current);
579
+ e = 0, kt.current && Ut(kt.current);
580
580
  }));
581
581
  };
582
582
  return window.addEventListener("scroll", t, !0), () => {
@@ -616,11 +616,11 @@ function yn({
616
616
  },
617
617
  r.key
618
618
  ))
619
- ] }), Nt = Vt ? "w-36 shrink-0 truncate text-slate-700 dark:text-slate-200" : "min-w-0 flex-1 truncate text-slate-700 dark:text-slate-200", vr = nr(x), nt = (e, t, r) => vr ? /* @__PURE__ */ n(
619
+ ] }), Nt = Vt ? "w-36 shrink-0 truncate text-slate-700 dark:text-slate-200" : "min-w-0 flex-1 truncate text-slate-700 dark:text-slate-200", kr = er(x), nt = (e, t, r) => kr ? /* @__PURE__ */ n(
620
620
  "button",
621
621
  {
622
622
  type: "button",
623
- onClick: () => x && sr(x, e, te),
623
+ onClick: () => x && tr(x, e, te),
624
624
  title: "View stock & planning detail",
625
625
  className: B(
626
626
  r,
@@ -628,7 +628,7 @@ function yn({
628
628
  ),
629
629
  children: t
630
630
  }
631
- ) : /* @__PURE__ */ n("span", { className: r, children: t }), Ut = (e) => {
631
+ ) : /* @__PURE__ */ n("span", { className: r, children: t }), Dt = (e) => {
632
632
  const t = Me.get(e) ?? Rt.find((r) => String(r.id) === e) ?? Le.find((r) => String(r.id) === e);
633
633
  return t ? Fe(ee, t) : `#${e}`;
634
634
  }, qe = (e) => Me.get(e) ?? Rt.find((t) => String(t.id) === e) ?? Le.find((t) => String(t.id) === e) ?? { id: e }, fe = (e) => {
@@ -637,7 +637,7 @@ function yn({
637
637
  if (t) return Ye.has(String(t.id)) ? null : Number(t[V] ?? 0);
638
638
  const r = Ze.get(e);
639
639
  return r === void 0 ? null : Number(((s = Ne[r]) == null ? void 0 : s[V]) ?? 0);
640
- }, _r = (e) => {
640
+ }, wr = (e) => {
641
641
  let t = e;
642
642
  for (const r of l.section_by.split(".")) {
643
643
  if (t == null || typeof t != "object") return "";
@@ -649,7 +649,7 @@ function yn({
649
649
  C.trim().toLowerCase();
650
650
  const e = /* @__PURE__ */ new Map();
651
651
  for (const t of M) {
652
- const r = Fe(ee, t), s = A ? Ot.get(String(t.id)) ?? [] : [_r(t)];
652
+ const r = Fe(ee, t), s = A ? Ot.get(String(t.id)) ?? [] : [wr(t)];
653
653
  if (!(A && a && s.length === 0))
654
654
  for (const c of s.length ? s : [""]) {
655
655
  const o = c || "Uncategorized";
@@ -679,13 +679,13 @@ function yn({
679
679
  t.items.some((s) => (fe(s.id) ?? 0) > 0) || e.add(t.name);
680
680
  ne(e);
681
681
  }
682
- async function Sr(e) {
682
+ async function Nr(e) {
683
683
  const t = {};
684
684
  for (const r of l.related_columns ?? []) {
685
685
  if (!r.copy_to) continue;
686
686
  let s = ft(r.key, e);
687
687
  if (s === void 0) {
688
- const c = De(r.match, te);
688
+ const c = Ue(r.match, te);
689
689
  if (c === null) continue;
690
690
  s = await h.request(
691
691
  R(`/items/${r.collection}`, {
@@ -694,8 +694,8 @@ function yn({
694
694
  filter: JSON.stringify({ ...c, [r.item_field]: { _eq: e } })
695
695
  })
696
696
  ).then((o) => {
697
- var i, p;
698
- return (p = (i = o.data) == null ? void 0 : i[0]) == null ? void 0 : p[r.value_field];
697
+ var i, b;
698
+ return (b = (i = o.data) == null ? void 0 : i[0]) == null ? void 0 : b[r.value_field];
699
699
  }).catch(() => {
700
700
  });
701
701
  }
@@ -712,13 +712,13 @@ function yn({
712
712
  r[i] !== void 0 && (c[o] = r[i]);
713
713
  Object.assign(c, s);
714
714
  for (const [o, i] of Object.entries(l.compute_fields ?? {})) {
715
- const p = Qe(i, c);
716
- p !== null && (c[o] = p);
715
+ const b = Qe(i, c);
716
+ b !== null && (c[o] = b);
717
717
  }
718
718
  return c;
719
719
  }
720
720
  async function at(e, t, r, s = {}) {
721
- const c = tr(t, { type: _e, min: 0, label: "Quantity" });
721
+ const c = Gt(t, { type: _e, min: 0, label: "Quantity" });
722
722
  if (!c.ok) {
723
723
  F((d) => ({ ...d, [e]: { kind: "error", message: c.message } }));
724
724
  return;
@@ -736,18 +736,18 @@ function yn({
736
736
  return;
737
737
  }
738
738
  }
739
- const p = o > 0 ? await Sr(e) : {};
740
- if (Pe && b) {
739
+ const b = o > 0 ? await Nr(e) : {};
740
+ if (Pe && p) {
741
741
  const d = Ee.get(e);
742
742
  if ((d == null ? void 0 : d.id) != null) {
743
743
  const u = String(d.id);
744
744
  if (o === 0) {
745
- b.cancelPendingEdit(f, y, u), b.queueDelete(f, y, u);
745
+ p.cancelPendingEdit(f, y, u), p.queueDelete(f, y, u);
746
746
  return;
747
747
  }
748
- Ye.has(u) && b.cancelPendingDelete(f, y, u);
749
- const w = Ce(e, o, r, p);
750
- for (const S of U)
748
+ Ye.has(u) && p.cancelPendingDelete(f, y, u);
749
+ const w = Ce(e, o, r, b);
750
+ for (const S of D)
751
751
  d[S] != null && d[S] !== "" && (w[S] = d[S]);
752
752
  for (const [S, $e] of Object.entries(l.compute_fields ?? {})) {
753
753
  const ve = Qe($e, { ...d, ...w });
@@ -756,26 +756,26 @@ function yn({
756
756
  const j = we.find((S) => String(S.id) === u) ?? {}, N = Object.fromEntries(
757
757
  Object.entries(w).filter(([S, $e]) => String($e ?? "") !== String(j[S] ?? ""))
758
758
  );
759
- Object.keys(N).length === 0 ? b.cancelPendingEdit(f, y, u) : (b.cancelPendingEdit(f, y, u), b.queueEdit(f, y, u, N));
759
+ Object.keys(N).length === 0 ? p.cancelPendingEdit(f, y, u) : (p.cancelPendingEdit(f, y, u), p.queueEdit(f, y, u, N));
760
760
  return;
761
761
  }
762
762
  }
763
763
  if (E || Pe) {
764
764
  const d = Ze.get(e);
765
- o === 0 ? d !== void 0 && (b == null || b.removeRow(f, y, d)) : d !== void 0 ? b == null || b.updateRow(
765
+ o === 0 ? d !== void 0 && (p == null || p.removeRow(f, y, d)) : d !== void 0 ? p == null || p.updateRow(
766
766
  f,
767
767
  y,
768
768
  d,
769
769
  Vr(
770
770
  Ne[d],
771
- Ce(e, o, r, p),
772
- U,
771
+ Ce(e, o, r, b),
772
+ D,
773
773
  l.compute_fields
774
774
  )
775
- ) : b == null || b.queueRow(
775
+ ) : p == null || p.queueRow(
776
776
  f,
777
777
  y,
778
- Ce(e, o, r, p)
778
+ Ce(e, o, r, b)
779
779
  );
780
780
  return;
781
781
  }
@@ -783,10 +783,10 @@ function yn({
783
783
  try {
784
784
  const d = Ee.get(e);
785
785
  if (o === 0)
786
- (d == null ? void 0 : d.id) != null && await h.request(Lr(`/items/${f}/${d.id}`));
786
+ (d == null ? void 0 : d.id) != null && await h.request(Rr(`/items/${f}/${d.id}`));
787
787
  else if ((d == null ? void 0 : d.id) != null) {
788
- const u = Ce(e, o, r, p);
789
- for (const S of U)
788
+ const u = Ce(e, o, r, b);
789
+ for (const S of D)
790
790
  d[S] != null && d[S] !== "" && (u[S] = d[S]);
791
791
  for (const [S, $e] of Object.entries(l.compute_fields ?? {})) {
792
792
  const ve = Qe($e, { ...d, ...u });
@@ -798,7 +798,7 @@ function yn({
798
798
  await h.request(
799
799
  Zt(`/items/${f}`, {
800
800
  [y]: _,
801
- ...Ce(e, o, r, p)
801
+ ...Ce(e, o, r, b)
802
802
  })
803
803
  );
804
804
  $.invalidateQueries({ queryKey: ["o2m-rows", f, y, _] });
@@ -810,45 +810,45 @@ function yn({
810
810
  });
811
811
  }
812
812
  }
813
- async function qr(e, t, r) {
813
+ async function vr(e, t, r) {
814
814
  const s = r.trim() === "" ? null : Number(r);
815
815
  if (r.trim() !== "" && Number.isNaN(s)) return;
816
816
  const c = (i) => {
817
- const p = { ...i, [t]: s };
817
+ const b = { ...i, [t]: s };
818
818
  for (const [d, u] of Object.entries(l.compute_fields ?? {})) {
819
- const w = Qe(u, p);
820
- w !== null && (p[d] = w);
819
+ const w = Qe(u, b);
820
+ w !== null && (b[d] = w);
821
821
  }
822
- return p;
822
+ return b;
823
823
  }, o = E ? void 0 : Ee.get(e);
824
824
  if ((o == null ? void 0 : o.id) == null) {
825
825
  const i = Ze.get(e);
826
826
  if (i === void 0) return;
827
- b == null || b.updateRow(f, y, i, c(Ne[i]));
827
+ p == null || p.updateRow(f, y, i, c(Ne[i]));
828
828
  return;
829
829
  }
830
- if (Pe && b) {
831
- const i = c(o), p = we.find((u) => String(u.id) === String(o.id)) ?? {}, d = Object.fromEntries(
830
+ if (Pe && p) {
831
+ const i = c(o), b = we.find((u) => String(u.id) === String(o.id)) ?? {}, d = Object.fromEntries(
832
832
  Object.entries(i).filter(
833
- ([u, w]) => u !== "id" && String(w ?? "") !== String(p[u] ?? "")
833
+ ([u, w]) => u !== "id" && String(w ?? "") !== String(b[u] ?? "")
834
834
  )
835
835
  );
836
- b.cancelPendingEdit(f, y, String(o.id)), Object.keys(d).length > 0 && b.queueEdit(f, y, String(o.id), d);
836
+ p.cancelPendingEdit(f, y, String(o.id)), Object.keys(d).length > 0 && p.queueEdit(f, y, String(o.id), d);
837
837
  return;
838
838
  }
839
839
  v((i) => new Set(i).add(e));
840
840
  try {
841
- const { id: i, ...p } = c(o);
842
- await h.request(Yt(`/items/${f}/${o.id}`, p)), $.invalidateQueries({ queryKey: ["o2m-rows", f, y, _] });
841
+ const { id: i, ...b } = c(o);
842
+ await h.request(Yt(`/items/${f}/${o.id}`, b)), $.invalidateQueries({ queryKey: ["o2m-rows", f, y, _] });
843
843
  } catch {
844
844
  } finally {
845
845
  v((i) => {
846
- const p = new Set(i);
847
- return p.delete(e), p;
846
+ const b = new Set(i);
847
+ return b.delete(e), b;
848
848
  });
849
849
  }
850
850
  }
851
- async function $r(e) {
851
+ async function _r(e) {
852
852
  if (e == null || e === "" || !x) return;
853
853
  const t = String(e), r = qe(t);
854
854
  let s = r;
@@ -865,15 +865,15 @@ function yn({
865
865
  const c = (fe(t) ?? 0) + 1;
866
866
  await at(t, String(c), s);
867
867
  }
868
- const jr = le.length, vt = Object.keys(l.copy_fields ?? {}), _t = Object.keys(l.compute_fields ?? {}), Ke = (e, t) => {
868
+ const Sr = le.length, vt = Object.keys(l.copy_fields ?? {}), _t = Object.keys(l.compute_fields ?? {}), Ke = (e, t) => {
869
869
  const r = fe(e);
870
870
  if (g)
871
871
  return /* @__PURE__ */ n("span", { className: "inline-block w-20 shrink-0 text-right tabular-nums text-slate-700 dark:text-slate-200", children: r && r > 0 ? r : "—" });
872
- const s = pe[e], c = s !== void 0 ? s : r && r > 0 ? String(r) : "", o = T[e], i = () => F((d) => {
872
+ const s = be[e], c = s !== void 0 ? s : r && r > 0 ? String(r) : "", o = T[e], i = () => F((d) => {
873
873
  if (!(e in d)) return d;
874
874
  const u = { ...d };
875
875
  return delete u[e], u;
876
- }), p = /* @__PURE__ */ n(
876
+ }), b = /* @__PURE__ */ n(
877
877
  "input",
878
878
  {
879
879
  type: "number",
@@ -901,69 +901,66 @@ function yn({
901
901
  )
902
902
  }
903
903
  );
904
- return /* @__PURE__ */ m(Gt, { open: !!o, onOpenChange: (d) => !d && i(), children: [
905
- /* @__PURE__ */ n(Xt, { asChild: !0, children: p }),
906
- /* @__PURE__ */ m(
907
- er,
904
+ return /* @__PURE__ */ m(Jr, { open: (o == null ? void 0 : o.kind) === "remove", onOpenChange: (d) => !d && i(), children: [
905
+ /* @__PURE__ */ n(Qr, { asChild: !0, children: /* @__PURE__ */ m("span", { className: "inline-flex shrink-0 flex-col items-end", children: [
906
+ b,
907
+ (o == null ? void 0 : o.kind) === "error" && /* @__PURE__ */ m(
908
+ "span",
909
+ {
910
+ role: "alert",
911
+ className: "mt-0.5 flex max-w-[220px] items-start gap-1 text-right text-[11px] leading-snug text-red-600 dark:text-red-400",
912
+ "data-catalog-qty-error": !0,
913
+ children: [
914
+ /* @__PURE__ */ n(St, { className: "mt-px h-3 w-3 shrink-0" }),
915
+ o.message,
916
+ r && r > 0 ? ` — still ${r}` : ""
917
+ ]
918
+ }
919
+ )
920
+ ] }) }),
921
+ /* @__PURE__ */ n(
922
+ zr,
908
923
  {
909
924
  align: "end",
910
925
  side: "bottom",
911
926
  className: "w-auto max-w-[260px] p-2.5 text-[12px]",
912
- onOpenAutoFocus: (d) => {
913
- (o == null ? void 0 : o.kind) === "error" && d.preventDefault();
914
- },
915
- children: [
916
- (o == null ? void 0 : o.kind) === "error" && /* @__PURE__ */ m(
917
- "p",
918
- {
919
- role: "alert",
920
- className: "flex items-start gap-1.5 text-red-600 dark:text-red-400",
921
- "data-catalog-qty-error": !0,
922
- children: [
923
- /* @__PURE__ */ n(St, { className: "mt-px h-3.5 w-3.5 shrink-0" }),
924
- o.message,
925
- r && r > 0 ? ` — still ${r}` : ""
926
- ]
927
- }
928
- ),
929
- (o == null ? void 0 : o.kind) === "remove" && /* @__PURE__ */ m("div", { "data-catalog-qty-remove": !0, children: [
930
- /* @__PURE__ */ n("p", { className: "text-slate-700 dark:text-slate-200", children: "Remove this line?" }),
931
- /* @__PURE__ */ m("div", { className: "mt-2 flex justify-end gap-1.5", children: [
932
- /* @__PURE__ */ n(
933
- "button",
934
- {
935
- type: "button",
936
- onClick: i,
937
- className: "h-6 rounded border border-slate-200 px-2 text-[11px] text-slate-600 hover:bg-muted dark:border-border dark:text-slate-300",
938
- children: "Keep"
939
- }
940
- ),
941
- /* @__PURE__ */ n(
942
- "button",
943
- {
944
- type: "button",
945
- onClick: () => {
946
- const d = o.row;
947
- i(), at(e, "0", d, { confirmedRemove: !0 });
948
- },
949
- className: "h-6 rounded bg-red-600 px-2 text-[11px] font-medium text-white hover:bg-red-700",
950
- children: "Remove"
951
- }
952
- )
953
- ] })
927
+ children: (o == null ? void 0 : o.kind) === "remove" && /* @__PURE__ */ m("div", { "data-catalog-qty-remove": !0, children: [
928
+ /* @__PURE__ */ n("p", { className: "text-slate-700 dark:text-slate-200", children: "Remove this line?" }),
929
+ /* @__PURE__ */ m("div", { className: "mt-2 flex justify-end gap-1.5", children: [
930
+ /* @__PURE__ */ n(
931
+ "button",
932
+ {
933
+ type: "button",
934
+ onClick: i,
935
+ className: "h-6 rounded border border-slate-200 px-2 text-[11px] text-slate-600 hover:bg-muted dark:border-border dark:text-slate-300",
936
+ children: "Keep"
937
+ }
938
+ ),
939
+ /* @__PURE__ */ n(
940
+ "button",
941
+ {
942
+ type: "button",
943
+ onClick: () => {
944
+ const d = o.row;
945
+ i(), at(e, "0", d, { confirmedRemove: !0 });
946
+ },
947
+ className: "h-6 rounded bg-red-600 px-2 text-[11px] font-medium text-white hover:bg-red-700",
948
+ children: "Remove"
949
+ }
950
+ )
954
951
  ] })
955
- ]
952
+ ] })
956
953
  }
957
954
  )
958
955
  ] });
959
- }, Fr = (e, t, r) => {
960
- const s = `${e}:${t}`, c = W[s], o = () => L((p) => {
961
- if (!(s in p)) return p;
962
- const d = { ...p };
956
+ }, qr = (e, t, r) => {
957
+ const s = `${e}:${t}`, c = W[s], o = () => L((b) => {
958
+ if (!(s in b)) return b;
959
+ const d = { ...b };
963
960
  return delete d[s], d;
964
961
  }), i = r[t] == null ? "" : String(r[t]);
965
- return /* @__PURE__ */ m(Gt, { open: !!c, onOpenChange: (p) => !p && o(), children: [
966
- /* @__PURE__ */ n(Xt, { asChild: !0, children: /* @__PURE__ */ n(
962
+ return /* @__PURE__ */ m("span", { className: "inline-flex shrink-0 flex-col items-end", children: [
963
+ /* @__PURE__ */ n(
967
964
  "input",
968
965
  {
969
966
  type: "number",
@@ -972,22 +969,22 @@ function yn({
972
969
  defaultValue: i,
973
970
  "aria-invalid": !!c || void 0,
974
971
  onFocus: o,
975
- onBlur: (p) => {
976
- const d = p.target.value;
972
+ onBlur: (b) => {
973
+ const d = b.target.value;
977
974
  if (d !== i) {
978
- const u = be.find((N) => N.field === t), w = tr(d, {
975
+ const u = pe.find((N) => N.field === t), w = Gt(d, {
979
976
  type: u == null ? void 0 : u.type,
980
977
  label: (u == null ? void 0 : u.label) || I(t)
981
978
  }), j = w.ok ? Oe(t, w.value, r) : w.message;
982
979
  if (j) {
983
- p.target.value = i, L((N) => ({ ...N, [s]: j }));
980
+ b.target.value = i, L((N) => ({ ...N, [s]: j }));
984
981
  return;
985
982
  }
986
983
  }
987
- qr(e, t, d);
984
+ vr(e, t, d);
988
985
  },
989
- onKeyDown: (p) => {
990
- p.key === "Enter" && p.currentTarget.blur();
986
+ onKeyDown: (b) => {
987
+ b.key === "Enter" && b.currentTarget.blur();
991
988
  },
992
989
  className: B(
993
990
  "h-7 w-20 shrink-0 rounded border border-slate-200 bg-white px-2 text-right text-[12px] outline-none focus:border-nvr-cyan dark:border-border dark:bg-background",
@@ -995,27 +992,18 @@ function yn({
995
992
  )
996
993
  },
997
994
  `${s}:${i}`
998
- ) }),
999
- /* @__PURE__ */ n(
1000
- er,
995
+ ),
996
+ c && /* @__PURE__ */ m(
997
+ "span",
1001
998
  {
1002
- align: "end",
1003
- side: "bottom",
1004
- className: "w-auto max-w-[260px] p-2.5 text-[12px]",
1005
- onOpenAutoFocus: (p) => p.preventDefault(),
1006
- children: /* @__PURE__ */ m(
1007
- "p",
1008
- {
1009
- role: "alert",
1010
- className: "flex items-start gap-1.5 text-red-600 dark:text-red-400",
1011
- "data-catalog-cell-error": !0,
1012
- children: [
1013
- /* @__PURE__ */ n(St, { className: "mt-px h-3.5 w-3.5 shrink-0" }),
1014
- c,
1015
- i !== "" ? ` — still ${i}` : ""
1016
- ]
1017
- }
1018
- )
999
+ role: "alert",
1000
+ className: "mt-0.5 flex max-w-[220px] items-start gap-1 text-right text-[11px] leading-snug text-red-600 dark:text-red-400",
1001
+ "data-catalog-cell-error": !0,
1002
+ children: [
1003
+ /* @__PURE__ */ n(St, { className: "mt-px h-3 w-3 shrink-0" }),
1004
+ c,
1005
+ i !== "" ? ` — still ${i}` : ""
1006
+ ]
1019
1007
  }
1020
1008
  )
1021
1009
  ] }, s);
@@ -1038,7 +1026,7 @@ function yn({
1038
1026
  }
1039
1027
  ),
1040
1028
  /* @__PURE__ */ m("span", { className: "shrink-0 rounded border border-slate-200 bg-slate-50 px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:border-border dark:bg-muted dark:text-slate-400", children: [
1041
- jr,
1029
+ Sr,
1042
1030
  " picked"
1043
1031
  ] })
1044
1032
  ] }),
@@ -1049,7 +1037,7 @@ function yn({
1049
1037
  /* @__PURE__ */ m(
1050
1038
  "div",
1051
1039
  {
1052
- ref: Nr,
1040
+ ref: yr,
1053
1041
  className: "sticky top-0 z-[5] flex items-center gap-2 border-b border-slate-200 bg-slate-50 px-3 py-1 text-[10px] font-medium uppercase tracking-wide text-slate-400 dark:border-border dark:bg-muted",
1054
1042
  children: [
1055
1043
  l.favorites && /* @__PURE__ */ n("span", { className: "w-[18px] shrink-0" }),
@@ -1161,7 +1149,7 @@ function yn({
1161
1149
  ] }),
1162
1150
  !oe.has("__favorites__") && Le.length === 0 && /* @__PURE__ */ n("p", { className: "border-b border-slate-100 px-3 py-2 text-center text-[11px] text-slate-400 dark:border-border/50", children: "No favorites yet — Manage lets you search the full catalog and star items." }),
1163
1151
  !oe.has("__favorites__") && Le.map((e, t) => {
1164
- const r = String(e.id), s = fe(r), c = pt(r);
1152
+ const r = String(e.id), s = fe(r), c = bt(r);
1165
1153
  return /* @__PURE__ */ m(
1166
1154
  "div",
1167
1155
  {
@@ -1179,7 +1167,7 @@ function yn({
1179
1167
  ze,
1180
1168
  {
1181
1169
  className: "h-3.5 w-3.5 shrink-0 text-amber-500",
1182
- "aria-label": `${bt} ${c.available} — ${c.qty} requested`
1170
+ "aria-label": `${pt} ${c.available} — ${c.qty} requested`
1183
1171
  }
1184
1172
  ),
1185
1173
  se.has(r) && /* @__PURE__ */ n(ae, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" }),
@@ -1225,7 +1213,7 @@ function yn({
1225
1213
  }
1226
1214
  ),
1227
1215
  !t && e.items.map((s, c) => {
1228
- const o = fe(s.id), i = pt(s.id);
1216
+ const o = fe(s.id), i = bt(s.id);
1229
1217
  return /* @__PURE__ */ m(
1230
1218
  "div",
1231
1219
  {
@@ -1243,7 +1231,7 @@ function yn({
1243
1231
  ze,
1244
1232
  {
1245
1233
  className: "h-3.5 w-3.5 shrink-0 text-amber-500",
1246
- "aria-label": `${bt} ${i.available} — ${i.qty} requested`
1234
+ "aria-label": `${pt} ${i.available} — ${i.qty} requested`
1247
1235
  }
1248
1236
  ),
1249
1237
  se.has(s.id) && /* @__PURE__ */ n(ae, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" }),
@@ -1256,7 +1244,7 @@ function yn({
1256
1244
  ] }, e.name);
1257
1245
  })
1258
1246
  ] }),
1259
- (l.builders ?? []).filter((e) => rr(e.show_when, te)).map((e) => /* @__PURE__ */ n(
1247
+ (l.builders ?? []).filter((e) => Xt(e.show_when, te)).map((e) => /* @__PURE__ */ n(
1260
1248
  Ir,
1261
1249
  {
1262
1250
  builder: e,
@@ -1275,7 +1263,7 @@ function yn({
1275
1263
  /* @__PURE__ */ n("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Summary" }),
1276
1264
  !g && /* @__PURE__ */ m("div", { className: "flex items-center gap-2", onClick: (e) => e.stopPropagation(), children: [
1277
1265
  l.upload_template && !E && Z && q && /* @__PURE__ */ n(
1278
- zr,
1266
+ Kr,
1279
1267
  {
1280
1268
  collection: q,
1281
1269
  templateFilter: (e) => {
@@ -1295,14 +1283,14 @@ function yn({
1295
1283
  {
1296
1284
  collection: x,
1297
1285
  value: null,
1298
- onChange: (e) => void $r(e),
1286
+ onChange: (e) => void _r(e),
1299
1287
  placeholder: "+ Add any item…"
1300
1288
  }
1301
1289
  ) })
1302
1290
  ] })
1303
1291
  ] }),
1304
1292
  le.length === 0 ? /* @__PURE__ */ n("p", { className: "px-3 py-4 text-center text-slate-400", children: "Nothing picked yet" }) : (() => {
1305
- const e = zt.filter((i) => !i.format), t = e[0], r = e.slice(1), s = zt.filter((i) => !!i.format), c = (i, p) => p === "presence" ? i == null || i === "" || Number(i) === 0 ? "No" : "Yes" : i === !0 || i === "true" ? "✓" : i === !1 || i === "false" || i == null || i === "" ? "—" : ue(i, p), o = (i) => /* @__PURE__ */ n("span", { className: "w-20 shrink-0 text-right text-[11px] font-medium text-slate-500", children: i });
1293
+ const e = zt.filter((i) => !i.format), t = e[0], r = e.slice(1), s = zt.filter((i) => !!i.format), c = (i, b) => b === "presence" ? i == null || i === "" || Number(i) === 0 ? "No" : "Yes" : i === !0 || i === "true" ? "✓" : i === !1 || i === "false" || i == null || i === "" ? "—" : ue(i, b), o = (i) => /* @__PURE__ */ n("span", { className: "w-20 shrink-0 text-right text-[11px] font-medium text-slate-500", children: i });
1306
1294
  return /* @__PURE__ */ m("div", { children: [
1307
1295
  /* @__PURE__ */ m("div", { className: "flex items-center gap-2 border-b border-slate-200 px-3 py-1.5 dark:border-border", children: [
1308
1296
  /* @__PURE__ */ n("span", { className: "flex-1 text-[11px] font-medium text-slate-500", children: "Item" }),
@@ -1311,14 +1299,14 @@ function yn({
1311
1299
  _t.map((i) => /* @__PURE__ */ n(Je, { children: o(I(i)) }, i)),
1312
1300
  !g && /* @__PURE__ */ n("span", { className: "w-6 shrink-0" })
1313
1301
  ] }),
1314
- le.map((i, p) => {
1315
- const d = i.row.id != null ? String(i.row.id) : null, u = d != null && Ye.has(d), w = u ? null : pt(i.key), j = u ? null : hr(i.key);
1302
+ le.map((i, b) => {
1303
+ const d = i.row.id != null ? String(i.row.id) : null, u = d != null && Ye.has(d), w = u ? null : bt(i.key), j = u ? null : fr(i.key);
1316
1304
  return /* @__PURE__ */ m(
1317
1305
  "div",
1318
1306
  {
1319
1307
  className: B(
1320
1308
  "border-b border-slate-100 px-3 py-2 last:border-b-0 dark:border-border/50",
1321
- p % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
1309
+ b % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
1322
1310
  w && "bg-amber-50 dark:bg-amber-900/15",
1323
1311
  j && "bg-red-50/70 dark:bg-red-900/15",
1324
1312
  u && "opacity-60"
@@ -1334,7 +1322,7 @@ function yn({
1334
1322
  children: [
1335
1323
  nt(
1336
1324
  i.key,
1337
- Ut(i.key),
1325
+ Dt(i.key),
1338
1326
  "shrink-0 font-semibold text-slate-800 dark:text-slate-100"
1339
1327
  ),
1340
1328
  Pe && !u && (d == null || We.has(d)) && /* @__PURE__ */ n(
@@ -1379,7 +1367,7 @@ ${j}`,
1379
1367
  vt.map(
1380
1368
  (N) => {
1381
1369
  var S;
1382
- return U.includes(N) && !g ? Fr(i.key, N, i.row) : /* @__PURE__ */ n(
1370
+ return D.includes(N) && !g ? qr(i.key, N, i.row) : /* @__PURE__ */ n(
1383
1371
  "span",
1384
1372
  {
1385
1373
  className: "w-20 shrink-0 text-right tabular-nums text-slate-600 dark:text-slate-300",
@@ -1419,7 +1407,7 @@ ${j}`,
1419
1407
  "button",
1420
1408
  {
1421
1409
  type: "button",
1422
- onClick: () => b == null ? void 0 : b.cancelPendingDelete(f, y, d),
1410
+ onClick: () => p == null ? void 0 : p.cancelPendingDelete(f, y, d),
1423
1411
  className: "shrink-0 rounded px-1.5 py-0.5 text-[11px] font-medium text-nvr-navy underline dark:text-nvr-cyan",
1424
1412
  children: "Undo"
1425
1413
  }
@@ -1430,8 +1418,8 @@ ${j}`,
1430
1418
  type: "button",
1431
1419
  title: "Remove (applies on Save)",
1432
1420
  onClick: () => {
1433
- if (!E && b && d != null) {
1434
- b.queueDelete(f, y, d);
1421
+ if (!E && p && d != null) {
1422
+ p.queueDelete(f, y, d);
1435
1423
  return;
1436
1424
  }
1437
1425
  at(i.key, "0", {}, { confirmedRemove: !0 });
@@ -1454,8 +1442,8 @@ ${j}`,
1454
1442
  " ",
1455
1443
  /* @__PURE__ */ n("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: c(ft(N.key, i.key), N.format) })
1456
1444
  ] }, N.key)),
1457
- wr(i.row),
1458
- ur(i.row).map((N) => /* @__PURE__ */ m(
1445
+ gr(i.row),
1446
+ dr(i.row).map((N) => /* @__PURE__ */ m(
1459
1447
  "span",
1460
1448
  {
1461
1449
  className: "inline-flex items-center gap-1 whitespace-nowrap rounded bg-amber-50 px-1.5 py-px text-[10.5px] font-medium text-amber-700 dark:bg-amber-500/10 dark:text-amber-300",
@@ -1468,7 +1456,7 @@ ${j}`,
1468
1456
  N
1469
1457
  )),
1470
1458
  rt.map((N) => {
1471
- const S = yr(N, i);
1459
+ const S = hr(N, i);
1472
1460
  return /* @__PURE__ */ m("span", { className: "whitespace-nowrap", children: [
1473
1461
  /* @__PURE__ */ n("span", { className: "text-slate-500 dark:text-muted-foreground", children: N.label ?? I(N.field) }),
1474
1462
  " ",
@@ -1478,7 +1466,7 @@ ${j}`,
1478
1466
  ] }),
1479
1467
  w && /* @__PURE__ */ m("p", { className: "mt-1 flex items-center gap-1 pl-0.5 text-[11px] font-medium text-amber-600 dark:text-amber-400", children: [
1480
1468
  /* @__PURE__ */ n(ze, { className: "h-3 w-3 shrink-0" }),
1481
- bt,
1469
+ pt,
1482
1470
  " is ",
1483
1471
  ue(w.available, "number"),
1484
1472
  " —",
@@ -1496,7 +1484,7 @@ ${j}`,
1496
1484
  const i = le.filter((w) => {
1497
1485
  const j = w.row.id != null ? String(w.row.id) : null;
1498
1486
  return !(j != null && Ye.has(j));
1499
- }), p = (w) => i.reduce((j, N) => {
1487
+ }), b = (w) => i.reduce((j, N) => {
1500
1488
  const S = Number(N.row[w]);
1501
1489
  return j + (Number.isFinite(S) ? S : 0);
1502
1490
  }, 0), d = (w) => {
@@ -1506,14 +1494,14 @@ ${j}`,
1506
1494
  "span",
1507
1495
  {
1508
1496
  className: "w-20 shrink-0 text-right text-[12px] font-semibold tabular-nums text-slate-800 dark:text-slate-100",
1509
- children: ue(p(w), d(w))
1497
+ children: ue(b(w), d(w))
1510
1498
  },
1511
1499
  w
1512
1500
  );
1513
1501
  return /* @__PURE__ */ m("div", { className: "flex items-center gap-2 border-t border-slate-200 bg-slate-50 px-3 py-1.5 dark:border-border dark:bg-muted/40", children: [
1514
1502
  /* @__PURE__ */ n("span", { className: "flex-1 text-[11px] font-semibold uppercase tracking-wide text-slate-500", children: "Total" }),
1515
1503
  vt.map((w) => /* @__PURE__ */ n("span", { className: "w-20 shrink-0" }, w)),
1516
- /* @__PURE__ */ n("span", { className: "w-20 shrink-0 text-right text-[12px] font-semibold tabular-nums text-slate-800 dark:text-slate-100", children: ue(p(V), "number") }),
1504
+ /* @__PURE__ */ n("span", { className: "w-20 shrink-0 text-right text-[12px] font-semibold tabular-nums text-slate-800 dark:text-slate-100", children: ue(b(V), "number") }),
1517
1505
  _t.map(u),
1518
1506
  !g && /* @__PURE__ */ n("span", { className: "w-6 shrink-0" })
1519
1507
  ] });
@@ -1521,7 +1509,7 @@ ${j}`,
1521
1509
  ] });
1522
1510
  })()
1523
1511
  ] }),
1524
- or && x && /* @__PURE__ */ n(
1512
+ ar && x && /* @__PURE__ */ n(
1525
1513
  Zr,
1526
1514
  {
1527
1515
  catalogCol: x,
@@ -1555,13 +1543,13 @@ function Ir({
1555
1543
  qtyInput: g,
1556
1544
  currentQty: h
1557
1545
  }) {
1558
- const $ = Ft(), b = f.item_field ?? y, [P, Z] = Y(!1), [U, E] = Y({}), V = O(
1546
+ const $ = Ft(), p = f.item_field ?? y, [P, Z] = Y(!1), [D, E] = Y({}), V = O(
1559
1547
  () => [
1560
1548
  "id",
1561
- b,
1549
+ p,
1562
1550
  ...f.attributes.flatMap((v) => [`${v.field}.id`, `${v.field}.${v.label_field}`])
1563
1551
  ].join(","),
1564
- [b, f.attributes]
1552
+ [p, f.attributes]
1565
1553
  ), { data: oe = [], isLoading: ne } = z({
1566
1554
  queryKey: [
1567
1555
  "catalog-builder",
@@ -1590,15 +1578,15 @@ function Ir({
1590
1578
  }, C = (v) => oe.filter(
1591
1579
  (T) => f.attributes.slice(0, v).every((F) => {
1592
1580
  var L;
1593
- const W = U[F.field];
1581
+ const W = D[F.field];
1594
1582
  return W ? ((L = ge(T, F.field)) == null ? void 0 : L.id) === W : !0;
1595
1583
  })
1596
- ), ye = f.attributes.every((v) => U[v.field]), pe = ye ? oe.find(
1584
+ ), ye = f.attributes.every((v) => D[v.field]), be = ye ? oe.find(
1597
1585
  (v) => f.attributes.every((T) => {
1598
1586
  var F;
1599
- return ((F = ge(v, T.field)) == null ? void 0 : F.id) === U[T.field];
1587
+ return ((F = ge(v, T.field)) == null ? void 0 : F.id) === D[T.field];
1600
1588
  })
1601
- ) : void 0, G = (pe == null ? void 0 : pe[b]) != null ? String(pe[b]) : null, { data: se } = z({
1589
+ ) : void 0, G = (be == null ? void 0 : be[p]) != null ? String(be[p]) : null, { data: se } = z({
1602
1590
  queryKey: ["catalog-builder-item", _, q, G],
1603
1591
  queryFn: () => $.request(
1604
1592
  R(`/items/${_}`, {
@@ -1651,15 +1639,15 @@ function Ir({
1651
1639
  Yr,
1652
1640
  {
1653
1641
  label: I(v.field),
1654
- value: U[v.field] ?? null,
1655
- valueLabel: U[v.field] ? F.get(U[v.field]) ?? U[v.field] : null,
1642
+ value: D[v.field] ?? null,
1643
+ valueLabel: D[v.field] ? F.get(D[v.field]) ?? D[v.field] : null,
1656
1644
  options: W,
1657
- disabled: T > 0 && !U[f.attributes[T - 1].field],
1645
+ disabled: T > 0 && !D[f.attributes[T - 1].field],
1658
1646
  onChange: (L) => E((K) => {
1659
1647
  const de = {};
1660
1648
  for (let x = 0; x < T; x++) {
1661
- const be = f.attributes[x].field;
1662
- K[be] && (de[be] = K[be]);
1649
+ const pe = f.attributes[x].field;
1650
+ K[pe] && (de[pe] = K[pe]);
1663
1651
  }
1664
1652
  return L && (de[v.field] = L), de;
1665
1653
  })
@@ -1683,14 +1671,14 @@ function Yr({
1683
1671
  disabled: l,
1684
1672
  onChange: g
1685
1673
  }) {
1686
- const [h, $] = Y(!1), b = Ve(null);
1674
+ const [h, $] = Y(!1), p = Ve(null);
1687
1675
  return je(() => {
1688
1676
  if (!h) return;
1689
1677
  const P = (Z) => {
1690
- b.current && !b.current.contains(Z.target) && $(!1);
1678
+ p.current && !p.current.contains(Z.target) && $(!1);
1691
1679
  };
1692
1680
  return document.addEventListener("mousedown", P), () => document.removeEventListener("mousedown", P);
1693
- }, [h]), /* @__PURE__ */ m("div", { ref: b, className: "relative", children: [
1681
+ }, [h]), /* @__PURE__ */ m("div", { ref: p, className: "relative", children: [
1694
1682
  /* @__PURE__ */ n("p", { className: "mb-1 text-[10px] font-medium text-slate-500 dark:text-slate-400", children: f }),
1695
1683
  /* @__PURE__ */ m(
1696
1684
  "button",
@@ -1701,7 +1689,7 @@ function Yr({
1701
1689
  className: "flex w-44 items-center justify-between rounded border border-slate-200 bg-white px-2 py-1.5 text-left text-[12px] text-slate-700 hover:border-slate-300 disabled:opacity-50 dark:border-border dark:bg-background dark:text-slate-200",
1702
1690
  children: [
1703
1691
  /* @__PURE__ */ n("span", { className: B("truncate", !_ && "text-slate-400"), children: _ ?? "Select…" }),
1704
- /* @__PURE__ */ n(Or, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
1692
+ /* @__PURE__ */ n(jr, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
1705
1693
  ]
1706
1694
  }
1707
1695
  ),
@@ -1747,18 +1735,18 @@ function Zr({
1747
1735
  pinnedIds: g,
1748
1736
  savingIds: h,
1749
1737
  relatedCols: $,
1750
- parentDraft: b,
1738
+ parentDraft: p,
1751
1739
  onToggle: P,
1752
1740
  onClose: Z,
1753
- anchor: U
1741
+ anchor: D
1754
1742
  }) {
1755
- const E = Ft(), [V, oe] = Y(""), [ne, ge] = Y(""), [C, ye] = Y(1), pe = Ve(null);
1743
+ const E = Ft(), [V, oe] = Y(""), [ne, ge] = Y(""), [C, ye] = Y(1), be = Ve(null);
1756
1744
  je(() => {
1757
1745
  const a = setTimeout(() => ge(V), 300);
1758
1746
  return () => clearTimeout(a);
1759
1747
  }, [V]), je(() => ye(1), [ne]), je(() => {
1760
1748
  var a;
1761
- (a = pe.current) == null || a.focus();
1749
+ (a = be.current) == null || a.focus();
1762
1750
  }, []), je(() => {
1763
1751
  const a = (k) => {
1764
1752
  k.key === "Escape" && (k.stopPropagation(), Z());
@@ -1799,17 +1787,17 @@ function Zr({
1799
1787
  for (const k of W) a.add(String(k.id));
1800
1788
  for (const k of g) a.add(k);
1801
1789
  return [...a];
1802
- }, [W, g]), { data: be = /* @__PURE__ */ new Map() } = z({
1790
+ }, [W, g]), { data: pe = /* @__PURE__ */ new Map() } = z({
1803
1791
  queryKey: ["favorites-manager-sections", q == null ? void 0 : q.junction, x.join(",")],
1804
1792
  queryFn: async () => {
1805
1793
  const a = q, k = await ot(E, `/items/${a.junction}`, {
1806
1794
  fields: `${a.fkToItem},${a.fkToSection}`,
1807
1795
  filter: JSON.stringify({ [a.fkToItem]: { _in: x } })
1808
- }), D = [...new Set(k.map((H) => String(H[a.fkToSection])))], J = D.length ? await ot(E, `/items/${a.target}`, {
1796
+ }), U = [...new Set(k.map((H) => String(H[a.fkToSection])))], J = U.length ? await ot(E, `/items/${a.target}`, {
1809
1797
  fields: `id,${a.labelPath}`,
1810
- filter: JSON.stringify({ id: { _in: D } })
1798
+ filter: JSON.stringify({ id: { _in: U } })
1811
1799
  }) : [], re = new Map(
1812
- J.map((H) => [String(H.id), String(ar(H, a.labelPath) ?? "")])
1800
+ J.map((H) => [String(H.id), String(rr(H, a.labelPath) ?? "")])
1813
1801
  ), M = /* @__PURE__ */ new Map();
1814
1802
  for (const H of k) {
1815
1803
  const ie = re.get(String(H[a.fkToSection]));
@@ -1825,7 +1813,7 @@ function Zr({
1825
1813
  const k = a.description ?? a.long_description ?? a.name;
1826
1814
  return typeof k == "string" && k.trim() && k.trim() !== _e(a) ? k : "";
1827
1815
  }, X = (a) => {
1828
- if (q) return (be.get(String(a.id)) ?? []).join(", ");
1816
+ if (q) return (pe.get(String(a.id)) ?? []).join(", ");
1829
1817
  if (!_) return "";
1830
1818
  const k = Fe(`{{${_}}}`, a);
1831
1819
  return k === `{{${_}}}` ? "" : k;
@@ -1833,11 +1821,11 @@ function Zr({
1833
1821
  if (k === "presence")
1834
1822
  return a == null || a === "" || Number(a) === 0 ? "No" : "Yes";
1835
1823
  if (a == null || a === "") return "—";
1836
- const D = Number(a);
1837
- return k === "currency" && Number.isFinite(D) ? D.toLocaleString("en-US", { style: "currency", currency: "USD" }) : k === "number" && Number.isFinite(D) ? D.toLocaleString() : String(a);
1824
+ const U = Number(a);
1825
+ return k === "currency" && Number.isFinite(U) ? U.toLocaleString("en-US", { style: "currency", currency: "USD" }) : k === "number" && Number.isFinite(U) ? U.toLocaleString() : String(a);
1838
1826
  }, A = $t({
1839
1827
  queries: $.map((a) => {
1840
- const k = De(a.match, b);
1828
+ const k = Ue(a.match, p);
1841
1829
  return {
1842
1830
  queryKey: [
1843
1831
  "favorites-manager-related",
@@ -1847,14 +1835,14 @@ function Zr({
1847
1835
  x.join(",")
1848
1836
  ],
1849
1837
  queryFn: async () => {
1850
- const D = await E.request(
1838
+ const U = await E.request(
1851
1839
  R(`/items/${a.collection}`, {
1852
1840
  filter: JSON.stringify({ [a.item_field]: { _in: x }, ...k ?? {} }),
1853
1841
  fields: `${a.item_field},${a.value_field}`,
1854
1842
  limit: 1e3
1855
1843
  })
1856
1844
  ).then((re) => re.data ?? []), J = /* @__PURE__ */ new Map();
1857
- for (const re of D) {
1845
+ for (const re of U) {
1858
1846
  const M = String(re[a.item_field]), H = re[a.value_field], ie = J.get(M);
1859
1847
  ie === void 0 ? J.set(M, H) : Number.isFinite(Number(ie)) && Number.isFinite(Number(H)) && J.set(M, Number(ie) + Number(H));
1860
1848
  }
@@ -1865,8 +1853,8 @@ function Zr({
1865
1853
  };
1866
1854
  })
1867
1855
  }), ce = $.filter(
1868
- (a) => a.match !== void 0 && De(a.match, b) === null
1869
- ), Ue = (a) => {
1856
+ (a) => a.match !== void 0 && Ue(a.match, p) === null
1857
+ ), De = (a) => {
1870
1858
  const k = l.has(a);
1871
1859
  return /* @__PURE__ */ n(
1872
1860
  "button",
@@ -1888,7 +1876,7 @@ function Zr({
1888
1876
  }
1889
1877
  );
1890
1878
  }, Q = (a, k) => /* @__PURE__ */ n("tr", { children: /* @__PURE__ */ n("td", { colSpan: 4 + $.length, className: B("border-b px-3 py-1.5", k), children: a }) }), te = (a, k) => {
1891
- const D = String(a.id), J = Oe(a);
1879
+ const U = String(a.id), J = Oe(a);
1892
1880
  return /* @__PURE__ */ m(
1893
1881
  "tr",
1894
1882
  {
@@ -1897,12 +1885,12 @@ function Zr({
1897
1885
  k % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30"
1898
1886
  ),
1899
1887
  children: [
1900
- /* @__PURE__ */ n("td", { className: "px-2 py-1", children: Ue(D) }),
1901
- /* @__PURE__ */ n("td", { className: "px-2 py-1 font-medium tabular-nums text-slate-700 dark:text-slate-200", children: nr(f) ? /* @__PURE__ */ n(
1888
+ /* @__PURE__ */ n("td", { className: "px-2 py-1", children: De(U) }),
1889
+ /* @__PURE__ */ n("td", { className: "px-2 py-1 font-medium tabular-nums text-slate-700 dark:text-slate-200", children: er(f) ? /* @__PURE__ */ n(
1902
1890
  "button",
1903
1891
  {
1904
1892
  type: "button",
1905
- onClick: () => sr(f, D, b),
1893
+ onClick: () => tr(f, U, p),
1906
1894
  title: "View stock & planning detail",
1907
1895
  className: "text-left underline decoration-slate-300 decoration-1 underline-offset-2 hover:text-[#009abe] hover:decoration-[#009abe] dark:decoration-slate-600",
1908
1896
  children: _e(a)
@@ -1912,7 +1900,7 @@ function Zr({
1912
1900
  /* @__PURE__ */ n("td", { className: "px-2 py-1", children: /* @__PURE__ */ n("p", { className: "truncate text-slate-500 dark:text-slate-400", children: X(a) || "—" }) }),
1913
1901
  $.map((re, M) => {
1914
1902
  var me, ke;
1915
- const H = re.match !== void 0 && De(re.match, b) === null, ie = H || (ke = (me = A[M]) == null ? void 0 : me.data) == null ? void 0 : ke.get(D);
1903
+ const H = re.match !== void 0 && Ue(re.match, p) === null, ie = H || (ke = (me = A[M]) == null ? void 0 : me.data) == null ? void 0 : ke.get(U);
1916
1904
  return /* @__PURE__ */ n(
1917
1905
  "td",
1918
1906
  {
@@ -1924,10 +1912,10 @@ function Zr({
1924
1912
  })
1925
1913
  ]
1926
1914
  },
1927
- D
1915
+ U
1928
1916
  );
1929
- }, Te = (U == null ? void 0 : U.closest('[role="dialog"]')) ?? document.body, he = V.trim() ? de.filter((a) => Qr(`${_e(a)} ${Oe(a)} ${X(a)}`, V)) : de;
1930
- return Rr(
1917
+ }, Te = (D == null ? void 0 : D.closest('[role="dialog"]')) ?? document.body, he = V.trim() ? de.filter((a) => Cr(`${_e(a)} ${Oe(a)} ${X(a)}`, V)) : de;
1918
+ return Fr(
1931
1919
  /* @__PURE__ */ m("div", { className: "fixed inset-0 z-[125]", role: "presentation", children: [
1932
1920
  /* @__PURE__ */ n(
1933
1921
  "div",
@@ -1967,7 +1955,7 @@ function Zr({
1967
1955
  /* @__PURE__ */ n(
1968
1956
  "input",
1969
1957
  {
1970
- ref: pe,
1958
+ ref: be,
1971
1959
  value: V,
1972
1960
  onChange: (a) => oe(a.target.value),
1973
1961
  placeholder: "Search by number or description…",
@@ -2094,5 +2082,5 @@ function Zr({
2094
2082
  }
2095
2083
  export {
2096
2084
  yn as CatalogPickerField,
2097
- rr as matchesShowWhen
2085
+ Xt as matchesShowWhen
2098
2086
  };