@nivaro/react 0.3.49 → 0.3.51

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 (46) hide show
  1. package/dist/components/InlineGridField.js +166 -105
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useSessionRecorder.js +1 -1
  4. package/dist/index.d.ts +38 -4
  5. package/dist/shared/components/ItemEditForm.js +5258 -5034
  6. package/dist/shared/components/QueryTable.js +489 -347
  7. package/dist/shared/components/ReportView.js +105 -99
  8. package/dist/shared/components/alerts/AlertManagerView.js +327 -301
  9. package/dist/shared/components/item-edit/CatalogPickerField.js +1230 -1175
  10. package/dist/shared/components/item-edit/CloneDialog.js +192 -142
  11. package/dist/shared/components/item-edit/DraftRecoveryBanner.js +58 -53
  12. package/dist/shared/components/item-edit/FieldRenderer.js +249 -244
  13. package/dist/shared/components/item-edit/FieldRow.js +402 -370
  14. package/dist/shared/components/item-edit/FilePickerField.js +315 -307
  15. package/dist/shared/components/item-edit/InlineGridField.js +92 -90
  16. package/dist/shared/components/item-edit/InlineTableField.js +3119 -2951
  17. package/dist/shared/components/item-edit/MidairCollisionDialog.js +175 -0
  18. package/dist/shared/components/item-edit/PlanGrid.js +162 -162
  19. package/dist/shared/components/item-edit/PolishFields.js +169 -162
  20. package/dist/shared/components/item-edit/RecordHeaderActions.js +76 -75
  21. package/dist/shared/components/item-edit/RecordLiveSync.js +93 -91
  22. package/dist/shared/components/item-edit/RelationCombobox.js +198 -191
  23. package/dist/shared/components/item-edit/SummaryPanel.js +282 -259
  24. package/dist/shared/components/item-edit/UserChip.js +233 -200
  25. package/dist/shared/components/item-edit/ValidationSummary.js +64 -47
  26. package/dist/shared/components/item-edit/header-midair.js +51 -0
  27. package/dist/shared/components/item-edit/helpers.js +181 -155
  28. package/dist/shared/components/item-edit/line-midair.js +207 -0
  29. package/dist/shared/components/item-edit/soft-rules.js +27 -0
  30. package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
  31. package/dist/shared/components/panels/CommentPanel.js +290 -284
  32. package/dist/shared/components/panels/ItemLockBanner.js +414 -358
  33. package/dist/shared/components/panels/PipelinePanel.js +1241 -992
  34. package/dist/shared/components/panels/RecordIntegrityBanner.js +1 -1
  35. package/dist/shared/components/panels/TaskPanel.js +71 -61
  36. package/dist/shared/components/panels/TransitionRequirementsDialog.js +569 -439
  37. package/dist/shared/components/panels/requirement-side-effects.js +40 -0
  38. package/dist/shared/components/queue/QueueWorklist.js +925 -871
  39. package/dist/shared/components/queue/column-chooser.js +21 -0
  40. package/dist/shared/components/queue/live-state-aspect.js +6 -0
  41. package/dist/shared/components/ui/number-draft-input.js +93 -0
  42. package/dist/shared/components/widgets/ReviewListWidget.js +191 -166
  43. package/dist/shared/lib/draft-store.js +48 -34
  44. package/dist/shared/lib/error-hints.js +1 -0
  45. package/dist/shared/lib/query-stats.js +60 -60
  46. package/package.json +1 -1
