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