@nivaro/react 0.3.31 → 0.3.32

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