@@ -1,88 +1,88 @@
1
- import { jsxs as c, jsx as s, Fragment as we } from "react/jsx-runtime";
2
- import { useQueryClient as Tn, useQuery as K, useQueries as nr } from "@tanstack/react-query";
3
- import { Search as $t, Loader2 as ne, PackageCheck as Rn, ChevronRight as sr, Star as at, AlertTriangle as st, AlertCircle as tr, X as jt, Plus as On, ChevronDown as Pn } from "lucide-react";
4
- import { useState as Y, useRef as Qe, useMemo as T, useEffect as Oe, Fragment as rt } from "react";
5
- import { createPortal as En } from "react-dom";
6
- import { useNivaroClient as Tt, useParentDraft as Kn, useReimportHandler as Ln, useItemEditAuth as An } from "../../context.js";
7
- import { canOpenCatalogItem as Ur, openCatalogItem as Yr } from "../../lib/catalog-item-open.js";
8
- import { get as R, del as Cn, patch as Br, post as Qr } from "../../lib/commands.js";
9
- import { evaluateBoolean as Jn } from "../../lib/expression.js";
10
- import { useLiveRefetchInterval as In } from "../../lib/live-queries.js";
11
- import { tokenize as zn, matchesSearch as Bn } from "../../lib/search-text.js";
12
- import { submissionLineErrors as Qn, normalizeIdent as Wn } from "../../lib/submission-errors.js";
13
- import { titleCase as U, cn as I, matchesAllTokens as Dn } from "../../lib/utils.js";
14
- import { ImportFromFileButton as Vn } from "../import/ImportFromFileButton.js";
15
- import { SearchHighlight as ar } from "../SearchHighlight.js";
16
- import { useOverflowTip as Hn } from "../TipLayer.js";
17
- import { Popover as Mn, PopoverAnchor as Un, PopoverContent as Yn } from "../ui/popover.js";
18
- import { useColumnWidths as Wr, ResetColumnsButton as rr, ColResizeHandle as Zn, fitWidth as Gn } from "./catalog-columns.js";
19
- import { orderCatalogMatches as Xn, rowMatchesFields as es } from "./catalog-search.js";
20
- import { applyDisplayTemplate as Ce } from "./helpers.js";
21
- import { evalClientFormula as nt } from "./InlineTableField.js";
22
- import { isIntegerFieldType as Dr, checkNumberEntry as Vr, mergePendingQtyRow as ts, lineRuleErrors as rs } from "./line-qty.js";
23
- import { resolveM2MRelatedCollection as ns } from "./M2MCombobox.js";
24
- import { useO2MStaging as ss } from "./O2MStagingContext.js";
25
- import { RelationCombobox as as, RelatedItemLabel as is } from "./RelationCombobox.js";
26
- const Zr = (m, k) => {
27
- let _ = m;
28
- for (const q of k.split(".")) {
29
- if (_ == null || typeof _ != "object") return;
30
- _ = _[q];
1
+ import { jsxs as c, jsx as s, Fragment as Ne } from "react/jsx-runtime";
2
+ import { useQueryClient as Kn, useQuery as A, useQueries as sr } from "@tanstack/react-query";
3
+ import { Search as Ft, Loader2 as ce, PackageCheck as Cn, ChevronRight as ar, Star as st, AlertTriangle as nt, AlertCircle as rr, X as Tt, Plus as Jn, ChevronDown as In } from "lucide-react";
4
+ import { useState as U, useRef as We, useMemo as F, useEffect as Re, Fragment as rt } from "react";
5
+ import { createPortal as zn } from "react-dom";
6
+ import { useNivaroClient as Rt, useParentDraft as Qn, useReimportHandler as Bn, useItemEditAuth as Dr } from "../../context.js";
7
+ import { canOpenCatalogItem as Zr, openCatalogItem as Gr } from "../../lib/catalog-item-open.js";
8
+ import { get as O, del as Wn, patch as Mr, post as Vr } from "../../lib/commands.js";
9
+ import { evaluateBoolean as Dn } from "../../lib/expression.js";
10
+ import { useLiveRefetchInterval as Mn } from "../../lib/live-queries.js";
11
+ import { tokenize as Vn, matchesSearch as Un } from "../../lib/search-text.js";
12
+ import { submissionLineErrors as Hn, normalizeIdent as Yn } from "../../lib/submission-errors.js";
13
+ import { titleCase as M, cn as K, matchesAllTokens as Zn } from "../../lib/utils.js";
14
+ import { ImportFromFileButton as Gn } from "../import/ImportFromFileButton.js";
15
+ import { SearchHighlight as ir } from "../SearchHighlight.js";
16
+ import { useOverflowTip as Xn } from "../TipLayer.js";
17
+ import { Popover as es, PopoverAnchor as ts, PopoverContent as rs } from "../ui/popover.js";
18
+ import { useColumnWidths as Ur, ResetColumnsButton as nr, ColResizeHandle as ns, fitWidth as ss } from "./catalog-columns.js";
19
+ import { orderCatalogMatches as as, rowMatchesFields as is } from "./catalog-search.js";
20
+ import { applyDisplayTemplate as Je } from "./helpers.js";
21
+ import { evalClientFormula as Be } from "./InlineTableField.js";
22
+ import { isIntegerFieldType as lr, checkNumberEntry as or, mergePendingQtyRow as ls, lineRuleErrors as os } from "./line-qty.js";
23
+ import { resolveM2MRelatedCollection as ds } from "./M2MCombobox.js";
24
+ import { useO2MStaging as cs } from "./O2MStagingContext.js";
25
+ import { RelationCombobox as us, RelatedItemLabel as ms } from "./RelationCombobox.js";
26
+ const Xr = (u, x) => {
27
+ let w = u;
28
+ for (const N of x.split(".")) {
29
+ if (w == null || typeof w != "object") return;
30
+ w = w[N];
31
31
  }
32
- return _;
32
+ return w;
33
33
  };
34
- async function Ft(m, k, _) {
35
- const q = [];
34
+ async function Ot(u, x, w) {
35
+ const N = [];
36
36
  for (let a = 1; a <= 50; a++) {
37
- const b = await m.request(R(k, { ..._, limit: 1e3, page: a })).then((x) => x.data ?? []);
38
- if (q.push(...b), b.length < 1e3) break;
37
+ const p = await u.request(O(x, { ...w, limit: 1e3, page: a })).then((g) => g.data ?? []);
38
+ if (N.push(...p), p.length < 1e3) break;
39
39
  }
40
- return q;
40
+ return N;
41
41
  }
42
- function We(m, k) {
43
- const _ = {};
44
- let q = !1;
45
- const a = (b) => {
46
- if (typeof b == "string" && b.startsWith("$parent.")) {
47
- const x = k == null ? void 0 : k[b.slice(8)];
48
- return x == null || x === "" ? (q = !0, b) : x;
42
+ function De(u, x) {
43
+ const w = {};
44
+ let N = !1;
45
+ const a = (p) => {
46
+ if (typeof p == "string" && p.startsWith("$parent.")) {
47
+ const g = x == null ? void 0 : x[p.slice(8)];
48
+ return g == null || g === "" ? (N = !0, p) : g;
49
49
  }
50
- return Array.isArray(b) ? b.map(a) : b && typeof b == "object" ? Object.fromEntries(Object.entries(b).map(([x, F]) => [x, a(F)])) : b;
50
+ return Array.isArray(p) ? p.map(a) : p && typeof p == "object" ? Object.fromEntries(Object.entries(p).map(([g, j]) => [g, a(j)])) : p;
51
51
  };
52
- for (const [b, x] of Object.entries(m ?? {}))
53
- if (typeof x == "string" && x.startsWith("$parent.")) {
54
- const F = k == null ? void 0 : k[x.slice(8)];
55
- if (F == null || F === "") {
56
- q = !0;
52
+ for (const [p, g] of Object.entries(u ?? {}))
53
+ if (typeof g == "string" && g.startsWith("$parent.")) {
54
+ const j = x == null ? void 0 : x[g.slice(8)];
55
+ if (j == null || j === "") {
56
+ N = !0;
57
57
  continue;
58
58
  }
59
- _[b] = { _eq: F };
60
- } else x && typeof x == "object" ? _[b] = a(x) : _[b] = { _eq: x };
61
- return q ? null : _;
59
+ w[p] = { _eq: j };
60
+ } else g && typeof g == "object" ? w[p] = a(g) : w[p] = { _eq: g };
61
+ return N ? null : w;
62
62
  }
63
- function Hr(m, k) {
64
- if (!m) return !0;
65
- for (const [_, q] of Object.entries(m)) {
66
- const a = k == null ? void 0 : k[_], b = a == null ? null : String(a), x = q && typeof q == "object" ? q : { _eq: q };
67
- for (const [F, y] of Object.entries(x))
68
- switch (F) {
63
+ function Hr(u, x) {
64
+ if (!u) return !0;
65
+ for (const [w, N] of Object.entries(u)) {
66
+ const a = x == null ? void 0 : x[w], p = a == null ? null : String(a), g = N && typeof N == "object" ? N : { _eq: N };
67
+ for (const [j, k] of Object.entries(g))
68
+ switch (j) {
69
69
  case "_eq":
70
- if (b !== String(y)) return !1;
70
+ if (p !== String(k)) return !1;
71
71
  break;
72
72
  case "_neq":
73
- if (b === String(y)) return !1;
73
+ if (p === String(k)) return !1;
74
74
  break;
75
75
  case "_in":
76
- if (!Array.isArray(y) || !y.map(String).includes(b ?? "")) return !1;
76
+ if (!Array.isArray(k) || !k.map(String).includes(p ?? "")) return !1;
77
77
  break;
78
78
  case "_nin":
79
- if (Array.isArray(y) && y.map(String).includes(b ?? "")) return !1;
79
+ if (Array.isArray(k) && k.map(String).includes(p ?? "")) return !1;
80
80
  break;
81
81
  case "_null":
82
- if (b !== null) return !1;
82
+ if (p !== null) return !1;
83
83
  break;
84
84
  case "_nnull":
85
- if (b === null) return !1;
85
+ if (p === null) return !1;
86
86
  break;
87
87
  default:
88
88
  return !1;
@@ -90,621 +90,641 @@ function Hr(m, k) {
90
90
  }
91
91
  return !0;
92
92
  }
93
- const ls = 2e3;
94
- function As({
95
- relatedCollection: m,
96
- manyField: k,
97
- parentId: _,
98
- parentCollection: q,
93
+ const fs = 2e3, hs = 999999999999e-2;
94
+ function bs(u, x) {
95
+ const w = Number(u);
96
+ if (lr(x) && u.trim() !== "" && !Number.isNaN(w) && !Number.isInteger(w))
97
+ return "Whole numbers only";
98
+ const N = or(u, { type: x, min: 0, label: "Quantity" });
99
+ return N.ok ? null : N.message;
100
+ }
101
+ function ps(u) {
102
+ const x = { ...u.probe };
103
+ for (const [w, N] of Object.entries(u.compute)) {
104
+ const a = Be(N, x);
105
+ if (a === null) continue;
106
+ x[w] = a;
107
+ const p = u.ruleError(w, a, x);
108
+ if (p) return p;
109
+ if (Math.abs(a) > hs)
110
+ return `${u.labelOf(w)} would be ${a.toLocaleString(void 0, { maximumFractionDigits: 2 })} — too large to save`;
111
+ }
112
+ return null;
113
+ }
114
+ function Ms({
115
+ relatedCollection: u,
116
+ manyField: x,
117
+ parentId: w,
118
+ parentCollection: N,
99
119
  config: a,
100
- readOnly: b = !1
120
+ readOnly: p = !1
101
121
  }) {
102
- var Or, Pr, Er, Kr, Lr, Ar, Cr, Jr;
103
- const x = Tt(), F = Tn(), y = ss(), O = Kn(), G = Ln(), se = a.editable_fields ?? [], B = _ === "new", P = a.qty_field ?? "quantity", [me, te] = Y(/* @__PURE__ */ new Set()), Pe = Qe(!1), [z, $e] = Y(""), [Ee, Ne] = Y({}), [fe, ae] = Y(/* @__PURE__ */ new Set()), [he, re] = Y({}), [de, V] = Y({}), { data: ie = [], isPending: ve } = K({
104
- queryKey: ["collection-relations", m],
105
- queryFn: () => x.request(R(`/collections/${m}`)).then((e) => {
122
+ var Lr, Ar, Kr, Cr, Jr, Ir, zr, Qr;
123
+ const g = Rt(), j = Kn(), k = cs(), R = Qn(), Z = Bn(), te = a.editable_fields ?? [], ve = a.catalog_locked_fields ?? [], { isAdmin: H } = Dr(), z = w === "new", re = N && !z ? `?parent_collection=${encodeURIComponent(N)}&parent_id=${encodeURIComponent(w)}` : "", ae = a.qty_field ?? "quantity", [ne, xe] = U(/* @__PURE__ */ new Set()), je = We(!1), [V, Pe] = U(""), [ye, he] = U({}), [ie, se] = U(/* @__PURE__ */ new Set()), [Y, G] = U({}), [_e, fe] = U({}), { data: Ee = [], isPending: q } = A({
124
+ queryKey: ["collection-relations", u],
125
+ queryFn: () => g.request(O(`/collections/${u}`)).then((e) => {
106
126
  var t;
107
127
  return ((t = e.data) == null ? void 0 : t.relations) ?? [];
108
128
  }),
109
129
  staleTime: 10 * 6e4
110
- }), p = T(
130
+ }), b = F(
111
131
  () => {
112
132
  var e;
113
- return ((e = ie.find(
114
- (t) => t.many_collection === m && t.many_field === a.item_field && !t.junction_field
133
+ return ((e = Ee.find(
134
+ (t) => t.many_collection === u && t.many_field === a.item_field && !t.junction_field
115
135
  )) == null ? void 0 : e.one_collection) ?? null;
116
136
  },
117
- [ie, m, a.item_field]
118
- ), { data: be = [] } = K({
119
- queryKey: ["field-config", m, null],
120
- queryFn: () => x.request(R(`/field-config/${m}`)).then((e) => e.data ?? []),
137
+ [Ee, u, a.item_field]
138
+ ), { data: L = [] } = A({
139
+ queryKey: ["field-config", u, null],
140
+ queryFn: () => g.request(O(`/field-config/${u}`)).then((e) => e.data ?? []),
121
141
  staleTime: 6e4
122
- }), v = ((Or = be.find((e) => e.field === P)) == null ? void 0 : Or.type) ?? null, Q = (e, t, r) => {
142
+ }), le = ((Lr = L.find((e) => e.field === ae)) == null ? void 0 : Lr.type) ?? null, Q = (e, t, r) => {
123
143
  var n;
124
- return ((n = rs(
125
- be.filter((l) => l.field === e).map((l) => ({
126
- field: l.field,
127
- label: l.label || U(l.field),
128
- type: l.type,
129
- validation_rules: l.validation_rules
144
+ return ((n = os(
145
+ L.filter((o) => o.field === e).map((o) => ({
146
+ field: o.field,
147
+ label: o.label || M(o.field),
148
+ type: o.type,
149
+ validation_rules: o.validation_rules
130
150
  })),
131
151
  { [e]: t },
132
152
  { ...r, [e]: t }
133
153
  )[0]) == null ? void 0 : n.message) ?? null;
134
- }, { data: S } = K({
135
- queryKey: ["col-meta", p],
136
- queryFn: () => x.request(R(`/collections/${p}`)).then((e) => e.data),
137
- enabled: !!p,
154
+ }, { data: $ } = A({
155
+ queryKey: ["col-meta", b],
156
+ queryFn: () => g.request(O(`/collections/${b}`)).then((e) => e.data),
157
+ enabled: !!b,
138
158
  staleTime: 3e5
139
- }), L = S == null ? void 0 : S.display_template, j = T(() => {
159
+ }), C = $ == null ? void 0 : $.display_template, P = F(() => {
140
160
  const e = a.section_by.split(".")[0];
141
- return ((S == null ? void 0 : S.relations) ?? []).find(
142
- (t) => t.one_collection === p && t.one_field === e && !!t.junction_field
161
+ return (($ == null ? void 0 : $.relations) ?? []).find(
162
+ (t) => t.one_collection === b && t.one_field === e && !!t.junction_field
143
163
  ) ?? null;
144
- }, [S, p, a.section_by]), A = (j == null ? void 0 : j.many_collection) ?? null, { data: pe = [] } = K({
145
- queryKey: ["collection-relations", A],
146
- queryFn: () => x.request(R(`/collections/${A}`)).then((e) => {
164
+ }, [$, b, a.section_by]), oe = (P == null ? void 0 : P.many_collection) ?? null, { data: at = [] } = A({
165
+ queryKey: ["collection-relations", oe],
166
+ queryFn: () => g.request(O(`/collections/${oe}`)).then((e) => {
147
167
  var t;
148
168
  return ((t = e.data) == null ? void 0 : t.relations) ?? [];
149
169
  }),
150
- enabled: !!A,
170
+ enabled: !!oe,
151
171
  staleTime: 10 * 6e4
152
- }), C = T(() => {
153
- if (!(j != null && j.many_field) || !A) return null;
154
- const e = String(j.junction_field), t = pe.find(
155
- (n) => n.many_collection === A && n.many_field === e
156
- ), r = ns(t);
172
+ }), B = F(() => {
173
+ if (!(P != null && P.many_field) || !oe) return null;
174
+ const e = String(P.junction_field), t = at.find(
175
+ (n) => n.many_collection === oe && n.many_field === e
176
+ ), r = ds(t);
157
177
  return r ? {
158
- junction: A,
159
- fkToItem: j.many_field,
178
+ junction: oe,
179
+ fkToItem: P.many_field,
160
180
  fkToSection: e,
161
181
  target: r,
162
182
  labelPath: a.section_by.split(".").slice(1).join(".") || "id"
163
183
  } : null;
164
- }, [j, A, pe, a.section_by]), W = O == null ? void 0 : O.draft, { resolvedFilter: Je, resolvedSectionFilter: Se, resolvedLinkFilter: i, missingParents: w } = T(() => {
165
- const e = [], t = (o) => {
166
- if (typeof o == "string" && o.startsWith("$parent.")) {
167
- const h = o.slice(8), d = W == null ? void 0 : W[h];
168
- return d == null || d === "" ? (e.push(h), o) : d;
184
+ }, [P, oe, at, a.section_by]), i = R == null ? void 0 : R.draft, { resolvedFilter: v, resolvedSectionFilter: J, resolvedLinkFilter: W, missingParents: D } = F(() => {
185
+ const e = [], t = (l) => {
186
+ if (typeof l == "string" && l.startsWith("$parent.")) {
187
+ const h = l.slice(8), d = i == null ? void 0 : i[h];
188
+ return d == null || d === "" ? (e.push(h), l) : d;
169
189
  }
170
- return Array.isArray(o) ? o.map(t) : o && typeof o == "object" ? Object.fromEntries(Object.entries(o).map(([h, d]) => [h, t(d)])) : o;
171
- }, r = a.filter ? t(a.filter) : void 0, n = a.section_filter ? t(a.section_filter) : void 0, l = a.link_filter ? t(a.link_filter) : void 0;
190
+ return Array.isArray(l) ? l.map(t) : l && typeof l == "object" ? Object.fromEntries(Object.entries(l).map(([h, d]) => [h, t(d)])) : l;
191
+ }, r = a.filter ? t(a.filter) : void 0, n = a.section_filter ? t(a.section_filter) : void 0, o = a.link_filter ? t(a.link_filter) : void 0;
172
192
  return {
173
193
  resolvedFilter: r,
174
194
  resolvedSectionFilter: n,
175
- resolvedLinkFilter: l,
195
+ resolvedLinkFilter: o,
176
196
  missingParents: [...new Set(e)]
177
197
  };
178
- }, [a.filter, a.section_filter, a.link_filter, W]), H = T(() => {
179
- if (!j || !Se && !i) return Je;
198
+ }, [a.filter, a.section_filter, a.link_filter, i]), ue = F(() => {
199
+ if (!P || !J && !W) return v;
180
200
  const e = {
181
- ...Se ?? {},
182
- ...i ? { _link: i } : {}
183
- }, t = { [j.one_field]: { _some: e } };
184
- return Je ? { _and: [Je, t] } : t;
185
- }, [j, Se, i, Je]), E = T(() => {
201
+ ...J ?? {},
202
+ ...W ? { _link: W } : {}
203
+ }, t = { [P.one_field]: { _some: e } };
204
+ return v ? { _and: [v, t] } : t;
205
+ }, [P, J, W, v]), T = F(() => {
186
206
  const e = /* @__PURE__ */ new Set(["id"]);
187
- S && !j && e.add(a.section_by);
188
- for (const t of [...(L ?? "").matchAll(/\{\{([\w.]+)\}\}/g)]) e.add(t[1]);
207
+ $ && !P && e.add(a.section_by);
208
+ for (const t of [...(C ?? "").matchAll(/\{\{([\w.]+)\}\}/g)]) e.add(t[1]);
189
209
  for (const t of Object.values(a.copy_fields ?? {})) e.add(t);
190
210
  for (const t of a.columns ?? []) e.add(t.field);
191
211
  return [...e].join(",");
192
- }, [L, S, j, a.section_by, a.copy_fields, a.columns]), le = JSON.stringify(H ?? null), { data: M = [], isLoading: Z } = K(
212
+ }, [C, $, P, a.section_by, a.copy_fields, a.columns]), be = JSON.stringify(ue ?? null), { data: de = [], isLoading: Se } = A(
193
213
  {
194
- queryKey: ["catalog-picker", p, E, le],
195
- queryFn: () => x.request(
196
- R(`/items/${p}`, {
197
- limit: ls,
198
- fields: E,
199
- ...H ? { filter: JSON.stringify(H) } : {}
214
+ queryKey: ["catalog-picker", b, T, be],
215
+ queryFn: () => g.request(
216
+ O(`/items/${b}`, {
217
+ limit: fs,
218
+ fields: T,
219
+ ...ue ? { filter: JSON.stringify(ue) } : {}
200
220
  })
201
221
  ).then((e) => e.data ?? []),
202
222
  // Wait for the catalog meta: a to-many section path both narrows this
203
223
  // read and must stay out of its `fields=`.
204
- enabled: !!p && !!S && w.length === 0 && (!j || !!C),
224
+ enabled: !!b && !!$ && D.length === 0 && (!P || !!B),
205
225
  staleTime: 6e4
206
226
  }
207
- ), ce = JSON.stringify(Se ?? null), { data: xe = [], isLoading: je } = K({
208
- queryKey: ["catalog-sections", C == null ? void 0 : C.target, C == null ? void 0 : C.labelPath, ce],
227
+ ), en = JSON.stringify(J ?? null), { data: it = [], isLoading: tn } = A({
228
+ queryKey: ["catalog-sections", B == null ? void 0 : B.target, B == null ? void 0 : B.labelPath, en],
209
229
  queryFn: async () => {
210
- const e = C;
211
- return (await Ft(x, `/items/${e.target}`, {
230
+ const e = B;
231
+ return (await Ot(g, `/items/${e.target}`, {
212
232
  fields: `id,${e.labelPath}`,
213
- ...Se ? { filter: JSON.stringify(Se) } : {}
233
+ ...J ? { filter: JSON.stringify(J) } : {}
214
234
  })).map((r) => ({
215
235
  id: String(r.id),
216
- name: String(Zr(r, e.labelPath) ?? "").trim()
236
+ name: String(Xr(r, e.labelPath) ?? "").trim()
217
237
  }));
218
238
  },
219
- enabled: !!C && w.length === 0,
239
+ enabled: !!B && D.length === 0,
220
240
  staleTime: 6e4
221
- }), De = T(() => xe.map((e) => e.id), [xe]), { data: ir = [], isLoading: Gr } = K({
241
+ }), Me = F(() => it.map((e) => e.id), [it]), { data: dr = [], isLoading: rn } = A({
222
242
  queryKey: [
223
243
  "catalog-section-links",
224
- C == null ? void 0 : C.junction,
225
- De.join(","),
226
- JSON.stringify(i ?? null)
244
+ B == null ? void 0 : B.junction,
245
+ Me.join(","),
246
+ JSON.stringify(W ?? null)
227
247
  ],
228
248
  queryFn: async () => {
229
- const e = C, t = [];
230
- for (let r = 0; r < De.length; r += 200) {
231
- const n = De.slice(r, r + 200), l = await Ft(x, `/items/${e.junction}`, {
249
+ const e = B, t = [];
250
+ for (let r = 0; r < Me.length; r += 200) {
251
+ const n = Me.slice(r, r + 200), o = await Ot(g, `/items/${e.junction}`, {
232
252
  fields: `${e.fkToItem},${e.fkToSection}`,
233
253
  filter: JSON.stringify(
234
- i ? { _and: [{ [e.fkToSection]: { _in: n } }, i] } : { [e.fkToSection]: { _in: n } }
254
+ W ? { _and: [{ [e.fkToSection]: { _in: n } }, W] } : { [e.fkToSection]: { _in: n } }
235
255
  )
236
256
  });
237
- for (const o of l)
238
- o[e.fkToItem] == null || o[e.fkToSection] == null || t.push({ item: String(o[e.fkToItem]), section: String(o[e.fkToSection]) });
257
+ for (const l of o)
258
+ l[e.fkToItem] == null || l[e.fkToSection] == null || t.push({ item: String(l[e.fkToItem]), section: String(l[e.fkToSection]) });
239
259
  }
240
260
  return t;
241
261
  },
242
- enabled: !!C && De.length > 0,
262
+ enabled: !!B && Me.length > 0,
243
263
  staleTime: 6e4
244
- }), lr = T(() => {
245
- const e = new Map(xe.map((r) => [r.id, r.name])), t = /* @__PURE__ */ new Map();
246
- for (const r of ir) {
264
+ }), cr = F(() => {
265
+ const e = new Map(it.map((r) => [r.id, r.name])), t = /* @__PURE__ */ new Map();
266
+ for (const r of dr) {
247
267
  const n = e.get(r.section);
248
268
  if (!n) continue;
249
- const l = t.get(r.item) ?? [];
250
- l.includes(n) || l.push(n), t.set(r.item, l);
269
+ const o = t.get(r.item) ?? [];
270
+ o.includes(n) || o.push(n), t.set(r.item, o);
251
271
  }
252
272
  return t;
253
- }, [xe, ir]), it = !!j && (!C || je || De.length > 0 && Gr), lt = T(() => {
273
+ }, [it, dr]), lt = !!P && (!B || tn || Me.length > 0 && rn), ot = F(() => {
254
274
  const e = /* @__PURE__ */ new Map();
255
- for (const t of M) e.set(String(t.id), t);
275
+ for (const t of de) e.set(String(t.id), t);
256
276
  return e;
257
- }, [M]), { data: Fe = [] } = K({
258
- queryKey: ["o2m-rows", m, k, _],
259
- queryFn: () => x.request(
260
- R(`/items/${m}`, {
261
- filter: JSON.stringify({ [k]: { _eq: _ } }),
277
+ }, [de]), { data: Fe = [] } = A({
278
+ queryKey: ["o2m-rows", u, x, w],
279
+ queryFn: () => g.request(
280
+ O(`/items/${u}`, {
281
+ filter: JSON.stringify({ [x]: { _eq: w } }),
262
282
  limit: 1e3
263
283
  })
264
284
  ).then((e) => e.data ?? []),
265
- enabled: !B,
285
+ enabled: !z,
266
286
  staleTime: 15e3
267
- }), Ve = !B && !!y, Te = y ? y.getPendingRows(m, k) : [], ot = Ve ? y.getPendingEdits(m, k) : /* @__PURE__ */ new Map(), Xr = JSON.stringify([...ot.entries()]), dt = T(
268
- () => ot.size === 0 ? Fe : Fe.map((e) => {
269
- const t = ot.get(String(e.id));
287
+ }), Ve = !z && !!k, Te = k ? k.getPendingRows(u, x) : [], dt = Ve ? k.getPendingEdits(u, x) : /* @__PURE__ */ new Map(), nn = JSON.stringify([...dt.entries()]), ct = F(
288
+ () => dt.size === 0 ? Fe : Fe.map((e) => {
289
+ const t = dt.get(String(e.id));
270
290
  return t ? { ...e, ...t } : e;
271
291
  }),
272
- [Fe, Xr]
273
- ), ct = !B && y ? y.getPendingDeletes(m, k) : /* @__PURE__ */ new Set(), He = T(() => {
292
+ [Fe, nn]
293
+ ), ut = !z && k ? k.getPendingDeletes(u, x) : /* @__PURE__ */ new Set(), Ue = F(() => {
274
294
  const e = /* @__PURE__ */ new Map();
275
- for (const t of dt) {
295
+ for (const t of ct) {
276
296
  const r = t[a.item_field];
277
297
  r != null && e.set(String(r), t);
278
298
  }
279
299
  return e;
280
- }, [dt, a.item_field]), ut = T(() => {
300
+ }, [ct, a.item_field]), mt = F(() => {
281
301
  const e = /* @__PURE__ */ new Map();
282
302
  return Te.forEach((t, r) => {
283
303
  const n = t[a.item_field];
284
304
  n != null && e.set(String(n), r);
285
305
  }), e;
286
- }, [Te, a.item_field]), ue = T(() => {
306
+ }, [Te, a.item_field]), pe = F(() => {
287
307
  const e = Te.filter((n) => n[a.item_field] != null).map((n) => ({ key: String(n[a.item_field]), row: n }));
288
- if (B) return e;
289
- const t = dt.filter((n) => n[a.item_field] != null).map((n) => ({ key: String(n[a.item_field]), row: n })), r = new Set(t.map((n) => n.key));
308
+ if (z) return e;
309
+ const t = ct.filter((n) => n[a.item_field] != null).map((n) => ({ key: String(n[a.item_field]), row: n })), r = new Set(t.map((n) => n.key));
290
310
  return [...t, ...e.filter((n) => !r.has(n.key))];
291
- }, [B, Te, dt, a.item_field]), mt = T(
292
- () => ue.filter((e) => !lt.has(e.key)).map((e) => e.key),
293
- [ue, lt]
294
- ), { data: or = [] } = K({
295
- queryKey: ["catalog-picker-labels", p, E, mt.join(",")],
296
- queryFn: () => x.request(
297
- R(`/items/${p}`, {
298
- filter: JSON.stringify({ id: { _in: mt } }),
299
- fields: E,
300
- limit: mt.length
311
+ }, [z, Te, ct, a.item_field]), ft = F(
312
+ () => pe.filter((e) => !ot.has(e.key)).map((e) => e.key),
313
+ [pe, ot]
314
+ ), { data: ur = [] } = A({
315
+ queryKey: ["catalog-picker-labels", b, T, ft.join(",")],
316
+ queryFn: () => g.request(
317
+ O(`/items/${b}`, {
318
+ filter: JSON.stringify({ id: { _in: ft } }),
319
+ fields: T,
320
+ limit: ft.length
301
321
  })
302
322
  ).then((e) => e.data ?? []),
303
- enabled: !!p && mt.length > 0,
323
+ enabled: !!b && ft.length > 0,
304
324
  staleTime: 6e4
305
- }), { data: _e = [] } = K({
306
- queryKey: ["pinned-items", p],
307
- queryFn: () => x.request(R(`/pinned/${p}`)).then((e) => e.data ?? []),
308
- enabled: !!p && !!a.favorites,
325
+ }), { data: qe = [] } = A({
326
+ queryKey: ["pinned-items", b],
327
+ queryFn: () => g.request(O(`/pinned/${b}`)).then((e) => e.data ?? []),
328
+ enabled: !!b && !!a.favorites,
309
329
  staleTime: 6e4
310
- }), Rt = T(() => new Set(_e), [_e]), { data: Me = [] } = K({
311
- queryKey: ["pinned-item-rows", p, E, _e.join(",")],
312
- queryFn: () => x.request(
313
- R(`/items/${p}`, {
314
- filter: JSON.stringify({ id: { _in: _e } }),
315
- fields: E,
316
- limit: _e.length
330
+ }), Pt = F(() => new Set(qe), [qe]), { data: He = [] } = A({
331
+ queryKey: ["pinned-item-rows", b, T, qe.join(",")],
332
+ queryFn: () => g.request(
333
+ O(`/items/${b}`, {
334
+ filter: JSON.stringify({ id: { _in: qe } }),
335
+ fields: T,
336
+ limit: qe.length
317
337
  })
318
338
  ).then((e) => e.data ?? []),
319
- enabled: !!p && !!a.favorites && _e.length > 0,
339
+ enabled: !!b && !!a.favorites && qe.length > 0,
320
340
  staleTime: 6e4
321
- }), [ft, dr] = Y(/* @__PURE__ */ new Set());
322
- async function cr(e) {
323
- if (!(!p || ft.has(e))) {
324
- dr((t) => new Set(t).add(e));
341
+ }), [ht, mr] = U(/* @__PURE__ */ new Set());
342
+ async function fr(e) {
343
+ if (!(!b || ht.has(e))) {
344
+ mr((t) => new Set(t).add(e));
325
345
  try {
326
- await x.request(Qr(`/pinned/${p}/${e}/toggle`)).catch(() => {
327
- }), await F.invalidateQueries({ queryKey: ["pinned-items", p] });
346
+ await g.request(Vr(`/pinned/${b}/${e}/toggle`)).catch(() => {
347
+ }), await j.invalidateQueries({ queryKey: ["pinned-items", b] });
328
348
  } finally {
329
- dr((t) => {
349
+ mr((t) => {
330
350
  const r = new Set(t);
331
351
  return r.delete(e), r;
332
352
  });
333
353
  }
334
354
  }
335
355
  }
336
- const [en, ur] = Y(!1), mr = Qe(null), Ot = (e) => a.favorites ? /* @__PURE__ */ s(
356
+ const [sn, hr] = U(!1), br = We(null), Et = (e) => a.favorites ? /* @__PURE__ */ s(
337
357
  "button",
338
358
  {
339
359
  type: "button",
340
- title: Rt.has(e) ? "Remove from favorites" : "Add to favorites",
341
- disabled: ft.has(e),
360
+ title: Pt.has(e) ? "Remove from favorites" : "Add to favorites",
361
+ disabled: ht.has(e),
342
362
  onClick: (t) => {
343
- t.stopPropagation(), cr(e);
363
+ t.stopPropagation(), fr(e);
344
364
  },
345
365
  className: "shrink-0 rounded p-0.5 transition-colors",
346
- children: ft.has(e) ? /* @__PURE__ */ s(ne, { className: "h-3.5 w-3.5 animate-spin text-amber-400" }) : /* @__PURE__ */ s(
347
- at,
366
+ children: ht.has(e) ? /* @__PURE__ */ s(ce, { className: "h-3.5 w-3.5 animate-spin text-amber-400" }) : /* @__PURE__ */ s(
367
+ st,
348
368
  {
349
- className: I(
369
+ className: K(
350
370
  "h-3.5 w-3.5",
351
- Rt.has(e) ? "fill-amber-400 text-amber-400" : "text-slate-300 hover:text-amber-400"
371
+ Pt.has(e) ? "fill-amber-400 text-amber-400" : "text-slate-300 hover:text-amber-400"
352
372
  )
353
373
  }
354
374
  )
355
375
  }
356
- ) : null, [oe, tn] = Y("");
357
- Oe(() => {
358
- const e = setTimeout(() => tn(z), 300);
376
+ ) : null, [me, an] = U("");
377
+ Re(() => {
378
+ const e = setTimeout(() => an(V), 300);
359
379
  return () => clearTimeout(e);
360
- }, [z]);
361
- const fr = T(() => {
380
+ }, [V]);
381
+ const pr = F(() => {
362
382
  var t;
363
- const e = (t = [...(L ?? "").matchAll(/\{\{([\w.]+)\}\}/g)][0]) == null ? void 0 : t[1];
383
+ const e = (t = [...(C ?? "").matchAll(/\{\{([\w.]+)\}\}/g)][0]) == null ? void 0 : t[1];
364
384
  return e && !e.includes(".") ? e : "id";
365
- }, [L]), { shownSearchFields: Ke, otherSearchFields: hr } = T(() => {
385
+ }, [C]), { shownSearchFields: Le, otherSearchFields: xr } = F(() => {
366
386
  const e = new Set(
367
- ((S == null ? void 0 : S.relations) ?? []).filter((n) => n.one_collection === p && n.one_field).map((n) => n.one_field)
387
+ (($ == null ? void 0 : $.relations) ?? []).filter((n) => n.one_collection === b && n.one_field).map((n) => n.one_field)
368
388
  ), t = new Set(
369
- ((S == null ? void 0 : S.fields) ?? []).filter((n) => (n.type === "string" || n.type === "text") && !e.has(n.field)).map((n) => n.field)
389
+ (($ == null ? void 0 : $.fields) ?? []).filter((n) => (n.type === "string" || n.type === "text") && !e.has(n.field)).map((n) => n.field)
370
390
  ), r = /* @__PURE__ */ new Set();
371
- for (const n of (L ?? "").matchAll(/\{\{([\w.]+)\}\}/g)) t.has(n[1]) && r.add(n[1]);
391
+ for (const n of (C ?? "").matchAll(/\{\{([\w.]+)\}\}/g)) t.has(n[1]) && r.add(n[1]);
372
392
  for (const n of a.columns ?? []) t.has(n.field) && r.add(n.field);
373
393
  return {
374
394
  shownSearchFields: [...r],
375
395
  otherSearchFields: [...t].filter((n) => !r.has(n))
376
396
  };
377
- }, [S, p, L, a.columns]), Ue = T(() => {
397
+ }, [$, b, C, a.columns]), Ye = F(() => {
378
398
  const e = a.related_columns ?? [], t = e.findIndex((r) => r.stock === !0);
379
399
  return t !== -1 ? t : e.findIndex((r) => r.key === "on_hand" && r.stock !== !1);
380
- }, [a.related_columns]), X = Ue === -1 ? null : (a.related_columns ?? [])[Ue] ?? null, qe = X ? We(X.match, W) : null, Le = T(() => {
400
+ }, [a.related_columns]), X = Ye === -1 ? null : (a.related_columns ?? [])[Ye] ?? null, $e = X ? De(X.match, i) : null, Ae = F(() => {
381
401
  for (const e of Object.values((X == null ? void 0 : X.match) ?? {}))
382
402
  if (typeof e == "string" && e.startsWith("$parent.")) return e.slice(8);
383
403
  return null;
384
- }, [X]), br = Le ? W == null ? void 0 : W[Le] : null, rn = Le ? ((Pr = O == null ? void 0 : O.fieldLabels) == null ? void 0 : Pr[Le]) ?? U(Le) : null, Ie = p ? `nvr:catalog-in-stock:${p}:${m}.${k}` : null, [pr, xr] = Y(!1);
385
- Oe(() => {
404
+ }, [X]), yr = Ae ? i == null ? void 0 : i[Ae] : null, ln = Ae ? ((Ar = R == null ? void 0 : R.fieldLabels) == null ? void 0 : Ar[Ae]) ?? M(Ae) : null, Ie = b ? `nvr:catalog-in-stock:${b}:${u}.${x}` : null, [gr, kr] = U(!1);
405
+ Re(() => {
386
406
  if (Ie)
387
407
  try {
388
- xr(localStorage.getItem(Ie) === "1");
408
+ kr(localStorage.getItem(Ie) === "1");
389
409
  } catch {
390
410
  }
391
411
  }, [Ie]);
392
- const Pt = (e) => {
393
- if (xr(e), !!Ie)
412
+ const Lt = (e) => {
413
+ if (kr(e), !!Ie)
394
414
  try {
395
415
  e ? localStorage.setItem(Ie, "1") : localStorage.removeItem(Ie);
396
416
  } catch {
397
417
  }
398
- }, ee = !!X && pr && qe !== null, Et = T(() => {
418
+ }, ee = !!X && gr && $e !== null, At = F(() => {
399
419
  if (!X) return null;
400
- const e = ((S == null ? void 0 : S.relations) ?? []).find(
401
- (t) => t.many_collection === X.collection && t.many_field === X.item_field && t.one_collection === p && !!t.one_field && !t.junction_field
420
+ const e = (($ == null ? void 0 : $.relations) ?? []).find(
421
+ (t) => t.many_collection === X.collection && t.many_field === X.item_field && t.one_collection === b && !!t.one_field && !t.junction_field
402
422
  );
403
423
  return (e == null ? void 0 : e.one_field) ?? null;
404
- }, [X, S, p]), Kt = T(
405
- () => ee && Et && X && qe ? { [Et]: { _some: { ...qe, [X.value_field]: { _gt: 0 } } } } : null,
406
- [ee, Et, X, qe]
407
- ), Lt = JSON.stringify(Kt), ht = ee && !Kt ? 100 : 25, At = (e, t) => {
424
+ }, [X, $, b]), Kt = F(
425
+ () => ee && At && X && $e ? { [At]: { _some: { ...$e, [X.value_field]: { _gt: 0 } } } } : null,
426
+ [ee, At, X, $e]
427
+ ), Ct = JSON.stringify(Kt), bt = ee && !Kt ? 100 : 25, Jt = (e, t) => {
408
428
  const r = [t, Kt].filter(Boolean);
409
429
  return r.length === 0 ? e : { ...e, filter: JSON.stringify(r.length === 1 ? r[0] : { _and: r }) };
410
- }, Ct = An().userId, bt = a.recent === !1 ? 0 : typeof a.recent == "object" && Number((Er = a.recent) == null ? void 0 : Er.days) || 30, Jt = ["user_created", "created_by", "creator"].find(
411
- (e) => be.some((t) => t.field === e)
412
- ), Ye = ["date_created", "created_at"].find(
413
- (e) => be.some((t) => t.field === e)
414
- ), { data: Ze = [] } = K({
430
+ }, It = Dr().userId, pt = a.recent === !1 ? 0 : typeof a.recent == "object" && Number((Kr = a.recent) == null ? void 0 : Kr.days) || 30, zt = ["user_created", "created_by", "creator"].find(
431
+ (e) => L.some((t) => t.field === e)
432
+ ), Ze = ["date_created", "created_at"].find(
433
+ (e) => L.some((t) => t.field === e)
434
+ ), { data: Ge = [] } = A({
415
435
  queryKey: [
416
436
  "catalog-recent-picks",
417
- m,
437
+ u,
418
438
  a.item_field,
419
- Ct,
420
- Jt,
421
- Ye,
422
- bt
439
+ It,
440
+ zt,
441
+ Ze,
442
+ pt
423
443
  ],
424
444
  queryFn: async () => {
425
- const e = new Date(Date.now() - bt * 864e5).toISOString(), t = { [Jt]: { _eq: Ct } };
426
- Ye && (t[Ye] = { _gte: e });
427
- const r = await x.request(
428
- R(`/items/${m}`, {
445
+ const e = new Date(Date.now() - pt * 864e5).toISOString(), t = { [zt]: { _eq: It } };
446
+ Ze && (t[Ze] = { _gte: e });
447
+ const r = await g.request(
448
+ O(`/items/${u}`, {
429
449
  fields: a.item_field,
430
450
  filter: JSON.stringify(t),
431
451
  limit: 500,
432
452
  count: "false",
433
- ...Ye ? { sort: `-${Ye}` } : {}
453
+ ...Ze ? { sort: `-${Ze}` } : {}
434
454
  })
435
- ).then((l) => l.data ?? []).catch(() => []), n = [];
436
- for (const l of r) {
437
- const o = l[a.item_field], h = o != null && typeof o == "object" ? o.id : o;
455
+ ).then((o) => o.data ?? []).catch(() => []), n = [];
456
+ for (const o of r) {
457
+ const l = o[a.item_field], h = l != null && typeof l == "object" ? l.id : l;
438
458
  if (h != null && h !== "" && !n.includes(String(h)) && n.push(String(h)), n.length >= 150) break;
439
459
  }
440
460
  return n;
441
461
  },
442
- enabled: bt > 0 && !!Ct && !!Jt && !b,
462
+ enabled: pt > 0 && !!It && !!zt && !p,
443
463
  staleTime: 5 * 6e4
444
- }), nn = T(() => new Set(Ze), [Ze]), It = !!p && oe.trim().length > 0, { data: zt = [], isFetching: sn } = K({
464
+ }), on = F(() => new Set(Ge), [Ge]), Qt = !!b && me.trim().length > 0, { data: Bt = [], isFetching: dn } = A({
445
465
  queryKey: [
446
466
  "catalog-shown-search",
447
- p,
448
- E,
449
- oe,
450
- Ke,
451
- Lt,
452
- ht
467
+ b,
468
+ T,
469
+ me,
470
+ Le,
471
+ Ct,
472
+ bt
453
473
  ],
454
- queryFn: () => x.request(
455
- R(
456
- `/items/${p}`,
457
- At({
458
- search: oe,
459
- search_fields: Ke.join(","),
474
+ queryFn: () => g.request(
475
+ O(
476
+ `/items/${b}`,
477
+ Jt({
478
+ search: me,
479
+ search_fields: Le.join(","),
460
480
  search_rank: "1",
461
- fields: E,
462
- limit: ht,
463
- sort: fr
481
+ fields: T,
482
+ limit: bt,
483
+ sort: pr
464
484
  })
465
485
  )
466
486
  ).then((e) => e.data ?? []),
467
- enabled: It && Ke.length > 0,
487
+ enabled: Qt && Le.length > 0,
468
488
  staleTime: 3e4,
469
489
  placeholderData: (e) => e
470
- }), pt = hr.join(","), { data: yr = [], isFetching: an } = K({
490
+ }), xt = xr.join(","), { data: wr = [], isFetching: cn } = A({
471
491
  queryKey: [
472
492
  "catalog-full-search",
473
- p,
474
- E,
475
- oe,
476
- pt,
477
- Lt,
478
- ht
493
+ b,
494
+ T,
495
+ me,
496
+ xt,
497
+ Ct,
498
+ bt
479
499
  ],
480
- queryFn: () => x.request(
481
- R(
482
- `/items/${p}`,
483
- At({
484
- search: oe,
485
- fields: [E, pt].filter(Boolean).join(","),
486
- limit: ht,
487
- sort: fr
500
+ queryFn: () => g.request(
501
+ O(
502
+ `/items/${b}`,
503
+ Jt({
504
+ search: me,
505
+ fields: [T, xt].filter(Boolean).join(","),
506
+ limit: bt,
507
+ sort: pr
488
508
  })
489
509
  )
490
510
  ).then((e) => e.data ?? []),
491
- enabled: It,
511
+ enabled: Qt,
492
512
  staleTime: 3e4,
493
513
  placeholderData: (e) => e
494
- }), ln = Ze.join(","), { data: gr = [] } = K({
514
+ }), un = Ge.join(","), { data: Nr = [] } = A({
495
515
  queryKey: [
496
516
  "catalog-recent-search",
497
- p,
498
- E,
499
- oe,
500
- pt,
501
- ln,
502
- Lt
517
+ b,
518
+ T,
519
+ me,
520
+ xt,
521
+ un,
522
+ Ct
503
523
  ],
504
- queryFn: () => x.request(
505
- R(
506
- `/items/${p}`,
507
- At(
524
+ queryFn: () => g.request(
525
+ O(
526
+ `/items/${b}`,
527
+ Jt(
508
528
  {
509
- search: oe,
510
- fields: [E, pt].filter(Boolean).join(","),
529
+ search: me,
530
+ fields: [T, xt].filter(Boolean).join(","),
511
531
  limit: 10,
512
532
  count: "false"
513
533
  },
514
- { id: { _in: Ze } }
534
+ { id: { _in: Ge } }
515
535
  )
516
536
  )
517
537
  ).then((e) => e.data ?? []).catch(() => []),
518
- enabled: It && Ze.length > 0,
538
+ enabled: Qt && Ge.length > 0,
519
539
  staleTime: 3e4,
520
540
  placeholderData: (e) => e
521
- }), Bt = sn || an, ze = T(
522
- () => Xn({
523
- shown: zt,
524
- other: yr,
525
- recent: gr,
526
- shownFields: Ke,
527
- q: oe
541
+ }), Wt = dn || cn, ze = F(
542
+ () => as({
543
+ shown: Bt,
544
+ other: wr,
545
+ recent: Nr,
546
+ shownFields: Le,
547
+ q: me
528
548
  }),
529
- [zt, yr, gr, Ke, oe]
530
- ), on = (e) => {
531
- if (Ke.length === 0 || zt.some((r) => String(r.id) === String(e.id)) || es(e, Ke, oe)) return null;
532
- const t = zn(oe);
533
- for (const r of hr) {
549
+ [Bt, wr, Nr, Le, me]
550
+ ), mn = (e) => {
551
+ if (Le.length === 0 || Bt.some((r) => String(r.id) === String(e.id)) || is(e, Le, me)) return null;
552
+ const t = Vn(me);
553
+ for (const r of xr) {
534
554
  const n = e[r];
535
555
  if (n == null || typeof n == "object") continue;
536
- const l = String(n);
537
- if (t.some((o) => Bn(l, o)))
538
- return `${U(r)}: ${l.length > 40 ? `${l.slice(0, 40)}…` : l}`;
556
+ const o = String(n);
557
+ if (t.some((l) => Un(o, l)))
558
+ return `${M(r)}: ${o.length > 40 ? `${o.slice(0, 40)}…` : o}`;
539
559
  }
540
560
  return null;
541
- }, xt = T(() => {
561
+ }, yt = F(() => {
542
562
  const e = /* @__PURE__ */ new Set();
543
- for (const t of M) e.add(String(t.id));
544
- for (const t of ue) e.add(t.key);
545
- for (const t of _e) e.add(t);
563
+ for (const t of de) e.add(String(t.id));
564
+ for (const t of pe) e.add(t.key);
565
+ for (const t of qe) e.add(t);
546
566
  for (const t of ze) e.add(String(t.id));
547
567
  return [...e];
548
- }, [M, ue, _e, ze]), yt = nr({
568
+ }, [de, pe, qe, ze]), gt = sr({
549
569
  queries: (a.related_columns ?? []).map((e) => {
550
- const t = We(e.match, W);
570
+ const t = De(e.match, i);
551
571
  return {
552
572
  queryKey: [
553
573
  "catalog-related",
554
574
  e.key,
555
575
  e.collection,
556
576
  JSON.stringify(t),
557
- xt.join(",")
577
+ yt.join(",")
558
578
  ],
559
579
  queryFn: async () => {
560
- const r = {}, n = e.aggregate === "sum", l = n ? 150 : 400;
561
- for (let o = 0; o < xt.length; o += l) {
562
- const h = xt.slice(o, o + l);
580
+ const r = {}, n = e.aggregate === "sum", o = n ? 150 : 400;
581
+ for (let l = 0; l < yt.length; l += o) {
582
+ const h = yt.slice(l, l + o);
563
583
  let d = 1;
564
584
  for (; ; ) {
565
- const u = await x.request(
566
- R(`/items/${e.collection}`, {
585
+ const m = await g.request(
586
+ O(`/items/${e.collection}`, {
567
587
  limit: n ? 1e3 : h.length,
568
588
  ...n ? { page: d } : {},
569
589
  fields: `${e.item_field},${e.value_field}`,
570
590
  filter: JSON.stringify({ ...t, [e.item_field]: { _in: h } })
571
591
  })
572
592
  ).then((f) => f.data ?? []);
573
- for (const f of u) {
574
- const N = f[e.item_field];
575
- if (N != null)
593
+ for (const f of m) {
594
+ const _ = f[e.item_field];
595
+ if (_ != null)
576
596
  if (n) {
577
- const $ = Number(f[e.value_field]);
578
- r[String(N)] = (Number(r[String(N)]) || 0) + (Number.isNaN($) ? 0 : $);
597
+ const S = Number(f[e.value_field]);
598
+ r[String(_)] = (Number(r[String(_)]) || 0) + (Number.isNaN(S) ? 0 : S);
579
599
  } else
580
- r[String(N)] = f[e.value_field];
600
+ r[String(_)] = f[e.value_field];
581
601
  }
582
- if (!n || u.length < 1e3) break;
602
+ if (!n || m.length < 1e3) break;
583
603
  d += 1;
584
604
  }
585
605
  }
586
606
  return r;
587
607
  },
588
- enabled: !!p && t !== null && xt.length > 0,
608
+ enabled: !!b && t !== null && yt.length > 0,
589
609
  staleTime: 3e4
590
610
  };
591
611
  })
592
- }), Qt = (e, t) => {
593
- var n, l;
594
- const r = (a.related_columns ?? []).findIndex((o) => o.key === e);
612
+ }), kt = (e, t) => {
613
+ var n, o;
614
+ const r = (a.related_columns ?? []).findIndex((l) => l.key === e);
595
615
  if (r !== -1)
596
- return (l = (n = yt[r]) == null ? void 0 : n.data) == null ? void 0 : l[t];
597
- }, Ge = Ue === -1 || (Kr = yt[Ue]) == null ? void 0 : Kr.data, dn = ee && !!((Lr = yt[Ue]) != null && Lr.isFetching), kr = (e) => {
598
- if (!ee || Ge === void 0) return !0;
599
- const t = Number(Ge[e]);
616
+ return (o = (n = gt[r]) == null ? void 0 : n.data) == null ? void 0 : o[t];
617
+ }, Xe = Ye === -1 || (Cr = gt[Ye]) == null ? void 0 : Cr.data, fn = ee && !!((Jr = gt[Ye]) != null && Jr.isFetching), vr = (e) => {
618
+ if (!ee || Xe === void 0) return !0;
619
+ const t = Number(Xe[e]);
600
620
  return Number.isFinite(t) && t > 0;
601
- }, Xe = ee ? ze.filter((e) => kr(String(e.id))) : ze, Wt = ee ? Me.filter((e) => kr(String(e.id))) : Me, Dt = (e) => {
621
+ }, et = ee ? ze.filter((e) => vr(String(e.id))) : ze, Dt = ee ? He.filter((e) => vr(String(e.id))) : He, Mt = (e) => {
602
622
  var d;
603
623
  const t = a.qty_warning;
604
624
  if (!t) return null;
605
- const r = ke(e) ?? 0;
625
+ const r = we(e) ?? 0;
606
626
  if (r <= 0) return null;
607
- const n = (a.related_columns ?? []).findIndex((u) => u.key === t.column);
627
+ const n = (a.related_columns ?? []).findIndex((m) => m.key === t.column);
608
628
  if (n === -1) return null;
609
- const l = (d = yt[n]) == null ? void 0 : d.data;
610
- if (l === void 0) return null;
611
- const o = l[e], h = o == null || o === "" ? 0 : Number(o);
629
+ const o = (d = gt[n]) == null ? void 0 : d.data;
630
+ if (o === void 0) return null;
631
+ const l = o[e], h = l == null || l === "" ? 0 : Number(l);
612
632
  return Number.isNaN(h) ? null : r > h ? { available: h, qty: r } : null;
613
- }, cn = (e) => {
633
+ }, hn = (e) => {
614
634
  const t = a.row_flags ?? [];
615
635
  if (t.length === 0) return [];
616
636
  const r = [];
617
637
  for (const n of t)
618
638
  if (!(!(n != null && n.when) || !n.label))
619
639
  try {
620
- const l = n.when.replace(/\{\{\s*([A-Za-z_][A-Za-z0-9_.]*)\s*\}\}/g, "$1");
621
- Jn(l, e) && r.push(n.label);
640
+ const o = n.when.replace(/\{\{\s*([A-Za-z_][A-Za-z0-9_.]*)\s*\}\}/g, "$1");
641
+ Dn(o, e) && r.push(n.label);
622
642
  } catch {
623
643
  }
624
644
  return r;
625
- }, Vt = a.qty_warning ? a.qty_warning.label ?? ((Ar = (a.related_columns ?? []).find((e) => {
645
+ }, Vt = a.qty_warning ? a.qty_warning.label ?? ((Ir = (a.related_columns ?? []).find((e) => {
626
646
  var t;
627
647
  return e.key === ((t = a.qty_warning) == null ? void 0 : t.column);
628
- })) == null ? void 0 : Ar.label) ?? U(a.qty_warning.column) : "", un = !!a.submission_errors, gt = T(
648
+ })) == null ? void 0 : Ir.label) ?? M(a.qty_warning.column) : "", bn = !!a.submission_errors, wt = F(
629
649
  () => {
630
650
  var e;
631
651
  return typeof a.submission_errors == "object" && Array.isArray((e = a.submission_errors) == null ? void 0 : e.match_fields) ? a.submission_errors.match_fields.filter((t) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(t)) : [];
632
652
  },
633
653
  [a.submission_errors]
634
- ), mn = In(6e4), { data: wr } = K({
635
- queryKey: ["erp-submissions", q ?? "", String(_)],
636
- queryFn: () => x.request(R(`/erp-submissions/${q}/${encodeURIComponent(_)}`)).then((e) => e.data ?? []),
637
- enabled: un && !B && !!q,
654
+ ), pn = Mn(6e4), { data: _r } = A({
655
+ queryKey: ["erp-submissions", N ?? "", String(w)],
656
+ queryFn: () => g.request(O(`/erp-submissions/${N}/${encodeURIComponent(w)}`)).then((e) => e.data ?? []),
657
+ enabled: bn && !z && !!N,
638
658
  staleTime: 15e3,
639
- refetchInterval: mn
640
- }), Ht = T(() => {
641
- const e = (wr ?? [])[0];
642
- return !e || e.status !== "failed" ? null : Qn(e.payload, e.last_error);
643
- }, [wr]), fn = ue.map((e) => e.key).join(","), { data: Mt } = K({
644
- queryKey: ["catalog-suberr-idents", p, gt.join(","), fn],
659
+ refetchInterval: pn
660
+ }), Ut = F(() => {
661
+ const e = (_r ?? [])[0];
662
+ return !e || e.status !== "failed" ? null : Hn(e.payload, e.last_error);
663
+ }, [_r]), xn = pe.map((e) => e.key).join(","), { data: Ht } = A({
664
+ queryKey: ["catalog-suberr-idents", b, wt.join(","), xn],
645
665
  queryFn: async () => {
646
- const e = ue.map((r) => r.key);
666
+ const e = pe.map((r) => r.key);
647
667
  if (e.length === 0) return {};
648
- const t = await x.request(
649
- R(`/items/${p}`, {
668
+ const t = await g.request(
669
+ O(`/items/${b}`, {
650
670
  limit: e.length,
651
- fields: ["id", ...gt].join(","),
671
+ fields: ["id", ...wt].join(","),
652
672
  filter: JSON.stringify({ id: { _in: e } })
653
673
  })
654
674
  ).then((r) => r.data ?? []);
655
675
  return Object.fromEntries(t.map((r) => [String(r.id), r]));
656
676
  },
657
- enabled: !!p && !!Ht && gt.length > 0 && ue.length > 0,
677
+ enabled: !!b && !!Ut && wt.length > 0 && pe.length > 0,
658
678
  staleTime: 6e4
659
- }), hn = (e) => {
660
- if (!Ht) return null;
661
- const t = Mt == null ? void 0 : Mt[e], r = [
662
- Rr(e),
663
- ...gt.map((n) => {
664
- const l = (t == null ? void 0 : t[n]) ?? Be(e)[n];
665
- return l != null && l !== "" ? String(l) : null;
679
+ }), yn = (e) => {
680
+ if (!Ut) return null;
681
+ const t = Ht == null ? void 0 : Ht[e], r = [
682
+ Er(e),
683
+ ...wt.map((n) => {
684
+ const o = (t == null ? void 0 : t[n]) ?? Ke(e)[n];
685
+ return o != null && o !== "" ? String(o) : null;
666
686
  })
667
- ].filter((n) => !!n).map(Wn);
668
- return Ht.reasonFor(r);
669
- }, kt = a.summary_fields ?? [], bn = Fe.map((e) => String(e.id)).join(","), pn = nr({
670
- queries: kt.filter((e) => e.m2m).map((e) => ({
671
- queryKey: ["catalog-summary-m2m", e.field, e.m2m.junction, bn],
687
+ ].filter((n) => !!n).map(Yn);
688
+ return Ut.reasonFor(r);
689
+ }, Nt = a.summary_fields ?? [], gn = Fe.map((e) => String(e.id)).join(","), kn = sr({
690
+ queries: Nt.filter((e) => e.m2m).map((e) => ({
691
+ queryKey: ["catalog-summary-m2m", e.field, e.m2m.junction, gn],
672
692
  queryFn: async () => {
673
693
  const t = Fe.map((f) => String(f.id));
674
694
  if (t.length === 0) return {};
675
- const r = e.m2m, n = await x.request(
676
- R(`/items/${r.junction}`, {
695
+ const r = e.m2m, n = await g.request(
696
+ O(`/items/${r.junction}`, {
677
697
  limit: 1e3,
678
698
  fields: `${r.fk_to_child},${r.related_field}`,
679
699
  filter: JSON.stringify({ [r.fk_to_child]: { _in: t } })
680
700
  })
681
- ).then((f) => f.data ?? []).catch(() => []), l = [...new Set(n.map((f) => String(f[r.related_field])))], o = r.label_field ?? "name", h = l.length ? await x.request(
682
- R(`/items/${r.related_collection}`, {
701
+ ).then((f) => f.data ?? []).catch(() => []), o = [...new Set(n.map((f) => String(f[r.related_field])))], l = r.label_field ?? "name", h = o.length ? await g.request(
702
+ O(`/items/${r.related_collection}`, {
683
703
  limit: 500,
684
- fields: `id,${o}`,
685
- filter: JSON.stringify({ id: { _in: l } })
704
+ fields: `id,${l}`,
705
+ filter: JSON.stringify({ id: { _in: o } })
686
706
  })
687
- ).then((f) => f.data ?? []).catch(() => []) : [], d = new Map(h.map((f) => [String(f.id), String(f[o] ?? f.id)])), u = {};
707
+ ).then((f) => f.data ?? []).catch(() => []) : [], d = new Map(h.map((f) => [String(f.id), String(f[l] ?? f.id)])), m = {};
688
708
  for (const f of n) {
689
- const N = String(f[r.fk_to_child]), $ = d.get(String(f[r.related_field]));
690
- $ && (u[N] = u[N] ? `${u[N]}, ${$}` : $);
709
+ const _ = String(f[r.fk_to_child]), S = d.get(String(f[r.related_field]));
710
+ S && (m[_] = m[_] ? `${m[_]}, ${S}` : S);
691
711
  }
692
- return u;
712
+ return m;
693
713
  },
694
- enabled: !B && Fe.length > 0,
714
+ enabled: !z && Fe.length > 0,
695
715
  staleTime: 15e3
696
716
  }))
697
- }), xn = (e, t) => {
698
- var l, o;
717
+ }), wn = (e, t) => {
718
+ var o, l;
699
719
  if (!e.m2m) return t.row[e.field];
700
- const r = kt.filter((h) => h.m2m).findIndex((h) => h.field === e.field);
720
+ const r = Nt.filter((h) => h.m2m).findIndex((h) => h.field === e.field);
701
721
  if (r === -1) return;
702
722
  const n = t.row.id;
703
723
  if (n != null)
704
- return (o = (l = pn[r]) == null ? void 0 : l.data) == null ? void 0 : o[String(n)];
705
- }, yn = !!((Cr = a.fulfilment) != null && Cr.shipped_field) && (a.fulfilment.show_when ? Hr(a.fulfilment.show_when, W) : !0), gn = (e) => {
706
- if (!yn || !a.fulfilment) return null;
707
- const t = Number(e[a.fulfilment.qty_field ?? P] ?? 0) || 0, r = Number(e[a.fulfilment.shipped_field] ?? 0) || 0, n = t > 0 && r >= t ? {
724
+ return (l = (o = kn[r]) == null ? void 0 : o.data) == null ? void 0 : l[String(n)];
725
+ }, Nn = !!((zr = a.fulfilment) != null && zr.shipped_field) && (a.fulfilment.show_when ? Hr(a.fulfilment.show_when, i) : !0), vn = (e) => {
726
+ if (!Nn || !a.fulfilment) return null;
727
+ const t = Number(e[a.fulfilment.qty_field ?? ae] ?? 0) || 0, r = Number(e[a.fulfilment.shipped_field] ?? 0) || 0, n = t > 0 && r >= t ? {
708
728
  dot: "bg-emerald-500",
709
729
  text: "text-emerald-700 dark:text-emerald-400",
710
730
  label: "Shipped"
@@ -729,7 +749,7 @@ function As({
729
749
  ]
730
750
  }
731
751
  );
732
- }, Nr = a.columns ?? [], vr = a.related_columns ?? [], wt = Nr.filter((e) => !e.summary_only), Ut = vr.filter((e) => !e.summary_only), Sr = Nr.filter((e) => !e.sections_only), _r = vr.filter((e) => !e.sections_only), qr = wt.length > 0 || Ut.length > 0, Yt = Qe(null), $r = (e) => {
752
+ }, Sr = a.columns ?? [], qr = a.related_columns ?? [], vt = Sr.filter((e) => !e.summary_only), Yt = qr.filter((e) => !e.summary_only), $r = Sr.filter((e) => !e.sections_only), jr = qr.filter((e) => !e.sections_only), Fr = vt.length > 0 || Yt.length > 0, Zt = We(null), Tr = (e) => {
733
753
  let t = e.parentElement;
734
754
  for (; t; ) {
735
755
  const r = getComputedStyle(t);
@@ -739,92 +759,92 @@ function As({
739
759
  }
740
760
  t = t.parentElement;
741
761
  }
742
- }, kn = (e) => {
743
- Yt.current = e, e && $r(e);
762
+ }, _n = (e) => {
763
+ Zt.current = e, e && Tr(e);
744
764
  };
745
- Oe(() => {
765
+ Re(() => {
746
766
  let e = 0;
747
767
  const t = () => {
748
768
  e || (e = requestAnimationFrame(() => {
749
- e = 0, Yt.current && $r(Yt.current);
769
+ e = 0, Zt.current && Tr(Zt.current);
750
770
  }));
751
771
  };
752
772
  return window.addEventListener("scroll", t, !0), () => {
753
773
  e && cancelAnimationFrame(e), window.removeEventListener("scroll", t, !0);
754
774
  };
755
775
  }, []);
756
- const Nt = (e, t) => {
776
+ const _t = (e, t) => {
757
777
  let r = e;
758
778
  for (const n of t.split(".")) {
759
779
  if (r == null || typeof r != "object") return;
760
780
  r = r[n];
761
781
  }
762
782
  return r;
763
- }, ye = (e, t) => {
783
+ }, ge = (e, t) => {
764
784
  if (t === "presence")
765
785
  return e == null || e === "" || Number(e) === 0 ? "No" : "Yes";
766
786
  if (e == null || e === "") return "—";
767
787
  const r = Number(e);
768
788
  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);
769
- }, vt = p ? `${p}:${m}.${k}` : null, Re = Wr(vt && `${vt}:catalog`), ge = Wr(vt && `${vt}:summary`), jr = Qe(null), wn = (e, t) => {
770
- const r = Gn(jr.current, t);
789
+ }, St = b ? `${b}:${u}.${x}` : null, Oe = Ur(St && `${St}:catalog`), ke = Ur(St && `${St}:summary`), Or = We(null), Sn = (e, t) => {
790
+ const r = ss(Or.current, t);
771
791
  r != null && e.setWidth(t, r);
772
- }, St = (e, t, r, n, l) => {
773
- const o = e.box(t, n, l);
774
- return /* @__PURE__ */ c("span", { ...o, className: I("relative", o.className), children: [
792
+ }, qt = (e, t, r, n, o) => {
793
+ const l = e.box(t, n, o);
794
+ return /* @__PURE__ */ c("span", { ...l, className: K("relative", l.className), children: [
775
795
  /* @__PURE__ */ s("span", { "data-cpf-fit": !0, className: "block truncate", children: r }),
776
796
  /* @__PURE__ */ s(
777
- Zn,
797
+ ns,
778
798
  {
779
799
  label: r,
780
800
  onResize: (h) => e.setWidth(t, h),
781
- onFit: () => wn(e, t)
801
+ onFit: () => Sn(e, t)
782
802
  }
783
803
  )
784
804
  ] }, t);
785
- }, Nn = (Jr = wt.find((e) => !e.format)) == null ? void 0 : Jr.field, Fr = (e) => e.format ? ["w-20 shrink-0", "text-right"] : e.field === Nn ? ["min-w-0 flex-[3]", ""] : ["w-36 shrink-0", ""], Zt = (e, t, r) => /* @__PURE__ */ c(we, { children: [
786
- wt.map((n) => {
787
- const [l, o] = Fr(n);
805
+ }, qn = (Qr = vt.find((e) => !e.format)) == null ? void 0 : Qr.field, Rr = (e) => e.format ? ["w-20 shrink-0", "text-right"] : e.field === qn ? ["min-w-0 flex-[3]", ""] : ["w-36 shrink-0", ""], Gt = (e, t, r) => /* @__PURE__ */ c(Ne, { children: [
806
+ vt.map((n) => {
807
+ const [o, l] = Rr(n);
788
808
  return /* @__PURE__ */ s(
789
- Mr,
809
+ Yr,
790
810
  {
791
- text: ye(Nt(t, n.field), n.format),
811
+ text: ge(_t(t, n.field), n.format),
792
812
  highlight: n.format ? void 0 : r,
793
- ...Re.box(n.field, l, I("text-slate-500 dark:text-slate-400", o))
813
+ ...Oe.box(n.field, o, K("text-slate-500 dark:text-slate-400", l))
794
814
  },
795
815
  n.field
796
816
  );
797
817
  }),
798
- Ut.map((n) => /* @__PURE__ */ s(
818
+ Yt.map((n) => /* @__PURE__ */ s(
799
819
  "span",
800
820
  {
801
- ...Re.box(
821
+ ...Oe.box(
802
822
  `rel:${n.key}`,
803
823
  "w-20 shrink-0",
804
824
  "truncate text-right text-slate-500 dark:text-slate-400"
805
825
  ),
806
- children: ye(Qt(n.key, e), n.format)
826
+ children: ge(kt(n.key, e), n.format)
807
827
  },
808
828
  n.key
809
829
  )),
810
830
  /* @__PURE__ */ s("span", { "aria-hidden": !0, className: "ml-auto" })
811
- ] }), vn = Ur(p), Tr = (e, t, r, n, l) => vn ? /* @__PURE__ */ s(
831
+ ] }), $n = Zr(b), Pr = (e, t, r, n, o) => $n ? /* @__PURE__ */ s(
812
832
  "button",
813
833
  {
814
834
  type: "button",
815
835
  "data-cpf-fit": n || void 0,
816
- onClick: () => p && Yr(p, e, W),
836
+ onClick: () => b && Gr(b, e, i),
817
837
  title: "View stock & planning detail",
818
- className: I(
838
+ className: K(
819
839
  r,
820
840
  "text-left underline decoration-slate-300 decoration-1 underline-offset-2 hover:text-[#009abe] hover:decoration-[#009abe] dark:decoration-slate-600"
821
841
  ),
822
- children: l ? /* @__PURE__ */ s(ar, { text: t, query: l }) : t
842
+ children: o ? /* @__PURE__ */ s(ir, { text: t, query: o }) : t
823
843
  }
824
- ) : /* @__PURE__ */ s("span", { className: r, "data-cpf-fit": n || void 0, children: l ? /* @__PURE__ */ s(ar, { text: t, query: l }) : t }), Gt = (e, t, r, n) => {
825
- const l = Re.box("item", qr ? "w-36 shrink-0" : "min-w-0 flex-1");
826
- return /* @__PURE__ */ c("span", { ...l, className: I("flex min-w-0 items-center gap-1.5", l.className), children: [
827
- Tr(
844
+ ) : /* @__PURE__ */ s("span", { className: r, "data-cpf-fit": n || void 0, children: o ? /* @__PURE__ */ s(ir, { text: t, query: o }) : t }), Xt = (e, t, r, n) => {
845
+ const o = Oe.box("item", Fr ? "w-36 shrink-0" : "min-w-0 flex-1");
846
+ return /* @__PURE__ */ c("span", { ...o, className: K("flex min-w-0 items-center gap-1.5", o.className), children: [
847
+ Pr(
828
848
  e,
829
849
  t,
830
850
  "min-w-0 truncate text-slate-700 dark:text-slate-200",
@@ -833,77 +853,77 @@ function As({
833
853
  ),
834
854
  r
835
855
  ] });
836
- }, Rr = (e) => {
837
- const t = lt.get(e) ?? or.find((r) => String(r.id) === e) ?? Me.find((r) => String(r.id) === e);
838
- return t ? Ce(L, t) : `#${e}`;
839
- }, Be = (e) => lt.get(e) ?? or.find((t) => String(t.id) === e) ?? Me.find((t) => String(t.id) === e) ?? { id: e }, ke = (e) => {
856
+ }, Er = (e) => {
857
+ const t = ot.get(e) ?? ur.find((r) => String(r.id) === e) ?? He.find((r) => String(r.id) === e);
858
+ return t ? Je(C, t) : `#${e}`;
859
+ }, Ke = (e) => ot.get(e) ?? ur.find((t) => String(t.id) === e) ?? He.find((t) => String(t.id) === e) ?? { id: e }, we = (e) => {
840
860
  var n;
841
- const t = B ? void 0 : He.get(e);
842
- if (t) return ct.has(String(t.id)) ? null : Number(t[P] ?? 0);
843
- const r = ut.get(e);
844
- return r === void 0 ? null : Number(((n = Te[r]) == null ? void 0 : n[P]) ?? 0);
845
- }, Sn = (e) => {
861
+ const t = z ? void 0 : Ue.get(e);
862
+ if (t) return ut.has(String(t.id)) ? null : Number(t[ae] ?? 0);
863
+ const r = mt.get(e);
864
+ return r === void 0 ? null : Number(((n = Te[r]) == null ? void 0 : n[ae]) ?? 0);
865
+ }, jn = (e) => {
846
866
  let t = e;
847
867
  for (const r of a.section_by.split(".")) {
848
868
  if (t == null || typeof t != "object") return "";
849
869
  t = t[r];
850
870
  }
851
871
  return String(t ?? "").trim();
852
- }, _t = T(() => {
853
- if (it) return [];
854
- z.trim().toLowerCase();
872
+ }, $t = F(() => {
873
+ if (lt) return [];
874
+ V.trim().toLowerCase();
855
875
  const e = /* @__PURE__ */ new Map();
856
- for (const t of M) {
857
- if (ee && Ge !== void 0 && !(Number(Ge[String(t.id)]) > 0)) continue;
858
- const r = Ce(L, t), n = j ? lr.get(String(t.id)) ?? [] : [Sn(t)];
859
- if (!(j && i && n.length === 0))
860
- for (const l of n.length ? n : [""]) {
861
- const o = l || "Uncategorized";
862
- e.has(o) || e.set(o, []), e.get(o).push({ id: String(t.id), label: r, row: t });
876
+ for (const t of de) {
877
+ if (ee && Xe !== void 0 && !(Number(Xe[String(t.id)]) > 0)) continue;
878
+ const r = Je(C, t), n = P ? cr.get(String(t.id)) ?? [] : [jn(t)];
879
+ if (!(P && W && n.length === 0))
880
+ for (const o of n.length ? n : [""]) {
881
+ const l = o || "Uncategorized";
882
+ e.has(l) || e.set(l, []), e.get(l).push({ id: String(t.id), label: r, row: t });
863
883
  }
864
884
  }
865
885
  return [...e.entries()].sort(
866
886
  ([t], [r]) => t === "Uncategorized" ? 1 : r === "Uncategorized" ? -1 : t.localeCompare(r)
867
887
  ).map(([t, r]) => ({
868
888
  name: t,
869
- items: r.sort((n, l) => n.label.localeCompare(l.label))
889
+ items: r.sort((n, o) => n.label.localeCompare(o.label))
870
890
  }));
871
891
  }, [
872
- M,
873
- L,
874
- z,
892
+ de,
893
+ C,
894
+ V,
875
895
  a.section_by,
876
- j,
877
- lr,
878
- it,
879
- i,
896
+ P,
897
+ cr,
898
+ lt,
899
+ W,
880
900
  ee,
881
- Ge
901
+ Xe
882
902
  ]);
883
- if (!Pe.current && _t.length > 0) {
884
- Pe.current = !0;
903
+ if (!je.current && $t.length > 0) {
904
+ je.current = !0;
885
905
  const e = /* @__PURE__ */ new Set();
886
- for (const t of _t)
887
- t.items.some((n) => (ke(n.id) ?? 0) > 0) || e.add(t.name);
888
- te(e);
906
+ for (const t of $t)
907
+ t.items.some((n) => (we(n.id) ?? 0) > 0) || e.add(t.name);
908
+ xe(e);
889
909
  }
890
- async function _n(e) {
910
+ async function Fn(e) {
891
911
  const t = {};
892
912
  for (const r of a.related_columns ?? []) {
893
913
  if (!r.copy_to) continue;
894
- let n = Qt(r.key, e);
914
+ let n = kt(r.key, e);
895
915
  if (n === void 0) {
896
- const l = We(r.match, W);
897
- if (l === null) continue;
898
- n = await x.request(
899
- R(`/items/${r.collection}`, {
916
+ const o = De(r.match, i);
917
+ if (o === null) continue;
918
+ n = await g.request(
919
+ O(`/items/${r.collection}`, {
900
920
  limit: 1,
901
921
  fields: `${r.item_field},${r.value_field}`,
902
- filter: JSON.stringify({ ...l, [r.item_field]: { _eq: e } })
922
+ filter: JSON.stringify({ ...o, [r.item_field]: { _eq: e } })
903
923
  })
904
- ).then((o) => {
924
+ ).then((l) => {
905
925
  var h, d;
906
- return (d = (h = o.data) == null ? void 0 : h[0]) == null ? void 0 : d[r.value_field];
926
+ return (d = (h = l.data) == null ? void 0 : h[0]) == null ? void 0 : d[r.value_field];
907
927
  }).catch(() => {
908
928
  });
909
929
  }
@@ -911,228 +931,258 @@ function As({
911
931
  }
912
932
  return t;
913
933
  }
914
- function et(e, t, r, n = {}) {
915
- const l = {
934
+ const Tn = (e, t) => {
935
+ var n;
936
+ for (const o of a.related_columns ?? []) {
937
+ if (o.copy_to !== t) continue;
938
+ const l = kt(o.key, e);
939
+ if (l != null && l !== "") return l;
940
+ }
941
+ const r = (n = a.copy_fields) == null ? void 0 : n[t];
942
+ return r ? Ke(e)[r] : void 0;
943
+ }, On = (e, t) => {
944
+ if (p || !te.includes(t)) return !1;
945
+ if (H || !ve.includes(t)) return !0;
946
+ const r = Tn(e, t);
947
+ return r == null || r === "" || !(Number(r) > 0);
948
+ };
949
+ function Qe(e, t, r, n = {}) {
950
+ const o = {
916
951
  [a.item_field]: r.id ?? e,
917
- [P]: t
952
+ [ae]: t
918
953
  };
919
- for (const [o, h] of Object.entries(a.copy_fields ?? {}))
920
- r[h] !== void 0 && (l[o] = r[h]);
921
- Object.assign(l, n);
922
- for (const [o, h] of Object.entries(a.compute_fields ?? {})) {
923
- const d = nt(h, l);
924
- d !== null && (l[o] = d);
954
+ for (const [l, h] of Object.entries(a.copy_fields ?? {}))
955
+ r[h] !== void 0 && (o[l] = r[h]);
956
+ Object.assign(o, n);
957
+ for (const [l, h] of Object.entries(a.compute_fields ?? {})) {
958
+ const d = Be(h, o);
959
+ d !== null && (o[l] = d);
925
960
  }
926
- return l;
961
+ return o;
962
+ }
963
+ function Rn(e, t, r, n) {
964
+ return ps({
965
+ compute: a.compute_fields ?? {},
966
+ probe: { ...Qe(e, t, r), ...n, [ae]: t },
967
+ ruleError: Q,
968
+ labelOf: (o) => {
969
+ var l;
970
+ return ((l = L.find((h) => h.field === o)) == null ? void 0 : l.label) || M(o);
971
+ }
972
+ });
927
973
  }
928
974
  async function tt(e, t, r, n = {}) {
929
- const l = Vr(t, { type: v, min: 0, label: "Quantity" });
930
- if (!l.ok) {
931
- re((u) => ({ ...u, [e]: { kind: "error", message: l.message } }));
975
+ const o = or(t, { type: le, min: 0, label: "Quantity" });
976
+ if (!o.ok) {
977
+ G((m) => ({ ...m, [e]: { kind: "error", message: o.message } }));
932
978
  return;
933
979
  }
934
- const o = l.value ?? 0;
935
- if ((ke(e) ?? 0) === o) return;
936
- if (o === 0 && !n.confirmedRemove) {
937
- re((u) => ({ ...u, [e]: { kind: "remove", row: r } }));
980
+ const l = o.value ?? 0;
981
+ if ((we(e) ?? 0) === l) return;
982
+ if (l === 0 && !n.confirmedRemove) {
983
+ G((m) => ({ ...m, [e]: { kind: "remove", row: r } }));
938
984
  return;
939
985
  }
940
- if (o > 0) {
941
- const u = ut.get(e), f = (B ? void 0 : He.get(e)) ?? (u !== void 0 ? Te[u] : void 0) ?? {}, N = Q(P, o, f);
942
- if (N) {
943
- re(($) => ({ ...$, [e]: { kind: "error", message: N } }));
986
+ if (l > 0) {
987
+ const m = mt.get(e), f = (z ? void 0 : Ue.get(e)) ?? (m !== void 0 ? Te[m] : void 0) ?? {}, _ = Q(ae, l, f) ?? Rn(e, l, r, f);
988
+ if (_) {
989
+ G((S) => ({ ...S, [e]: { kind: "error", message: _ } }));
944
990
  return;
945
991
  }
946
992
  }
947
- const d = o > 0 ? await _n(e) : {};
948
- if (Ve && y) {
949
- const u = He.get(e);
950
- if ((u == null ? void 0 : u.id) != null) {
951
- const f = String(u.id);
952
- if (o === 0) {
953
- y.cancelPendingEdit(m, k, f), y.queueDelete(m, k, f);
993
+ const d = l > 0 ? await Fn(e) : {};
994
+ if (Ve && k) {
995
+ const m = Ue.get(e);
996
+ if ((m == null ? void 0 : m.id) != null) {
997
+ const f = String(m.id);
998
+ if (l === 0) {
999
+ k.cancelPendingEdit(u, x, f), k.queueDelete(u, x, f);
954
1000
  return;
955
1001
  }
956
- ct.has(f) && y.cancelPendingDelete(m, k, f);
957
- const N = et(e, o, r, d);
958
- for (const g of se)
959
- u[g] != null && u[g] !== "" && (N[g] = u[g]);
960
- for (const [g, D] of Object.entries(a.compute_fields ?? {})) {
961
- const Ae = nt(D, { ...u, ...N });
962
- Ae !== null && (N[g] = Ae);
1002
+ ut.has(f) && k.cancelPendingDelete(u, x, f);
1003
+ const _ = Qe(e, l, r, d);
1004
+ for (const y of te)
1005
+ m[y] != null && m[y] !== "" && (_[y] = m[y]);
1006
+ for (const [y, I] of Object.entries(a.compute_fields ?? {})) {
1007
+ const Ce = Be(I, { ...m, ..._ });
1008
+ Ce !== null && (_[y] = Ce);
963
1009
  }
964
- const $ = Fe.find((g) => String(g.id) === f) ?? {}, J = Object.fromEntries(
965
- Object.entries(N).filter(([g, D]) => String(D ?? "") !== String($[g] ?? ""))
1010
+ const S = Fe.find((y) => String(y.id) === f) ?? {}, E = Object.fromEntries(
1011
+ Object.entries(_).filter(([y, I]) => String(I ?? "") !== String(S[y] ?? ""))
966
1012
  );
967
- Object.keys(J).length === 0 ? y.cancelPendingEdit(m, k, f) : (y.cancelPendingEdit(m, k, f), y.queueEdit(m, k, f, J));
1013
+ Object.keys(E).length === 0 ? k.cancelPendingEdit(u, x, f) : (k.cancelPendingEdit(u, x, f), k.queueEdit(u, x, f, E));
968
1014
  return;
969
1015
  }
970
1016
  }
971
- if (B || Ve) {
972
- const u = ut.get(e);
973
- o === 0 ? u !== void 0 && (y == null || y.removeRow(m, k, u)) : u !== void 0 ? y == null || y.updateRow(
974
- m,
975
- k,
1017
+ if (z || Ve) {
1018
+ const m = mt.get(e);
1019
+ l === 0 ? m !== void 0 && (k == null || k.removeRow(u, x, m)) : m !== void 0 ? k == null || k.updateRow(
976
1020
  u,
977
- ts(
978
- Te[u],
979
- et(e, o, r, d),
980
- se,
1021
+ x,
1022
+ m,
1023
+ ls(
1024
+ Te[m],
1025
+ Qe(e, l, r, d),
1026
+ te,
981
1027
  a.compute_fields
982
1028
  )
983
- ) : y == null || y.queueRow(
984
- m,
985
- k,
986
- et(e, o, r, d)
1029
+ ) : k == null || k.queueRow(
1030
+ u,
1031
+ x,
1032
+ Qe(e, l, r, d)
987
1033
  );
988
1034
  return;
989
1035
  }
990
- ae((u) => new Set(u).add(e));
1036
+ se((m) => new Set(m).add(e));
991
1037
  try {
992
- const u = He.get(e);
993
- if (o === 0)
994
- (u == null ? void 0 : u.id) != null && await x.request(Cn(`/items/${m}/${u.id}`));
995
- else if ((u == null ? void 0 : u.id) != null) {
996
- const f = et(e, o, r, d);
997
- for (const g of se)
998
- u[g] != null && u[g] !== "" && (f[g] = u[g]);
999
- for (const [g, D] of Object.entries(a.compute_fields ?? {})) {
1000
- const Ae = nt(D, { ...u, ...f });
1001
- Ae !== null && (f[g] = Ae);
1038
+ const m = Ue.get(e);
1039
+ if (l === 0)
1040
+ (m == null ? void 0 : m.id) != null && await g.request(Wn(`/items/${u}/${m.id}${re}`));
1041
+ else if ((m == null ? void 0 : m.id) != null) {
1042
+ const f = Qe(e, l, r, d);
1043
+ for (const y of te)
1044
+ m[y] != null && m[y] !== "" && (f[y] = m[y]);
1045
+ for (const [y, I] of Object.entries(a.compute_fields ?? {})) {
1046
+ const Ce = Be(I, { ...m, ...f });
1047
+ Ce !== null && (f[y] = Ce);
1002
1048
  }
1003
- const N = { ...u, ...f }, { id: $, ...J } = N;
1004
- await x.request(Br(`/items/${m}/${u.id}`, J));
1049
+ const _ = { ...m, ...f }, { id: S, ...E } = _;
1050
+ await g.request(Mr(`/items/${u}/${m.id}${re}`, E));
1005
1051
  } else
1006
- await x.request(
1007
- Qr(`/items/${m}`, {
1008
- [k]: _,
1009
- ...et(e, o, r, d)
1052
+ await g.request(
1053
+ Vr(`/items/${u}${re}`, {
1054
+ [x]: w,
1055
+ ...Qe(e, l, r, d)
1010
1056
  })
1011
1057
  );
1012
- F.invalidateQueries({ queryKey: ["o2m-rows", m, k, _] });
1058
+ j.invalidateQueries({ queryKey: ["o2m-rows", u, x, w] });
1013
1059
  } catch {
1014
1060
  } finally {
1015
- ae((u) => {
1016
- const f = new Set(u);
1061
+ se((m) => {
1062
+ const f = new Set(m);
1017
1063
  return f.delete(e), f;
1018
1064
  });
1019
1065
  }
1020
1066
  }
1021
- async function qn(e, t, r) {
1067
+ async function Pn(e, t, r) {
1022
1068
  const n = r.trim() === "" ? null : Number(r);
1023
1069
  if (r.trim() !== "" && Number.isNaN(n)) return;
1024
- const l = (h) => {
1070
+ const o = (h) => {
1025
1071
  const d = { ...h, [t]: n };
1026
- for (const [u, f] of Object.entries(a.compute_fields ?? {})) {
1027
- const N = nt(f, d);
1028
- N !== null && (d[u] = N);
1072
+ for (const [m, f] of Object.entries(a.compute_fields ?? {})) {
1073
+ const _ = Be(f, d);
1074
+ _ !== null && (d[m] = _);
1029
1075
  }
1030
1076
  return d;
1031
- }, o = B ? void 0 : He.get(e);
1032
- if ((o == null ? void 0 : o.id) == null) {
1033
- const h = ut.get(e);
1077
+ }, l = z ? void 0 : Ue.get(e);
1078
+ if ((l == null ? void 0 : l.id) == null) {
1079
+ const h = mt.get(e);
1034
1080
  if (h === void 0) return;
1035
- y == null || y.updateRow(m, k, h, l(Te[h]));
1081
+ k == null || k.updateRow(u, x, h, o(Te[h]));
1036
1082
  return;
1037
1083
  }
1038
- if (Ve && y) {
1039
- const h = l(o), d = Fe.find((f) => String(f.id) === String(o.id)) ?? {}, u = Object.fromEntries(
1084
+ if (Ve && k) {
1085
+ const h = o(l), d = Fe.find((f) => String(f.id) === String(l.id)) ?? {}, m = Object.fromEntries(
1040
1086
  Object.entries(h).filter(
1041
- ([f, N]) => f !== "id" && String(N ?? "") !== String(d[f] ?? "")
1087
+ ([f, _]) => f !== "id" && String(_ ?? "") !== String(d[f] ?? "")
1042
1088
  )
1043
1089
  );
1044
- y.cancelPendingEdit(m, k, String(o.id)), Object.keys(u).length > 0 && y.queueEdit(m, k, String(o.id), u);
1090
+ k.cancelPendingEdit(u, x, String(l.id)), Object.keys(m).length > 0 && k.queueEdit(u, x, String(l.id), m);
1045
1091
  return;
1046
1092
  }
1047
- ae((h) => new Set(h).add(e));
1093
+ se((h) => new Set(h).add(e));
1048
1094
  try {
1049
- const { id: h, ...d } = l(o);
1050
- await x.request(Br(`/items/${m}/${o.id}`, d)), F.invalidateQueries({ queryKey: ["o2m-rows", m, k, _] });
1095
+ const { id: h, ...d } = o(l);
1096
+ await g.request(Mr(`/items/${u}/${l.id}${re}`, d)), j.invalidateQueries({ queryKey: ["o2m-rows", u, x, w] });
1051
1097
  } catch {
1052
1098
  } finally {
1053
- ae((h) => {
1099
+ se((h) => {
1054
1100
  const d = new Set(h);
1055
1101
  return d.delete(e), d;
1056
1102
  });
1057
1103
  }
1058
1104
  }
1059
- async function $n(e) {
1060
- if (e == null || e === "" || !p) return;
1061
- const t = String(e), r = Be(t);
1105
+ async function En(e) {
1106
+ if (e == null || e === "" || !b) return;
1107
+ const t = String(e), r = Ke(t);
1062
1108
  let n = r;
1063
- Object.keys(r).length <= 1 && (n = await x.request(
1064
- R(`/items/${p}`, {
1109
+ Object.keys(r).length <= 1 && (n = await g.request(
1110
+ O(`/items/${b}`, {
1065
1111
  filter: JSON.stringify({ id: { _eq: e } }),
1066
- fields: E,
1112
+ fields: T,
1067
1113
  limit: 1
1068
1114
  })
1069
- ).then((o) => {
1115
+ ).then((l) => {
1070
1116
  var h;
1071
- return ((h = o.data) == null ? void 0 : h[0]) ?? { id: e };
1117
+ return ((h = l.data) == null ? void 0 : h[0]) ?? { id: e };
1072
1118
  }).catch(() => ({ id: e })));
1073
- const l = (ke(t) ?? 0) + 1;
1074
- await tt(t, String(l), n);
1119
+ const o = (we(t) ?? 0) + 1;
1120
+ await tt(t, String(o), n);
1075
1121
  }
1076
- const jn = ue.length, Xt = Object.keys(a.copy_fields ?? {}), er = Object.keys(a.compute_fields ?? {}), qt = (e, t) => {
1077
- const r = ke(e);
1078
- if (b)
1122
+ const Ln = pe.length, er = Object.keys(a.copy_fields ?? {}), tr = Object.keys(a.compute_fields ?? {}), jt = (e, t) => {
1123
+ const r = we(e);
1124
+ if (p)
1079
1125
  return /* @__PURE__ */ s("span", { className: "inline-block w-20 shrink-0 text-right tabular-nums text-slate-700 dark:text-slate-200", children: r && r > 0 ? r : "—" });
1080
- const n = Ee[e], l = n !== void 0 ? n : r && r > 0 ? String(r) : "", o = he[e], h = () => re((u) => {
1081
- if (!(e in u)) return u;
1082
- const f = { ...u };
1126
+ const n = ye[e], o = n !== void 0 ? n : r && r > 0 ? String(r) : "", l = Y[e], h = () => G((m) => {
1127
+ if (!(e in m)) return m;
1128
+ const f = { ...m };
1083
1129
  return delete f[e], f;
1084
1130
  }), d = /* @__PURE__ */ s(
1085
1131
  "input",
1086
1132
  {
1087
1133
  type: "number",
1088
1134
  min: 0,
1089
- step: Dr(v) ? 1 : "any",
1090
- disabled: b,
1091
- value: l,
1135
+ step: lr(le) ? 1 : "any",
1136
+ disabled: p,
1137
+ value: o,
1092
1138
  placeholder: "0",
1093
- "aria-invalid": (o == null ? void 0 : o.kind) === "error" || void 0,
1139
+ "aria-invalid": (l == null ? void 0 : l.kind) === "error" || void 0,
1094
1140
  onFocus: h,
1095
- onChange: (u) => Ne((f) => ({ ...f, [e]: u.target.value })),
1096
- onBlur: (u) => {
1097
- const f = u.target.value;
1098
- Ne((N) => {
1099
- const $ = { ...N };
1100
- return delete $[e], $;
1141
+ onChange: (m) => he((f) => ({ ...f, [e]: m.target.value })),
1142
+ onBlur: (m) => {
1143
+ const f = m.target.value, _ = bs(f, le);
1144
+ if (_) {
1145
+ G((S) => ({ ...S, [e]: { kind: "error", message: _ } }));
1146
+ return;
1147
+ }
1148
+ he((S) => {
1149
+ const E = { ...S };
1150
+ return delete E[e], E;
1101
1151
  }), tt(e, f, t);
1102
1152
  },
1103
- onKeyDown: (u) => {
1104
- u.key === "Enter" && u.currentTarget.blur();
1153
+ onKeyDown: (m) => {
1154
+ m.key === "Enter" && m.currentTarget.blur();
1105
1155
  },
1106
- className: I(
1156
+ className: K(
1107
1157
  "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",
1108
- (o == null ? void 0 : o.kind) === "error" && "border-red-400 dark:border-red-600"
1158
+ (l == null ? void 0 : l.kind) === "error" && "border-red-400 dark:border-red-600"
1109
1159
  )
1110
1160
  }
1111
1161
  );
1112
- return /* @__PURE__ */ c(Mn, { open: (o == null ? void 0 : o.kind) === "remove", onOpenChange: (u) => !u && h(), children: [
1113
- /* @__PURE__ */ s(Un, { asChild: !0, children: /* @__PURE__ */ c("span", { className: "inline-flex shrink-0 flex-col items-end", children: [
1162
+ return /* @__PURE__ */ c(es, { open: (l == null ? void 0 : l.kind) === "remove", onOpenChange: (m) => !m && h(), children: [
1163
+ /* @__PURE__ */ s(ts, { asChild: !0, children: /* @__PURE__ */ c("span", { className: "inline-flex shrink-0 flex-col items-end", children: [
1114
1164
  d,
1115
- (o == null ? void 0 : o.kind) === "error" && /* @__PURE__ */ c(
1165
+ (l == null ? void 0 : l.kind) === "error" && /* @__PURE__ */ c(
1116
1166
  "span",
1117
1167
  {
1118
1168
  role: "alert",
1119
1169
  className: "mt-0.5 flex max-w-[220px] items-start gap-1 text-right text-[11px] leading-snug text-red-600 dark:text-red-400",
1120
1170
  "data-catalog-qty-error": !0,
1121
1171
  children: [
1122
- /* @__PURE__ */ s(tr, { className: "mt-px h-3 w-3 shrink-0" }),
1123
- o.message,
1172
+ /* @__PURE__ */ s(rr, { className: "mt-px h-3 w-3 shrink-0" }),
1173
+ l.message,
1124
1174
  r && r > 0 ? ` — still ${r}` : ""
1125
1175
  ]
1126
1176
  }
1127
1177
  )
1128
1178
  ] }) }),
1129
1179
  /* @__PURE__ */ s(
1130
- Yn,
1180
+ rs,
1131
1181
  {
1132
1182
  align: "end",
1133
1183
  side: "bottom",
1134
1184
  className: "w-auto max-w-[260px] p-2.5 text-[12px]",
1135
- children: (o == null ? void 0 : o.kind) === "remove" && /* @__PURE__ */ c("div", { "data-catalog-qty-remove": !0, children: [
1185
+ children: (l == null ? void 0 : l.kind) === "remove" && /* @__PURE__ */ c("div", { "data-catalog-qty-remove": !0, children: [
1136
1186
  /* @__PURE__ */ s("p", { className: "text-slate-700 dark:text-slate-200", children: "Remove this line?" }),
1137
1187
  /* @__PURE__ */ c("div", { className: "mt-2 flex justify-end gap-1.5", children: [
1138
1188
  /* @__PURE__ */ s(
@@ -1149,8 +1199,8 @@ function As({
1149
1199
  {
1150
1200
  type: "button",
1151
1201
  onClick: () => {
1152
- const u = o.row;
1153
- h(), tt(e, "0", u, { confirmedRemove: !0 });
1202
+ const m = l.row;
1203
+ h(), tt(e, "0", m, { confirmedRemove: !0 });
1154
1204
  },
1155
1205
  className: "h-6 rounded bg-red-600 px-2 text-[11px] font-medium text-white hover:bg-red-700",
1156
1206
  children: "Remove"
@@ -1161,11 +1211,11 @@ function As({
1161
1211
  }
1162
1212
  )
1163
1213
  ] });
1164
- }, Fn = (e, t, r) => {
1165
- const n = `${e}:${t}`, l = de[n], o = () => V((d) => {
1214
+ }, An = (e, t, r) => {
1215
+ const n = `${e}:${t}`, o = _e[n], l = () => fe((d) => {
1166
1216
  if (!(n in d)) return d;
1167
- const u = { ...d };
1168
- return delete u[n], u;
1217
+ const m = { ...d };
1218
+ return delete m[n], m;
1169
1219
  }), h = r[t] == null ? "" : String(r[t]);
1170
1220
  return /* @__PURE__ */ c("span", { className: "inline-flex shrink-0 flex-col items-end", children: [
1171
1221
  /* @__PURE__ */ s(
@@ -1175,60 +1225,60 @@ function As({
1175
1225
  min: 0,
1176
1226
  step: "any",
1177
1227
  defaultValue: h,
1178
- "aria-invalid": !!l || void 0,
1179
- onFocus: o,
1228
+ "aria-invalid": !!o || void 0,
1229
+ onFocus: l,
1180
1230
  onBlur: (d) => {
1181
- const u = d.target.value;
1182
- if (u !== h) {
1183
- const f = be.find((J) => J.field === t), N = Vr(u, {
1231
+ const m = d.target.value;
1232
+ if (m !== h) {
1233
+ const f = L.find((E) => E.field === t), _ = or(m, {
1184
1234
  type: f == null ? void 0 : f.type,
1185
- label: (f == null ? void 0 : f.label) || U(t)
1186
- }), $ = N.ok ? Q(t, N.value, r) : N.message;
1187
- if ($) {
1188
- d.target.value = h, V((J) => ({ ...J, [n]: $ }));
1235
+ label: (f == null ? void 0 : f.label) || M(t)
1236
+ }), S = _.ok ? Q(t, _.value, r) : _.message;
1237
+ if (S) {
1238
+ d.target.value = h, fe((E) => ({ ...E, [n]: S }));
1189
1239
  return;
1190
1240
  }
1191
1241
  }
1192
- qn(e, t, u);
1242
+ Pn(e, t, m);
1193
1243
  },
1194
1244
  onKeyDown: (d) => {
1195
1245
  d.key === "Enter" && d.currentTarget.blur();
1196
1246
  },
1197
- className: I(
1247
+ className: K(
1198
1248
  "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",
1199
- l && "border-red-400 dark:border-red-600"
1249
+ o && "border-red-400 dark:border-red-600"
1200
1250
  )
1201
1251
  },
1202
1252
  `${n}:${h}`
1203
1253
  ),
1204
- l && /* @__PURE__ */ c(
1254
+ o && /* @__PURE__ */ c(
1205
1255
  "span",
1206
1256
  {
1207
1257
  role: "alert",
1208
1258
  className: "mt-0.5 flex max-w-[220px] items-start gap-1 text-right text-[11px] leading-snug text-red-600 dark:text-red-400",
1209
1259
  "data-catalog-cell-error": !0,
1210
1260
  children: [
1211
- /* @__PURE__ */ s(tr, { className: "mt-px h-3 w-3 shrink-0" }),
1212
- l,
1261
+ /* @__PURE__ */ s(rr, { className: "mt-px h-3 w-3 shrink-0" }),
1262
+ o,
1213
1263
  h !== "" ? ` — still ${h}` : ""
1214
1264
  ]
1215
1265
  }
1216
1266
  )
1217
1267
  ] }, n);
1218
1268
  };
1219
- return !p && ve ? /* @__PURE__ */ c("div", { className: "space-y-2 py-1", "aria-busy": "true", children: [
1269
+ return !b && q ? /* @__PURE__ */ c("div", { className: "space-y-2 py-1", "aria-busy": "true", children: [
1220
1270
  /* @__PURE__ */ s("div", { className: "h-8 w-full animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" }),
1221
1271
  /* @__PURE__ */ s("div", { className: "h-8 w-2/3 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" })
1222
- ] }) : p ? /* @__PURE__ */ c("div", { ref: jr, className: "space-y-3", children: [
1223
- !b && /* @__PURE__ */ c(we, { children: [
1272
+ ] }) : b ? /* @__PURE__ */ c("div", { ref: Or, className: "space-y-3", children: [
1273
+ !p && /* @__PURE__ */ c(Ne, { children: [
1224
1274
  /* @__PURE__ */ c("div", { className: "rounded-lg border border-slate-200 text-[12px] dark:border-border", children: [
1225
1275
  /* @__PURE__ */ c("div", { className: "flex items-center gap-2 border-b border-slate-200 px-3 py-2 dark:border-border", children: [
1226
- /* @__PURE__ */ s($t, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
1276
+ /* @__PURE__ */ s(Ft, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
1227
1277
  /* @__PURE__ */ s(
1228
1278
  "input",
1229
1279
  {
1230
- value: z,
1231
- onChange: (e) => $e(e.target.value),
1280
+ value: V,
1281
+ onChange: (e) => Pe(e.target.value),
1232
1282
  placeholder: "Search catalog…",
1233
1283
  className: "w-full bg-transparent text-[12px] outline-none placeholder:text-slate-400"
1234
1284
  }
@@ -1238,28 +1288,28 @@ function As({
1238
1288
  {
1239
1289
  type: "button",
1240
1290
  "aria-pressed": ee,
1241
- "aria-disabled": qe === null ? "true" : void 0,
1291
+ "aria-disabled": $e === null ? "true" : void 0,
1242
1292
  onClick: () => {
1243
- qe !== null && Pt(!pr);
1293
+ $e !== null && Lt(!gr);
1244
1294
  },
1245
1295
  "data-catalog-in-stock": ee ? "on" : "off",
1246
- "data-tip": qe === null ? `Choose ${rn ?? "where stock is counted"} to show only items in stock there` : ee ? "Showing only items with stock on hand — click to show everything" : "Show only items with stock on hand",
1247
- className: I(
1296
+ "data-tip": $e === null ? `Choose ${ln ?? "where stock is counted"} to show only items in stock there` : ee ? "Showing only items with stock on hand — click to show everything" : "Show only items with stock on hand",
1297
+ className: K(
1248
1298
  "inline-flex h-6 max-w-[220px] shrink-0 items-center gap-1 rounded border px-1.5 text-[11px] font-medium transition-colors duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan aria-disabled:cursor-not-allowed aria-disabled:opacity-50",
1249
1299
  ee ? "border-nvr-cyan/40 bg-nvr-cyan/10 text-[#00728d] dark:border-nvr-cyan/40 dark:bg-nvr-cyan/15 dark:text-nvr-cyan" : "border-slate-200 bg-white text-slate-600 hover:bg-muted dark:border-border dark:bg-background dark:text-slate-300"
1250
1300
  ),
1251
1301
  children: [
1252
- dn ? /* @__PURE__ */ s(ne, { className: "h-3 w-3 shrink-0 animate-spin" }) : /* @__PURE__ */ s(Rn, { className: "h-3 w-3 shrink-0" }),
1302
+ fn ? /* @__PURE__ */ s(ce, { className: "h-3 w-3 shrink-0 animate-spin" }) : /* @__PURE__ */ s(Cn, { className: "h-3 w-3 shrink-0" }),
1253
1303
  /* @__PURE__ */ c("span", { className: "truncate", children: [
1254
1304
  "In stock",
1255
- qe !== null && Le && br != null && /* @__PURE__ */ c(we, { children: [
1305
+ $e !== null && Ae && yr != null && /* @__PURE__ */ c(Ne, { children: [
1256
1306
  " at ",
1257
1307
  /* @__PURE__ */ s(
1258
- ds,
1308
+ ys,
1259
1309
  {
1260
- parentCollection: q,
1261
- field: Le,
1262
- id: br
1310
+ parentCollection: N,
1311
+ field: Ae,
1312
+ id: yr
1263
1313
  }
1264
1314
  )
1265
1315
  ] })
@@ -1267,40 +1317,40 @@ function As({
1267
1317
  ]
1268
1318
  }
1269
1319
  ),
1270
- X && qe === null && /* @__PURE__ */ s("span", { className: "shrink-0 text-[11px] text-slate-500 dark:text-slate-400", children: "Pick a place first" }),
1320
+ X && $e === null && /* @__PURE__ */ s("span", { className: "shrink-0 text-[11px] text-slate-500 dark:text-slate-400", children: "Pick a place first" }),
1271
1321
  /* @__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: [
1272
- jn,
1322
+ Ln,
1273
1323
  " picked"
1274
1324
  ] }),
1275
- /* @__PURE__ */ s(rr, { show: Re.customized, onReset: Re.reset })
1325
+ /* @__PURE__ */ s(nr, { show: Oe.customized, onReset: Oe.reset })
1276
1326
  ] }),
1277
- qr && // Sticky: the catalog list is tall and the page scroller carries it —
1327
+ Fr && // Sticky: the catalog list is tall and the page scroller carries it —
1278
1328
  // without this the labels scroll away and favorites/section rows
1279
1329
  // read as headerless columns. Opaque bg (not the /60 tint) so rows
1280
1330
  // never bleed through while pinned.
1281
1331
  /* @__PURE__ */ c(
1282
1332
  "div",
1283
1333
  {
1284
- ref: kn,
1334
+ ref: _n,
1285
1335
  className: "sticky top-0 z-[5] flex items-center gap-4 border-b border-slate-200 bg-slate-50 px-3 py-1 text-[10px] font-medium uppercase tracking-wide text-slate-500 dark:border-border dark:bg-muted dark:text-slate-400",
1286
1336
  children: [
1287
1337
  a.favorites && /* @__PURE__ */ s("span", { className: "w-[18px] shrink-0" }),
1288
- St(Re, "item", "Item", "w-36 shrink-0"),
1289
- wt.map((e) => {
1290
- const [t, r] = Fr(e);
1291
- return St(
1292
- Re,
1338
+ qt(Oe, "item", "Item", "w-36 shrink-0"),
1339
+ vt.map((e) => {
1340
+ const [t, r] = Rr(e);
1341
+ return qt(
1342
+ Oe,
1293
1343
  e.field,
1294
- e.label ?? U(e.field.split(".")[0]),
1344
+ e.label ?? M(e.field.split(".")[0]),
1295
1345
  t,
1296
1346
  r
1297
1347
  );
1298
1348
  }),
1299
- Ut.map(
1300
- (e) => St(
1301
- Re,
1349
+ Yt.map(
1350
+ (e) => qt(
1351
+ Oe,
1302
1352
  `rel:${e.key}`,
1303
- e.label ?? U(e.key),
1353
+ e.label ?? M(e.key),
1304
1354
  "w-20 shrink-0",
1305
1355
  "text-right"
1306
1356
  )
@@ -1311,20 +1361,20 @@ function As({
1311
1361
  ]
1312
1362
  }
1313
1363
  ),
1314
- z.trim().length > 0 && Xe.length === 0 && Bt && /* @__PURE__ */ c("div", { className: "flex items-center justify-center gap-2 border-b border-slate-100 px-3 py-3 text-slate-500 dark:border-border/50 dark:text-slate-400", children: [
1315
- /* @__PURE__ */ s(ne, { className: "h-3.5 w-3.5 animate-spin" }),
1364
+ V.trim().length > 0 && et.length === 0 && Wt && /* @__PURE__ */ c("div", { className: "flex items-center justify-center gap-2 border-b border-slate-100 px-3 py-3 text-slate-500 dark:border-border/50 dark:text-slate-400", children: [
1365
+ /* @__PURE__ */ s(ce, { className: "h-3.5 w-3.5 animate-spin" }),
1316
1366
  " Searching the catalog…"
1317
1367
  ] }),
1318
- z.trim().length > 0 && Xe.length === 0 && !Bt && /* @__PURE__ */ s("p", { className: "px-3 py-4 text-center text-slate-500 dark:text-slate-400", children: ee && ze.length > 0 ? /* @__PURE__ */ c(we, { children: [
1368
+ V.trim().length > 0 && et.length === 0 && !Wt && /* @__PURE__ */ s("p", { className: "px-3 py-4 text-center text-slate-500 dark:text-slate-400", children: ee && ze.length > 0 ? /* @__PURE__ */ c(Ne, { children: [
1319
1369
  'Nothing in stock matches "',
1320
- z.trim(),
1370
+ V.trim(),
1321
1371
  '" —',
1322
1372
  " ",
1323
1373
  /* @__PURE__ */ c(
1324
1374
  "button",
1325
1375
  {
1326
1376
  type: "button",
1327
- onClick: () => Pt(!1),
1377
+ onClick: () => Lt(!1),
1328
1378
  className: "font-medium text-[#00728d] underline-offset-2 hover:underline dark:text-nvr-cyan",
1329
1379
  children: [
1330
1380
  "show ",
@@ -1333,99 +1383,99 @@ function As({
1333
1383
  ]
1334
1384
  }
1335
1385
  )
1336
- ] }) : /* @__PURE__ */ c(we, { children: [
1386
+ ] }) : /* @__PURE__ */ c(Ne, { children: [
1337
1387
  'No items match "',
1338
- z.trim(),
1388
+ V.trim(),
1339
1389
  '"'
1340
1390
  ] }) }),
1341
- z.trim().length > 0 && Xe.length > 0 && /* @__PURE__ */ c(rt, { children: [
1391
+ V.trim().length > 0 && et.length > 0 && /* @__PURE__ */ c(rt, { children: [
1342
1392
  /* @__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: [
1343
- /* @__PURE__ */ s($t, { className: "h-3 w-3 shrink-0 text-sky-500" }),
1393
+ /* @__PURE__ */ s(Ft, { className: "h-3 w-3 shrink-0 text-sky-500" }),
1344
1394
  /* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Search results" }),
1345
- /* @__PURE__ */ s("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: Xe.length }),
1395
+ /* @__PURE__ */ s("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: et.length }),
1346
1396
  /* @__PURE__ */ c("span", { className: "text-[11px] text-slate-500 dark:text-slate-400", children: [
1347
1397
  "across the entire catalog",
1348
1398
  ee ? ", in stock only" : "",
1349
1399
  " — enter a quantity to add"
1350
1400
  ] }),
1351
- Bt && /* @__PURE__ */ s(ne, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" })
1401
+ Wt && /* @__PURE__ */ s(ce, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" })
1352
1402
  ] }),
1353
- Xe.map((e, t) => {
1354
- const r = String(e.id), n = ke(r);
1403
+ et.map((e, t) => {
1404
+ const r = String(e.id), n = we(r);
1355
1405
  return /* @__PURE__ */ c(
1356
1406
  "div",
1357
1407
  {
1358
- className: I(
1408
+ className: K(
1359
1409
  "flex items-center gap-4 border-b border-slate-100 px-3 py-1 dark:border-border/50",
1360
1410
  t % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
1361
1411
  (n ?? 0) > 0 && "bg-nvr-cyan/5"
1362
1412
  ),
1363
1413
  children: [
1364
- Ot(r),
1365
- Gt(
1414
+ Et(r),
1415
+ Xt(
1366
1416
  r,
1367
- Ce(L, e),
1417
+ Je(C, e),
1368
1418
  (() => {
1369
- const l = on(e), o = nn.has(r);
1370
- return !l && !o ? null : /* @__PURE__ */ c(we, { children: [
1371
- o && /* @__PURE__ */ s(
1419
+ const o = mn(e), l = on.has(r);
1420
+ return !o && !l ? null : /* @__PURE__ */ c(Ne, { children: [
1421
+ l && /* @__PURE__ */ s(
1372
1422
  "span",
1373
1423
  {
1374
1424
  "data-catalog-recent": !0,
1375
- "data-tip": `You added this in the last ${bt} days`,
1425
+ "data-tip": `You added this in the last ${pt} days`,
1376
1426
  className: "shrink-0 rounded bg-slate-100 px-1.5 py-0.5 text-[10px] font-medium text-slate-600 dark:bg-muted dark:text-slate-400",
1377
1427
  children: "Recent"
1378
1428
  }
1379
1429
  ),
1380
- l && /* @__PURE__ */ s(
1430
+ o && /* @__PURE__ */ s(
1381
1431
  "span",
1382
1432
  {
1383
1433
  "data-catalog-match-why": !0,
1384
- "data-tip": `Matched on ${l}`,
1434
+ "data-tip": `Matched on ${o}`,
1385
1435
  "data-cpf-fit": !0,
1386
1436
  className: "min-w-0 max-w-[160px] shrink-[4] truncate rounded border border-slate-200 bg-slate-50 px-1.5 py-0.5 text-[10px] text-slate-500 dark:border-border dark:bg-muted dark:text-slate-400",
1387
- children: l
1437
+ children: o
1388
1438
  }
1389
1439
  )
1390
1440
  ] });
1391
1441
  })(),
1392
- oe
1442
+ me
1393
1443
  ),
1394
- Zt(r, e, oe),
1395
- /* @__PURE__ */ s("span", { className: "flex w-3.5 shrink-0 items-center justify-center", children: fe.has(r) && /* @__PURE__ */ s(ne, { className: "h-3 w-3 animate-spin text-slate-400" }) }),
1396
- qt(r, e)
1444
+ Gt(r, e, me),
1445
+ /* @__PURE__ */ s("span", { className: "flex w-3.5 shrink-0 items-center justify-center", children: ie.has(r) && /* @__PURE__ */ s(ce, { className: "h-3 w-3 animate-spin text-slate-400" }) }),
1446
+ jt(r, e)
1397
1447
  ]
1398
1448
  },
1399
1449
  r
1400
1450
  );
1401
1451
  })
1402
1452
  ] }),
1403
- w.length > 0 && !z.trim() && /* @__PURE__ */ c("p", { className: "px-3 py-6 text-center text-slate-400", children: [
1453
+ D.length > 0 && !V.trim() && /* @__PURE__ */ c("p", { className: "px-3 py-6 text-center text-slate-400", children: [
1404
1454
  "Search the full catalog above, or select",
1405
1455
  " ",
1406
- w.map((e) => {
1456
+ D.map((e) => {
1407
1457
  var t;
1408
- return ((t = O == null ? void 0 : O.fieldLabels) == null ? void 0 : t[e]) ?? U(e);
1458
+ return ((t = R == null ? void 0 : R.fieldLabels) == null ? void 0 : t[e]) ?? M(e);
1409
1459
  }).join(", "),
1410
1460
  " ",
1411
1461
  "to browse by category"
1412
1462
  ] }),
1413
- w.length === 0 && (Z || it) && /* @__PURE__ */ c("div", { className: "flex items-center justify-center gap-2 py-6 text-slate-500 dark:text-slate-400", children: [
1414
- /* @__PURE__ */ s(ne, { className: "h-4 w-4 animate-spin" }),
1463
+ D.length === 0 && (Se || lt) && /* @__PURE__ */ c("div", { className: "flex items-center justify-center gap-2 py-6 text-slate-500 dark:text-slate-400", children: [
1464
+ /* @__PURE__ */ s(ce, { className: "h-4 w-4 animate-spin" }),
1415
1465
  " Loading catalog…"
1416
1466
  ] }),
1417
- w.length === 0 && !Z && !it && _t.length === 0 && /* @__PURE__ */ s("p", { className: "px-3 py-6 text-center text-slate-500 dark:text-slate-400", children: ee && M.length > 0 ? /* @__PURE__ */ c(we, { children: [
1467
+ D.length === 0 && !Se && !lt && $t.length === 0 && /* @__PURE__ */ s("p", { className: "px-3 py-6 text-center text-slate-500 dark:text-slate-400", children: ee && de.length > 0 ? /* @__PURE__ */ c(Ne, { children: [
1418
1468
  "Nothing in this catalog is in stock here —",
1419
1469
  " ",
1420
1470
  /* @__PURE__ */ c(
1421
1471
  "button",
1422
1472
  {
1423
1473
  type: "button",
1424
- onClick: () => Pt(!1),
1474
+ onClick: () => Lt(!1),
1425
1475
  className: "font-medium text-[#00728d] underline-offset-2 hover:underline dark:text-nvr-cyan",
1426
1476
  children: [
1427
1477
  "show all ",
1428
- M.length
1478
+ de.length
1429
1479
  ]
1430
1480
  }
1431
1481
  )
@@ -1436,71 +1486,71 @@ function As({
1436
1486
  "button",
1437
1487
  {
1438
1488
  type: "button",
1439
- onClick: () => te((e) => {
1489
+ onClick: () => xe((e) => {
1440
1490
  const t = new Set(e);
1441
1491
  return t.has("__favorites__") ? t.delete("__favorites__") : t.add("__favorites__"), t;
1442
1492
  }),
1443
1493
  className: "flex min-w-0 flex-1 items-center gap-1.5 py-0.5 text-left",
1444
1494
  children: [
1445
1495
  /* @__PURE__ */ s(
1446
- sr,
1496
+ ar,
1447
1497
  {
1448
- className: I(
1498
+ className: K(
1449
1499
  "h-3 w-3 shrink-0 text-slate-400 transition-transform",
1450
- !me.has("__favorites__") && "rotate-90"
1500
+ !ne.has("__favorites__") && "rotate-90"
1451
1501
  )
1452
1502
  }
1453
1503
  ),
1454
- /* @__PURE__ */ s(at, { className: "h-3 w-3 shrink-0 fill-amber-400 text-amber-400" }),
1504
+ /* @__PURE__ */ s(st, { className: "h-3 w-3 shrink-0 fill-amber-400 text-amber-400" }),
1455
1505
  /* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Favorites" }),
1456
- /* @__PURE__ */ s("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: Wt.length })
1506
+ /* @__PURE__ */ s("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: Dt.length })
1457
1507
  ]
1458
1508
  }
1459
1509
  ),
1460
1510
  /* @__PURE__ */ s(
1461
1511
  "button",
1462
1512
  {
1463
- ref: mr,
1513
+ ref: br,
1464
1514
  type: "button",
1465
- onClick: () => ur(!0),
1515
+ onClick: () => hr(!0),
1466
1516
  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",
1467
1517
  children: "Manage"
1468
1518
  }
1469
1519
  )
1470
1520
  ] }),
1471
- !me.has("__favorites__") && Wt.length === 0 && /* @__PURE__ */ s("p", { className: "border-b border-slate-100 px-3 py-2 text-center text-[11px] text-slate-400 dark:border-border/50", children: Me.length > 0 ? "None of your favorites are in stock here." : "No favorites yet — Manage lets you search the full catalog and star items." }),
1472
- !me.has("__favorites__") && Wt.map((e, t) => {
1473
- const r = String(e.id), n = ke(r), l = Dt(r);
1521
+ !ne.has("__favorites__") && Dt.length === 0 && /* @__PURE__ */ s("p", { className: "border-b border-slate-100 px-3 py-2 text-center text-[11px] text-slate-400 dark:border-border/50", children: He.length > 0 ? "None of your favorites are in stock here." : "No favorites yet — Manage lets you search the full catalog and star items." }),
1522
+ !ne.has("__favorites__") && Dt.map((e, t) => {
1523
+ const r = String(e.id), n = we(r), o = Mt(r);
1474
1524
  return /* @__PURE__ */ c(
1475
1525
  "div",
1476
1526
  {
1477
- className: I(
1527
+ className: K(
1478
1528
  "flex items-center gap-4 border-b border-slate-100 px-3 py-1 dark:border-border/50",
1479
1529
  t % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
1480
1530
  (n ?? 0) > 0 && "bg-nvr-cyan/5",
1481
- l && "bg-amber-50 dark:bg-amber-900/15"
1531
+ o && "bg-amber-50 dark:bg-amber-900/15"
1482
1532
  ),
1483
1533
  children: [
1484
- Ot(r),
1485
- Gt(r, Ce(L, e)),
1486
- Zt(r, e),
1487
- /* @__PURE__ */ s("span", { className: "flex w-3.5 shrink-0 items-center justify-center", children: fe.has(r) ? /* @__PURE__ */ s(ne, { className: "h-3 w-3 animate-spin text-slate-400" }) : l && /* @__PURE__ */ s(
1488
- st,
1534
+ Et(r),
1535
+ Xt(r, Je(C, e)),
1536
+ Gt(r, e),
1537
+ /* @__PURE__ */ s("span", { className: "flex w-3.5 shrink-0 items-center justify-center", children: ie.has(r) ? /* @__PURE__ */ s(ce, { className: "h-3 w-3 animate-spin text-slate-400" }) : o && /* @__PURE__ */ s(
1538
+ nt,
1489
1539
  {
1490
1540
  className: "h-3.5 w-3.5 text-amber-500",
1491
- "aria-label": `${Vt} ${l.available} — ${l.qty} requested`
1541
+ "aria-label": `${Vt} ${o.available} — ${o.qty} requested`
1492
1542
  }
1493
1543
  ) }),
1494
- qt(r, e)
1544
+ jt(r, e)
1495
1545
  ]
1496
1546
  },
1497
1547
  r
1498
1548
  );
1499
1549
  })
1500
1550
  ] }),
1501
- w.length === 0 && _t.map((e) => {
1502
- const t = me.has(e.name), r = e.items.reduce(
1503
- (n, l) => n + ((ke(l.id) ?? 0) > 0 ? 1 : 0),
1551
+ D.length === 0 && $t.map((e) => {
1552
+ const t = ne.has(e.name), r = e.items.reduce(
1553
+ (n, o) => n + ((we(o.id) ?? 0) > 0 ? 1 : 0),
1504
1554
  0
1505
1555
  );
1506
1556
  return /* @__PURE__ */ c(rt, { children: [
@@ -1508,16 +1558,16 @@ function As({
1508
1558
  "button",
1509
1559
  {
1510
1560
  type: "button",
1511
- onClick: () => te((n) => {
1512
- const l = new Set(n);
1513
- return l.has(e.name) ? l.delete(e.name) : l.add(e.name), l;
1561
+ onClick: () => xe((n) => {
1562
+ const o = new Set(n);
1563
+ return o.has(e.name) ? o.delete(e.name) : o.add(e.name), o;
1514
1564
  }),
1515
1565
  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",
1516
1566
  children: [
1517
1567
  /* @__PURE__ */ s(
1518
- sr,
1568
+ ar,
1519
1569
  {
1520
- className: I(
1570
+ className: K(
1521
1571
  "h-3 w-3 shrink-0 text-slate-400 transition-transform",
1522
1572
  !t && "rotate-90"
1523
1573
  )
@@ -1532,29 +1582,29 @@ function As({
1532
1582
  ]
1533
1583
  }
1534
1584
  ),
1535
- !t && e.items.map((n, l) => {
1536
- const o = ke(n.id), h = Dt(n.id);
1585
+ !t && e.items.map((n, o) => {
1586
+ const l = we(n.id), h = Mt(n.id);
1537
1587
  return /* @__PURE__ */ c(
1538
1588
  "div",
1539
1589
  {
1540
- className: I(
1590
+ className: K(
1541
1591
  "flex items-center gap-4 border-b border-slate-100 px-3 py-1 dark:border-border/50",
1542
- l % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
1543
- (o ?? 0) > 0 && "bg-nvr-cyan/5",
1592
+ o % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
1593
+ (l ?? 0) > 0 && "bg-nvr-cyan/5",
1544
1594
  h && "bg-amber-50 dark:bg-amber-900/15"
1545
1595
  ),
1546
1596
  children: [
1547
- Ot(n.id),
1548
- Gt(n.id, n.label),
1549
- Zt(n.id, n.row),
1550
- /* @__PURE__ */ s("span", { className: "flex w-3.5 shrink-0 items-center justify-center", children: fe.has(n.id) ? /* @__PURE__ */ s(ne, { className: "h-3 w-3 animate-spin text-slate-400" }) : h && /* @__PURE__ */ s(
1551
- st,
1597
+ Et(n.id),
1598
+ Xt(n.id, n.label),
1599
+ Gt(n.id, n.row),
1600
+ /* @__PURE__ */ s("span", { className: "flex w-3.5 shrink-0 items-center justify-center", children: ie.has(n.id) ? /* @__PURE__ */ s(ce, { className: "h-3 w-3 animate-spin text-slate-400" }) : h && /* @__PURE__ */ s(
1601
+ nt,
1552
1602
  {
1553
1603
  className: "h-3.5 w-3.5 text-amber-500",
1554
1604
  "aria-label": `${Vt} ${h.available} — ${h.qty} requested`
1555
1605
  }
1556
1606
  ) }),
1557
- qt(n.id, n.row)
1607
+ jt(n.id, n.row)
1558
1608
  ]
1559
1609
  },
1560
1610
  n.id
@@ -1563,18 +1613,18 @@ function As({
1563
1613
  ] }, e.name);
1564
1614
  })
1565
1615
  ] }),
1566
- (a.builders ?? []).filter((e) => Hr(e.show_when, W)).map((e) => /* @__PURE__ */ s(
1567
- os,
1616
+ (a.builders ?? []).filter((e) => Hr(e.show_when, i)).map((e) => /* @__PURE__ */ s(
1617
+ xs,
1568
1618
  {
1569
1619
  builder: e,
1570
1620
  defaultItemField: a.item_field,
1571
- catalogCol: p,
1572
- catalogFields: E,
1573
- tmpl: L,
1574
- currentQty: ke,
1621
+ catalogCol: b,
1622
+ catalogFields: T,
1623
+ tmpl: C,
1624
+ currentQty: we,
1575
1625
  addQty: (t, r, n) => tt(t, String(r), n),
1576
- qtyStep: Dr(v) ? 1 : "any",
1577
- readOnly: b
1626
+ qtyStep: lr(le) ? 1 : "any",
1627
+ readOnly: p
1578
1628
  },
1579
1629
  e.label
1580
1630
  ))
@@ -1582,11 +1632,11 @@ function As({
1582
1632
  /* @__PURE__ */ c("div", { className: "rounded-lg border border-slate-200 text-[12px] dark:border-border", children: [
1583
1633
  /* @__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: [
1584
1634
  /* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Summary" }),
1585
- !b && /* @__PURE__ */ c("div", { className: "flex items-center gap-2", onClick: (e) => e.stopPropagation(), children: [
1586
- a.upload_template && !B && G && q && /* @__PURE__ */ s(
1587
- Vn,
1635
+ !p && /* @__PURE__ */ c("div", { className: "flex items-center gap-2", onClick: (e) => e.stopPropagation(), children: [
1636
+ a.upload_template && !z && Z && N && /* @__PURE__ */ s(
1637
+ Gn,
1588
1638
  {
1589
- collection: q,
1639
+ collection: N,
1590
1640
  templateFilter: (e) => {
1591
1641
  var t;
1592
1642
  return e.name === a.upload_template && ((t = e.reimport) == null ? void 0 : t.enabled) === !0;
@@ -1595,74 +1645,74 @@ function As({
1595
1645
  var t;
1596
1646
  return ((t = e.reimport) == null ? void 0 : t.button_label) ?? e.button_label;
1597
1647
  },
1598
- onParsed: (e, t) => G(e, t),
1648
+ onParsed: (e, t) => Z(e, t),
1599
1649
  compact: !0
1600
1650
  }
1601
1651
  ),
1602
1652
  /* @__PURE__ */ s("div", { className: "w-64", children: /* @__PURE__ */ s(
1603
- as,
1653
+ us,
1604
1654
  {
1605
- collection: p,
1655
+ collection: b,
1606
1656
  value: null,
1607
- onChange: (e) => void $n(e),
1657
+ onChange: (e) => void En(e),
1608
1658
  placeholder: "+ Add any item…"
1609
1659
  }
1610
1660
  ) })
1611
1661
  ] })
1612
1662
  ] }),
1613
- ue.length === 0 ? /* @__PURE__ */ s("p", { className: "px-3 py-4 text-center text-slate-400", children: "Nothing picked yet" }) : (() => {
1614
- const e = Sr.filter((d) => !d.format), t = e[0], r = e.slice(1), n = Sr.filter((d) => !!d.format), l = (d, u) => u === "presence" ? d == null || d === "" || Number(d) === 0 ? "No" : "Yes" : d === !0 || d === "true" ? "✓" : d === !1 || d === "false" || d == null || d === "" ? "—" : ye(d, u), o = (d, u) => u ? St(
1615
- ge,
1616
- u,
1663
+ pe.length === 0 ? /* @__PURE__ */ s("p", { className: "px-3 py-4 text-center text-slate-400", children: "Nothing picked yet" }) : (() => {
1664
+ const e = $r.filter((d) => !d.format), t = e[0], r = e.slice(1), n = $r.filter((d) => !!d.format), o = (d, m) => m === "presence" ? d == null || d === "" || Number(d) === 0 ? "No" : "Yes" : d === !0 || d === "true" ? "✓" : d === !1 || d === "false" || d == null || d === "" ? "—" : ge(d, m), l = (d, m) => m ? qt(
1665
+ ke,
1666
+ m,
1617
1667
  d,
1618
1668
  "w-20 shrink-0",
1619
1669
  "text-right text-[11px] font-medium text-slate-500 dark:text-slate-400"
1620
- ) : /* @__PURE__ */ s("span", { className: "w-20 shrink-0 text-right text-[11px] font-medium text-slate-500 dark:text-slate-400", children: d }), h = (d) => se.includes(d) && !b ? void 0 : `s:${d}`;
1670
+ ) : /* @__PURE__ */ s("span", { className: "w-20 shrink-0 text-right text-[11px] font-medium text-slate-500 dark:text-slate-400", children: d }), h = (d) => te.includes(d) && !p ? void 0 : `s:${d}`;
1621
1671
  return /* @__PURE__ */ c("div", { children: [
1622
1672
  /* @__PURE__ */ c("div", { className: "flex items-center gap-4 border-b border-slate-200 px-3 py-1.5 dark:border-border", children: [
1623
1673
  /* @__PURE__ */ c("span", { className: "flex flex-1 items-center gap-1 text-[11px] font-medium text-slate-500 dark:text-slate-400", children: [
1624
1674
  "Item",
1625
- b && /* @__PURE__ */ s(
1626
- rr,
1675
+ p && /* @__PURE__ */ s(
1676
+ nr,
1627
1677
  {
1628
- show: ge.customized,
1629
- onReset: ge.reset,
1678
+ show: ke.customized,
1679
+ onReset: ke.reset,
1630
1680
  className: "-my-1"
1631
1681
  }
1632
1682
  )
1633
1683
  ] }),
1634
- Xt.map((d) => /* @__PURE__ */ s(rt, { children: o(U(d), h(d)) }, d)),
1635
- o(U(P)),
1636
- er.map((d) => /* @__PURE__ */ s(rt, { children: o(U(d), `s:${d}`) }, d)),
1637
- !b && /* @__PURE__ */ s("span", { className: "-my-1 flex w-6 shrink-0 justify-end", children: /* @__PURE__ */ s(rr, { show: ge.customized, onReset: ge.reset }) })
1684
+ er.map((d) => /* @__PURE__ */ s(rt, { children: l(M(d), h(d)) }, d)),
1685
+ l(M(ae)),
1686
+ tr.map((d) => /* @__PURE__ */ s(rt, { children: l(M(d), `s:${d}`) }, d)),
1687
+ !p && /* @__PURE__ */ s("span", { className: "-my-1 flex w-6 shrink-0 justify-end", children: /* @__PURE__ */ s(nr, { show: ke.customized, onReset: ke.reset }) })
1638
1688
  ] }),
1639
- ue.map((d, u) => {
1640
- const f = d.row.id != null ? String(d.row.id) : null, N = f != null && ct.has(f), $ = N ? null : Dt(d.key), J = N ? null : hn(d.key);
1689
+ pe.map((d, m) => {
1690
+ const f = d.row.id != null ? String(d.row.id) : null, _ = f != null && ut.has(f), S = _ ? null : Mt(d.key), E = _ ? null : yn(d.key);
1641
1691
  return /* @__PURE__ */ c(
1642
1692
  "div",
1643
1693
  {
1644
- className: I(
1694
+ className: K(
1645
1695
  "border-b border-slate-100 px-3 py-2 last:border-b-0 dark:border-border/50",
1646
- u % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
1647
- $ && "bg-amber-50 dark:bg-amber-900/15",
1648
- J && "bg-red-50/70 dark:bg-red-900/15",
1649
- N && "opacity-60"
1696
+ m % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
1697
+ S && "bg-amber-50 dark:bg-amber-900/15",
1698
+ E && "bg-red-50/70 dark:bg-red-900/15",
1699
+ _ && "opacity-60"
1650
1700
  ),
1651
1701
  children: [
1652
1702
  /* @__PURE__ */ c(
1653
1703
  "div",
1654
1704
  {
1655
- className: I(
1705
+ className: K(
1656
1706
  "flex items-center gap-4",
1657
- N && "line-through decoration-slate-400"
1707
+ _ && "line-through decoration-slate-400"
1658
1708
  ),
1659
1709
  children: [
1660
- Tr(
1710
+ Pr(
1661
1711
  d.key,
1662
- Rr(d.key),
1712
+ Er(d.key),
1663
1713
  "shrink-0 font-semibold text-slate-800 dark:text-slate-100"
1664
1714
  ),
1665
- Ve && !N && (f == null || ot.has(f)) && /* @__PURE__ */ s(
1715
+ Ve && !_ && (f == null || dt.has(f)) && /* @__PURE__ */ s(
1666
1716
  "span",
1667
1717
  {
1668
1718
  "data-catalog-staged": f == null ? "new" : "edited",
@@ -1671,214 +1721,216 @@ function As({
1671
1721
  children: f == null ? "New" : "Edited"
1672
1722
  }
1673
1723
  ),
1674
- J && /* @__PURE__ */ s(
1724
+ E && /* @__PURE__ */ s(
1675
1725
  "span",
1676
1726
  {
1677
1727
  className: "shrink-0",
1678
1728
  "data-tip": `This line was in the failed submission
1679
- ${J}`,
1729
+ ${E}`,
1680
1730
  "data-submission-error": !0,
1681
- children: /* @__PURE__ */ s(tr, { className: "h-3.5 w-3.5 text-red-500", strokeWidth: 2 })
1731
+ children: /* @__PURE__ */ s(rr, { className: "h-3.5 w-3.5 text-red-500", strokeWidth: 2 })
1682
1732
  }
1683
1733
  ),
1684
1734
  t && /* @__PURE__ */ s(
1685
- Mr,
1735
+ Yr,
1686
1736
  {
1687
- text: ye(Nt(Be(d.key), t.field), void 0),
1737
+ text: ge(_t(Ke(d.key), t.field), void 0),
1688
1738
  className: "min-w-0 flex-1 text-slate-600 dark:text-slate-300"
1689
1739
  }
1690
1740
  ),
1691
1741
  !t && /* @__PURE__ */ s("span", { className: "flex-1" }),
1692
- r.map((g) => {
1693
- const D = Nt(Be(d.key), g.field);
1694
- return D == null || D === "" ? null : /* @__PURE__ */ s(
1742
+ r.map((y) => {
1743
+ const I = _t(Ke(d.key), y.field);
1744
+ return I == null || I === "" ? null : /* @__PURE__ */ s(
1695
1745
  "span",
1696
1746
  {
1697
1747
  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",
1698
- children: String(D)
1748
+ children: String(I)
1699
1749
  },
1700
- g.field
1750
+ y.field
1701
1751
  );
1702
1752
  }),
1703
- Xt.map(
1704
- (g) => {
1705
- var D;
1706
- return se.includes(g) && !b ? Fn(d.key, g, d.row) : /* @__PURE__ */ s(
1753
+ er.map(
1754
+ (y) => {
1755
+ var I;
1756
+ return On(d.key, y) ? An(d.key, y, d.row) : /* @__PURE__ */ s(
1707
1757
  "span",
1708
1758
  {
1709
- ...ge.box(
1710
- `s:${g}`,
1759
+ "data-catalog-locked": !p && te.includes(y) ? y : void 0,
1760
+ "data-tip": !p && te.includes(y) ? "Set by the catalog — only an administrator can change it" : void 0,
1761
+ ...ke.box(
1762
+ `s:${y}`,
1711
1763
  "w-20 shrink-0",
1712
1764
  "truncate text-right tabular-nums text-slate-600 dark:text-slate-300"
1713
1765
  ),
1714
- children: ye(d.row[g], (D = a.field_formats) == null ? void 0 : D[g])
1766
+ children: ge(d.row[y], (I = a.field_formats) == null ? void 0 : I[y])
1715
1767
  },
1716
- g
1768
+ y
1717
1769
  );
1718
1770
  }
1719
1771
  ),
1720
1772
  /* @__PURE__ */ c("span", { className: "inline-flex w-20 shrink-0 items-center justify-end gap-1", children: [
1721
- fe.has(d.key) && /* @__PURE__ */ s(ne, { className: "h-3 w-3 animate-spin text-slate-400" }),
1722
- qt(d.key, Be(d.key))
1773
+ ie.has(d.key) && /* @__PURE__ */ s(ce, { className: "h-3 w-3 animate-spin text-slate-400" }),
1774
+ jt(d.key, Ke(d.key))
1723
1775
  ] }),
1724
- er.map((g) => {
1725
- var Ir, zr;
1726
- if (N)
1776
+ tr.map((y) => {
1777
+ var Br, Wr;
1778
+ if (_)
1727
1779
  return /* @__PURE__ */ s(
1728
1780
  "span",
1729
1781
  {
1730
1782
  "data-tip": "Not counted — this line is removed when you save",
1731
- ...ge.box(
1732
- `s:${g}`,
1783
+ ...ke.box(
1784
+ `s:${y}`,
1733
1785
  "w-20 shrink-0",
1734
1786
  "text-right tabular-nums text-slate-400 dark:text-slate-500"
1735
1787
  ),
1736
1788
  children: "—"
1737
1789
  },
1738
- g
1790
+ y
1739
1791
  );
1740
- const D = d.row[g], Ae = D != null && D !== "" ? D : nt(((Ir = a.compute_fields) == null ? void 0 : Ir[g]) ?? "", d.row);
1792
+ const I = d.row[y], Ce = I != null && I !== "" ? I : Be(((Br = a.compute_fields) == null ? void 0 : Br[y]) ?? "", d.row);
1741
1793
  return /* @__PURE__ */ s(
1742
1794
  "span",
1743
1795
  {
1744
- ...ge.box(
1745
- `s:${g}`,
1796
+ ...ke.box(
1797
+ `s:${y}`,
1746
1798
  "w-20 shrink-0",
1747
1799
  "truncate text-right tabular-nums text-slate-600 dark:text-slate-300"
1748
1800
  ),
1749
- children: ye(Ae, (zr = a.field_formats) == null ? void 0 : zr[g])
1801
+ children: ge(Ce, (Wr = a.field_formats) == null ? void 0 : Wr[y])
1750
1802
  },
1751
- g
1803
+ y
1752
1804
  );
1753
1805
  }),
1754
- !b && N && /* @__PURE__ */ s(
1806
+ !p && _ && /* @__PURE__ */ s(
1755
1807
  "button",
1756
1808
  {
1757
1809
  type: "button",
1758
- onClick: () => y == null ? void 0 : y.cancelPendingDelete(m, k, f),
1810
+ onClick: () => k == null ? void 0 : k.cancelPendingDelete(u, x, f),
1759
1811
  className: "shrink-0 rounded px-1.5 py-0.5 text-[11px] font-medium text-nvr-navy underline dark:text-nvr-cyan",
1760
1812
  children: "Undo"
1761
1813
  }
1762
1814
  ),
1763
- !b && !N && /* @__PURE__ */ s(
1815
+ !p && !_ && /* @__PURE__ */ s(
1764
1816
  "button",
1765
1817
  {
1766
1818
  type: "button",
1767
1819
  title: "Remove (applies on Save)",
1768
1820
  onClick: () => {
1769
- if (!B && y && f != null) {
1770
- y.queueDelete(m, k, f);
1821
+ if (!z && k && f != null) {
1822
+ k.queueDelete(u, x, f);
1771
1823
  return;
1772
1824
  }
1773
1825
  tt(d.key, "0", {}, { confirmedRemove: !0 });
1774
1826
  },
1775
1827
  className: "w-6 shrink-0 rounded p-0.5 text-slate-300 transition-colors hover:text-red-500",
1776
- children: /* @__PURE__ */ s(jt, { className: "mx-auto h-3.5 w-3.5" })
1828
+ children: /* @__PURE__ */ s(Tt, { className: "mx-auto h-3.5 w-3.5" })
1777
1829
  }
1778
1830
  )
1779
1831
  ]
1780
1832
  }
1781
1833
  ),
1782
- (n.length > 0 || _r.length > 0 || kt.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: [
1783
- n.map((g) => /* @__PURE__ */ c("span", { className: "whitespace-nowrap", children: [
1784
- /* @__PURE__ */ s("span", { className: "text-slate-500 dark:text-muted-foreground", children: g.label ?? U(g.field.split(".")[0]) }),
1834
+ (n.length > 0 || jr.length > 0 || Nt.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: [
1835
+ n.map((y) => /* @__PURE__ */ c("span", { className: "whitespace-nowrap", children: [
1836
+ /* @__PURE__ */ s("span", { className: "text-slate-500 dark:text-muted-foreground", children: y.label ?? M(y.field.split(".")[0]) }),
1785
1837
  " ",
1786
- /* @__PURE__ */ s("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: l(Nt(Be(d.key), g.field), g.format) })
1787
- ] }, g.field)),
1788
- _r.map((g) => /* @__PURE__ */ c("span", { className: "whitespace-nowrap", children: [
1789
- /* @__PURE__ */ s("span", { className: "text-slate-500 dark:text-muted-foreground", children: g.label ?? U(g.key) }),
1838
+ /* @__PURE__ */ s("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: o(_t(Ke(d.key), y.field), y.format) })
1839
+ ] }, y.field)),
1840
+ jr.map((y) => /* @__PURE__ */ c("span", { className: "whitespace-nowrap", children: [
1841
+ /* @__PURE__ */ s("span", { className: "text-slate-500 dark:text-muted-foreground", children: y.label ?? M(y.key) }),
1790
1842
  " ",
1791
- /* @__PURE__ */ s("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: l(Qt(g.key, d.key), g.format) })
1792
- ] }, g.key)),
1793
- gn(d.row),
1794
- cn(d.row).map((g) => /* @__PURE__ */ c(
1843
+ /* @__PURE__ */ s("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: o(kt(y.key, d.key), y.format) })
1844
+ ] }, y.key)),
1845
+ vn(d.row),
1846
+ hn(d.row).map((y) => /* @__PURE__ */ c(
1795
1847
  "span",
1796
1848
  {
1797
1849
  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",
1798
- "data-catalog-row-flag": g,
1850
+ "data-catalog-row-flag": y,
1799
1851
  children: [
1800
- /* @__PURE__ */ s(st, { className: "h-3 w-3" }),
1801
- g
1852
+ /* @__PURE__ */ s(nt, { className: "h-3 w-3" }),
1853
+ y
1802
1854
  ]
1803
1855
  },
1804
- g
1856
+ y
1805
1857
  )),
1806
- kt.map((g) => {
1807
- const D = xn(g, d);
1858
+ Nt.map((y) => {
1859
+ const I = wn(y, d);
1808
1860
  return /* @__PURE__ */ c("span", { className: "whitespace-nowrap", children: [
1809
- /* @__PURE__ */ s("span", { className: "text-slate-500 dark:text-muted-foreground", children: g.label ?? U(g.field) }),
1861
+ /* @__PURE__ */ s("span", { className: "text-slate-500 dark:text-muted-foreground", children: y.label ?? M(y.field) }),
1810
1862
  " ",
1811
- /* @__PURE__ */ s("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: l(D, g.format) })
1812
- ] }, g.field);
1863
+ /* @__PURE__ */ s("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: o(I, y.format) })
1864
+ ] }, y.field);
1813
1865
  })
1814
1866
  ] }),
1815
- $ && /* @__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: [
1816
- /* @__PURE__ */ s(st, { className: "h-3 w-3 shrink-0" }),
1867
+ S && /* @__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: [
1868
+ /* @__PURE__ */ s(nt, { className: "h-3 w-3 shrink-0" }),
1817
1869
  Vt,
1818
1870
  " is ",
1819
- ye($.available, "number"),
1871
+ ge(S.available, "number"),
1820
1872
  " —",
1821
1873
  " ",
1822
- ye($.qty, "number"),
1874
+ ge(S.qty, "number"),
1823
1875
  " requested"
1824
1876
  ] }),
1825
- N && /* @__PURE__ */ s("p", { className: "mt-1 pl-0.5 text-[11px] text-red-500", children: "Removed — applies when you save" })
1877
+ _ && /* @__PURE__ */ s("p", { className: "mt-1 pl-0.5 text-[11px] text-red-500", children: "Removed — applies when you save" })
1826
1878
  ]
1827
1879
  },
1828
1880
  d.key
1829
1881
  );
1830
1882
  }),
1831
1883
  (() => {
1832
- const d = ue.filter(($) => {
1833
- const J = $.row.id != null ? String($.row.id) : null;
1834
- return !(J != null && ct.has(J));
1835
- }), u = ($) => d.reduce((J, g) => {
1836
- const D = Number(g.row[$]);
1837
- return J + (Number.isFinite(D) ? D : 0);
1838
- }, 0), f = ($) => {
1839
- var J;
1840
- return ((J = a.field_formats) == null ? void 0 : J[$]) ?? "number";
1841
- }, N = ($) => /* @__PURE__ */ s(
1884
+ const d = pe.filter((S) => {
1885
+ const E = S.row.id != null ? String(S.row.id) : null;
1886
+ return !(E != null && ut.has(E));
1887
+ }), m = (S) => d.reduce((E, y) => {
1888
+ const I = Number(y.row[S]);
1889
+ return E + (Number.isFinite(I) ? I : 0);
1890
+ }, 0), f = (S) => {
1891
+ var E;
1892
+ return ((E = a.field_formats) == null ? void 0 : E[S]) ?? "number";
1893
+ }, _ = (S) => /* @__PURE__ */ s(
1842
1894
  "span",
1843
1895
  {
1844
- ...ge.box(
1845
- `s:${$}`,
1896
+ ...ke.box(
1897
+ `s:${S}`,
1846
1898
  "w-20 shrink-0",
1847
1899
  "truncate text-right text-[12px] font-semibold tabular-nums text-slate-800 dark:text-slate-100"
1848
1900
  ),
1849
- children: ye(u($), f($))
1901
+ children: ge(m(S), f(S))
1850
1902
  },
1851
- $
1903
+ S
1852
1904
  );
1853
1905
  return /* @__PURE__ */ c("div", { className: "flex items-center gap-4 border-t border-slate-200 bg-slate-50 px-3 py-1.5 dark:border-border dark:bg-muted/40", children: [
1854
1906
  /* @__PURE__ */ s("span", { className: "flex-1 text-[11px] font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400", children: "Total" }),
1855
- Xt.map(($) => {
1856
- const J = h($);
1857
- return J ? /* @__PURE__ */ s("span", { ...ge.box(J, "w-20 shrink-0") }, $) : /* @__PURE__ */ s("span", { className: "w-20 shrink-0" }, $);
1907
+ er.map((S) => {
1908
+ const E = h(S);
1909
+ return E ? /* @__PURE__ */ s("span", { ...ke.box(E, "w-20 shrink-0") }, S) : /* @__PURE__ */ s("span", { className: "w-20 shrink-0" }, S);
1858
1910
  }),
1859
- /* @__PURE__ */ s("span", { className: "w-20 shrink-0 text-right text-[12px] font-semibold tabular-nums text-slate-800 dark:text-slate-100", children: ye(u(P), "number") }),
1860
- er.map(N),
1861
- !b && /* @__PURE__ */ s("span", { className: "w-6 shrink-0" })
1911
+ /* @__PURE__ */ s("span", { className: "w-20 shrink-0 text-right text-[12px] font-semibold tabular-nums text-slate-800 dark:text-slate-100", children: ge(m(ae), "number") }),
1912
+ tr.map(_),
1913
+ !p && /* @__PURE__ */ s("span", { className: "w-6 shrink-0" })
1862
1914
  ] });
1863
1915
  })()
1864
1916
  ] });
1865
1917
  })()
1866
1918
  ] }),
1867
- en && p && /* @__PURE__ */ s(
1868
- us,
1919
+ sn && b && /* @__PURE__ */ s(
1920
+ ks,
1869
1921
  {
1870
- catalogCol: p,
1871
- tmpl: L,
1922
+ catalogCol: b,
1923
+ tmpl: C,
1872
1924
  sectionBy: a.section_by,
1873
- sectionM2M: C,
1874
- pinnedSet: Rt,
1875
- pinnedIds: _e,
1876
- savingIds: ft,
1925
+ sectionM2M: B,
1926
+ pinnedSet: Pt,
1927
+ pinnedIds: qe,
1928
+ savingIds: ht,
1877
1929
  relatedCols: (a.favorites_manager_columns ?? []).map((e) => (a.related_columns ?? []).find((t) => t.key === e)).filter((e) => !!e),
1878
- parentDraft: W,
1879
- onToggle: (e) => void cr(e),
1880
- onClose: () => ur(!1),
1881
- anchor: mr.current
1930
+ parentDraft: i,
1931
+ onToggle: (e) => void fr(e),
1932
+ onClose: () => hr(!1),
1933
+ anchor: br.current
1882
1934
  }
1883
1935
  )
1884
1936
  ] }) : /* @__PURE__ */ c("p", { className: "py-1 text-[12px] text-slate-400", children: [
@@ -1886,85 +1938,85 @@ ${J}`,
1886
1938
  a.item_field,
1887
1939
  '" does not resolve to an M2O relation on',
1888
1940
  " ",
1889
- m
1941
+ u
1890
1942
  ] });
1891
1943
  }
1892
- function os({
1893
- builder: m,
1894
- defaultItemField: k,
1895
- catalogCol: _,
1896
- catalogFields: q,
1944
+ function xs({
1945
+ builder: u,
1946
+ defaultItemField: x,
1947
+ catalogCol: w,
1948
+ catalogFields: N,
1897
1949
  tmpl: a,
1898
- currentQty: b,
1899
- addQty: x,
1900
- qtyStep: F,
1901
- readOnly: y
1950
+ currentQty: p,
1951
+ addQty: g,
1952
+ qtyStep: j,
1953
+ readOnly: k
1902
1954
  }) {
1903
- const O = Tt(), G = m.item_field ?? k, [se, B] = Y(!1), [P, me] = Y({}), [te, Pe] = Y("1"), [z, $e] = Y(!1), Ee = T(
1955
+ const R = Rt(), Z = u.item_field ?? x, [te, ve] = U(!1), [H, z] = U({}), [re, ae] = U("1"), [ne, xe] = U(!1), je = F(
1904
1956
  () => [
1905
1957
  "id",
1906
- G,
1907
- ...m.attributes.flatMap((v) => [`${v.field}.id`, `${v.field}.${v.label_field}`])
1958
+ Z,
1959
+ ...u.attributes.flatMap((q) => [`${q.field}.id`, `${q.field}.${q.label_field}`])
1908
1960
  ].join(","),
1909
- [G, m.attributes]
1910
- ), { data: Ne = [], isLoading: fe } = K({
1961
+ [Z, u.attributes]
1962
+ ), { data: V = [], isLoading: Pe } = A({
1911
1963
  queryKey: [
1912
1964
  "catalog-builder",
1913
- m.collection,
1914
- Ee,
1915
- JSON.stringify(m.filter ?? null)
1965
+ u.collection,
1966
+ je,
1967
+ JSON.stringify(u.filter ?? null)
1916
1968
  ],
1917
- queryFn: () => O.request(
1918
- R(`/items/${m.collection}`, {
1969
+ queryFn: () => R.request(
1970
+ O(`/items/${u.collection}`, {
1919
1971
  limit: 2e3,
1920
- fields: Ee,
1921
- ...m.filter ? { filter: JSON.stringify(m.filter) } : {}
1972
+ fields: je,
1973
+ ...u.filter ? { filter: JSON.stringify(u.filter) } : {}
1922
1974
  })
1923
- ).then((v) => v.data ?? []),
1924
- enabled: se,
1975
+ ).then((q) => q.data ?? []),
1976
+ enabled: te,
1925
1977
  staleTime: 6e4
1926
- }), ae = (v, Q) => {
1927
- var L;
1928
- const S = v[Q];
1929
- if (S == null) return null;
1930
- if (typeof S == "object") {
1931
- const j = S, A = ((L = m.attributes.find((pe) => pe.field === Q)) == null ? void 0 : L.label_field) ?? "id";
1932
- return { id: String(j.id ?? ""), label: String(j[A] ?? j.id ?? "") };
1978
+ }), ye = (q, b) => {
1979
+ var le;
1980
+ const L = q[b];
1981
+ if (L == null) return null;
1982
+ if (typeof L == "object") {
1983
+ const Q = L, $ = ((le = u.attributes.find((C) => C.field === b)) == null ? void 0 : le.label_field) ?? "id";
1984
+ return { id: String(Q.id ?? ""), label: String(Q[$] ?? Q.id ?? "") };
1933
1985
  }
1934
- return { id: String(S), label: String(S) };
1935
- }, he = (v) => Ne.filter(
1936
- (Q) => m.attributes.slice(0, v).every((S) => {
1937
- var j;
1938
- const L = P[S.field];
1939
- return L ? ((j = ae(Q, S.field)) == null ? void 0 : j.id) === L : !0;
1986
+ return { id: String(L), label: String(L) };
1987
+ }, he = (q) => V.filter(
1988
+ (b) => u.attributes.slice(0, q).every((L) => {
1989
+ var Q;
1990
+ const le = H[L.field];
1991
+ return le ? ((Q = ye(b, L.field)) == null ? void 0 : Q.id) === le : !0;
1940
1992
  })
1941
- ), re = m.attributes.every((v) => P[v.field]), de = re ? Ne.find(
1942
- (v) => m.attributes.every((Q) => {
1943
- var S;
1944
- return ((S = ae(v, Q.field)) == null ? void 0 : S.id) === P[Q.field];
1993
+ ), ie = u.attributes.every((q) => H[q.field]), se = ie ? V.find(
1994
+ (q) => u.attributes.every((b) => {
1995
+ var L;
1996
+ return ((L = ye(q, b.field)) == null ? void 0 : L.id) === H[b.field];
1945
1997
  })
1946
- ) : void 0, V = (de == null ? void 0 : de[G]) != null ? String(de[G]) : null, { data: ie } = K({
1947
- queryKey: ["catalog-builder-item", _, q, V],
1948
- queryFn: () => O.request(
1949
- R(`/items/${_}`, {
1950
- filter: JSON.stringify({ id: { _eq: V } }),
1951
- fields: q,
1998
+ ) : void 0, Y = (se == null ? void 0 : se[Z]) != null ? String(se[Z]) : null, { data: G } = A({
1999
+ queryKey: ["catalog-builder-item", w, N, Y],
2000
+ queryFn: () => R.request(
2001
+ O(`/items/${w}`, {
2002
+ filter: JSON.stringify({ id: { _eq: Y } }),
2003
+ fields: N,
1952
2004
  limit: 1
1953
2005
  })
1954
- ).then((v) => {
1955
- var Q;
1956
- return ((Q = v.data) == null ? void 0 : Q[0]) ?? null;
2006
+ ).then((q) => {
2007
+ var b;
2008
+ return ((b = q.data) == null ? void 0 : b[0]) ?? null;
1957
2009
  }),
1958
- enabled: !!V,
2010
+ enabled: !!Y,
1959
2011
  staleTime: 6e4
1960
- }), ve = Number(te), p = !!V && !!ie && !z && te.trim() !== "" && Number.isFinite(ve) && ve > 0 && (F === "any" || Number.isInteger(ve));
1961
- async function be() {
1962
- if (!(!p || !V || !ie)) {
1963
- $e(!0);
2012
+ }), _e = Number(re), fe = !!Y && !!G && !ne && re.trim() !== "" && Number.isFinite(_e) && _e > 0 && (j === "any" || Number.isInteger(_e));
2013
+ async function Ee() {
2014
+ if (!(!fe || !Y || !G)) {
2015
+ xe(!0);
1964
2016
  try {
1965
- await x(V, (b(V) ?? 0) + ve, ie), me({}), Pe("1");
2017
+ await g(Y, (p(Y) ?? 0) + _e, G), z({}), ae("1");
1966
2018
  } finally {
1967
- $e(!1);
2019
+ xe(!1);
1968
2020
  }
1969
2021
  }
1970
2022
  }
@@ -1973,73 +2025,73 @@ function os({
1973
2025
  "button",
1974
2026
  {
1975
2027
  type: "button",
1976
- onClick: () => B((v) => !v),
2028
+ onClick: () => ve((q) => !q),
1977
2029
  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",
1978
2030
  children: [
1979
2031
  /* @__PURE__ */ s(
1980
- sr,
2032
+ ar,
1981
2033
  {
1982
- className: I(
2034
+ className: K(
1983
2035
  "h-3 w-3 shrink-0 text-slate-400 transition-transform",
1984
- se && "rotate-90"
2036
+ te && "rotate-90"
1985
2037
  )
1986
2038
  }
1987
2039
  ),
1988
- /* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: m.label })
2040
+ /* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: u.label })
1989
2041
  ]
1990
2042
  }
1991
2043
  ),
1992
- se && /* @__PURE__ */ s("div", { className: "space-y-2 border-t border-slate-200 p-3 dark:border-border", children: fe ? /* @__PURE__ */ c("div", { className: "flex items-center gap-2 py-2 text-slate-400", children: [
1993
- /* @__PURE__ */ s(ne, { className: "h-4 w-4 animate-spin" }),
2044
+ te && /* @__PURE__ */ s("div", { className: "space-y-2 border-t border-slate-200 p-3 dark:border-border", children: Pe ? /* @__PURE__ */ c("div", { className: "flex items-center gap-2 py-2 text-slate-400", children: [
2045
+ /* @__PURE__ */ s(ce, { className: "h-4 w-4 animate-spin" }),
1994
2046
  " Loading options…"
1995
2047
  ] }) : /* @__PURE__ */ c("div", { className: "flex flex-wrap items-end gap-3", children: [
1996
- m.attributes.map((v, Q) => {
1997
- const S = /* @__PURE__ */ new Map();
1998
- for (const j of he(Q)) {
1999
- const A = ae(j, v.field);
2000
- A != null && A.id && S.set(A.id, A.label);
2048
+ u.attributes.map((q, b) => {
2049
+ const L = /* @__PURE__ */ new Map();
2050
+ for (const Q of he(b)) {
2051
+ const $ = ye(Q, q.field);
2052
+ $ != null && $.id && L.set($.id, $.label);
2001
2053
  }
2002
- const L = [...S.entries()].sort(
2003
- ([, j], [, A]) => j.localeCompare(A, void 0, { numeric: !0 })
2054
+ const le = [...L.entries()].sort(
2055
+ ([, Q], [, $]) => Q.localeCompare($, void 0, { numeric: !0 })
2004
2056
  );
2005
2057
  return /* @__PURE__ */ s(
2006
- cs,
2058
+ gs,
2007
2059
  {
2008
- label: U(v.field),
2009
- value: P[v.field] ?? null,
2010
- valueLabel: P[v.field] ? S.get(P[v.field]) ?? P[v.field] : null,
2011
- options: L,
2012
- disabled: Q > 0 && !P[m.attributes[Q - 1].field],
2013
- onChange: (j) => me((A) => {
2014
- const pe = {};
2015
- for (let C = 0; C < Q; C++) {
2016
- const W = m.attributes[C].field;
2017
- A[W] && (pe[W] = A[W]);
2060
+ label: M(q.field),
2061
+ value: H[q.field] ?? null,
2062
+ valueLabel: H[q.field] ? L.get(H[q.field]) ?? H[q.field] : null,
2063
+ options: le,
2064
+ disabled: b > 0 && !H[u.attributes[b - 1].field],
2065
+ onChange: (Q) => z(($) => {
2066
+ const C = {};
2067
+ for (let P = 0; P < b; P++) {
2068
+ const oe = u.attributes[P].field;
2069
+ $[oe] && (C[oe] = $[oe]);
2018
2070
  }
2019
- return j && (pe[v.field] = j), pe;
2071
+ return Q && (C[q.field] = Q), C;
2020
2072
  })
2021
2073
  },
2022
- v.field
2074
+ q.field
2023
2075
  );
2024
2076
  }),
2025
- /* @__PURE__ */ s("div", { className: "flex min-h-[28px] flex-1 items-center gap-2", children: V && ie ? /* @__PURE__ */ c(we, { children: [
2026
- /* @__PURE__ */ s("span", { className: "min-w-0 flex-1 truncate text-slate-700 dark:text-slate-200", children: Ce(a, ie) }),
2027
- (b(V) ?? 0) > 0 && /* @__PURE__ */ c("span", { className: "rounded bg-nvr-cyan/10 px-1.5 py-0.5 text-[10px] font-semibold text-[#00728d] dark:bg-nvr-cyan/15 dark:text-nvr-cyan", children: [
2028
- b(V),
2077
+ /* @__PURE__ */ s("div", { className: "flex min-h-[28px] flex-1 items-center gap-2", children: Y && G ? /* @__PURE__ */ c(Ne, { children: [
2078
+ /* @__PURE__ */ s("span", { className: "min-w-0 flex-1 truncate text-slate-700 dark:text-slate-200", children: Je(a, G) }),
2079
+ (p(Y) ?? 0) > 0 && /* @__PURE__ */ c("span", { className: "rounded bg-nvr-cyan/10 px-1.5 py-0.5 text-[10px] font-semibold text-[#00728d] dark:bg-nvr-cyan/15 dark:text-nvr-cyan", children: [
2080
+ p(Y),
2029
2081
  " in summary"
2030
2082
  ] }),
2031
- !y && /* @__PURE__ */ c(we, { children: [
2083
+ !k && /* @__PURE__ */ c(Ne, { children: [
2032
2084
  /* @__PURE__ */ s(
2033
2085
  "input",
2034
2086
  {
2035
2087
  type: "number",
2036
2088
  min: 0,
2037
- step: F,
2038
- value: te,
2089
+ step: j,
2090
+ value: re,
2039
2091
  "aria-label": "Quantity to add",
2040
- onChange: (v) => Pe(v.target.value),
2041
- onKeyDown: (v) => {
2042
- v.key === "Enter" && (v.preventDefault(), be());
2092
+ onChange: (q) => ae(q.target.value),
2093
+ onKeyDown: (q) => {
2094
+ q.key === "Enter" && (q.preventDefault(), Ee());
2043
2095
  },
2044
2096
  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"
2045
2097
  }
@@ -2048,315 +2100,315 @@ function os({
2048
2100
  "button",
2049
2101
  {
2050
2102
  type: "button",
2051
- onClick: () => void be(),
2052
- disabled: !p,
2103
+ onClick: () => void Ee(),
2104
+ disabled: !fe,
2053
2105
  className: "flex h-7 shrink-0 items-center gap-1 rounded bg-nvr-cyan px-2.5 text-[12px] font-medium text-white hover:bg-nvr-cyan/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan focus-visible:ring-offset-1 disabled:opacity-50",
2054
2106
  children: [
2055
- z ? /* @__PURE__ */ s(ne, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ s(On, { className: "h-3.5 w-3.5" }),
2107
+ ne ? /* @__PURE__ */ s(ce, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ s(Jn, { className: "h-3.5 w-3.5" }),
2056
2108
  "Add"
2057
2109
  ]
2058
2110
  }
2059
2111
  )
2060
2112
  ] })
2061
- ] }) : re ? /* @__PURE__ */ s("span", { className: "text-slate-400", children: "No matching item for this combination" }) : /* @__PURE__ */ s("span", { className: "text-slate-400", children: "Pick each attribute to resolve an item" }) })
2113
+ ] }) : ie ? /* @__PURE__ */ s("span", { className: "text-slate-400", children: "No matching item for this combination" }) : /* @__PURE__ */ s("span", { className: "text-slate-400", children: "Pick each attribute to resolve an item" }) })
2062
2114
  ] }) })
2063
2115
  ] });
2064
2116
  }
2065
- function ds({
2066
- parentCollection: m,
2067
- field: k,
2068
- id: _
2117
+ function ys({
2118
+ parentCollection: u,
2119
+ field: x,
2120
+ id: w
2069
2121
  }) {
2070
- var F;
2071
- const q = Tt(), { data: a = [] } = K({
2072
- queryKey: ["collection-relations", m],
2073
- queryFn: () => q.request(R(`/collections/${m}`)).then((y) => {
2074
- var O;
2075
- return ((O = y.data) == null ? void 0 : O.relations) ?? [];
2122
+ var j;
2123
+ const N = Rt(), { data: a = [] } = A({
2124
+ queryKey: ["collection-relations", u],
2125
+ queryFn: () => N.request(O(`/collections/${u}`)).then((k) => {
2126
+ var R;
2127
+ return ((R = k.data) == null ? void 0 : R.relations) ?? [];
2076
2128
  }),
2077
- enabled: !!m,
2129
+ enabled: !!u,
2078
2130
  staleTime: 10 * 6e4
2079
- }), b = ((F = a.find(
2080
- (y) => y.many_collection === m && y.many_field === k && !y.junction_field
2081
- )) == null ? void 0 : F.one_collection) ?? null, { data: x } = K({
2082
- queryKey: ["col-meta", b],
2083
- queryFn: () => q.request(R(`/collections/${b}`)).then((y) => y.data),
2084
- enabled: !!b,
2131
+ }), p = ((j = a.find(
2132
+ (k) => k.many_collection === u && k.many_field === x && !k.junction_field
2133
+ )) == null ? void 0 : j.one_collection) ?? null, { data: g } = A({
2134
+ queryKey: ["col-meta", p],
2135
+ queryFn: () => N.request(O(`/collections/${p}`)).then((k) => k.data),
2136
+ enabled: !!p,
2085
2137
  staleTime: 3e5
2086
2138
  });
2087
- return b ? /* @__PURE__ */ s(is, { collection: b, id: _, displayTemplate: x == null ? void 0 : x.display_template }) : /* @__PURE__ */ c(we, { children: [
2139
+ return p ? /* @__PURE__ */ s(ms, { collection: p, id: w, displayTemplate: g == null ? void 0 : g.display_template }) : /* @__PURE__ */ c(Ne, { children: [
2088
2140
  "this ",
2089
- U(k)
2141
+ M(x)
2090
2142
  ] });
2091
2143
  }
2092
- function Mr({
2093
- text: m,
2094
- highlight: k,
2095
- className: _,
2096
- ...q
2144
+ function Yr({
2145
+ text: u,
2146
+ highlight: x,
2147
+ className: w,
2148
+ ...N
2097
2149
  }) {
2098
- const a = Hn(m);
2099
- return /* @__PURE__ */ s("span", { ref: a, className: I("truncate", _), ...q, children: k ? /* @__PURE__ */ s(ar, { text: m, query: k }) : m });
2150
+ const a = Xn(u);
2151
+ return /* @__PURE__ */ s("span", { ref: a, className: K("truncate", w), ...N, children: x ? /* @__PURE__ */ s(ir, { text: u, query: x }) : u });
2100
2152
  }
2101
- function cs({
2102
- label: m,
2103
- value: k,
2104
- valueLabel: _,
2105
- options: q,
2153
+ function gs({
2154
+ label: u,
2155
+ value: x,
2156
+ valueLabel: w,
2157
+ options: N,
2106
2158
  disabled: a,
2107
- onChange: b
2159
+ onChange: p
2108
2160
  }) {
2109
- const [x, F] = Y(!1), y = Qe(null);
2110
- return Oe(() => {
2111
- if (!x) return;
2112
- const O = (G) => {
2113
- y.current && !y.current.contains(G.target) && F(!1);
2161
+ const [g, j] = U(!1), k = We(null);
2162
+ return Re(() => {
2163
+ if (!g) return;
2164
+ const R = (Z) => {
2165
+ k.current && !k.current.contains(Z.target) && j(!1);
2114
2166
  };
2115
- return document.addEventListener("mousedown", O), () => document.removeEventListener("mousedown", O);
2116
- }, [x]), /* @__PURE__ */ c("div", { ref: y, className: "relative", children: [
2117
- /* @__PURE__ */ s("p", { className: "mb-1 text-[10px] font-medium text-slate-500 dark:text-slate-400", children: m }),
2167
+ return document.addEventListener("mousedown", R), () => document.removeEventListener("mousedown", R);
2168
+ }, [g]), /* @__PURE__ */ c("div", { ref: k, className: "relative", children: [
2169
+ /* @__PURE__ */ s("p", { className: "mb-1 text-[10px] font-medium text-slate-500 dark:text-slate-400", children: u }),
2118
2170
  /* @__PURE__ */ c(
2119
2171
  "button",
2120
2172
  {
2121
2173
  type: "button",
2122
2174
  disabled: a,
2123
- onClick: () => F((O) => !O),
2175
+ onClick: () => j((R) => !R),
2124
2176
  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",
2125
2177
  children: [
2126
- /* @__PURE__ */ s("span", { className: I("truncate", !_ && "text-slate-400"), children: _ ?? "Select…" }),
2127
- /* @__PURE__ */ s(Pn, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
2178
+ /* @__PURE__ */ s("span", { className: K("truncate", !w && "text-slate-400"), children: w ?? "Select…" }),
2179
+ /* @__PURE__ */ s(In, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
2128
2180
  ]
2129
2181
  }
2130
2182
  ),
2131
- x && /* @__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: [
2132
- k && /* @__PURE__ */ c(
2183
+ g && /* @__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: [
2184
+ x && /* @__PURE__ */ c(
2133
2185
  "button",
2134
2186
  {
2135
2187
  type: "button",
2136
2188
  onClick: () => {
2137
- b(null), F(!1);
2189
+ p(null), j(!1);
2138
2190
  },
2139
2191
  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",
2140
2192
  children: [
2141
- /* @__PURE__ */ s(jt, { className: "h-3 w-3 text-slate-400" }),
2193
+ /* @__PURE__ */ s(Tt, { className: "h-3 w-3 text-slate-400" }),
2142
2194
  " Clear"
2143
2195
  ]
2144
2196
  }
2145
2197
  ),
2146
- q.map(([O, G]) => /* @__PURE__ */ s(
2198
+ N.map(([R, Z]) => /* @__PURE__ */ s(
2147
2199
  "button",
2148
2200
  {
2149
2201
  type: "button",
2150
2202
  onClick: () => {
2151
- b(O), F(!1);
2203
+ p(R), j(!1);
2152
2204
  },
2153
- className: I(
2205
+ className: K(
2154
2206
  "block w-full truncate px-2 py-1 text-left text-[12px] hover:bg-muted",
2155
- O === k ? "font-medium text-nvr-cyan" : "text-slate-700 dark:text-slate-200"
2207
+ R === x ? "font-medium text-nvr-cyan" : "text-slate-700 dark:text-slate-200"
2156
2208
  ),
2157
- children: G
2209
+ children: Z
2158
2210
  },
2159
- O
2211
+ R
2160
2212
  ))
2161
2213
  ] })
2162
2214
  ] });
2163
2215
  }
2164
- function us({
2165
- catalogCol: m,
2166
- tmpl: k,
2167
- sectionBy: _,
2168
- sectionM2M: q,
2216
+ function ks({
2217
+ catalogCol: u,
2218
+ tmpl: x,
2219
+ sectionBy: w,
2220
+ sectionM2M: N,
2169
2221
  pinnedSet: a,
2170
- pinnedIds: b,
2171
- savingIds: x,
2172
- relatedCols: F,
2173
- parentDraft: y,
2174
- onToggle: O,
2175
- onClose: G,
2176
- anchor: se
2222
+ pinnedIds: p,
2223
+ savingIds: g,
2224
+ relatedCols: j,
2225
+ parentDraft: k,
2226
+ onToggle: R,
2227
+ onClose: Z,
2228
+ anchor: te
2177
2229
  }) {
2178
- const B = Tt(), [P, me] = Y(""), [te, Pe] = Y(""), [z, $e] = Y(1), Ee = Qe(null);
2179
- Oe(() => {
2180
- const i = setTimeout(() => Pe(P), 300);
2230
+ const ve = Rt(), [H, z] = U(""), [re, ae] = U(""), [ne, xe] = U(1), je = We(null);
2231
+ Re(() => {
2232
+ const i = setTimeout(() => ae(H), 300);
2181
2233
  return () => clearTimeout(i);
2182
- }, [P]), Oe(() => $e(1), [te]), Oe(() => {
2234
+ }, [H]), Re(() => xe(1), [re]), Re(() => {
2183
2235
  var i;
2184
- (i = Ee.current) == null || i.focus();
2185
- }, []), Oe(() => {
2186
- const i = (w) => {
2187
- w.key === "Escape" && (w.stopPropagation(), G());
2236
+ (i = je.current) == null || i.focus();
2237
+ }, []), Re(() => {
2238
+ const i = (v) => {
2239
+ v.key === "Escape" && (v.stopPropagation(), Z());
2188
2240
  };
2189
2241
  return window.addEventListener("keydown", i, !0), () => window.removeEventListener("keydown", i, !0);
2190
- }, [G]);
2191
- const Ne = T(() => {
2192
- var w;
2193
- const i = (w = [...(k ?? "").matchAll(/\{\{([\w.]+)\}\}/g)][0]) == null ? void 0 : w[1];
2242
+ }, [Z]);
2243
+ const V = F(() => {
2244
+ var v;
2245
+ const i = (v = [...(x ?? "").matchAll(/\{\{([\w.]+)\}\}/g)][0]) == null ? void 0 : v[1];
2194
2246
  return i && !i.includes(".") ? i : "id";
2195
- }, [k]), fe = !q && _.includes(".") ? `*,${_}` : "*", ae = 50, { data: he, isFetching: re } = K({
2196
- queryKey: ["favorites-manager-list", m, te, Ne, z],
2197
- queryFn: () => B.request(
2198
- R(`/items/${m}`, {
2199
- fields: fe,
2200
- limit: ae,
2201
- page: z,
2202
- sort: Ne,
2203
- ...te.trim() ? { search: te } : {}
2247
+ }, [x]), Pe = !N && w.includes(".") ? `*,${w}` : "*", ye = 50, { data: he, isFetching: ie } = A({
2248
+ queryKey: ["favorites-manager-list", u, re, V, ne],
2249
+ queryFn: () => ve.request(
2250
+ O(`/items/${u}`, {
2251
+ fields: Pe,
2252
+ limit: ye,
2253
+ page: ne,
2254
+ sort: V,
2255
+ ...re.trim() ? { search: re } : {}
2204
2256
  })
2205
2257
  ),
2206
2258
  staleTime: 3e4,
2207
2259
  placeholderData: (i) => i
2208
- }), de = ((he == null ? void 0 : he.data) ?? []).filter((i) => !a.has(String(i.id))), V = (he == null ? void 0 : he.total) ?? de.length, ie = Math.max(1, Math.ceil(V / ae)), { data: ve = [] } = K({
2209
- queryKey: ["favorites-manager-pinned", m, fe, b.join(",")],
2210
- queryFn: () => B.request(
2211
- R(`/items/${m}`, {
2212
- filter: JSON.stringify({ id: { _in: b } }),
2213
- fields: fe,
2214
- limit: b.length,
2215
- sort: Ne
2260
+ }), se = ((he == null ? void 0 : he.data) ?? []).filter((i) => !a.has(String(i.id))), Y = (he == null ? void 0 : he.total) ?? se.length, G = Math.max(1, Math.ceil(Y / ye)), { data: _e = [] } = A({
2261
+ queryKey: ["favorites-manager-pinned", u, Pe, p.join(",")],
2262
+ queryFn: () => ve.request(
2263
+ O(`/items/${u}`, {
2264
+ filter: JSON.stringify({ id: { _in: p } }),
2265
+ fields: Pe,
2266
+ limit: p.length,
2267
+ sort: V
2216
2268
  })
2217
2269
  ).then((i) => i.data ?? []),
2218
- enabled: b.length > 0,
2270
+ enabled: p.length > 0,
2219
2271
  staleTime: 3e4
2220
- }), p = T(() => {
2272
+ }), fe = F(() => {
2221
2273
  const i = /* @__PURE__ */ new Set();
2222
- for (const w of de) i.add(String(w.id));
2223
- for (const w of b) i.add(w);
2274
+ for (const v of se) i.add(String(v.id));
2275
+ for (const v of p) i.add(v);
2224
2276
  return [...i];
2225
- }, [de, b]), { data: be = /* @__PURE__ */ new Map() } = K({
2226
- queryKey: ["favorites-manager-sections", q == null ? void 0 : q.junction, p.join(",")],
2277
+ }, [se, p]), { data: Ee = /* @__PURE__ */ new Map() } = A({
2278
+ queryKey: ["favorites-manager-sections", N == null ? void 0 : N.junction, fe.join(",")],
2227
2279
  queryFn: async () => {
2228
- const i = q, w = await Ft(B, `/items/${i.junction}`, {
2280
+ const i = N, v = await Ot(ve, `/items/${i.junction}`, {
2229
2281
  fields: `${i.fkToItem},${i.fkToSection}`,
2230
- filter: JSON.stringify({ [i.fkToItem]: { _in: p } })
2231
- }), H = [...new Set(w.map((Z) => String(Z[i.fkToSection])))], E = H.length ? await Ft(B, `/items/${i.target}`, {
2282
+ filter: JSON.stringify({ [i.fkToItem]: { _in: fe } })
2283
+ }), J = [...new Set(v.map((T) => String(T[i.fkToSection])))], W = J.length ? await Ot(ve, `/items/${i.target}`, {
2232
2284
  fields: `id,${i.labelPath}`,
2233
- filter: JSON.stringify({ id: { _in: H } })
2234
- }) : [], le = new Map(
2235
- E.map((Z) => [String(Z.id), String(Zr(Z, i.labelPath) ?? "")])
2236
- ), M = /* @__PURE__ */ new Map();
2237
- for (const Z of w) {
2238
- const ce = le.get(String(Z[i.fkToSection]));
2239
- if (!ce) continue;
2240
- const xe = String(Z[i.fkToItem]), je = M.get(xe) ?? [];
2241
- je.includes(ce) || je.push(ce), M.set(xe, je);
2285
+ filter: JSON.stringify({ id: { _in: J } })
2286
+ }) : [], D = new Map(
2287
+ W.map((T) => [String(T.id), String(Xr(T, i.labelPath) ?? "")])
2288
+ ), ue = /* @__PURE__ */ new Map();
2289
+ for (const T of v) {
2290
+ const be = D.get(String(T[i.fkToSection]));
2291
+ if (!be) continue;
2292
+ const de = String(T[i.fkToItem]), Se = ue.get(de) ?? [];
2293
+ Se.includes(be) || Se.push(be), ue.set(de, Se);
2242
2294
  }
2243
- return M;
2295
+ return ue;
2244
2296
  },
2245
- enabled: !!q && p.length > 0,
2297
+ enabled: !!N && fe.length > 0,
2246
2298
  staleTime: 6e4
2247
- }), v = (i) => k ? Ce(k, i) : String(i.cifa_number ?? i.name ?? `#${i.id}`), Q = (i) => {
2248
- const w = i.description ?? i.long_description ?? i.name;
2249
- return typeof w == "string" && w.trim() && w.trim() !== v(i) ? w : "";
2250
- }, S = (i) => {
2251
- if (q) return (be.get(String(i.id)) ?? []).join(", ");
2252
- if (!_) return "";
2253
- const w = Ce(`{{${_}}}`, i);
2254
- return w === `{{${_}}}` ? "" : w;
2255
- }, L = (i, w) => {
2256
- if (w === "presence")
2299
+ }), q = (i) => x ? Je(x, i) : String(i.cifa_number ?? i.name ?? `#${i.id}`), b = (i) => {
2300
+ const v = i.description ?? i.long_description ?? i.name;
2301
+ return typeof v == "string" && v.trim() && v.trim() !== q(i) ? v : "";
2302
+ }, L = (i) => {
2303
+ if (N) return (Ee.get(String(i.id)) ?? []).join(", ");
2304
+ if (!w) return "";
2305
+ const v = Je(`{{${w}}}`, i);
2306
+ return v === `{{${w}}}` ? "" : v;
2307
+ }, le = (i, v) => {
2308
+ if (v === "presence")
2257
2309
  return i == null || i === "" || Number(i) === 0 ? "No" : "Yes";
2258
2310
  if (i == null || i === "") return "—";
2259
- const H = Number(i);
2260
- return w === "currency" && Number.isFinite(H) ? H.toLocaleString("en-US", { style: "currency", currency: "USD" }) : w === "number" && Number.isFinite(H) ? H.toLocaleString() : String(i);
2261
- }, j = nr({
2262
- queries: F.map((i) => {
2263
- const w = We(i.match, y);
2311
+ const J = Number(i);
2312
+ return v === "currency" && Number.isFinite(J) ? J.toLocaleString("en-US", { style: "currency", currency: "USD" }) : v === "number" && Number.isFinite(J) ? J.toLocaleString() : String(i);
2313
+ }, Q = sr({
2314
+ queries: j.map((i) => {
2315
+ const v = De(i.match, k);
2264
2316
  return {
2265
2317
  queryKey: [
2266
2318
  "favorites-manager-related",
2267
2319
  i.key,
2268
2320
  i.collection,
2269
- JSON.stringify(w),
2270
- p.join(",")
2321
+ JSON.stringify(v),
2322
+ fe.join(",")
2271
2323
  ],
2272
2324
  queryFn: async () => {
2273
- const H = await B.request(
2274
- R(`/items/${i.collection}`, {
2275
- filter: JSON.stringify({ [i.item_field]: { _in: p }, ...w ?? {} }),
2325
+ const J = await ve.request(
2326
+ O(`/items/${i.collection}`, {
2327
+ filter: JSON.stringify({ [i.item_field]: { _in: fe }, ...v ?? {} }),
2276
2328
  fields: `${i.item_field},${i.value_field}`,
2277
2329
  limit: 1e3
2278
2330
  })
2279
- ).then((le) => le.data ?? []), E = /* @__PURE__ */ new Map();
2280
- for (const le of H) {
2281
- const M = String(le[i.item_field]), Z = le[i.value_field], ce = E.get(M);
2282
- ce === void 0 ? E.set(M, Z) : Number.isFinite(Number(ce)) && Number.isFinite(Number(Z)) && E.set(M, Number(ce) + Number(Z));
2331
+ ).then((D) => D.data ?? []), W = /* @__PURE__ */ new Map();
2332
+ for (const D of J) {
2333
+ const ue = String(D[i.item_field]), T = D[i.value_field], be = W.get(ue);
2334
+ be === void 0 ? W.set(ue, T) : Number.isFinite(Number(be)) && Number.isFinite(Number(T)) && W.set(ue, Number(be) + Number(T));
2283
2335
  }
2284
- return E;
2336
+ return W;
2285
2337
  },
2286
- enabled: p.length > 0 && (i.match === void 0 || w !== null),
2338
+ enabled: fe.length > 0 && (i.match === void 0 || v !== null),
2287
2339
  staleTime: 3e4
2288
2340
  };
2289
2341
  })
2290
- }), A = F.filter(
2291
- (i) => i.match !== void 0 && We(i.match, y) === null
2292
- ), pe = (i) => {
2293
- const w = a.has(i);
2342
+ }), $ = j.filter(
2343
+ (i) => i.match !== void 0 && De(i.match, k) === null
2344
+ ), C = (i) => {
2345
+ const v = a.has(i);
2294
2346
  return /* @__PURE__ */ s(
2295
2347
  "button",
2296
2348
  {
2297
2349
  type: "button",
2298
- title: w ? "Remove from favorites" : "Add to favorites",
2299
- disabled: x.has(i),
2300
- onClick: () => O(i),
2350
+ title: v ? "Remove from favorites" : "Add to favorites",
2351
+ disabled: g.has(i),
2352
+ onClick: () => R(i),
2301
2353
  className: "shrink-0 rounded p-1 transition-colors hover:bg-amber-100/60 dark:hover:bg-amber-400/10",
2302
- children: x.has(i) ? /* @__PURE__ */ s(ne, { className: "h-4 w-4 animate-spin text-amber-400" }) : /* @__PURE__ */ s(
2303
- at,
2354
+ children: g.has(i) ? /* @__PURE__ */ s(ce, { className: "h-4 w-4 animate-spin text-amber-400" }) : /* @__PURE__ */ s(
2355
+ st,
2304
2356
  {
2305
- className: I(
2357
+ className: K(
2306
2358
  "h-4 w-4",
2307
- w ? "fill-amber-400 text-amber-400" : "text-slate-300 hover:text-amber-400"
2359
+ v ? "fill-amber-400 text-amber-400" : "text-slate-300 hover:text-amber-400"
2308
2360
  )
2309
2361
  }
2310
2362
  )
2311
2363
  }
2312
2364
  );
2313
- }, C = (i, w) => /* @__PURE__ */ s("tr", { children: /* @__PURE__ */ s("td", { colSpan: 4 + F.length, className: I("border-b px-3 py-1.5", w), children: i }) }), W = (i, w) => {
2314
- const H = String(i.id), E = Q(i);
2365
+ }, P = (i, v) => /* @__PURE__ */ s("tr", { children: /* @__PURE__ */ s("td", { colSpan: 4 + j.length, className: K("border-b px-3 py-1.5", v), children: i }) }), oe = (i, v) => {
2366
+ const J = String(i.id), W = b(i);
2315
2367
  return /* @__PURE__ */ c(
2316
2368
  "tr",
2317
2369
  {
2318
- className: I(
2370
+ className: K(
2319
2371
  "border-b border-slate-100 dark:border-border/50",
2320
- w % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30"
2372
+ v % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30"
2321
2373
  ),
2322
2374
  children: [
2323
- /* @__PURE__ */ s("td", { className: "px-2 py-1", children: pe(H) }),
2324
- /* @__PURE__ */ s("td", { className: "px-2 py-1 font-medium tabular-nums text-slate-700 dark:text-slate-200", children: Ur(m) ? /* @__PURE__ */ s(
2375
+ /* @__PURE__ */ s("td", { className: "px-2 py-1", children: C(J) }),
2376
+ /* @__PURE__ */ s("td", { className: "px-2 py-1 font-medium tabular-nums text-slate-700 dark:text-slate-200", children: Zr(u) ? /* @__PURE__ */ s(
2325
2377
  "button",
2326
2378
  {
2327
2379
  type: "button",
2328
- onClick: () => Yr(m, H, y),
2380
+ onClick: () => Gr(u, J, k),
2329
2381
  title: "View stock & planning detail",
2330
2382
  className: "text-left underline decoration-slate-300 decoration-1 underline-offset-2 hover:text-[#009abe] hover:decoration-[#009abe] dark:decoration-slate-600",
2331
- children: v(i)
2383
+ children: q(i)
2332
2384
  }
2333
- ) : v(i) }),
2334
- /* @__PURE__ */ s("td", { className: "max-w-0 px-2 py-1", children: /* @__PURE__ */ s("p", { className: "truncate text-slate-600 dark:text-slate-300", "data-tip": E || void 0, children: E || "—" }) }),
2335
- /* @__PURE__ */ s("td", { className: "px-2 py-1", children: /* @__PURE__ */ s("p", { className: "truncate text-slate-500 dark:text-slate-400", children: S(i) || "—" }) }),
2336
- F.map((le, M) => {
2337
- var xe, je;
2338
- const Z = le.match !== void 0 && We(le.match, y) === null, ce = Z || (je = (xe = j[M]) == null ? void 0 : xe.data) == null ? void 0 : je.get(H);
2385
+ ) : q(i) }),
2386
+ /* @__PURE__ */ s("td", { className: "max-w-0 px-2 py-1", children: /* @__PURE__ */ s("p", { className: "truncate text-slate-600 dark:text-slate-300", "data-tip": W || void 0, children: W || "—" }) }),
2387
+ /* @__PURE__ */ s("td", { className: "px-2 py-1", children: /* @__PURE__ */ s("p", { className: "truncate text-slate-500 dark:text-slate-400", children: L(i) || "—" }) }),
2388
+ j.map((D, ue) => {
2389
+ var de, Se;
2390
+ const T = D.match !== void 0 && De(D.match, k) === null, be = T || (Se = (de = Q[ue]) == null ? void 0 : de.data) == null ? void 0 : Se.get(J);
2339
2391
  return /* @__PURE__ */ s(
2340
2392
  "td",
2341
2393
  {
2342
2394
  className: "whitespace-nowrap px-2 py-1 text-right tabular-nums text-slate-600 dark:text-slate-300",
2343
- children: Z ? "—" : L(ce, le.format)
2395
+ children: T ? "—" : le(be, D.format)
2344
2396
  },
2345
- le.key
2397
+ D.key
2346
2398
  );
2347
2399
  })
2348
2400
  ]
2349
2401
  },
2350
- H
2402
+ J
2351
2403
  );
2352
- }, Je = (se == null ? void 0 : se.closest('[role="dialog"]')) ?? document.body, Se = P.trim() ? ve.filter((i) => Dn(`${v(i)} ${Q(i)} ${S(i)}`, P)) : ve;
2353
- return En(
2404
+ }, at = (te == null ? void 0 : te.closest('[role="dialog"]')) ?? document.body, B = H.trim() ? _e.filter((i) => Zn(`${q(i)} ${b(i)} ${L(i)}`, H)) : _e;
2405
+ return zn(
2354
2406
  /* @__PURE__ */ c("div", { className: "fixed inset-0 z-[125]", role: "presentation", children: [
2355
2407
  /* @__PURE__ */ s(
2356
2408
  "div",
2357
2409
  {
2358
2410
  className: "absolute inset-0 bg-slate-900/30 motion-safe:animate-in motion-safe:fade-in",
2359
- onClick: G
2411
+ onClick: Z
2360
2412
  }
2361
2413
  ),
2362
2414
  /* @__PURE__ */ c(
@@ -2368,7 +2420,7 @@ function us({
2368
2420
  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",
2369
2421
  children: [
2370
2422
  /* @__PURE__ */ c("div", { className: "flex items-start gap-2.5 border-b border-slate-200 px-4 py-3 dark:border-border", children: [
2371
- /* @__PURE__ */ s(at, { className: "mt-0.5 h-4 w-4 shrink-0 fill-amber-400 text-amber-400" }),
2423
+ /* @__PURE__ */ s(st, { className: "mt-0.5 h-4 w-4 shrink-0 fill-amber-400 text-amber-400" }),
2372
2424
  /* @__PURE__ */ c("div", { className: "min-w-0 flex-1", children: [
2373
2425
  /* @__PURE__ */ s("p", { className: "text-[13px] font-semibold text-slate-800 dark:text-slate-100", children: "CIFA favorites" }),
2374
2426
  /* @__PURE__ */ s("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." })
@@ -2377,40 +2429,40 @@ function us({
2377
2429
  "button",
2378
2430
  {
2379
2431
  type: "button",
2380
- onClick: G,
2432
+ onClick: Z,
2381
2433
  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]",
2382
2434
  "aria-label": "Close",
2383
- children: /* @__PURE__ */ s(jt, { className: "h-4 w-4" })
2435
+ children: /* @__PURE__ */ s(Tt, { className: "h-4 w-4" })
2384
2436
  }
2385
2437
  )
2386
2438
  ] }),
2387
2439
  /* @__PURE__ */ c("div", { className: "border-b border-slate-200 px-3 py-2 dark:border-border", children: [
2388
2440
  /* @__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: [
2389
- /* @__PURE__ */ s($t, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
2441
+ /* @__PURE__ */ s(Ft, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
2390
2442
  /* @__PURE__ */ s(
2391
2443
  "input",
2392
2444
  {
2393
- ref: Ee,
2394
- value: P,
2395
- onChange: (i) => me(i.target.value),
2445
+ ref: je,
2446
+ value: H,
2447
+ onChange: (i) => z(i.target.value),
2396
2448
  placeholder: "Search by number or description…",
2397
2449
  className: "min-w-0 flex-1 bg-transparent text-[12px] text-slate-700 outline-none placeholder:text-slate-400 dark:text-slate-200"
2398
2450
  }
2399
2451
  ),
2400
- P && /* @__PURE__ */ s(
2452
+ H && /* @__PURE__ */ s(
2401
2453
  "button",
2402
2454
  {
2403
2455
  type: "button",
2404
- onClick: () => me(""),
2456
+ onClick: () => z(""),
2405
2457
  className: "shrink-0 text-slate-400 hover:text-slate-600",
2406
2458
  "aria-label": "Clear search",
2407
- children: /* @__PURE__ */ s(jt, { className: "h-3.5 w-3.5" })
2459
+ children: /* @__PURE__ */ s(Tt, { className: "h-3.5 w-3.5" })
2408
2460
  }
2409
2461
  )
2410
2462
  ] }),
2411
- A.length > 0 && /* @__PURE__ */ c("p", { className: "mt-1.5 flex items-center gap-1 text-[10px] text-amber-600 dark:text-amber-400", children: [
2412
- /* @__PURE__ */ s(st, { className: "h-3 w-3 shrink-0" }),
2413
- A.map((i) => i.label ?? U(i.key)).join(", "),
2463
+ $.length > 0 && /* @__PURE__ */ c("p", { className: "mt-1.5 flex items-center gap-1 text-[10px] text-amber-600 dark:text-amber-400", children: [
2464
+ /* @__PURE__ */ s(nt, { className: "h-3 w-3 shrink-0" }),
2465
+ $.map((i) => i.label ?? M(i.key)).join(", "),
2414
2466
  " fill in once the form's warehouse selection is made."
2415
2467
  ] })
2416
2468
  ] }),
@@ -2420,63 +2472,63 @@ function us({
2420
2472
  /* @__PURE__ */ s("col", { className: "w-[88px]" }),
2421
2473
  /* @__PURE__ */ s("col", {}),
2422
2474
  /* @__PURE__ */ s("col", { className: "w-[130px]" }),
2423
- F.map((i) => /* @__PURE__ */ s("col", { className: "w-[86px]" }, i.key))
2475
+ j.map((i) => /* @__PURE__ */ s("col", { className: "w-[86px]" }, i.key))
2424
2476
  ] }),
2425
2477
  /* @__PURE__ */ s("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: [
2426
2478
  /* @__PURE__ */ s("th", { className: "px-2 py-1.5", "aria-label": "Favorite" }),
2427
2479
  /* @__PURE__ */ s("th", { className: "px-2 py-1.5", children: "CIFA #" }),
2428
2480
  /* @__PURE__ */ s("th", { className: "px-2 py-1.5", children: "Description" }),
2429
2481
  /* @__PURE__ */ s("th", { className: "px-2 py-1.5", children: "Category" }),
2430
- F.map((i) => /* @__PURE__ */ s("th", { className: "px-2 py-1.5 text-right", children: i.label ?? U(i.key) }, i.key))
2482
+ j.map((i) => /* @__PURE__ */ s("th", { className: "px-2 py-1.5 text-right", children: i.label ?? M(i.key) }, i.key))
2431
2483
  ] }) }),
2432
- /* @__PURE__ */ c("tbody", { className: I(re && "opacity-50 transition-opacity"), children: [
2433
- C(
2484
+ /* @__PURE__ */ c("tbody", { className: K(ie && "opacity-50 transition-opacity"), children: [
2485
+ P(
2434
2486
  /* @__PURE__ */ c("span", { className: "flex items-center gap-1.5", children: [
2435
- /* @__PURE__ */ s(at, { className: "h-3 w-3 shrink-0 fill-amber-400 text-amber-400" }),
2487
+ /* @__PURE__ */ s(st, { className: "h-3 w-3 shrink-0 fill-amber-400 text-amber-400" }),
2436
2488
  /* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Your favorites" }),
2437
- /* @__PURE__ */ s("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: b.length })
2489
+ /* @__PURE__ */ s("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: p.length })
2438
2490
  ] }),
2439
2491
  "border-slate-200 bg-amber-50/70 dark:border-border dark:bg-amber-900/10"
2440
2492
  ),
2441
- Se.length === 0 && /* @__PURE__ */ s("tr", { children: /* @__PURE__ */ s(
2493
+ B.length === 0 && /* @__PURE__ */ s("tr", { children: /* @__PURE__ */ s(
2442
2494
  "td",
2443
2495
  {
2444
- colSpan: 4 + F.length,
2496
+ colSpan: 4 + j.length,
2445
2497
  className: "border-b border-slate-100 px-4 py-3 text-center text-[11px] text-slate-400 dark:border-border/50",
2446
- children: b.length === 0 ? "No favorites yet — star the items you order most." : "No favorites match your search."
2498
+ children: p.length === 0 ? "No favorites yet — star the items you order most." : "No favorites match your search."
2447
2499
  }
2448
2500
  ) }),
2449
- Se.map((i, w) => W(i, w)),
2450
- C(
2501
+ B.map((i, v) => oe(i, v)),
2502
+ P(
2451
2503
  /* @__PURE__ */ c("span", { className: "flex items-center gap-1.5", children: [
2452
- /* @__PURE__ */ s($t, { className: "h-3 w-3 shrink-0 text-slate-400" }),
2504
+ /* @__PURE__ */ s(Ft, { className: "h-3 w-3 shrink-0 text-slate-400" }),
2453
2505
  /* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "All CIFAs" }),
2454
- /* @__PURE__ */ s("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: V.toLocaleString() }),
2455
- re && /* @__PURE__ */ s(ne, { className: "h-3 w-3 animate-spin text-slate-400" })
2506
+ /* @__PURE__ */ s("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: Y.toLocaleString() }),
2507
+ ie && /* @__PURE__ */ s(ce, { className: "h-3 w-3 animate-spin text-slate-400" })
2456
2508
  ] }),
2457
2509
  "border-t border-slate-200 bg-slate-50 dark:border-border dark:bg-muted/40"
2458
2510
  ),
2459
- !re && de.length === 0 && /* @__PURE__ */ s("tr", { children: /* @__PURE__ */ s(
2511
+ !ie && se.length === 0 && /* @__PURE__ */ s("tr", { children: /* @__PURE__ */ s(
2460
2512
  "td",
2461
2513
  {
2462
- colSpan: 4 + F.length,
2514
+ colSpan: 4 + j.length,
2463
2515
  className: "px-4 py-4 text-center text-[11px] text-slate-400",
2464
- children: te.trim() ? `No CIFAs match "${te}".` : "No catalog items."
2516
+ children: re.trim() ? `No CIFAs match "${re}".` : "No catalog items."
2465
2517
  }
2466
2518
  ) }),
2467
- de.map((i, w) => W(i, w))
2519
+ se.map((i, v) => oe(i, v))
2468
2520
  ] })
2469
2521
  ] }) }),
2470
- ie > 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: [
2522
+ G > 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: [
2471
2523
  /* @__PURE__ */ c("span", { className: "flex items-center gap-2 text-[10px] tabular-nums text-slate-400", children: [
2472
- (z - 1) * ae + 1,
2524
+ (ne - 1) * ye + 1,
2473
2525
  "–",
2474
- Math.min(z * ae, V),
2526
+ Math.min(ne * ye, Y),
2475
2527
  " of",
2476
2528
  " ",
2477
- V.toLocaleString(),
2478
- re && /* @__PURE__ */ c("span", { className: "flex items-center gap-1 text-slate-500", children: [
2479
- /* @__PURE__ */ s(ne, { className: "h-3 w-3 animate-spin" }),
2529
+ Y.toLocaleString(),
2530
+ ie && /* @__PURE__ */ c("span", { className: "flex items-center gap-1 text-slate-500", children: [
2531
+ /* @__PURE__ */ s(ce, { className: "h-3 w-3 animate-spin" }),
2480
2532
  " Loading…"
2481
2533
  ] })
2482
2534
  ] }),
@@ -2485,23 +2537,23 @@ function us({
2485
2537
  "button",
2486
2538
  {
2487
2539
  type: "button",
2488
- disabled: z <= 1 || re,
2489
- onClick: () => $e((i) => Math.max(1, i - 1)),
2540
+ disabled: ne <= 1 || ie,
2541
+ onClick: () => xe((i) => Math.max(1, i - 1)),
2490
2542
  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]",
2491
2543
  children: "‹ Prev"
2492
2544
  }
2493
2545
  ),
2494
2546
  /* @__PURE__ */ c("span", { className: "px-1 text-[10px] tabular-nums text-slate-400", children: [
2495
- z,
2547
+ ne,
2496
2548
  " / ",
2497
- ie.toLocaleString()
2549
+ G.toLocaleString()
2498
2550
  ] }),
2499
2551
  /* @__PURE__ */ s(
2500
2552
  "button",
2501
2553
  {
2502
2554
  type: "button",
2503
- disabled: z >= ie || re,
2504
- onClick: () => $e((i) => Math.min(ie, i + 1)),
2555
+ disabled: ne >= G || ie,
2556
+ onClick: () => xe((i) => Math.min(G, i + 1)),
2505
2557
  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]",
2506
2558
  children: "Next ›"
2507
2559
  }
@@ -2512,10 +2564,13 @@ function us({
2512
2564
  }
2513
2565
  )
2514
2566
  ] }),
2515
- Je
2567
+ at
2516
2568
  );
2517
2569
  }
2518
2570
  export {
2519
- As as CatalogPickerField,
2520
- Hr as matchesShowWhen
2571
+ Ms as CatalogPickerField,
2572
+ hs as MAX_LINE_MONEY,
2573
+ ps as lineComputeError,
2574
+ Hr as matchesShowWhen,
2575
+ bs as qtyEntryProblem
2521
2576
  };