@nivaro/react 0.3.13 → 0.3.14

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 (48) hide show
  1. package/dist/components/slots/pipeline/OwnersSection.js +79 -75
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useSessionRecorder.js +1 -1
  4. package/dist/index.d.ts +33 -2
  5. package/dist/index.js +520 -516
  6. package/dist/shared/components/CollectionBrowserView.js +2373 -2298
  7. package/dist/shared/components/DataTable.js +347 -335
  8. package/dist/shared/components/ItemEditForm.js +5278 -5149
  9. package/dist/shared/components/ListLoadError.js +33 -0
  10. package/dist/shared/components/PageRenderer.js +562 -529
  11. package/dist/shared/components/ProfileView.js +53 -51
  12. package/dist/shared/components/RecordReadView.js +119 -117
  13. package/dist/shared/components/ReportView.js +1268 -1241
  14. package/dist/shared/components/cbv/export-rows.js +69 -0
  15. package/dist/shared/components/cbv/saved-view-risk.js +35 -0
  16. package/dist/shared/components/cbv/unknown-fields.js +18 -0
  17. package/dist/shared/components/integrations/console/AlertsView.js +27 -25
  18. package/dist/shared/components/integrations/console/EventsView.js +244 -209
  19. package/dist/shared/components/item-edit/CatalogPickerField.js +946 -878
  20. package/dist/shared/components/item-edit/DraftRecoveryBanner.js +84 -57
  21. package/dist/shared/components/item-edit/FieldAffordances.js +63 -61
  22. package/dist/shared/components/item-edit/FieldRow.js +195 -179
  23. package/dist/shared/components/item-edit/FilePickerField.js +257 -254
  24. package/dist/shared/components/item-edit/HeaderTools.js +139 -95
  25. package/dist/shared/components/item-edit/InlineTableField.js +2087 -2075
  26. package/dist/shared/components/item-edit/RowComments.js +1 -3
  27. package/dist/shared/components/item-edit/SummaryPanel.js +62 -62
  28. package/dist/shared/components/item-edit/UserChip.js +113 -113
  29. package/dist/shared/components/item-edit/file-download.js +18 -0
  30. package/dist/shared/components/item-edit/line-qty.js +67 -32
  31. package/dist/shared/components/item-edit/save-refusal.js +23 -0
  32. package/dist/shared/components/monitoring/TrafficMiniMap.js +9 -9
  33. package/dist/shared/components/panels/CommentPanel.js +30 -30
  34. package/dist/shared/components/panels/ItemLockBanner.js +207 -185
  35. package/dist/shared/components/panels/PipelinePanel.js +915 -786
  36. package/dist/shared/components/pipeline/PipelineEditorView.js +45 -25
  37. package/dist/shared/components/profile/DelegationCard.js +1 -1
  38. package/dist/shared/components/profile/session-actions.js +24 -24
  39. package/dist/shared/components/queue/QueueItemSheet.js +18 -18
  40. package/dist/shared/components/queue/QueueWorklist.js +517 -504
  41. package/dist/shared/components/ui/dropdown-menu.js +8 -7
  42. package/dist/shared/lib/draft-store.js +60 -33
  43. package/dist/shared/lib/leave-guard.js +38 -0
  44. package/dist/shared/lib/load-error.js +38 -17
  45. package/dist/shared/lib/summary-mode.js +25 -25
  46. package/dist/shared/lib/table-pins.js +23 -0
  47. package/dist/shared/lib/validation-rules.js +55 -51
  48. package/package.json +1 -1
@@ -1,83 +1,83 @@
1
- import { jsxs as c, jsx as n, Fragment as _t } from "react/jsx-runtime";
2
- import { useQueryClient as Nr, useQuery as J, useQueries as St } from "@tanstack/react-query";
3
- import { Search as st, Loader2 as oe, ChevronRight as qt, Star as Qe, AlertTriangle as Je, AlertCircle as Mt, X as at, ChevronDown as vr } from "lucide-react";
4
- import { useState as Y, useRef as ze, useMemo as O, useEffect as je, Fragment as Ce } from "react";
5
- import { createPortal as _r } from "react-dom";
6
- import { useNivaroClient as $t, useParentDraft as Sr, useReimportHandler as qr } from "../../context.js";
7
- import { canOpenCatalogItem as Zt, openCatalogItem as Gt } from "../../lib/catalog-item-open.js";
8
- import { get as P, patch as Wt, del as $r, post as It } from "../../lib/commands.js";
9
- import { evaluateBoolean as jr } from "../../lib/expression.js";
10
- import { useLiveRefetchInterval as Fr } from "../../lib/live-queries.js";
11
- import { submissionLineErrors as Tr, normalizeIdent as Or } from "../../lib/submission-errors.js";
12
- import { titleCase as re, cn as z, matchesAllTokens as Pr } from "../../lib/utils.js";
13
- import { ImportFromFileButton as Rr } from "../import/ImportFromFileButton.js";
14
- import { Popover as Lr, PopoverAnchor as Er, PopoverContent as Ar } from "../ui/popover.js";
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";
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";
15
15
  import { applyDisplayTemplate as Fe } from "./helpers.js";
