@nivaro/react 0.3.29 → 0.3.31

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