16
- import { evalClientFormula as Ke } from "./InlineTableField.js";
17
- import { isIntegerFieldType as Cr, checkNumberEntry as Kr, mergePendingQtyRow as Jr } from "./line-qty.js";
18
- import { resolveM2MRelatedCollection as Qr } from "./M2MCombobox.js";
19
- import { useO2MStaging as zr } from "./O2MStagingContext.js";
20
- import { RelationCombobox as Br } from "./RelationCombobox.js";
21
- const Xt = (u, g) => {
22
- let _ = u;
23
- for (const q of g.split(".")) {
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";
19
+ import { useO2MStaging as Hr } from "./O2MStagingContext.js";
20
+ import { RelationCombobox as Mr } from "./RelationCombobox.js";
21
+ const ar = (f, y) => {
22
+ let _ = f;
23
+ for (const q of y.split(".")) {
24
24
  if (_ == null || typeof _ != "object") return;
25
25
  _ = _[q];
26
26
  }
27
27
  return _;
28
28
  };
29
- async function it(u, g, _) {
29
+ async function ot(f, y, _) {
30
30
  const q = [];
31
31
  for (let l = 1; l <= 50; l++) {
32
- const x = await u.request(P(g, { ..._, limit: 1e3, page: l })).then((h) => h.data ?? []);
33
- if (q.push(...x), x.length < 1e3) break;
32
+ const g = await f.request(R(y, { ..._, limit: 1e3, page: l })).then((h) => h.data ?? []);
33
+ if (q.push(...g), g.length < 1e3) break;
34
34
  }
35
35
  return q;
36
36
  }
37
- function Be(u, g) {
37
+ function De(f, y) {
38
38
  const _ = {};
39
39
  let q = !1;
40
- const l = (x) => {
41
- if (typeof x == "string" && x.startsWith("$parent.")) {
42
- const h = g == null ? void 0 : g[x.slice(8)];
43
- return h == null || h === "" ? (q = !0, x) : h;
40
+ const l = (g) => {
41
+ if (typeof g == "string" && g.startsWith("$parent.")) {
42
+ const h = y == null ? void 0 : y[g.slice(8)];
43
+ return h == null || h === "" ? (q = !0, g) : h;
44
44
  }
45
- return Array.isArray(x) ? x.map(l) : x && typeof x == "object" ? Object.fromEntries(Object.entries(x).map(([h, $]) => [h, l($)])) : x;
45
+ return Array.isArray(g) ? g.map(l) : g && typeof g == "object" ? Object.fromEntries(Object.entries(g).map(([h, $]) => [h, l($)])) : g;
46
46
  };
47
- for (const [x, h] of Object.entries(u ?? {}))
47
+ for (const [g, h] of Object.entries(f ?? {}))
48
48
  if (typeof h == "string" && h.startsWith("$parent.")) {
49
- const $ = g == null ? void 0 : g[h.slice(8)];
49
+ const $ = y == null ? void 0 : y[h.slice(8)];
50
50
  if ($ == null || $ === "") {
51
51
  q = !0;
52
52
  continue;
53
53
  }
54
- _[x] = { _eq: $ };
55
- } else h && typeof h == "object" ? _[x] = l(h) : _[x] = { _eq: h };
54
+ _[g] = { _eq: $ };
55
+ } else h && typeof h == "object" ? _[g] = l(h) : _[g] = { _eq: h };
56
56
  return q ? null : _;
57
57
  }
58
- function Yt(u, g) {
59
- if (!u) return !0;
60
- for (const [_, q] of Object.entries(u)) {
61
- const l = g == null ? void 0 : g[_], x = l == null ? null : String(l), h = q && typeof q == "object" ? q : { _eq: q };
62
- for (const [$, p] of Object.entries(h))
58
+ function rr(f, y) {
59
+ if (!f) return !0;
60
+ for (const [_, q] of Object.entries(f)) {
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))
63
63
  switch ($) {
64
64
  case "_eq":
65
- if (x !== String(p)) return !1;
65
+ if (g !== String(b)) return !1;
66
66
  break;
67
67
  case "_neq":
68
- if (x === String(p)) return !1;
68
+ if (g === String(b)) return !1;
69
69
  break;
70
70
  case "_in":
71
- if (!Array.isArray(p) || !p.map(String).includes(x ?? "")) return !1;
71
+ if (!Array.isArray(b) || !b.map(String).includes(g ?? "")) return !1;
72
72
  break;
73
73
  case "_nin":
74
- if (Array.isArray(p) && p.map(String).includes(x ?? "")) return !1;
74
+ if (Array.isArray(b) && b.map(String).includes(g ?? "")) return !1;
75
75
  break;
76
76
  case "_null":
77
- if (x !== null) return !1;
77
+ if (g !== null) return !1;
78
78
  break;
79
79
  case "_nnull":
80
- if (x === null) return !1;
80
+ if (g === null) return !1;
81
81
  break;
82
82
  default:
83
83
  return !1;
@@ -85,443 +85,455 @@ function Yt(u, g) {
85
85
  }
86
86
  return !0;
87
87
  }
88
- const Vr = 2e3;
89
- function bn({
90
- relatedCollection: u,
91
- manyField: g,
88
+ const Wr = 2e3;
89
+ function yn({
90
+ relatedCollection: f,
91
+ manyField: y,
92
92
  parentId: _,
93
93
  parentCollection: q,
94
94
  config: l,
95
- readOnly: x = !1
95
+ readOnly: g = !1
96
96
  }) {
97
- var Vt, Dt, Ut;
98
- const h = $t(), $ = Nr(), p = zr(), L = Sr(), Z = qr(), B = l.editable_fields ?? [], A = _ === "new", V = l.qty_field ?? "quantity", [ce, ne] = Y(/* @__PURE__ */ new Set()), ye = ze(!1), [C, ke] = Y(""), [pe, G] = Y({}), [se, v] = Y(/* @__PURE__ */ new Set()), [F, j] = Y({}), { data: D = [], isPending: K } = J({
99
- queryKey: ["collection-relations", u],
100
- queryFn: () => h.request(P(`/collections/${u}`)).then((e) => {
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({
99
+ queryKey: ["collection-relations", f],
100
+ queryFn: () => h.request(R(`/collections/${f}`)).then((e) => {
101
101
  var t;
102
102
  return ((t = e.data) == null ? void 0 : t.relations) ?? [];
103
103
  }),
104
104
  staleTime: 10 * 6e4
105
- }), b = O(
105
+ }), x = O(
106
106
  () => {
107
107
  var e;
108
- return ((e = D.find(
109
- (t) => t.many_collection === u && t.many_field === l.item_field && !t.junction_field
108
+ return ((e = K.find(
109
+ (t) => t.many_collection === f && t.many_field === l.item_field && !t.junction_field
110
110
  )) == null ? void 0 : e.one_collection) ?? null;
111
111
  },
112
- [D, u, l.item_field]
113
- ), { data: me = [] } = J({
114
- queryKey: ["field-config", u, null],
115
- queryFn: () => h.request(P(`/field-config/${u}`)).then((e) => e.data ?? []),
112
+ [K, f, l.item_field]
113
+ ), { data: be = [] } = z({
114
+ queryKey: ["field-config", f, null],
115
+ queryFn: () => h.request(R(`/field-config/${f}`)).then((e) => e.data ?? []),
116
116
  staleTime: 6e4
117
- }), X = ((Vt = me.find((e) => e.field === V)) == null ? void 0 : Vt.type) ?? null, { data: U } = J({
118
- queryKey: ["col-meta", b],
117
+ }), _e = ((Ht = be.find((e) => e.field === V)) == null ? void 0 : Ht.type) ?? null, Oe = (e, t, r) => {
118
+ var s;
119
+ return ((s = Dr(
120
+ be.filter((c) => c.field === e).map((c) => ({
121
+ field: c.field,
122
+ label: c.label || I(c.field),
123
+ type: c.type,
124
+ validation_rules: c.validation_rules
125
+ })),
126
+ { [e]: t },
127
+ { ...r, [e]: t }
128
+ )[0]) == null ? void 0 : s.message) ?? null;
129
+ }, { data: X } = z({
130
+ queryKey: ["col-meta", x],
119
131
  queryFn: () => h.request(
120
- P(`/collections/${b}`)
132
+ R(`/collections/${x}`)
121
133
  ).then((e) => e.data),
122
- enabled: !!b,
134
+ enabled: !!x,
123
135
  staleTime: 3e5
124
- }), H = U == null ? void 0 : U.display_template, R = O(() => {
136
+ }), ee = X == null ? void 0 : X.display_template, A = O(() => {
125
137
  const e = l.section_by.split(".")[0];
126
- return ((U == null ? void 0 : U.relations) ?? []).find(
127
- (t) => t.one_collection === b && t.one_field === e && !!t.junction_field
138
+ return ((X == null ? void 0 : X.relations) ?? []).find(
139
+ (t) => t.one_collection === x && t.one_field === e && !!t.junction_field
128
140
  ) ?? null;
129
- }, [U, b, l.section_by]), ue = (R == null ? void 0 : R.many_collection) ?? null, { data: Ve = [] } = J({
130
- queryKey: ["collection-relations", ue],
131
- queryFn: () => h.request(P(`/collections/${ue}`)).then((e) => {
141
+ }, [X, x, l.section_by]), ce = (A == null ? void 0 : A.many_collection) ?? null, { data: Ue = [] } = z({
142
+ queryKey: ["collection-relations", ce],
143
+ queryFn: () => h.request(R(`/collections/${ce}`)).then((e) => {
132
144
  var t;
133
145
  return ((t = e.data) == null ? void 0 : t.relations) ?? [];
134
146
  }),
135
- enabled: !!ue,
147
+ enabled: !!ce,
136
148
  staleTime: 10 * 6e4
137
149
  }), Q = O(() => {
138
- if (!(R != null && R.many_field) || !ue) return null;
139
- const e = String(R.junction_field), t = Ve.find(
140
- (s) => s.many_collection === ue && s.many_field === e
141
- ), r = Qr(t);
150
+ if (!(A != null && A.many_field) || !ce) return null;
151
+ const e = String(A.junction_field), t = Ue.find(
152
+ (s) => s.many_collection === ce && s.many_field === e
153
+ ), r = Ur(t);
142
154
  return r ? {
143
- junction: ue,
144
- fkToItem: R.many_field,
155
+ junction: ce,
156
+ fkToItem: A.many_field,
145
157
  fkToSection: e,
146
158
  target: r,
147
159
  labelPath: l.section_by.split(".").slice(1).join(".") || "id"
148
160
  } : null;
149
- }, [R, ue, Ve, l.section_by]), ee = L == null ? void 0 : L.draft, { resolvedFilter: Te, resolvedSectionFilter: he, resolvedLinkFilter: ae, missingParents: xe } = O(() => {
161
+ }, [A, ce, Ue, l.section_by]), te = P == null ? void 0 : P.draft, { resolvedFilter: Te, resolvedSectionFilter: he, resolvedLinkFilter: a, missingParents: k } = O(() => {
150
162
  const e = [], t = (o) => {
151
163
  if (typeof o == "string" && o.startsWith("$parent.")) {
152
- const i = o.slice(8), y = ee == null ? void 0 : ee[i];
153
- return y == null || y === "" ? (e.push(i), o) : y;
164
+ const i = o.slice(8), p = te == null ? void 0 : te[i];
165
+ return p == null || p === "" ? (e.push(i), o) : p;
154
166
  }
155
- return Array.isArray(o) ? o.map(t) : o && typeof o == "object" ? Object.fromEntries(Object.entries(o).map(([i, y]) => [i, t(y)])) : o;
156
- }, r = l.filter ? t(l.filter) : void 0, s = l.section_filter ? t(l.section_filter) : void 0, m = l.link_filter ? t(l.link_filter) : void 0;
167
+ return Array.isArray(o) ? o.map(t) : o && typeof o == "object" ? Object.fromEntries(Object.entries(o).map(([i, p]) => [i, t(p)])) : o;
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;
157
169
  return {
158
170
  resolvedFilter: r,
159
171
  resolvedSectionFilter: s,
160
- resolvedLinkFilter: m,
172
+ resolvedLinkFilter: c,
161
173
  missingParents: [...new Set(e)]
162
174
  };
163
- }, [l.filter, l.section_filter, l.link_filter, ee]), Oe = O(() => {
164
- if (!R || !he && !ae) return Te;
175
+ }, [l.filter, l.section_filter, l.link_filter, te]), D = O(() => {
176
+ if (!A || !he && !a) return Te;
165
177
  const e = {
166
178
  ...he ?? {},
167
- ...ae ? { _link: ae } : {}
168
- }, t = { [R.one_field]: { _some: e } };
179
+ ...a ? { _link: a } : {}
180
+ }, t = { [A.one_field]: { _some: e } };
169
181
  return Te ? { _and: [Te, t] } : t;
170
- }, [R, he, ae, Te]), a = O(() => {
182
+ }, [A, he, a, Te]), J = O(() => {
171
183
  const e = /* @__PURE__ */ new Set(["id"]);
172
- U && !R && e.add(l.section_by);
173
- for (const t of [...(H ?? "").matchAll(/\{\{([\w.]+)\}\}/g)]) e.add(t[1]);
184
+ X && !A && e.add(l.section_by);
185
+ for (const t of [...(ee ?? "").matchAll(/\{\{([\w.]+)\}\}/g)]) e.add(t[1]);
174
186
  for (const t of Object.values(l.copy_fields ?? {})) e.add(t);
175
187
  for (const t of l.columns ?? []) e.add(t.field);
176
188
  return [...e].join(",");
177
- }, [H, U, R, l.section_by, l.copy_fields, l.columns]), w = JSON.stringify(Oe ?? null), { data: E = [], isLoading: ie } = J(
189
+ }, [ee, X, A, l.section_by, l.copy_fields, l.columns]), re = JSON.stringify(D ?? null), { data: M = [], isLoading: H } = z(
178
190
  {
179
- queryKey: ["catalog-picker", b, a, w],
191
+ queryKey: ["catalog-picker", x, J, re],
180
192
  queryFn: () => h.request(
181
- P(`/items/${b}`, {
182
- limit: Vr,
183
- fields: a,
184
- ...Oe ? { filter: JSON.stringify(Oe) } : {}
193
+ R(`/items/${x}`, {
194
+ limit: Wr,
195
+ fields: J,
196
+ ...D ? { filter: JSON.stringify(D) } : {}
185
197
  })
186
198
  ).then((e) => e.data ?? []),
187
199
  // Wait for the catalog meta: a to-many section path both narrows this
188
200
  // read and must stay out of its `fields=`.
189
- enabled: !!b && !!U && xe.length === 0 && (!R || !!Q),
201
+ enabled: !!x && !!X && k.length === 0 && (!A || !!Q),
190
202
  staleTime: 6e4
191
203
  }
192
- ), te = JSON.stringify(he ?? null), { data: I = [], isLoading: M } = J({
193
- queryKey: ["catalog-sections", Q == null ? void 0 : Q.target, Q == null ? void 0 : Q.labelPath, te],
204
+ ), ie = JSON.stringify(he ?? null), { data: me = [], isLoading: ke } = z({
205
+ queryKey: ["catalog-sections", Q == null ? void 0 : Q.target, Q == null ? void 0 : Q.labelPath, ie],
194
206
  queryFn: async () => {
195
207
  const e = Q;
196
- return (await it(h, `/items/${e.target}`, {
208
+ return (await ot(h, `/items/${e.target}`, {
197
209
  fields: `id,${e.labelPath}`,
198
210
  ...he ? { filter: JSON.stringify(he) } : {}
199
211
  })).map((r) => ({
200
212
  id: String(r.id),
201
- name: String(Xt(r, e.labelPath) ?? "").trim()
213
+ name: String(ar(r, e.labelPath) ?? "").trim()
202
214
  }));
203
215
  },
204
- enabled: !!Q && xe.length === 0,
216
+ enabled: !!Q && k.length === 0,
205
217
  staleTime: 6e4
206
- }), W = O(() => I.map((e) => e.id), [I]), { data: we = [], isLoading: Ne } = J({
218
+ }), Re = O(() => me.map((e) => e.id), [me]), { data: Tt = [], isLoading: ir } = z({
207
219
  queryKey: [
208
220
  "catalog-section-links",
209
221
  Q == null ? void 0 : Q.junction,
210
- W.join(","),
211
- JSON.stringify(ae ?? null)
222
+ Re.join(","),
223
+ JSON.stringify(a ?? null)
212
224
  ],
213
225
  queryFn: async () => {
214
226
  const e = Q, t = [];
215
- for (let r = 0; r < W.length; r += 200) {
216
- const s = W.slice(r, r + 200), m = await it(h, `/items/${e.junction}`, {
227
+ for (let r = 0; r < Re.length; r += 200) {
228
+ const s = Re.slice(r, r + 200), c = await ot(h, `/items/${e.junction}`, {
217
229
  fields: `${e.fkToItem},${e.fkToSection}`,
218
230
  filter: JSON.stringify(
219
- ae ? { _and: [{ [e.fkToSection]: { _in: s } }, ae] } : { [e.fkToSection]: { _in: s } }
231
+ a ? { _and: [{ [e.fkToSection]: { _in: s } }, a] } : { [e.fkToSection]: { _in: s } }
220
232
  )
221
233
  });
222
- for (const o of m)
234
+ for (const o of c)
223
235
  o[e.fkToItem] == null || o[e.fkToSection] == null || t.push({ item: String(o[e.fkToItem]), section: String(o[e.fkToSection]) });
224
236
  }
225
237
  return t;
226
238
  },
227
- enabled: !!Q && W.length > 0,
239
+ enabled: !!Q && Re.length > 0,
228
240
  staleTime: 6e4
229
- }), jt = O(() => {
230
- const e = new Map(I.map((r) => [r.id, r.name])), t = /* @__PURE__ */ new Map();
231
- for (const r of we) {
241
+ }), Ot = O(() => {
242
+ const e = new Map(me.map((r) => [r.id, r.name])), t = /* @__PURE__ */ new Map();
243
+ for (const r of Tt) {
232
244
  const s = e.get(r.section);
233
245
  if (!s) continue;
234
- const m = t.get(r.item) ?? [];
235
- m.includes(s) || m.push(s), t.set(r.item, m);
246
+ const c = t.get(r.item) ?? [];
247
+ c.includes(s) || c.push(s), t.set(r.item, c);
236
248
  }
237
249
  return t;
238
- }, [I, we]), De = !!R && (!Q || M || W.length > 0 && Ne), Ue = O(() => {
250
+ }, [me, Tt]), He = !!A && (!Q || ke || Re.length > 0 && ir), Me = O(() => {
239
251
  const e = /* @__PURE__ */ new Map();
240
- for (const t of E) e.set(String(t.id), t);
252
+ for (const t of M) e.set(String(t.id), t);
241
253
  return e;
242
- }, [E]), { data: ve = [] } = J({
243
- queryKey: ["o2m-rows", u, g, _],
254
+ }, [M]), { data: we = [] } = z({
255
+ queryKey: ["o2m-rows", f, y, _],
244
256
  queryFn: () => h.request(
245
- P(`/items/${u}`, {
246
- filter: JSON.stringify({ [g]: { _eq: _ } }),
257
+ R(`/items/${f}`, {
258
+ filter: JSON.stringify({ [y]: { _eq: _ } }),
247
259
  limit: 1e3
248
260
  })
249
261
  ).then((e) => e.data ?? []),
250
- enabled: !A,
262
+ enabled: !E,
251
263
  staleTime: 15e3
252
- }), Pe = !A && !!p, Se = p ? p.getPendingRows(u, g) : [], He = Pe ? p.getPendingEdits(u, g) : /* @__PURE__ */ new Map(), er = JSON.stringify([...He.entries()]), Me = O(
253
- () => He.size === 0 ? ve : ve.map((e) => {
254
- const t = He.get(String(e.id));
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(
265
+ () => We.size === 0 ? we : we.map((e) => {
266
+ const t = We.get(String(e.id));
255
267
  return t ? { ...e, ...t } : e;
256
268
  }),
257
- [ve, er]
258
- ), We = !A && p ? p.getPendingDeletes(u, g) : /* @__PURE__ */ new Set(), Ie = O(() => {
269
+ [we, lr]
270
+ ), Ye = !E && b ? b.getPendingDeletes(f, y) : /* @__PURE__ */ new Set(), Ee = O(() => {
259
271
  const e = /* @__PURE__ */ new Map();
260
- for (const t of Me) {
272
+ for (const t of Ie) {
261
273
  const r = t[l.item_field];
262
274
  r != null && e.set(String(r), t);
263
275
  }
264
276
  return e;
265
- }, [Me, l.item_field]), lt = O(() => {
277
+ }, [Ie, l.item_field]), Ze = O(() => {
266
278
  const e = /* @__PURE__ */ new Map();
267
- return Se.forEach((t, r) => {
279
+ return Ne.forEach((t, r) => {
268
280
  const s = t[l.item_field];
269
281
  s != null && e.set(String(s), r);
270
282
  }), e;
271
- }, [Se, l.item_field]), de = O(() => {
272
- const e = Se.filter((s) => s[l.item_field] != null).map((s) => ({ key: String(s[l.item_field]), row: s }));
273
- if (A) return e;
274
- const t = Me.filter((s) => s[l.item_field] != null).map((s) => ({ key: String(s[l.item_field]), row: s })), r = new Set(t.map((s) => s.key));
283
+ }, [Ne, l.item_field]), le = O(() => {
284
+ const e = Ne.filter((s) => s[l.item_field] != null).map((s) => ({ key: String(s[l.item_field]), row: s }));
285
+ if (E) return e;
286
+ const t = Ie.filter((s) => s[l.item_field] != null).map((s) => ({ key: String(s[l.item_field]), row: s })), r = new Set(t.map((s) => s.key));
275
287
  return [...t, ...e.filter((s) => !r.has(s.key))];
276
- }, [A, Se, Me, l.item_field]), Ye = O(
277
- () => de.filter((e) => !Ue.has(e.key)).map((e) => e.key),
278
- [de, Ue]
279
- ), { data: Ft = [] } = J({
280
- queryKey: ["catalog-picker-labels", b, a, Ye.join(",")],
288
+ }, [E, Ne, Ie, l.item_field]), Ge = O(
289
+ () => le.filter((e) => !Me.has(e.key)).map((e) => e.key),
290
+ [le, Me]
291
+ ), { data: Rt = [] } = z({
292
+ queryKey: ["catalog-picker-labels", x, J, Ge.join(",")],
281
293
  queryFn: () => h.request(
282
- P(`/items/${b}`, {
283
- filter: JSON.stringify({ id: { _in: Ye } }),
284
- fields: a,
285
- limit: Ye.length
294
+ R(`/items/${x}`, {
295
+ filter: JSON.stringify({ id: { _in: Ge } }),
296
+ fields: J,
297
+ limit: Ge.length
286
298
  })
287
299
  ).then((e) => e.data ?? []),
288
- enabled: !!b && Ye.length > 0,
300
+ enabled: !!x && Ge.length > 0,
289
301
  staleTime: 6e4
290
- }), { data: ge = [] } = J({
291
- queryKey: ["pinned-items", b],
292
- queryFn: () => h.request(P(`/pinned/${b}`)).then((e) => e.data ?? []),
293
- enabled: !!b && !!l.favorites,
302
+ }), { data: xe = [] } = z({
303
+ queryKey: ["pinned-items", x],
304
+ queryFn: () => h.request(R(`/pinned/${x}`)).then((e) => e.data ?? []),
305
+ enabled: !!x && !!l.favorites,
294
306
  staleTime: 6e4
295
- }), ot = O(() => new Set(ge), [ge]), { data: Re = [] } = J({
296
- queryKey: ["pinned-item-rows", b, a, ge.join(",")],
307
+ }), dt = O(() => new Set(xe), [xe]), { data: Le = [] } = z({
308
+ queryKey: ["pinned-item-rows", x, J, xe.join(",")],
297
309
  queryFn: () => h.request(
298
- P(`/items/${b}`, {
299
- filter: JSON.stringify({ id: { _in: ge } }),
300
- fields: a,
301
- limit: ge.length
310
+ R(`/items/${x}`, {
311
+ filter: JSON.stringify({ id: { _in: xe } }),
312
+ fields: J,
313
+ limit: xe.length
302
314
  })
303
315
  ).then((e) => e.data ?? []),
304
- enabled: !!b && !!l.favorites && ge.length > 0,
316
+ enabled: !!x && !!l.favorites && xe.length > 0,
305
317
  staleTime: 6e4
306
- }), [Ze, Tt] = Y(/* @__PURE__ */ new Set());
307
- async function Ot(e) {
308
- if (!(!b || Ze.has(e))) {
309
- Tt((t) => new Set(t).add(e));
318
+ }), [Xe, Pt] = Y(/* @__PURE__ */ new Set());
319
+ async function Et(e) {
320
+ if (!(!x || Xe.has(e))) {
321
+ Pt((t) => new Set(t).add(e));
310
322
  try {
311
- await h.request(It(`/pinned/${b}/${e}/toggle`)).catch(() => {
312
- }), await $.invalidateQueries({ queryKey: ["pinned-items", b] });
323
+ await h.request(Zt(`/pinned/${x}/${e}/toggle`)).catch(() => {
324
+ }), await $.invalidateQueries({ queryKey: ["pinned-items", x] });
313
325
  } finally {
314
- Tt((t) => {
326
+ Pt((t) => {
315
327
  const r = new Set(t);
316
328
  return r.delete(e), r;
317
329
  });
318
330
  }
319
331
  }
320
332
  }
321
- const [tr, Pt] = Y(!1), Rt = ze(null), dt = (e) => l.favorites ? /* @__PURE__ */ n(
333
+ const [or, Lt] = Y(!1), At = Ve(null), ct = (e) => l.favorites ? /* @__PURE__ */ n(
322
334
  "button",
323
335
  {
324
336
  type: "button",
325
- title: ot.has(e) ? "Remove from favorites" : "Add to favorites",
326
- disabled: Ze.has(e),
337
+ title: dt.has(e) ? "Remove from favorites" : "Add to favorites",
338
+ disabled: Xe.has(e),
327
339
  onClick: (t) => {
328
- t.stopPropagation(), Ot(e);
340
+ t.stopPropagation(), Et(e);
329
341
  },
330
342
  className: "shrink-0 rounded p-0.5 transition-colors",
331
- children: Ze.has(e) ? /* @__PURE__ */ n(oe, { className: "h-3.5 w-3.5 animate-spin text-amber-400" }) : /* @__PURE__ */ n(
332
- Qe,
343
+ children: Xe.has(e) ? /* @__PURE__ */ n(ae, { className: "h-3.5 w-3.5 animate-spin text-amber-400" }) : /* @__PURE__ */ n(
344
+ Be,
333
345
  {
334
- className: z(
346
+ className: B(
335
347
  "h-3.5 w-3.5",
336
- ot.has(e) ? "fill-amber-400 text-amber-400" : "text-slate-300 hover:text-amber-400"
348
+ dt.has(e) ? "fill-amber-400 text-amber-400" : "text-slate-300 hover:text-amber-400"
337
349
  )
338
350
  }
339
351
  )
340
352
  }
341
- ) : null, [ct, rr] = Y("");
353
+ ) : null, [mt, dr] = Y("");
342
354
  je(() => {
343
- const e = setTimeout(() => rr(C), 300);
355
+ const e = setTimeout(() => dr(C), 300);
344
356
  return () => clearTimeout(e);
345
357
  }, [C]);
346
- const nr = O(() => {
358
+ const cr = O(() => {
347
359
  var t;
348
- const e = (t = [...(H ?? "").matchAll(/\{\{([\w.]+)\}\}/g)][0]) == null ? void 0 : t[1];
360
+ const e = (t = [...(ee ?? "").matchAll(/\{\{([\w.]+)\}\}/g)][0]) == null ? void 0 : t[1];
349
361
  return e && !e.includes(".") ? e : "id";
350
- }, [H]), { data: sr = [], isFetching: mt } = J({
351
- queryKey: ["catalog-full-search", b, a, ct],
362
+ }, [ee]), { data: mr = [], isFetching: ut } = z({
363
+ queryKey: ["catalog-full-search", x, J, mt],
352
364
  queryFn: () => h.request(
353
- P(`/items/${b}`, {
354
- search: ct,
355
- fields: a,
365
+ R(`/items/${x}`, {
366
+ search: mt,
367
+ fields: J,
356
368
  limit: 25,
357
- sort: nr
369
+ sort: cr
358
370
  })
359
371
  ).then((e) => e.data ?? []),
360
- enabled: !!b && ct.trim().length > 0,
372
+ enabled: !!x && mt.trim().length > 0,
361
373
  staleTime: 3e4,
362
374
  placeholderData: (e) => e
363
- }), qe = sr, Ge = O(() => {
375
+ }), Se = mr, et = O(() => {
364
376
  const e = /* @__PURE__ */ new Set();
365
- for (const t of E) e.add(String(t.id));
366
- for (const t of de) e.add(t.key);
367
- for (const t of ge) e.add(t);
368
- for (const t of qe) e.add(String(t.id));
377
+ for (const t of M) e.add(String(t.id));
378
+ for (const t of le) e.add(t.key);
379
+ for (const t of xe) e.add(t);
380
+ for (const t of Se) e.add(String(t.id));
369
381
  return [...e];
370
- }, [E, de, ge, qe]), Lt = St({
382
+ }, [M, le, xe, Se]), Ct = $t({
371
383
  queries: (l.related_columns ?? []).map((e) => {
372
- const t = Be(e.match, ee);
384
+ const t = De(e.match, te);
373
385
  return {
374
386
  queryKey: [
375
387
  "catalog-related",
376
388
  e.key,
377
389
  e.collection,
378
390
  JSON.stringify(t),
379
- Ge.join(",")
391
+ et.join(",")
380
392
  ],
381
393
  queryFn: async () => {
382
- const r = {}, s = e.aggregate === "sum", m = s ? 150 : 400;
383
- for (let o = 0; o < Ge.length; o += m) {
384
- const i = Ge.slice(o, o + m);
385
- let y = 1;
394
+ const r = {}, s = e.aggregate === "sum", c = s ? 150 : 400;
395
+ for (let o = 0; o < et.length; o += c) {
396
+ const i = et.slice(o, o + c);
397
+ let p = 1;
386
398
  for (; ; ) {
387
399
  const d = await h.request(
388
- P(`/items/${e.collection}`, {
400
+ R(`/items/${e.collection}`, {
389
401
  limit: s ? 1e3 : i.length,
390
- ...s ? { page: y } : {},
402
+ ...s ? { page: p } : {},
391
403
  fields: `${e.item_field},${e.value_field}`,
392
404
  filter: JSON.stringify({ ...t, [e.item_field]: { _in: i } })
393
405
  })
394
- ).then((f) => f.data ?? []);
395
- for (const f of d) {
396
- const N = f[e.item_field];
397
- if (N != null)
406
+ ).then((u) => u.data ?? []);
407
+ for (const u of d) {
408
+ const w = u[e.item_field];
409
+ if (w != null)
398
410
  if (s) {
399
- const T = Number(f[e.value_field]);
400
- r[String(N)] = (Number(r[String(N)]) || 0) + (Number.isNaN(T) ? 0 : T);
411
+ const j = Number(u[e.value_field]);
412
+ r[String(w)] = (Number(r[String(w)]) || 0) + (Number.isNaN(j) ? 0 : j);
401
413
  } else
402
- r[String(N)] = f[e.value_field];
414
+ r[String(w)] = u[e.value_field];
403
415
  }
404
416
  if (!s || d.length < 1e3) break;
405
- y += 1;
417
+ p += 1;
406
418
  }
407
419
  }
408
420
  return r;
409
421
  },
410
- enabled: !!b && t !== null && Ge.length > 0,
422
+ enabled: !!x && t !== null && et.length > 0,
411
423
  staleTime: 3e4
412
424
  };
413
425
  })
414
- }), ut = (e, t) => {
415
- var s, m;
426
+ }), ft = (e, t) => {
427
+ var s, c;
416
428
  const r = (l.related_columns ?? []).findIndex((o) => o.key === e);
417
429
  if (r !== -1)
418
- return (m = (s = Lt[r]) == null ? void 0 : s.data) == null ? void 0 : m[t];
419
- }, ft = (e) => {
420
- var y;
430
+ return (c = (s = Ct[r]) == null ? void 0 : s.data) == null ? void 0 : c[t];
431
+ }, pt = (e) => {
432
+ var p;
421
433
  const t = l.qty_warning;
422
434
  if (!t) return null;
423
- const r = be(e) ?? 0;
435
+ const r = fe(e) ?? 0;
424
436
  if (r <= 0) return null;
425
437
  const s = (l.related_columns ?? []).findIndex((d) => d.key === t.column);
426
438
  if (s === -1) return null;
427
- const m = (y = Lt[s]) == null ? void 0 : y.data;
428
- if (m === void 0) return null;
429
- const o = m[e], i = o == null || o === "" ? 0 : Number(o);
439
+ const c = (p = Ct[s]) == null ? void 0 : p.data;
440
+ if (c === void 0) return null;
441
+ const o = c[e], i = o == null || o === "" ? 0 : Number(o);
430
442
  return Number.isNaN(i) ? null : r > i ? { available: i, qty: r } : null;
431
- }, ar = (e) => {
443
+ }, ur = (e) => {
432
444
  const t = l.row_flags ?? [];
433
445
  if (t.length === 0) return [];
434
446
  const r = [];
435
447
  for (const s of t)
436
448
  if (!(!(s != null && s.when) || !s.label))
437
449
  try {
438
- const m = s.when.replace(/\{\{\s*([A-Za-z_][A-Za-z0-9_.]*)\s*\}\}/g, "$1");
439
- jr(m, e) && r.push(s.label);
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);
440
452
  } catch {
441
453
  }
442
454
  return r;
443
- }, bt = l.qty_warning ? l.qty_warning.label ?? ((Dt = (l.related_columns ?? []).find((e) => {
455
+ }, bt = l.qty_warning ? l.qty_warning.label ?? ((Mt = (l.related_columns ?? []).find((e) => {
444
456
  var t;
445
457
  return e.key === ((t = l.qty_warning) == null ? void 0 : t.column);
446
- })) == null ? void 0 : Dt.label) ?? re(l.qty_warning.column) : "", ir = !!l.submission_errors, Xe = O(
458
+ })) == null ? void 0 : Mt.label) ?? I(l.qty_warning.column) : "", fr = !!l.submission_errors, tt = O(
447
459
  () => {
448
460
  var e;
449
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)) : [];
450
462
  },
451
463
  [l.submission_errors]
452
- ), lr = Fr(6e4), { data: Et } = J({
464
+ ), pr = Cr(6e4), { data: Kt } = z({
453
465
  queryKey: ["erp-submissions", q ?? "", String(_)],
454
- queryFn: () => h.request(P(`/erp-submissions/${q}/${encodeURIComponent(_)}`)).then((e) => e.data ?? []),
455
- enabled: ir && !A && !!q,
466
+ queryFn: () => h.request(R(`/erp-submissions/${q}/${encodeURIComponent(_)}`)).then((e) => e.data ?? []),
467
+ enabled: fr && !E && !!q,
456
468
  staleTime: 15e3,
457
- refetchInterval: lr
458
- }), pt = O(() => {
459
- const e = (Et ?? [])[0];
460
- return !e || e.status !== "failed" ? null : Tr(e.payload, e.last_error);
461
- }, [Et]), or = de.map((e) => e.key).join(","), { data: ht } = J({
462
- queryKey: ["catalog-suberr-idents", b, Xe.join(","), or],
469
+ refetchInterval: pr
470
+ }), ht = O(() => {
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],
463
475
  queryFn: async () => {
464
- const e = de.map((r) => r.key);
476
+ const e = le.map((r) => r.key);
465
477
  if (e.length === 0) return {};
466
478
  const t = await h.request(
467
- P(`/items/${b}`, {
479
+ R(`/items/${x}`, {
468
480
  limit: e.length,
469
- fields: ["id", ...Xe].join(","),
481
+ fields: ["id", ...tt].join(","),
470
482
  filter: JSON.stringify({ id: { _in: e } })
471
483
  })
472
484
  ).then((r) => r.data ?? []);
473
485
  return Object.fromEntries(t.map((r) => [String(r.id), r]));
474
486
  },
475
- enabled: !!b && !!pt && Xe.length > 0 && de.length > 0,
487
+ enabled: !!x && !!ht && tt.length > 0 && le.length > 0,
476
488
  staleTime: 6e4
477
- }), dr = (e) => {
478
- if (!pt) return null;
479
- const t = ht == null ? void 0 : ht[e], r = [
480
- Bt(e),
481
- ...Xe.map((s) => {
482
- const m = (t == null ? void 0 : t[s]) ?? $e(e)[s];
483
- return m != null && m !== "" ? String(m) : null;
489
+ }), hr = (e) => {
490
+ if (!ht) return null;
491
+ const t = xt == null ? void 0 : xt[e], r = [
492
+ Ut(e),
493
+ ...tt.map((s) => {
494
+ const c = (t == null ? void 0 : t[s]) ?? qe(e)[s];
495
+ return c != null && c !== "" ? String(c) : null;
484
496
  })
485
- ].filter((s) => !!s).map(Or);
486
- return pt.reasonFor(r);
487
- }, et = l.summary_fields ?? [], cr = ve.map((e) => String(e.id)).join(","), mr = St({
488
- queries: et.filter((e) => e.m2m).map((e) => ({
489
- queryKey: ["catalog-summary-m2m", e.field, e.m2m.junction, cr],
497
+ ].filter((s) => !!s).map(Jr);
498
+ return ht.reasonFor(r);
499
+ }, rt = l.summary_fields ?? [], xr = we.map((e) => String(e.id)).join(","), gr = $t({
500
+ queries: rt.filter((e) => e.m2m).map((e) => ({
501
+ queryKey: ["catalog-summary-m2m", e.field, e.m2m.junction, xr],
490
502
  queryFn: async () => {
491
- const t = ve.map((f) => String(f.id));
503
+ const t = we.map((u) => String(u.id));
492
504
  if (t.length === 0) return {};
493
505
  const r = e.m2m, s = await h.request(
494
- P(`/items/${r.junction}`, {
506
+ R(`/items/${r.junction}`, {
495
507
  limit: 1e3,
496
508
  fields: `${r.fk_to_child},${r.related_field}`,
497
509
  filter: JSON.stringify({ [r.fk_to_child]: { _in: t } })
498
510
  })
499
- ).then((f) => f.data ?? []).catch(() => []), m = [...new Set(s.map((f) => String(f[r.related_field])))], o = r.label_field ?? "name", i = m.length ? await h.request(
500
- P(`/items/${r.related_collection}`, {
511
+ ).then((u) => u.data ?? []).catch(() => []), c = [...new Set(s.map((u) => String(u[r.related_field])))], o = r.label_field ?? "name", i = c.length ? await h.request(
512
+ R(`/items/${r.related_collection}`, {
501
513
  limit: 500,
502
514
  fields: `id,${o}`,
503
- filter: JSON.stringify({ id: { _in: m } })
515
+ filter: JSON.stringify({ id: { _in: c } })
504
516
  })
505
- ).then((f) => f.data ?? []).catch(() => []) : [], y = new Map(i.map((f) => [String(f.id), String(f[o] ?? f.id)])), d = {};
506
- for (const f of s) {
507
- const N = String(f[r.fk_to_child]), T = y.get(String(f[r.related_field]));
508
- T && (d[N] = d[N] ? `${d[N]}, ${T}` : T);
517
+ ).then((u) => u.data ?? []).catch(() => []) : [], p = new Map(i.map((u) => [String(u.id), String(u[o] ?? u.id)])), d = {};
518
+ for (const u of s) {
519
+ const w = String(u[r.fk_to_child]), j = p.get(String(u[r.related_field]));
520
+ j && (d[w] = d[w] ? `${d[w]}, ${j}` : j);
509
521
  }
510
522
  return d;
511
523
  },
512
- enabled: !A && ve.length > 0,
524
+ enabled: !E && we.length > 0,
513
525
  staleTime: 15e3
514
526
  }))
515
- }), ur = (e, t) => {
516
- var m, o;
527
+ }), yr = (e, t) => {
528
+ var c, o;
517
529
  if (!e.m2m) return t.row[e.field];
518
- const r = et.filter((i) => i.m2m).findIndex((i) => i.field === e.field);
530
+ const r = rt.filter((i) => i.m2m).findIndex((i) => i.field === e.field);
519
531
  if (r === -1) return;
520
532
  const s = t.row.id;
521
533
  if (s != null)
522
- return (o = (m = mr[r]) == null ? void 0 : m.data) == null ? void 0 : o[String(s)];
523
- }, fr = !!((Ut = l.fulfilment) != null && Ut.shipped_field) && (l.fulfilment.show_when ? Yt(l.fulfilment.show_when, ee) : !0), br = (e) => {
524
- if (!fr || !l.fulfilment) return 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;
525
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 ? {
526
538
  dot: "bg-emerald-500",
527
539
  text: "text-emerald-700 dark:text-emerald-400",
@@ -535,7 +547,7 @@ function bn({
535
547
  text: "text-slate-500 dark:text-slate-400",
536
548
  label: "Requested"
537
549
  };
538
- return /* @__PURE__ */ c(
550
+ return /* @__PURE__ */ m(
539
551
  "span",
540
552
  {
541
553
  className: "inline-flex items-center gap-1.5 whitespace-nowrap",
@@ -547,7 +559,7 @@ function bn({
547
559
  ]
548
560
  }
549
561
  );
550
- }, At = l.columns ?? [], Ct = l.related_columns ?? [], xt = At.filter((e) => !e.summary_only), gt = Ct.filter((e) => !e.summary_only), Kt = At.filter((e) => !e.sections_only), Jt = Ct.filter((e) => !e.sections_only), Qt = xt.length > 0 || gt.length > 0, yt = ze(null), zt = (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), Dt = (e) => {
551
563
  let t = e.parentElement;
552
564
  for (; t; ) {
553
565
  const r = getComputedStyle(t);
@@ -557,90 +569,90 @@ function bn({
557
569
  }
558
570
  t = t.parentElement;
559
571
  }
560
- }, pr = (e) => {
561
- yt.current = e, e && zt(e);
572
+ }, Nr = (e) => {
573
+ kt.current = e, e && Dt(e);
562
574
  };
563
575
  je(() => {
564
576
  let e = 0;
565
577
  const t = () => {
566
578
  e || (e = requestAnimationFrame(() => {
567
- e = 0, yt.current && zt(yt.current);
579
+ e = 0, kt.current && Dt(kt.current);
568
580
  }));
569
581
  };
570
582
  return window.addEventListener("scroll", t, !0), () => {
571
583
  e && cancelAnimationFrame(e), window.removeEventListener("scroll", t, !0);
572
584
  };
573
585
  }, []);
574
- const Le = (e, t) => {
586
+ const Ae = (e, t) => {
575
587
  let r = e;
576
588
  for (const s of t.split(".")) {
577
589
  if (r == null || typeof r != "object") return;
578
590
  r = r[s];
579
591
  }
580
592
  return r;
581
- }, fe = (e, t) => {
593
+ }, ue = (e, t) => {
582
594
  if (t === "presence")
583
595
  return e == null || e === "" || Number(e) === 0 ? "No" : "Yes";
584
596
  if (e == null || e === "") return "—";
585
597
  const r = Number(e);
586
598
  return t === "currency" ? Number.isNaN(r) ? String(e) : r.toLocaleString(void 0, { style: "currency", currency: "USD" }) : t === "number" ? Number.isNaN(r) ? String(e) : r.toLocaleString(void 0, { maximumFractionDigits: 2 }) : String(e);
587
- }, kt = (e, t) => /* @__PURE__ */ c(_t, { children: [
588
- xt.map((r) => /* @__PURE__ */ n(
599
+ }, wt = (e, t) => /* @__PURE__ */ m(qt, { children: [
600
+ gt.map((r) => /* @__PURE__ */ n(
589
601
  "span",
590
602
  {
591
- className: z(
603
+ className: B(
592
604
  "truncate text-slate-500 dark:text-slate-400",
593
605
  r.format ? "w-20 shrink-0 text-right" : "min-w-0 flex-1"
594
606
  ),
595
- children: fe(Le(t, r.field), r.format)
607
+ children: ue(Ae(t, r.field), r.format)
596
608
  },
597
609
  r.field
598
610
  )),
599
- gt.map((r) => /* @__PURE__ */ n(
611
+ yt.map((r) => /* @__PURE__ */ n(
600
612
  "span",
601
613
  {
602
614
  className: "w-20 shrink-0 truncate text-right text-slate-500 dark:text-slate-400",
603
- children: fe(ut(r.key, e), r.format)
615
+ children: ue(ft(r.key, e), r.format)
604
616
  },
605
617
  r.key
606
618
  ))
607
- ] }), wt = Qt ? "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", hr = Zt(b), tt = (e, t, r) => hr ? /* @__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", vr = nr(x), nt = (e, t, r) => vr ? /* @__PURE__ */ n(
608
620
  "button",
609
621
  {
610
622
  type: "button",
611
- onClick: () => b && Gt(b, e, ee),
623
+ onClick: () => x && sr(x, e, te),
612
624
  title: "View stock & planning detail",
613
- className: z(
625
+ className: B(
614
626
  r,
615
627
  "text-left underline decoration-slate-300 decoration-1 underline-offset-2 hover:text-[#009abe] hover:decoration-[#009abe] dark:decoration-slate-600"
616
628
  ),
617
629
  children: t
618
630
  }
619
- ) : /* @__PURE__ */ n("span", { className: r, children: t }), Bt = (e) => {
620
- const t = Ue.get(e) ?? Ft.find((r) => String(r.id) === e) ?? Re.find((r) => String(r.id) === e);
621
- return t ? Fe(H, t) : `#${e}`;
622
- }, $e = (e) => Ue.get(e) ?? Ft.find((t) => String(t.id) === e) ?? Re.find((t) => String(t.id) === e) ?? { id: e }, be = (e) => {
631
+ ) : /* @__PURE__ */ n("span", { className: r, children: t }), Ut = (e) => {
632
+ const t = Me.get(e) ?? Rt.find((r) => String(r.id) === e) ?? Le.find((r) => String(r.id) === e);
633
+ return t ? Fe(ee, t) : `#${e}`;
634
+ }, qe = (e) => Me.get(e) ?? Rt.find((t) => String(t.id) === e) ?? Le.find((t) => String(t.id) === e) ?? { id: e }, fe = (e) => {
623
635
  var s;
624
- const t = A ? void 0 : Ie.get(e);
625
- if (t) return We.has(String(t.id)) ? null : Number(t[V] ?? 0);
626
- const r = lt.get(e);
627
- return r === void 0 ? null : Number(((s = Se[r]) == null ? void 0 : s[V]) ?? 0);
628
- }, xr = (e) => {
636
+ const t = E ? void 0 : Ee.get(e);
637
+ if (t) return Ye.has(String(t.id)) ? null : Number(t[V] ?? 0);
638
+ const r = Ze.get(e);
639
+ return r === void 0 ? null : Number(((s = Ne[r]) == null ? void 0 : s[V]) ?? 0);
640
+ }, _r = (e) => {
629
641
  let t = e;
630
642
  for (const r of l.section_by.split(".")) {
631
643
  if (t == null || typeof t != "object") return "";
632
644
  t = t[r];
633
645
  }
634
646
  return String(t ?? "").trim();
635
- }, rt = O(() => {
636
- if (De) return [];
647
+ }, st = O(() => {
648
+ if (He) return [];
637
649
  C.trim().toLowerCase();
638
650
  const e = /* @__PURE__ */ new Map();
639
- for (const t of E) {
640
- const r = Fe(H, t), s = R ? jt.get(String(t.id)) ?? [] : [xr(t)];
641
- if (!(R && ae && s.length === 0))
642
- for (const m of s.length ? s : [""]) {
643
- const o = m || "Uncategorized";
651
+ for (const t of M) {
652
+ const r = Fe(ee, t), s = A ? Ot.get(String(t.id)) ?? [] : [_r(t)];
653
+ if (!(A && a && s.length === 0))
654
+ for (const c of s.length ? s : [""]) {
655
+ const o = c || "Uncategorized";
644
656
  e.has(o) || e.set(o, []), e.get(o).push({ id: String(t.id), label: r, row: t });
645
657
  }
646
658
  }
@@ -648,42 +660,42 @@ function bn({
648
660
  ([t], [r]) => t === "Uncategorized" ? 1 : r === "Uncategorized" ? -1 : t.localeCompare(r)
649
661
  ).map(([t, r]) => ({
650
662
  name: t,
651
- items: r.sort((s, m) => s.label.localeCompare(m.label))
663
+ items: r.sort((s, c) => s.label.localeCompare(c.label))
652
664
  }));
653
665
  }, [
654
- E,
655
- H,
666
+ M,
667
+ ee,
656
668
  C,
657
669
  l.section_by,
658
- R,
659
- jt,
660
- De,
661
- ae
670
+ A,
671
+ Ot,
672
+ He,
673
+ a
662
674
  ]);
663
- if (!ye.current && rt.length > 0) {
664
- ye.current = !0;
675
+ if (!ge.current && st.length > 0) {
676
+ ge.current = !0;
665
677
  const e = /* @__PURE__ */ new Set();
666
- for (const t of rt)
667
- t.items.some((s) => (be(s.id) ?? 0) > 0) || e.add(t.name);
678
+ for (const t of st)
679
+ t.items.some((s) => (fe(s.id) ?? 0) > 0) || e.add(t.name);
668
680
  ne(e);
669
681
  }
670
- async function gr(e) {
682
+ async function Sr(e) {
671
683
  const t = {};
672
684
  for (const r of l.related_columns ?? []) {
673
685
  if (!r.copy_to) continue;
674
- let s = ut(r.key, e);
686
+ let s = ft(r.key, e);
675
687
  if (s === void 0) {
676
- const m = Be(r.match, ee);
677
- if (m === null) continue;
688
+ const c = De(r.match, te);
689
+ if (c === null) continue;
678
690
  s = await h.request(
679
- P(`/items/${r.collection}`, {
691
+ R(`/items/${r.collection}`, {
680
692
  limit: 1,
681
693
  fields: `${r.item_field},${r.value_field}`,
682
- filter: JSON.stringify({ ...m, [r.item_field]: { _eq: e } })
694
+ filter: JSON.stringify({ ...c, [r.item_field]: { _eq: e } })
683
695
  })
684
696
  ).then((o) => {
685
- var i, y;
686
- return (y = (i = o.data) == null ? void 0 : i[0]) == null ? void 0 : y[r.value_field];
697
+ var i, p;
698
+ return (p = (i = o.data) == null ? void 0 : i[0]) == null ? void 0 : p[r.value_field];
687
699
  }).catch(() => {
688
700
  });
689
701
  }
@@ -691,201 +703,208 @@ function bn({
691
703
  }
692
704
  return t;
693
705
  }
694
- function Ee(e, t, r, s = {}) {
695
- const m = {
706
+ function Ce(e, t, r, s = {}) {
707
+ const c = {
696
708
  [l.item_field]: r.id ?? e,
697
709
  [V]: t
698
710
  };
699
711
  for (const [o, i] of Object.entries(l.copy_fields ?? {}))
700
- r[i] !== void 0 && (m[o] = r[i]);
701
- Object.assign(m, s);
712
+ r[i] !== void 0 && (c[o] = r[i]);
713
+ Object.assign(c, s);
702
714
  for (const [o, i] of Object.entries(l.compute_fields ?? {})) {
703
- const y = Ke(i, m);
704
- y !== null && (m[o] = y);
715
+ const p = Qe(i, c);
716
+ p !== null && (c[o] = p);
705
717
  }
706
- return m;
718
+ return c;
707
719
  }
708
- async function nt(e, t, r, s = {}) {
709
- const m = Kr(t, { type: X, min: 0, label: "Quantity" });
710
- if (!m.ok) {
711
- j((d) => ({ ...d, [e]: { kind: "error", message: m.message } }));
720
+ async function at(e, t, r, s = {}) {
721
+ const c = tr(t, { type: _e, min: 0, label: "Quantity" });
722
+ if (!c.ok) {
723
+ F((d) => ({ ...d, [e]: { kind: "error", message: c.message } }));
712
724
  return;
713
725
  }
714
- const o = m.value ?? 0;
715
- if ((be(e) ?? 0) === o) return;
726
+ const o = c.value ?? 0;
727
+ if ((fe(e) ?? 0) === o) return;
716
728
  if (o === 0 && !s.confirmedRemove) {
717
- j((d) => ({ ...d, [e]: { kind: "remove", row: r } }));
729
+ F((d) => ({ ...d, [e]: { kind: "remove", row: r } }));
718
730
  return;
719
731
  }
720
- const y = o > 0 ? await gr(e) : {};
721
- if (Pe && p) {
722
- const d = Ie.get(e);
732
+ if (o > 0) {
733
+ const d = Ze.get(e), u = (E ? void 0 : Ee.get(e)) ?? (d !== void 0 ? Ne[d] : void 0) ?? {}, w = Oe(V, o, u);
734
+ if (w) {
735
+ F((j) => ({ ...j, [e]: { kind: "error", message: w } }));
736
+ return;
737
+ }
738
+ }
739
+ const p = o > 0 ? await Sr(e) : {};
740
+ if (Pe && b) {
741
+ const d = Ee.get(e);
723
742
  if ((d == null ? void 0 : d.id) != null) {
724
- const f = String(d.id);
743
+ const u = String(d.id);
725
744
  if (o === 0) {
726
- p.cancelPendingEdit(u, g, f), p.queueDelete(u, g, f);
745
+ b.cancelPendingEdit(f, y, u), b.queueDelete(f, y, u);
727
746
  return;
728
747
  }
729
- We.has(f) && p.cancelPendingDelete(u, g, f);
730
- const N = Ee(e, o, r, y);
731
- for (const S of B)
732
- d[S] != null && d[S] !== "" && (N[S] = d[S]);
733
- for (const [S, le] of Object.entries(l.compute_fields ?? {})) {
734
- const _e = Ke(le, { ...d, ...N });
735
- _e !== null && (N[S] = _e);
748
+ Ye.has(u) && b.cancelPendingDelete(f, y, u);
749
+ const w = Ce(e, o, r, p);
750
+ for (const S of U)
751
+ d[S] != null && d[S] !== "" && (w[S] = d[S]);
752
+ for (const [S, $e] of Object.entries(l.compute_fields ?? {})) {
753
+ const ve = Qe($e, { ...d, ...w });
754
+ ve !== null && (w[S] = ve);
736
755
  }
737
- const T = ve.find((S) => String(S.id) === f) ?? {}, k = Object.fromEntries(
738
- Object.entries(N).filter(([S, le]) => String(le ?? "") !== String(T[S] ?? ""))
756
+ const j = we.find((S) => String(S.id) === u) ?? {}, N = Object.fromEntries(
757
+ Object.entries(w).filter(([S, $e]) => String($e ?? "") !== String(j[S] ?? ""))
739
758
  );
740
- Object.keys(k).length === 0 ? p.cancelPendingEdit(u, g, f) : (p.cancelPendingEdit(u, g, f), p.queueEdit(u, g, f, k));
759
+ Object.keys(N).length === 0 ? b.cancelPendingEdit(f, y, u) : (b.cancelPendingEdit(f, y, u), b.queueEdit(f, y, u, N));
741
760
  return;
742
761
  }
743
762
  }
744
- if (A || Pe) {
745
- const d = lt.get(e);
746
- o === 0 ? d !== void 0 && (p == null || p.removeRow(u, g, d)) : d !== void 0 ? p == null || p.updateRow(
747
- u,
748
- g,
763
+ if (E || Pe) {
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(
766
+ f,
767
+ y,
749
768
  d,
750
- Jr(
751
- Se[d],
752
- Ee(e, o, r, y),
753
- B,
769
+ Vr(
770
+ Ne[d],
771
+ Ce(e, o, r, p),
772
+ U,
754
773
  l.compute_fields
755
774
  )
756
- ) : p == null || p.queueRow(
757
- u,
758
- g,
759
- Ee(e, o, r, y)
775
+ ) : b == null || b.queueRow(
776
+ f,
777
+ y,
778
+ Ce(e, o, r, p)
760
779
  );
761
780
  return;
762
781
  }
763
782
  v((d) => new Set(d).add(e));
764
783
  try {
765
- const d = Ie.get(e);
784
+ const d = Ee.get(e);
766
785
  if (o === 0)
767
- (d == null ? void 0 : d.id) != null && await h.request($r(`/items/${u}/${d.id}`));
786
+ (d == null ? void 0 : d.id) != null && await h.request(Lr(`/items/${f}/${d.id}`));
768
787
  else if ((d == null ? void 0 : d.id) != null) {
769
- const f = Ee(e, o, r, y);
770
- for (const S of B)
771
- d[S] != null && d[S] !== "" && (f[S] = d[S]);
772
- for (const [S, le] of Object.entries(l.compute_fields ?? {})) {
773
- const _e = Ke(le, { ...d, ...f });
774
- _e !== null && (f[S] = _e);
788
+ const u = Ce(e, o, r, p);
789
+ for (const S of U)
790
+ d[S] != null && d[S] !== "" && (u[S] = d[S]);
791
+ for (const [S, $e] of Object.entries(l.compute_fields ?? {})) {
792
+ const ve = Qe($e, { ...d, ...u });
793
+ ve !== null && (u[S] = ve);
775
794
  }
776
- const N = { ...d, ...f }, { id: T, ...k } = N;
777
- await h.request(Wt(`/items/${u}/${d.id}`, k));
795
+ const w = { ...d, ...u }, { id: j, ...N } = w;
796
+ await h.request(Yt(`/items/${f}/${d.id}`, N));
778
797
  } else
779
798
  await h.request(
780
- It(`/items/${u}`, {
781
- [g]: _,
782
- ...Ee(e, o, r, y)
799
+ Zt(`/items/${f}`, {
800
+ [y]: _,
801
+ ...Ce(e, o, r, p)
783
802
  })
784
803
  );
785
- $.invalidateQueries({ queryKey: ["o2m-rows", u, g, _] });
804
+ $.invalidateQueries({ queryKey: ["o2m-rows", f, y, _] });
786
805
  } catch {
787
806
  } finally {
788
807
  v((d) => {
789
- const f = new Set(d);
790
- return f.delete(e), f;
808
+ const u = new Set(d);
809
+ return u.delete(e), u;
791
810
  });
792
811
  }
793
812
  }
794
- async function yr(e, t, r) {
813
+ async function qr(e, t, r) {
795
814
  const s = r.trim() === "" ? null : Number(r);
796
815
  if (r.trim() !== "" && Number.isNaN(s)) return;
797
- const m = (i) => {
798
- const y = { ...i, [t]: s };
799
- for (const [d, f] of Object.entries(l.compute_fields ?? {})) {
800
- const N = Ke(f, y);
801
- N !== null && (y[d] = N);
816
+ const c = (i) => {
817
+ const p = { ...i, [t]: s };
818
+ for (const [d, u] of Object.entries(l.compute_fields ?? {})) {
819
+ const w = Qe(u, p);
820
+ w !== null && (p[d] = w);
802
821
  }
803
- return y;
804
- }, o = A ? void 0 : Ie.get(e);
822
+ return p;
823
+ }, o = E ? void 0 : Ee.get(e);
805
824
  if ((o == null ? void 0 : o.id) == null) {
806
- const i = lt.get(e);
825
+ const i = Ze.get(e);
807
826
  if (i === void 0) return;
808
- p == null || p.updateRow(u, g, i, m(Se[i]));
827
+ b == null || b.updateRow(f, y, i, c(Ne[i]));
809
828
  return;
810
829
  }
811
- if (Pe && p) {
812
- const i = m(o), y = ve.find((f) => String(f.id) === String(o.id)) ?? {}, d = Object.fromEntries(
830
+ if (Pe && b) {
831
+ const i = c(o), p = we.find((u) => String(u.id) === String(o.id)) ?? {}, d = Object.fromEntries(
813
832
  Object.entries(i).filter(
814
- ([f, N]) => f !== "id" && String(N ?? "") !== String(y[f] ?? "")
833
+ ([u, w]) => u !== "id" && String(w ?? "") !== String(p[u] ?? "")
815
834
  )
816
835
  );
817
- p.cancelPendingEdit(u, g, String(o.id)), Object.keys(d).length > 0 && p.queueEdit(u, g, String(o.id), d);
836
+ b.cancelPendingEdit(f, y, String(o.id)), Object.keys(d).length > 0 && b.queueEdit(f, y, String(o.id), d);
818
837
  return;
819
838
  }
820
839
  v((i) => new Set(i).add(e));
821
840
  try {
822
- const { id: i, ...y } = m(o);
823
- await h.request(Wt(`/items/${u}/${o.id}`, y)), $.invalidateQueries({ queryKey: ["o2m-rows", u, g, _] });
841
+ const { id: i, ...p } = c(o);
842
+ await h.request(Yt(`/items/${f}/${o.id}`, p)), $.invalidateQueries({ queryKey: ["o2m-rows", f, y, _] });
824
843
  } catch {
825
844
  } finally {
826
845
  v((i) => {
827
- const y = new Set(i);
828
- return y.delete(e), y;
846
+ const p = new Set(i);
847
+ return p.delete(e), p;
829
848
  });
830
849
  }
831
850
  }
832
- async function kr(e) {
833
- if (e == null || e === "" || !b) return;
834
- const t = String(e), r = $e(t);
851
+ async function $r(e) {
852
+ if (e == null || e === "" || !x) return;
853
+ const t = String(e), r = qe(t);
835
854
  let s = r;
836
855
  Object.keys(r).length <= 1 && (s = await h.request(
837
- P(`/items/${b}`, {
856
+ R(`/items/${x}`, {
838
857
  filter: JSON.stringify({ id: { _eq: e } }),
839
- fields: a,
858
+ fields: J,
840
859
  limit: 1
841
860
  })
842
861
  ).then((o) => {
843
862
  var i;
844
863
  return ((i = o.data) == null ? void 0 : i[0]) ?? { id: e };
845
864
  }).catch(() => ({ id: e })));
846
- const m = (be(t) ?? 0) + 1;
847
- await nt(t, String(m), s);
865
+ const c = (fe(t) ?? 0) + 1;
866
+ await at(t, String(c), s);
848
867
  }
849
- const wr = de.length, Nt = Object.keys(l.copy_fields ?? {}), vt = Object.keys(l.compute_fields ?? {}), Ae = (e, t) => {
850
- const r = be(e);
851
- if (x)
868
+ const jr = le.length, vt = Object.keys(l.copy_fields ?? {}), _t = Object.keys(l.compute_fields ?? {}), Ke = (e, t) => {
869
+ const r = fe(e);
870
+ if (g)
852
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 : "—" });
853
- const s = pe[e], m = s !== void 0 ? s : r && r > 0 ? String(r) : "", o = F[e], i = () => j((d) => {
872
+ const s = pe[e], c = s !== void 0 ? s : r && r > 0 ? String(r) : "", o = T[e], i = () => F((d) => {
854
873
  if (!(e in d)) return d;
855
- const f = { ...d };
856
- return delete f[e], f;
857
- }), y = /* @__PURE__ */ n(
874
+ const u = { ...d };
875
+ return delete u[e], u;
876
+ }), p = /* @__PURE__ */ n(
858
877
  "input",
859
878
  {
860
879
  type: "number",
861
880
  min: 0,
862
- step: Cr(X) ? 1 : "any",
863
- disabled: x,
864
- value: m,
881
+ step: Br(_e) ? 1 : "any",
882
+ disabled: g,
883
+ value: c,
865
884
  placeholder: "0",
866
885
  "aria-invalid": (o == null ? void 0 : o.kind) === "error" || void 0,
867
886
  onFocus: i,
868
- onChange: (d) => G((f) => ({ ...f, [e]: d.target.value })),
887
+ onChange: (d) => G((u) => ({ ...u, [e]: d.target.value })),
869
888
  onBlur: (d) => {
870
- const f = d.target.value;
871
- G((N) => {
872
- const T = { ...N };
873
- return delete T[e], T;
874
- }), nt(e, f, t);
889
+ const u = d.target.value;
890
+ G((w) => {
891
+ const j = { ...w };
892
+ return delete j[e], j;
893
+ }), at(e, u, t);
875
894
  },
876
895
  onKeyDown: (d) => {
877
896
  d.key === "Enter" && d.currentTarget.blur();
878
897
  },
879
- className: z(
898
+ className: B(
880
899
  "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 disabled:opacity-50 dark:border-border dark:bg-background",
881
900
  (o == null ? void 0 : o.kind) === "error" && "border-red-400 dark:border-red-600"
882
901
  )
883
902
  }
884
903
  );
885
- return /* @__PURE__ */ c(Lr, { open: !!o, onOpenChange: (d) => !d && i(), children: [
886
- /* @__PURE__ */ n(Er, { asChild: !0, children: y }),
887
- /* @__PURE__ */ c(
888
- Ar,
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,
889
908
  {
890
909
  align: "end",
891
910
  side: "bottom",
@@ -894,22 +913,22 @@ function bn({
894
913
  (o == null ? void 0 : o.kind) === "error" && d.preventDefault();
895
914
  },
896
915
  children: [
897
- (o == null ? void 0 : o.kind) === "error" && /* @__PURE__ */ c(
916
+ (o == null ? void 0 : o.kind) === "error" && /* @__PURE__ */ m(
898
917
  "p",
899
918
  {
900
919
  role: "alert",
901
920
  className: "flex items-start gap-1.5 text-red-600 dark:text-red-400",
902
921
  "data-catalog-qty-error": !0,
903
922
  children: [
904
- /* @__PURE__ */ n(Mt, { className: "mt-px h-3.5 w-3.5 shrink-0" }),
923
+ /* @__PURE__ */ n(St, { className: "mt-px h-3.5 w-3.5 shrink-0" }),
905
924
  o.message,
906
925
  r && r > 0 ? ` — still ${r}` : ""
907
926
  ]
908
927
  }
909
928
  ),
910
- (o == null ? void 0 : o.kind) === "remove" && /* @__PURE__ */ c("div", { "data-catalog-qty-remove": !0, children: [
929
+ (o == null ? void 0 : o.kind) === "remove" && /* @__PURE__ */ m("div", { "data-catalog-qty-remove": !0, children: [
911
930
  /* @__PURE__ */ n("p", { className: "text-slate-700 dark:text-slate-200", children: "Remove this line?" }),
912
- /* @__PURE__ */ c("div", { className: "mt-2 flex justify-end gap-1.5", children: [
931
+ /* @__PURE__ */ m("div", { className: "mt-2 flex justify-end gap-1.5", children: [
913
932
  /* @__PURE__ */ n(
914
933
  "button",
915
934
  {
@@ -925,7 +944,7 @@ function bn({
925
944
  type: "button",
926
945
  onClick: () => {
927
946
  const d = o.row;
928
- i(), nt(e, "0", d, { confirmedRemove: !0 });
947
+ i(), at(e, "0", d, { confirmedRemove: !0 });
929
948
  },
930
949
  className: "h-6 rounded bg-red-600 px-2 text-[11px] font-medium text-white hover:bg-red-700",
931
950
  children: "Remove"
@@ -937,111 +956,174 @@ function bn({
937
956
  }
938
957
  )
939
958
  ] });
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 };
963
+ return delete d[s], d;
964
+ }), 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(
967
+ "input",
968
+ {
969
+ type: "number",
970
+ min: 0,
971
+ step: "any",
972
+ defaultValue: i,
973
+ "aria-invalid": !!c || void 0,
974
+ onFocus: o,
975
+ onBlur: (p) => {
976
+ const d = p.target.value;
977
+ if (d !== i) {
978
+ const u = be.find((N) => N.field === t), w = tr(d, {
979
+ type: u == null ? void 0 : u.type,
980
+ label: (u == null ? void 0 : u.label) || I(t)
981
+ }), j = w.ok ? Oe(t, w.value, r) : w.message;
982
+ if (j) {
983
+ p.target.value = i, L((N) => ({ ...N, [s]: j }));
984
+ return;
985
+ }
986
+ }
987
+ qr(e, t, d);
988
+ },
989
+ onKeyDown: (p) => {
990
+ p.key === "Enter" && p.currentTarget.blur();
991
+ },
992
+ className: B(
993
+ "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",
994
+ c && "border-red-400 dark:border-red-600"
995
+ )
996
+ },
997
+ `${s}:${i}`
998
+ ) }),
999
+ /* @__PURE__ */ n(
1000
+ er,
1001
+ {
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
+ )
1019
+ }
1020
+ )
1021
+ ] }, s);
940
1022
  };
941
- return !b && K ? /* @__PURE__ */ c("div", { className: "space-y-2 py-1", "aria-busy": "true", children: [
1023
+ return !x && de ? /* @__PURE__ */ m("div", { className: "space-y-2 py-1", "aria-busy": "true", children: [
942
1024
  /* @__PURE__ */ n("div", { className: "h-8 w-full animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" }),
943
1025
  /* @__PURE__ */ n("div", { className: "h-8 w-2/3 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" })
944
- ] }) : b ? /* @__PURE__ */ c("div", { className: "space-y-3", children: [
945
- !x && /* @__PURE__ */ c(_t, { children: [
946
- /* @__PURE__ */ c("div", { className: "rounded-lg border border-slate-200 text-[12px] dark:border-border", children: [
947
- /* @__PURE__ */ c("div", { className: "flex items-center gap-2 border-b border-slate-200 px-3 py-2 dark:border-border", children: [
948
- /* @__PURE__ */ n(st, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
1026
+ ] }) : x ? /* @__PURE__ */ m("div", { className: "space-y-3", children: [
1027
+ !g && /* @__PURE__ */ m(qt, { children: [
1028
+ /* @__PURE__ */ m("div", { className: "rounded-lg border border-slate-200 text-[12px] dark:border-border", children: [
1029
+ /* @__PURE__ */ m("div", { className: "flex items-center gap-2 border-b border-slate-200 px-3 py-2 dark:border-border", children: [
1030
+ /* @__PURE__ */ n(it, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
949
1031
  /* @__PURE__ */ n(
950
1032
  "input",
951
1033
  {
952
1034
  value: C,
953
- onChange: (e) => ke(e.target.value),
1035
+ onChange: (e) => ye(e.target.value),
954
1036
  placeholder: "Search catalog…",
955
1037
  className: "w-full bg-transparent text-[12px] outline-none placeholder:text-slate-400"
956
1038
  }
957
1039
  ),
958
- /* @__PURE__ */ c("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: [
959
- wr,
1040
+ /* @__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,
960
1042
  " picked"
961
1043
  ] })
962
1044
  ] }),
963
- Qt && // Sticky: the catalog list is tall and the page scroller carries it —
1045
+ Vt && // Sticky: the catalog list is tall and the page scroller carries it —
964
1046
  // without this the labels scroll away and favorites/section rows
965
1047
  // read as headerless columns. Opaque bg (not the /60 tint) so rows
966
1048
  // never bleed through while pinned.
967
- /* @__PURE__ */ c(
1049
+ /* @__PURE__ */ m(
968
1050
  "div",
969
1051
  {
970
- ref: pr,
1052
+ ref: Nr,
971
1053
  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",
972
1054
  children: [
973
1055
  l.favorites && /* @__PURE__ */ n("span", { className: "w-[18px] shrink-0" }),
974
1056
  /* @__PURE__ */ n("span", { className: "w-36 shrink-0", children: "Item" }),
975
- xt.map((e) => /* @__PURE__ */ n(
1057
+ gt.map((e) => /* @__PURE__ */ n(
976
1058
  "span",
977
1059
  {
978
1060
  className: e.format ? "w-20 shrink-0 text-right" : "min-w-0 flex-1",
979
- children: e.label ?? re(e.field.split(".")[0])
1061
+ children: e.label ?? I(e.field.split(".")[0])
980
1062
  },
981
1063
  e.field
982
1064
  )),
983
- gt.map((e) => /* @__PURE__ */ n("span", { className: "w-20 shrink-0 text-right", children: e.label ?? re(e.key) }, e.key)),
1065
+ yt.map((e) => /* @__PURE__ */ n("span", { className: "w-20 shrink-0 text-right", children: e.label ?? I(e.key) }, e.key)),
984
1066
  /* @__PURE__ */ n("span", { className: "w-20 shrink-0 text-right", children: "Qty" })
985
1067
  ]
986
1068
  }
987
1069
  ),
988
- C.trim().length > 0 && qe.length === 0 && mt && /* @__PURE__ */ c("div", { className: "flex items-center justify-center gap-2 border-b border-slate-100 px-3 py-3 text-slate-400 dark:border-border/50", children: [
989
- /* @__PURE__ */ n(oe, { className: "h-3.5 w-3.5 animate-spin" }),
1070
+ C.trim().length > 0 && Se.length === 0 && ut && /* @__PURE__ */ m("div", { className: "flex items-center justify-center gap-2 border-b border-slate-100 px-3 py-3 text-slate-400 dark:border-border/50", children: [
1071
+ /* @__PURE__ */ n(ae, { className: "h-3.5 w-3.5 animate-spin" }),
990
1072
  " Searching the catalog…"
991
1073
  ] }),
992
- C.trim().length > 0 && qe.length === 0 && !mt && /* @__PURE__ */ c("p", { className: "px-3 py-4 text-center text-slate-400", children: [
1074
+ C.trim().length > 0 && Se.length === 0 && !ut && /* @__PURE__ */ m("p", { className: "px-3 py-4 text-center text-slate-400", children: [
993
1075
  'No CIFAs match "',
994
1076
  C.trim(),
995
1077
  '"'
996
1078
  ] }),
997
- C.trim().length > 0 && qe.length > 0 && /* @__PURE__ */ c(Ce, { children: [
998
- /* @__PURE__ */ c("div", { className: "flex w-full items-center gap-1.5 border-b border-t border-slate-200 bg-sky-50/70 px-2 py-1.5 dark:border-border dark:bg-sky-900/10", children: [
999
- /* @__PURE__ */ n(st, { className: "h-3 w-3 shrink-0 text-sky-500" }),
1079
+ C.trim().length > 0 && Se.length > 0 && /* @__PURE__ */ m(Je, { children: [
1080
+ /* @__PURE__ */ m("div", { className: "flex w-full items-center gap-1.5 border-b border-t border-slate-200 bg-sky-50/70 px-2 py-1.5 dark:border-border dark:bg-sky-900/10", children: [
1081
+ /* @__PURE__ */ n(it, { className: "h-3 w-3 shrink-0 text-sky-500" }),
1000
1082
  /* @__PURE__ */ n("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Search results" }),
1001
- /* @__PURE__ */ n("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: qe.length }),
1083
+ /* @__PURE__ */ n("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: Se.length }),
1002
1084
  /* @__PURE__ */ n("span", { className: "text-[10px] text-slate-400", children: "across the entire catalog — enter a quantity to add" }),
1003
- mt && /* @__PURE__ */ n(oe, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" })
1085
+ ut && /* @__PURE__ */ n(ae, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" })
1004
1086
  ] }),
1005
- qe.map((e, t) => {
1006
- const r = String(e.id), s = be(r);
1007
- return /* @__PURE__ */ c(
1087
+ Se.map((e, t) => {
1088
+ const r = String(e.id), s = fe(r);
1089
+ return /* @__PURE__ */ m(
1008
1090
  "div",
1009
1091
  {
1010
- className: z(
1092
+ className: B(
1011
1093
  "flex items-center gap-2 border-b border-slate-100 px-3 py-1 dark:border-border/50",
1012
1094
  t % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
1013
1095
  (s ?? 0) > 0 && "bg-nvr-cyan/5"
1014
1096
  ),
1015
1097
  children: [
1016
- dt(r),
1017
- tt(r, Fe(H, e), wt),
1018
- kt(r, e),
1019
- se.has(r) && /* @__PURE__ */ n(oe, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" }),
1020
- Ae(r, e)
1098
+ ct(r),
1099
+ nt(r, Fe(ee, e), Nt),
1100
+ wt(r, e),
1101
+ se.has(r) && /* @__PURE__ */ n(ae, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" }),
1102
+ Ke(r, e)
1021
1103
  ]
1022
1104
  },
1023
1105
  r
1024
1106
  );
1025
1107
  })
1026
1108
  ] }),
1027
- xe.length > 0 && !C.trim() && /* @__PURE__ */ c("p", { className: "px-3 py-6 text-center text-slate-400", children: [
1109
+ k.length > 0 && !C.trim() && /* @__PURE__ */ m("p", { className: "px-3 py-6 text-center text-slate-400", children: [
1028
1110
  "Search the full catalog above, or select",
1029
1111
  " ",
1030
- xe.map((e) => {
1112
+ k.map((e) => {
1031
1113
  var t;
1032
- return ((t = L == null ? void 0 : L.fieldLabels) == null ? void 0 : t[e]) ?? re(e);
1114
+ return ((t = P == null ? void 0 : P.fieldLabels) == null ? void 0 : t[e]) ?? I(e);
1033
1115
  }).join(", "),
1034
1116
  " ",
1035
1117
  "to browse by category"
1036
1118
  ] }),
1037
- xe.length === 0 && (ie || De) && /* @__PURE__ */ c("div", { className: "flex items-center justify-center gap-2 py-6 text-slate-400", children: [
1038
- /* @__PURE__ */ n(oe, { className: "h-4 w-4 animate-spin" }),
1119
+ k.length === 0 && (H || He) && /* @__PURE__ */ m("div", { className: "flex items-center justify-center gap-2 py-6 text-slate-400", children: [
1120
+ /* @__PURE__ */ n(ae, { className: "h-4 w-4 animate-spin" }),
1039
1121
  " Loading catalog…"
1040
1122
  ] }),
1041
- xe.length === 0 && !ie && !De && rt.length === 0 && /* @__PURE__ */ n("p", { className: "px-3 py-6 text-center text-slate-400", children: "No catalog items" }),
1042
- l.favorites && /* @__PURE__ */ c(Ce, { children: [
1043
- /* @__PURE__ */ c("div", { className: "flex w-full items-center gap-1.5 border-b border-slate-200 bg-amber-50/70 px-2 py-1 dark:border-border dark:bg-amber-900/10", children: [
1044
- /* @__PURE__ */ c(
1123
+ k.length === 0 && !H && !He && st.length === 0 && /* @__PURE__ */ n("p", { className: "px-3 py-6 text-center text-slate-400", children: "No catalog items" }),
1124
+ l.favorites && /* @__PURE__ */ m(Je, { children: [
1125
+ /* @__PURE__ */ m("div", { className: "flex w-full items-center gap-1.5 border-b border-slate-200 bg-amber-50/70 px-2 py-1 dark:border-border dark:bg-amber-900/10", children: [
1126
+ /* @__PURE__ */ m(
1045
1127
  "button",
1046
1128
  {
1047
1129
  type: "button",
@@ -1052,82 +1134,82 @@ function bn({
1052
1134
  className: "flex min-w-0 flex-1 items-center gap-1.5 py-0.5 text-left",
1053
1135
  children: [
1054
1136
  /* @__PURE__ */ n(
1055
- qt,
1137
+ jt,
1056
1138
  {
1057
- className: z(
1139
+ className: B(
1058
1140
  "h-3 w-3 shrink-0 text-slate-400 transition-transform",
1059
- !ce.has("__favorites__") && "rotate-90"
1141
+ !oe.has("__favorites__") && "rotate-90"
1060
1142
  )
1061
1143
  }
1062
1144
  ),
1063
- /* @__PURE__ */ n(Qe, { className: "h-3 w-3 shrink-0 fill-amber-400 text-amber-400" }),
1145
+ /* @__PURE__ */ n(Be, { className: "h-3 w-3 shrink-0 fill-amber-400 text-amber-400" }),
1064
1146
  /* @__PURE__ */ n("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Favorites" }),
1065
- /* @__PURE__ */ n("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: Re.length })
1147
+ /* @__PURE__ */ n("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: Le.length })
1066
1148
  ]
1067
1149
  }
1068
1150
  ),
1069
1151
  /* @__PURE__ */ n(
1070
1152
  "button",
1071
1153
  {
1072
- ref: Rt,
1154
+ ref: At,
1073
1155
  type: "button",
1074
- onClick: () => Pt(!0),
1156
+ onClick: () => Lt(!0),
1075
1157
  className: "shrink-0 rounded border border-amber-200 bg-white px-2 py-0.5 text-[10px] font-semibold text-amber-700 transition-colors hover:border-amber-300 hover:bg-amber-50 dark:border-amber-400/30 dark:bg-transparent dark:text-amber-300 dark:hover:bg-amber-400/10",
1076
1158
  children: "Manage"
1077
1159
  }
1078
1160
  )
1079
1161
  ] }),
1080
- !ce.has("__favorites__") && Re.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." }),
1081
- !ce.has("__favorites__") && Re.map((e, t) => {
1082
- const r = String(e.id), s = be(r), m = ft(r);
1083
- return /* @__PURE__ */ c(
1162
+ !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
+ !oe.has("__favorites__") && Le.map((e, t) => {
1164
+ const r = String(e.id), s = fe(r), c = pt(r);
1165
+ return /* @__PURE__ */ m(
1084
1166
  "div",
1085
1167
  {
1086
- className: z(
1168
+ className: B(
1087
1169
  "flex items-center gap-2 border-b border-slate-100 px-3 py-1 dark:border-border/50",
1088
1170
  t % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
1089
1171
  (s ?? 0) > 0 && "bg-nvr-cyan/5",
1090
- m && "bg-amber-50 dark:bg-amber-900/15"
1172
+ c && "bg-amber-50 dark:bg-amber-900/15"
1091
1173
  ),
1092
1174
  children: [
1093
- dt(r),
1094
- tt(r, Fe(H, e), wt),
1095
- kt(r, e),
1096
- m && /* @__PURE__ */ n(
1097
- Je,
1175
+ ct(r),
1176
+ nt(r, Fe(ee, e), Nt),
1177
+ wt(r, e),
1178
+ c && /* @__PURE__ */ n(
1179
+ ze,
1098
1180
  {
1099
1181
  className: "h-3.5 w-3.5 shrink-0 text-amber-500",
1100
- "aria-label": `${bt} ${m.available} — ${m.qty} requested`
1182
+ "aria-label": `${bt} ${c.available} — ${c.qty} requested`
1101
1183
  }
1102
1184
  ),
1103
- se.has(r) && /* @__PURE__ */ n(oe, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" }),
1104
- Ae(r, e)
1185
+ se.has(r) && /* @__PURE__ */ n(ae, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" }),
1186
+ Ke(r, e)
1105
1187
  ]
1106
1188
  },
1107
1189
  r
1108
1190
  );
1109
1191
  })
1110
1192
  ] }),
1111
- xe.length === 0 && rt.map((e) => {
1112
- const t = ce.has(e.name), r = e.items.reduce(
1113
- (s, m) => s + ((be(m.id) ?? 0) > 0 ? 1 : 0),
1193
+ k.length === 0 && st.map((e) => {
1194
+ const t = oe.has(e.name), r = e.items.reduce(
1195
+ (s, c) => s + ((fe(c.id) ?? 0) > 0 ? 1 : 0),
1114
1196
  0
1115
1197
  );
1116
- return /* @__PURE__ */ c(Ce, { children: [
1117
- /* @__PURE__ */ c(
1198
+ return /* @__PURE__ */ m(Je, { children: [
1199
+ /* @__PURE__ */ m(
1118
1200
  "button",
1119
1201
  {
1120
1202
  type: "button",
1121
1203
  onClick: () => ne((s) => {
1122
- const m = new Set(s);
1123
- return m.has(e.name) ? m.delete(e.name) : m.add(e.name), m;
1204
+ const c = new Set(s);
1205
+ return c.has(e.name) ? c.delete(e.name) : c.add(e.name), c;
1124
1206
  }),
1125
1207
  className: "flex w-full items-center gap-1.5 border-b border-slate-200 bg-slate-100/80 px-2 py-1.5 text-left dark:border-border dark:bg-muted",
1126
1208
  children: [
1127
1209
  /* @__PURE__ */ n(
1128
- qt,
1210
+ jt,
1129
1211
  {
1130
- className: z(
1212
+ className: B(
1131
1213
  "h-3 w-3 shrink-0 text-slate-400 transition-transform",
1132
1214
  !t && "rotate-90"
1133
1215
  )
@@ -1135,37 +1217,37 @@ function bn({
1135
1217
  ),
1136
1218
  /* @__PURE__ */ n("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: e.name }),
1137
1219
  /* @__PURE__ */ n("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: e.items.length }),
1138
- r > 0 && /* @__PURE__ */ c("span", { className: "rounded bg-nvr-cyan/10 px-1.5 py-0.5 text-[10px] font-semibold text-[#009abe]", children: [
1220
+ r > 0 && /* @__PURE__ */ m("span", { className: "rounded bg-nvr-cyan/10 px-1.5 py-0.5 text-[10px] font-semibold text-[#009abe]", children: [
1139
1221
  r,
1140
1222
  " picked"
1141
1223
  ] })
1142
1224
  ]
1143
1225
  }
1144
1226
  ),
1145
- !t && e.items.map((s, m) => {
1146
- const o = be(s.id), i = ft(s.id);
1147
- return /* @__PURE__ */ c(
1227
+ !t && e.items.map((s, c) => {
1228
+ const o = fe(s.id), i = pt(s.id);
1229
+ return /* @__PURE__ */ m(
1148
1230
  "div",
1149
1231
  {
1150
- className: z(
1232
+ className: B(
1151
1233
  "flex items-center gap-2 border-b border-slate-100 px-3 py-1 dark:border-border/50",
1152
- m % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
1234
+ c % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
1153
1235
  (o ?? 0) > 0 && "bg-nvr-cyan/5",
1154
1236
  i && "bg-amber-50 dark:bg-amber-900/15"
1155
1237
  ),
1156
1238
  children: [
1157
- dt(s.id),
1158
- tt(s.id, s.label, wt),
1159
- kt(s.id, s.row),
1239
+ ct(s.id),
1240
+ nt(s.id, s.label, Nt),
1241
+ wt(s.id, s.row),
1160
1242
  i && /* @__PURE__ */ n(
1161
- Je,
1243
+ ze,
1162
1244
  {
1163
1245
  className: "h-3.5 w-3.5 shrink-0 text-amber-500",
1164
1246
  "aria-label": `${bt} ${i.available} — ${i.qty} requested`
1165
1247
  }
1166
1248
  ),
1167
- se.has(s.id) && /* @__PURE__ */ n(oe, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" }),
1168
- Ae(s.id, s.row)
1249
+ se.has(s.id) && /* @__PURE__ */ n(ae, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" }),
1250
+ Ke(s.id, s.row)
1169
1251
  ]
1170
1252
  },
1171
1253
  s.id
@@ -1174,26 +1256,26 @@ function bn({
1174
1256
  ] }, e.name);
1175
1257
  })
1176
1258
  ] }),
1177
- (l.builders ?? []).filter((e) => Yt(e.show_when, ee)).map((e) => /* @__PURE__ */ n(
1178
- Dr,
1259
+ (l.builders ?? []).filter((e) => rr(e.show_when, te)).map((e) => /* @__PURE__ */ n(
1260
+ Ir,
1179
1261
  {
1180
1262
  builder: e,
1181
1263
  defaultItemField: l.item_field,
1182
- catalogCol: b,
1183
- catalogFields: a,
1184
- tmpl: H,
1185
- qtyInput: Ae,
1186
- currentQty: be
1264
+ catalogCol: x,
1265
+ catalogFields: J,
1266
+ tmpl: ee,
1267
+ qtyInput: Ke,
1268
+ currentQty: fe
1187
1269
  },
1188
1270
  e.label
1189
1271
  ))
1190
1272
  ] }),
1191
- /* @__PURE__ */ c("div", { className: "rounded-lg border border-slate-200 text-[12px] dark:border-border", children: [
1192
- /* @__PURE__ */ c("div", { className: "flex items-center justify-between gap-2 border-b border-slate-200 bg-slate-50 px-3 py-2 dark:border-border dark:bg-muted", children: [
1273
+ /* @__PURE__ */ m("div", { className: "rounded-lg border border-slate-200 text-[12px] dark:border-border", children: [
1274
+ /* @__PURE__ */ m("div", { className: "flex items-center justify-between gap-2 border-b border-slate-200 bg-slate-50 px-3 py-2 dark:border-border dark:bg-muted", children: [
1193
1275
  /* @__PURE__ */ n("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Summary" }),
1194
- !x && /* @__PURE__ */ c("div", { className: "flex items-center gap-2", onClick: (e) => e.stopPropagation(), children: [
1195
- l.upload_template && !A && Z && q && /* @__PURE__ */ n(
1196
- Rr,
1276
+ !g && /* @__PURE__ */ m("div", { className: "flex items-center gap-2", onClick: (e) => e.stopPropagation(), children: [
1277
+ l.upload_template && !E && Z && q && /* @__PURE__ */ n(
1278
+ zr,
1197
1279
  {
1198
1280
  collection: q,
1199
1281
  templateFilter: (e) => {
@@ -1209,53 +1291,53 @@ function bn({
1209
1291
  }
1210
1292
  ),
1211
1293
  /* @__PURE__ */ n("div", { className: "w-64", children: /* @__PURE__ */ n(
1212
- Br,
1294
+ Mr,
1213
1295
  {
1214
- collection: b,
1296
+ collection: x,
1215
1297
  value: null,
1216
- onChange: (e) => void kr(e),
1298
+ onChange: (e) => void $r(e),
1217
1299
  placeholder: "+ Add any item…"
1218
1300
  }
1219
1301
  ) })
1220
1302
  ] })
1221
1303
  ] }),
1222
- de.length === 0 ? /* @__PURE__ */ n("p", { className: "px-3 py-4 text-center text-slate-400", children: "Nothing picked yet" }) : (() => {
1223
- const e = Kt.filter((i) => !i.format), t = e[0], r = e.slice(1), s = Kt.filter((i) => !!i.format), m = (i, y) => y === "presence" ? i == null || i === "" || Number(i) === 0 ? "No" : "Yes" : i === !0 || i === "true" ? "✓" : i === !1 || i === "false" || i == null || i === "" ? "—" : fe(i, y), o = (i) => /* @__PURE__ */ n("span", { className: "w-20 shrink-0 text-right text-[11px] font-medium text-slate-500", children: i });
1224
- return /* @__PURE__ */ c("div", { children: [
1225
- /* @__PURE__ */ c("div", { className: "flex items-center gap-2 border-b border-slate-200 px-3 py-1.5 dark:border-border", children: [
1304
+ 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 });
1306
+ return /* @__PURE__ */ m("div", { children: [
1307
+ /* @__PURE__ */ m("div", { className: "flex items-center gap-2 border-b border-slate-200 px-3 py-1.5 dark:border-border", children: [
1226
1308
  /* @__PURE__ */ n("span", { className: "flex-1 text-[11px] font-medium text-slate-500", children: "Item" }),
1227
- Nt.map((i) => /* @__PURE__ */ n(Ce, { children: o(re(i)) }, i)),
1228
- o(re(V)),
1229
- vt.map((i) => /* @__PURE__ */ n(Ce, { children: o(re(i)) }, i)),
1230
- !x && /* @__PURE__ */ n("span", { className: "w-6 shrink-0" })
1309
+ vt.map((i) => /* @__PURE__ */ n(Je, { children: o(I(i)) }, i)),
1310
+ o(I(V)),
1311
+ _t.map((i) => /* @__PURE__ */ n(Je, { children: o(I(i)) }, i)),
1312
+ !g && /* @__PURE__ */ n("span", { className: "w-6 shrink-0" })
1231
1313
  ] }),
1232
- de.map((i, y) => {
1233
- const d = i.row.id != null ? String(i.row.id) : null, f = d != null && We.has(d), N = f ? null : ft(i.key), T = f ? null : dr(i.key);
1234
- return /* @__PURE__ */ c(
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);
1316
+ return /* @__PURE__ */ m(
1235
1317
  "div",
1236
1318
  {
1237
- className: z(
1319
+ className: B(
1238
1320
  "border-b border-slate-100 px-3 py-2 last:border-b-0 dark:border-border/50",
1239
- y % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
1240
- N && "bg-amber-50 dark:bg-amber-900/15",
1241
- T && "bg-red-50/70 dark:bg-red-900/15",
1242
- f && "opacity-60"
1321
+ p % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
1322
+ w && "bg-amber-50 dark:bg-amber-900/15",
1323
+ j && "bg-red-50/70 dark:bg-red-900/15",
1324
+ u && "opacity-60"
1243
1325
  ),
1244
1326
  children: [
1245
- /* @__PURE__ */ c(
1327
+ /* @__PURE__ */ m(
1246
1328
  "div",
1247
1329
  {
1248
- className: z(
1330
+ className: B(
1249
1331
  "flex items-center gap-2",
1250
- f && "line-through decoration-slate-400"
1332
+ u && "line-through decoration-slate-400"
1251
1333
  ),
1252
1334
  children: [
1253
- tt(
1335
+ nt(
1254
1336
  i.key,
1255
- Bt(i.key),
1337
+ Ut(i.key),
1256
1338
  "shrink-0 font-semibold text-slate-800 dark:text-slate-100"
1257
1339
  ),
1258
- Pe && !f && (d == null || He.has(d)) && /* @__PURE__ */ n(
1340
+ Pe && !u && (d == null || We.has(d)) && /* @__PURE__ */ n(
1259
1341
  "span",
1260
1342
  {
1261
1343
  "data-catalog-staged": d == null ? "new" : "edited",
@@ -1264,70 +1346,56 @@ function bn({
1264
1346
  children: d == null ? "New" : "Edited"
1265
1347
  }
1266
1348
  ),
1267
- T && /* @__PURE__ */ n(
1349
+ j && /* @__PURE__ */ n(
1268
1350
  "span",
1269
1351
  {
1270
1352
  className: "shrink-0",
1271
1353
  "data-tip": `This line was in the failed submission
1272
- ${T}`,
1354
+ ${j}`,
1273
1355
  "data-submission-error": !0,
1274
- children: /* @__PURE__ */ n(Mt, { className: "h-3.5 w-3.5 text-red-500", strokeWidth: 2 })
1356
+ children: /* @__PURE__ */ n(St, { className: "h-3.5 w-3.5 text-red-500", strokeWidth: 2 })
1275
1357
  }
1276
1358
  ),
1277
1359
  t && /* @__PURE__ */ n(
1278
1360
  "span",
1279
1361
  {
1280
1362
  className: "min-w-0 flex-1 truncate text-slate-600 dark:text-slate-300",
1281
- title: String(Le($e(i.key), t.field) ?? ""),
1282
- children: fe(Le($e(i.key), t.field), void 0)
1363
+ title: String(Ae(qe(i.key), t.field) ?? ""),
1364
+ children: ue(Ae(qe(i.key), t.field), void 0)
1283
1365
  }
1284
1366
  ),
1285
1367
  !t && /* @__PURE__ */ n("span", { className: "flex-1" }),
1286
- r.map((k) => {
1287
- const S = Le($e(i.key), k.field);
1368
+ r.map((N) => {
1369
+ const S = Ae(qe(i.key), N.field);
1288
1370
  return S == null || S === "" ? null : /* @__PURE__ */ n(
1289
1371
  "span",
1290
1372
  {
1291
1373
  className: "shrink-0 rounded bg-slate-100 px-1.5 py-0.5 text-[10.5px] font-medium text-slate-600 dark:bg-muted dark:text-slate-300",
1292
1374
  children: String(S)
1293
1375
  },
1294
- k.field
1376
+ N.field
1295
1377
  );
1296
1378
  }),
1297
- Nt.map(
1298
- (k) => {
1379
+ vt.map(
1380
+ (N) => {
1299
1381
  var S;
1300
- return B.includes(k) && !x ? /* @__PURE__ */ n(
1301
- "input",
1302
- {
1303
- type: "number",
1304
- min: 0,
1305
- step: "any",
1306
- defaultValue: i.row[k] == null ? "" : String(i.row[k]),
1307
- onBlur: (le) => void yr(i.key, k, le.target.value),
1308
- onKeyDown: (le) => {
1309
- le.key === "Enter" && le.currentTarget.blur();
1310
- },
1311
- className: "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"
1312
- },
1313
- `${i.key}:${k}:${String(i.row[k] ?? "")}`
1314
- ) : /* @__PURE__ */ n(
1382
+ return U.includes(N) && !g ? Fr(i.key, N, i.row) : /* @__PURE__ */ n(
1315
1383
  "span",
1316
1384
  {
1317
1385
  className: "w-20 shrink-0 text-right tabular-nums text-slate-600 dark:text-slate-300",
1318
- children: fe(i.row[k], (S = l.field_formats) == null ? void 0 : S[k])
1386
+ children: ue(i.row[N], (S = l.field_formats) == null ? void 0 : S[N])
1319
1387
  },
1320
- k
1388
+ N
1321
1389
  );
1322
1390
  }
1323
1391
  ),
1324
- /* @__PURE__ */ c("span", { className: "inline-flex w-20 shrink-0 items-center justify-end gap-1", children: [
1325
- se.has(i.key) && /* @__PURE__ */ n(oe, { className: "h-3 w-3 animate-spin text-slate-400" }),
1326
- Ae(i.key, $e(i.key))
1392
+ /* @__PURE__ */ m("span", { className: "inline-flex w-20 shrink-0 items-center justify-end gap-1", children: [
1393
+ se.has(i.key) && /* @__PURE__ */ n(ae, { className: "h-3 w-3 animate-spin text-slate-400" }),
1394
+ Ke(i.key, qe(i.key))
1327
1395
  ] }),
1328
- vt.map((k) => {
1329
- var _e, Ht;
1330
- if (f)
1396
+ _t.map((N) => {
1397
+ var ve, It;
1398
+ if (u)
1331
1399
  return /* @__PURE__ */ n(
1332
1400
  "span",
1333
1401
  {
@@ -1335,218 +1403,218 @@ ${T}`,
1335
1403
  className: "w-20 shrink-0 text-right tabular-nums text-slate-400 dark:text-slate-500",
1336
1404
  children: "—"
1337
1405
  },
1338
- k
1406
+ N
1339
1407
  );
1340
- const S = i.row[k], le = S != null && S !== "" ? S : Ke(((_e = l.compute_fields) == null ? void 0 : _e[k]) ?? "", i.row);
1408
+ const S = i.row[N], $e = S != null && S !== "" ? S : Qe(((ve = l.compute_fields) == null ? void 0 : ve[N]) ?? "", i.row);
1341
1409
  return /* @__PURE__ */ n(
1342
1410
  "span",
1343
1411
  {
1344
1412
  className: "w-20 shrink-0 text-right tabular-nums text-slate-600 dark:text-slate-300",
1345
- children: fe(le, (Ht = l.field_formats) == null ? void 0 : Ht[k])
1413
+ children: ue($e, (It = l.field_formats) == null ? void 0 : It[N])
1346
1414
  },
1347
- k
1415
+ N
1348
1416
  );
1349
1417
  }),
1350
- !x && f && /* @__PURE__ */ n(
1418
+ !g && u && /* @__PURE__ */ n(
1351
1419
  "button",
1352
1420
  {
1353
1421
  type: "button",
1354
- onClick: () => p == null ? void 0 : p.cancelPendingDelete(u, g, d),
1422
+ onClick: () => b == null ? void 0 : b.cancelPendingDelete(f, y, d),
1355
1423
  className: "shrink-0 rounded px-1.5 py-0.5 text-[11px] font-medium text-nvr-navy underline dark:text-nvr-cyan",
1356
1424
  children: "Undo"
1357
1425
  }
1358
1426
  ),
1359
- !x && !f && /* @__PURE__ */ n(
1427
+ !g && !u && /* @__PURE__ */ n(
1360
1428
  "button",
1361
1429
  {
1362
1430
  type: "button",
1363
1431
  title: "Remove (applies on Save)",
1364
1432
  onClick: () => {
1365
- if (!A && p && d != null) {
1366
- p.queueDelete(u, g, d);
1433
+ if (!E && b && d != null) {
1434
+ b.queueDelete(f, y, d);
1367
1435
  return;
1368
1436
  }
1369
- nt(i.key, "0", {}, { confirmedRemove: !0 });
1437
+ at(i.key, "0", {}, { confirmedRemove: !0 });
1370
1438
  },
1371
1439
  className: "w-6 shrink-0 rounded p-0.5 text-slate-300 transition-colors hover:text-red-500",
1372
- children: /* @__PURE__ */ n(at, { className: "mx-auto h-3.5 w-3.5" })
1440
+ children: /* @__PURE__ */ n(lt, { className: "mx-auto h-3.5 w-3.5" })
1373
1441
  }
1374
1442
  )
1375
1443
  ]
1376
1444
  }
1377
1445
  ),
1378
- (s.length > 0 || Jt.length > 0 || et.length > 0) && /* @__PURE__ */ c("div", { className: "mt-1 flex flex-wrap items-baseline gap-x-4 gap-y-0.5 pl-0.5 text-[11px]", children: [
1379
- s.map((k) => /* @__PURE__ */ c("span", { className: "whitespace-nowrap", children: [
1380
- /* @__PURE__ */ n("span", { className: "text-slate-500 dark:text-muted-foreground", children: k.label ?? re(k.field.split(".")[0]) }),
1446
+ (s.length > 0 || Bt.length > 0 || rt.length > 0) && /* @__PURE__ */ m("div", { className: "mt-1 flex flex-wrap items-baseline gap-x-4 gap-y-0.5 pl-0.5 text-[11px]", children: [
1447
+ s.map((N) => /* @__PURE__ */ m("span", { className: "whitespace-nowrap", children: [
1448
+ /* @__PURE__ */ n("span", { className: "text-slate-500 dark:text-muted-foreground", children: N.label ?? I(N.field.split(".")[0]) }),
1381
1449
  " ",
1382
- /* @__PURE__ */ n("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: m(Le($e(i.key), k.field), k.format) })
1383
- ] }, k.field)),
1384
- Jt.map((k) => /* @__PURE__ */ c("span", { className: "whitespace-nowrap", children: [
1385
- /* @__PURE__ */ n("span", { className: "text-slate-500 dark:text-muted-foreground", children: k.label ?? re(k.key) }),
1450
+ /* @__PURE__ */ n("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: c(Ae(qe(i.key), N.field), N.format) })
1451
+ ] }, N.field)),
1452
+ Bt.map((N) => /* @__PURE__ */ m("span", { className: "whitespace-nowrap", children: [
1453
+ /* @__PURE__ */ n("span", { className: "text-slate-500 dark:text-muted-foreground", children: N.label ?? I(N.key) }),
1386
1454
  " ",
1387
- /* @__PURE__ */ n("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: m(ut(k.key, i.key), k.format) })
1388
- ] }, k.key)),
1389
- br(i.row),
1390
- ar(i.row).map((k) => /* @__PURE__ */ c(
1455
+ /* @__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
+ ] }, N.key)),
1457
+ wr(i.row),
1458
+ ur(i.row).map((N) => /* @__PURE__ */ m(
1391
1459
  "span",
1392
1460
  {
1393
1461
  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",
1394
- "data-catalog-row-flag": k,
1462
+ "data-catalog-row-flag": N,
1395
1463
  children: [
1396
- /* @__PURE__ */ n(Je, { className: "h-3 w-3" }),
1397
- k
1464
+ /* @__PURE__ */ n(ze, { className: "h-3 w-3" }),
1465
+ N
1398
1466
  ]
1399
1467
  },
1400
- k
1468
+ N
1401
1469
  )),
1402
- et.map((k) => {
1403
- const S = ur(k, i);
1404
- return /* @__PURE__ */ c("span", { className: "whitespace-nowrap", children: [
1405
- /* @__PURE__ */ n("span", { className: "text-slate-500 dark:text-muted-foreground", children: k.label ?? re(k.field) }),
1470
+ rt.map((N) => {
1471
+ const S = yr(N, i);
1472
+ return /* @__PURE__ */ m("span", { className: "whitespace-nowrap", children: [
1473
+ /* @__PURE__ */ n("span", { className: "text-slate-500 dark:text-muted-foreground", children: N.label ?? I(N.field) }),
1406
1474
  " ",
1407
- /* @__PURE__ */ n("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: m(S, k.format) })
1408
- ] }, k.field);
1475
+ /* @__PURE__ */ n("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: c(S, N.format) })
1476
+ ] }, N.field);
1409
1477
  })
1410
1478
  ] }),
1411
- N && /* @__PURE__ */ c("p", { className: "mt-1 flex items-center gap-1 pl-0.5 text-[11px] font-medium text-amber-600 dark:text-amber-400", children: [
1412
- /* @__PURE__ */ n(Je, { className: "h-3 w-3 shrink-0" }),
1479
+ 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
+ /* @__PURE__ */ n(ze, { className: "h-3 w-3 shrink-0" }),
1413
1481
  bt,
1414
1482
  " is ",
1415
- fe(N.available, "number"),
1483
+ ue(w.available, "number"),
1416
1484
  " —",
1417
1485
  " ",
1418
- fe(N.qty, "number"),
1486
+ ue(w.qty, "number"),
1419
1487
  " requested"
1420
1488
  ] }),
1421
- f && /* @__PURE__ */ n("p", { className: "mt-1 pl-0.5 text-[11px] text-red-500", children: "Removed — applies when you save" })
1489
+ u && /* @__PURE__ */ n("p", { className: "mt-1 pl-0.5 text-[11px] text-red-500", children: "Removed — applies when you save" })
1422
1490
  ]
1423
1491
  },
1424
1492
  i.key
1425
1493
  );
1426
1494
  }),
1427
1495
  (() => {
1428
- const i = de.filter((N) => {
1429
- const T = N.row.id != null ? String(N.row.id) : null;
1430
- return !(T != null && We.has(T));
1431
- }), y = (N) => i.reduce((T, k) => {
1432
- const S = Number(k.row[N]);
1433
- return T + (Number.isFinite(S) ? S : 0);
1434
- }, 0), d = (N) => {
1435
- var T;
1436
- return ((T = l.field_formats) == null ? void 0 : T[N]) ?? "number";
1437
- }, f = (N) => /* @__PURE__ */ n(
1496
+ const i = le.filter((w) => {
1497
+ const j = w.row.id != null ? String(w.row.id) : null;
1498
+ return !(j != null && Ye.has(j));
1499
+ }), p = (w) => i.reduce((j, N) => {
1500
+ const S = Number(N.row[w]);
1501
+ return j + (Number.isFinite(S) ? S : 0);
1502
+ }, 0), d = (w) => {
1503
+ var j;
1504
+ return ((j = l.field_formats) == null ? void 0 : j[w]) ?? "number";
1505
+ }, u = (w) => /* @__PURE__ */ n(
1438
1506
  "span",
1439
1507
  {
1440
1508
  className: "w-20 shrink-0 text-right text-[12px] font-semibold tabular-nums text-slate-800 dark:text-slate-100",
1441
- children: fe(y(N), d(N))
1509
+ children: ue(p(w), d(w))
1442
1510
  },
1443
- N
1511
+ w
1444
1512
  );
1445
- return /* @__PURE__ */ c("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: [
1513
+ 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: [
1446
1514
  /* @__PURE__ */ n("span", { className: "flex-1 text-[11px] font-semibold uppercase tracking-wide text-slate-500", children: "Total" }),
1447
- Nt.map((N) => /* @__PURE__ */ n("span", { className: "w-20 shrink-0" }, N)),
1448
- /* @__PURE__ */ n("span", { className: "w-20 shrink-0 text-right text-[12px] font-semibold tabular-nums text-slate-800 dark:text-slate-100", children: fe(y(V), "number") }),
1449
- vt.map(f),
1450
- !x && /* @__PURE__ */ n("span", { className: "w-6 shrink-0" })
1515
+ 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") }),
1517
+ _t.map(u),
1518
+ !g && /* @__PURE__ */ n("span", { className: "w-6 shrink-0" })
1451
1519
  ] });
1452
1520
  })()
1453
1521
  ] });
1454
1522
  })()
1455
1523
  ] }),
1456
- tr && b && /* @__PURE__ */ n(
1457
- Hr,
1524
+ or && x && /* @__PURE__ */ n(
1525
+ Zr,
1458
1526
  {
1459
- catalogCol: b,
1460
- tmpl: H,
1527
+ catalogCol: x,
1528
+ tmpl: ee,
1461
1529
  sectionBy: l.section_by,
1462
1530
  sectionM2M: Q,
1463
- pinnedSet: ot,
1464
- pinnedIds: ge,
1465
- savingIds: Ze,
1531
+ pinnedSet: dt,
1532
+ pinnedIds: xe,
1533
+ savingIds: Xe,
1466
1534
  relatedCols: (l.favorites_manager_columns ?? []).map((e) => (l.related_columns ?? []).find((t) => t.key === e)).filter((e) => !!e),
1467
- parentDraft: ee,
1468
- onToggle: (e) => void Ot(e),
1469
- onClose: () => Pt(!1),
1470
- anchor: Rt.current
1535
+ parentDraft: te,
1536
+ onToggle: (e) => void Et(e),
1537
+ onClose: () => Lt(!1),
1538
+ anchor: At.current
1471
1539
  }
1472
1540
  )
1473
- ] }) : /* @__PURE__ */ c("p", { className: "py-1 text-[12px] text-slate-400", children: [
1541
+ ] }) : /* @__PURE__ */ m("p", { className: "py-1 text-[12px] text-slate-400", children: [
1474
1542
  'Catalog picker: field "',
1475
1543
  l.item_field,
1476
1544
  '" does not resolve to an M2O relation on',
1477
1545
  " ",
1478
- u
1546
+ f
1479
1547
  ] });
1480
1548
  }
1481
- function Dr({
1482
- builder: u,
1483
- defaultItemField: g,
1549
+ function Ir({
1550
+ builder: f,
1551
+ defaultItemField: y,
1484
1552
  catalogCol: _,
1485
1553
  catalogFields: q,
1486
1554
  tmpl: l,
1487
- qtyInput: x,
1555
+ qtyInput: g,
1488
1556
  currentQty: h
1489
1557
  }) {
1490
- const $ = $t(), p = u.item_field ?? g, [L, Z] = Y(!1), [B, A] = Y({}), V = O(
1558
+ const $ = Ft(), b = f.item_field ?? y, [P, Z] = Y(!1), [U, E] = Y({}), V = O(
1491
1559
  () => [
1492
1560
  "id",
1493
- p,
1494
- ...u.attributes.flatMap((v) => [`${v.field}.id`, `${v.field}.${v.label_field}`])
1561
+ b,
1562
+ ...f.attributes.flatMap((v) => [`${v.field}.id`, `${v.field}.${v.label_field}`])
1495
1563
  ].join(","),
1496
- [p, u.attributes]
1497
- ), { data: ce = [], isLoading: ne } = J({
1564
+ [b, f.attributes]
1565
+ ), { data: oe = [], isLoading: ne } = z({
1498
1566
  queryKey: [
1499
1567
  "catalog-builder",
1500
- u.collection,
1568
+ f.collection,
1501
1569
  V,
1502
- JSON.stringify(u.filter ?? null)
1570
+ JSON.stringify(f.filter ?? null)
1503
1571
  ],
1504
1572
  queryFn: () => $.request(
1505
- P(`/items/${u.collection}`, {
1573
+ R(`/items/${f.collection}`, {
1506
1574
  limit: 2e3,
1507
1575
  fields: V,
1508
- ...u.filter ? { filter: JSON.stringify(u.filter) } : {}
1576
+ ...f.filter ? { filter: JSON.stringify(f.filter) } : {}
1509
1577
  })
1510
1578
  ).then((v) => v.data ?? []),
1511
- enabled: L,
1579
+ enabled: P,
1512
1580
  staleTime: 6e4
1513
- }), ye = (v, F) => {
1514
- var D;
1515
- const j = v[F];
1516
- if (j == null) return null;
1517
- if (typeof j == "object") {
1518
- const K = j, b = ((D = u.attributes.find((me) => me.field === F)) == null ? void 0 : D.label_field) ?? "id";
1519
- return { id: String(K.id ?? ""), label: String(K[b] ?? K.id ?? "") };
1581
+ }), ge = (v, T) => {
1582
+ var W;
1583
+ const F = v[T];
1584
+ if (F == null) return null;
1585
+ if (typeof F == "object") {
1586
+ const L = F, K = ((W = f.attributes.find((de) => de.field === T)) == null ? void 0 : W.label_field) ?? "id";
1587
+ return { id: String(L.id ?? ""), label: String(L[K] ?? L.id ?? "") };
1520
1588
  }
1521
- return { id: String(j), label: String(j) };
1522
- }, C = (v) => ce.filter(
1523
- (F) => u.attributes.slice(0, v).every((j) => {
1524
- var K;
1525
- const D = B[j.field];
1526
- return D ? ((K = ye(F, j.field)) == null ? void 0 : K.id) === D : !0;
1589
+ return { id: String(F), label: String(F) };
1590
+ }, C = (v) => oe.filter(
1591
+ (T) => f.attributes.slice(0, v).every((F) => {
1592
+ var L;
1593
+ const W = U[F.field];
1594
+ return W ? ((L = ge(T, F.field)) == null ? void 0 : L.id) === W : !0;
1527
1595
  })
1528
- ), ke = u.attributes.every((v) => B[v.field]), pe = ke ? ce.find(
1529
- (v) => u.attributes.every((F) => {
1530
- var j;
1531
- return ((j = ye(v, F.field)) == null ? void 0 : j.id) === B[F.field];
1596
+ ), ye = f.attributes.every((v) => U[v.field]), pe = ye ? oe.find(
1597
+ (v) => f.attributes.every((T) => {
1598
+ var F;
1599
+ return ((F = ge(v, T.field)) == null ? void 0 : F.id) === U[T.field];
1532
1600
  })
1533
- ) : void 0, G = (pe == null ? void 0 : pe[p]) != null ? String(pe[p]) : null, { data: se } = J({
1601
+ ) : void 0, G = (pe == null ? void 0 : pe[b]) != null ? String(pe[b]) : null, { data: se } = z({
1534
1602
  queryKey: ["catalog-builder-item", _, q, G],
1535
1603
  queryFn: () => $.request(
1536
- P(`/items/${_}`, {
1604
+ R(`/items/${_}`, {
1537
1605
  filter: JSON.stringify({ id: { _eq: G } }),
1538
1606
  fields: q,
1539
1607
  limit: 1
1540
1608
  })
1541
1609
  ).then((v) => {
1542
- var F;
1543
- return ((F = v.data) == null ? void 0 : F[0]) ?? null;
1610
+ var T;
1611
+ return ((T = v.data) == null ? void 0 : T[0]) ?? null;
1544
1612
  }),
1545
1613
  enabled: !!G,
1546
1614
  staleTime: 6e4
1547
1615
  });
1548
- return /* @__PURE__ */ c("div", { className: "rounded-lg border border-slate-200 text-[12px] dark:border-border", children: [
1549
- /* @__PURE__ */ c(
1616
+ return /* @__PURE__ */ m("div", { className: "rounded-lg border border-slate-200 text-[12px] dark:border-border", children: [
1617
+ /* @__PURE__ */ m(
1550
1618
  "button",
1551
1619
  {
1552
1620
  type: "button",
@@ -1554,157 +1622,157 @@ function Dr({
1554
1622
  className: "flex w-full items-center gap-1.5 rounded-t-lg bg-slate-100/80 px-2 py-1.5 text-left dark:bg-muted",
1555
1623
  children: [
1556
1624
  /* @__PURE__ */ n(
1557
- qt,
1625
+ jt,
1558
1626
  {
1559
- className: z(
1627
+ className: B(
1560
1628
  "h-3 w-3 shrink-0 text-slate-400 transition-transform",
1561
- L && "rotate-90"
1629
+ P && "rotate-90"
1562
1630
  )
1563
1631
  }
1564
1632
  ),
1565
- /* @__PURE__ */ n("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: u.label })
1633
+ /* @__PURE__ */ n("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: f.label })
1566
1634
  ]
1567
1635
  }
1568
1636
  ),
1569
- L && /* @__PURE__ */ n("div", { className: "space-y-2 border-t border-slate-200 p-3 dark:border-border", children: ne ? /* @__PURE__ */ c("div", { className: "flex items-center gap-2 py-2 text-slate-400", children: [
1570
- /* @__PURE__ */ n(oe, { className: "h-4 w-4 animate-spin" }),
1637
+ P && /* @__PURE__ */ n("div", { className: "space-y-2 border-t border-slate-200 p-3 dark:border-border", children: ne ? /* @__PURE__ */ m("div", { className: "flex items-center gap-2 py-2 text-slate-400", children: [
1638
+ /* @__PURE__ */ n(ae, { className: "h-4 w-4 animate-spin" }),
1571
1639
  " Loading options…"
1572
- ] }) : /* @__PURE__ */ c("div", { className: "flex flex-wrap items-end gap-3", children: [
1573
- u.attributes.map((v, F) => {
1574
- const j = /* @__PURE__ */ new Map();
1575
- for (const K of C(F)) {
1576
- const b = ye(K, v.field);
1577
- b != null && b.id && j.set(b.id, b.label);
1640
+ ] }) : /* @__PURE__ */ m("div", { className: "flex flex-wrap items-end gap-3", children: [
1641
+ f.attributes.map((v, T) => {
1642
+ const F = /* @__PURE__ */ new Map();
1643
+ for (const L of C(T)) {
1644
+ const K = ge(L, v.field);
1645
+ K != null && K.id && F.set(K.id, K.label);
1578
1646
  }
1579
- const D = [...j.entries()].sort(
1580
- ([, K], [, b]) => K.localeCompare(b, void 0, { numeric: !0 })
1647
+ const W = [...F.entries()].sort(
1648
+ ([, L], [, K]) => L.localeCompare(K, void 0, { numeric: !0 })
1581
1649
  );
1582
1650
  return /* @__PURE__ */ n(
1583
- Ur,
1651
+ Yr,
1584
1652
  {
1585
- label: re(v.field),
1586
- value: B[v.field] ?? null,
1587
- valueLabel: B[v.field] ? j.get(B[v.field]) ?? B[v.field] : null,
1588
- options: D,
1589
- disabled: F > 0 && !B[u.attributes[F - 1].field],
1590
- onChange: (K) => A((b) => {
1591
- const me = {};
1592
- for (let X = 0; X < F; X++) {
1593
- const U = u.attributes[X].field;
1594
- b[U] && (me[U] = b[U]);
1653
+ label: I(v.field),
1654
+ value: U[v.field] ?? null,
1655
+ valueLabel: U[v.field] ? F.get(U[v.field]) ?? U[v.field] : null,
1656
+ options: W,
1657
+ disabled: T > 0 && !U[f.attributes[T - 1].field],
1658
+ onChange: (L) => E((K) => {
1659
+ const de = {};
1660
+ for (let x = 0; x < T; x++) {
1661
+ const be = f.attributes[x].field;
1662
+ K[be] && (de[be] = K[be]);
1595
1663
  }
1596
- return K && (me[v.field] = K), me;
1664
+ return L && (de[v.field] = L), de;
1597
1665
  })
1598
1666
  },
1599
1667
  v.field
1600
1668
  );
1601
1669
  }),
1602
- /* @__PURE__ */ n("div", { className: "flex min-h-[28px] flex-1 items-center gap-2", children: G && se ? /* @__PURE__ */ c(_t, { children: [
1670
+ /* @__PURE__ */ n("div", { className: "flex min-h-[28px] flex-1 items-center gap-2", children: G && se ? /* @__PURE__ */ m(qt, { children: [
1603
1671
  /* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate text-slate-700 dark:text-slate-200", children: Fe(l, se) }),
1604
1672
  (h(G) ?? 0) > 0 && /* @__PURE__ */ n("span", { className: "rounded bg-nvr-cyan/10 px-1.5 py-0.5 text-[10px] font-semibold text-[#009abe]", children: "picked" }),
1605
- x(G, se)
1606
- ] }) : ke ? /* @__PURE__ */ n("span", { className: "text-slate-400", children: "No matching item for this combination" }) : /* @__PURE__ */ n("span", { className: "text-slate-400", children: "Pick each attribute to resolve an item" }) })
1673
+ g(G, se)
1674
+ ] }) : ye ? /* @__PURE__ */ n("span", { className: "text-slate-400", children: "No matching item for this combination" }) : /* @__PURE__ */ n("span", { className: "text-slate-400", children: "Pick each attribute to resolve an item" }) })
1607
1675
  ] }) })
1608
1676
  ] });
1609
1677
  }
1610
- function Ur({
1611
- label: u,
1612
- value: g,
1678
+ function Yr({
1679
+ label: f,
1680
+ value: y,
1613
1681
  valueLabel: _,
1614
1682
  options: q,
1615
1683
  disabled: l,
1616
- onChange: x
1684
+ onChange: g
1617
1685
  }) {
1618
- const [h, $] = Y(!1), p = ze(null);
1686
+ const [h, $] = Y(!1), b = Ve(null);
1619
1687
  return je(() => {
1620
1688
  if (!h) return;
1621
- const L = (Z) => {
1622
- p.current && !p.current.contains(Z.target) && $(!1);
1689
+ const P = (Z) => {
1690
+ b.current && !b.current.contains(Z.target) && $(!1);
1623
1691
  };
1624
- return document.addEventListener("mousedown", L), () => document.removeEventListener("mousedown", L);
1625
- }, [h]), /* @__PURE__ */ c("div", { ref: p, className: "relative", children: [
1626
- /* @__PURE__ */ n("p", { className: "mb-1 text-[10px] font-medium text-slate-500 dark:text-slate-400", children: u }),
1627
- /* @__PURE__ */ c(
1692
+ return document.addEventListener("mousedown", P), () => document.removeEventListener("mousedown", P);
1693
+ }, [h]), /* @__PURE__ */ m("div", { ref: b, className: "relative", children: [
1694
+ /* @__PURE__ */ n("p", { className: "mb-1 text-[10px] font-medium text-slate-500 dark:text-slate-400", children: f }),
1695
+ /* @__PURE__ */ m(
1628
1696
  "button",
1629
1697
  {
1630
1698
  type: "button",
1631
1699
  disabled: l,
1632
- onClick: () => $((L) => !L),
1700
+ onClick: () => $((P) => !P),
1633
1701
  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",
1634
1702
  children: [
1635
- /* @__PURE__ */ n("span", { className: z("truncate", !_ && "text-slate-400"), children: _ ?? "Select…" }),
1636
- /* @__PURE__ */ n(vr, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
1703
+ /* @__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" })
1637
1705
  ]
1638
1706
  }
1639
1707
  ),
1640
- h && /* @__PURE__ */ c("div", { className: "absolute z-50 mt-1 max-h-52 w-44 overflow-y-auto rounded-md border border-border bg-popover py-1 shadow-md", children: [
1641
- g && /* @__PURE__ */ c(
1708
+ h && /* @__PURE__ */ m("div", { className: "absolute z-50 mt-1 max-h-52 w-44 overflow-y-auto rounded-md border border-border bg-popover py-1 shadow-md", children: [
1709
+ y && /* @__PURE__ */ m(
1642
1710
  "button",
1643
1711
  {
1644
1712
  type: "button",
1645
1713
  onClick: () => {
1646
- x(null), $(!1);
1714
+ g(null), $(!1);
1647
1715
  },
1648
1716
  className: "flex w-full items-center gap-1.5 border-b border-slate-100 px-2 py-1 text-left text-[12px] text-slate-500 hover:bg-muted dark:border-border dark:text-slate-400",
1649
1717
  children: [
1650
- /* @__PURE__ */ n(at, { className: "h-3 w-3 text-slate-400" }),
1718
+ /* @__PURE__ */ n(lt, { className: "h-3 w-3 text-slate-400" }),
1651
1719
  " Clear"
1652
1720
  ]
1653
1721
  }
1654
1722
  ),
1655
- q.map(([L, Z]) => /* @__PURE__ */ n(
1723
+ q.map(([P, Z]) => /* @__PURE__ */ n(
1656
1724
  "button",
1657
1725
  {
1658
1726
  type: "button",
1659
1727
  onClick: () => {
1660
- x(L), $(!1);
1728
+ g(P), $(!1);
1661
1729
  },
1662
- className: z(
1730
+ className: B(
1663
1731
  "block w-full truncate px-2 py-1 text-left text-[12px] hover:bg-muted",
1664
- L === g ? "font-medium text-nvr-cyan" : "text-slate-700 dark:text-slate-200"
1732
+ P === y ? "font-medium text-nvr-cyan" : "text-slate-700 dark:text-slate-200"
1665
1733
  ),
1666
1734
  children: Z
1667
1735
  },
1668
- L
1736
+ P
1669
1737
  ))
1670
1738
  ] })
1671
1739
  ] });
1672
1740
  }
1673
- function Hr({
1674
- catalogCol: u,
1675
- tmpl: g,
1741
+ function Zr({
1742
+ catalogCol: f,
1743
+ tmpl: y,
1676
1744
  sectionBy: _,
1677
1745
  sectionM2M: q,
1678
1746
  pinnedSet: l,
1679
- pinnedIds: x,
1747
+ pinnedIds: g,
1680
1748
  savingIds: h,
1681
1749
  relatedCols: $,
1682
- parentDraft: p,
1683
- onToggle: L,
1750
+ parentDraft: b,
1751
+ onToggle: P,
1684
1752
  onClose: Z,
1685
- anchor: B
1753
+ anchor: U
1686
1754
  }) {
1687
- const A = $t(), [V, ce] = Y(""), [ne, ye] = Y(""), [C, ke] = Y(1), pe = ze(null);
1755
+ const E = Ft(), [V, oe] = Y(""), [ne, ge] = Y(""), [C, ye] = Y(1), pe = Ve(null);
1688
1756
  je(() => {
1689
- const a = setTimeout(() => ye(V), 300);
1757
+ const a = setTimeout(() => ge(V), 300);
1690
1758
  return () => clearTimeout(a);
1691
- }, [V]), je(() => ke(1), [ne]), je(() => {
1759
+ }, [V]), je(() => ye(1), [ne]), je(() => {
1692
1760
  var a;
1693
1761
  (a = pe.current) == null || a.focus();
1694
1762
  }, []), je(() => {
1695
- const a = (w) => {
1696
- w.key === "Escape" && (w.stopPropagation(), Z());
1763
+ const a = (k) => {
1764
+ k.key === "Escape" && (k.stopPropagation(), Z());
1697
1765
  };
1698
1766
  return window.addEventListener("keydown", a, !0), () => window.removeEventListener("keydown", a, !0);
1699
1767
  }, [Z]);
1700
1768
  const G = O(() => {
1701
- var w;
1702
- const a = (w = [...(g ?? "").matchAll(/\{\{([\w.]+)\}\}/g)][0]) == null ? void 0 : w[1];
1769
+ var k;
1770
+ const a = (k = [...(y ?? "").matchAll(/\{\{([\w.]+)\}\}/g)][0]) == null ? void 0 : k[1];
1703
1771
  return a && !a.includes(".") ? a : "id";
1704
- }, [g]), se = !q && _.includes(".") ? `*,${_}` : "*", v = 50, { data: F, isFetching: j } = J({
1705
- queryKey: ["favorites-manager-list", u, ne, G, C],
1706
- queryFn: () => A.request(
1707
- P(`/items/${u}`, {
1772
+ }, [y]), se = !q && _.includes(".") ? `*,${_}` : "*", v = 50, { data: T, isFetching: F } = z({
1773
+ queryKey: ["favorites-manager-list", f, ne, G, C],
1774
+ queryFn: () => E.request(
1775
+ R(`/items/${f}`, {
1708
1776
  fields: se,
1709
1777
  limit: v,
1710
1778
  page: C,
@@ -1714,153 +1782,153 @@ function Hr({
1714
1782
  ),
1715
1783
  staleTime: 3e4,
1716
1784
  placeholderData: (a) => a
1717
- }), D = ((F == null ? void 0 : F.data) ?? []).filter((a) => !l.has(String(a.id))), K = (F == null ? void 0 : F.total) ?? D.length, b = Math.max(1, Math.ceil(K / v)), { data: me = [] } = J({
1718
- queryKey: ["favorites-manager-pinned", u, se, x.join(",")],
1719
- queryFn: () => A.request(
1720
- P(`/items/${u}`, {
1721
- filter: JSON.stringify({ id: { _in: x } }),
1785
+ }), W = ((T == null ? void 0 : T.data) ?? []).filter((a) => !l.has(String(a.id))), L = (T == null ? void 0 : T.total) ?? W.length, K = Math.max(1, Math.ceil(L / v)), { data: de = [] } = z({
1786
+ queryKey: ["favorites-manager-pinned", f, se, g.join(",")],
1787
+ queryFn: () => E.request(
1788
+ R(`/items/${f}`, {
1789
+ filter: JSON.stringify({ id: { _in: g } }),
1722
1790
  fields: se,
1723
- limit: x.length,
1791
+ limit: g.length,
1724
1792
  sort: G
1725
1793
  })
1726
1794
  ).then((a) => a.data ?? []),
1727
- enabled: x.length > 0,
1795
+ enabled: g.length > 0,
1728
1796
  staleTime: 3e4
1729
- }), X = O(() => {
1797
+ }), x = O(() => {
1730
1798
  const a = /* @__PURE__ */ new Set();
1731
- for (const w of D) a.add(String(w.id));
1732
- for (const w of x) a.add(w);
1799
+ for (const k of W) a.add(String(k.id));
1800
+ for (const k of g) a.add(k);
1733
1801
  return [...a];
1734
- }, [D, x]), { data: U = /* @__PURE__ */ new Map() } = J({
1735
- queryKey: ["favorites-manager-sections", q == null ? void 0 : q.junction, X.join(",")],
1802
+ }, [W, g]), { data: be = /* @__PURE__ */ new Map() } = z({
1803
+ queryKey: ["favorites-manager-sections", q == null ? void 0 : q.junction, x.join(",")],
1736
1804
  queryFn: async () => {
1737
- const a = q, w = await it(A, `/items/${a.junction}`, {
1805
+ const a = q, k = await ot(E, `/items/${a.junction}`, {
1738
1806
  fields: `${a.fkToItem},${a.fkToSection}`,
1739
- filter: JSON.stringify({ [a.fkToItem]: { _in: X } })
1740
- }), E = [...new Set(w.map((M) => String(M[a.fkToSection])))], ie = E.length ? await it(A, `/items/${a.target}`, {
1807
+ 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}`, {
1741
1809
  fields: `id,${a.labelPath}`,
1742
- filter: JSON.stringify({ id: { _in: E } })
1743
- }) : [], te = new Map(
1744
- ie.map((M) => [String(M.id), String(Xt(M, a.labelPath) ?? "")])
1745
- ), I = /* @__PURE__ */ new Map();
1746
- for (const M of w) {
1747
- const W = te.get(String(M[a.fkToSection]));
1748
- if (!W) continue;
1749
- const we = String(M[a.fkToItem]), Ne = I.get(we) ?? [];
1750
- Ne.includes(W) || Ne.push(W), I.set(we, Ne);
1810
+ filter: JSON.stringify({ id: { _in: D } })
1811
+ }) : [], re = new Map(
1812
+ J.map((H) => [String(H.id), String(ar(H, a.labelPath) ?? "")])
1813
+ ), M = /* @__PURE__ */ new Map();
1814
+ for (const H of k) {
1815
+ const ie = re.get(String(H[a.fkToSection]));
1816
+ if (!ie) continue;
1817
+ const me = String(H[a.fkToItem]), ke = M.get(me) ?? [];
1818
+ ke.includes(ie) || ke.push(ie), M.set(me, ke);
1751
1819
  }
1752
- return I;
1820
+ return M;
1753
1821
  },
1754
- enabled: !!q && X.length > 0,
1822
+ enabled: !!q && x.length > 0,
1755
1823
  staleTime: 6e4
1756
- }), H = (a) => g ? Fe(g, a) : String(a.cifa_number ?? a.name ?? `#${a.id}`), R = (a) => {
1757
- const w = a.description ?? a.long_description ?? a.name;
1758
- return typeof w == "string" && w.trim() && w.trim() !== H(a) ? w : "";
1759
- }, ue = (a) => {
1760
- if (q) return (U.get(String(a.id)) ?? []).join(", ");
1824
+ }), _e = (a) => y ? Fe(y, a) : String(a.cifa_number ?? a.name ?? `#${a.id}`), Oe = (a) => {
1825
+ const k = a.description ?? a.long_description ?? a.name;
1826
+ return typeof k == "string" && k.trim() && k.trim() !== _e(a) ? k : "";
1827
+ }, X = (a) => {
1828
+ if (q) return (be.get(String(a.id)) ?? []).join(", ");
1761
1829
  if (!_) return "";
1762
- const w = Fe(`{{${_}}}`, a);
1763
- return w === `{{${_}}}` ? "" : w;
1764
- }, Ve = (a, w) => {
1765
- if (w === "presence")
1830
+ const k = Fe(`{{${_}}}`, a);
1831
+ return k === `{{${_}}}` ? "" : k;
1832
+ }, ee = (a, k) => {
1833
+ if (k === "presence")
1766
1834
  return a == null || a === "" || Number(a) === 0 ? "No" : "Yes";
1767
1835
  if (a == null || a === "") return "—";
1768
- const E = Number(a);
1769
- return w === "currency" && Number.isFinite(E) ? E.toLocaleString("en-US", { style: "currency", currency: "USD" }) : w === "number" && Number.isFinite(E) ? E.toLocaleString() : String(a);
1770
- }, Q = St({
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);
1838
+ }, A = $t({
1771
1839
  queries: $.map((a) => {
1772
- const w = Be(a.match, p);
1840
+ const k = De(a.match, b);
1773
1841
  return {
1774
1842
  queryKey: [
1775
1843
  "favorites-manager-related",
1776
1844
  a.key,
1777
1845
  a.collection,
1778
- JSON.stringify(w),
1779
- X.join(",")
1846
+ JSON.stringify(k),
1847
+ x.join(",")
1780
1848
  ],
1781
1849
  queryFn: async () => {
1782
- const E = await A.request(
1783
- P(`/items/${a.collection}`, {
1784
- filter: JSON.stringify({ [a.item_field]: { _in: X }, ...w ?? {} }),
1850
+ const D = await E.request(
1851
+ R(`/items/${a.collection}`, {
1852
+ filter: JSON.stringify({ [a.item_field]: { _in: x }, ...k ?? {} }),
1785
1853
  fields: `${a.item_field},${a.value_field}`,
1786
1854
  limit: 1e3
1787
1855
  })
1788
- ).then((te) => te.data ?? []), ie = /* @__PURE__ */ new Map();
1789
- for (const te of E) {
1790
- const I = String(te[a.item_field]), M = te[a.value_field], W = ie.get(I);
1791
- W === void 0 ? ie.set(I, M) : Number.isFinite(Number(W)) && Number.isFinite(Number(M)) && ie.set(I, Number(W) + Number(M));
1856
+ ).then((re) => re.data ?? []), J = /* @__PURE__ */ new Map();
1857
+ for (const re of D) {
1858
+ const M = String(re[a.item_field]), H = re[a.value_field], ie = J.get(M);
1859
+ ie === void 0 ? J.set(M, H) : Number.isFinite(Number(ie)) && Number.isFinite(Number(H)) && J.set(M, Number(ie) + Number(H));
1792
1860
  }
1793
- return ie;
1861
+ return J;
1794
1862
  },
1795
- enabled: X.length > 0 && (a.match === void 0 || w !== null),
1863
+ enabled: x.length > 0 && (a.match === void 0 || k !== null),
1796
1864
  staleTime: 3e4
1797
1865
  };
1798
1866
  })
1799
- }), ee = $.filter(
1800
- (a) => a.match !== void 0 && Be(a.match, p) === null
1801
- ), Te = (a) => {
1802
- const w = l.has(a);
1867
+ }), ce = $.filter(
1868
+ (a) => a.match !== void 0 && De(a.match, b) === null
1869
+ ), Ue = (a) => {
1870
+ const k = l.has(a);
1803
1871
  return /* @__PURE__ */ n(
1804
1872
  "button",
1805
1873
  {
1806
1874
  type: "button",
1807
- title: w ? "Remove from favorites" : "Add to favorites",
1875
+ title: k ? "Remove from favorites" : "Add to favorites",
1808
1876
  disabled: h.has(a),
1809
- onClick: () => L(a),
1877
+ onClick: () => P(a),
1810
1878
  className: "shrink-0 rounded p-1 transition-colors hover:bg-amber-100/60 dark:hover:bg-amber-400/10",
1811
- children: h.has(a) ? /* @__PURE__ */ n(oe, { className: "h-4 w-4 animate-spin text-amber-400" }) : /* @__PURE__ */ n(
1812
- Qe,
1879
+ children: h.has(a) ? /* @__PURE__ */ n(ae, { className: "h-4 w-4 animate-spin text-amber-400" }) : /* @__PURE__ */ n(
1880
+ Be,
1813
1881
  {
1814
- className: z(
1882
+ className: B(
1815
1883
  "h-4 w-4",
1816
- w ? "fill-amber-400 text-amber-400" : "text-slate-300 hover:text-amber-400"
1884
+ k ? "fill-amber-400 text-amber-400" : "text-slate-300 hover:text-amber-400"
1817
1885
  )
1818
1886
  }
1819
1887
  )
1820
1888
  }
1821
1889
  );
1822
- }, he = (a, w) => /* @__PURE__ */ n("tr", { children: /* @__PURE__ */ n("td", { colSpan: 4 + $.length, className: z("border-b px-3 py-1.5", w), children: a }) }), ae = (a, w) => {
1823
- const E = String(a.id), ie = R(a);
1824
- return /* @__PURE__ */ c(
1890
+ }, 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);
1892
+ return /* @__PURE__ */ m(
1825
1893
  "tr",
1826
1894
  {
1827
- className: z(
1895
+ className: B(
1828
1896
  "border-b border-slate-100 dark:border-border/50",
1829
- w % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30"
1897
+ k % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30"
1830
1898
  ),
1831
1899
  children: [
1832
- /* @__PURE__ */ n("td", { className: "px-2 py-1", children: Te(E) }),
1833
- /* @__PURE__ */ n("td", { className: "px-2 py-1 font-medium tabular-nums text-slate-700 dark:text-slate-200", children: Zt(u) ? /* @__PURE__ */ n(
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(
1834
1902
  "button",
1835
1903
  {
1836
1904
  type: "button",
1837
- onClick: () => Gt(u, E, p),
1905
+ onClick: () => sr(f, D, b),
1838
1906
  title: "View stock & planning detail",
1839
1907
  className: "text-left underline decoration-slate-300 decoration-1 underline-offset-2 hover:text-[#009abe] hover:decoration-[#009abe] dark:decoration-slate-600",
1840
- children: H(a)
1908
+ children: _e(a)
1841
1909
  }
1842
- ) : H(a) }),
1843
- /* @__PURE__ */ n("td", { className: "max-w-0 px-2 py-1", children: /* @__PURE__ */ n("p", { className: "truncate text-slate-600 dark:text-slate-300", "data-tip": ie || void 0, children: ie || "—" }) }),
1844
- /* @__PURE__ */ n("td", { className: "px-2 py-1", children: /* @__PURE__ */ n("p", { className: "truncate text-slate-500 dark:text-slate-400", children: ue(a) || "—" }) }),
1845
- $.map((te, I) => {
1846
- var we, Ne;
1847
- const M = te.match !== void 0 && Be(te.match, p) === null, W = M || (Ne = (we = Q[I]) == null ? void 0 : we.data) == null ? void 0 : Ne.get(E);
1910
+ ) : _e(a) }),
1911
+ /* @__PURE__ */ n("td", { className: "max-w-0 px-2 py-1", children: /* @__PURE__ */ n("p", { className: "truncate text-slate-600 dark:text-slate-300", "data-tip": J || void 0, children: J || "—" }) }),
1912
+ /* @__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
+ $.map((re, M) => {
1914
+ 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);
1848
1916
  return /* @__PURE__ */ n(
1849
1917
  "td",
1850
1918
  {
1851
1919
  className: "whitespace-nowrap px-2 py-1 text-right tabular-nums text-slate-600 dark:text-slate-300",
1852
- children: M ? "—" : Ve(W, te.format)
1920
+ children: H ? "—" : ee(ie, re.format)
1853
1921
  },
1854
- te.key
1922
+ re.key
1855
1923
  );
1856
1924
  })
1857
1925
  ]
1858
1926
  },
1859
- E
1927
+ D
1860
1928
  );
1861
- }, xe = (B == null ? void 0 : B.closest('[role="dialog"]')) ?? document.body, Oe = V.trim() ? me.filter((a) => Pr(`${H(a)} ${R(a)} ${ue(a)}`, V)) : me;
1862
- return _r(
1863
- /* @__PURE__ */ c("div", { className: "fixed inset-0 z-[125]", role: "presentation", children: [
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(
1931
+ /* @__PURE__ */ m("div", { className: "fixed inset-0 z-[125]", role: "presentation", children: [
1864
1932
  /* @__PURE__ */ n(
1865
1933
  "div",
1866
1934
  {
@@ -1868,7 +1936,7 @@ function Hr({
1868
1936
  onClick: Z
1869
1937
  }
1870
1938
  ),
1871
- /* @__PURE__ */ c(
1939
+ /* @__PURE__ */ m(
1872
1940
  "div",
1873
1941
  {
1874
1942
  role: "dialog",
@@ -1876,9 +1944,9 @@ function Hr({
1876
1944
  style: { width: "50vw" },
1877
1945
  className: "absolute inset-y-0 right-0 flex flex-col border-l border-slate-200 bg-white shadow-2xl motion-safe:animate-in motion-safe:slide-in-from-right dark:border-border dark:bg-background",
1878
1946
  children: [
1879
- /* @__PURE__ */ c("div", { className: "flex items-start gap-2.5 border-b border-slate-200 px-4 py-3 dark:border-border", children: [
1880
- /* @__PURE__ */ n(Qe, { className: "mt-0.5 h-4 w-4 shrink-0 fill-amber-400 text-amber-400" }),
1881
- /* @__PURE__ */ c("div", { className: "min-w-0 flex-1", children: [
1947
+ /* @__PURE__ */ m("div", { className: "flex items-start gap-2.5 border-b border-slate-200 px-4 py-3 dark:border-border", children: [
1948
+ /* @__PURE__ */ n(Be, { className: "mt-0.5 h-4 w-4 shrink-0 fill-amber-400 text-amber-400" }),
1949
+ /* @__PURE__ */ m("div", { className: "min-w-0 flex-1", children: [
1882
1950
  /* @__PURE__ */ n("p", { className: "text-[13px] font-semibold text-slate-800 dark:text-slate-100", children: "CIFA favorites" }),
1883
1951
  /* @__PURE__ */ n("p", { className: "text-[11px] leading-snug text-slate-500 dark:text-slate-400", children: "Browse the full catalog and star items — favorites appear at the top of every request's item list." })
1884
1952
  ] }),
@@ -1889,19 +1957,19 @@ function Hr({
1889
1957
  onClick: Z,
1890
1958
  className: "shrink-0 rounded p-1 text-slate-400 transition-colors hover:bg-slate-100 hover:text-slate-600 dark:hover:bg-white/[0.06]",
1891
1959
  "aria-label": "Close",
1892
- children: /* @__PURE__ */ n(at, { className: "h-4 w-4" })
1960
+ children: /* @__PURE__ */ n(lt, { className: "h-4 w-4" })
1893
1961
  }
1894
1962
  )
1895
1963
  ] }),
1896
- /* @__PURE__ */ c("div", { className: "border-b border-slate-200 px-3 py-2 dark:border-border", children: [
1897
- /* @__PURE__ */ c("div", { className: "flex items-center gap-2 rounded-md border border-slate-200 bg-slate-50 px-2.5 py-1.5 focus-within:border-nvr-cyan focus-within:bg-white dark:border-border dark:bg-muted/40 dark:focus-within:bg-background", children: [
1898
- /* @__PURE__ */ n(st, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
1964
+ /* @__PURE__ */ m("div", { className: "border-b border-slate-200 px-3 py-2 dark:border-border", children: [
1965
+ /* @__PURE__ */ m("div", { className: "flex items-center gap-2 rounded-md border border-slate-200 bg-slate-50 px-2.5 py-1.5 focus-within:border-nvr-cyan focus-within:bg-white dark:border-border dark:bg-muted/40 dark:focus-within:bg-background", children: [
1966
+ /* @__PURE__ */ n(it, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
1899
1967
  /* @__PURE__ */ n(
1900
1968
  "input",
1901
1969
  {
1902
1970
  ref: pe,
1903
1971
  value: V,
1904
- onChange: (a) => ce(a.target.value),
1972
+ onChange: (a) => oe(a.target.value),
1905
1973
  placeholder: "Search by number or description…",
1906
1974
  className: "min-w-0 flex-1 bg-transparent text-[12px] text-slate-700 outline-none placeholder:text-slate-400 dark:text-slate-200"
1907
1975
  }
@@ -1910,62 +1978,62 @@ function Hr({
1910
1978
  "button",
1911
1979
  {
1912
1980
  type: "button",
1913
- onClick: () => ce(""),
1981
+ onClick: () => oe(""),
1914
1982
  className: "shrink-0 text-slate-400 hover:text-slate-600",
1915
1983
  "aria-label": "Clear search",
1916
- children: /* @__PURE__ */ n(at, { className: "h-3.5 w-3.5" })
1984
+ children: /* @__PURE__ */ n(lt, { className: "h-3.5 w-3.5" })
1917
1985
  }
1918
1986
  )
1919
1987
  ] }),
1920
- ee.length > 0 && /* @__PURE__ */ c("p", { className: "mt-1.5 flex items-center gap-1 text-[10px] text-amber-600 dark:text-amber-400", children: [
1921
- /* @__PURE__ */ n(Je, { className: "h-3 w-3 shrink-0" }),
1922
- ee.map((a) => a.label ?? re(a.key)).join(", "),
1988
+ ce.length > 0 && /* @__PURE__ */ m("p", { className: "mt-1.5 flex items-center gap-1 text-[10px] text-amber-600 dark:text-amber-400", children: [
1989
+ /* @__PURE__ */ n(ze, { className: "h-3 w-3 shrink-0" }),
1990
+ ce.map((a) => a.label ?? I(a.key)).join(", "),
1923
1991
  " fill in once the form's warehouse selection is made."
1924
1992
  ] })
1925
1993
  ] }),
1926
- /* @__PURE__ */ n("div", { className: "min-h-0 flex-1 overflow-y-auto", children: /* @__PURE__ */ c("table", { className: "w-full table-fixed border-collapse text-[11px]", children: [
1927
- /* @__PURE__ */ c("colgroup", { children: [
1994
+ /* @__PURE__ */ n("div", { className: "min-h-0 flex-1 overflow-y-auto", children: /* @__PURE__ */ m("table", { className: "w-full table-fixed border-collapse text-[11px]", children: [
1995
+ /* @__PURE__ */ m("colgroup", { children: [
1928
1996
  /* @__PURE__ */ n("col", { className: "w-9" }),
1929
1997
  /* @__PURE__ */ n("col", { className: "w-[88px]" }),
1930
1998
  /* @__PURE__ */ n("col", {}),
1931
1999
  /* @__PURE__ */ n("col", { className: "w-[130px]" }),
1932
2000
  $.map((a) => /* @__PURE__ */ n("col", { className: "w-[86px]" }, a.key))
1933
2001
  ] }),
1934
- /* @__PURE__ */ n("thead", { className: "sticky top-0 z-[1]", children: /* @__PURE__ */ c("tr", { className: "bg-slate-100 text-left text-[10px] font-semibold uppercase tracking-wide text-slate-500 dark:bg-muted dark:text-slate-400", children: [
2002
+ /* @__PURE__ */ n("thead", { className: "sticky top-0 z-[1]", children: /* @__PURE__ */ m("tr", { className: "bg-slate-100 text-left text-[10px] font-semibold uppercase tracking-wide text-slate-500 dark:bg-muted dark:text-slate-400", children: [
1935
2003
  /* @__PURE__ */ n("th", { className: "px-2 py-1.5", "aria-label": "Favorite" }),
1936
2004
  /* @__PURE__ */ n("th", { className: "px-2 py-1.5", children: "CIFA #" }),
1937
2005
  /* @__PURE__ */ n("th", { className: "px-2 py-1.5", children: "Description" }),
1938
2006
  /* @__PURE__ */ n("th", { className: "px-2 py-1.5", children: "Category" }),
1939
- $.map((a) => /* @__PURE__ */ n("th", { className: "px-2 py-1.5 text-right", children: a.label ?? re(a.key) }, a.key))
2007
+ $.map((a) => /* @__PURE__ */ n("th", { className: "px-2 py-1.5 text-right", children: a.label ?? I(a.key) }, a.key))
1940
2008
  ] }) }),
1941
- /* @__PURE__ */ c("tbody", { className: z(j && "opacity-50 transition-opacity"), children: [
1942
- he(
1943
- /* @__PURE__ */ c("span", { className: "flex items-center gap-1.5", children: [
1944
- /* @__PURE__ */ n(Qe, { className: "h-3 w-3 shrink-0 fill-amber-400 text-amber-400" }),
2009
+ /* @__PURE__ */ m("tbody", { className: B(F && "opacity-50 transition-opacity"), children: [
2010
+ Q(
2011
+ /* @__PURE__ */ m("span", { className: "flex items-center gap-1.5", children: [
2012
+ /* @__PURE__ */ n(Be, { className: "h-3 w-3 shrink-0 fill-amber-400 text-amber-400" }),
1945
2013
  /* @__PURE__ */ n("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Your favorites" }),
1946
- /* @__PURE__ */ n("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: x.length })
2014
+ /* @__PURE__ */ n("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: g.length })
1947
2015
  ] }),
1948
2016
  "border-slate-200 bg-amber-50/70 dark:border-border dark:bg-amber-900/10"
1949
2017
  ),
1950
- Oe.length === 0 && /* @__PURE__ */ n("tr", { children: /* @__PURE__ */ n(
2018
+ he.length === 0 && /* @__PURE__ */ n("tr", { children: /* @__PURE__ */ n(
1951
2019
  "td",
1952
2020
  {
1953
2021
  colSpan: 4 + $.length,
1954
2022
  className: "border-b border-slate-100 px-4 py-3 text-center text-[11px] text-slate-400 dark:border-border/50",
1955
- children: x.length === 0 ? "No favorites yet — star the items you order most." : "No favorites match your search."
2023
+ children: g.length === 0 ? "No favorites yet — star the items you order most." : "No favorites match your search."
1956
2024
  }
1957
2025
  ) }),
1958
- Oe.map((a, w) => ae(a, w)),
1959
- he(
1960
- /* @__PURE__ */ c("span", { className: "flex items-center gap-1.5", children: [
1961
- /* @__PURE__ */ n(st, { className: "h-3 w-3 shrink-0 text-slate-400" }),
2026
+ he.map((a, k) => te(a, k)),
2027
+ Q(
2028
+ /* @__PURE__ */ m("span", { className: "flex items-center gap-1.5", children: [
2029
+ /* @__PURE__ */ n(it, { className: "h-3 w-3 shrink-0 text-slate-400" }),
1962
2030
  /* @__PURE__ */ n("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "All CIFAs" }),
1963
- /* @__PURE__ */ n("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: K.toLocaleString() }),
1964
- j && /* @__PURE__ */ n(oe, { className: "h-3 w-3 animate-spin text-slate-400" })
2031
+ /* @__PURE__ */ n("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: L.toLocaleString() }),
2032
+ F && /* @__PURE__ */ n(ae, { className: "h-3 w-3 animate-spin text-slate-400" })
1965
2033
  ] }),
1966
2034
  "border-t border-slate-200 bg-slate-50 dark:border-border dark:bg-muted/40"
1967
2035
  ),
1968
- !j && D.length === 0 && /* @__PURE__ */ n("tr", { children: /* @__PURE__ */ n(
2036
+ !F && W.length === 0 && /* @__PURE__ */ n("tr", { children: /* @__PURE__ */ n(
1969
2037
  "td",
1970
2038
  {
1971
2039
  colSpan: 4 + $.length,
@@ -1973,44 +2041,44 @@ function Hr({
1973
2041
  children: ne.trim() ? `No CIFAs match "${ne}".` : "No catalog items."
1974
2042
  }
1975
2043
  ) }),
1976
- D.map((a, w) => ae(a, w))
2044
+ W.map((a, k) => te(a, k))
1977
2045
  ] })
1978
2046
  ] }) }),
1979
- b > 1 && /* @__PURE__ */ c("div", { className: "flex shrink-0 items-center justify-between border-t border-slate-200 px-3 py-2 dark:border-border", children: [
1980
- /* @__PURE__ */ c("span", { className: "flex items-center gap-2 text-[10px] tabular-nums text-slate-400", children: [
2047
+ K > 1 && /* @__PURE__ */ m("div", { className: "flex shrink-0 items-center justify-between border-t border-slate-200 px-3 py-2 dark:border-border", children: [
2048
+ /* @__PURE__ */ m("span", { className: "flex items-center gap-2 text-[10px] tabular-nums text-slate-400", children: [
1981
2049
  (C - 1) * v + 1,
1982
2050
  "–",
1983
- Math.min(C * v, K),
2051
+ Math.min(C * v, L),
1984
2052
  " of",
1985
2053
  " ",
1986
- K.toLocaleString(),
1987
- j && /* @__PURE__ */ c("span", { className: "flex items-center gap-1 text-slate-500", children: [
1988
- /* @__PURE__ */ n(oe, { className: "h-3 w-3 animate-spin" }),
2054
+ L.toLocaleString(),
2055
+ F && /* @__PURE__ */ m("span", { className: "flex items-center gap-1 text-slate-500", children: [
2056
+ /* @__PURE__ */ n(ae, { className: "h-3 w-3 animate-spin" }),
1989
2057
  " Loading…"
1990
2058
  ] })
1991
2059
  ] }),
1992
- /* @__PURE__ */ c("div", { className: "flex items-center gap-1", children: [
2060
+ /* @__PURE__ */ m("div", { className: "flex items-center gap-1", children: [
1993
2061
  /* @__PURE__ */ n(
1994
2062
  "button",
1995
2063
  {
1996
2064
  type: "button",
1997
- disabled: C <= 1 || j,
1998
- onClick: () => ke((a) => Math.max(1, a - 1)),
2065
+ disabled: C <= 1 || F,
2066
+ onClick: () => ye((a) => Math.max(1, a - 1)),
1999
2067
  className: "rounded border border-slate-200 px-2 py-0.5 text-[11px] text-slate-600 transition-colors hover:bg-slate-50 disabled:opacity-40 dark:border-border dark:text-slate-300 dark:hover:bg-white/[0.04]",
2000
2068
  children: "‹ Prev"
2001
2069
  }
2002
2070
  ),
2003
- /* @__PURE__ */ c("span", { className: "px-1 text-[10px] tabular-nums text-slate-400", children: [
2071
+ /* @__PURE__ */ m("span", { className: "px-1 text-[10px] tabular-nums text-slate-400", children: [
2004
2072
  C,
2005
2073
  " / ",
2006
- b.toLocaleString()
2074
+ K.toLocaleString()
2007
2075
  ] }),
2008
2076
  /* @__PURE__ */ n(
2009
2077
  "button",
2010
2078
  {
2011
2079
  type: "button",
2012
- disabled: C >= b || j,
2013
- onClick: () => ke((a) => Math.min(b, a + 1)),
2080
+ disabled: C >= K || F,
2081
+ onClick: () => ye((a) => Math.min(K, a + 1)),
2014
2082
  className: "rounded border border-slate-200 px-2 py-0.5 text-[11px] text-slate-600 transition-colors hover:bg-slate-50 disabled:opacity-40 dark:border-border dark:text-slate-300 dark:hover:bg-white/[0.04]",
2015
2083
  children: "Next ›"
2016
2084
  }
@@ -2021,10 +2089,10 @@ function Hr({
2021
2089
  }
2022
2090
  )
2023
2091
  ] }),
2024
- xe
2092
+ Te
2025
2093
  );
2026
2094
  }
2027
2095
  export {
2028
- bn as CatalogPickerField,
2029
- Yt as matchesShowWhen
2096
+ yn as CatalogPickerField,
2097
+ rr as matchesShowWhen
2030
2098
  };