@nivaro/react 0.1.17 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +685 -684
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -785,7 +785,7 @@ function DataTable$1({
785
785
  collapsedGroups: E,
786
786
  onToggleGroup: K
787
787
  }) {
788
- const Q = Math.ceil(n / r), ie = (a - 1) * r + 1, z = Math.min(a * r, n), U = !N && w && w.length > 0, ee = h !== void 0 || U || S !== void 0, le = (G) => {
788
+ const U = Math.ceil(n / r), ie = (a - 1) * r + 1, z = Math.min(a * r, n), Q = !N && w && w.length > 0, ee = h !== void 0 || Q || S !== void 0, le = (G) => {
789
789
  !G.sortable || !c || c(nextSort(d, G.key));
790
790
  }, J = q !== void 0, V = useMemo(() => {
791
791
  if (!J || !q) return e;
@@ -907,7 +907,7 @@ function DataTable$1({
907
907
  }
908
908
  )
909
909
  ] }),
910
- U && (w == null ? void 0 : w.map((G) => /* @__PURE__ */ jsx(
910
+ Q && (w == null ? void 0 : w.map((G) => /* @__PURE__ */ jsx(
911
911
  FilterControl,
912
912
  {
913
913
  def: G,
@@ -1117,7 +1117,7 @@ function DataTable$1({
1117
1117
  /* @__PURE__ */ jsxs("span", { className: "px-2 text-[12px] text-slate-400", children: [
1118
1118
  a,
1119
1119
  " / ",
1120
- Q
1120
+ U
1121
1121
  ] }),
1122
1122
  /* @__PURE__ */ jsx(
1123
1123
  Button,
@@ -1125,7 +1125,7 @@ function DataTable$1({
1125
1125
  variant: "ghost",
1126
1126
  size: "sm",
1127
1127
  className: "h-7 px-2.5 text-[12px] text-slate-600",
1128
- disabled: a >= Q,
1128
+ disabled: a >= U,
1129
1129
  onClick: () => p(a + 1),
1130
1130
  children: "Next →"
1131
1131
  }
@@ -2276,7 +2276,7 @@ function QueryTable({
2276
2276
  for (const Z of k)
2277
2277
  Z.group && Z.group !== ue && B++, M.push(Z.group ? B : -1), ue = Z.group;
2278
2278
  }
2279
- const E = (B) => I && M[B] >= 0 && M[B] % 2 === 1 ? "bg-slate-50/70 dark:bg-muted/20" : "", K = !!(t != null && t.sticky), Q = "border-r border-slate-200 dark:border-border", ie = (B, ue) => K && B === 0 ? `sticky left-0 z-[1] ${Q} ${ue}` : "", z = (B) => K ? B === 0 ? `sticky left-0 top-0 z-[3] ${Q} bg-slate-50 dark:bg-muted` : "sticky top-0 z-[2] bg-white dark:bg-card" : "", U = (B) => K && (B === 0 || B === 1) ? "pl-3" : "", ee = (B, ue, Z = 0, je) => {
2279
+ const E = (B) => I && M[B] >= 0 && M[B] % 2 === 1 ? "bg-slate-50/70 dark:bg-muted/20" : "", K = !!(t != null && t.sticky), U = "border-r border-slate-200 dark:border-border", ie = (B, ue) => K && B === 0 ? `sticky left-0 z-[1] ${U} ${ue}` : "", z = (B) => K ? B === 0 ? `sticky left-0 top-0 z-[3] ${U} bg-slate-50 dark:bg-muted` : "sticky top-0 z-[2] bg-white dark:bg-card" : "", Q = (B) => K && (B === 0 || B === 1) ? "pl-3" : "", ee = (B, ue, Z = 0, je) => {
2280
2280
  const _e = Z === !0 ? 1 : Z === !1 ? 0 : Z;
2281
2281
  return /* @__PURE__ */ jsxs(
2282
2282
  "tr",
@@ -2287,7 +2287,7 @@ function QueryTable({
2287
2287
  k.map((ke, G) => /* @__PURE__ */ jsx(
2288
2288
  "td",
2289
2289
  {
2290
- className: `whitespace-nowrap py-1.5 pr-3 ${U(G)} ${N(ke, "text-slate-700 dark:text-slate-200")} ${b(ke) ? "text-right tabular-nums" : ""} ${ke.group ? "min-w-[58px]" : ""} ${y(ke) || E(G)} ${ie(G, "bg-slate-50 group-hover/qtr:bg-slate-100 dark:bg-muted dark:group-hover/qtr:bg-muted")}`,
2290
+ className: `whitespace-nowrap py-1.5 pr-3 ${Q(G)} ${N(ke, "text-slate-700 dark:text-slate-200")} ${b(ke) ? "text-right tabular-nums" : ""} ${ke.group ? "min-w-[58px]" : ""} ${y(ke) || E(G)} ${ie(G, "bg-slate-50 group-hover/qtr:bg-slate-100 dark:bg-muted dark:group-hover/qtr:bg-muted")}`,
2291
2291
  style: {
2292
2292
  ..._e > 0 && G === 0 ? { paddingLeft: 2 + _e * 16 } : {},
2293
2293
  ...v(ke) ?? {}
@@ -2346,7 +2346,7 @@ function QueryTable({
2346
2346
  k.map((ce, ve) => /* @__PURE__ */ jsx(
2347
2347
  "td",
2348
2348
  {
2349
- className: `whitespace-nowrap py-1.5 pr-3 ${U(ve)} text-[11.5px] font-semibold ${N(ce, "text-slate-600 dark:text-slate-300")} ${b(ce) ? "text-right tabular-nums" : ""} ${y(ce)} ${K && ve === 0 ? `sticky left-0 z-[1] ${Q} bg-slate-100 dark:bg-muted` : ""}`,
2349
+ className: `whitespace-nowrap py-1.5 pr-3 ${Q(ve)} text-[11.5px] font-semibold ${N(ce, "text-slate-600 dark:text-slate-300")} ${b(ce) ? "text-right tabular-nums" : ""} ${y(ce)} ${K && ve === 0 ? `sticky left-0 z-[1] ${U} bg-slate-100 dark:bg-muted` : ""}`,
2350
2350
  style: v(ce),
2351
2351
  children: ve === 0 ? `${G ? "▸" : "▾"} ${_e}` : ce.formula ? L(evalRowFormula(ce.formula, pe), ce.format) : ce.field && ce.field !== B && b(ce) ? A(pe, ce) : ""
2352
2352
  },
@@ -2404,7 +2404,7 @@ function QueryTable({
2404
2404
  k.map((ut, Nt) => /* @__PURE__ */ jsx(
2405
2405
  "td",
2406
2406
  {
2407
- className: `whitespace-nowrap py-1.5 pr-3 ${U(Nt)} text-[11.5px] font-medium text-slate-600 dark:text-slate-300 ${b(ut) ? "text-right tabular-nums" : ""} ${K && Nt === 0 ? `sticky left-0 z-[1] ${Q} bg-slate-100/80 dark:bg-muted` : ""}`,
2407
+ className: `whitespace-nowrap py-1.5 pr-3 ${Q(Nt)} text-[11.5px] font-medium text-slate-600 dark:text-slate-300 ${b(ut) ? "text-right tabular-nums" : ""} ${K && Nt === 0 ? `sticky left-0 z-[1] ${U} bg-slate-100/80 dark:bg-muted` : ""}`,
2408
2408
  style: Nt === 0 ? { paddingLeft: 18 } : void 0,
2409
2409
  children: Nt === 0 ? `${_t ? "▸" : "▾"} ${Ie}` : ut.formula ? L(evalRowFormula(ut.formula, Ft), ut.format) : ut.field && ut.field !== B && b(ut) ? A(Ft, ut) : ""
2410
2410
  },
@@ -2513,7 +2513,7 @@ function QueryTable({
2513
2513
  (B, ue) => B.group ? /* @__PURE__ */ jsx(
2514
2514
  "th",
2515
2515
  {
2516
- className: `min-w-[58px] whitespace-nowrap border-b border-slate-200 py-1 pr-3 ${U(ue)} text-[11px] font-medium text-slate-400 dark:border-border ${b(B) ? "text-right" : "text-left"} ${y(B) || E(ue)} ${K ? "sticky top-[26px] z-[2] bg-white dark:bg-card" : ""}`,
2516
+ className: `min-w-[58px] whitespace-nowrap border-b border-slate-200 py-1 pr-3 ${Q(ue)} text-[11px] font-medium text-slate-400 dark:border-border ${b(B) ? "text-right" : "text-left"} ${y(B) || E(ue)} ${K ? "sticky top-[26px] z-[2] bg-white dark:bg-card" : ""}`,
2517
2517
  children: B.label ?? titleize(B.field ?? "")
2518
2518
  },
2519
2519
  B.field ?? B.label ?? ue
@@ -2523,7 +2523,7 @@ function QueryTable({
2523
2523
  k.map((B, ue) => /* @__PURE__ */ jsxs(
2524
2524
  "th",
2525
2525
  {
2526
- className: `whitespace-nowrap border-b border-slate-200 py-1.5 pr-3 ${U(ue)} text-[10.5px] font-semibold uppercase tracking-wider dark:border-border ${f(B) ? "border-t-2 border-t-[#6366f1] bg-[#6366f10f] text-[#4f46e5] dark:border-t-[#a5b4fc] dark:bg-[#a5b4fc12] dark:text-[#a5b4fc]" : "text-slate-400"} ${B.stack ? "min-w-[64px]" : ""} ${b(B) ? "text-right" : "text-left"} ${z(ue)}`,
2526
+ className: `whitespace-nowrap border-b border-slate-200 py-1.5 pr-3 ${Q(ue)} text-[10.5px] font-semibold uppercase tracking-wider dark:border-border ${f(B) ? "border-t-2 border-t-[#6366f1] bg-[#6366f10f] text-[#4f46e5] dark:border-t-[#a5b4fc] dark:bg-[#a5b4fc12] dark:text-[#a5b4fc]" : "text-slate-400"} ${B.stack ? "min-w-[64px]" : ""} ${b(B) ? "text-right" : "text-left"} ${z(ue)}`,
2527
2527
  children: [
2528
2528
  B.label ?? titleize(B.field ?? ""),
2529
2529
  B.stack && (t == null ? void 0 : t.stack_legend) && /* @__PURE__ */ jsxs(
@@ -2560,7 +2560,7 @@ function QueryTable({
2560
2560
  k.map((B, ue) => /* @__PURE__ */ jsx(
2561
2561
  "td",
2562
2562
  {
2563
- className: `whitespace-nowrap py-1.5 pr-3 ${U(ue)} ${N(B, "")} ${b(B) ? "text-right tabular-nums" : ""} ${y(B)} ${K ? `sticky bottom-0 border-t border-slate-300 dark:border-border ${ue === 0 ? `left-0 z-[3] ${Q} bg-slate-50 dark:bg-muted` : "z-[2] bg-white dark:bg-card"}` : ""}`,
2563
+ className: `whitespace-nowrap py-1.5 pr-3 ${Q(ue)} ${N(B, "")} ${b(B) ? "text-right tabular-nums" : ""} ${y(B)} ${K ? `sticky bottom-0 border-t border-slate-300 dark:border-border ${ue === 0 ? `left-0 z-[3] ${U} bg-slate-50 dark:bg-muted` : "z-[2] bg-white dark:bg-card"}` : ""}`,
2564
2564
  style: v(B),
2565
2565
  children: ue === 0 && !B.sum && !B.formula ? "Total" : B.sum || B.formula ? B.formula ? L(evalRowFormula(B.formula, g), B.format) : A(g, B) : ""
2566
2566
  },
@@ -3621,7 +3621,7 @@ function WidgetSlot({
3621
3621
  const _ = useApiFetchConfig(), k = o ?? _.apiBase, [w, x] = useState(l), [u, S] = useState(null), [f, y] = useState(null), [v, N] = useState(!0), [C, F] = useState(!0), [q, g] = useState(!0), [b, j] = useState(null), [L, A] = useState(0), I = useRef(!1), M = {};
3622
3622
  for (const [B, ue] of Object.entries(s))
3623
3623
  (ue == null || typeof ue != "object") && (M[B] = ue);
3624
- const E = { ...M, ...resolveInputs(t, s) }, K = (de = u == null ? void 0 : u.config) == null ? void 0 : de.drilldown, Q = useDrilldown(), ie = K != null && K.id_input ? E[K.id_input] : null, z = !!Q && !!(K != null && K.collection) && ie != null && ie !== "", U = async () => {
3624
+ const E = { ...M, ...resolveInputs(t, s) }, K = (de = u == null ? void 0 : u.config) == null ? void 0 : de.drilldown, U = useDrilldown(), ie = K != null && K.id_input ? E[K.id_input] : null, z = !!U && !!(K != null && K.collection) && ie != null && ie !== "", Q = async () => {
3625
3625
  var je, _e;
3626
3626
  if (!z || !(K != null && K.collection)) return;
3627
3627
  const B = String(ie);
@@ -3646,7 +3646,7 @@ function WidgetSlot({
3646
3646
  } catch {
3647
3647
  return;
3648
3648
  }
3649
- ue != null && (Q == null || Q.open({
3649
+ ue != null && (U == null || U.open({
3650
3650
  collection: K.collection,
3651
3651
  itemId: ue,
3652
3652
  layoutId: K.layout_id ?? null,
@@ -3770,7 +3770,7 @@ function WidgetSlot({
3770
3770
  "button",
3771
3771
  {
3772
3772
  type: "button",
3773
- onClick: () => void U(),
3773
+ onClick: () => void Q(),
3774
3774
  title: (K == null ? void 0 : K.title) ?? "Open details",
3775
3775
  className: "h-full w-full cursor-pointer text-left transition-colors hover:bg-nvr-cyan/5",
3776
3776
  "data-nvr-widget-drill": K == null ? void 0 : K.collection,
@@ -3802,7 +3802,7 @@ function WidgetSlot({
3802
3802
  "button",
3803
3803
  {
3804
3804
  type: "button",
3805
- onClick: () => void U(),
3805
+ onClick: () => void Q(),
3806
3806
  title: (K == null ? void 0 : K.title) ?? "Open details",
3807
3807
  className: "cursor-pointer text-left",
3808
3808
  "data-nvr-widget-drill": K == null ? void 0 : K.collection,
@@ -4168,9 +4168,9 @@ function FieldRow({
4168
4168
  j.many_collection,
4169
4169
  j.many_field,
4170
4170
  r
4171
- ]) ?? []).map((he) => he[j.junction_field]) : [], K = j ? M[0] ?? E[0] ?? null : q, Q = (A == null ? void 0 : A.one_collection) ?? (L == null ? void 0 : L.one_collection) ?? void 0;
4171
+ ]) ?? []).map((he) => he[j.junction_field]) : [], K = j ? M[0] ?? E[0] ?? null : q, U = (A == null ? void 0 : A.one_collection) ?? (L == null ? void 0 : L.one_collection) ?? void 0;
4172
4172
  let ie;
4173
- const z = [], U = [];
4173
+ const z = [], Q = [];
4174
4174
  let ee = null, le = null;
4175
4175
  for (const he of y) {
4176
4176
  const de = t[he.parent_field] ?? (() => {
@@ -4205,12 +4205,12 @@ function FieldRow({
4205
4205
  ie[ue[0]] = he.filter_via_many ? { _some: Z } : Z;
4206
4206
  } else
4207
4207
  ie[he.filter_column] = B;
4208
- z.push(titleCase$2(String(he.parent_field))), U.push(String(he.parent_field));
4208
+ z.push(titleCase$2(String(he.parent_field))), Q.push(String(he.parent_field));
4209
4209
  } else
4210
4210
  ee || (ee = titleCase$2(String(he.parent_field))), he.show_all_if_no_parent === !1 && !le && (le = titleCase$2(String(he.parent_field)));
4211
4211
  }
4212
4212
  function J() {
4213
- for (const he of U) {
4213
+ for (const he of Q) {
4214
4214
  const de = document.querySelector(`[data-field="${he}"]`);
4215
4215
  de && (de.scrollIntoView({ behavior: "smooth", block: "center" }), de.style.transition = "box-shadow 0.15s ease", de.style.boxShadow = "0 0 0 2px #00ceff, 0 0 0 5px rgba(0,206,255,0.25)", de.style.borderRadius = "12px", setTimeout(() => {
4216
4216
  de.style.boxShadow = "none", setTimeout(() => {
@@ -4239,7 +4239,7 @@ function FieldRow({
4239
4239
  cascadeRules: y,
4240
4240
  cascadeFilter: ie,
4241
4241
  currentValue: K,
4242
- relatedCollection: Q,
4242
+ relatedCollection: U,
4243
4243
  onClear: V
4244
4244
  }
4245
4245
  ),
@@ -5233,11 +5233,11 @@ function GroupSection({
5233
5233
  fieldInlineDisplay: M,
5234
5234
  swapConfig: E,
5235
5235
  swapped: K,
5236
- onSwapToggle: Q,
5236
+ onSwapToggle: U,
5237
5237
  alternateFields: ie,
5238
5238
  alternateWidths: z
5239
5239
  }) {
5240
- const [U, ee] = useState(e.is_collapsed ?? !1), [le, J] = useState({}), V = x !== void 0, oe = V ? !w : U, ye = V ? x : () => ee((G) => !G), he = !p && t.some((G) => i[G.field]), de = e.visibility_mode ?? "always";
5240
+ const [Q, ee] = useState(e.is_collapsed ?? !1), [le, J] = useState({}), V = x !== void 0, oe = V ? !w : Q, ye = V ? x : () => ee((G) => !G), he = !p && t.some((G) => i[G.field]), de = e.visibility_mode ?? "always";
5241
5241
  if (de === "new_only" && !_ || de === "existing_only" && _) return null;
5242
5242
  const ae = A ?? [], B = !_ && ae.some((G) => G.widget_id != null && le[G.field] === void 0);
5243
5243
  let ue = !1;
@@ -5424,12 +5424,12 @@ function GroupSection({
5424
5424
  })(), Ft = (ie ?? []).some((et) => {
5425
5425
  const Tt = s[et.field];
5426
5426
  return Tt != null && Tt !== "";
5427
- }), $t = st && Q ? /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1.5", children: [
5427
+ }), $t = st && U ? /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1.5", children: [
5428
5428
  /* @__PURE__ */ jsx(
5429
5429
  "button",
5430
5430
  {
5431
5431
  type: "button",
5432
- onClick: Q,
5432
+ onClick: U,
5433
5433
  className: "inline-flex items-center rounded px-1.5 py-0.5 text-[10px] font-medium text-nvr-cyan hover:bg-nvr-cyan/10 transition-colors",
5434
5434
  children: K ? E.back_label ?? "Back" : E.toggle_label ?? "Enter manually"
5435
5435
  }
@@ -5863,8 +5863,8 @@ function NestedRelationEditor({
5863
5863
  return q.map((G) => ({ key: String(G.id), data: G }));
5864
5864
  }
5865
5865
  return (n ?? []).map((G, pe) => ({ key: `staged:${pe}`, data: G }));
5866
- }, [s, q, n, d, c]), [j, L] = useState(null), [A, I] = useState({}), [M, E] = useState(null), [K, Q] = useState(!1), [ie, z] = useState(null);
5867
- function U(G, pe) {
5866
+ }, [s, q, n, d, c]), [j, L] = useState(null), [A, I] = useState({}), [M, E] = useState(null), [K, U] = useState(!1), [ie, z] = useState(null);
5867
+ function Q(G, pe) {
5868
5868
  I((me) => ({ ...me, [G]: pe })), z(null);
5869
5869
  }
5870
5870
  function ee() {
@@ -5901,7 +5901,7 @@ function NestedRelationEditor({
5901
5901
  J();
5902
5902
  return;
5903
5903
  }
5904
- Q(!0);
5904
+ U(!0);
5905
5905
  try {
5906
5906
  j === "new" ? await k.request(
5907
5907
  post$1(`/items/${f}`, {
@@ -5912,7 +5912,7 @@ function NestedRelationEditor({
5912
5912
  } catch (ce) {
5913
5913
  z(parseSaveError(ce));
5914
5914
  } finally {
5915
- Q(!1);
5915
+ U(!1);
5916
5916
  }
5917
5917
  return;
5918
5918
  }
@@ -6086,7 +6086,7 @@ function NestedRelationEditor({
6086
6086
  {
6087
6087
  field: ve,
6088
6088
  value: A[ve.field] ?? null,
6089
- onChange: (Be) => U(ve.field, Be),
6089
+ onChange: (Be) => Q(ve.field, Be),
6090
6090
  relations: v,
6091
6091
  collection: f,
6092
6092
  itemId: s != null ? G : "new"
@@ -6176,7 +6176,7 @@ function NestedRelationEditor({
6176
6176
  {
6177
6177
  field: G,
6178
6178
  value: A[G.field] ?? null,
6179
- onChange: (pe) => U(G.field, pe),
6179
+ onChange: (pe) => Q(G.field, pe),
6180
6180
  relations: v,
6181
6181
  collection: f,
6182
6182
  itemId: "new"
@@ -6363,14 +6363,14 @@ function RelationCombobox({
6363
6363
  ).then((de) => de.data ?? []),
6364
6364
  enabled: p,
6365
6365
  staleTime: I ? 0 : 3e4
6366
- }), { data: Q, isLoading: ie } = useQuery({
6366
+ }), { data: U, isLoading: ie } = useQuery({
6367
6367
  queryKey: ["relation-single", e, String(t), A],
6368
6368
  queryFn: () => c.request(
6369
6369
  get$1(`/items/${e}/${t}`, A ? { fields: A } : void 0)
6370
6370
  ).then((de) => de.data),
6371
6371
  enabled: !!t,
6372
6372
  staleTime: 6e4
6373
- }), z = JSON.stringify(r ? { _and: [{ id: { _eq: t } }, r] } : { id: { _eq: t } }), { data: U } = useQuery({
6373
+ }), z = JSON.stringify(r ? { _and: [{ id: { _eq: t } }, r] } : { id: { _eq: t } }), { data: Q } = useQuery({
6374
6374
  queryKey: ["relation-avail", e, String(t), I],
6375
6375
  queryFn: () => c.request(
6376
6376
  get$1(`/items/${e}`, {
@@ -6380,9 +6380,9 @@ function RelationCombobox({
6380
6380
  fields: "id"
6381
6381
  })
6382
6382
  ).then((de) => de.data ?? []),
6383
- enabled: !!t && !!Q,
6383
+ enabled: !!t && !!U,
6384
6384
  staleTime: 3e4
6385
- }), ee = !!t && U !== void 0 && U.length === 0, le = useRef(null), J = t == null || t === "";
6385
+ }), ee = !!t && Q !== void 0 && Q.length === 0, le = useRef(null), J = t == null || t === "";
6386
6386
  useEffect(() => {
6387
6387
  if (!l || n || !J) return;
6388
6388
  const de = `${e}|${I ?? ""}`;
@@ -6401,7 +6401,7 @@ function RelationCombobox({
6401
6401
  le.current = null;
6402
6402
  }));
6403
6403
  }, [l, n, J, e, I]);
6404
- const V = L, oe = t && Q ? applyDisplayTemplate(V, Q) : null, ye = !!t && ie && !Q, he = useStaleTip(ee);
6404
+ const V = L, oe = t && U ? applyDisplayTemplate(V, U) : null, ye = !!t && ie && !U, he = useStaleTip(ee);
6405
6405
  return o ? /* @__PURE__ */ jsxs(
6406
6406
  "button",
6407
6407
  {
@@ -6740,12 +6740,12 @@ function AllocateDrawer({
6740
6740
  ), C = useMemo(() => {
6741
6741
  const E = /* @__PURE__ */ new Set(["id"]);
6742
6742
  e.group_by && E.add(e.group_by);
6743
- const K = (Q) => {
6744
- /^__\w+__$/.test(Q) || E.add(Q);
6743
+ const K = (U) => {
6744
+ /^__\w+__$/.test(U) || E.add(U);
6745
6745
  };
6746
- for (const Q of v) {
6747
- Q.path && K(Q.path);
6748
- for (const ie of (Q.formula ?? "").matchAll(/\{\{\s*([\w.]+)\s*\}\}/g)) K(ie[1]);
6746
+ for (const U of v) {
6747
+ U.path && K(U.path);
6748
+ for (const ie of (U.formula ?? "").matchAll(/\{\{\s*([\w.]+)\s*\}\}/g)) K(ie[1]);
6749
6749
  }
6750
6750
  return [...E].join(",");
6751
6751
  }, [v, e.group_by]), { data: F = [], isFetching: q } = useQuery({
@@ -6762,32 +6762,32 @@ function AllocateDrawer({
6762
6762
  }), g = useMemo(() => {
6763
6763
  const E = /* @__PURE__ */ new Map();
6764
6764
  for (const K of a) {
6765
- const Q = K[e.target_field];
6766
- Q != null && E.set(String(Q), K);
6765
+ const U = K[e.target_field];
6766
+ U != null && E.set(String(U), K);
6767
6767
  }
6768
6768
  return E;
6769
6769
  }, [a, e.target_field]);
6770
6770
  function b(E) {
6771
- const K = g.get(E), Q = (K == null ? void 0 : K.id) != null ? String(K.id) : null, ie = !!(Q && (m != null && m.has(Q))), z = (c ?? []).findIndex(
6771
+ const K = g.get(E), U = (K == null ? void 0 : K.id) != null ? String(K.id) : null, ie = !!(U && (m != null && m.has(U))), z = (c ?? []).findIndex(
6772
6772
  (ee) => String(ee[e.target_field]) === E
6773
6773
  );
6774
- let U = 0;
6775
- if (z >= 0) U = Number((c ?? [])[z][e.value_field]) || 0;
6774
+ let Q = 0;
6775
+ if (z >= 0) Q = Number((c ?? [])[z][e.value_field]) || 0;
6776
6776
  else if (K && !ie) {
6777
- const ee = Q ? p == null ? void 0 : p.get(Q) : void 0;
6778
- U = Number(ee && e.value_field in ee ? ee[e.value_field] : K[e.value_field]) || 0;
6777
+ const ee = U ? p == null ? void 0 : p.get(U) : void 0;
6778
+ Q = Number(ee && e.value_field in ee ? ee[e.value_field] : K[e.value_field]) || 0;
6779
6779
  }
6780
- return { savedRow: K, pendingIdx: z, amount: U, deleted: ie };
6780
+ return { savedRow: K, pendingIdx: z, amount: Q, deleted: ie };
6781
6781
  }
6782
- async function j(E, K, Q) {
6782
+ async function j(E, K, U) {
6783
6783
  let ie = K.trim() === "" ? null : Number(K);
6784
6784
  if (ie !== null && !Number.isFinite(ie)) return;
6785
- if (ie !== null && Q) {
6786
- const U = M(Q);
6787
- U !== null && ie > U && (ie = Math.max(0, Math.round(U * 100) / 100), S((ee) => ({ ...ee, [E]: String(ie) })));
6785
+ if (ie !== null && U) {
6786
+ const Q = M(U);
6787
+ Q !== null && ie > Q && (ie = Math.max(0, Math.round(Q * 100) / 100), S((ee) => ({ ...ee, [E]: String(ie) })));
6788
6788
  }
6789
6789
  if (d && o) {
6790
- const { savedRow: U, pendingIdx: ee, deleted: le } = b(E), J = (U == null ? void 0 : U.id) != null ? String(U.id) : null;
6790
+ const { savedRow: Q, pendingIdx: ee, deleted: le } = b(E), J = (Q == null ? void 0 : Q.id) != null ? String(Q.id) : null;
6791
6791
  ie === null || ie === 0 ? ee >= 0 ? o.removeRow(t, s, ee) : J && !le && (o.cancelPendingEdit(t, s, J), o.queueDelete(t, s, J)) : ee >= 0 ? o.updateRow(t, s, ee, {
6792
6792
  ...(c ?? [])[ee],
6793
6793
  [e.value_field]: ie
@@ -6814,10 +6814,10 @@ function AllocateDrawer({
6814
6814
  x(null);
6815
6815
  }
6816
6816
  }
6817
- function L(E, K, Q) {
6818
- const ie = E.replace(/\{\{\s*([\w.]+|__\w+__)\s*\}\}/g, (z, U) => {
6819
- if (U in Q) return String(Q[U]);
6820
- const ee = Number(walkPath$1(K, U));
6817
+ function L(E, K, U) {
6818
+ const ie = E.replace(/\{\{\s*([\w.]+|__\w+__)\s*\}\}/g, (z, Q) => {
6819
+ if (Q in U) return String(U[Q]);
6820
+ const ee = Number(walkPath$1(K, Q));
6821
6821
  return String(Number.isFinite(ee) ? ee : 0);
6822
6822
  });
6823
6823
  if (!/^[-+*/(). 0-9eE]+$/.test(ie)) return null;
@@ -6829,17 +6829,17 @@ function AllocateDrawer({
6829
6829
  }
6830
6830
  }
6831
6831
  function A(E) {
6832
- const K = g.get(E), Q = Number((K == null ? void 0 : K[e.value_field]) ?? 0) || 0, ie = u[E], z = d ? b(E).amount : Q;
6833
- return { __input__: ie !== void 0 && ie !== "" ? Number(ie) || 0 : z, __saved__: Q };
6832
+ const K = g.get(E), U = Number((K == null ? void 0 : K[e.value_field]) ?? 0) || 0, ie = u[E], z = d ? b(E).amount : U;
6833
+ return { __input__: ie !== void 0 && ie !== "" ? Number(ie) || 0 : z, __saved__: U };
6834
6834
  }
6835
6835
  function I(E, K) {
6836
- const Q = L(E, K, A(String(K.id)));
6837
- return Q === null ? "—" : Q.toLocaleString("en-US", { style: "currency", currency: "USD" });
6836
+ const U = L(E, K, A(String(K.id)));
6837
+ return U === null ? "—" : U.toLocaleString("en-US", { style: "currency", currency: "USD" });
6838
6838
  }
6839
6839
  function M(E) {
6840
6840
  if (!e.value_max) return null;
6841
- const K = g.get(String(E.id)), Q = Number((K == null ? void 0 : K[e.value_field]) ?? 0) || 0;
6842
- return L(e.value_max, E, { __input__: Q, __saved__: Q });
6841
+ const K = g.get(String(E.id)), U = Number((K == null ? void 0 : K[e.value_field]) ?? 0) || 0;
6842
+ return L(e.value_max, E, { __input__: U, __saved__: U });
6843
6843
  }
6844
6844
  return /* @__PURE__ */ jsxs(Fragment, { children: [
6845
6845
  /* @__PURE__ */ jsx(
@@ -6862,14 +6862,14 @@ function AllocateDrawer({
6862
6862
  ] }) }),
6863
6863
  /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-slate-100", children: (() => {
6864
6864
  const E = (le) => e.group_by ? String(walkPath$1(le, e.group_by) ?? "—") : "";
6865
- let K = F, Q = [];
6866
- e.group_by && (Q = [...new Set(F.map(E))], K = Q.flatMap((le) => F.filter((J) => E(J) === le)));
6865
+ let K = F, U = [];
6866
+ e.group_by && (U = [...new Set(F.map(E))], K = U.flatMap((le) => F.filter((J) => E(J) === le)));
6867
6867
  const ie = f ?? new Set(
6868
6868
  F.filter((le) => b(String(le.id)).amount > 0).map(E)
6869
6869
  ), z = (le) => y((J) => {
6870
6870
  const V = new Set(J ?? ie);
6871
6871
  return V.has(le) ? V.delete(le) : V.add(le), V;
6872
- }), U = [];
6872
+ }), Q = [];
6873
6873
  let ee = null;
6874
6874
  for (const le of K) {
6875
6875
  const J = String(le.id), V = E(le);
@@ -6884,7 +6884,7 @@ function AllocateDrawer({
6884
6884
  }
6885
6885
  return pe.toLocaleString("en-US", { style: "currency", currency: "USD" });
6886
6886
  }, _e = de.reduce((ke, G) => ke + A(String(G.id)).__input__, 0);
6887
- U.push(
6887
+ Q.push(
6888
6888
  /* @__PURE__ */ jsxs("tr", { className: "border-b border-slate-200 bg-slate-100/80", children: [
6889
6889
  /* @__PURE__ */ jsx("td", { colSpan: Z, className: "px-2 py-1", children: /* @__PURE__ */ jsxs(
6890
6890
  "button",
@@ -6922,7 +6922,7 @@ function AllocateDrawer({
6922
6922
  }
6923
6923
  if (e.group_by && !ie.has(V)) continue;
6924
6924
  const oe = b(J), ye = oe.amount > 0 ? oe.savedRow ?? {} : void 0, he = u[J] ?? (oe.amount > 0 ? String(oe.amount) : "");
6925
- U.push(
6925
+ Q.push(
6926
6926
  /* @__PURE__ */ jsxs("tr", { className: cn$1(ye && "bg-[#00ceff]/5"), children: [
6927
6927
  v.map((de, ae) => {
6928
6928
  const B = de.formula ? I(de.formula, le) : fmtDrawerVal(walkPath$1(le, de.path ?? ""), de.format);
@@ -6967,7 +6967,7 @@ function AllocateDrawer({
6967
6967
  ] }, J)
6968
6968
  );
6969
6969
  }
6970
- return U;
6970
+ return Q;
6971
6971
  })() })
6972
6972
  ] }) })
6973
6973
  ] })
@@ -7110,7 +7110,7 @@ function AutoAllocateButton({
7110
7110
  fields: `id,${_},${k}`,
7111
7111
  limit: 500
7112
7112
  })
7113
- ).then((Q) => Q.data ?? []), b = g.reduce((Q, ie) => Q + (Number(ie[k]) || 0), 0);
7113
+ ).then((U) => U.data ?? []), b = g.reduce((U, ie) => U + (Number(ie[k]) || 0), 0);
7114
7114
  let j = F - b;
7115
7115
  if (j <= 0) continue;
7116
7116
  const L = buildMatchedDrawer(
@@ -7127,34 +7127,34 @@ function AutoAllocateButton({
7127
7127
  ...e.candidates.sort ? { sort: e.candidates.sort } : {},
7128
7128
  limit: 500
7129
7129
  })
7130
- ).then((Q) => Q.data ?? []);
7130
+ ).then((U) => U.data ?? []);
7131
7131
  if (A.length === 0) {
7132
7132
  y.push(N + 1);
7133
7133
  continue;
7134
7134
  }
7135
- const I = A.map((Q) => String(Q.id)), M = await i.request(
7135
+ const I = A.map((U) => String(U.id)), M = await i.request(
7136
7136
  get$1(`/items/${t.collection}`, {
7137
7137
  filter: JSON.stringify({ [_]: { _in: I } }),
7138
7138
  fields: `${_},${k}`,
7139
7139
  limit: 2e3
7140
7140
  })
7141
- ).then((Q) => Q.data ?? []), E = {};
7142
- for (const Q of M) {
7143
- const ie = String(Q[_]);
7144
- E[ie] = (E[ie] ?? 0) + (Number(Q[k]) || 0);
7141
+ ).then((U) => U.data ?? []), E = {};
7142
+ for (const U of M) {
7143
+ const ie = String(U[_]);
7144
+ E[ie] = (E[ie] ?? 0) + (Number(U[k]) || 0);
7145
7145
  }
7146
7146
  const K = j;
7147
- for (const Q of A) {
7147
+ for (const U of A) {
7148
7148
  if (j <= 0) break;
7149
- const ie = String(Q.id), U = (evalClientFormula(e.candidates.capacity_formula, Q) ?? 0) - (E[ie] ?? 0) - (u[ie] ?? 0);
7150
- if (U < w) continue;
7151
- const ee = Math.min(j, U), le = g.find((J) => String(J[_]) === ie);
7149
+ const ie = String(U.id), Q = (evalClientFormula(e.candidates.capacity_formula, U) ?? 0) - (E[ie] ?? 0) - (u[ie] ?? 0);
7150
+ if (Q < w) continue;
7151
+ const ee = Math.min(j, Q), le = g.find((J) => String(J[_]) === ie);
7152
7152
  le ? await i.request(
7153
7153
  patch$1(`/items/${t.collection}/${le.id}`, {
7154
7154
  [k]: (Number(le[k]) || 0) + ee
7155
7155
  })
7156
7156
  ) : await i.request(
7157
- post$1(`/items/${t.collection}`, { ...q.seed, [_]: Q.id, [k]: ee })
7157
+ post$1(`/items/${t.collection}`, { ...q.seed, [_]: U.id, [k]: ee })
7158
7158
  ), u[ie] = (u[ie] ?? 0) + ee, j -= ee, S += ee;
7159
7159
  }
7160
7160
  j < K && f++, j > 0 && y.push(N + 1);
@@ -7216,13 +7216,13 @@ function InlineTableField({
7216
7216
  readOnly: j = !1
7217
7217
  }) {
7218
7218
  var na;
7219
- const L = useNivaroClient(), A = useDrilldown(), I = useQueryClient(), M = useO2MStaging(), E = useAddendumO2M()[b ?? ""] ?? [], K = s === "new", Q = useParentDraft(), ie = useReimportHandler(), z = q ? q.line_field ?? "line_number" : null, { data: U } = useQuery({
7219
+ const L = useNivaroClient(), A = useDrilldown(), I = useQueryClient(), M = useO2MStaging(), E = useAddendumO2M()[b ?? ""] ?? [], K = s === "new", U = useParentDraft(), ie = useReimportHandler(), z = q ? q.line_field ?? "line_number" : null, { data: Q } = useQuery({
7220
7220
  queryKey: ["erp-submissions", n ?? "", String(s)],
7221
7221
  queryFn: () => L.request(get$1(`/erp-submissions/${n}/${encodeURIComponent(String(s))}`)).then((O) => O.data ?? []),
7222
7222
  enabled: !!q && !!n && !K && !!s,
7223
7223
  staleTime: 15e3
7224
7224
  }), ee = useMemo(() => {
7225
- const O = /* @__PURE__ */ new Map(), ne = U == null ? void 0 : U[0];
7225
+ const O = /* @__PURE__ */ new Map(), ne = Q == null ? void 0 : Q[0];
7226
7226
  if (!ne || ne.status !== "failed") return O;
7227
7227
  const xe = ne.response, ge = xe && typeof xe == "object" && Array.isArray(xe.orderDetailResponse) ? xe.orderDetailResponse : [];
7228
7228
  for (const Ce of ge)
@@ -7243,7 +7243,7 @@ function InlineTableField({
7243
7243
  Fe && !O.has(Fe[1]) && O.set(Fe[1], Fe[2] || Ce.trim());
7244
7244
  }
7245
7245
  return O;
7246
- }, [U]), le = useRef(!1), [J, V] = useState(K && !!g);
7246
+ }, [Q]), le = useRef(!1), [J, V] = useState(K && !!g);
7247
7247
  useEffect(() => {
7248
7248
  if (!le.current) {
7249
7249
  if (!K || !g || !M) {
@@ -7370,37 +7370,37 @@ function InlineTableField({
7370
7370
  staleTime: 3e4
7371
7371
  }), Zt = c ?? [], Ks = useQueries({
7372
7372
  queries: Zt.map((O) => ({
7373
- queryKey: ["resolve-cascade", Q == null ? void 0 : Q.collection, O.parent_field, e, O.child_field],
7373
+ queryKey: ["resolve-cascade", U == null ? void 0 : U.collection, O.parent_field, e, O.child_field],
7374
7374
  queryFn: () => L.request(
7375
7375
  get$1("/data-model/resolve-cascade", {
7376
- parent_collection: Q.collection,
7376
+ parent_collection: U.collection,
7377
7377
  parent_field: O.parent_field,
7378
7378
  child_collection: e,
7379
7379
  child_field: O.child_field
7380
7380
  })
7381
7381
  ).then((ne) => ne.data),
7382
- enabled: !!(Q != null && Q.collection) && !!O.parent_field && !!O.child_field,
7382
+ enabled: !!(U != null && U.collection) && !!O.parent_field && !!O.child_field,
7383
7383
  staleTime: 3e5
7384
7384
  }))
7385
7385
  }), Pt = useMemo(() => {
7386
7386
  const O = {};
7387
- return !Q || !Zt.length || Zt.forEach((ne, xe) => {
7387
+ return !U || !Zt.length || Zt.forEach((ne, xe) => {
7388
7388
  var Fe;
7389
7389
  const ge = (Fe = Ks[xe]) == null ? void 0 : Fe.data;
7390
7390
  if (!ge || ge.type === "none") return;
7391
- const Ce = Q.draft[ne.parent_field];
7391
+ const Ce = U.draft[ne.parent_field];
7392
7392
  Ce == null || Ce === "" || (ge.type === "direct_fk" ? O[ne.child_field] = { [ge.filter_column]: { _eq: Ce } } : ge.type === "m2m_junction" && (O[ne.child_field] = {
7393
7393
  _exists_junction: { table: ge.table, self_fk: ge.self_fk, filter_fk: ge.filter_fk, value: Ce }
7394
7394
  }));
7395
7395
  }), O;
7396
- }, [Zt, Ks, Q]), it = i === "pending", te = M ? M.getPendingRows(e, t) : [], $e = it && M ? M.getPendingEdits(e, t) : /* @__PURE__ */ new Map(), Se = it && M ? M.getPendingDeletes(e, t) : /* @__PURE__ */ new Set(), Le = useMemo(
7396
+ }, [Zt, Ks, U]), it = i === "pending", te = M ? M.getPendingRows(e, t) : [], $e = it && M ? M.getPendingEdits(e, t) : /* @__PURE__ */ new Map(), Se = it && M ? M.getPendingDeletes(e, t) : /* @__PURE__ */ new Set(), Le = useMemo(
7397
7397
  () => Y.filter((O) => O.interface === "relation-path" && O.field.includes(".")).map((O) => O.field),
7398
7398
  [Y]
7399
- ), Ue = useMemo(
7399
+ ), Qe = useMemo(
7400
7400
  () => Y.filter((O) => O.interface === "match-agg-column"),
7401
7401
  [Y]
7402
7402
  ), Ye = useMemo(
7403
- () => Ue.map((O) => {
7403
+ () => Qe.map((O) => {
7404
7404
  const ne = O.options ? typeof O.options == "string" ? (() => {
7405
7405
  try {
7406
7406
  return JSON.parse(O.options);
@@ -7414,7 +7414,7 @@ function InlineTableField({
7414
7414
  Ce.push([Me, Ae.slice(5)]);
7415
7415
  continue;
7416
7416
  }
7417
- const Xe = resolveMatchToken(Ae, {}, s, Q == null ? void 0 : Q.draft);
7417
+ const Xe = resolveMatchToken(Ae, {}, s, U == null ? void 0 : U.draft);
7418
7418
  if (Xe == null || Xe === "") {
7419
7419
  Fe = !0;
7420
7420
  continue;
@@ -7444,7 +7444,7 @@ function InlineTableField({
7444
7444
  format: ne.format ?? null
7445
7445
  };
7446
7446
  }),
7447
- [Ue, s, Q == null ? void 0 : Q.draft]
7447
+ [Qe, s, U == null ? void 0 : U.draft]
7448
7448
  ), qe = useQueries({
7449
7449
  queries: Ye.map((O) => ({
7450
7450
  queryKey: [
@@ -7537,7 +7537,7 @@ function InlineTableField({
7537
7537
  });
7538
7538
  }
7539
7539
  return O;
7540
- }, [as, jt, xt, it, $e, x, u, S]), Ut = !!S && !!jt, [es, ms] = useState(/* @__PURE__ */ new Set()), Ms = (O) => String(O[S ?? ""] ?? "").trim() || "Uncategorized", on = (O) => ms((ne) => {
7540
+ }, [as, jt, xt, it, $e, x, u, S]), Qt = !!S && !!jt, [es, ms] = useState(/* @__PURE__ */ new Set()), Ms = (O) => String(O[S ?? ""] ?? "").trim() || "Uncategorized", on = (O) => ms((ne) => {
7541
7541
  const xe = new Set(ne);
7542
7542
  return xe.has(O) ? xe.delete(O) : xe.add(O), xe;
7543
7543
  }), wn = useMemo(
@@ -7615,7 +7615,7 @@ function InlineTableField({
7615
7615
  var ge;
7616
7616
  O.set(ne, ((ge = nn[xe]) == null ? void 0 : ge.data) ?? []);
7617
7617
  }), O;
7618
- }, [Vt, nn]), Qs = useMemo(() => {
7618
+ }, [Vt, nn]), Us = useMemo(() => {
7619
7619
  const O = /* @__PURE__ */ new Map();
7620
7620
  return Vt.forEach((ne, xe) => {
7621
7621
  var ge;
@@ -7626,7 +7626,7 @@ function InlineTableField({
7626
7626
  for (const ne of As) {
7627
7627
  const xe = js.get(ne);
7628
7628
  if (!xe) continue;
7629
- const ge = Qs.get(xe.grandCollection) ?? [], Ce = /* @__PURE__ */ new Map();
7629
+ const ge = Us.get(xe.grandCollection) ?? [], Ce = /* @__PURE__ */ new Map();
7630
7630
  for (const Fe of rs) {
7631
7631
  if (Fe.relationField !== ne) continue;
7632
7632
  const Me = ge.find((Ae) => Ae.many_collection === xe.grandCollection && Ae.many_field === Fe.memberField && !Ae.junction_field);
@@ -7635,7 +7635,7 @@ function InlineTableField({
7635
7635
  O.set(ne, Ce);
7636
7636
  }
7637
7637
  return O;
7638
- }, [As, js, Qs, rs]), Ss = useMemo(() => dt.map((O) => String(O.id)), [dt]), $n = Ss.join(","), un = useQueries({
7638
+ }, [As, js, Us, rs]), Ss = useMemo(() => dt.map((O) => String(O.id)), [dt]), $n = Ss.join(","), un = useQueries({
7639
7639
  queries: As.map((O) => {
7640
7640
  const ne = js.get(O);
7641
7641
  return {
@@ -7684,7 +7684,7 @@ function InlineTableField({
7684
7684
  }
7685
7685
  for (const [xe, ge] of O) O.set(xe, [...new Set(ge)].sort());
7686
7686
  return O;
7687
- }, [Zs, an, te]), { data: Us = {} } = useQuery({
7687
+ }, [Zs, an, te]), { data: Qs = {} } = useQuery({
7688
7688
  queryKey: ["summary-m2o-display", e, ...Array.from(hn.entries()).flat(2)],
7689
7689
  queryFn: async () => {
7690
7690
  const O = {};
@@ -7738,7 +7738,7 @@ function InlineTableField({
7738
7738
  const Xe = (ft = an.get(Ce)) == null ? void 0 : ft.get(Fe), Ve = Ae.map((bt) => {
7739
7739
  var pt;
7740
7740
  const Ct = bt[Fe];
7741
- return Ct == null || Ct === "" ? null : Xe != null && Xe.one_collection ? ((pt = Us[Xe.one_collection]) == null ? void 0 : pt[String(Ct)]) ?? String(Ct) : String(Ct);
7741
+ return Ct == null || Ct === "" ? null : Xe != null && Xe.one_collection ? ((pt = Qs[Xe.one_collection]) == null ? void 0 : pt[String(Ct)]) ?? String(Ct) : String(Ct);
7742
7742
  }).filter((bt) => !!bt);
7743
7743
  return Ve.length > 0 ? Ve.join(", ") : "—";
7744
7744
  }
@@ -7753,7 +7753,7 @@ function InlineTableField({
7753
7753
  const Ae = Me.one_collection, Xe = Fe.map((ft) => {
7754
7754
  var Ct;
7755
7755
  const bt = ft[Ce];
7756
- return bt == null || bt === "" ? null : { id: String(bt), label: ((Ct = Us[Ae]) == null ? void 0 : Ct[String(bt)]) ?? String(bt) };
7756
+ return bt == null || bt === "" ? null : { id: String(bt), label: ((Ct = Qs[Ae]) == null ? void 0 : Ct[String(bt)]) ?? String(bt) };
7757
7757
  }).filter((ft) => !!ft);
7758
7758
  return Xe.length === 0 ? "—" : /* @__PURE__ */ jsx("span", { className: "inline-flex flex-wrap gap-x-1.5", children: Xe.map((ft, bt) => /* @__PURE__ */ jsx(
7759
7759
  "button",
@@ -7771,7 +7771,7 @@ function InlineTableField({
7771
7771
  const ps = zt && (dn.length > 0 || Cs.length > 0) ? [...dn, ...Cs] : _s, Mn = useMemo(
7772
7772
  () => Y.filter((O) => O.group_key === "__apply_values__" && !NON_DISPLAY_TYPES$1.has(O.type ?? "") && !SENTINEL_FIELDS.has(O.field)),
7773
7773
  [Y]
7774
- ), Qn = useMemo(
7774
+ ), Un = useMemo(
7775
7775
  () => Y.filter((O) => O.group_key === "__create_with_defaults__" && !NON_DISPLAY_TYPES$1.has(O.type ?? "") && !SENTINEL_FIELDS.has(O.field)),
7776
7776
  [Y]
7777
7777
  ), Ps = useMemo(() => {
@@ -7889,7 +7889,7 @@ function InlineTableField({
7889
7889
  const ne = String(O.id);
7890
7890
  (Ne == null ? void 0 : Ne.rowId) !== ne && Ie({ rowId: ne, draft: sn({ ...O }) });
7891
7891
  }
7892
- function Un(O, ne) {
7892
+ function Qn(O, ne) {
7893
7893
  if (j) return;
7894
7894
  const xe = `pending:${ne}`;
7895
7895
  (Ne == null ? void 0 : Ne.rowId) !== xe && Ie({ rowId: xe, draft: sn({ ...O }) });
@@ -7904,14 +7904,14 @@ function InlineTableField({
7904
7904
  const xe = Je.current, ge = sn(xe ? { ...xe.draft, [O]: ne } : { [O]: ne });
7905
7905
  if (Ie((Ce) => Ce && { ...Ce, draft: ge }), p && p.length > 0 && L) {
7906
7906
  const Ce = {};
7907
- if (Q != null && Q.draft) {
7907
+ if (U != null && U.draft) {
7908
7908
  if (k != null && k.length)
7909
- for (const Fe of k) Ce[Fe] = Q.draft[Fe] ?? null;
7909
+ for (const Fe of k) Ce[Fe] = U.draft[Fe] ?? null;
7910
7910
  for (const Fe of p) {
7911
7911
  const Me = Fe.trigger_field;
7912
7912
  if (typeof Me == "string" && Me.startsWith("$parent.")) {
7913
7913
  const Ae = Me.slice(8);
7914
- Ae in Ce || (Ce[Ae] = Q.draft[Ae] ?? null);
7914
+ Ae in Ce || (Ce[Ae] = U.draft[Ae] ?? null);
7915
7915
  }
7916
7916
  }
7917
7917
  }
@@ -8315,7 +8315,7 @@ function InlineTableField({
8315
8315
  parentId: s,
8316
8316
  rows: K ? [] : dt,
8317
8317
  rowDefaults: ds,
8318
- parentDraft: Q == null ? void 0 : Q.draft,
8318
+ parentDraft: U == null ? void 0 : U.draft,
8319
8319
  invalidate: () => I.invalidateQueries({ queryKey: ["o2m-rows", e, t, s] }),
8320
8320
  staging: M,
8321
8321
  stagingActive: (K || it) && !!M,
@@ -8335,7 +8335,7 @@ function InlineTableField({
8335
8335
  matchCfg: O.match,
8336
8336
  rows: dt,
8337
8337
  parentId: s,
8338
- parentDraft: Q == null ? void 0 : Q.draft,
8338
+ parentDraft: U == null ? void 0 : U.draft,
8339
8339
  relatedCollection: e,
8340
8340
  manyField: t
8341
8341
  }
@@ -8384,7 +8384,7 @@ function InlineTableField({
8384
8384
  compact: !0
8385
8385
  }
8386
8386
  ),
8387
- Qn.length > 0 && /* @__PURE__ */ jsx(
8387
+ Un.length > 0 && /* @__PURE__ */ jsx(
8388
8388
  "button",
8389
8389
  {
8390
8390
  type: "button",
@@ -8478,7 +8478,7 @@ function InlineTableField({
8478
8478
  d && (xt || K || it) && /* @__PURE__ */ jsx("td", { className: "w-6" }),
8479
8479
  o && /* @__PURE__ */ jsx("td", { className: "w-8" }),
8480
8480
  (K || it) && /* @__PURE__ */ jsx("td", { className: "px-3 py-1 align-middle w-20", children: /* @__PURE__ */ jsx("span", { className: "text-[10px] font-medium text-[#009abe]", children: "Defaults" }) }),
8481
- Qn.map((O) => /* @__PURE__ */ jsx("td", { className: "px-2 py-1 align-top", children: /* @__PURE__ */ jsx(
8481
+ Un.map((O) => /* @__PURE__ */ jsx("td", { className: "px-2 py-1 align-top", children: /* @__PURE__ */ jsx(
8482
8482
  FieldRenderer,
8483
8483
  {
8484
8484
  field: O,
@@ -8513,7 +8513,7 @@ function InlineTableField({
8513
8513
  Ae.preventDefault(), is !== null && Js !== null && is !== Js && (M == null || M.reorderRows(e, t, is, Js)), Es();
8514
8514
  },
8515
8515
  onDragEnd: Es,
8516
- onClick: () => !ge && Un(O, ne),
8516
+ onClick: () => !ge && Qn(O, ne),
8517
8517
  onBlur: (Ae) => {
8518
8518
  !ge || st || Ae.currentTarget.contains(Ae.relatedTarget) || (qt.current = setTimeout(() => void ks(), 150));
8519
8519
  },
@@ -8625,7 +8625,7 @@ function InlineTableField({
8625
8625
  ] }, ne);
8626
8626
  }),
8627
8627
  !K && Rt === "original" && dt.map((O, ne) => {
8628
- const xe = String(O.id), ge = Ut ? Ms(O) : null, Ce = ge !== null && (ne === 0 || Ms(dt[ne - 1]) !== ge), Fe = ge !== null && es.has(ge), Me = Ce && ge !== null ? /* @__PURE__ */ jsx("tr", { className: "border-b border-slate-200 bg-slate-100/80 dark:border-border dark:bg-muted", children: /* @__PURE__ */ jsx("td", { colSpan: ps.length + 1 + (K || it ? 1 : 0) + (o ? 1 : 0) + (d && (xt || K || it) ? 1 : 0), className: "px-2 py-1", children: /* @__PURE__ */ jsxs(
8628
+ const xe = String(O.id), ge = Qt ? Ms(O) : null, Ce = ge !== null && (ne === 0 || Ms(dt[ne - 1]) !== ge), Fe = ge !== null && es.has(ge), Me = Ce && ge !== null ? /* @__PURE__ */ jsx("tr", { className: "border-b border-slate-200 bg-slate-100/80 dark:border-border dark:bg-muted", children: /* @__PURE__ */ jsx("td", { colSpan: ps.length + 1 + (K || it ? 1 : 0) + (o ? 1 : 0) + (d && (xt || K || it) ? 1 : 0), className: "px-2 py-1", children: /* @__PURE__ */ jsxs(
8629
8629
  "button",
8630
8630
  {
8631
8631
  type: "button",
@@ -8770,7 +8770,7 @@ function InlineTableField({
8770
8770
  }
8771
8771
  ) }),
8772
8772
  Ae && !ft && _ && _.length > 0 && /* @__PURE__ */ jsx("tr", { className: "border-b border-slate-100 bg-[#f0fbff]/60 dark:bg-nvr-cyan/5", children: /* @__PURE__ */ jsx("td", { colSpan: En, className: "px-3 py-2", children: /* @__PURE__ */ jsx("div", { className: "space-y-2", children: _.map((pt) => {
8773
- const ss = typeof pt == "string" ? pt : pt.field, Os = typeof pt == "string" ? void 0 : pt.hint, Yt = typeof pt == "string" ? void 0 : pt.match, Bt = (Ne == null ? void 0 : Ne.draft) ?? bt, Gs = Yt ? buildMatchedDrawer(Yt, Bt, s, Q == null ? void 0 : Q.draft) : null;
8773
+ const ss = typeof pt == "string" ? pt : pt.field, Os = typeof pt == "string" ? void 0 : pt.hint, Yt = typeof pt == "string" ? void 0 : pt.match, Bt = (Ne == null ? void 0 : Ne.draft) ?? bt, Gs = Yt ? buildMatchedDrawer(Yt, Bt, s, U == null ? void 0 : U.draft) : null;
8774
8774
  return /* @__PURE__ */ jsx(
8775
8775
  NestedRelationEditor,
8776
8776
  {
@@ -9090,10 +9090,10 @@ function CatalogPickerField({
9090
9090
  }), q = F == null ? void 0 : F.display_template, g = d == null ? void 0 : d.draft, { resolvedFilter: b, missingParents: j } = useMemo(() => {
9091
9091
  const te = [], $e = (Le) => {
9092
9092
  if (typeof Le == "string" && Le.startsWith("$parent.")) {
9093
- const Ue = Le.slice(8), Ye = g == null ? void 0 : g[Ue];
9094
- return Ye == null || Ye === "" ? (te.push(Ue), Le) : Ye;
9093
+ const Qe = Le.slice(8), Ye = g == null ? void 0 : g[Qe];
9094
+ return Ye == null || Ye === "" ? (te.push(Qe), Le) : Ye;
9095
9095
  }
9096
- return Array.isArray(Le) ? Le.map($e) : Le && typeof Le == "object" ? Object.fromEntries(Object.entries(Le).map(([Ue, Ye]) => [Ue, $e(Ye)])) : Le;
9096
+ return Array.isArray(Le) ? Le.map($e) : Le && typeof Le == "object" ? Object.fromEntries(Object.entries(Le).map(([Qe, Ye]) => [Qe, $e(Ye)])) : Le;
9097
9097
  };
9098
9098
  return { resolvedFilter: a.filter ? $e(a.filter) : void 0, missingParents: [...new Set(te)] };
9099
9099
  }, [a.filter, g]), L = useMemo(() => {
@@ -9129,20 +9129,20 @@ function CatalogPickerField({
9129
9129
  ).then((te) => te.data ?? []),
9130
9130
  enabled: !m,
9131
9131
  staleTime: 15e3
9132
- }), Q = m && o ? o.getPendingRows(e, t) : [], ie = !m && o ? o.getPendingDeletes(e, t) : /* @__PURE__ */ new Set(), z = useMemo(() => {
9132
+ }), U = m && o ? o.getPendingRows(e, t) : [], ie = !m && o ? o.getPendingDeletes(e, t) : /* @__PURE__ */ new Set(), z = useMemo(() => {
9133
9133
  const te = /* @__PURE__ */ new Map();
9134
9134
  for (const $e of K) {
9135
9135
  const Se = $e[a.item_field];
9136
9136
  Se != null && te.set(String(Se), $e);
9137
9137
  }
9138
9138
  return te;
9139
- }, [K, a.item_field]), U = useMemo(() => {
9139
+ }, [K, a.item_field]), Q = useMemo(() => {
9140
9140
  const te = /* @__PURE__ */ new Map();
9141
- return Q.forEach(($e, Se) => {
9141
+ return U.forEach(($e, Se) => {
9142
9142
  const Le = $e[a.item_field];
9143
9143
  Le != null && te.set(String(Le), Se);
9144
9144
  }), te;
9145
- }, [Q, a.item_field]), ee = useMemo(() => m ? Q.filter((te) => te[a.item_field] != null).map((te) => ({ key: String(te[a.item_field]), row: te })) : K.filter((te) => te[a.item_field] != null).map((te) => ({ key: String(te[a.item_field]), row: te })), [m, Q, K, a.item_field]), le = useMemo(
9145
+ }, [U, a.item_field]), ee = useMemo(() => m ? U.filter((te) => te[a.item_field] != null).map((te) => ({ key: String(te[a.item_field]), row: te })) : K.filter((te) => te[a.item_field] != null).map((te) => ({ key: String(te[a.item_field]), row: te })), [m, U, K, a.item_field]), le = useMemo(
9146
9146
  () => ee.filter((te) => !E.has(te.key)).map((te) => te.key),
9147
9147
  [ee, E]
9148
9148
  ), { data: J = [] } = useQuery({
@@ -9214,9 +9214,9 @@ function CatalogPickerField({
9214
9214
  ae.join(",")
9215
9215
  ],
9216
9216
  queryFn: async () => {
9217
- const Se = {}, Le = te.aggregate === "sum", Ue = Le ? 150 : 400;
9218
- for (let Ye = 0; Ye < ae.length; Ye += Ue) {
9219
- const qe = ae.slice(Ye, Ye + Ue);
9217
+ const Se = {}, Le = te.aggregate === "sum", Qe = Le ? 150 : 400;
9218
+ for (let Ye = 0; Ye < ae.length; Ye += Qe) {
9219
+ const qe = ae.slice(Ye, Ye + Qe);
9220
9220
  let St = 1;
9221
9221
  for (; ; ) {
9222
9222
  const Et = await l.request(
@@ -9247,10 +9247,10 @@ function CatalogPickerField({
9247
9247
  };
9248
9248
  })
9249
9249
  }), ue = (te, $e) => {
9250
- var Le, Ue;
9250
+ var Le, Qe;
9251
9251
  const Se = (a.related_columns ?? []).findIndex((Ye) => Ye.key === te);
9252
9252
  if (Se !== -1)
9253
- return (Ue = (Le = B[Se]) == null ? void 0 : Le.data) == null ? void 0 : Ue[$e];
9253
+ return (Qe = (Le = B[Se]) == null ? void 0 : Le.data) == null ? void 0 : Qe[$e];
9254
9254
  }, Z = (te) => {
9255
9255
  var St;
9256
9256
  const $e = a.qty_warning;
@@ -9259,9 +9259,9 @@ function CatalogPickerField({
9259
9259
  if (Se <= 0) return null;
9260
9260
  const Le = (a.related_columns ?? []).findIndex((Et) => Et.key === $e.column);
9261
9261
  if (Le === -1) return null;
9262
- const Ue = (St = B[Le]) == null ? void 0 : St.data;
9263
- if (Ue === void 0) return null;
9264
- const Ye = Ue[te], qe = Ye == null || Ye === "" ? 0 : Number(Ye);
9262
+ const Qe = (St = B[Le]) == null ? void 0 : St.data;
9263
+ if (Qe === void 0) return null;
9264
+ const Ye = Qe[te], qe = Ye == null || Ye === "" ? 0 : Number(Ye);
9265
9265
  return Number.isNaN(qe) ? null : Se > qe ? { available: qe, qty: Se } : null;
9266
9266
  }, je = a.qty_warning ? a.qty_warning.label ?? ((it = (a.related_columns ?? []).find((te) => {
9267
9267
  var $e;
@@ -9283,8 +9283,8 @@ function CatalogPickerField({
9283
9283
  if (!te || te.status !== "failed") return null;
9284
9284
  const $e = te.payload, Se = /* @__PURE__ */ new Set();
9285
9285
  for (const Le of Array.isArray($e == null ? void 0 : $e.products) ? $e.products : [])
9286
- for (const Ue of Object.values(Le ?? {}))
9287
- (typeof Ue == "string" || typeof Ue == "number") && Ue !== "" && Se.add(String(Ue));
9286
+ for (const Qe of Object.values(Le ?? {}))
9287
+ (typeof Qe == "string" || typeof Qe == "number") && Qe !== "" && Se.add(String(Qe));
9288
9288
  return Se.size === 0 ? null : { idents: Se, error: te.last_error ?? "Submission failed" };
9289
9289
  }, [G]), me = ee.map((te) => te.key).join(","), { data: ce } = useQuery({
9290
9290
  queryKey: ["catalog-suberr-idents", C, ke.join(","), me],
@@ -9308,8 +9308,8 @@ function CatalogPickerField({
9308
9308
  return [
9309
9309
  Ot(te),
9310
9310
  ...ke.map((Le) => {
9311
- const Ue = ($e == null ? void 0 : $e[Le]) ?? At(te)[Le];
9312
- return Ue != null && Ue !== "" ? String(Ue) : null;
9311
+ const Qe = ($e == null ? void 0 : $e[Le]) ?? At(te)[Le];
9312
+ return Qe != null && Qe !== "" ? String(Qe) : null;
9313
9313
  })
9314
9314
  ].some((Le) => Le && pe.idents.has(Le)) ? pe.error : null;
9315
9315
  }, Be = a.summary_fields ?? [], Ne = K.map((te) => String(te.id)).join(","), Ie = useQueries({
@@ -9324,11 +9324,11 @@ function CatalogPickerField({
9324
9324
  fields: `${Se.fk_to_child},${Se.related_field}`,
9325
9325
  filter: JSON.stringify({ [Se.fk_to_child]: { _in: $e } })
9326
9326
  })
9327
- ).then((mt) => mt.data ?? []).catch(() => []), Ue = [...new Set(Le.map((mt) => String(mt[Se.related_field])))], Ye = Se.label_field ?? "name", qe = Ue.length ? await l.request(
9327
+ ).then((mt) => mt.data ?? []).catch(() => []), Qe = [...new Set(Le.map((mt) => String(mt[Se.related_field])))], Ye = Se.label_field ?? "name", qe = Qe.length ? await l.request(
9328
9328
  get$1(`/items/${Se.related_collection}`, {
9329
9329
  limit: 500,
9330
9330
  fields: `id,${Ye}`,
9331
- filter: JSON.stringify({ id: { _in: Ue } })
9331
+ filter: JSON.stringify({ id: { _in: Qe } })
9332
9332
  })
9333
9333
  ).then((mt) => mt.data ?? []).catch(() => []) : [], St = new Map(qe.map((mt) => [String(mt.id), String(mt[Ye] ?? mt.id)])), Et = {};
9334
9334
  for (const mt of Le) {
@@ -9341,13 +9341,13 @@ function CatalogPickerField({
9341
9341
  staleTime: 15e3
9342
9342
  }))
9343
9343
  }), Je = (te, $e) => {
9344
- var Ue, Ye;
9344
+ var Qe, Ye;
9345
9345
  if (!te.m2m) return $e.row[te.field];
9346
9346
  const Se = Be.filter((qe) => qe.m2m).findIndex((qe) => qe.field === te.field);
9347
9347
  if (Se === -1) return;
9348
9348
  const Le = $e.row.id;
9349
9349
  if (Le != null)
9350
- return (Ye = (Ue = Ie[Se]) == null ? void 0 : Ue.data) == null ? void 0 : Ye[String(Le)];
9350
+ return (Ye = (Qe = Ie[Se]) == null ? void 0 : Qe.data) == null ? void 0 : Ye[String(Le)];
9351
9351
  }, st = a.columns ?? [], _t = a.related_columns ?? [], Ft = st.filter((te) => !te.summary_only), $t = _t.filter((te) => !te.summary_only), ut = st.filter((te) => !te.sections_only), Nt = _t.filter((te) => !te.sections_only), Rt = Ft.length > 0 || $t.length > 0, et = (te, $e) => {
9352
9352
  let Se = te;
9353
9353
  for (const Le of $e.split(".")) {
@@ -9385,8 +9385,8 @@ function CatalogPickerField({
9385
9385
  }, At = (te) => E.get(te) ?? J.find(($e) => String($e.id) === te) ?? ye.find(($e) => String($e.id) === te) ?? { id: te }, Y = (te) => {
9386
9386
  var Se;
9387
9387
  if (m) {
9388
- const Le = U.get(te);
9389
- return Le === void 0 ? null : Number(((Se = Q[Le]) == null ? void 0 : Se[h]) ?? 0);
9388
+ const Le = Q.get(te);
9389
+ return Le === void 0 ? null : Number(((Se = U[Le]) == null ? void 0 : Se[h]) ?? 0);
9390
9390
  }
9391
9391
  const $e = z.get(te);
9392
9392
  return $e ? Number($e[h] ?? 0) : null;
@@ -9402,14 +9402,14 @@ function CatalogPickerField({
9402
9402
  for (const Se of I) {
9403
9403
  const Le = applyDisplayTemplate(q, Se);
9404
9404
  if (te && !Le.toLowerCase().includes(te)) continue;
9405
- const Ue = Oe(Se) || "Uncategorized";
9406
- $e.has(Ue) || $e.set(Ue, []), $e.get(Ue).push({ id: String(Se.id), label: Le, row: Se });
9405
+ const Qe = Oe(Se) || "Uncategorized";
9406
+ $e.has(Qe) || $e.set(Qe, []), $e.get(Qe).push({ id: String(Se.id), label: Le, row: Se });
9407
9407
  }
9408
9408
  return [...$e.entries()].sort(
9409
9409
  ([Se], [Le]) => Se === "Uncategorized" ? 1 : Le === "Uncategorized" ? -1 : Se.localeCompare(Le)
9410
9410
  ).map(([Se, Le]) => ({
9411
9411
  name: Se,
9412
- items: Le.sort((Ue, Ye) => Ue.label.localeCompare(Ye.label))
9412
+ items: Le.sort((Qe, Ye) => Qe.label.localeCompare(Ye.label))
9413
9413
  }));
9414
9414
  }, [I, q, x, a.section_by]);
9415
9415
  if (!w.current && wt.length > 0) {
@@ -9425,13 +9425,13 @@ function CatalogPickerField({
9425
9425
  if (!Se.copy_to) continue;
9426
9426
  let Le = ue(Se.key, te);
9427
9427
  if (Le === void 0) {
9428
- const Ue = resolveRelatedMatch(Se.match, g);
9429
- if (Ue === null) continue;
9428
+ const Qe = resolveRelatedMatch(Se.match, g);
9429
+ if (Qe === null) continue;
9430
9430
  Le = await l.request(
9431
9431
  get$1(`/items/${Se.collection}`, {
9432
9432
  limit: 1,
9433
9433
  fields: `${Se.item_field},${Se.value_field}`,
9434
- filter: JSON.stringify({ ...Ue, [Se.item_field]: { _eq: te } })
9434
+ filter: JSON.stringify({ ...Qe, [Se.item_field]: { _eq: te } })
9435
9435
  })
9436
9436
  ).then((Ye) => {
9437
9437
  var qe, St;
@@ -9444,27 +9444,27 @@ function CatalogPickerField({
9444
9444
  return $e;
9445
9445
  }
9446
9446
  function xt(te, $e, Se, Le = {}) {
9447
- const Ue = {
9447
+ const Qe = {
9448
9448
  [a.item_field]: Se.id ?? te,
9449
9449
  [h]: $e
9450
9450
  };
9451
9451
  for (const [Ye, qe] of Object.entries(a.copy_fields ?? {}))
9452
- Se[qe] !== void 0 && (Ue[Ye] = Se[qe]);
9453
- Object.assign(Ue, Le);
9452
+ Se[qe] !== void 0 && (Qe[Ye] = Se[qe]);
9453
+ Object.assign(Qe, Le);
9454
9454
  for (const [Ye, qe] of Object.entries(a.compute_fields ?? {})) {
9455
- const St = evalClientFormula(qe, Ue);
9456
- St !== null && (Ue[Ye] = St);
9455
+ const St = evalClientFormula(qe, Qe);
9456
+ St !== null && (Qe[Ye] = St);
9457
9457
  }
9458
- return Ue;
9458
+ return Qe;
9459
9459
  }
9460
9460
  async function ht(te, $e, Se) {
9461
9461
  const Le = $e.trim() === "" ? 0 : Number($e);
9462
9462
  if (Number.isNaN(Le) || Le < 0 || (Y(te) ?? 0) === Le) return;
9463
9463
  const Ye = Le > 0 ? await vt(te) : {};
9464
9464
  if (m) {
9465
- const qe = U.get(te);
9465
+ const qe = Q.get(te);
9466
9466
  Le === 0 ? qe !== void 0 && (o == null || o.removeRow(e, t, qe)) : qe !== void 0 ? o == null || o.updateRow(e, t, qe, {
9467
- ...Q[qe],
9467
+ ...U[qe],
9468
9468
  ...xt(te, Le, Se, Ye)
9469
9469
  }) : o == null || o.queueRow(
9470
9470
  e,
@@ -9507,7 +9507,7 @@ function CatalogPickerField({
9507
9507
  async function ds(te, $e, Se) {
9508
9508
  const Le = Se.trim() === "" ? null : Number(Se);
9509
9509
  if (Se.trim() !== "" && Number.isNaN(Le)) return;
9510
- const Ue = (qe) => {
9510
+ const Qe = (qe) => {
9511
9511
  const St = { ...qe, [$e]: Le };
9512
9512
  for (const [Et, mt] of Object.entries(a.compute_fields ?? {})) {
9513
9513
  const It = evalClientFormula(mt, St);
@@ -9516,16 +9516,16 @@ function CatalogPickerField({
9516
9516
  return St;
9517
9517
  };
9518
9518
  if (m) {
9519
- const qe = U.get(te);
9519
+ const qe = Q.get(te);
9520
9520
  if (qe === void 0) return;
9521
- o == null || o.updateRow(e, t, qe, Ue(Q[qe]));
9521
+ o == null || o.updateRow(e, t, qe, Qe(U[qe]));
9522
9522
  return;
9523
9523
  }
9524
9524
  const Ye = z.get(te);
9525
9525
  if ((Ye == null ? void 0 : Ye.id) != null) {
9526
9526
  v((qe) => new Set(qe).add(te));
9527
9527
  try {
9528
- const { id: qe, ...St } = Ue(Ye);
9528
+ const { id: qe, ...St } = Qe(Ye);
9529
9529
  await l.request(patch$1(`/items/${e}/${Ye.id}`, St)), i.invalidateQueries({ queryKey: ["o2m-rows", e, t, s] });
9530
9530
  } catch {
9531
9531
  } finally {
@@ -9550,18 +9550,18 @@ function CatalogPickerField({
9550
9550
  var qe;
9551
9551
  return ((qe = Ye.data) == null ? void 0 : qe[0]) ?? { id: te };
9552
9552
  }).catch(() => ({ id: te })));
9553
- const Ue = (Y($e) ?? 0) + 1;
9554
- await ht($e, String(Ue), Le);
9553
+ const Qe = (Y($e) ?? 0) + 1;
9554
+ await ht($e, String(Qe), Le);
9555
9555
  }
9556
9556
  const cs = ee.length, Zt = Object.keys(a.copy_fields ?? {}), Ks = Object.keys(a.compute_fields ?? {}), Pt = (te, $e) => {
9557
- const Se = Y(te), Le = S[te], Ue = Le !== void 0 ? Le : Se && Se > 0 ? String(Se) : "";
9557
+ const Se = Y(te), Le = S[te], Qe = Le !== void 0 ? Le : Se && Se > 0 ? String(Se) : "";
9558
9558
  return /* @__PURE__ */ jsx(
9559
9559
  "input",
9560
9560
  {
9561
9561
  type: "number",
9562
9562
  min: 0,
9563
9563
  disabled: r,
9564
- value: Ue,
9564
+ value: Qe,
9565
9565
  placeholder: "0",
9566
9566
  onChange: (Ye) => f((qe) => ({ ...qe, [te]: Ye.target.value })),
9567
9567
  onBlur: (Ye) => {
@@ -9652,7 +9652,7 @@ function CatalogPickerField({
9652
9652
  !_.has("__favorites__") && ye.filter(
9653
9653
  (te) => !x.trim() || applyDisplayTemplate(q, te).toLowerCase().includes(x.trim().toLowerCase())
9654
9654
  ).map((te, $e) => {
9655
- const Se = String(te.id), Le = Y(Se), Ue = Z(Se);
9655
+ const Se = String(te.id), Le = Y(Se), Qe = Z(Se);
9656
9656
  return /* @__PURE__ */ jsxs(
9657
9657
  "div",
9658
9658
  {
@@ -9660,17 +9660,17 @@ function CatalogPickerField({
9660
9660
  "flex items-center gap-2 border-b border-slate-100 px-3 py-1 dark:border-border/50",
9661
9661
  $e % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
9662
9662
  (Le ?? 0) > 0 && "bg-[#00ceff0d]",
9663
- Ue && "bg-amber-50 dark:bg-amber-900/15"
9663
+ Qe && "bg-amber-50 dark:bg-amber-900/15"
9664
9664
  ),
9665
9665
  children: [
9666
9666
  de(Se),
9667
9667
  /* @__PURE__ */ jsx("span", { className: qt, children: applyDisplayTemplate(q, te) }),
9668
9668
  Xt(Se, te),
9669
- Ue && /* @__PURE__ */ jsx(
9669
+ Qe && /* @__PURE__ */ jsx(
9670
9670
  AlertTriangle,
9671
9671
  {
9672
9672
  className: "h-3.5 w-3.5 shrink-0 text-amber-500",
9673
- "aria-label": `${je} ${Ue.available} — ${Ue.qty} requested`
9673
+ "aria-label": `${je} ${Qe.available} — ${Qe.qty} requested`
9674
9674
  }
9675
9675
  ),
9676
9676
  y.has(Se) && /* @__PURE__ */ jsx(Loader2, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" }),
@@ -9683,7 +9683,7 @@ function CatalogPickerField({
9683
9683
  ] }),
9684
9684
  j.length === 0 && wt.map((te) => {
9685
9685
  const $e = _.has(te.name), Se = te.items.reduce(
9686
- (Le, Ue) => Le + ((Y(Ue.id) ?? 0) > 0 ? 1 : 0),
9686
+ (Le, Qe) => Le + ((Y(Qe.id) ?? 0) > 0 ? 1 : 0),
9687
9687
  0
9688
9688
  );
9689
9689
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
@@ -9692,8 +9692,8 @@ function CatalogPickerField({
9692
9692
  {
9693
9693
  type: "button",
9694
9694
  onClick: () => k((Le) => {
9695
- const Ue = new Set(Le);
9696
- return Ue.has(te.name) ? Ue.delete(te.name) : Ue.add(te.name), Ue;
9695
+ const Qe = new Set(Le);
9696
+ return Qe.has(te.name) ? Qe.delete(te.name) : Qe.add(te.name), Qe;
9697
9697
  }),
9698
9698
  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",
9699
9699
  children: [
@@ -9715,14 +9715,14 @@ function CatalogPickerField({
9715
9715
  ]
9716
9716
  }
9717
9717
  ),
9718
- !$e && te.items.map((Le, Ue) => {
9718
+ !$e && te.items.map((Le, Qe) => {
9719
9719
  const Ye = Y(Le.id), qe = Z(Le.id);
9720
9720
  return /* @__PURE__ */ jsxs(
9721
9721
  "div",
9722
9722
  {
9723
9723
  className: cn$1(
9724
9724
  "flex items-center gap-2 border-b border-slate-100 px-3 py-1 dark:border-border/50",
9725
- Ue % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
9725
+ Qe % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
9726
9726
  (Ye ?? 0) > 0 && "bg-[#00ceff0d]",
9727
9727
  qe && "bg-amber-50 dark:bg-amber-900/15"
9728
9728
  ),
@@ -9792,7 +9792,7 @@ function CatalogPickerField({
9792
9792
  ] })
9793
9793
  ] }),
9794
9794
  ee.length === 0 ? /* @__PURE__ */ jsx("p", { className: "px-3 py-4 text-center text-slate-400", children: "Nothing picked yet" }) : (() => {
9795
- const te = ut.filter((qe) => !qe.format), $e = te[0], Se = te.slice(1), Le = ut.filter((qe) => !!qe.format), Ue = (qe, St) => qe === !0 || qe === "true" ? "✓" : qe === !1 || qe === "false" || qe == null || qe === "" ? "—" : Tt(qe, St), Ye = (qe) => /* @__PURE__ */ jsx("span", { className: "w-20 shrink-0 text-right text-[11px] font-medium text-slate-500", children: qe });
9795
+ const te = ut.filter((qe) => !qe.format), $e = te[0], Se = te.slice(1), Le = ut.filter((qe) => !!qe.format), Qe = (qe, St) => qe === !0 || qe === "true" ? "✓" : qe === !1 || qe === "false" || qe == null || qe === "" ? "—" : Tt(qe, St), Ye = (qe) => /* @__PURE__ */ jsx("span", { className: "w-20 shrink-0 text-right text-[11px] font-medium text-slate-500", children: qe });
9796
9796
  return /* @__PURE__ */ jsxs("div", { children: [
9797
9797
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 border-b border-slate-200 px-3 py-1.5 dark:border-border", children: [
9798
9798
  /* @__PURE__ */ jsx("span", { className: "flex-1 text-[11px] font-medium text-slate-500", children: "Item" }),
@@ -9853,9 +9853,9 @@ function CatalogPickerField({
9853
9853
  min: 0,
9854
9854
  step: "any",
9855
9855
  defaultValue: qe.row[jt] == null ? "" : String(qe.row[jt]),
9856
- onBlur: (Ut) => void ds(qe.key, jt, Ut.target.value),
9857
- onKeyDown: (Ut) => {
9858
- Ut.key === "Enter" && Ut.currentTarget.blur();
9856
+ onBlur: (Qt) => void ds(qe.key, jt, Qt.target.value),
9857
+ onKeyDown: (Qt) => {
9858
+ Qt.key === "Enter" && Qt.currentTarget.blur();
9859
9859
  },
9860
9860
  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"
9861
9861
  },
@@ -9876,12 +9876,12 @@ function CatalogPickerField({
9876
9876
  ] }),
9877
9877
  Ks.map((jt) => {
9878
9878
  var es, ms;
9879
- const dt = qe.row[jt], Ut = dt != null && dt !== "" ? dt : evalClientFormula(((es = a.compute_fields) == null ? void 0 : es[jt]) ?? "", qe.row);
9879
+ const dt = qe.row[jt], Qt = dt != null && dt !== "" ? dt : evalClientFormula(((es = a.compute_fields) == null ? void 0 : es[jt]) ?? "", qe.row);
9880
9880
  return /* @__PURE__ */ jsx(
9881
9881
  "span",
9882
9882
  {
9883
9883
  className: "w-20 shrink-0 text-right tabular-nums text-slate-600 dark:text-slate-300",
9884
- children: Tt(Ut, (ms = a.field_formats) == null ? void 0 : ms[jt])
9884
+ children: Tt(Qt, (ms = a.field_formats) == null ? void 0 : ms[jt])
9885
9885
  },
9886
9886
  jt
9887
9887
  );
@@ -9916,19 +9916,19 @@ function CatalogPickerField({
9916
9916
  Le.map((jt) => /* @__PURE__ */ jsxs("span", { className: "whitespace-nowrap", children: [
9917
9917
  /* @__PURE__ */ jsx("span", { className: "text-slate-500 dark:text-muted-foreground", children: jt.label ?? titleCase$2(jt.field.split(".")[0]) }),
9918
9918
  " ",
9919
- /* @__PURE__ */ jsx("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: Ue(et(At(qe.key), jt.field), jt.format) })
9919
+ /* @__PURE__ */ jsx("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: Qe(et(At(qe.key), jt.field), jt.format) })
9920
9920
  ] }, jt.field)),
9921
9921
  Nt.map((jt) => /* @__PURE__ */ jsxs("span", { className: "whitespace-nowrap", children: [
9922
9922
  /* @__PURE__ */ jsx("span", { className: "text-slate-500 dark:text-muted-foreground", children: jt.label ?? titleCase$2(jt.key) }),
9923
9923
  " ",
9924
- /* @__PURE__ */ jsx("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: Ue(ue(jt.key, qe.key), jt.format) })
9924
+ /* @__PURE__ */ jsx("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: Qe(ue(jt.key, qe.key), jt.format) })
9925
9925
  ] }, jt.key)),
9926
9926
  Be.map((jt) => {
9927
9927
  const dt = Je(jt, qe);
9928
9928
  return /* @__PURE__ */ jsxs("span", { className: "whitespace-nowrap", children: [
9929
9929
  /* @__PURE__ */ jsx("span", { className: "text-slate-500 dark:text-muted-foreground", children: jt.label ?? titleCase$2(jt.field) }),
9930
9930
  " ",
9931
- /* @__PURE__ */ jsx("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: Ue(dt, jt.format) })
9931
+ /* @__PURE__ */ jsx("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: Qe(dt, jt.format) })
9932
9932
  ] }, jt.field);
9933
9933
  })
9934
9934
  ] }),
@@ -10474,14 +10474,14 @@ function FileM2MField({
10474
10474
  }) {
10475
10475
  const i = useNivaroClient(), o = useQueryClient(), d = useGridFlush(), c = useId(), p = useId(), m = useM2MStaging(), [h, _] = useState(!1), [k, w] = useState(!1), [x, u] = useState([]), S = useRef(null), [f, y] = useState([]), [v, N] = useState(/* @__PURE__ */ new Set()), C = e.junction_field ?? "", F = e.many_field ?? "", q = e.one_field ?? `${e.many_collection}.${C}`, g = t === "new", b = (z) => i.fileUrl(z);
10476
10476
  useEffect(() => () => {
10477
- u((z) => (z.forEach((U) => URL.revokeObjectURL(U.url)), []));
10477
+ u((z) => (z.forEach((Q) => URL.revokeObjectURL(Q.url)), []));
10478
10478
  }, []), useEffect(() => {
10479
10479
  if (!d || !x.length || l) return;
10480
10480
  const z = x;
10481
10481
  return d.register(c, async () => {
10482
- for (const U of z) {
10483
- const ee = await i.upload(U.file);
10484
- URL.revokeObjectURL(U.url), await K(ee.id);
10482
+ for (const Q of z) {
10483
+ const ee = await i.upload(Q.file);
10484
+ URL.revokeObjectURL(Q.url), await K(ee.id);
10485
10485
  }
10486
10486
  u([]), o.invalidateQueries({ queryKey: ["file-browser"] });
10487
10487
  }), () => d.unregister(c);
@@ -10491,14 +10491,14 @@ function FileM2MField({
10491
10491
  d.unregister(p);
10492
10492
  return;
10493
10493
  }
10494
- const U = f, ee = new Set(v), le = x;
10494
+ const Q = f, ee = new Set(v), le = x;
10495
10495
  return d.register(p, async () => {
10496
10496
  const J = [];
10497
10497
  for (const V of le) {
10498
10498
  const oe = await i.upload(V.file);
10499
10499
  URL.revokeObjectURL(V.url), J.push(oe.id);
10500
10500
  }
10501
- for (const V of [...U, ...J])
10501
+ for (const V of [...Q, ...J])
10502
10502
  await i.request(
10503
10503
  post$1(`/items/${e.many_collection}`, { [F]: t, [C]: V })
10504
10504
  );
@@ -10530,9 +10530,9 @@ function FileM2MField({
10530
10530
  limit: String(I.length),
10531
10531
  fields: "id,filename_download,title,type,filesize,uploaded_on,uploaded_by_name"
10532
10532
  })
10533
- ).then((ee) => ee.data ?? []), U = {};
10534
- for (const ee of z) U[ee.id] = ee;
10535
- return U;
10533
+ ).then((ee) => ee.data ?? []), Q = {};
10534
+ for (const ee of z) Q[ee.id] = ee;
10535
+ return Q;
10536
10536
  },
10537
10537
  enabled: I.length > 0,
10538
10538
  staleTime: 6e4
@@ -10546,8 +10546,8 @@ function FileM2MField({
10546
10546
  f.includes(z) ? y((ee) => ee.filter((le) => le !== z)) : N((ee) => /* @__PURE__ */ new Set([...ee, z]));
10547
10547
  return;
10548
10548
  }
10549
- const U = j.find((ee) => String(ee[C]) === z);
10550
- U != null && U.id && (await i.request(del$1(`/items/${e.many_collection}/${U.id}`)), o.invalidateQueries({ queryKey: ["m2m-items", e.many_collection, F, t] }));
10549
+ const Q = j.find((ee) => String(ee[C]) === z);
10550
+ Q != null && Q.id && (await i.request(del$1(`/items/${e.many_collection}/${Q.id}`)), o.invalidateQueries({ queryKey: ["m2m-items", e.many_collection, F, t] }));
10551
10551
  }
10552
10552
  async function K(z) {
10553
10553
  if (!I.includes(z)) {
@@ -10556,7 +10556,7 @@ function FileM2MField({
10556
10556
  return;
10557
10557
  }
10558
10558
  if (l) {
10559
- y((U) => U.includes(z) ? U : [...U, z]);
10559
+ y((Q) => Q.includes(z) ? Q : [...Q, z]);
10560
10560
  return;
10561
10561
  }
10562
10562
  await i.request(
@@ -10564,19 +10564,19 @@ function FileM2MField({
10564
10564
  ), o.invalidateQueries({ queryKey: ["m2m-items", e.many_collection, F, t] });
10565
10565
  }
10566
10566
  }
10567
- function Q(z) {
10568
- URL.revokeObjectURL(z), u((U) => U.filter((ee) => ee.url !== z));
10567
+ function U(z) {
10568
+ URL.revokeObjectURL(z), u((Q) => Q.filter((ee) => ee.url !== z));
10569
10569
  }
10570
10570
  async function ie(z) {
10571
- const U = Array.from(z.target.files ?? []);
10572
- if (U.length)
10571
+ const Q = Array.from(z.target.files ?? []);
10572
+ if (Q.length)
10573
10573
  if (S.current && (S.current.value = ""), d) {
10574
- const ee = U.map((le) => ({ file: le, url: URL.createObjectURL(le) }));
10574
+ const ee = Q.map((le) => ({ file: le, url: URL.createObjectURL(le) }));
10575
10575
  u((le) => [...le, ...ee]);
10576
10576
  } else {
10577
10577
  w(!0);
10578
10578
  try {
10579
- for (const ee of U) {
10579
+ for (const ee of Q) {
10580
10580
  const le = await i.upload(ee);
10581
10581
  await K(le.id);
10582
10582
  }
@@ -10590,26 +10590,26 @@ function FileM2MField({
10590
10590
  return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
10591
10591
  (I.length > 0 || x.length > 0) && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
10592
10592
  I.map((z) => {
10593
- const U = M[z];
10593
+ const Q = M[z];
10594
10594
  return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 rounded-lg border border-slate-200 p-2 bg-slate-50", children: [
10595
10595
  /* @__PURE__ */ jsx(
10596
10596
  FileThumb,
10597
10597
  {
10598
10598
  url: b(z),
10599
- type: (U == null ? void 0 : U.type) ?? null,
10600
- filename: (U == null ? void 0 : U.filename_download) ?? z,
10599
+ type: (Q == null ? void 0 : Q.type) ?? null,
10600
+ filename: (Q == null ? void 0 : Q.filename_download) ?? z,
10601
10601
  size: "sm"
10602
10602
  }
10603
10603
  ),
10604
10604
  /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
10605
- /* @__PURE__ */ jsx("p", { className: "text-[12px] font-medium text-slate-700 truncate", children: (U == null ? void 0 : U.title) || (U == null ? void 0 : U.filename_download) || z }),
10605
+ /* @__PURE__ */ jsx("p", { className: "text-[12px] font-medium text-slate-700 truncate", children: (Q == null ? void 0 : Q.title) || (Q == null ? void 0 : Q.filename_download) || z }),
10606
10606
  /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-x-2 mt-0.5", children: [
10607
- (U == null ? void 0 : U.type) && /* @__PURE__ */ jsx("span", { className: "text-[10px] text-slate-400", children: U.type }),
10608
- (U == null ? void 0 : U.filesize) != null && /* @__PURE__ */ jsx("span", { className: "text-[10px] text-slate-400", children: fmtSize(U.filesize) }),
10609
- (U == null ? void 0 : U.uploaded_on) && /* @__PURE__ */ jsx("span", { className: "text-[10px] text-slate-400", children: fmtDate$2(U.uploaded_on) }),
10610
- (U == null ? void 0 : U.uploaded_by_name) && /* @__PURE__ */ jsxs("span", { className: "text-[10px] text-slate-500", children: [
10607
+ (Q == null ? void 0 : Q.type) && /* @__PURE__ */ jsx("span", { className: "text-[10px] text-slate-400", children: Q.type }),
10608
+ (Q == null ? void 0 : Q.filesize) != null && /* @__PURE__ */ jsx("span", { className: "text-[10px] text-slate-400", children: fmtSize(Q.filesize) }),
10609
+ (Q == null ? void 0 : Q.uploaded_on) && /* @__PURE__ */ jsx("span", { className: "text-[10px] text-slate-400", children: fmtDate$2(Q.uploaded_on) }),
10610
+ (Q == null ? void 0 : Q.uploaded_by_name) && /* @__PURE__ */ jsxs("span", { className: "text-[10px] text-slate-500", children: [
10611
10611
  "by ",
10612
- U.uploaded_by_name
10612
+ Q.uploaded_by_name
10613
10613
  ] })
10614
10614
  ] })
10615
10615
  ] }),
@@ -10658,7 +10658,7 @@ function FileM2MField({
10658
10658
  "button",
10659
10659
  {
10660
10660
  type: "button",
10661
- onClick: () => Q(z.url),
10661
+ onClick: () => U(z.url),
10662
10662
  className: "text-slate-300 hover:text-red-400 p-0.5 shrink-0",
10663
10663
  children: /* @__PURE__ */ jsx(X, { className: "h-3.5 w-3.5" })
10664
10664
  }
@@ -10735,7 +10735,7 @@ function InlineGridField$1({
10735
10735
  layoutSlug: n,
10736
10736
  parentFieldKey: a
10737
10737
  }) {
10738
- var U;
10738
+ var Q;
10739
10739
  const r = useNivaroClient(), l = useQueryClient(), i = useO2MStaging(), o = s === "new", d = useAddendumO2M()[a ?? ""] ?? [], [c, p] = useState(null), [m, h] = useState({}), [_, k] = useState(!1), [w, x] = useState({}), [u, S] = useState(!1), f = useAddendumView(), { data: y } = useQuery({
10740
10740
  queryKey: ["active-layout", e, n ?? null],
10741
10741
  queryFn: () => r.request(
@@ -10746,7 +10746,7 @@ function InlineGridField$1({
10746
10746
  ).then((ee) => ee.data).catch(() => null),
10747
10747
  staleTime: 6e4,
10748
10748
  enabled: !!n
10749
- }), v = n ? ((U = y == null ? void 0 : y.layout) == null ? void 0 : U.id) ?? null : null, { data: N = [] } = useQuery({
10749
+ }), v = n ? ((Q = y == null ? void 0 : y.layout) == null ? void 0 : Q.id) ?? null : null, { data: N = [] } = useQuery({
10750
10750
  queryKey: ["field-config", e, v],
10751
10751
  queryFn: () => r.request(
10752
10752
  get$1(`/field-config/${e}`, v ? { layout_id: String(v) } : void 0)
@@ -10907,7 +10907,7 @@ function InlineGridField$1({
10907
10907
  ] })
10908
10908
  ] });
10909
10909
  }
10910
- function Q(ee, le) {
10910
+ function U(ee, le) {
10911
10911
  return g.map((J) => /* @__PURE__ */ jsx("td", { className: "px-3 py-1.5", children: E(J, ee, le) }, J.field));
10912
10912
  }
10913
10913
  if (!o && F)
@@ -11015,7 +11015,7 @@ function InlineGridField$1({
11015
11015
  })(),
11016
11016
  f === "original" && _ && !z && /* @__PURE__ */ jsxs("tr", { className: "border-b border-slate-100 bg-nvr-cyan/5", children: [
11017
11017
  o && /* @__PURE__ */ jsx("td", { className: "px-3 py-1.5" }),
11018
- Q(w, (ee, le) => x((J) => ({ ...J, [ee]: le }))),
11018
+ U(w, (ee, le) => x((J) => ({ ...J, [ee]: le }))),
11019
11019
  /* @__PURE__ */ jsx("td", { className: "px-2 py-1.5", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 justify-end", children: [
11020
11020
  /* @__PURE__ */ jsx(
11021
11021
  "button",
@@ -11140,10 +11140,10 @@ function M2MCombobox({
11140
11140
  ).then((J) => J.data ?? []),
11141
11141
  enabled: !!w && I.length > 0,
11142
11142
  staleTime: 3e4
11143
- }), K = new Set((E ?? []).map((J) => String(J.id))), Q = E !== void 0 ? new Set(I.filter((J) => !K.has(J))) : /* @__PURE__ */ new Set(), ie = new Set(b.map(String)), z = /* @__PURE__ */ new Set([...A, ...ie]), U = useRef(l);
11144
- U.current = l, useEffect(() => {
11143
+ }), K = new Set((E ?? []).map((J) => String(J.id))), U = E !== void 0 ? new Set(I.filter((J) => !K.has(J))) : /* @__PURE__ */ new Set(), ie = new Set(b.map(String)), z = /* @__PURE__ */ new Set([...A, ...ie]), Q = useRef(l);
11144
+ Q.current = l, useEffect(() => {
11145
11145
  var J;
11146
- (J = U.current) == null || J.call(U, z.size);
11146
+ (J = Q.current) == null || J.call(Q, z.size);
11147
11147
  }, [z.size]);
11148
11148
  function ee(J) {
11149
11149
  const V = String(J);
@@ -11204,7 +11204,7 @@ function M2MCombobox({
11204
11204
  },
11205
11205
  children: [
11206
11206
  L.map((J) => {
11207
- const V = J[x], oe = Q.has(String(V));
11207
+ const V = J[x], oe = U.has(String(V));
11208
11208
  return /* @__PURE__ */ jsxs(
11209
11209
  "span",
11210
11210
  {
@@ -11383,7 +11383,7 @@ function M2MSingleSelectCombobox({
11383
11383
  var ae;
11384
11384
  (ae = K.current) == null || ae.call(K, M != null ? 1 : 0);
11385
11385
  }, [M]);
11386
- const { data: Q } = useQuery({
11386
+ const { data: U } = useQuery({
11387
11387
  queryKey: ["relation-single", k, String(M)],
11388
11388
  queryFn: () => o.request(
11389
11389
  get$1(`/items/${k}/${M}`)
@@ -11400,13 +11400,13 @@ function M2MSingleSelectCombobox({
11400
11400
  fields: "id"
11401
11401
  })
11402
11402
  ).then((ae) => ae.data ?? []),
11403
- enabled: !!k && M != null && !!Q,
11403
+ enabled: !!k && M != null && !!U,
11404
11404
  staleTime: 3e4
11405
- }), U = z !== void 0 && z.length === 0, ee = useStaleTip(U), le = (S == null ? void 0 : S.display_template) ?? null;
11405
+ }), Q = z !== void 0 && z.length === 0, ee = useStaleTip(Q), le = (S == null ? void 0 : S.display_template) ?? null;
11406
11406
  function J(ae) {
11407
11407
  return le ? le.replace(/\{\{([^}]+)\}\}/g, (B, ue) => String(ae[ue.trim()] ?? "")) : String(ae.name ?? ae.title ?? ae.label ?? ae.id ?? "");
11408
11408
  }
11409
- const V = q.find((ae) => String(ae.id) === String(M)) ?? Q, oe = M != null && !Q && !V, ye = V ? J(V) : null;
11409
+ const V = q.find((ae) => String(ae.id) === String(M)) ?? U, oe = M != null && !U && !V, ye = V ? J(V) : null;
11410
11410
  if (i)
11411
11411
  return /* @__PURE__ */ jsx("span", { className: "block truncate text-[12px] text-slate-700", children: oe ? "…" : ye ?? "—" });
11412
11412
  function he(ae) {
@@ -11447,7 +11447,7 @@ function M2MSingleSelectCombobox({
11447
11447
  type: "button",
11448
11448
  className: cn$1(
11449
11449
  "w-full h-9 px-3 text-[12px] border rounded-md bg-white text-left flex items-center justify-between hover:bg-slate-50 cursor-pointer transition-colors disabled:pointer-events-none disabled:opacity-50",
11450
- U ? "border-amber-300 dark:border-amber-600" : E ? "border-nvr-cyan/50" : "border-slate-200"
11450
+ Q ? "border-amber-300 dark:border-amber-600" : E ? "border-nvr-cyan/50" : "border-slate-200"
11451
11451
  ),
11452
11452
  children: [
11453
11453
  oe || y && I == null && t !== "new" ? /* @__PURE__ */ jsx(Loader2, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground" }) : /* @__PURE__ */ jsxs(
@@ -11458,7 +11458,7 @@ function M2MSingleSelectCombobox({
11458
11458
  ye ? E ? "text-nvr-cyan" : "text-slate-800" : "text-muted-foreground"
11459
11459
  ),
11460
11460
  children: [
11461
- U && /* @__PURE__ */ jsx(AlertTriangle, { className: "h-3.5 w-3.5 shrink-0 text-amber-500" }),
11461
+ Q && /* @__PURE__ */ jsx(AlertTriangle, { className: "h-3.5 w-3.5 shrink-0 text-amber-500" }),
11462
11462
  /* @__PURE__ */ jsx("span", { className: "truncate", children: ye ?? "Select…" })
11463
11463
  ]
11464
11464
  }
@@ -11647,8 +11647,8 @@ function RelationGroupedCombobox({
11647
11647
  }, 30) : (m(""), _(/* @__PURE__ */ new Set()));
11648
11648
  }, [d]), useEffect(() => {
11649
11649
  if (!d) return;
11650
- const z = (U) => {
11651
- w.current && !w.current.contains(U.target) && c(!1);
11650
+ const z = (Q) => {
11651
+ w.current && !w.current.contains(Q.target) && c(!1);
11652
11652
  };
11653
11653
  return document.addEventListener("mousedown", z), () => document.removeEventListener("mousedown", z);
11654
11654
  }, [d]);
@@ -11660,13 +11660,13 @@ function RelationGroupedCombobox({
11660
11660
  }), u = useMemo(
11661
11661
  () => {
11662
11662
  var z;
11663
- return ((z = ((x == null ? void 0 : x.relations) ?? []).find((U) => U.many_field === n && !U.junction_field)) == null ? void 0 : z.one_collection) ?? null;
11663
+ return ((z = ((x == null ? void 0 : x.relations) ?? []).find((Q) => Q.many_field === n && !Q.junction_field)) == null ? void 0 : z.one_collection) ?? null;
11664
11664
  },
11665
11665
  [x, n]
11666
11666
  ), S = useMemo(
11667
11667
  () => {
11668
11668
  var z;
11669
- return ((z = ((x == null ? void 0 : x.relations) ?? []).find((U) => U.many_field === a && !U.junction_field)) == null ? void 0 : z.one_collection) ?? null;
11669
+ return ((z = ((x == null ? void 0 : x.relations) ?? []).find((Q) => Q.many_field === a && !Q.junction_field)) == null ? void 0 : z.one_collection) ?? null;
11670
11670
  },
11671
11671
  [x, a]
11672
11672
  ), { data: f } = useQuery({
@@ -11699,10 +11699,10 @@ function RelationGroupedCombobox({
11699
11699
  enabled: !!t && !!q,
11700
11700
  staleTime: 3e4
11701
11701
  }), L = !!t && j !== void 0 && j.length === 0, A = f == null ? void 0 : f.display_template, I = y == null ? void 0 : y.display_template, M = useMemo(() => {
11702
- const z = C ?? [], U = p.toLowerCase(), ee = /* @__PURE__ */ new Map();
11702
+ const z = C ?? [], Q = p.toLowerCase(), ee = /* @__PURE__ */ new Map();
11703
11703
  for (const le of z) {
11704
11704
  const J = le[n], V = le[a], oe = J ? String(J.id ?? "") : "__none__", ye = J ? applyDisplayTemplate(A, J) : "—", he = V ? applyDisplayTemplate(I, V) : String(le.id ?? "");
11705
- U && !ye.toLowerCase().includes(U) && !he.toLowerCase().includes(U) || (ee.has(oe) || ee.set(oe, { label: ye, items: [] }), ee.get(oe).items.push(le));
11705
+ Q && !ye.toLowerCase().includes(Q) && !he.toLowerCase().includes(Q) || (ee.has(oe) || ee.set(oe, { label: ye, items: [] }), ee.get(oe).items.push(le));
11706
11706
  }
11707
11707
  return [...ee.entries()].map(([le, J]) => ({ id: le, label: J.label, items: J.items }));
11708
11708
  }, [C, p, n, a, A, I]);
@@ -11710,17 +11710,17 @@ function RelationGroupedCombobox({
11710
11710
  p && _(new Set(M.map((z) => z.id)));
11711
11711
  }, [p, M]);
11712
11712
  function E(z) {
11713
- _((U) => {
11714
- const ee = new Set(U);
11713
+ _((Q) => {
11714
+ const ee = new Set(Q);
11715
11715
  return ee.has(z) ? ee.delete(z) : ee.add(z), ee;
11716
11716
  });
11717
11717
  }
11718
11718
  let K = null;
11719
11719
  if (q) {
11720
- const z = q[n], U = q[a], ee = z ? applyDisplayTemplate(A, z) : null, le = U ? applyDisplayTemplate(I, U) : null;
11720
+ const z = q[n], Q = q[a], ee = z ? applyDisplayTemplate(A, z) : null, le = Q ? applyDisplayTemplate(I, Q) : null;
11721
11721
  K = [ee, le].filter(Boolean).join(" — ") || null;
11722
11722
  }
11723
- const Q = !!t && g && !q, ie = useStaleTip(L);
11723
+ const U = !!t && g && !q, ie = useStaleTip(L);
11724
11724
  return /* @__PURE__ */ jsxs("div", { ref: w, className: "relative", ...ie.bind, children: [
11725
11725
  /* @__PURE__ */ jsxs(
11726
11726
  "button",
@@ -11733,7 +11733,7 @@ function RelationGroupedCombobox({
11733
11733
  L ? "border-amber-300 dark:border-amber-600" : "border-input"
11734
11734
  ),
11735
11735
  children: [
11736
- Q ? /* @__PURE__ */ jsx(Loader2, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground" }) : /* @__PURE__ */ jsxs("span", { className: cn$1("flex items-center gap-1.5 truncate min-w-0", !K && "text-muted-foreground"), children: [
11736
+ U ? /* @__PURE__ */ jsx(Loader2, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground" }) : /* @__PURE__ */ jsxs("span", { className: cn$1("flex items-center gap-1.5 truncate min-w-0", !K && "text-muted-foreground"), children: [
11737
11737
  L && /* @__PURE__ */ jsx(AlertTriangle, { className: "h-3.5 w-3.5 shrink-0 text-amber-500" }),
11738
11738
  /* @__PURE__ */ jsx("span", { className: "truncate", children: K ?? l ?? "Select…" })
11739
11739
  ] }),
@@ -11772,7 +11772,7 @@ function RelationGroupedCombobox({
11772
11772
  }
11773
11773
  ),
11774
11774
  F ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : M.length === 0 ? /* @__PURE__ */ jsx("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children: "No results" }) : M.map((z) => {
11775
- const U = h.has(z.id);
11775
+ const Q = h.has(z.id);
11776
11776
  return /* @__PURE__ */ jsxs("div", { children: [
11777
11777
  /* @__PURE__ */ jsxs(
11778
11778
  "button",
@@ -11781,13 +11781,13 @@ function RelationGroupedCombobox({
11781
11781
  onClick: () => E(z.id),
11782
11782
  className: "flex w-full items-center gap-1.5 px-3 py-1.5 text-[11px] font-semibold uppercase tracking-wide text-slate-500 hover:bg-slate-50",
11783
11783
  children: [
11784
- U ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3 shrink-0" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 shrink-0" }),
11784
+ Q ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3 shrink-0" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 shrink-0" }),
11785
11785
  z.label,
11786
11786
  /* @__PURE__ */ jsx("span", { className: "ml-auto font-normal normal-case tracking-normal text-slate-400", children: z.items.length })
11787
11787
  ]
11788
11788
  }
11789
11789
  ),
11790
- U && z.items.map((ee) => {
11790
+ Q && z.items.map((ee) => {
11791
11791
  const le = ee[a], J = le ? applyDisplayTemplate(I, le) : String(ee.id ?? ""), V = String(ee.id) === String(t);
11792
11792
  return /* @__PURE__ */ jsxs(
11793
11793
  "button",
@@ -12415,7 +12415,7 @@ function FieldRenderer({
12415
12415
  } catch {
12416
12416
  return {};
12417
12417
  }
12418
- })() : e.options ?? {}, C = N.layout_id ?? null, F = !!N.show_row_revisions, q = N.allow_revision_restore !== !1, g = N.save_mode ?? "immediate", b = !!N.show_line_numbers, j = N.enable_reorder !== !1, L = Array.isArray(N.parent_cascades) ? N.parent_cascades : void 0, A = Array.isArray(N.row_rules) ? N.row_rules : void 0, I = Array.isArray(N.column_presets) ? N.column_presets : void 0, M = typeof N.default_preset == "string" && N.default_preset ? N.default_preset : void 0, E = Array.isArray(N.drawer_relations) ? N.drawer_relations : void 0, K = Array.isArray(N.parent_context_fields) ? N.parent_context_fields : void 0, Q = Array.isArray(N.unique_by) ? N.unique_by : void 0, ie = typeof N.sort_field == "string" && N.sort_field ? N.sort_field : void 0, z = N.sort_dir === "desc" ? "desc" : "asc", U = typeof N.section_group_by == "string" && N.section_group_by.includes(".") ? N.section_group_by : void 0, ee = N.row_filter && typeof N.row_filter == "object" ? N.row_filter : void 0, le = N.allocate_drawer && typeof N.allocate_drawer == "object" ? N.allocate_drawer : void 0, J = N.auto_allocate && typeof N.auto_allocate == "object" ? N.auto_allocate : void 0, V = Array.isArray(N.row_bulk_actions) ? N.row_bulk_actions : void 0, oe = typeof N.upload_template == "string" && N.upload_template ? N.upload_template : void 0, ye = N.row_defaults && typeof N.row_defaults == "object" ? N.row_defaults : void 0, he = N.submission_errors === !0 ? {} : N.submission_errors && typeof N.submission_errors == "object" ? N.submission_errors : void 0, de = N.catalog_mode;
12418
+ })() : e.options ?? {}, C = N.layout_id ?? null, F = !!N.show_row_revisions, q = N.allow_revision_restore !== !1, g = N.save_mode ?? "immediate", b = !!N.show_line_numbers, j = N.enable_reorder !== !1, L = Array.isArray(N.parent_cascades) ? N.parent_cascades : void 0, A = Array.isArray(N.row_rules) ? N.row_rules : void 0, I = Array.isArray(N.column_presets) ? N.column_presets : void 0, M = typeof N.default_preset == "string" && N.default_preset ? N.default_preset : void 0, E = Array.isArray(N.drawer_relations) ? N.drawer_relations : void 0, K = Array.isArray(N.parent_context_fields) ? N.parent_context_fields : void 0, U = Array.isArray(N.unique_by) ? N.unique_by : void 0, ie = typeof N.sort_field == "string" && N.sort_field ? N.sort_field : void 0, z = N.sort_dir === "desc" ? "desc" : "asc", Q = typeof N.section_group_by == "string" && N.section_group_by.includes(".") ? N.section_group_by : void 0, ee = N.row_filter && typeof N.row_filter == "object" ? N.row_filter : void 0, le = N.allocate_drawer && typeof N.allocate_drawer == "object" ? N.allocate_drawer : void 0, J = N.auto_allocate && typeof N.auto_allocate == "object" ? N.auto_allocate : void 0, V = Array.isArray(N.row_bulk_actions) ? N.row_bulk_actions : void 0, oe = typeof N.upload_template == "string" && N.upload_template ? N.upload_template : void 0, ye = N.row_defaults && typeof N.row_defaults == "object" ? N.row_defaults : void 0, he = N.submission_errors === !0 ? {} : N.submission_errors && typeof N.submission_errors == "object" ? N.submission_errors : void 0, de = N.catalog_mode;
12419
12419
  return de != null && de.item_field && (de != null && de.section_by) ? /* @__PURE__ */ jsx(
12420
12420
  CatalogPickerField,
12421
12421
  {
@@ -12426,7 +12426,7 @@ function FieldRenderer({
12426
12426
  config: de,
12427
12427
  readOnly: e.readonly
12428
12428
  }
12429
- ) : /* @__PURE__ */ jsx(InlineTableField, { relatedCollection: y, manyField: v, parentId: r, parentCollection: a, layoutId: C, showRowRevisions: F, allowRevisionRestore: q, saveMode: g, showLineNumbers: b, enableReorder: j, parentCascades: L, rowRules: A, columnPresets: I, defaultPreset: M, drawerRelations: E, parentContextFields: K, uniqueBy: Q, sortField: ie, sortDir: z, sectionGroupBy: U, rowFilter: ee, rowDefaults: ye, allocateDrawer: le, autoAllocate: J, rowBulkActions: V, uploadTemplate: oe, submissionErrors: he, prefillParentId: c, parentFieldKey: e.field, readOnly: e.readonly });
12429
+ ) : /* @__PURE__ */ jsx(InlineTableField, { relatedCollection: y, manyField: v, parentId: r, parentCollection: a, layoutId: C, showRowRevisions: F, allowRevisionRestore: q, saveMode: g, showLineNumbers: b, enableReorder: j, parentCascades: L, rowRules: A, columnPresets: I, defaultPreset: M, drawerRelations: E, parentContextFields: K, uniqueBy: U, sortField: ie, sortDir: z, sectionGroupBy: Q, rowFilter: ee, rowDefaults: ye, allocateDrawer: le, autoAllocate: J, rowBulkActions: V, uploadTemplate: oe, submissionErrors: he, prefillParentId: c, parentFieldKey: e.field, readOnly: e.readonly });
12430
12430
  }
12431
12431
  }
12432
12432
  return /* @__PURE__ */ jsx("p", { className: "text-[12px] text-slate-400 py-1", children: "Inline table editing not available in embedded form" });
@@ -13517,18 +13517,18 @@ function AddendumCreateSheet({
13517
13517
  return K.splice(A, 1), M.set(E, K), M;
13518
13518
  }),
13519
13519
  updateRow: (j, L, A, I) => y((M) => {
13520
- const E = new Map(M), K = `${j}.${L}`, Q = [...E.get(K) ?? []];
13521
- return Q[A] = { ...Q[A], ...I }, E.set(K, Q), E;
13520
+ const E = new Map(M), K = `${j}.${L}`, U = [...E.get(K) ?? []];
13521
+ return U[A] = { ...U[A], ...I }, E.set(K, U), E;
13522
13522
  }),
13523
13523
  reorderRows: (j, L, A, I) => y((M) => {
13524
- const E = new Map(M), K = `${j}.${L}`, Q = [...E.get(K) ?? []], [ie] = Q.splice(A, 1);
13525
- return Q.splice(I, 0, ie), E.set(K, Q), E;
13524
+ const E = new Map(M), K = `${j}.${L}`, U = [...E.get(K) ?? []], [ie] = U.splice(A, 1);
13525
+ return U.splice(I, 0, ie), E.set(K, U), E;
13526
13526
  }),
13527
13527
  getPendingEdits: (j, L) => v.get(`${j}.${L}`) ?? /* @__PURE__ */ new Map(),
13528
13528
  getPendingDeletes: (j, L) => C.get(`${j}.${L}`) ?? /* @__PURE__ */ new Set(),
13529
13529
  queueEdit: (j, L, A, I) => N((M) => {
13530
- const E = new Map(M), K = `${j}.${L}`, Q = new Map(E.get(K) ?? []);
13531
- return Q.set(A, { ...Q.get(A) ?? {}, ...I }), E.set(K, Q), E;
13530
+ const E = new Map(M), K = `${j}.${L}`, U = new Map(E.get(K) ?? []);
13531
+ return U.set(A, { ...U.get(A) ?? {}, ...I }), E.set(K, U), E;
13532
13532
  }),
13533
13533
  queueDelete: (j, L, A) => F((I) => {
13534
13534
  const M = new Map(I), E = `${j}.${L}`;
@@ -15222,7 +15222,7 @@ function TransitionRequirementsDialog({
15222
15222
  const A = rowKey(b.collection, L.id), I = j.optional_when;
15223
15223
  if (I) {
15224
15224
  const M = (g = q[A]) == null ? void 0 : g[I.field], E = new Set(I.in.map(String));
15225
- if ((Array.isArray(M) ? M : [M]).some((Q) => Q != null && Q !== "" && E.has(String(Q)))) continue;
15225
+ if ((Array.isArray(M) ? M : [M]).some((U) => U != null && U !== "" && E.has(String(U)))) continue;
15226
15226
  }
15227
15227
  q[A] = { ...q[A], [C]: N };
15228
15228
  }
@@ -15276,8 +15276,8 @@ function TransitionRequirementsDialog({
15276
15276
  const g = rowKey(F.collection, q.id), b = i[g] ?? {}, j = d.current[g] ?? {}, L = {}, A = [];
15277
15277
  for (const I of F.fields) {
15278
15278
  if (I.kind === "m2m") {
15279
- const M = Array.isArray(b[I.field]) ? b[I.field] : [], E = Array.isArray(j[I.field]) ? j[I.field] : [], K = M.filter((ie) => !E.includes(ie)), Q = E.filter((ie) => !M.includes(ie));
15280
- (K.length > 0 || Q.length > 0) && A.push({ meta: I, add: K, remove: Q });
15279
+ const M = Array.isArray(b[I.field]) ? b[I.field] : [], E = Array.isArray(j[I.field]) ? j[I.field] : [], K = M.filter((ie) => !E.includes(ie)), U = E.filter((ie) => !M.includes(ie));
15280
+ (K.length > 0 || U.length > 0) && A.push({ meta: I, add: K, remove: U });
15281
15281
  continue;
15282
15282
  }
15283
15283
  w(g, I) || b[I.field] !== j[I.field] && (L[I.field] = coerceForPatch(String(b[I.field] ?? ""), I.type));
@@ -15295,8 +15295,8 @@ function TransitionRequirementsDialog({
15295
15295
  filter: JSON.stringify({ [I.fk_to_child]: { _eq: q.id } })
15296
15296
  })
15297
15297
  );
15298
- for (const Q of K.data ?? [])
15299
- E.includes(String(Q[I.junction_field])) && await r.request(del$1(`/items/${I.junction}/${Q.id}`));
15298
+ for (const U of K.data ?? [])
15299
+ E.includes(String(U[I.junction_field])) && await r.request(del$1(`/items/${I.junction}/${U.id}`));
15300
15300
  }
15301
15301
  for (const K of M)
15302
15302
  await r.request(
@@ -16241,7 +16241,7 @@ function PipelinePanelInner({
16241
16241
  /* @__PURE__ */ jsx(Skeleton, { className: "ml-auto h-3.5 w-3.5 rounded" })
16242
16242
  ] }) });
16243
16243
  if (!(N != null && N.binding)) return null;
16244
- const { instance: j, available_transitions: L, history: A, states: I } = N, M = new Map((I ?? []).map((J) => [J.id, J])), E = (j == null ? void 0 : j.current_state_obj) ?? null, K = m ? (L ?? []).find((J) => J.id === m) : null, Q = K ? M.get(K.to_state) : null, ie = !(j != null && j.completed_at) && L && L.length > 0, z = (J, V = !1) => {
16244
+ const { instance: j, available_transitions: L, history: A, states: I } = N, M = new Map((I ?? []).map((J) => [J.id, J])), E = (j == null ? void 0 : j.current_state_obj) ?? null, K = m ? (L ?? []).find((J) => J.id === m) : null, U = K ? M.get(K.to_state) : null, ie = !(j != null && j.completed_at) && L && L.length > 0, z = (J, V = !1) => {
16245
16245
  const oe = /* @__PURE__ */ new Map();
16246
16246
  for (const ye of J) {
16247
16247
  const he = oe.get(ye.label) ?? [];
@@ -16299,14 +16299,14 @@ function PipelinePanelInner({
16299
16299
  }) })
16300
16300
  ] }, ye);
16301
16301
  });
16302
- }, U = /* @__PURE__ */ jsxs("div", { className: "space-y-3 rounded-lg border border-slate-200 bg-slate-50 dark:bg-slate-900/30 dark:border-border p-3.5", children: [
16302
+ }, Q = /* @__PURE__ */ jsxs("div", { className: "space-y-3 rounded-lg border border-slate-200 bg-slate-50 dark:bg-slate-900/30 dark:border-border p-3.5", children: [
16303
16303
  /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
16304
16304
  /* @__PURE__ */ jsx("span", { className: "text-[11px] font-semibold text-slate-400", children: "Confirming" }),
16305
16305
  K && /* @__PURE__ */ jsx("span", { className: "text-[12px] font-medium text-slate-700", children: K.label }),
16306
- E && Q && /* @__PURE__ */ jsxs("div", { className: "ml-auto flex items-center gap-1.5", children: [
16306
+ E && U && /* @__PURE__ */ jsxs("div", { className: "ml-auto flex items-center gap-1.5", children: [
16307
16307
  /* @__PURE__ */ jsx(StateBadge$2, { label: E.label, color: E.color, small: !0 }),
16308
16308
  /* @__PURE__ */ jsx(ArrowRight, { className: "h-3 w-3 shrink-0 text-slate-300" }),
16309
- /* @__PURE__ */ jsx(StateBadge$2, { label: Q.label, color: Q.color, small: !0 })
16309
+ /* @__PURE__ */ jsx(StateBadge$2, { label: U.label, color: U.color, small: !0 })
16310
16310
  ] })
16311
16311
  ] }),
16312
16312
  /* @__PURE__ */ jsx(
@@ -16411,7 +16411,7 @@ function PipelinePanelInner({
16411
16411
  ]
16412
16412
  }
16413
16413
  ),
16414
- !w && m && /* @__PURE__ */ jsx("div", { className: "border-t border-slate-100 dark:border-border/60 px-4 py-3", children: U }),
16414
+ !w && m && /* @__PURE__ */ jsx("div", { className: "border-t border-slate-100 dark:border-border/60 px-4 py-3", children: Q }),
16415
16415
  w && /* @__PURE__ */ jsxs("div", { className: "border-t border-slate-100 dark:border-border/60", children: [
16416
16416
  l && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 border-b border-amber-100 bg-amber-50 px-5 py-2.5 dark:border-amber-500/20 dark:bg-amber-500/10", children: [
16417
16417
  /* @__PURE__ */ jsx("span", { className: "h-1.5 w-1.5 rounded-full bg-amber-400 shrink-0" }),
@@ -16440,7 +16440,7 @@ function PipelinePanelInner({
16440
16440
  ) }),
16441
16441
  ie && /* @__PURE__ */ jsxs("div", { className: "space-y-3 px-5 py-4", children: [
16442
16442
  /* @__PURE__ */ jsx("div", { className: "flex flex-wrap justify-end gap-2", children: z(L) }),
16443
- m && U
16443
+ m && Q
16444
16444
  ] }),
16445
16445
  /* @__PURE__ */ jsxs("div", { className: "px-5 py-3", children: [
16446
16446
  /* @__PURE__ */ jsxs(
@@ -17797,7 +17797,7 @@ function ItemEditForm({
17797
17797
  queryKey: ["relations", e],
17798
17798
  queryFn: () => N.request(get$1(`/data-model/relations/for/${e}`)).then((T) => T.data ?? []),
17799
17799
  staleTime: 6e4
17800
- }), { data: Q = [] } = useQuery({
17800
+ }), { data: U = [] } = useQuery({
17801
17801
  queryKey: ["field-rules", e],
17802
17802
  queryFn: () => N.request(get$1("/field-rules", { collection: e })).then((T) => T.data ?? []),
17803
17803
  enabled: !!e,
@@ -17815,7 +17815,7 @@ function ItemEditForm({
17815
17815
  ).then((T) => (T.data ?? []).filter((P) => P.layout_type === "file" && !!P.is_active)),
17816
17816
  enabled: !!e && !b,
17817
17817
  staleTime: 6e4
17818
- }), [U, ee] = useState({}), [le, J] = useState(null), [V, oe] = useState(!1), [ye, he] = useState(!1), [de, ae] = useState(0), [B, ue] = useState("original"), [Z, je] = useState(!1), _e = useCallback(async (T) => {
17818
+ }), [Q, ee] = useState({}), [le, J] = useState(null), [V, oe] = useState(!1), [ye, he] = useState(!1), [de, ae] = useState(0), [B, ue] = useState("original"), [Z, je] = useState(!1), _e = useCallback(async (T) => {
17819
17819
  if (!(!g || !e)) {
17820
17820
  J(T), oe(!1);
17821
17821
  try {
@@ -17889,7 +17889,7 @@ function ItemEditForm({
17889
17889
  ds((P) => [...P, T]);
17890
17890
  }, []), [cs, Zt] = useState([]), Ks = useCallback((T) => {
17891
17891
  Zt((P) => [...P, T]);
17892
- }, []), [Pt, it] = useState(/* @__PURE__ */ new Map()), [te, $e] = useState(/* @__PURE__ */ new Map()), [Se, Le] = useState(/* @__PURE__ */ new Map()), Ue = useMemo(() => ({
17892
+ }, []), [Pt, it] = useState(/* @__PURE__ */ new Map()), [te, $e] = useState(/* @__PURE__ */ new Map()), [Se, Le] = useState(/* @__PURE__ */ new Map()), Qe = useMemo(() => ({
17893
17893
  getPendingRows: (T, P) => Pt.get(`${T}.${P}`) ?? [],
17894
17894
  queueRow: (T, P, W) => it((se) => {
17895
17895
  const re = new Map(se), we = `${T}.${P}`;
@@ -17900,18 +17900,18 @@ function ItemEditForm({
17900
17900
  return Te.splice(W, 1), re.set(we, Te), re;
17901
17901
  }),
17902
17902
  updateRow: (T, P, W, se) => it((re) => {
17903
- const we = new Map(re), Te = `${T}.${P}`, Qe = [...we.get(Te) ?? []];
17904
- return Qe[W] = { ...Qe[W], ...se }, we.set(Te, Qe), we;
17903
+ const we = new Map(re), Te = `${T}.${P}`, Ue = [...we.get(Te) ?? []];
17904
+ return Ue[W] = { ...Ue[W], ...se }, we.set(Te, Ue), we;
17905
17905
  }),
17906
17906
  reorderRows: (T, P, W, se) => it((re) => {
17907
- const we = new Map(re), Te = `${T}.${P}`, Qe = [...we.get(Te) ?? []], [Re] = Qe.splice(W, 1);
17908
- return Qe.splice(se, 0, Re), we.set(Te, Qe), we;
17907
+ const we = new Map(re), Te = `${T}.${P}`, Ue = [...we.get(Te) ?? []], [Re] = Ue.splice(W, 1);
17908
+ return Ue.splice(se, 0, Re), we.set(Te, Ue), we;
17909
17909
  }),
17910
17910
  getPendingEdits: (T, P) => te.get(`${T}.${P}`) ?? /* @__PURE__ */ new Map(),
17911
17911
  getPendingDeletes: (T, P) => Se.get(`${T}.${P}`) ?? /* @__PURE__ */ new Set(),
17912
17912
  queueEdit: (T, P, W, se) => $e((re) => {
17913
- const we = new Map(re), Te = `${T}.${P}`, Qe = new Map(we.get(Te) ?? []);
17914
- return Qe.set(W, { ...Qe.get(W) ?? {}, ...se }), we.set(Te, Qe), we;
17913
+ const we = new Map(re), Te = `${T}.${P}`, Ue = new Map(we.get(Te) ?? []);
17914
+ return Ue.set(W, { ...Ue.get(W) ?? {}, ...se }), we.set(Te, Ue), we;
17915
17915
  }),
17916
17916
  queueDelete: (T, P, W) => {
17917
17917
  Le((se) => {
@@ -17957,7 +17957,7 @@ function ItemEditForm({
17957
17957
  })
17958
17958
  }),
17959
17959
  [mt, lt]
17960
- ), Ut = useCallback(async (T) => {
17960
+ ), Qt = useCallback(async (T) => {
17961
17961
  Be.current = { ...Be.current, ...T.values }, ve((se) => ({ ...se, ...T.values }));
17962
17962
  const P = [...T.issues];
17963
17963
  if (T.lines.length > 0) {
@@ -17971,11 +17971,11 @@ function ItemEditForm({
17971
17971
  } catch {
17972
17972
  return {};
17973
17973
  }
17974
- })() : we ?? {}, Qe = Array.isArray(Te.row_rules) ? Te.row_rules : [];
17975
- if (Qe.length > 0) {
17974
+ })() : we ?? {}, Ue = Array.isArray(Te.row_rules) ? Te.row_rules : [];
17975
+ if (Ue.length > 0) {
17976
17976
  const Re = { ...Be.current }, He = {};
17977
17977
  for (const Pe of Te.parent_context_fields ?? []) He[Pe] = Re[Pe] ?? null;
17978
- for (const Pe of Qe) {
17978
+ for (const Pe of Ue) {
17979
17979
  const tt = Pe.trigger_field;
17980
17980
  if (typeof tt == "string" && tt.startsWith("$parent.")) {
17981
17981
  const yt = tt.slice(8);
@@ -17993,7 +17993,7 @@ function ItemEditForm({
17993
17993
  collection: se.many_collection,
17994
17994
  data: kt.values,
17995
17995
  parent_context: He,
17996
- row_rules: Qe
17996
+ row_rules: Ue
17997
17997
  })
17998
17998
  ).then((ns) => ns.updates ?? {}).catch(() => (Ge = !0, {}))
17999
17999
  )
@@ -18009,7 +18009,7 @@ function ItemEditForm({
18009
18009
  });
18010
18010
  }
18011
18011
  for (const Re of T.lines)
18012
- Ue.queueRow(se.many_collection, se.many_field, {
18012
+ Qe.queueRow(se.many_collection, se.many_field, {
18013
18013
  ...Re.values,
18014
18014
  ...Re.nested ? { [T.nested_relation ? `__o2m_${Re.nested.field}` : Re.nested.field]: Re.nested.rows } : {}
18015
18015
  });
@@ -18029,7 +18029,7 @@ function ItemEditForm({
18029
18029
  );
18030
18030
  if (we) {
18031
18031
  const Te = we.one_field ?? `${we.many_collection}.${we.junction_field}`;
18032
- for (const Qe of re) dt.stageLink(Te, Qe);
18032
+ for (const Ue of re) dt.stageLink(Te, Ue);
18033
18033
  } else
18034
18034
  P.push({
18035
18035
  severity: "error",
@@ -18038,7 +18038,7 @@ function ItemEditForm({
18038
18038
  });
18039
18039
  }
18040
18040
  qe(P);
18041
- }, [e, E, Ue, dt, A, N]), [es, ms] = useState(null), [Ms, on] = useState(!1), wn = useCallback(
18041
+ }, [e, E, Qe, dt, A, N]), [es, ms] = useState(null), [Ms, on] = useState(!1), wn = useCallback(
18042
18042
  async (T, P) => {
18043
18043
  const W = P.reimport;
18044
18044
  if (!W || (et || [...Pt.values()].some((Re) => Re.length > 0) || [...te.values()].some((Re) => Re.size > 0) || [...Se.values()].some((Re) => Re.size > 0)) && !window.confirm(
@@ -18073,9 +18073,9 @@ function ItemEditForm({
18073
18073
  return;
18074
18074
  }
18075
18075
  }
18076
- let Qe;
18076
+ let Ue;
18077
18077
  try {
18078
- Qe = T.lines.length > 0 && (re != null && re.many_collection) && re.many_field ? diffReimportLines(we, Te, { lines: W.lines, match_by: W.match_by }) : { creates: [], updates: [], deletes: [], matchedUnchanged: 0 };
18078
+ Ue = T.lines.length > 0 && (re != null && re.many_collection) && re.many_field ? diffReimportLines(we, Te, { lines: W.lines, match_by: W.match_by }) : { creates: [], updates: [], deletes: [], matchedUnchanged: 0 };
18079
18079
  } catch (Re) {
18080
18080
  qe([
18081
18081
  {
@@ -18086,7 +18086,7 @@ function ItemEditForm({
18086
18086
  ]);
18087
18087
  return;
18088
18088
  }
18089
- qe([]), ms({ diff: Qe, result: T, template: P, existingRows: Te });
18089
+ qe([]), ms({ diff: Ue, result: T, template: P, existingRows: Te });
18090
18090
  },
18091
18091
  [et, Pt, te, Se, E, e, N, g]
18092
18092
  ), sn = useCallback(
@@ -18106,11 +18106,11 @@ function ItemEditForm({
18106
18106
  }
18107
18107
  Object.keys(He).length > 0 && (Be.current = { ...Be.current, ...He }, ve((Ze) => ({ ...Ze, ...He })));
18108
18108
  }
18109
- const Qe = P.line_target_field ? E.find(
18109
+ const Ue = P.line_target_field ? E.find(
18110
18110
  (He) => He.one_collection === e && He.one_field === P.line_target_field
18111
18111
  ) : null;
18112
- if (Qe != null && Qe.many_collection && Qe.many_field) {
18113
- const He = Qe.many_collection, Ze = Qe.many_field;
18112
+ if (Ue != null && Ue.many_collection && Ue.many_field) {
18113
+ const He = Ue.many_collection, Ze = Ue.many_field;
18114
18114
  let Ge = T.creates;
18115
18115
  if (Ge.length > 0) {
18116
18116
  const We = (A ?? []).find((kt) => kt.field === P.line_target_field), Pe = We == null ? void 0 : We.options, tt = typeof Pe == "string" ? (() => {
@@ -18130,7 +18130,7 @@ function ItemEditForm({
18130
18130
  gt in ns || (ns[gt] = kt[gt] ?? null);
18131
18131
  }
18132
18132
  }
18133
- const Qt = [];
18133
+ const Ut = [];
18134
18134
  let vs = !1;
18135
18135
  const Ys = 10;
18136
18136
  for (let De = 0; De < Ge.length; De += Ys) {
@@ -18149,21 +18149,21 @@ function ItemEditForm({
18149
18149
  ).then((Wt) => Wt.updates ?? {}).catch(() => (vs = !0, {}));
18150
18150
  })
18151
18151
  );
18152
- Qt.push(...gt);
18152
+ Ut.push(...gt);
18153
18153
  }
18154
18154
  vs && Te.push({
18155
18155
  severity: "warn",
18156
18156
  rule: "reimport-apply",
18157
18157
  message: "Some line autofill rules could not be evaluated — check the affected rows before saving."
18158
- }), Ge = Ge.map((De, rt) => ({ ...De, ...Qt[rt] }));
18158
+ }), Ge = Ge.map((De, rt) => ({ ...De, ...Ut[rt] }));
18159
18159
  }
18160
18160
  }
18161
18161
  for (const We of Ge)
18162
- Ue.queueRow(He, Ze, We);
18162
+ Qe.queueRow(He, Ze, We);
18163
18163
  for (const We of T.updates)
18164
- Ue.queueEdit(He, Ze, We.id, We.changes);
18164
+ Qe.queueEdit(He, Ze, We.id, We.changes);
18165
18165
  for (const We of T.deletes)
18166
- Ue.queueDelete(He, Ze, We);
18166
+ Qe.queueDelete(He, Ze, We);
18167
18167
  if (re.lines === "upsert" || re.lines === "upsert_delete") {
18168
18168
  const We = buildReimportFileRows(P), Pe = /* @__PURE__ */ new Map();
18169
18169
  for (const yt of se)
@@ -18172,10 +18172,10 @@ function ItemEditForm({
18172
18172
  for (const yt of We) {
18173
18173
  const kt = Pe.get(reimportMatchKey(yt, re.match_by));
18174
18174
  if (kt)
18175
- for (const [ns, Qt] of Object.entries(yt)) {
18175
+ for (const [ns, Ut] of Object.entries(yt)) {
18176
18176
  if (!ns.startsWith("__o2m_")) continue;
18177
18177
  const vs = ns.slice(6), Ys = tt.get(vs) ?? [];
18178
- Ys.push({ id: kt, members: Array.isArray(Qt) ? Qt : [] }), tt.set(vs, Ys);
18178
+ Ys.push({ id: kt, members: Array.isArray(Ut) ? Ut : [] }), tt.set(vs, Ys);
18179
18179
  }
18180
18180
  }
18181
18181
  for (const [yt, kt] of tt) {
@@ -18190,11 +18190,11 @@ function ItemEditForm({
18190
18190
  });
18191
18191
  continue;
18192
18192
  }
18193
- const Qt = ns.many_collection, vs = ns.many_field, Ys = kt.map((gt) => gt.id);
18193
+ const Ut = ns.many_collection, vs = ns.many_field, Ys = kt.map((gt) => gt.id);
18194
18194
  let De = [];
18195
18195
  try {
18196
18196
  De = await N.request(
18197
- get$1(`/items/${Qt}`, {
18197
+ get$1(`/items/${Ut}`, {
18198
18198
  filter: JSON.stringify({ [vs]: { _in: Ys } }),
18199
18199
  fields: `id,${vs}`,
18200
18200
  limit: 2e3
@@ -18214,7 +18214,7 @@ function ItemEditForm({
18214
18214
  Ht.push(String(gt.id)), rt.set(Lt, Ht);
18215
18215
  }
18216
18216
  for (const gt of kt)
18217
- Ue.queueEdit(He, Ze, gt.id, {
18217
+ Qe.queueEdit(He, Ze, gt.id, {
18218
18218
  [`__nested_ops_${yt}`]: {
18219
18219
  created: gt.members,
18220
18220
  updated: [],
@@ -18292,13 +18292,13 @@ function ItemEditForm({
18292
18292
  message: `Re-import: ${T.updates.length} updates · ${T.creates.length} new · ${T.deletes.length} deletes · ${T.matchedUnchanged} unchanged`
18293
18293
  }), qe(Te);
18294
18294
  },
18295
- [e, E, Ue, dt, N, g, A]
18295
+ [e, E, Qe, dt, N, g, A]
18296
18296
  ), Rn = useRef(!1);
18297
18297
  useEffect(() => {
18298
18298
  !b || !v || Rn.current || (Rn.current = !0, ve((T) => ({ ...v, ...T })), Be.current = { ...v, ...Be.current }, Tt(!0));
18299
18299
  }, [b, v]), useEffect(() => {
18300
- !b || !y || St.current || (y.lines.length > 0 || Object.keys(y.m2m ?? {}).length > 0) && !K || y.lines.length > 0 && !M || (St.current = !0, Ut(y));
18301
- }, [b, y, K, M, Ut]), useEffect(() => {
18300
+ !b || !y || St.current || (y.lines.length > 0 || Object.keys(y.m2m ?? {}).length > 0) && !K || y.lines.length > 0 && !M || (St.current = !0, Qt(y));
18301
+ }, [b, y, K, M, Qt]), useEffect(() => {
18302
18302
  ke && (Oe.current = ke, Be.current = ke, ve(ke), Tt(!1));
18303
18303
  }, [ke]), useEffect(() => {
18304
18304
  var W;
@@ -18335,7 +18335,7 @@ function ItemEditForm({
18335
18335
  Object.keys(T).length !== 0 && (Oe.current = { ...Oe.current, ...T }, Be.current = { ...Be.current, ...T }, ve((P) => ({ ...P, ...T })));
18336
18336
  }, [Jt]);
18337
18337
  const zt = useMemo(() => {
18338
- const T = Q.filter((se) => se.is_active === !0 || se.is_active === 1), P = /* @__PURE__ */ new Set();
18338
+ const T = U.filter((se) => se.is_active === !0 || se.is_active === 1), P = /* @__PURE__ */ new Set();
18339
18339
  for (const se of T)
18340
18340
  P.add(se.trigger_field), P.add(se.target_field);
18341
18341
  for (const se of E)
@@ -18346,7 +18346,7 @@ function ItemEditForm({
18346
18346
  re && W.set(se, re);
18347
18347
  }
18348
18348
  return W;
18349
- }, [Q, E, e]), On = [...zt.values()], dn = useQueries({
18349
+ }, [U, E, e]), On = [...zt.values()], dn = useQueries({
18350
18350
  queries: On.map((T) => ({
18351
18351
  queryKey: ["m2m-items", T.manyCollection, T.manyField, g],
18352
18352
  queryFn: () => N.request(
@@ -18404,8 +18404,8 @@ function ItemEditForm({
18404
18404
  continue;
18405
18405
  }
18406
18406
  if (((we == null ? void 0 : we.source_fk_field) || se.field) !== T || !(we != null && we.source_collection) || !we.field_map) continue;
18407
- const Qe = we.field_map, Re = [
18408
- ...new Set(Object.values(Qe).flatMap((He) => String(He).split("||").map((Ze) => Ze.trim())))
18407
+ const Ue = we.field_map, Re = [
18408
+ ...new Set(Object.values(Ue).flatMap((He) => String(He).split("||").map((Ze) => Ze.trim())))
18409
18409
  ].filter(Boolean);
18410
18410
  Re.length !== 0 && N.request(
18411
18411
  get$1(`/items/${we.source_collection}/${P}`, {
@@ -18415,7 +18415,7 @@ function ItemEditForm({
18415
18415
  const Ze = He.data;
18416
18416
  if (!Ze) return;
18417
18417
  const Ge = {};
18418
- for (const [We, Pe] of Object.entries(Qe)) {
18418
+ for (const [We, Pe] of Object.entries(Ue)) {
18419
18419
  const tt = String(Pe).split("||").map((kt) => kt.trim());
18420
18420
  let yt = null;
18421
18421
  for (const kt of tt)
@@ -18435,36 +18435,36 @@ function ItemEditForm({
18435
18435
  var re;
18436
18436
  const { scalar: P, alias: W } = partitionRuleResults(T, new Set(zt.keys())), se = dropUnsettledAliasResults(W, rs);
18437
18437
  for (const [we, Te] of Object.entries(se)) {
18438
- const Qe = zt.get(we);
18439
- if (!Qe) continue;
18438
+ const Ue = zt.get(we);
18439
+ if (!Ue) continue;
18440
18440
  const Re = idsNeedingStaging(Te, (re = As.current[we]) == null ? void 0 : re.ids);
18441
- for (const He of Re) dt.stageLink(Qe.stagingKey, He);
18441
+ for (const He of Re) dt.stageLink(Ue.stagingKey, He);
18442
18442
  }
18443
18443
  if (Object.keys(P).length > 0) {
18444
18444
  const we = mergeRuleResults(Be.current, P);
18445
18445
  Be.current = we, ve(we);
18446
- for (const [Te, Qe] of Object.entries(P)) fn(Te, Qe);
18446
+ for (const [Te, Ue] of Object.entries(P)) fn(Te, Ue);
18447
18447
  }
18448
18448
  },
18449
18449
  [zt, rs, dt, fn]
18450
- ), Qs = useRef({});
18450
+ ), Us = useRef({});
18451
18451
  useEffect(() => {
18452
- const T = Qs.current;
18452
+ const T = Us.current;
18453
18453
  return () => {
18454
18454
  for (const P of Object.values(T)) clearTimeout(P);
18455
18455
  };
18456
18456
  }, []);
18457
18457
  const an = useCallback(
18458
18458
  (T, P) => {
18459
- const W = rulesForTriggerField(Q, T);
18459
+ const W = rulesForTriggerField(U, T);
18460
18460
  if (W.length === 0) return;
18461
- const se = Qs.current[T];
18462
- se && clearTimeout(se), Qs.current[T] = setTimeout(() => {
18463
- delete Qs.current[T];
18461
+ const se = Us.current[T];
18462
+ se && clearTimeout(se), Us.current[T] = setTimeout(() => {
18463
+ delete Us.current[T];
18464
18464
  const re = P !== void 0 ? P : Be.current[T], we = {};
18465
18465
  for (const Te of W) {
18466
- const Qe = js(Te.target_field);
18467
- we[Te.target_field] = Qe !== void 0 ? Qe : Be.current[Te.target_field];
18466
+ const Ue = js(Te.target_field);
18467
+ we[Te.target_field] = Ue !== void 0 ? Ue : Be.current[Te.target_field];
18468
18468
  }
18469
18469
  N.request(
18470
18470
  post$1("/field-rules/evaluate", {
@@ -18477,12 +18477,12 @@ function ItemEditForm({
18477
18477
  });
18478
18478
  }, 300);
18479
18479
  },
18480
- [Q, e, N, js, Nn]
18480
+ [U, e, N, js, Nn]
18481
18481
  ), Ss = useRef({}), $n = useRef(!1), un = useMemo(
18482
18482
  () => [...zt.entries()].filter(
18483
- ([T]) => rulesForTriggerField(Q, T).length > 0
18483
+ ([T]) => rulesForTriggerField(U, T).length > 0
18484
18484
  ),
18485
- [zt, Q]
18485
+ [zt, U]
18486
18486
  );
18487
18487
  useEffect(() => {
18488
18488
  if (!$n.current) {
@@ -18521,12 +18521,12 @@ function ItemEditForm({
18521
18521
  Be.current = W, ve(W), Tt(!0);
18522
18522
  const se = P == null || P === "";
18523
18523
  se || wt.current.add(T), _t((re) => {
18524
- const we = { ...re }, Te = (A ?? []).find((Qe) => Qe.field === T);
18524
+ const we = { ...re }, Te = (A ?? []).find((Ue) => Ue.field === T);
18525
18525
  return Te != null && Te.required && se && wt.current.has(T) ? we[T] = "This field is required" : delete we[T], we;
18526
18526
  }), an(T), se || fn(T, P);
18527
18527
  },
18528
18528
  [A, an, fn]
18529
- ), [hn, Us] = useState({}), Cs = useMemo(
18529
+ ), [hn, Qs] = useState({}), Cs = useMemo(
18530
18530
  () => E.filter((T) => !T.junction_field && T.one_collection === e && T.one_field && T.many_field && T.many_collection),
18531
18531
  [E, e]
18532
18532
  ), Ws = useQueries({
@@ -18553,7 +18553,7 @@ function ItemEditForm({
18553
18553
  }), T;
18554
18554
  }, [Cs, Ws]), xs = useCallback(
18555
18555
  (T, P) => {
18556
- Us((W) => W[T] === P ? W : { ...W, [T]: P }), P > 0 && wt.current.add(T), _t((W) => {
18556
+ Qs((W) => W[T] === P ? W : { ...W, [T]: P }), P > 0 && wt.current.add(T), _t((W) => {
18557
18557
  const se = (A ?? []).find((we) => we.field === T);
18558
18558
  if (!(se != null && se.required)) return W;
18559
18559
  const re = { ...W };
@@ -18563,7 +18563,7 @@ function ItemEditForm({
18563
18563
  [A]
18564
18564
  ), ps = _ && !b && !!(ie != null && ie.item_locking_enabled), {
18565
18565
  lockHolder: Mn,
18566
- acquired: Qn,
18566
+ acquired: Un,
18567
18567
  isReadOnly: Ps,
18568
18568
  takeOver: An,
18569
18569
  takingOver: Pn
@@ -18593,8 +18593,8 @@ function ItemEditForm({
18593
18593
  try {
18594
18594
  const se = JSON.parse(ie.addendum_allowed_states);
18595
18595
  if (Array.isArray(se) && se.length > 0) {
18596
- const re = ((T = gs == null ? void 0 : gs.instance) == null ? void 0 : T.current_state) ?? null, we = ((W = (P = gs == null ? void 0 : gs.states) == null ? void 0 : P.find((Qe) => Qe.id === re)) == null ? void 0 : W.key) ?? null;
18597
- if (!se.some((Qe) => Qe.state_keys.length === 0 || we !== null && Qe.state_keys.includes(we))) return !1;
18596
+ const re = ((T = gs == null ? void 0 : gs.instance) == null ? void 0 : T.current_state) ?? null, we = ((W = (P = gs == null ? void 0 : gs.states) == null ? void 0 : P.find((Ue) => Ue.id === re)) == null ? void 0 : W.key) ?? null;
18597
+ if (!se.some((Ue) => Ue.state_keys.length === 0 || we !== null && Ue.state_keys.includes(we))) return !1;
18598
18598
  }
18599
18599
  } catch {
18600
18600
  }
@@ -18606,7 +18606,7 @@ function ItemEditForm({
18606
18606
  ).then((T) => T.data ?? []),
18607
18607
  enabled: bn,
18608
18608
  staleTime: 3e4
18609
- }), Un = useMemo(() => {
18609
+ }), Qn = useMemo(() => {
18610
18610
  const T = {};
18611
18611
  for (const P of fs)
18612
18612
  if (!["approved", "rejected"].includes(P.status))
@@ -18662,11 +18662,11 @@ function ItemEditForm({
18662
18662
  }), mn = useMemo(() => {
18663
18663
  const T = { ...$s };
18664
18664
  return os.forEach((P, W) => {
18665
- var Qe;
18665
+ var Ue;
18666
18666
  if (!P.one_field) return;
18667
18667
  const se = $s[P.one_field];
18668
18668
  if (!se || !se.agg_field) return;
18669
- const we = (((Qe = Sn[W]) == null ? void 0 : Qe.data) ?? []).find((Re) => Re.field === se.agg_field);
18669
+ const we = (((Ue = Sn[W]) == null ? void 0 : Ue.data) ?? []).find((Re) => Re.field === se.agg_field);
18670
18670
  if (!we) return;
18671
18671
  const Te = we.options ? typeof we.options == "string" ? we.options : JSON.stringify(we.options) : null;
18672
18672
  Te && (T[P.one_field] = { ...se, field_options: Te });
@@ -18690,8 +18690,8 @@ function ItemEditForm({
18690
18690
  if (!P.one_field || !P.many_collection || !P.many_field) return;
18691
18691
  const se = ((Ge = pn[W]) == null ? void 0 : Ge.data) ?? [], re = mn[P.one_field];
18692
18692
  if (!re) return;
18693
- const we = `${P.many_collection}.${P.many_field}`, Te = te.get(we) ?? /* @__PURE__ */ new Map(), Qe = Se.get(we) ?? /* @__PURE__ */ new Set(), Re = Pt.get(we) ?? [], He = [
18694
- ...se.filter((We) => !Qe.has(String(We.id))).map((We) => Te.has(String(We.id)) ? { ...We, ...Te.get(String(We.id)) } : We),
18693
+ const we = `${P.many_collection}.${P.many_field}`, Te = te.get(we) ?? /* @__PURE__ */ new Map(), Ue = Se.get(we) ?? /* @__PURE__ */ new Set(), Re = Pt.get(we) ?? [], He = [
18694
+ ...se.filter((We) => !Ue.has(String(We.id))).map((We) => Te.has(String(We.id)) ? { ...We, ...Te.get(String(We.id)) } : We),
18695
18695
  ...Re
18696
18696
  ];
18697
18697
  if (re.agg === "count") {
@@ -18837,8 +18837,8 @@ function ItemEditForm({
18837
18837
  if (re.length === 0) continue;
18838
18838
  const we = Me.get(se.id) ?? ((W = re[0]) == null ? void 0 : W.key), Te = re.find((Re) => Re.key === we);
18839
18839
  if (!P(Te)) continue;
18840
- const Qe = re.find((Re) => !P(Re));
18841
- Qe && Qe.key !== we && Ae((Re) => new Map(Re).set(se.id, Qe.key));
18840
+ const Ue = re.find((Re) => !P(Re));
18841
+ Ue && Ue.key !== we && Ae((Re) => new Map(Re).set(se.id, Ue.key));
18842
18842
  }
18843
18843
  }, [b, ws, ke, Bt, Ke, Ct, ts, Me]);
18844
18844
  const ca = useMemo(() => {
@@ -18924,8 +18924,8 @@ function ItemEditForm({
18924
18924
  try {
18925
18925
  const W = P.input_bindings, re = (typeof W == "string" ? JSON.parse(W) : Array.isArray(W) ? W : []).find((we) => we.key === "__inline_display__");
18926
18926
  if (re != null && re.binding_value) {
18927
- const we = JSON.parse(re.binding_value), Te = Array.isArray(we), Qe = Te ? we : we.fields ?? [], Re = Te ? null : we.separator ?? null;
18928
- Array.isArray(Qe) && Qe.length && (T[P.field] = { entries: Qe, separator: Re });
18927
+ const we = JSON.parse(re.binding_value), Te = Array.isArray(we), Ue = Te ? we : we.fields ?? [], Re = Te ? null : we.separator ?? null;
18928
+ Array.isArray(Ue) && Ue.length && (T[P.field] = { entries: Ue, separator: Re });
18929
18929
  }
18930
18930
  } catch {
18931
18931
  }
@@ -18972,12 +18972,12 @@ function ItemEditForm({
18972
18972
  () => ia.map((T) => T.value).join((Bs == null ? void 0 : Bs.separator) ?? " | "),
18973
18973
  [ia, Bs]
18974
18974
  ), wa = useMemo(() => ((j == null ? void 0 : j.assignments) ?? []).filter((T) => (T.field === "__owners__" || !T.field.startsWith("__")) && (T.group_key ?? null) === "__header__").map((T) => {
18975
- var Qe, Re, He, Ze;
18975
+ var Ue, Re, He, Ze;
18976
18976
  const P = (A ?? []).find((Ge) => Ge.field === T.field);
18977
18977
  let W = "text", se, re, we, Te;
18978
18978
  try {
18979
18979
  const Ge = T.input_bindings, We = typeof Ge == "string" ? JSON.parse(Ge) : Array.isArray(Ge) ? Ge : [], Pe = We.find((tt) => tt.key === "__display_format__");
18980
- Pe != null && Pe.binding_value && (W = Pe.binding_value), se = ((Qe = We.find((tt) => tt.key === "__color__")) == null ? void 0 : Qe.binding_value) || void 0, re = ((Re = We.find((tt) => tt.key === "__weight__")) == null ? void 0 : Re.binding_value) || void 0, we = ((He = We.find((tt) => tt.key === "__display_as__")) == null ? void 0 : He.binding_value) || void 0, Te = ((Ze = We.find((tt) => tt.key === "__link_template__")) == null ? void 0 : Ze.binding_value) || void 0;
18980
+ Pe != null && Pe.binding_value && (W = Pe.binding_value), se = ((Ue = We.find((tt) => tt.key === "__color__")) == null ? void 0 : Ue.binding_value) || void 0, re = ((Re = We.find((tt) => tt.key === "__weight__")) == null ? void 0 : Re.binding_value) || void 0, we = ((He = We.find((tt) => tt.key === "__display_as__")) == null ? void 0 : He.binding_value) || void 0, Te = ((Ze = We.find((tt) => tt.key === "__link_template__")) == null ? void 0 : Ze.binding_value) || void 0;
18981
18981
  } catch {
18982
18982
  }
18983
18983
  return {
@@ -19095,7 +19095,7 @@ function ItemEditForm({
19095
19095
  for (const [W, se] of te.entries()) {
19096
19096
  if (se.size === 0) continue;
19097
19097
  const re = W.split(".")[0], we = /* @__PURE__ */ new Set();
19098
- for (const Te of se.values()) for (const Qe of Object.keys(Te)) Qe.startsWith("__") || we.add(Qe);
19098
+ for (const Te of se.values()) for (const Ue of Object.keys(Te)) Ue.startsWith("__") || we.add(Ue);
19099
19099
  we.size && T.push({ collection: re, changedFields: [...we] });
19100
19100
  }
19101
19101
  for (const W of T)
@@ -19133,7 +19133,7 @@ function ItemEditForm({
19133
19133
  return ((gt = rt == null ? void 0 : rt.data) == null ? void 0 : gt.error) ?? (De instanceof Error ? De.message : "Failed");
19134
19134
  }
19135
19135
  let P = null;
19136
- const W = [...mt.entries()].some(([, De]) => De.length > 0) || [...lt.entries()].some(([, De]) => De.size > 0), se = [...Pt.entries()].filter(([, De]) => De.length > 0).map(([De]) => De), re = [...te.entries()].filter(([, De]) => De.size > 0).map(([De]) => De), we = [...Se.entries()].filter(([, De]) => De.size > 0).map(([De]) => De), Te = b ? Ls.filter((De) => !SYSTEM_FIELDS.has(De.field) && !De.readonly && De.field in ce).length : Ls.filter((De) => SYSTEM_FIELDS.has(De.field) || De.readonly || !(De.field in ce) ? !1 : !valuesEqual(ce[De.field], Oe.current[De.field])).length, Qe = b ? `${Te} field${Te !== 1 ? "s" : ""} set` : Te === 0 ? "No field changes" : `${Te} field${Te !== 1 ? "s" : ""} changed`;
19136
+ const W = [...mt.entries()].some(([, De]) => De.length > 0) || [...lt.entries()].some(([, De]) => De.size > 0), se = [...Pt.entries()].filter(([, De]) => De.length > 0).map(([De]) => De), re = [...te.entries()].filter(([, De]) => De.size > 0).map(([De]) => De), we = [...Se.entries()].filter(([, De]) => De.size > 0).map(([De]) => De), Te = b ? Ls.filter((De) => !SYSTEM_FIELDS.has(De.field) && !De.readonly && De.field in ce).length : Ls.filter((De) => SYSTEM_FIELDS.has(De.field) || De.readonly || !(De.field in ce) ? !1 : !valuesEqual(ce[De.field], Oe.current[De.field])).length, Ue = b ? `${Te} field${Te !== 1 ? "s" : ""} set` : Te === 0 ? "No field changes" : `${Te} field${Te !== 1 ? "s" : ""} changed`;
19137
19137
  let Re = 0, He = 0;
19138
19138
  for (const [, De] of mt.entries()) Re += De.length;
19139
19139
  for (const [, De] of lt.entries()) He += De.size;
@@ -19142,7 +19142,7 @@ function ItemEditForm({
19142
19142
  He > 0 ? `-${He} unlinked` : ""
19143
19143
  ].filter(Boolean).join(" · "), Ge = [...Ie.current.entries()], We = [
19144
19144
  ...Ge.length > 0 ? [{ id: "flush", label: "Save attachments", status: "pending", detail: `${Ge.length} field${Ge.length !== 1 ? "s" : ""} with pending changes` }] : [],
19145
- { id: "main", label: b ? `Create ${(ie == null ? void 0 : ie.singular) || titleCase$2(e)}` : `Save ${(ie == null ? void 0 : ie.singular) || titleCase$2(e)}`, status: "pending", detail: Qe },
19145
+ { id: "main", label: b ? `Create ${(ie == null ? void 0 : ie.singular) || titleCase$2(e)}` : `Save ${(ie == null ? void 0 : ie.singular) || titleCase$2(e)}`, status: "pending", detail: Ue },
19146
19146
  ...W ? [{ id: "m2m", label: "Update relationships", status: "pending", detail: Ze }] : [],
19147
19147
  ...se.map((De) => {
19148
19148
  var gt;
@@ -19275,7 +19275,7 @@ function ItemEditForm({
19275
19275
  Y(rt, { status: "error", error: T(Mt) });
19276
19276
  }
19277
19277
  }
19278
- const Qt = new Map(te);
19278
+ const Ut = new Map(te);
19279
19279
  for (const De of re) {
19280
19280
  const rt = `o2m:edit:${De}`, [gt] = De.split("."), Lt = te.get(De) ?? /* @__PURE__ */ new Map();
19281
19281
  Y(rt, { status: "running", progress: { done: 0, total: Lt.size } });
@@ -19321,9 +19321,9 @@ function ItemEditForm({
19321
19321
  var Xs;
19322
19322
  return { progress: { done: (((Xs = bs.progress) == null ? void 0 : Xs.done) ?? 0) + 1, total: Lt.size } };
19323
19323
  });
19324
- })), Mt.size > 0 ? Qt.set(De, Mt) : Qt.delete(De), !Ht && Wt === 0 ? Y(rt, { status: "done" }) : Ht || Y(rt, { status: "error", error: `${Wt} nested row${Wt !== 1 ? "s" : ""} failed` });
19324
+ })), Mt.size > 0 ? Ut.set(De, Mt) : Ut.delete(De), !Ht && Wt === 0 ? Y(rt, { status: "done" }) : Ht || Y(rt, { status: "error", error: `${Wt} nested row${Wt !== 1 ? "s" : ""} failed` });
19325
19325
  }
19326
- $e(Qt), P && $t(P);
19326
+ $e(Ut), P && $t(P);
19327
19327
  const vs = new Map(Se);
19328
19328
  for (const De of we) {
19329
19329
  const rt = `o2m:del:${De}`, [gt] = De.split("."), Lt = Se.get(De) ?? /* @__PURE__ */ new Set();
@@ -19380,8 +19380,8 @@ function ItemEditForm({
19380
19380
  continue;
19381
19381
  }
19382
19382
  re.some((Te) => {
19383
- var Qe, Re;
19384
- return Te.type === "pipeline_state" && ((Qe = Te.state_keys) != null && Qe.length) ? Te.state_keys.includes(W ?? "") : Te.type === "role" && ((Re = Te.role_ids) != null && Re.length) ? Te.role_ids.includes(T ?? "") : !1;
19383
+ var Ue, Re;
19384
+ return Te.type === "pipeline_state" && ((Ue = Te.state_keys) != null && Ue.length) ? Te.state_keys.includes(W ?? "") : Te.type === "role" && ((Re = Te.role_ids) != null && Re.length) ? Te.role_ids.includes(T ?? "") : !1;
19385
19385
  }) && da.add(se.field);
19386
19386
  }
19387
19387
  }
@@ -19494,7 +19494,7 @@ function ItemEditForm({
19494
19494
  const T = be.filter((P) => !P.hidden);
19495
19495
  return T.length === 0 ? null : /* @__PURE__ */ jsx("div", { className: "rounded-xl border border-slate-200 bg-white px-5 py-5", children: /* @__PURE__ */ jsx(GridContainer, { children: (P) => T.map((W) => {
19496
19496
  var He;
19497
- const se = qn == null ? void 0 : qn[W.field], re = se == null ? void 0 : se.entries, we = (se == null ? void 0 : se.separator) ?? null, Te = ce[W.field], Qe = Te != null && Te !== "", Re = re != null && re.length && Qe ? ((He = E.find((Ze) => Ze.many_collection === e && Ze.many_field === W.field && !Ze.junction_field)) == null ? void 0 : He.one_collection) ?? null : null;
19497
+ const se = qn == null ? void 0 : qn[W.field], re = se == null ? void 0 : se.entries, we = (se == null ? void 0 : se.separator) ?? null, Te = ce[W.field], Ue = Te != null && Te !== "", Re = re != null && re.length && Ue ? ((He = E.find((Ze) => Ze.many_collection === e && Ze.many_field === W.field && !Ze.junction_field)) == null ? void 0 : He.one_collection) ?? null : null;
19498
19498
  return /* @__PURE__ */ jsxs("div", { style: { gridColumn: `span ${resolveColSpan(W.options, P)}` }, children: [
19499
19499
  /* @__PURE__ */ jsx(
19500
19500
  FieldRow,
@@ -19513,7 +19513,7 @@ function ItemEditForm({
19513
19513
  onCountChange: xs
19514
19514
  }
19515
19515
  ),
19516
- (re == null ? void 0 : re.length) && Qe && Re && /* @__PURE__ */ jsx(
19516
+ (re == null ? void 0 : re.length) && Ue && Re && /* @__PURE__ */ jsx(
19517
19517
  InlineDisplay,
19518
19518
  {
19519
19519
  relCollection: Re,
@@ -19535,14 +19535,14 @@ function ItemEditForm({
19535
19535
  } catch {
19536
19536
  return null;
19537
19537
  }
19538
- })(), Te = ((we == null ? void 0 : we.alternate_fields) ?? []).map((Pe) => typeof Pe == "string" ? { field: Pe, width: 2 } : Pe), Qe = we != null && we.enabled ? xe.has((re == null ? void 0 : re.id) ?? -1) : !1, Re = (fe[(re == null ? void 0 : re.key) ?? ""] ?? []).filter((Pe) => !Pe.hidden), He = !b && !!L && !!us && (Yn === (re == null ? void 0 : re.key) || Yn === T.key), Ze = /* @__PURE__ */ new Set(), Ge = /* @__PURE__ */ new Set();
19538
+ })(), Te = ((we == null ? void 0 : we.alternate_fields) ?? []).map((Pe) => typeof Pe == "string" ? { field: Pe, width: 2 } : Pe), Ue = we != null && we.enabled ? xe.has((re == null ? void 0 : re.id) ?? -1) : !1, Re = (fe[(re == null ? void 0 : re.key) ?? ""] ?? []).filter((Pe) => !Pe.hidden), He = !b && !!L && !!us && (Yn === (re == null ? void 0 : re.key) || Yn === T.key), Ze = /* @__PURE__ */ new Set(), Ge = /* @__PURE__ */ new Set();
19539
19539
  for (const Pe of P) {
19540
19540
  if (b && !ft(T, Pe.key)) continue;
19541
19541
  const tt = fe[Pe.key] ?? [];
19542
- tt.some((Qt) => st[Qt.field]) && Ge.add(Pe.key);
19543
- const kt = tt.filter((Qt) => Qt.required && !Qt.hidden);
19544
- (kt.length === 0 || kt.every((Qt) => {
19545
- const vs = ce[Qt.field];
19542
+ tt.some((Ut) => st[Ut.field]) && Ge.add(Pe.key);
19543
+ const kt = tt.filter((Ut) => Ut.required && !Ut.hidden);
19544
+ (kt.length === 0 || kt.every((Ut) => {
19545
+ const vs = ce[Ut.field];
19546
19546
  return vs != null && vs !== "";
19547
19547
  })) && Ze.add(Pe.key);
19548
19548
  }
@@ -19573,7 +19573,7 @@ function ItemEditForm({
19573
19573
  /* @__PURE__ */ jsxs("div", { className: "px-5 py-5", children: [
19574
19574
  /* @__PURE__ */ jsx(GridContainer, { children: (Pe) => Re.map((tt) => {
19575
19575
  var Wt;
19576
- const yt = qn == null ? void 0 : qn[tt.field], kt = yt == null ? void 0 : yt.entries, ns = (yt == null ? void 0 : yt.separator) ?? null, Qt = ce[tt.field], vs = Qt != null && Qt !== "", Ys = kt != null && kt.length && vs ? ((Wt = E.find((Mt) => Mt.many_collection === e && Mt.many_field === tt.field && !Mt.junction_field)) == null ? void 0 : Wt.one_collection) ?? null : null, De = (we == null ? void 0 : we.enabled) && tt.field === we.primary_field, rt = (() => {
19576
+ const yt = qn == null ? void 0 : qn[tt.field], kt = yt == null ? void 0 : yt.entries, ns = (yt == null ? void 0 : yt.separator) ?? null, Ut = ce[tt.field], vs = Ut != null && Ut !== "", Ys = kt != null && kt.length && vs ? ((Wt = E.find((Mt) => Mt.many_collection === e && Mt.many_field === tt.field && !Mt.junction_field)) == null ? void 0 : Wt.one_collection) ?? null : null, De = (we == null ? void 0 : we.enabled) && tt.field === we.primary_field, rt = (() => {
19577
19577
  const Mt = ce[(we == null ? void 0 : we.primary_field) ?? ""];
19578
19578
  return Mt != null && Mt !== "";
19579
19579
  })(), gt = Te.some((Mt) => {
@@ -19589,7 +19589,7 @@ function ItemEditForm({
19589
19589
  return Dt.has(re.id) ? Dt.delete(re.id) : Dt.add(re.id), Dt;
19590
19590
  }),
19591
19591
  className: "inline-flex items-center rounded px-1.5 py-0.5 text-[10px] font-medium text-nvr-cyan hover:bg-nvr-cyan/10 transition-colors",
19592
- children: Qe ? we.back_label ?? "Back" : we.toggle_label ?? "Enter manually"
19592
+ children: Ue ? we.back_label ?? "Back" : we.toggle_label ?? "Enter manually"
19593
19593
  }
19594
19594
  ),
19595
19595
  /* @__PURE__ */ jsxs("span", { className: ["inline-flex items-center gap-0.5 rounded px-1 py-0.5 text-[9px] font-medium", rt ? "bg-emerald-50 text-emerald-600 dark:bg-emerald-900/30 dark:text-emerald-400" : "bg-slate-100 text-slate-400 dark:bg-slate-800 dark:text-slate-500"].join(" "), children: [
@@ -19600,7 +19600,7 @@ function ItemEditForm({
19600
19600
  /* @__PURE__ */ jsx("span", { className: ["h-1.5 w-1.5 rounded-full", gt ? "bg-emerald-500" : "bg-slate-300 dark:bg-slate-600"].join(" ") }),
19601
19601
  "Manual"
19602
19602
  ] })
19603
- ] }) : void 0, Ht = De && Qe ? /* @__PURE__ */ jsx("div", { className: "mt-2 rounded-lg border border-slate-200 bg-slate-50 dark:border-border dark:bg-slate-900/40 p-3", children: /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-3", children: Te.map((Mt) => {
19603
+ ] }) : void 0, Ht = De && Ue ? /* @__PURE__ */ jsx("div", { className: "mt-2 rounded-lg border border-slate-200 bg-slate-50 dark:border-border dark:bg-slate-900/40 p-3", children: /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-3", children: Te.map((Mt) => {
19604
19604
  const Dt = (A ?? []).find((Bn) => Bn.field === Mt.field);
19605
19605
  return Dt ? /* @__PURE__ */ jsx("div", { style: { gridColumn: `span ${Mt.width}` }, children: /* @__PURE__ */ jsx(
19606
19606
  FieldRow,
@@ -19641,7 +19641,7 @@ function ItemEditForm({
19641
19641
  swapContent: Ht
19642
19642
  }
19643
19643
  ),
19644
- (kt == null ? void 0 : kt.length) && vs && Ys && /* @__PURE__ */ jsx(InlineDisplay, { relCollection: Ys, relId: Qt, entries: kt, separator: ns })
19644
+ (kt == null ? void 0 : kt.length) && vs && Ys && /* @__PURE__ */ jsx(InlineDisplay, { relCollection: Ys, relId: Ut, entries: kt, separator: ns })
19645
19645
  ] }, tt.field);
19646
19646
  }) }),
19647
19647
  aa.filter((Pe) => (Pe.group_key ?? null) === re.key).map((Pe) => {
@@ -19734,15 +19734,15 @@ function ItemEditForm({
19734
19734
  } catch {
19735
19735
  return null;
19736
19736
  }
19737
- })(), se = ((W == null ? void 0 : W.alternate_fields) ?? []).map((We) => typeof We == "string" ? { field: We, width: 2 } : We), re = W != null && W.enabled ? xe.has(P.id) : !1, Te = fe[P.key] ?? [], Qe = ea && Xn === P.key && c, Re = Zn && Yn === P.key && !b, He = aa.filter((We) => (We.group_key ?? null) === P.key);
19738
- if (Te.length === 0 && !Qe && !Re && He.length === 0) return null;
19737
+ })(), se = ((W == null ? void 0 : W.alternate_fields) ?? []).map((We) => typeof We == "string" ? { field: We, width: 2 } : We), re = W != null && W.enabled ? xe.has(P.id) : !1, Te = fe[P.key] ?? [], Ue = ea && Xn === P.key && c, Re = Zn && Yn === P.key && !b, He = aa.filter((We) => (We.group_key ?? null) === P.key);
19738
+ if (Te.length === 0 && !Ue && !Re && He.length === 0) return null;
19739
19739
  const Ze = In && P.type !== "tab";
19740
19740
  return /* @__PURE__ */ jsx(
19741
19741
  GroupSection,
19742
19742
  {
19743
19743
  group: P,
19744
19744
  fields: Te,
19745
- ownersAssignment: Qe ? Rs : void 0,
19745
+ ownersAssignment: Ue ? Rs : void 0,
19746
19746
  pdfAssignment: Re ? us : void 0,
19747
19747
  pdfAttachField: Re ? Cn : void 0,
19748
19748
  pdfFilenameTemplate: Re ? ja : void 0,
@@ -19813,20 +19813,20 @@ function ItemEditForm({
19813
19813
  ] });
19814
19814
  }
19815
19815
  function $a(T, P = !1) {
19816
- const W = (T === "__general__" ? P ? be : [...be, ...ct.flatMap((Qe) => fe[Qe.key] ?? [])] : fe[T] ?? []).filter((Qe) => !Qe.hidden), se = ea && Xn === T && c, re = Zn && Yn === T && !b, we = aa.filter((Qe) => (Qe.group_key ?? null) === T), Te = W.map((Qe) => ({ _k: Qe.field, sort: Qe.sort ?? 0, _t: "field", f: Qe }));
19816
+ const W = (T === "__general__" ? P ? be : [...be, ...ct.flatMap((Ue) => fe[Ue.key] ?? [])] : fe[T] ?? []).filter((Ue) => !Ue.hidden), se = ea && Xn === T && c, re = Zn && Yn === T && !b, we = aa.filter((Ue) => (Ue.group_key ?? null) === T), Te = W.map((Ue) => ({ _k: Ue.field, sort: Ue.sort ?? 0, _t: "field", f: Ue }));
19817
19817
  se && Rs && Te.push({ _k: "__owners__", sort: Rs.sort, _t: "owners", slot: Rs }), re && us && Te.push({ _k: "__pdf__", sort: us.sort, _t: "pdf", slot: us });
19818
- for (const Qe of we)
19819
- Te.push({ _k: Qe.field, sort: Qe.sort, _t: "widget", slot: Qe });
19820
- return Te.sort((Qe, Re) => Qe.sort - Re.sort), /* @__PURE__ */ jsx("div", { className: "rounded-xl border border-slate-200 bg-white px-5 py-5", children: /* @__PURE__ */ jsx(GridContainer, { children: (Qe) => Te.map((Re) => {
19818
+ for (const Ue of we)
19819
+ Te.push({ _k: Ue.field, sort: Ue.sort, _t: "widget", slot: Ue });
19820
+ return Te.sort((Ue, Re) => Ue.sort - Re.sort), /* @__PURE__ */ jsx("div", { className: "rounded-xl border border-slate-200 bg-white px-5 py-5", children: /* @__PURE__ */ jsx(GridContainer, { children: (Ue) => Te.map((Re) => {
19821
19821
  var kt, ns;
19822
19822
  if (Re._t === "owners") {
19823
- const Qt = Re.slot.col_span ?? 12;
19824
- return /* @__PURE__ */ jsx("div", { style: { gridColumn: `span ${Qt}` }, children: /* @__PURE__ */ jsx(OwnersInline, { collection: e, itemId: g, label: Re.slot.label_override || "Owners" }) }, "__owners__");
19823
+ const Ut = Re.slot.col_span ?? 12;
19824
+ return /* @__PURE__ */ jsx("div", { style: { gridColumn: `span ${Ut}` }, children: /* @__PURE__ */ jsx(OwnersInline, { collection: e, itemId: g, label: Re.slot.label_override || "Owners" }) }, "__owners__");
19825
19825
  }
19826
19826
  if (Re._t === "pdf") {
19827
19827
  if (!L) return null;
19828
- const Qt = Re.slot.col_span ?? 12, vs = ((kt = Re.slot.label_override) == null ? void 0 : kt.trim()) || "Generate PDF", Ys = !Cn;
19829
- return /* @__PURE__ */ jsx("div", { style: { gridColumn: `span ${Qt}` }, children: /* @__PURE__ */ jsxs(
19828
+ const Ut = Re.slot.col_span ?? 12, vs = ((kt = Re.slot.label_override) == null ? void 0 : kt.trim()) || "Generate PDF", Ys = !Cn;
19829
+ return /* @__PURE__ */ jsx("div", { style: { gridColumn: `span ${Ut}` }, children: /* @__PURE__ */ jsxs(
19830
19830
  "button",
19831
19831
  {
19832
19832
  type: "button",
@@ -19846,8 +19846,8 @@ function ItemEditForm({
19846
19846
  }
19847
19847
  if (Re._t === "widget") {
19848
19848
  if (!Re.slot.widget_id) return null;
19849
- const Qt = Re.slot.col_span ?? 12;
19850
- return /* @__PURE__ */ jsx("div", { style: { gridColumn: `span ${Qt}` }, children: /* @__PURE__ */ jsx(
19849
+ const Ut = Re.slot.col_span ?? 12;
19850
+ return /* @__PURE__ */ jsx("div", { style: { gridColumn: `span ${Ut}` }, children: /* @__PURE__ */ jsx(
19851
19851
  WidgetSlot,
19852
19852
  {
19853
19853
  widgetId: Re.slot.widget_id,
@@ -19858,8 +19858,8 @@ function ItemEditForm({
19858
19858
  }
19859
19859
  ) }, Re.slot.field);
19860
19860
  }
19861
- const He = Re.f, Ze = qn == null ? void 0 : qn[He.field], Ge = Ze == null ? void 0 : Ze.entries, We = (Ze == null ? void 0 : Ze.separator) ?? null, Pe = ce[He.field], tt = Pe != null && Pe !== "", yt = Ge != null && Ge.length && tt ? ((ns = E.find((Qt) => Qt.many_collection === e && Qt.many_field === He.field && !Qt.junction_field)) == null ? void 0 : ns.one_collection) ?? null : null;
19862
- return /* @__PURE__ */ jsxs("div", { style: { gridColumn: `span ${resolveColSpan(He.options, Qe)}` }, children: [
19861
+ const He = Re.f, Ze = qn == null ? void 0 : qn[He.field], Ge = Ze == null ? void 0 : Ze.entries, We = (Ze == null ? void 0 : Ze.separator) ?? null, Pe = ce[He.field], tt = Pe != null && Pe !== "", yt = Ge != null && Ge.length && tt ? ((ns = E.find((Ut) => Ut.many_collection === e && Ut.many_field === He.field && !Ut.junction_field)) == null ? void 0 : ns.one_collection) ?? null : null;
19862
+ return /* @__PURE__ */ jsxs("div", { style: { gridColumn: `span ${resolveColSpan(He.options, Ue)}` }, children: [
19863
19863
  /* @__PURE__ */ jsx(
19864
19864
  FieldRow,
19865
19865
  {
@@ -19889,7 +19889,7 @@ function ItemEditForm({
19889
19889
  ] }, He.field);
19890
19890
  }) }) });
19891
19891
  }
19892
- function Qa() {
19892
+ function Ua() {
19893
19893
  var P;
19894
19894
  const T = [
19895
19895
  ...ct.length > 0 ? [{ key: "__general__", label: "General" }] : [],
@@ -19942,8 +19942,8 @@ function ItemEditForm({
19942
19942
  )
19943
19943
  ] });
19944
19944
  }
19945
- function Ua() {
19946
- var Qe;
19945
+ function Qa() {
19946
+ var Ue;
19947
19947
  const T = Bt.findIndex((Re) => Re.key === Ct), P = T === Bt.length - 1, se = /* @__PURE__ */ jsx("div", { className: "mt-6 border-t border-slate-200 pt-4", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
19948
19948
  /* @__PURE__ */ jsxs(
19949
19949
  "button",
@@ -20034,7 +20034,7 @@ function ItemEditForm({
20034
20034
  {
20035
20035
  collection: e,
20036
20036
  item: g,
20037
- addendumLayoutId: ((Qe = j == null ? void 0 : j.layout) == null ? void 0 : Qe.addendum_layout_id) ?? null,
20037
+ addendumLayoutId: ((Ue = j == null ? void 0 : j.layout) == null ? void 0 : Ue.addendum_layout_id) ?? null,
20038
20038
  canCreate: en,
20039
20039
  onActiveCountChange: ae,
20040
20040
  onApplied: () => {
@@ -20065,7 +20065,7 @@ function ItemEditForm({
20065
20065
  ] })
20066
20066
  ] });
20067
20067
  const Ta = (ie == null ? void 0 : ie.display_name) ?? titleCase$2(e ?? ""), Wa = (ie == null ? void 0 : ie.singular) || Ta, ha = !b && ke && (ie != null && ie.display_template) ? applyDisplayTemplate(ie.display_template, ke) : Ta, qa = !b && F && Dn;
20068
- return /* @__PURE__ */ jsx(ReimportHandlerContext.Provider, { value: b ? null : wn, children: /* @__PURE__ */ jsx(RelationPathDataContext.Provider, { value: _s, children: /* @__PURE__ */ jsx(AddendumO2MContext.Provider, { value: yn, children: /* @__PURE__ */ jsx(AddendumViewContext.Provider, { value: B, children: /* @__PURE__ */ jsx(AddendumFieldContext.Provider, { value: Un, children: /* @__PURE__ */ jsx(ParentDraftContext.Provider, { value: { draft: nn, collection: e, dirtyFields: Ne.current }, children: /* @__PURE__ */ jsx(GridFlushContext.Provider, { value: b ? null : Je, children: /* @__PURE__ */ jsx(O2MStagingContext.Provider, { value: Ue, children: /* @__PURE__ */ jsxs(M2MStagingContext.Provider, { value: dt, children: [
20068
+ return /* @__PURE__ */ jsx(ReimportHandlerContext.Provider, { value: b ? null : wn, children: /* @__PURE__ */ jsx(RelationPathDataContext.Provider, { value: _s, children: /* @__PURE__ */ jsx(AddendumO2MContext.Provider, { value: yn, children: /* @__PURE__ */ jsx(AddendumViewContext.Provider, { value: B, children: /* @__PURE__ */ jsx(AddendumFieldContext.Provider, { value: Qn, children: /* @__PURE__ */ jsx(ParentDraftContext.Provider, { value: { draft: nn, collection: e, dirtyFields: Ne.current }, children: /* @__PURE__ */ jsx(GridFlushContext.Provider, { value: b ? null : Je, children: /* @__PURE__ */ jsx(O2MStagingContext.Provider, { value: Qe, children: /* @__PURE__ */ jsxs(M2MStagingContext.Provider, { value: dt, children: [
20069
20069
  /* @__PURE__ */ jsx(TipLayer, {}),
20070
20070
  /* @__PURE__ */ jsx(
20071
20071
  SaveProgressDialog,
@@ -20198,7 +20198,7 @@ function ItemEditForm({
20198
20198
  ] })
20199
20199
  ] }),
20200
20200
  /* @__PURE__ */ jsxs("div", { className: "ml-auto flex items-center gap-1.5", children: [
20201
- b && /* @__PURE__ */ jsx(ImportFromFileButton, { collection: e, onParsed: Ut }),
20201
+ b && /* @__PURE__ */ jsx(ImportFromFileButton, { collection: e, onParsed: Qt }),
20202
20202
  !b && /* @__PURE__ */ jsx(
20203
20203
  ImportFromFileButton,
20204
20204
  {
@@ -20428,7 +20428,7 @@ function ItemEditForm({
20428
20428
  }), xt(We), setTimeout(() => xt((kt) => kt === We ? null : kt), 1500));
20429
20429
  };
20430
20430
  if (T.type === "widget") {
20431
- const Ge = T.data, We = U[Ge.field] === "button-group";
20431
+ const Ge = T.data, We = Q[Ge.field] === "button-group";
20432
20432
  return /* @__PURE__ */ jsxs("div", { className: "group relative self-stretch border-r border-slate-200 dark:border-border", children: [
20433
20433
  /* @__PURE__ */ jsx(
20434
20434
  WidgetSlot,
@@ -20469,7 +20469,7 @@ function ItemEditForm({
20469
20469
  }
20470
20470
  )
20471
20471
  ] }, "__owners__");
20472
- const se = rs[W.field], re = se ? se.ids : ks[W.field], Te = ls && !se && ys != null && W.field in ys && String(ce[W.field] ?? "") !== String(ys[W.field] ?? "") ? "text-amber-600 dark:text-amber-400" : W.color === "cyan" ? "text-nvr-cyan" : W.color === "blue" ? "text-blue-600 dark:text-blue-400" : W.color === "green" ? "text-emerald-600 dark:text-emerald-400" : W.color === "amber" ? "text-amber-600 dark:text-amber-400" : W.color === "red" ? "text-red-600 dark:text-red-400" : W.color === "purple" ? "text-purple-600 dark:text-purple-400" : "text-slate-900 dark:text-slate-100", Qe = W.weight === "bold" ? "font-bold" : W.weight === "semibold" ? "font-semibold" : W.weight === "medium" ? "font-medium" : "font-semibold", Re = `${Te} ${Qe}`, He = W.displayAs === "pill", Ze = W.displayAs === "tag";
20472
+ const se = rs[W.field], re = se ? se.ids : ks[W.field], Te = ls && !se && ys != null && W.field in ys && String(ce[W.field] ?? "") !== String(ys[W.field] ?? "") ? "text-amber-600 dark:text-amber-400" : W.color === "cyan" ? "text-nvr-cyan" : W.color === "blue" ? "text-blue-600 dark:text-blue-400" : W.color === "green" ? "text-emerald-600 dark:text-emerald-400" : W.color === "amber" ? "text-amber-600 dark:text-amber-400" : W.color === "red" ? "text-red-600 dark:text-red-400" : W.color === "purple" ? "text-purple-600 dark:text-purple-400" : "text-slate-900 dark:text-slate-100", Ue = W.weight === "bold" ? "font-bold" : W.weight === "semibold" ? "font-semibold" : W.weight === "medium" ? "font-medium" : "font-semibold", Re = `${Te} ${Ue}`, He = W.displayAs === "pill", Ze = W.displayAs === "tag";
20473
20473
  return /* @__PURE__ */ jsxs(
20474
20474
  "div",
20475
20475
  {
@@ -20546,7 +20546,7 @@ function ItemEditForm({
20546
20546
  isAdmin: F
20547
20547
  }
20548
20548
  ),
20549
- ze ? ws ? Ua() : Qa() : Ka(),
20549
+ ze ? ws ? Qa() : Ua() : Ka(),
20550
20550
  S
20551
20551
  ]
20552
20552
  }
@@ -21099,7 +21099,7 @@ function ImportWizard({
21099
21099
  onSuccess: (V) => t(V.data.id),
21100
21100
  onError: (V) => N(V.message)
21101
21101
  });
21102
- function Q(V, oe) {
21102
+ function U(V, oe) {
21103
21103
  k((ye) => ({ ...ye, [V]: oe })), w[V] !== void 0 && x((ye) => {
21104
21104
  const he = { ...ye };
21105
21105
  return delete he[V], he;
@@ -21111,7 +21111,7 @@ function ImportWizard({
21111
21111
  const z = q.filter((V) => {
21112
21112
  var oe;
21113
21113
  return (oe = _[V]) == null ? void 0 : oe.trim();
21114
- }).length, U = a === 0 ? q.length > 0 : a === 1 ? !!m && z > 0 : !0;
21114
+ }).length, Q = a === 0 ? q.length > 0 : a === 1 ? !!m && z > 0 : !0;
21115
21115
  return /* @__PURE__ */ jsxs("div", { className: "flex min-h-0 flex-1 flex-col gap-4", children: [
21116
21116
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
21117
21117
  /* @__PURE__ */ jsxs(Button, { variant: "ghost", size: "sm", className: "h-7 px-2", onClick: e, children: [
@@ -21295,7 +21295,7 @@ val1,val2,val3`,
21295
21295
  PickCombobox,
21296
21296
  {
21297
21297
  value: _[V] ?? "",
21298
- onChange: (oe) => Q(V, oe),
21298
+ onChange: (oe) => U(V, oe),
21299
21299
  options: [
21300
21300
  { value: "", label: "— skip this column —" },
21301
21301
  ...I.map((oe) => ({ value: oe, label: oe }))
@@ -21306,7 +21306,7 @@ val1,val2,val3`,
21306
21306
  Input,
21307
21307
  {
21308
21308
  value: _[V] ?? "",
21309
- onChange: (oe) => Q(V, oe.target.value),
21309
+ onChange: (oe) => U(V, oe.target.value),
21310
21310
  placeholder: "field_name",
21311
21311
  className: "h-8 font-mono text-[12px]"
21312
21312
  }
@@ -21407,7 +21407,7 @@ val1,val2,val3`,
21407
21407
  v && /* @__PURE__ */ jsx("p", { className: "text-[12px] text-red-600 dark:text-red-400", children: v }),
21408
21408
  /* @__PURE__ */ jsxs("div", { className: "ml-auto flex items-center gap-2", children: [
21409
21409
  /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", onClick: e, children: "Cancel" }),
21410
- a < STEPS.length - 1 ? /* @__PURE__ */ jsxs(Button, { size: "sm", disabled: !U, onClick: () => r((V) => V + 1), children: [
21410
+ a < STEPS.length - 1 ? /* @__PURE__ */ jsxs(Button, { size: "sm", disabled: !Q, onClick: () => r((V) => V + 1), children: [
21411
21411
  "Next ",
21412
21412
  /* @__PURE__ */ jsx(ArrowRight, { className: "h-3.5 w-3.5" })
21413
21413
  ] }) : /* @__PURE__ */ jsx(Button, { size: "sm", disabled: K.isPending, onClick: () => K.mutate(), children: K.isPending ? /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -22301,7 +22301,7 @@ function ImportConsole({
22301
22301
  ), M = useQuery({
22302
22302
  queryKey: ["staged-import-stats", f],
22303
22303
  queryFn: () => a.request(get$1("/staged-imports/stats", { days: f }))
22304
- }), E = (ke = M.data) == null ? void 0 : ke.data, Q = ((E == null ? void 0 : E.active.length) ?? 0) > 0 ? LIVE_POLL_MS : IDLE_POLL_MS, ie = useQuery({
22304
+ }), E = (ke = M.data) == null ? void 0 : ke.data, U = ((E == null ? void 0 : E.active.length) ?? 0) > 0 ? LIVE_POLL_MS : IDLE_POLL_MS, ie = useQuery({
22305
22305
  queryKey: ["staged-import-runs", m, _, L, u, f],
22306
22306
  queryFn: () => a.request(
22307
22307
  get$1("/staged-imports", {
@@ -22313,15 +22313,15 @@ function ImportConsole({
22313
22313
  ...L.trim() ? { search: L.trim() } : {}
22314
22314
  })
22315
22315
  ),
22316
- refetchInterval: Q,
22316
+ refetchInterval: U,
22317
22317
  // Refetching must not blank the table out from under someone reading it.
22318
22318
  placeholderData: (me) => me
22319
22319
  }), z = ((G = ie.data) == null ? void 0 : G.data) ?? [];
22320
- function U() {
22320
+ function Q() {
22321
22321
  r.invalidateQueries({ queryKey: ["staged-import-runs"] }), r.invalidateQueries({ queryKey: ["staged-import-stats"] }), r.invalidateQueries({ queryKey: ["collection-import-jobs"] });
22322
22322
  }
22323
- const ee = useRef(U);
22324
- ee.current = U, useEffect(() => {
22323
+ const ee = useRef(Q);
22324
+ ee.current = Q, useEffect(() => {
22325
22325
  if (e)
22326
22326
  return e.subscribe((me) => {
22327
22327
  j((ce) => ({
@@ -22333,13 +22333,13 @@ function ImportConsole({
22333
22333
  const le = (E == null ? void 0 : E.by_status) ?? {}, J = (E == null ? void 0 : E.active) ?? [], V = J.find((me) => me.status === "running") ?? J[0], oe = J.filter((me) => me.id !== (V == null ? void 0 : V.id)).length, ye = (E == null ? void 0 : E.by_key) ?? {}, he = useMutation({
22334
22334
  mutationFn: (me) => a.request(post$1(`/staged-imports/${me}/requeue`)),
22335
22335
  onSuccess: () => {
22336
- g(null), U();
22336
+ g(null), Q();
22337
22337
  },
22338
22338
  onError: (me) => g(me.message)
22339
22339
  }), de = useMutation({
22340
22340
  mutationFn: (me) => a.request(post$1(`/staged-imports/${me}/cancel`)),
22341
22341
  onSuccess: () => {
22342
- g(null), U();
22342
+ g(null), Q();
22343
22343
  },
22344
22344
  onError: (me) => g(me.message)
22345
22345
  }), ae = [
@@ -22486,7 +22486,7 @@ function ImportConsole({
22486
22486
  variant: "ghost",
22487
22487
  size: "sm",
22488
22488
  className: "h-7 px-2",
22489
- onClick: U,
22489
+ onClick: Q,
22490
22490
  "aria-label": "Refresh",
22491
22491
  children: /* @__PURE__ */ jsx(
22492
22492
  RefreshCw,
@@ -22682,7 +22682,7 @@ function ImportConsole({
22682
22682
  onOpenChange: F,
22683
22683
  definitions: I.filter((me) => me.is_active),
22684
22684
  onQueued: (me) => {
22685
- U(), N(me);
22685
+ Q(), N(me);
22686
22686
  }
22687
22687
  }
22688
22688
  )
@@ -23616,8 +23616,8 @@ function ChildTable({
23616
23616
  ];
23617
23617
  for (const [I, M] of Object.entries(k)) {
23618
23618
  if (!(M != null && M.value.trim())) continue;
23619
- const E = M.value.trim(), K = Number(E), Q = M.op === "_contains" ? E : E === "true" || E === "false" ? E === "true" : Number.isNaN(K) ? E : K;
23620
- A.push({ path: [I], op: M.op, value: Q });
23619
+ const E = M.value.trim(), K = Number(E), U = M.op === "_contains" ? E : E === "true" || E === "false" ? E === "true" : Number.isNaN(K) ? E : K;
23620
+ A.push({ path: [I], op: M.op, value: U });
23621
23621
  }
23622
23622
  return JSON.stringify(A);
23623
23623
  }, [k, t, s]), x = 25, { data: u, isLoading: S, isFetching: f } = useQuery({
@@ -24080,9 +24080,9 @@ function RowActionsMenu({
24080
24080
  useEffect(() => {
24081
24081
  if (!p) return;
24082
24082
  const A = (M) => {
24083
- var K, Q;
24083
+ var K, U;
24084
24084
  const E = M.target;
24085
- !((K = w.current) != null && K.contains(E)) && !((Q = k.current) != null && Q.contains(E)) && m(!1);
24085
+ !((K = w.current) != null && K.contains(E)) && !((U = k.current) != null && U.contains(E)) && m(!1);
24086
24086
  }, I = (M) => {
24087
24087
  M.key === "Escape" && m(!1);
24088
24088
  };
@@ -24109,13 +24109,13 @@ function RowActionsMenu({
24109
24109
  if (A.has(K))
24110
24110
  A.get(K).push(E);
24111
24111
  else {
24112
- const Q = [E];
24113
- A.set(K, Q), I.push({ key: `g:${K}`, label: K, options: Q });
24112
+ const U = [E];
24113
+ A.set(K, U), I.push({ key: `g:${K}`, label: K, options: U });
24114
24114
  }
24115
24115
  }
24116
24116
  for (const E of I)
24117
24117
  E.options.length > 1 && E.options.sort(
24118
- (K, Q) => (f.get(K.to_state ?? "") ?? 999) - (f.get(Q.to_state ?? "") ?? 999)
24118
+ (K, U) => (f.get(K.to_state ?? "") ?? 999) - (f.get(U.to_state ?? "") ?? 999)
24119
24119
  );
24120
24120
  return I;
24121
24121
  }, [u, f]), v = (A) => {
@@ -24135,7 +24135,7 @@ function RowActionsMenu({
24135
24135
  const I = A.getBoundingClientRect();
24136
24136
  let { x: M, y: E } = h;
24137
24137
  if (I.right > window.innerWidth - 8 && (M = Math.max(8, window.innerWidth - I.width - 8)), I.bottom > window.innerHeight - 8) {
24138
- const Q = (K = k.current) == null ? void 0 : K.getBoundingClientRect(), ie = ((Q == null ? void 0 : Q.top) ?? E) - I.height - 4;
24138
+ const U = (K = k.current) == null ? void 0 : K.getBoundingClientRect(), ie = ((U == null ? void 0 : U.top) ?? E) - I.height - 4;
24139
24139
  E = ie >= 8 ? ie : Math.max(8, window.innerHeight - I.height - 8);
24140
24140
  }
24141
24141
  (M !== h.x || E !== h.y) && _({ x: M, y: E });
@@ -25118,24 +25118,24 @@ function FilterBar({
25118
25118
  }), [m, h] = useState(null), [_, k] = useState("_contains"), [w, x] = useState(""), [u, S] = useState(""), [f, y] = useState([]), [v, N] = useState({}), [C, F] = useState(null), q = useRef(null);
25119
25119
  useEffect(() => {
25120
25120
  if (!l) return;
25121
- const Q = (z) => {
25122
- var U;
25123
- (U = q.current) != null && U.contains(z.target) || i(!1);
25121
+ const U = (z) => {
25122
+ var Q;
25123
+ (Q = q.current) != null && Q.contains(z.target) || i(!1);
25124
25124
  }, ie = (z) => {
25125
25125
  z.key === "Escape" && i(!1);
25126
25126
  };
25127
- return window.addEventListener("mousedown", Q), window.addEventListener("keydown", ie), () => {
25128
- window.removeEventListener("mousedown", Q), window.removeEventListener("keydown", ie);
25127
+ return window.addEventListener("mousedown", U), window.addEventListener("keydown", ie), () => {
25128
+ window.removeEventListener("mousedown", U), window.removeEventListener("keydown", ie);
25129
25129
  };
25130
25130
  }, [l]);
25131
25131
  const g = () => {
25132
25132
  d(""), p({ collection: e, path: [], pathLabels: [] }), h(null), k("_contains"), x(""), S(""), y([]), N({}), F(null);
25133
25133
  }, b = () => {
25134
25134
  g(), i(!0);
25135
- }, j = (Q) => {
25136
- r(C ? a.map((ie) => ie.id === C ? { ...Q, id: C } : ie) : [...a, { ...Q, id: crypto.randomUUID() }]), i(!1), g();
25137
- }, L = (Q, ie) => {
25138
- m && j({ path: m.path, pathLabels: m.pathLabels, fieldType: m.fieldType, op: Q, value: ie });
25135
+ }, j = (U) => {
25136
+ r(C ? a.map((ie) => ie.id === C ? { ...U, id: C } : ie) : [...a, { ...U, id: crypto.randomUUID() }]), i(!1), g();
25137
+ }, L = (U, ie) => {
25138
+ m && j({ path: m.path, pathLabels: m.pathLabels, fieldType: m.fieldType, op: U, value: ie });
25139
25139
  }, A = () => {
25140
25140
  !m || f.length === 0 || j({
25141
25141
  path: m.path,
@@ -25143,27 +25143,27 @@ function FilterBar({
25143
25143
  fieldType: "relation",
25144
25144
  op: "_in",
25145
25145
  value: f,
25146
- valueLabels: f.map((Q) => v[String(Q)] ?? String(Q)),
25146
+ valueLabels: f.map((U) => v[String(U)] ?? String(U)),
25147
25147
  relTarget: m.relTarget
25148
25148
  });
25149
- }, I = (Q) => {
25150
- if (i(!0), d(""), p({ collection: e, path: [], pathLabels: [] }), F(Q.id), Array.isArray(Q.value)) {
25151
- h({ path: Q.path, pathLabels: Q.pathLabels, fieldType: "relation", relTarget: Q.relTarget }), y(Q.value);
25149
+ }, I = (U) => {
25150
+ if (i(!0), d(""), p({ collection: e, path: [], pathLabels: [] }), F(U.id), Array.isArray(U.value)) {
25151
+ h({ path: U.path, pathLabels: U.pathLabels, fieldType: "relation", relTarget: U.relTarget }), y(U.value);
25152
25152
  const ie = {};
25153
- Q.value.forEach((z, U) => {
25153
+ U.value.forEach((z, Q) => {
25154
25154
  var ee;
25155
- ie[String(z)] = ((ee = Q.valueLabels) == null ? void 0 : ee[U]) ?? String(z);
25155
+ ie[String(z)] = ((ee = U.valueLabels) == null ? void 0 : ee[Q]) ?? String(z);
25156
25156
  }), N(ie);
25157
- } else if (h({ path: Q.path, pathLabels: Q.pathLabels, fieldType: Q.fieldType }), k(Q.op), Q.op === "_between") {
25158
- const [ie, z] = String(Q.value).split("..");
25157
+ } else if (h({ path: U.path, pathLabels: U.pathLabels, fieldType: U.fieldType }), k(U.op), U.op === "_between") {
25158
+ const [ie, z] = String(U.value).split("..");
25159
25159
  x(ie ?? ""), S(z ?? "");
25160
25160
  } else
25161
- x(String(Q.value ?? ""));
25161
+ x(String(U.value ?? ""));
25162
25162
  }, M = (() => {
25163
25163
  if (!m) return null;
25164
25164
  if (m.relTarget !== void 0) return "relation";
25165
- const Q = m.fieldType;
25166
- return Q === "integer" || Q === "decimal" || Q === "float" ? "number" : Q === "date" || Q === "datetime" || Q === "timestamp" ? "date" : Q === "boolean" ? "boolean" : "string";
25165
+ const U = m.fieldType;
25166
+ return U === "integer" || U === "decimal" || U === "float" ? "number" : U === "date" || U === "datetime" || U === "timestamp" ? "date" : U === "boolean" ? "boolean" : "string";
25167
25167
  })(), E = NUM_FILTER_OPS, K = [
25168
25168
  { value: "_contains", label: "Contains" },
25169
25169
  { value: "_ncontains", label: "Doesn't contain" },
@@ -25185,21 +25185,21 @@ function FilterBar({
25185
25185
  "input",
25186
25186
  {
25187
25187
  value: s,
25188
- onChange: (Q) => n(Q.target.value),
25188
+ onChange: (U) => n(U.target.value),
25189
25189
  placeholder: "Search…",
25190
25190
  "aria-label": `Search ${e}`,
25191
25191
  className: "h-8 w-48 rounded-md border border-slate-200 bg-white pl-8 pr-3 text-[13px] outline-none focus:border-[#00ceff80] focus:ring-2 focus:ring-[#00ceff4d] dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100"
25192
25192
  }
25193
25193
  )
25194
25194
  ] }),
25195
- a.map((Q) => {
25196
- const ie = filterChipText(Q);
25195
+ a.map((U) => {
25196
+ const ie = filterChipText(U);
25197
25197
  return /* @__PURE__ */ jsxs(
25198
25198
  "span",
25199
25199
  {
25200
25200
  className: "inline-flex items-center gap-1.5 rounded-md border border-slate-200 bg-white px-2 py-1 text-[12px] transition-colors hover:border-[#00ceff66] dark:border-slate-700 dark:bg-slate-900",
25201
25201
  children: [
25202
- /* @__PURE__ */ jsxs("button", { type: "button", onClick: () => I(Q), className: "inline-flex items-center gap-1.5", children: [
25202
+ /* @__PURE__ */ jsxs("button", { type: "button", onClick: () => I(U), className: "inline-flex items-center gap-1.5", children: [
25203
25203
  /* @__PURE__ */ jsx("span", { className: "text-slate-500", children: ie.field }),
25204
25204
  /* @__PURE__ */ jsx("span", { className: "font-semibold text-slate-700 dark:text-slate-200", children: ie.op }),
25205
25205
  ie.value && /* @__PURE__ */ jsx("span", { className: "text-[#00a5cc] dark:text-[#00ceff]", children: ie.value })
@@ -25208,7 +25208,7 @@ function FilterBar({
25208
25208
  "button",
25209
25209
  {
25210
25210
  type: "button",
25211
- onClick: () => r(a.filter((z) => z.id !== Q.id)),
25211
+ onClick: () => r(a.filter((z) => z.id !== U.id)),
25212
25212
  "aria-label": "Remove filter",
25213
25213
  className: "text-slate-400 hover:text-red-500",
25214
25214
  children: "✕"
@@ -25216,7 +25216,7 @@ function FilterBar({
25216
25216
  )
25217
25217
  ]
25218
25218
  },
25219
- Q.id
25219
+ U.id
25220
25220
  );
25221
25221
  }),
25222
25222
  /* @__PURE__ */ jsxs("div", { className: "relative", ref: q, children: [
@@ -25247,7 +25247,7 @@ function FilterBar({
25247
25247
  {
25248
25248
  autoFocus: !0,
25249
25249
  value: o,
25250
- onChange: (Q) => d(Q.target.value),
25250
+ onChange: (U) => d(U.target.value),
25251
25251
  placeholder: "Find field…",
25252
25252
  className: "h-8 w-full rounded-lg border-2 border-[#00ceff80] bg-white px-2.5 text-[12.5px] outline-none placeholder:text-slate-400 focus:ring-2 focus:ring-[#00ceff33] dark:border-[#00ceff66] dark:bg-slate-800 dark:text-slate-100"
25253
25253
  }
@@ -25260,12 +25260,12 @@ function FilterBar({
25260
25260
  pathLabels: c.pathLabels,
25261
25261
  search: o,
25262
25262
  depth: c.path.length,
25263
- onDrill: (Q, ie, z) => {
25264
- p({ collection: Q, path: ie, pathLabels: z }), d("");
25263
+ onDrill: (U, ie, z) => {
25264
+ p({ collection: U, path: ie, pathLabels: z }), d("");
25265
25265
  },
25266
- onPick: (Q) => {
25267
- h(Q), k(
25268
- Q.fieldType === "integer" || Q.fieldType === "decimal" || Q.fieldType === "float" ? "_eq" : "_contains"
25266
+ onPick: (U) => {
25267
+ h(U), k(
25268
+ U.fieldType === "integer" || U.fieldType === "decimal" || U.fieldType === "float" ? "_eq" : "_contains"
25269
25269
  );
25270
25270
  }
25271
25271
  }
@@ -25292,10 +25292,10 @@ function FilterBar({
25292
25292
  target: m.relTarget,
25293
25293
  selected: f,
25294
25294
  labels: v,
25295
- onToggle: (Q, ie) => {
25295
+ onToggle: (U, ie) => {
25296
25296
  y(
25297
- (z) => z.map(String).includes(String(Q)) ? z.filter((U) => String(U) !== String(Q)) : [...z, Q]
25298
- ), N((z) => ({ ...z, [String(Q)]: ie }));
25297
+ (z) => z.map(String).includes(String(U)) ? z.filter((Q) => String(Q) !== String(U)) : [...z, U]
25298
+ ), N((z) => ({ ...z, [String(U)]: ie }));
25299
25299
  }
25300
25300
  }
25301
25301
  ),
@@ -25316,28 +25316,28 @@ function FilterBar({
25316
25316
  { label: "Yes", op: "_eq:true" },
25317
25317
  { label: "No", op: "_eq:false" },
25318
25318
  { label: "Empty", op: "_null" }
25319
- ].map((Q) => /* @__PURE__ */ jsx(
25319
+ ].map((U) => /* @__PURE__ */ jsx(
25320
25320
  "button",
25321
25321
  {
25322
25322
  type: "button",
25323
- onClick: () => L(Q.op.includes(":") ? Q.op.split(":")[0] : Q.op, Q.op.includes(":") ? Q.op.split(":")[1] : ""),
25323
+ onClick: () => L(U.op.includes(":") ? U.op.split(":")[0] : U.op, U.op.includes(":") ? U.op.split(":")[1] : ""),
25324
25324
  className: "h-8 flex-1 rounded-md border border-slate-200 text-[12.5px] text-slate-600 hover:border-[#00ceff66] hover:bg-[#00ceff0d] dark:border-slate-700 dark:text-slate-300",
25325
- children: Q.label
25325
+ children: U.label
25326
25326
  },
25327
- Q.op
25327
+ U.op
25328
25328
  )) }) : M === "date" ? /* @__PURE__ */ jsxs("div", { className: "space-y-2 p-3", children: [
25329
- /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1", children: DATE_PRESETS$1.filter((Q) => Q.value).map((Q) => /* @__PURE__ */ jsx(
25329
+ /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1", children: DATE_PRESETS$1.filter((U) => U.value).map((U) => /* @__PURE__ */ jsx(
25330
25330
  "button",
25331
25331
  {
25332
25332
  type: "button",
25333
25333
  onClick: () => {
25334
- const ie = dateRangeFor(Q.value);
25334
+ const ie = dateRangeFor(U.value);
25335
25335
  ie && L("_between", `${ie.from}..${ie.to}`);
25336
25336
  },
25337
25337
  className: "rounded-md border border-slate-200 px-2 py-1 text-[11.5px] text-slate-600 hover:border-[#00ceff66] hover:bg-[#00ceff0d] dark:border-slate-700 dark:text-slate-300",
25338
- children: Q.label
25338
+ children: U.label
25339
25339
  },
25340
- Q.value
25340
+ U.value
25341
25341
  )) }),
25342
25342
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
25343
25343
  /* @__PURE__ */ jsx(
@@ -25345,7 +25345,7 @@ function FilterBar({
25345
25345
  {
25346
25346
  type: "date",
25347
25347
  value: w,
25348
- onChange: (Q) => x(Q.target.value),
25348
+ onChange: (U) => x(U.target.value),
25349
25349
  "aria-label": "From date",
25350
25350
  className: "h-8 min-w-0 flex-1 rounded-md border border-slate-200 bg-white px-2 text-[12px] dark:border-slate-700 dark:bg-slate-800 dark:text-slate-100"
25351
25351
  }
@@ -25356,7 +25356,7 @@ function FilterBar({
25356
25356
  {
25357
25357
  type: "date",
25358
25358
  value: u,
25359
- onChange: (Q) => S(Q.target.value),
25359
+ onChange: (U) => S(U.target.value),
25360
25360
  "aria-label": "To date",
25361
25361
  className: "h-8 min-w-0 flex-1 rounded-md border border-slate-200 bg-white px-2 text-[12px] dark:border-slate-700 dark:bg-slate-800 dark:text-slate-100"
25362
25362
  }
@@ -25378,21 +25378,21 @@ function FilterBar({
25378
25378
  "form",
25379
25379
  {
25380
25380
  className: "space-y-2 p-3",
25381
- onSubmit: (Q) => {
25382
- Q.preventDefault(), M === "number" && _ === "_between" ? w !== "" && u !== "" && L("_between", `${w}..${u}`) : w.trim() && L(_, w.trim());
25381
+ onSubmit: (U) => {
25382
+ U.preventDefault(), M === "number" && _ === "_between" ? w !== "" && u !== "" && L("_between", `${w}..${u}`) : w.trim() && L(_, w.trim());
25383
25383
  },
25384
25384
  children: [
25385
25385
  /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
25386
25386
  (M === "number" ? [...E, { value: "_between", label: "Between" }] : K).map(
25387
- (Q) => /* @__PURE__ */ jsx(
25387
+ (U) => /* @__PURE__ */ jsx(
25388
25388
  "button",
25389
25389
  {
25390
25390
  type: "button",
25391
- onClick: () => k(Q.value),
25392
- className: `rounded-md border px-2 py-1 text-[11.5px] ${_ === Q.value ? "border-[#00ceff66] bg-[#00ceff14] font-medium text-slate-800 dark:text-slate-100" : "border-slate-200 text-slate-500 hover:text-slate-700 dark:border-slate-700 dark:text-slate-400"}`,
25393
- children: Q.label
25391
+ onClick: () => k(U.value),
25392
+ className: `rounded-md border px-2 py-1 text-[11.5px] ${_ === U.value ? "border-[#00ceff66] bg-[#00ceff14] font-medium text-slate-800 dark:text-slate-100" : "border-slate-200 text-slate-500 hover:text-slate-700 dark:border-slate-700 dark:text-slate-400"}`,
25393
+ children: U.label
25394
25394
  },
25395
- Q.value
25395
+ U.value
25396
25396
  )
25397
25397
  ),
25398
25398
  /* @__PURE__ */ jsx(
@@ -25421,7 +25421,7 @@ function FilterBar({
25421
25421
  autoFocus: !0,
25422
25422
  type: M === "number" ? "number" : "text",
25423
25423
  value: w,
25424
- onChange: (Q) => x(Q.target.value),
25424
+ onChange: (U) => x(U.target.value),
25425
25425
  placeholder: "Value…",
25426
25426
  className: "h-8 min-w-0 flex-1 rounded-md border border-slate-200 bg-white px-2.5 text-[13px] outline-none focus:border-[#00ceff80] dark:border-slate-700 dark:bg-slate-800 dark:text-slate-100"
25427
25427
  }
@@ -25433,7 +25433,7 @@ function FilterBar({
25433
25433
  {
25434
25434
  type: "number",
25435
25435
  value: u,
25436
- onChange: (Q) => S(Q.target.value),
25436
+ onChange: (U) => S(U.target.value),
25437
25437
  placeholder: "To…",
25438
25438
  className: "h-8 min-w-0 flex-1 rounded-md border border-slate-200 bg-white px-2.5 text-[13px] outline-none focus:border-[#00ceff80] dark:border-slate-700 dark:bg-slate-800 dark:text-slate-100"
25439
25439
  }
@@ -25682,9 +25682,9 @@ function CollectionBrowserView({
25682
25682
  className: d
25683
25683
  }) {
25684
25684
  var D;
25685
- const c = useNivaroClient(), p = useQueryClient(), { open: m, urlFor: h } = useItemNavigation(), [_, k] = useState(1), [w, x] = useState(r), u = useDebounced(w.trim(), 350), [S, f] = useState([]), [y, v] = useState(n ?? ""), [N, C] = useState(s ?? null), [F, q] = useState({}), [g, b] = useState(null), [j, L] = useState({}), [A, I] = useState(null), [M, E] = useState(!1), K = useRef(null), [Q, ie] = useState({}), [z, U] = useState({}), [ee, le] = useState(l ?? []), { scopes: J, ready: V } = useMyScopes(), [oe, ye] = useState(!1), [he, de] = useState(/* @__PURE__ */ new Set()), [ae, B] = useState({}), [ue, Z] = useState(null), [je, _e] = useState(null), [ke, G] = useState(!1), [pe, me] = useState([]), [ce, ve] = useState(null), [Be, Ne] = useState(!1), [Ie, Je] = useState(""), [st, _t] = useState(!1), Ft = useRef(null), $t = useRef(null), ut = useRef(!1), { isAdmin: Nt } = useItemEditAuth(), Rt = useRef(e);
25685
+ const c = useNivaroClient(), p = useQueryClient(), { open: m, urlFor: h } = useItemNavigation(), [_, k] = useState(1), [w, x] = useState(r), u = useDebounced(w.trim(), 350), [S, f] = useState([]), [y, v] = useState(n ?? ""), [N, C] = useState(s ?? null), [F, q] = useState({}), [g, b] = useState(null), [j, L] = useState({}), [A, I] = useState(null), [M, E] = useState(!1), K = useRef(null), [U, ie] = useState({}), [z, Q] = useState({}), [ee, le] = useState(l ?? []), { scopes: J, ready: V } = useMyScopes(), [oe, ye] = useState(!1), [he, de] = useState(/* @__PURE__ */ new Set()), [ae, B] = useState({}), [ue, Z] = useState(null), [je, _e] = useState(null), [ke, G] = useState(!1), [pe, me] = useState([]), [ce, ve] = useState(null), [Be, Ne] = useState(!1), [Ie, Je] = useState(""), [st, _t] = useState(!1), Ft = useRef(null), $t = useRef(null), ut = useRef(!1), { isAdmin: Nt } = useItemEditAuth(), Rt = useRef(e);
25686
25686
  useEffect(() => {
25687
- Rt.current !== e && (Rt.current = e, k(1), x(r), f([]), v(n ?? ""), C(s ?? null), q({}), L({}), me([]), ve(null), ie({}), U({}), B({}), le([]), Z(null), _e(null), ut.current = !1);
25687
+ Rt.current !== e && (Rt.current = e, k(1), x(r), f([]), v(n ?? ""), C(s ?? null), q({}), L({}), me([]), ve(null), ie({}), Q({}), B({}), le([]), Z(null), _e(null), ut.current = !1);
25688
25688
  }, [e]), useEffect(() => {
25689
25689
  if (!ke) return;
25690
25690
  const $ = (H) => {
@@ -25726,7 +25726,7 @@ function CollectionBrowserView({
25726
25726
  (((ot = Ke[ct]) == null ? void 0 : ot.length) ?? 0) > 0 || (Ke[ct] = Kt);
25727
25727
  return Ke;
25728
25728
  };
25729
- ie(be), U(be), de(new Set(Object.keys(fe)));
25729
+ ie(be), Q(be), de(new Set(Object.keys(fe)));
25730
25730
  }
25731
25731
  ye(!0);
25732
25732
  })();
@@ -25771,7 +25771,7 @@ function CollectionBrowserView({
25771
25771
  )
25772
25772
  ],
25773
25773
  [it, Se]
25774
- ), Ue = useQueries({
25774
+ ), Qe = useQueries({
25775
25775
  queries: Le.map(($) => ({
25776
25776
  queryKey: ["cbv-collection-meta", $],
25777
25777
  queryFn: () => c.request(get$1(`/collections/${$}`)).then((H) => H.data),
@@ -25782,9 +25782,9 @@ function CollectionBrowserView({
25782
25782
  const $ = /* @__PURE__ */ new Map();
25783
25783
  return Le.forEach((H, fe) => {
25784
25784
  var be;
25785
- return $.set(H, (be = Ue[fe]) == null ? void 0 : be.data);
25785
+ return $.set(H, (be = Qe[fe]) == null ? void 0 : be.data);
25786
25786
  }), $;
25787
- }, [Le, Ue]), qe = useMemo(() => {
25787
+ }, [Le, Qe]), qe = useMemo(() => {
25788
25788
  const $ = {};
25789
25789
  for (const H of it) {
25790
25790
  const fe = H.info.relation.many_collection ?? "";
@@ -25855,7 +25855,7 @@ function CollectionBrowserView({
25855
25855
  data: lt,
25856
25856
  isLoading: jt,
25857
25857
  isFetching: dt,
25858
- refetch: Ut,
25858
+ refetch: Qt,
25859
25859
  error: es
25860
25860
  } = useQuery({
25861
25861
  queryKey: ["cbv-items", e, u, y, _, Y, mt],
@@ -25939,7 +25939,7 @@ function CollectionBrowserView({
25939
25939
  if (!fe) return null;
25940
25940
  const be = (Ke = Vt == null ? void 0 : Vt.targets) == null ? void 0 : Ke[fe], Ee = ((Kt = (ct = (ot = Vt == null ? void 0 : Vt.rows) == null ? void 0 : ot[String($)]) == null ? void 0 : ct[fe]) == null ? void 0 : Kt.ids) ?? [];
25941
25941
  return !be || isSystemCol(be) || Ee.length === 0 ? null : { target: be, id: String(Ee[0]) };
25942
- }, Qs = ($) => $.includes(".") || $ in qe, an = ($) => {
25942
+ }, Us = ($) => $.includes(".") || $ in qe, an = ($) => {
25943
25943
  if ($.includes(".")) return { kind: "text", path: $.split(".") };
25944
25944
  const H = isM2OField(xt, e, $);
25945
25945
  if (H != null && H.one_collection)
@@ -26042,7 +26042,7 @@ function CollectionBrowserView({
26042
26042
  }, hn = ($, H) => {
26043
26043
  const fe = j[H];
26044
26044
  return fe && $ && $ !== "—" ? formatMultiValue($, fe) : $;
26045
- }, { data: Us = [] } = useQuery({
26045
+ }, { data: Qs = [] } = useQuery({
26046
26046
  queryKey: ["cbv-views", e],
26047
26047
  queryFn: () => c.request(get$1("/saved-views", { collection: e })).then(($) => $.data ?? []),
26048
26048
  staleTime: 3e4
@@ -26059,7 +26059,7 @@ function CollectionBrowserView({
26059
26059
  as(null);
26060
26060
  k(1);
26061
26061
  }, rn = () => {
26062
- const $ = Us.find((H) => H.is_default);
26062
+ const $ = Qs.find((H) => H.is_default);
26063
26063
  if ($) {
26064
26064
  Ws($);
26065
26065
  return;
@@ -26084,11 +26084,11 @@ function CollectionBrowserView({
26084
26084
  ]
26085
26085
  });
26086
26086
  useEffect(() => {
26087
- if (ut.current || Us.length === 0 || Tt.length === 0) return;
26087
+ if (ut.current || Qs.length === 0 || Tt.length === 0) return;
26088
26088
  ut.current = !0;
26089
- const $ = Us.find((H) => H.is_default);
26089
+ const $ = Qs.find((H) => H.is_default);
26090
26090
  $ && ce == null && Ws($);
26091
- }, [Us, Tt]);
26091
+ }, [Qs, Tt]);
26092
26092
  const ps = useMutation({
26093
26093
  mutationFn: () => c.request(
26094
26094
  post$1("/saved-views", { collection: e, name: Ie.trim(), ...xs() })
@@ -26099,12 +26099,12 @@ function CollectionBrowserView({
26099
26099
  }), Mn = useMutation({
26100
26100
  mutationFn: ($) => c.request(patch$1(`/saved-views/${$}`, xs())),
26101
26101
  onSuccess: Cs
26102
- }), Qn = useMutation({
26102
+ }), Un = useMutation({
26103
26103
  mutationFn: ({ id: $, on: H }) => c.request(patch$1(`/saved-views/${$}`, { is_default: H })),
26104
26104
  onSuccess: Cs
26105
26105
  }), Ps = useMutation({
26106
26106
  mutationFn: () => {
26107
- const $ = Us.find((H) => H.is_default);
26107
+ const $ = Qs.find((H) => H.is_default);
26108
26108
  return $ ? c.request(patch$1(`/saved-views/${$.id}`, { ...xs(), is_default: !0 })) : c.request(
26109
26109
  post$1("/saved-views", { collection: e, name: "Default", is_default: !0, ...xs() })
26110
26110
  );
@@ -26175,7 +26175,7 @@ function CollectionBrowserView({
26175
26175
  y === $ ? v(`-${$}`) : y === `-${$}` ? v("") : v($), k(1);
26176
26176
  }, Vs = ms.length > 0 && ms.every(($) => pe.includes($.id)), gs = () => me(
26177
26177
  Vs ? pe.filter(($) => !ms.some((H) => H.id === $)) : [.../* @__PURE__ */ new Set([...pe, ...ms.map(($) => $.id)])]
26178
- ), en = ($) => me((H) => H.includes($) ? H.filter((fe) => fe !== $) : [...H, $]), fs = Ms === 0 ? 0 : (_ - 1) * Y + 1, Un = Math.min(_ * Y, Ms), gn = !!(Jt != null && Jt.instances), _n = (qt ? 1 : 0) + (gn ? 2 : 0) + (Ot ? 1 : 0), ys = [
26178
+ ), en = ($) => me((H) => H.includes($) ? H.filter((fe) => fe !== $) : [...H, $]), fs = Ms === 0 ? 0 : (_ - 1) * Y + 1, Qn = Math.min(_ * Y, Ms), gn = !!(Jt != null && Jt.instances), _n = (qt ? 1 : 0) + (gn ? 2 : 0) + (Ot ? 1 : 0), ys = [
26179
26179
  ...ht.map(($) => ({ key: $, kind: "data" })),
26180
26180
  ...gn ? [
26181
26181
  { key: "__state__", kind: "state" },
@@ -26331,7 +26331,7 @@ function CollectionBrowserView({
26331
26331
  "button",
26332
26332
  {
26333
26333
  type: "button",
26334
- onClick: () => void Ut(),
26334
+ onClick: () => void Qt(),
26335
26335
  "aria-label": "Refresh",
26336
26336
  title: "Refresh",
26337
26337
  className: "flex h-8 w-8 items-center justify-center rounded-md border border-slate-200 text-slate-500 hover:bg-slate-100 hover:text-slate-700 dark:border-slate-700 dark:text-slate-400 dark:hover:bg-slate-800",
@@ -26597,7 +26597,7 @@ function CollectionBrowserView({
26597
26597
  def: $,
26598
26598
  allowedIds: wt($),
26599
26599
  scopeDefault: he.has($.key),
26600
- selected: Q[$.key] ?? [],
26600
+ selected: U[$.key] ?? [],
26601
26601
  onChange: (H) => ie((fe) => ({ ...fe, [$.key]: H }))
26602
26602
  },
26603
26603
  $.key
@@ -26607,7 +26607,7 @@ function CollectionBrowserView({
26607
26607
  {
26608
26608
  type: "button",
26609
26609
  onClick: () => {
26610
- U(Q), k(1);
26610
+ Q(U), k(1);
26611
26611
  },
26612
26612
  className: "h-6 rounded bg-[#00ceff] px-2.5 text-[11px] font-semibold text-white",
26613
26613
  children: "Apply"
@@ -26618,7 +26618,7 @@ function CollectionBrowserView({
26618
26618
  {
26619
26619
  type: "button",
26620
26620
  onClick: () => {
26621
- ie({}), U({}), B({}), k(1);
26621
+ ie({}), Q({}), B({}), k(1);
26622
26622
  },
26623
26623
  className: "h-6 rounded border border-slate-200 px-2 text-[11px] text-slate-500 hover:text-slate-700 dark:border-slate-700 dark:text-slate-400",
26624
26624
  children: "Clear"
@@ -26631,7 +26631,7 @@ function CollectionBrowserView({
26631
26631
  ] })
26632
26632
  ] }),
26633
26633
  /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 flex-wrap items-center gap-1.5 border-b border-slate-100 bg-white px-4 py-1.5 dark:border-slate-800 dark:bg-slate-900", children: [
26634
- !Us.some(($) => $.is_default) && /* @__PURE__ */ jsx(
26634
+ !Qs.some(($) => $.is_default) && /* @__PURE__ */ jsx(
26635
26635
  "button",
26636
26636
  {
26637
26637
  type: "button",
@@ -26640,7 +26640,7 @@ function CollectionBrowserView({
26640
26640
  children: "Default"
26641
26641
  }
26642
26642
  ),
26643
- Us.map(($) => /* @__PURE__ */ jsxs(
26643
+ Qs.map(($) => /* @__PURE__ */ jsxs(
26644
26644
  "span",
26645
26645
  {
26646
26646
  className: `inline-flex h-6 items-center gap-1 rounded-full border px-2.5 text-[12px] transition-colors ${ce === $.id ? "border-[#00ceff66] bg-[#00ceff1a] text-slate-900 dark:text-white" : "border-slate-200 bg-white text-slate-600 hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-300"}`,
@@ -26654,7 +26654,7 @@ function CollectionBrowserView({
26654
26654
  "button",
26655
26655
  {
26656
26656
  type: "button",
26657
- onClick: () => Qn.mutate({ id: $.id, on: !$.is_default }),
26657
+ onClick: () => Un.mutate({ id: $.id, on: !$.is_default }),
26658
26658
  title: $.is_default ? "Unset collection default" : "Make collection default",
26659
26659
  "aria-label": `Toggle default ${$.name}`,
26660
26660
  className: $.is_default ? "text-[#00a5cc]" : "text-slate-400 hover:text-[#00a5cc]",
@@ -26752,7 +26752,7 @@ function CollectionBrowserView({
26752
26752
  H
26753
26753
  );
26754
26754
  }
26755
- const Ke = vt.get(H), ot = Qs(H) || !!(Ke != null && Ke.computed_formula && !Ke.computed_store), ct = !ot && (y === H || y === `-${H}`), Kt = y === `-${H}`, ze = vt.get(H), at = Pt(H);
26755
+ const Ke = vt.get(H), ot = Us(H) || !!(Ke != null && Ke.computed_formula && !Ke.computed_store), ct = !ot && (y === H || y === `-${H}`), Kt = y === `-${H}`, ze = vt.get(H), at = Pt(H);
26756
26756
  return /* @__PURE__ */ jsxs(
26757
26757
  "th",
26758
26758
  {
@@ -26819,7 +26819,7 @@ function CollectionBrowserView({
26819
26819
  {
26820
26820
  type: "button",
26821
26821
  onClick: () => {
26822
- f([]), B({}), ie({}), U({}), x(""), k(1);
26822
+ f([]), B({}), ie({}), Q({}), x(""), k(1);
26823
26823
  },
26824
26824
  className: "mt-1 h-7 rounded-md border border-slate-200 px-3 text-[12px] font-medium text-slate-600 hover:border-[#00ceff66] hover:text-[#00a5cc] dark:border-slate-700 dark:text-slate-300",
26825
26825
  children: "Clear all filters"
@@ -26921,13 +26921,13 @@ function CollectionBrowserView({
26921
26921
  },
26922
26922
  ze
26923
26923
  );
26924
- const at = Qs(ze) ? Nn(H, ze) : null, Gt = Qs(ze) ? null : isM2OField(xt, e, ze);
26924
+ const at = Us(ze) ? Nn(H, ze) : null, Gt = Us(ze) ? null : isM2OField(xt, e, ze);
26925
26925
  return /* @__PURE__ */ jsx(
26926
26926
  "td",
26927
26927
  {
26928
26928
  style: os(ze),
26929
26929
  className: `whitespace-nowrap px-3 py-1.5 ${Zs(ze) ? "text-right" : ""} ${$s(ze, "z-[1]", ot)}`,
26930
- children: Qs(ze) ? fn(ze) === "nivaro_users" ? (() => {
26930
+ children: Us(ze) ? fn(ze) === "nivaro_users" ? (() => {
26931
26931
  var Ds, ln, En;
26932
26932
  const Ts = ze.includes(".") ? ze : qe[ze], Es = ((En = (ln = (Ds = Vt == null ? void 0 : Vt.rows) == null ? void 0 : Ds[String(H)]) == null ? void 0 : ln[Ts]) == null ? void 0 : En.ids) ?? [], Ln = nn(H, ze) ?? "";
26933
26933
  if (Es.length === 0 || !Ln || Ln === "—")
@@ -27011,7 +27011,7 @@ function CollectionBrowserView({
27011
27011
  /* @__PURE__ */ jsxs("span", { className: "font-semibold text-slate-700 dark:text-slate-200", children: [
27012
27012
  fmtNum(fs),
27013
27013
  "–",
27014
- fmtNum(Un)
27014
+ fmtNum(Qn)
27015
27015
  ] }),
27016
27016
  " ",
27017
27017
  "of ",
@@ -27293,7 +27293,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
27293
27293
  queryKey: ["queue-meta", e],
27294
27294
  queryFn: () => a.request(get$1(`/queues/${e}`)).then((D) => D.data),
27295
27295
  enabled: !!e
27296
- }), { scopes: A, ready: I } = useMyScopes(), M = useRef(!1), [E, K] = useState(!1), [Q, ie] = useState({}), z = useRef({});
27296
+ }), { scopes: A, ready: I } = useMyScopes(), M = useRef(!1), [E, K] = useState(!1), [U, ie] = useState({}), z = useRef({});
27297
27297
  useEffect(() => {
27298
27298
  if (M.current || !I || !j) return;
27299
27299
  M.current = !0;
@@ -27339,7 +27339,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
27339
27339
  Object.keys(H).length > 0 && ie(H), Object.keys($).length > 0 && (z.current = $, x((be) => ({ ...be, ...$ }))), K(!0);
27340
27340
  })();
27341
27341
  }, [I, A, j]);
27342
- const U = ((Sn = (os = j == null ? void 0 : j.sources) == null ? void 0 : os.find((D) => D.type === "collection")) == null ? void 0 : Sn.collection) ?? null, ee = (j == null ? void 0 : j.claims_enabled) !== !1, le = j == null ? void 0 : j.display_config, J = (le == null ? void 0 : le.views) ?? ["table", "kanban", "workload"], V = (le == null ? void 0 : le.work_next) !== !1, oe = (le == null ? void 0 : le.bulk_actions) !== !1, ye = (D, $) => {
27342
+ const Q = ((Sn = (os = j == null ? void 0 : j.sources) == null ? void 0 : os.find((D) => D.type === "collection")) == null ? void 0 : Sn.collection) ?? null, ee = (j == null ? void 0 : j.claims_enabled) !== !1, le = j == null ? void 0 : j.display_config, J = (le == null ? void 0 : le.views) ?? ["table", "kanban", "workload"], V = (le == null ? void 0 : le.work_next) !== !1, oe = (le == null ? void 0 : le.bulk_actions) !== !1, ye = (D, $) => {
27343
27343
  var H, fe;
27344
27344
  return ((fe = (H = j == null ? void 0 : j.column_aliases) == null ? void 0 : H[D]) == null ? void 0 : fe.trim()) || $;
27345
27345
  }, he = useRef(!1);
@@ -27553,7 +27553,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
27553
27553
  return H.has(D) ? H.delete(D) : H.add(D), H;
27554
27554
  });
27555
27555
  }
27556
- const Se = useMemo(() => te ? te.filter((D) => !f.has(D.key)).flatMap((D) => D.rows) : qt, [te, qt, f]), Le = (D) => `${D.collection}:${D.item_id}`, [Ue, Ye] = useState(null), [qe, St] = useState(!1), [Et, mt] = useState(null), It = (D) => l.open({
27556
+ const Se = useMemo(() => te ? te.filter((D) => !f.has(D.key)).flatMap((D) => D.rows) : qt, [te, qt, f]), Le = (D) => `${D.collection}:${D.item_id}`, [Qe, Ye] = useState(null), [qe, St] = useState(!1), [Et, mt] = useState(null), It = (D) => l.open({
27557
27557
  collection: D.collection,
27558
27558
  itemId: D.item_id,
27559
27559
  layoutSlug: (le == null ? void 0 : le.item_layout) ?? null
@@ -27577,9 +27577,9 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
27577
27577
  Ye(D);
27578
27578
  };
27579
27579
  useEffect(() => {
27580
- if (!Ue) return;
27581
- const D = qt.find(($) => Le($) === Le(Ue));
27582
- D && D !== Ue && Ye(D);
27580
+ if (!Qe) return;
27581
+ const D = qt.find(($) => Le($) === Le(Qe));
27582
+ D && D !== Qe && Ye(D);
27583
27583
  }, [qt]);
27584
27584
  const jt = (D) => !D.claimed_by || D.claimed_by.id === r;
27585
27585
  function dt(D) {
@@ -27610,7 +27610,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
27610
27610
  $.preventDefault();
27611
27611
  const Ee = Se[Math.max(fe - 1, 0)];
27612
27612
  Ee && mt(Le(Ee));
27613
- } else if ($.key === "Enter" && fe >= 0 && !Ue)
27613
+ } else if ($.key === "Enter" && fe >= 0 && !Qe)
27614
27614
  $.preventDefault(), lt(Se[fe]);
27615
27615
  else if ($.key === "c" && fe >= 0 && ee) {
27616
27616
  $.preventDefault();
@@ -27619,8 +27619,8 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
27619
27619
  } else $.key === "o" && fe >= 0 && ($.preventDefault(), It(Se[fe]));
27620
27620
  }
27621
27621
  return window.addEventListener("keydown", D), () => window.removeEventListener("keydown", D);
27622
- }, [m, Se, Et, Ue, r, $t, ut, ee]);
27623
- const { data: Ut } = useQuery({
27622
+ }, [m, Se, Et, Qe, r, $t, ut, ee]);
27623
+ const { data: Qt } = useQuery({
27624
27624
  queryKey: ["queue-views", e],
27625
27625
  queryFn: () => a.request(get$1(`/queues/${e}/views`)),
27626
27626
  enabled: !!e
@@ -27631,7 +27631,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
27631
27631
  }
27632
27632
  function On() {
27633
27633
  var $, H;
27634
- const D = Ut == null ? void 0 : Ut.data.find((fe) => fe.is_default);
27634
+ const D = Qt == null ? void 0 : Qt.data.find((fe) => fe.is_default);
27635
27635
  if (D) {
27636
27636
  zt(D);
27637
27637
  return;
@@ -27639,10 +27639,10 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
27639
27639
  d((($ = j == null ? void 0 : j.display_config) == null ? void 0 : $.default_scope) ?? "all"), x({ ...z.current }), k(""), S(null), et(null), F(null), (H = j == null ? void 0 : j.display_config) != null && H.default_view && h(j.display_config.default_view), p(1), ms(null);
27640
27640
  }
27641
27641
  useEffect(() => {
27642
- if (de || !(j != null && j.display_config) || Nt === void 0 || Ut === void 0) return;
27643
- const D = Nt.data.default_view_id, $ = D != null ? Ut.data.find((fe) => fe.id === D) : void 0, H = Ut.data.find((fe) => fe.is_default);
27642
+ if (de || !(j != null && j.display_config) || Nt === void 0 || Qt === void 0) return;
27643
+ const D = Nt.data.default_view_id, $ = D != null ? Qt.data.find((fe) => fe.id === D) : void 0, H = Qt.data.find((fe) => fe.is_default);
27644
27644
  $ ? zt($) : H ? zt(H) : (h(j.display_config.default_view), d(j.display_config.default_scope)), ae(!0);
27645
- }, [j, Nt, Ut, de]);
27645
+ }, [j, Nt, Qt, de]);
27646
27646
  const { isAdmin: dn } = useItemEditAuth(), rs = dn || (j == null ? void 0 : j.owner) != null && j.owner === r, As = useMutation({
27647
27647
  mutationFn: ({ viewId: D, on: $ }) => a.request(patch$1(`/queues/views/${D}`, { is_default: $ })),
27648
27648
  onSuccess: () => {
@@ -27705,12 +27705,12 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
27705
27705
  onError: () => {
27706
27706
  n.invalidateQueries({ queryKey: ["queue-column-prefs", e] }), toast.error("Failed to update default view");
27707
27707
  }
27708
- }), [Nn, Qs] = useState([]), [an, Ss] = useState(!1);
27708
+ }), [Nn, Us] = useState([]), [an, Ss] = useState(!1);
27709
27709
  async function $n(D, $) {
27710
27710
  const H = qt.filter((Ke) => Nn.includes(Le(Ke)));
27711
27711
  Ss(!0);
27712
27712
  const fe = await Promise.allSettled(H.map($)), be = fe.filter((Ke) => Ke.status === "fulfilled").length, Ee = fe.length - be;
27713
- Ss(!1), Qs([]), n.invalidateQueries({ queryKey: ["queue-items", e] }), Ee ? toast.warning(`${D}: ${be} succeeded, ${Ee} failed`) : toast.success(`${D}: ${be} succeeded`);
27713
+ Ss(!1), Us([]), n.invalidateQueries({ queryKey: ["queue-items", e] }), Ee ? toast.warning(`${D}: ${be} succeeded, ${Ee} failed`) : toast.success(`${D}: ${be} succeeded`);
27714
27714
  }
27715
27715
  const un = (D) => {
27716
27716
  var $;
@@ -27746,8 +27746,8 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
27746
27746
  " at risk"
27747
27747
  ] })
27748
27748
  ] })
27749
- })), Us = (((mn = ve == null ? void 0 : ve.available_values.collection) == null ? void 0 : mn.length) ?? 0) > 1, Cs = [
27750
- ...Us ? [
27749
+ })), Qs = (((mn = ve == null ? void 0 : ve.available_values.collection) == null ? void 0 : mn.length) ?? 0) > 1, Cs = [
27750
+ ...Qs ? [
27751
27751
  {
27752
27752
  key: "collection",
27753
27753
  header: ye("collection", "Collection"),
@@ -27838,7 +27838,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
27838
27838
  };
27839
27839
  }
27840
27840
  return { enabled: !0, layout_id: null, width: null };
27841
- }, Qn = useMemo(() => {
27841
+ }, Un = useMemo(() => {
27842
27842
  const D = {};
27843
27843
  for (const $ of (j == null ? void 0 : j.sources) ?? [])
27844
27844
  for (const [H, fe] of Object.entries($.column_formats ?? {}))
@@ -27886,7 +27886,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
27886
27886
  ) : /* @__PURE__ */ jsx("span", { className: "block max-w-[200px] truncate text-[12px]", title: Ke, children: Ee });
27887
27887
  }
27888
27888
  })), zs = [
27889
- ...Us ? ["collection"] : [],
27889
+ ...Qs ? ["collection"] : [],
27890
27890
  "state",
27891
27891
  "owners",
27892
27892
  "aging_hours",
@@ -27894,7 +27894,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
27894
27894
  "at_risk",
27895
27895
  ...rn.map((D) => `extra.${D}`)
27896
27896
  ], bn = [
27897
- ...Us ? ["collection"] : [],
27897
+ ...Qs ? ["collection"] : [],
27898
27898
  "state",
27899
27899
  "owners",
27900
27900
  "aging_hours",
@@ -27904,7 +27904,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
27904
27904
  ], Vs = (le == null ? void 0 : le.default_columns) ?? null, gs = Rt ?? Vs, en = new Set(gs ?? bn), fs = [
27905
27905
  ...(gs ?? []).filter((D) => zs.includes(D)),
27906
27906
  ...zs.filter((D) => !(gs ?? []).includes(D))
27907
- ], Un = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 4 } }));
27907
+ ], Qn = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 4 } }));
27908
27908
  function gn(D) {
27909
27909
  const { active: $, over: H } = D;
27910
27910
  if (!H || $.id === H.id) return;
@@ -27961,7 +27961,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
27961
27961
  $.trim() && (H.filter = JSON.stringify({ [D.display_field]: { _contains: $.trim() } }));
27962
27962
  const be = (await a.request(
27963
27963
  get$1(`/items/${D.target_collection}`, H)
27964
- )).data ?? [], Ee = un(D.path), Ke = Q[D.path] ? new Set(Q[D.path]) : null, ot = /* @__PURE__ */ new Set(), ct = [];
27964
+ )).data ?? [], Ee = un(D.path), Ke = U[D.path] ? new Set(U[D.path]) : null, ot = /* @__PURE__ */ new Set(), ct = [];
27965
27965
  for (const Kt of be) {
27966
27966
  const ze = Kt[D.display_field];
27967
27967
  if (ze == null || ze === "") continue;
@@ -28046,7 +28046,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28046
28046
  placeholder: ye(`extra.${D}`, formatColumnHeader(D)),
28047
28047
  type: "combobox",
28048
28048
  multi: !0,
28049
- restricted: !!((H = Q[D]) != null && H.length),
28049
+ restricted: !!((H = U[D]) != null && H.length),
28050
28050
  loadOptions: yn($)
28051
28051
  } : {
28052
28052
  key: `extra.${D}`,
@@ -28315,7 +28315,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28315
28315
  }
28316
28316
  ),
28317
28317
  /* @__PURE__ */ jsxs("div", { className: "ml-auto flex flex-wrap items-center gap-1.5", children: [
28318
- !((Ut == null ? void 0 : Ut.data) ?? []).some((D) => D.is_default) && /* @__PURE__ */ jsx(
28318
+ !((Qt == null ? void 0 : Qt.data) ?? []).some((D) => D.is_default) && /* @__PURE__ */ jsx(
28319
28319
  "button",
28320
28320
  {
28321
28321
  type: "button",
@@ -28328,7 +28328,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28328
28328
  children: "Default"
28329
28329
  }
28330
28330
  ),
28331
- ((Ut == null ? void 0 : Ut.data) ?? []).map((D) => /* @__PURE__ */ jsxs(
28331
+ ((Qt == null ? void 0 : Qt.data) ?? []).map((D) => /* @__PURE__ */ jsxs(
28332
28332
  "span",
28333
28333
  {
28334
28334
  className: cn$1(
@@ -28410,7 +28410,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28410
28410
  ) }),
28411
28411
  /* @__PURE__ */ jsxs(PopoverContent, { className: "w-[240px] p-3", align: "end", children: [
28412
28412
  (() => {
28413
- const D = Ut == null ? void 0 : Ut.data.find(($) => $.id === es);
28413
+ const D = Qt == null ? void 0 : Qt.data.find(($) => $.id === es);
28414
28414
  return !D || D.user !== r && !dn ? null : /* @__PURE__ */ jsxs(
28415
28415
  "button",
28416
28416
  {
@@ -28485,7 +28485,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28485
28485
  /* @__PURE__ */ jsx(PopoverContent, { className: "w-[220px] p-2", align: "end", children: /* @__PURE__ */ jsx(
28486
28486
  DndContext,
28487
28487
  {
28488
- sensors: Un,
28488
+ sensors: Qn,
28489
28489
  collisionDetection: closestCenter,
28490
28490
  onDragEnd: gn,
28491
28491
  children: /* @__PURE__ */ jsx(
@@ -28523,11 +28523,11 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28523
28523
  ]
28524
28524
  }
28525
28525
  ),
28526
- U && i && /* @__PURE__ */ jsx(
28526
+ Q && i && /* @__PURE__ */ jsx(
28527
28527
  ImportFromFileButton,
28528
28528
  {
28529
- collection: U,
28530
- onParsed: (D, $) => i(`/collections/${U}/new`, {
28529
+ collection: Q,
28530
+ onParsed: (D, $) => i(`/collections/${Q}/new`, {
28531
28531
  state: { importResult: D, importTemplateId: $.id }
28532
28532
  })
28533
28533
  }
@@ -28674,7 +28674,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28674
28674
  collapsedGroups: f,
28675
28675
  onToggleGroup: $e,
28676
28676
  selectedIds: oe ? Nn : void 0,
28677
- onSelectionChange: oe ? Qs : void 0,
28677
+ onSelectionChange: oe ? Us : void 0,
28678
28678
  hideFilterRow: !0,
28679
28679
  nowrapCells: !0,
28680
28680
  columnPins: Hs,
@@ -28734,7 +28734,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28734
28734
  )
28735
28735
  ),
28736
28736
  onTransition: (D) => $n("Transition", ($) => _t($, D)),
28737
- onClear: () => Qs([])
28737
+ onClear: () => Us([])
28738
28738
  }
28739
28739
  ),
28740
28740
  xs && /* @__PURE__ */ jsx(
@@ -28752,11 +28752,11 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28752
28752
  /* @__PURE__ */ jsx(
28753
28753
  QueueItemSheet,
28754
28754
  {
28755
- item: Ue,
28755
+ item: Qe,
28756
28756
  stateLabels: Ks,
28757
28757
  collectionLabel: it,
28758
28758
  claimsEnabled: ee,
28759
- columnFormats: Qn,
28759
+ columnFormats: Un,
28760
28760
  width: le == null ? void 0 : le.sheet_width,
28761
28761
  itemLayout: le == null ? void 0 : le.item_layout,
28762
28762
  onOpenChange: (D) => {
@@ -28765,7 +28765,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28765
28765
  onClaim: (D) => $t.mutate(D),
28766
28766
  onRelease: (D) => ut.mutate(D),
28767
28767
  workNextActive: qe,
28768
- onNext: () => Ue && dt(Ue),
28768
+ onNext: () => Qe && dt(Qe),
28769
28769
  refetchItems: () => n.invalidateQueries({ queryKey: ["queue-items", e] })
28770
28770
  }
28771
28771
  )
@@ -29970,7 +29970,7 @@ function ReportView({
29970
29970
  }), L = useMutation({
29971
29971
  mutationFn: (ce) => i.request(deleteReportFilterPreset(e, ce)),
29972
29972
  onSuccess: b
29973
- }), [A, I] = useState(""), [M, E] = useState(!1), [K, Q] = useState(""), [ie, z] = useState(!1), [U, ee] = useState(null), { data: le, isLoading: J } = useQuery({
29973
+ }), [A, I] = useState(""), [M, E] = useState(!1), [K, U] = useState(""), [ie, z] = useState(!1), [Q, ee] = useState(null), { data: le, isLoading: J } = useQuery({
29974
29974
  queryKey: ["nivaro-report", e],
29975
29975
  queryFn: () => i.request(readReport(e)).then((ce) => ce.data),
29976
29976
  staleTime: 3e4
@@ -30043,7 +30043,7 @@ function ReportView({
30043
30043
  var st;
30044
30044
  return de.some((_t) => _t.field === Je.field) && ((st = Je.values) == null ? void 0 : st.length) > 0;
30045
30045
  }).map((Je) => ({ field: Je.field, values: Je.values, labels: Je.values.map(String) }));
30046
- S(Ie), k(Ie), h(Ne.data.date_range ?? null), x(void 0), Q("");
30046
+ S(Ie), k(Ie), h(Ne.data.date_range ?? null), x(void 0), U("");
30047
30047
  } catch (Ne) {
30048
30048
  ee(
30049
30049
  ((Be = (ve = Ne.response) == null ? void 0 : ve.data) == null ? void 0 : Be.error) ?? "Could not parse that"
@@ -30173,7 +30173,7 @@ function ReportView({
30173
30173
  "input",
30174
30174
  {
30175
30175
  value: K,
30176
- onChange: (ce) => Q(ce.target.value),
30176
+ onChange: (ce) => U(ce.target.value),
30177
30177
  onKeyDown: (ce) => {
30178
30178
  ce.key === "Enter" && G();
30179
30179
  },
@@ -30192,7 +30192,7 @@ function ReportView({
30192
30192
  }
30193
30193
  )
30194
30194
  ] }),
30195
- U && /* @__PURE__ */ jsx("span", { className: "text-[10.5px] text-red-400", children: U })
30195
+ Q && /* @__PURE__ */ jsx("span", { className: "text-[10.5px] text-red-400", children: Q })
30196
30196
  ] })
30197
30197
  ] }),
30198
30198
  ae.length === 0 ? /* @__PURE__ */ jsx("div", { className: "p-6 text-[13px] text-slate-400", children: l ?? "This report has no widgets yet." }) : /* @__PURE__ */ jsx(
@@ -32152,13 +32152,13 @@ function AlertManagerView({
32152
32152
  queryFn: () => m("GET", "/metric-alerts/anomaly-definitions").then(
32153
32153
  (Y) => Y.data
32154
32154
  )
32155
- }), { data: K = [], isLoading: Q } = useQuery({
32155
+ }), { data: K = [], isLoading: U } = useQuery({
32156
32156
  queryKey: ["nvr-ma-anomaly-rules"],
32157
32157
  queryFn: () => m("GET", "/metric-alerts/anomaly-rules").then((Y) => Y.data)
32158
32158
  }), { data: ie = [], isLoading: z } = useQuery({
32159
32159
  queryKey: ["nvr-ma-anomaly-log"],
32160
32160
  queryFn: () => m("GET", "/metric-alerts/anomaly-log").then((Y) => Y.data)
32161
- }), [U, ee] = useState(!1), [le, J] = useState(null), [V, oe] = useState(null), [ye, he] = useState(!1), [de, ae] = useState(null), [B, ue] = useState(null), [Z, je] = useState(!1), _e = useMemo(
32161
+ }), [Q, ee] = useState(!1), [le, J] = useState(null), [V, oe] = useState(null), [ye, he] = useState(!1), [de, ae] = useState(null), [B, ue] = useState(null), [Z, je] = useState(!1), _e = useMemo(
32162
32162
  () => Object.fromEntries(y.map((Y) => [Y.rule_id, Y])),
32163
32163
  [y]
32164
32164
  ), ke = useMemo(() => {
@@ -32936,7 +32936,7 @@ function AlertManagerView({
32936
32936
  { label: "", width: 80 }
32937
32937
  ],
32938
32938
  empty: "No anomaly rules yet — create one to start detecting unusual patterns",
32939
- loading: Q,
32939
+ loading: U,
32940
32940
  children: K.map((Y) => {
32941
32941
  const Oe = Ot(Y.created_by);
32942
32942
  return /* @__PURE__ */ jsxs("tr", { className: "hover:bg-slate-50/60 dark:hover:bg-muted/30", children: [
@@ -33101,7 +33101,7 @@ function AlertManagerView({
33101
33101
  /* @__PURE__ */ jsx(
33102
33102
  AlertRuleDrawer,
33103
33103
  {
33104
- open: U,
33104
+ open: Q,
33105
33105
  definitions: x,
33106
33106
  editRule: le,
33107
33107
  preselectedDefinitionId: V,
@@ -33266,53 +33266,53 @@ function ChatRoomView({
33266
33266
  useNivaroClient();
33267
33267
  const i = r.me, { messages: o, loading: d } = useChatMessages(e), c = useSendChatMessage(e), p = useMarkRoomRead(), m = useTypingIndicator(e), h = usePeerReadAt(e.startsWith("dm:") ? e : null), _ = useEntityRoomLink(e), [k, w] = useState(""), [x, u] = useState(!1), [S, f] = useState(""), [y, v] = useState(null), [N, C] = useState(0), F = useRef(/* @__PURE__ */ new Map()), q = useRef(null), g = useRef(null);
33268
33268
  useEffect(() => {
33269
- var U;
33270
- (U = g.current) == null || U.scrollIntoView({ block: "end" });
33269
+ var Q;
33270
+ (Q = g.current) == null || Q.scrollIntoView({ block: "end" });
33271
33271
  }, [o.length]), useEffect(() => {
33272
33272
  p.mutate(e);
33273
33273
  }, [e, o.length]);
33274
33274
  const b = useMemo(() => {
33275
33275
  if (y === null) return [];
33276
- const U = y.toLowerCase();
33277
- return r.onlineUsers.filter((ee) => (ee.display_name ?? "").toLowerCase().startsWith(U)).slice(0, 6);
33278
- }, [y, r.onlineUsers]), j = (U) => {
33276
+ const Q = y.toLowerCase();
33277
+ return r.onlineUsers.filter((ee) => (ee.display_name ?? "").toLowerCase().startsWith(Q)).slice(0, 6);
33278
+ }, [y, r.onlineUsers]), j = (Q) => {
33279
33279
  var V;
33280
- const ee = U.display_name ?? "Unknown", le = `@[${ee}] `, J = k.lastIndexOf(`@${y ?? ""}`);
33281
- w(J !== -1 ? k.slice(0, J) + le : k + le), F.current.set(ee, U), v(null), (V = q.current) == null || V.focus();
33280
+ const ee = Q.display_name ?? "Unknown", le = `@[${ee}] `, J = k.lastIndexOf(`@${y ?? ""}`);
33281
+ w(J !== -1 ? k.slice(0, J) + le : k + le), F.current.set(ee, Q), v(null), (V = q.current) == null || V.focus();
33282
33282
  }, L = () => {
33283
- const U = k.trim();
33284
- if (!U) return;
33283
+ const Q = k.trim();
33284
+ if (!Q) return;
33285
33285
  w(""), v(null), m.clearTyping();
33286
- const ee = i ? [...F.current.entries()].filter(([le]) => U.includes(`@[${le}]`)).map(([, le]) => le.user_id) : [];
33287
- c.mutate({ text: U, mentions: ee }), F.current.clear();
33288
- }, A = (U, ee) => {
33289
- w(U), m.onType();
33290
- const le = getMentionQuery(U, ee);
33286
+ const ee = i ? [...F.current.entries()].filter(([le]) => Q.includes(`@[${le}]`)).map(([, le]) => le.user_id) : [];
33287
+ c.mutate({ text: Q, mentions: ee }), F.current.clear();
33288
+ }, A = (Q, ee) => {
33289
+ w(Q), m.onType();
33290
+ const le = getMentionQuery(Q, ee);
33291
33291
  v(le), le !== null && C(0);
33292
- }, I = (U) => {
33292
+ }, I = (Q) => {
33293
33293
  if (y !== null && b.length > 0) {
33294
- if (U.key === "ArrowDown") {
33295
- U.preventDefault(), C((ee) => (ee + 1) % b.length);
33294
+ if (Q.key === "ArrowDown") {
33295
+ Q.preventDefault(), C((ee) => (ee + 1) % b.length);
33296
33296
  return;
33297
33297
  }
33298
- if (U.key === "ArrowUp") {
33299
- U.preventDefault(), C((ee) => (ee - 1 + b.length) % b.length);
33298
+ if (Q.key === "ArrowUp") {
33299
+ Q.preventDefault(), C((ee) => (ee - 1 + b.length) % b.length);
33300
33300
  return;
33301
33301
  }
33302
- if (U.key === "Enter" || U.key === "Tab") {
33303
- U.preventDefault(), j(b[N]);
33302
+ if (Q.key === "Enter" || Q.key === "Tab") {
33303
+ Q.preventDefault(), j(b[N]);
33304
33304
  return;
33305
33305
  }
33306
- U.key === "Escape" && (U.preventDefault(), v(null));
33306
+ Q.key === "Escape" && (Q.preventDefault(), v(null));
33307
33307
  }
33308
33308
  }, M = (z = i == null ? void 0 : i.id) == null ? void 0 : z.toLowerCase(), E = x && S.trim().length > 0, K = useMemo(
33309
- () => E ? o.filter((U) => U.message.toLowerCase().includes(S.trim().toLowerCase())) : o,
33309
+ () => E ? o.filter((Q) => Q.message.toLowerCase().includes(S.trim().toLowerCase())) : o,
33310
33310
  [o, E, S]
33311
- ), Q = useMemo(() => {
33312
- var U;
33311
+ ), U = useMemo(() => {
33312
+ var Q;
33313
33313
  if (E) return -1;
33314
33314
  for (let ee = K.length - 1; ee >= 0; ee--)
33315
- if (((U = K[ee].sender) == null ? void 0 : U.toLowerCase()) === M) return ee;
33315
+ if (((Q = K[ee].sender) == null ? void 0 : Q.toLowerCase()) === M) return ee;
33316
33316
  return -1;
33317
33317
  }, [K, M, E]), ie = h ? new Date(h).getTime() : 0;
33318
33318
  return /* @__PURE__ */ jsxs("div", { className: "flex h-full min-h-0 flex-col", "data-chat-room": e, children: [
@@ -33333,8 +33333,8 @@ function ChatRoomView({
33333
33333
  {
33334
33334
  type: "button",
33335
33335
  onClick: () => {
33336
- var U;
33337
- return (U = r.navigate) == null ? void 0 : U.call(r, _);
33336
+ var Q;
33337
+ return (Q = r.navigate) == null ? void 0 : Q.call(r, _);
33338
33338
  },
33339
33339
  className: cn$1(
33340
33340
  "flex items-center gap-1 rounded-md px-1.5 py-1 text-[11px] font-medium transition-colors",
@@ -33354,7 +33354,7 @@ function ChatRoomView({
33354
33354
  {
33355
33355
  type: "button",
33356
33356
  onClick: () => {
33357
- u((U) => !U), f("");
33357
+ u((Q) => !Q), f("");
33358
33358
  },
33359
33359
  className: cn$1(
33360
33360
  "rounded-md p-1 transition-colors",
@@ -33380,26 +33380,26 @@ function ChatRoomView({
33380
33380
  {
33381
33381
  autoFocus: !0,
33382
33382
  value: S,
33383
- onChange: (U) => f(U.target.value),
33383
+ onChange: (Q) => f(Q.target.value),
33384
33384
  placeholder: "Search messages…",
33385
33385
  className: cn$1("h-7 w-full rounded-md border px-2 text-[12px] outline-none", l.input),
33386
33386
  "aria-label": "Search messages"
33387
33387
  }
33388
33388
  ) }),
33389
33389
  /* @__PURE__ */ jsxs("div", { className: "min-h-0 flex-1 space-y-2.5 overflow-y-auto px-3 py-3", "data-chat-messages": !0, children: [
33390
- d ? /* @__PURE__ */ jsx("p", { className: "py-6 text-center text-[12px] text-slate-400", children: "Loading…" }) : K.length === 0 ? /* @__PURE__ */ jsx("p", { className: "py-6 text-center text-[12px] text-slate-400", children: E ? "No messages match." : "No messages yet — say hello." }) : K.map((U, ee) => {
33390
+ d ? /* @__PURE__ */ jsx("p", { className: "py-6 text-center text-[12px] text-slate-400", children: "Loading…" }) : K.length === 0 ? /* @__PURE__ */ jsx("p", { className: "py-6 text-center text-[12px] text-slate-400", children: E ? "No messages match." : "No messages yet — say hello." }) : K.map((Q, ee) => {
33391
33391
  var he;
33392
- const le = ((he = U.sender) == null ? void 0 : he.toLowerCase()) === M, J = K[ee - 1], V = ee === 0 || J && new Date(J.date_created).toDateString() !== new Date(U.date_created).toDateString(), oe = le && ee === Q, ye = oe && ie > 0 && new Date(U.date_created).getTime() <= ie;
33392
+ const le = ((he = Q.sender) == null ? void 0 : he.toLowerCase()) === M, J = K[ee - 1], V = ee === 0 || J && new Date(J.date_created).toDateString() !== new Date(Q.date_created).toDateString(), oe = le && ee === U, ye = oe && ie > 0 && new Date(Q.date_created).getTime() <= ie;
33393
33393
  return /* @__PURE__ */ jsxs("div", { children: [
33394
33394
  V && /* @__PURE__ */ jsxs("div", { className: "my-2 flex items-center gap-2", children: [
33395
33395
  /* @__PURE__ */ jsx("span", { className: "h-px flex-1 bg-slate-100 dark:bg-border" }),
33396
- /* @__PURE__ */ jsx("span", { className: "text-[10px] font-medium text-slate-400", children: dateDivider(U.date_created) }),
33396
+ /* @__PURE__ */ jsx("span", { className: "text-[10px] font-medium text-slate-400", children: dateDivider(Q.date_created) }),
33397
33397
  /* @__PURE__ */ jsx("span", { className: "h-px flex-1 bg-slate-100 dark:bg-border" })
33398
33398
  ] }),
33399
33399
  /* @__PURE__ */ jsxs("div", { className: cn$1("flex gap-2", le && "flex-row-reverse"), children: [
33400
- !le && /* @__PURE__ */ jsx(Avatar, { id: U.sender, name: U.sender_name, size: 26 }),
33400
+ !le && /* @__PURE__ */ jsx(Avatar, { id: Q.sender, name: Q.sender_name, size: 26 }),
33401
33401
  /* @__PURE__ */ jsxs("div", { className: cn$1("max-w-[78%]", le && "text-right"), children: [
33402
- !le && /* @__PURE__ */ jsx("p", { className: "mb-0.5 text-[10.5px] font-medium text-slate-400", children: U.sender_name ?? "Unknown" }),
33402
+ !le && /* @__PURE__ */ jsx("p", { className: "mb-0.5 text-[10.5px] font-medium text-slate-400", children: Q.sender_name ?? "Unknown" }),
33403
33403
  /* @__PURE__ */ jsx(
33404
33404
  "div",
33405
33405
  {
@@ -33407,12 +33407,12 @@ function ChatRoomView({
33407
33407
  "inline-block rounded-2xl px-3 py-1.5 text-left text-[12.5px] leading-snug",
33408
33408
  le ? cn$1("rounded-br-md", l.bubbleMine) : cn$1("rounded-bl-md", l.bubbleOther)
33409
33409
  ),
33410
- children: a ? a(U, { mine: le }) : /* @__PURE__ */ jsx(MessageBody, { text: U.message, mine: le })
33410
+ children: a ? a(Q, { mine: le }) : /* @__PURE__ */ jsx(MessageBody, { text: Q.message, mine: le })
33411
33411
  }
33412
33412
  ),
33413
33413
  /* @__PURE__ */ jsxs("p", { className: "mt-0.5 flex items-center justify-end gap-1 text-[10px] text-slate-400", children: [
33414
33414
  !le && /* @__PURE__ */ jsx("span", { className: "mr-auto" }),
33415
- new Date(U.date_created).toLocaleTimeString("en-US", {
33415
+ new Date(Q.date_created).toLocaleTimeString("en-US", {
33416
33416
  hour: "numeric",
33417
33417
  minute: "2-digit"
33418
33418
  }),
@@ -33432,7 +33432,7 @@ function ChatRoomView({
33432
33432
  ] })
33433
33433
  ] })
33434
33434
  ] })
33435
- ] }, U.id);
33435
+ ] }, Q.id);
33436
33436
  }),
33437
33437
  /* @__PURE__ */ jsx("div", { ref: g })
33438
33438
  ] }),
@@ -33441,8 +33441,8 @@ function ChatRoomView({
33441
33441
  "form",
33442
33442
  {
33443
33443
  className: cn$1("relative flex shrink-0 items-center gap-2 border-t p-2.5", l.divider),
33444
- onSubmit: (U) => {
33445
- U.preventDefault(), L();
33444
+ onSubmit: (Q) => {
33445
+ Q.preventDefault(), L();
33446
33446
  },
33447
33447
  "data-chat-composer": !0,
33448
33448
  children: [
@@ -33454,23 +33454,23 @@ function ChatRoomView({
33454
33454
  l.surface,
33455
33455
  "border-slate-200 dark:border-border"
33456
33456
  ),
33457
- children: b.map((U, ee) => /* @__PURE__ */ jsxs(
33457
+ children: b.map((Q, ee) => /* @__PURE__ */ jsxs(
33458
33458
  "button",
33459
33459
  {
33460
33460
  type: "button",
33461
33461
  onMouseDown: (le) => {
33462
- le.preventDefault(), j(U);
33462
+ le.preventDefault(), j(Q);
33463
33463
  },
33464
33464
  className: cn$1(
33465
33465
  "flex w-full items-center gap-2 px-3 py-1.5 text-left text-[12.5px]",
33466
33466
  ee === N ? l.accentSoft : "text-slate-700 dark:text-slate-200"
33467
33467
  ),
33468
33468
  children: [
33469
- /* @__PURE__ */ jsx(Avatar, { id: U.user_id, name: U.display_name, size: 22 }),
33470
- /* @__PURE__ */ jsx("span", { className: "truncate", children: U.display_name ?? "Unknown" })
33469
+ /* @__PURE__ */ jsx(Avatar, { id: Q.user_id, name: Q.display_name, size: 22 }),
33470
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: Q.display_name ?? "Unknown" })
33471
33471
  ]
33472
33472
  },
33473
- U.user_id
33473
+ Q.user_id
33474
33474
  ))
33475
33475
  }
33476
33476
  ),
@@ -33479,7 +33479,7 @@ function ChatRoomView({
33479
33479
  {
33480
33480
  ref: q,
33481
33481
  value: k,
33482
- onChange: (U) => A(U.target.value, U.target.selectionStart ?? U.target.value.length),
33482
+ onChange: (Q) => A(Q.target.value, Q.target.selectionStart ?? Q.target.value.length),
33483
33483
  onKeyDown: I,
33484
33484
  placeholder: `Message ${t}… (@ to mention)`,
33485
33485
  className: cn$1("h-9 min-w-0 flex-1 rounded-lg border px-3 text-[12.5px] outline-none", l.input),
@@ -33912,8 +33912,8 @@ function ChatChannelBrowser({
33912
33912
  ] });
33913
33913
  }
33914
33914
  function usePresenceExtras() {
33915
- var n, a;
33916
- const e = useNivaroClient(), { data: t } = useQuery({
33915
+ var a, r;
33916
+ const e = useNivaroClient(), { data: t, isFetched: s } = useQuery({
33917
33917
  queryKey: ["presence-online"],
33918
33918
  queryFn: () => e.request(get$1("/presence/online")),
33919
33919
  // Matches the presence heartbeat cadence — the page someone is on should
@@ -33923,12 +33923,13 @@ function usePresenceExtras() {
33923
33923
  });
33924
33924
  return {
33925
33925
  byUser: useMemo(() => {
33926
- const r = /* @__PURE__ */ new Map();
33927
- for (const l of (t == null ? void 0 : t.data) ?? []) r.set(String(l.user_id).toUpperCase(), l);
33928
- return r;
33926
+ const l = /* @__PURE__ */ new Map();
33927
+ for (const i of (t == null ? void 0 : t.data) ?? []) l.set(String(i.user_id).toUpperCase(), i);
33928
+ return l;
33929
33929
  }, [t]),
33930
- fields: ((n = t == null ? void 0 : t.config) == null ? void 0 : n.fields) ?? ["role", "page"],
33931
- adminUrl: ((a = t == null ? void 0 : t.config) == null ? void 0 : a.admin_url) ?? null
33930
+ fields: ((a = t == null ? void 0 : t.config) == null ? void 0 : a.fields) ?? ["role", "page"],
33931
+ adminUrl: ((r = t == null ? void 0 : t.config) == null ? void 0 : r.admin_url) ?? null,
33932
+ loaded: s
33932
33933
  };
33933
33934
  }
33934
33935
  function prettyPath(e) {
@@ -33946,7 +33947,7 @@ function ChatPanel({
33946
33947
  renderMessageBody: s,
33947
33948
  requestedDm: n
33948
33949
  }) {
33949
- const a = useChatConfig(), r = useTheme(), l = a.me, [i, o] = useState("online"), [d, c] = useState(null), [p, m] = useState(!1), { rooms: h, totalUnread: _ } = useChatRooms(), k = a.onlineUsers, w = usePresenceExtras(), { isAdmin: x } = useItemEditAuth(), { navigate: u } = useNavigation(), S = (v) => {
33950
+ const a = useChatConfig(), r = useTheme(), l = a.me, [i, o] = useState("online"), [d, c] = useState(null), [p, m] = useState(!1), { rooms: h, totalUnread: _ } = useChatRooms(), k = usePresenceExtras(), w = k.loaded ? a.onlineUsers.filter((v) => k.byUser.has(String(v.user_id).toUpperCase())) : [], { isAdmin: x } = useItemEditAuth(), { navigate: u } = useNavigation(), S = (v) => {
33950
33951
  /^https?:\/\//i.test(v) ? window.open(v, "_blank", "noopener") : u(v);
33951
33952
  }, f = (v) => {
33952
33953
  l && (o("chat"), c({ room: dmRoom(l.id, v.user_id), label: v.display_name ?? "Direct message" }));
@@ -33987,7 +33988,7 @@ function ChatPanel({
33987
33988
  i === v ? r.accentSoft : "text-slate-500 hover:text-slate-700 dark:hover:text-slate-300"
33988
33989
  ),
33989
33990
  children: [
33990
- v === "online" ? `Online · ${k.length}` : v === "chat" ? "Chat" : "Browse",
33991
+ v === "online" ? `Online · ${w.length}` : v === "chat" ? "Chat" : "Browse",
33991
33992
  v === "chat" && _ > 0 && /* @__PURE__ */ jsx(
33992
33993
  "span",
33993
33994
  {
@@ -34014,7 +34015,7 @@ function ChatPanel({
34014
34015
  }
34015
34016
  )
34016
34017
  ] }),
34017
- i === "online" ? /* @__PURE__ */ jsx("div", { className: "min-h-0 flex-1 overflow-y-auto p-2", "data-chat-online": !0, children: k.length === 0 ? /* @__PURE__ */ jsx("p", { className: "px-3 py-8 text-center text-[12px] text-slate-400", children: "No one else is online right now." }) : k.map((v) => /* @__PURE__ */ jsxs(
34018
+ i === "online" ? /* @__PURE__ */ jsx("div", { className: "min-h-0 flex-1 overflow-y-auto p-2", "data-chat-online": !0, children: w.length === 0 ? /* @__PURE__ */ jsx("p", { className: "px-3 py-8 text-center text-[12px] text-slate-400", children: "No one else is online right now." }) : w.map((v) => /* @__PURE__ */ jsxs(
34018
34019
  "button",
34019
34020
  {
34020
34021
  type: "button",
@@ -34029,15 +34030,15 @@ function ChatPanel({
34029
34030
  /* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1", children: [
34030
34031
  /* @__PURE__ */ jsx("span", { className: "block truncate text-[13px] font-medium text-slate-800 dark:text-slate-100", children: v.display_name ?? "Unknown user" }),
34031
34032
  /* @__PURE__ */ jsx("span", { className: "block truncate text-[11px] text-slate-400", children: (() => {
34032
- const N = w.byUser.get(String(v.user_id).toUpperCase());
34033
- return w.fields.map((F) => F === "role" ? humanLabel((N == null ? void 0 : N.role_name) ?? v.role_name) : F === "scopes" ? ((N == null ? void 0 : N.scopes) ?? []).join(", ") || null : F === "page" ? prettyPath((N == null ? void 0 : N.current_path) ?? v.current_path) : null).filter(Boolean).join(" · ") || "Online";
34033
+ const N = k.byUser.get(String(v.user_id).toUpperCase());
34034
+ return k.fields.map((F) => F === "role" ? humanLabel((N == null ? void 0 : N.role_name) ?? v.role_name) : F === "scopes" ? ((N == null ? void 0 : N.scopes) ?? []).join(", ") || null : F === "page" ? prettyPath((N == null ? void 0 : N.current_path) ?? v.current_path) : null).filter(Boolean).join(" · ") || "Online";
34034
34035
  })() })
34035
34036
  ] }),
34036
34037
  (() => {
34037
34038
  var q;
34038
- const N = w.byUser.get(String(v.user_id).toUpperCase());
34039
+ const N = k.byUser.get(String(v.user_id).toUpperCase());
34039
34040
  if (!x || !(N != null && N.recording_id)) return null;
34040
- const C = ((q = w.adminUrl) == null ? void 0 : q.replace(/\/$/, "")) ?? "", F = a.sessionUrl ? a.sessionUrl(N.recording_id, String(v.user_id)) : `${C}/session-replays?recording=${N.recording_id}`;
34041
+ const C = ((q = k.adminUrl) == null ? void 0 : q.replace(/\/$/, "")) ?? "", F = a.sessionUrl ? a.sessionUrl(N.recording_id, String(v.user_id)) : `${C}/session-replays?recording=${N.recording_id}`;
34041
34042
  return F ? /* @__PURE__ */ jsx(
34042
34043
  "span",
34043
34044
  {
@@ -34349,7 +34350,7 @@ function MatrixEditor({
34349
34350
  }
34350
34351
  _(_e);
34351
34352
  }, [v, L, F, x, u, M, e.option_section]);
34352
- const K = useMemo(() => u ? [...v].map((Z) => ({ id: String(Z.id), label: String(Z[u.label_field ?? "name"] ?? Z.id) })).sort((Z, je) => Z.label.localeCompare(je.label)) : [{ id: "", label: "" }], [v, u]), Q = useMemo(() => {
34353
+ const K = useMemo(() => u ? [...v].map((Z) => ({ id: String(Z.id), label: String(Z[u.label_field ?? "name"] ?? Z.id) })).sort((Z, je) => Z.label.localeCompare(je.label)) : [{ id: "", label: "" }], [v, u]), U = useMemo(() => {
34353
34354
  var je, _e;
34354
34355
  const Z = /* @__PURE__ */ new Set();
34355
34356
  for (const ke of K) {
@@ -34359,9 +34360,9 @@ function MatrixEditor({
34359
34360
  return Z;
34360
34361
  }, [K, I, e.specials]), ie = useMemo(() => {
34361
34362
  let Z = 0;
34362
- for (const [je, _e] of L) Q.has(je) || (Z += _e.total);
34363
+ for (const [je, _e] of L) U.has(je) || (Z += _e.total);
34363
34364
  return Z;
34364
- }, [L, Q]), z = e.cap ? Number(walkPath(g[e.cap.scope_field] ?? {}, e.cap.field)) || 0 : null, U = useMemo(
34365
+ }, [L, U]), z = e.cap ? Number(walkPath(g[e.cap.scope_field] ?? {}, e.cap.field)) || 0 : null, Q = useMemo(
34365
34366
  () => [...L.values()].reduce((Z, je) => Z + je.total, 0),
34366
34367
  [L]
34367
34368
  ), ee = useMemo(() => {
@@ -34508,7 +34509,7 @@ function MatrixEditor({
34508
34509
  /* @__PURE__ */ jsxs("span", { children: [
34509
34510
  /* @__PURE__ */ jsx("span", { className: "text-slate-500", children: "Allocated:" }),
34510
34511
  " ",
34511
- /* @__PURE__ */ jsx("strong", { className: "tabular-nums", children: fmtVal(U, "currency") })
34512
+ /* @__PURE__ */ jsx("strong", { className: "tabular-nums", children: fmtVal(Q, "currency") })
34512
34513
  ] }),
34513
34514
  /* @__PURE__ */ jsxs("span", { children: [
34514
34515
  /* @__PURE__ */ jsx("span", { className: "text-slate-500", children: "Available to allocate:" }),
@@ -34786,55 +34787,55 @@ function JsonMapEditor({
34786
34787
  queryKey: ["json-map-keys", y, JSON.stringify(e.sections.map((z) => z.collection))],
34787
34788
  queryFn: async () => {
34788
34789
  const z = [];
34789
- for (let U = 0; U < e.sections.length; U++) {
34790
- const ee = e.sections[U], le = templateFields(ee.label_template), J = resolveScope(ee.filter, t), V = J && !hasUndef(J) ? J : void 0, oe = await s.request(
34790
+ for (let Q = 0; Q < e.sections.length; Q++) {
34791
+ const ee = e.sections[Q], le = templateFields(ee.label_template), J = resolveScope(ee.filter, t), V = J && !hasUndef(J) ? J : void 0, oe = await s.request(
34791
34792
  get$1(`/items/${ee.collection}`, {
34792
34793
  limit: 1e3,
34793
34794
  fields: ["id", ...le].join(","),
34794
34795
  ...V ? { filter: JSON.stringify(V) } : {}
34795
34796
  })
34796
34797
  );
34797
- z.push({ section: U, rows: oe.data ?? [] });
34798
+ z.push({ section: Q, rows: oe.data ?? [] });
34798
34799
  }
34799
34800
  return z;
34800
34801
  },
34801
34802
  staleTime: 3e4
34802
34803
  }), q = useMemo(() => {
34803
34804
  const z = [];
34804
- for (const U of F.data ?? []) {
34805
- const ee = e.sections[U.section], le = U.rows.map((J) => ({
34805
+ for (const Q of F.data ?? []) {
34806
+ const ee = e.sections[Q.section], le = Q.rows.map((J) => ({
34806
34807
  key: String(J.id),
34807
34808
  label: applyTemplate(ee.label_template, J) || `#${J.id}`,
34808
34809
  section: ee.section_label ?? null
34809
34810
  })).sort((J, V) => J.label.localeCompare(V.label));
34810
34811
  z.push(...le);
34811
34812
  }
34812
- for (const U of e.extra_rows ?? [])
34813
- z.push({ key: U.key, label: U.label, section: null, bg: U.bg });
34813
+ for (const Q of e.extra_rows ?? [])
34814
+ z.push({ key: Q.key, label: Q.label, section: null, bg: Q.bg });
34814
34815
  return z;
34815
34816
  }, [F.data, e.sections, e.extra_rows]), g = useMemo(() => {
34816
34817
  const z = {};
34817
- for (const U of e.map_columns) {
34818
- const ee = C == null ? void 0 : C[U.json_field];
34818
+ for (const Q of e.map_columns) {
34819
+ const ee = C == null ? void 0 : C[Q.json_field];
34819
34820
  try {
34820
- z[U.json_field] = typeof ee == "string" ? JSON.parse(ee) : ee ?? {};
34821
+ z[Q.json_field] = typeof ee == "string" ? JSON.parse(ee) : ee ?? {};
34821
34822
  } catch {
34822
- z[U.json_field] = {};
34823
+ z[Q.json_field] = {};
34823
34824
  }
34824
34825
  }
34825
34826
  return z;
34826
- }, [C, e.map_columns]), b = (z, U) => {
34827
+ }, [C, e.map_columns]), b = (z, Q) => {
34827
34828
  var J, V;
34828
- const ee = (J = k[z]) == null ? void 0 : J[U];
34829
+ const ee = (J = k[z]) == null ? void 0 : J[Q];
34829
34830
  if (ee !== void 0) return ee;
34830
- const le = (V = g[z]) == null ? void 0 : V[U];
34831
+ const le = (V = g[z]) == null ? void 0 : V[Q];
34831
34832
  return le == null ? "" : String(le);
34832
- }, j = (z, U, ee) => w((le) => ({ ...le, [z]: { ...le[z] ?? {}, [U]: ee } })), L = (z) => {
34833
- const U = h[z];
34834
- if (U !== void 0) return U;
34833
+ }, j = (z, Q, ee) => w((le) => ({ ...le, [z]: { ...le[z] ?? {}, [Q]: ee } })), L = (z) => {
34834
+ const Q = h[z];
34835
+ if (Q !== void 0) return Q;
34835
34836
  const ee = C == null ? void 0 : C[z];
34836
34837
  return ee == null ? "" : String(ee);
34837
- }, A = p || r != null, I = Object.keys(h).length > 0 || Object.values(k).some((z) => Object.keys(z).length > 0) || d !== null || p, M = e.remaining_hint, E = M && L(M.when_field) === M.when_value ? M.total - q.reduce((z, U) => z + (Number(b(M.json_field, U.key)) || 0), 0) : null;
34838
+ }, A = p || r != null, I = Object.keys(h).length > 0 || Object.values(k).some((z) => Object.keys(z).length > 0) || d !== null || p, M = e.remaining_hint, E = M && L(M.when_field) === M.when_value ? M.total - q.reduce((z, Q) => z + (Number(b(M.json_field, Q.key)) || 0), 0) : null;
34838
34839
  async function K() {
34839
34840
  var z;
34840
34841
  if (p && !i.trim()) {
@@ -34843,26 +34844,26 @@ function JsonMapEditor({
34843
34844
  }
34844
34845
  u(!0), f(null);
34845
34846
  try {
34846
- const U = {};
34847
+ const Q = {};
34847
34848
  for (const le of e.fields ?? []) {
34848
34849
  const J = h[le.field];
34849
- J !== void 0 ? U[le.field] = J : p && (U[le.field] = le.options[0]);
34850
+ J !== void 0 ? Q[le.field] = J : p && (Q[le.field] = le.options[0]);
34850
34851
  }
34851
34852
  for (const le of e.map_columns) {
34852
34853
  const J = { ...p ? {} : g[le.json_field] };
34853
34854
  for (const [V, oe] of Object.entries(k[le.json_field] ?? {}))
34854
34855
  oe === "" ? delete J[V] : J[V] = Number(oe);
34855
- (Object.keys(J).length > 0 || !p) && (U[le.json_field] = JSON.stringify(J));
34856
+ (Object.keys(J).length > 0 || !p) && (Q[le.json_field] = JSON.stringify(J));
34856
34857
  }
34857
34858
  let ee = r;
34858
34859
  if (p) {
34859
- U[a] = i.trim();
34860
- for (const J of e.seed_fields ?? []) U[J] = t[J];
34860
+ Q[a] = i.trim();
34861
+ for (const J of e.seed_fields ?? []) Q[J] = t[J];
34861
34862
  ee = (z = (await s.request(
34862
- post$1(`/items/${e.collection}`, U)
34863
+ post$1(`/items/${e.collection}`, Q)
34863
34864
  )).data) == null ? void 0 : z.id, m(!1), o(""), l(ee ?? null);
34864
34865
  } else
34865
- d !== null && d.trim() && (U[a] = d.trim()), await s.request(patch$1(`/items/${e.collection}/${r}`, U));
34866
+ d !== null && d.trim() && (Q[a] = d.trim()), await s.request(patch$1(`/items/${e.collection}/${r}`, Q));
34866
34867
  if (c(null), e.after_save) {
34867
34868
  const le = resolveScope(e.after_save.params ?? {}, t);
34868
34869
  await s.request(post$1(`/custom-queries/${e.after_save.query_slug}/execute`, { params: le }));
@@ -34870,17 +34871,17 @@ function JsonMapEditor({
34870
34871
  _({}), w({}), await n.invalidateQueries({ queryKey: ["json-map-record", e.collection] }), await n.invalidateQueries({
34871
34872
  predicate: (le) => JSON.stringify(le.queryKey).includes(e.collection)
34872
34873
  }), f("Saved");
34873
- } catch (U) {
34874
- f(`Save failed: ${U instanceof Error ? U.message : "unknown error"}`);
34874
+ } catch (Q) {
34875
+ f(`Save failed: ${Q instanceof Error ? Q.message : "unknown error"}`);
34875
34876
  } finally {
34876
34877
  u(!1);
34877
34878
  }
34878
34879
  }
34879
- const Q = useMemo(() => {
34880
+ const U = useMemo(() => {
34880
34881
  const z = [];
34881
- for (const U of q) {
34882
+ for (const Q of q) {
34882
34883
  const ee = z[z.length - 1];
34883
- ee && ee.section === U.section ? ee.rows.push(U) : z.push({ section: U.section, rows: [U] });
34884
+ ee && ee.section === Q.section ? ee.rows.push(Q) : z.push({ section: Q.section, rows: [Q] });
34884
34885
  }
34885
34886
  return z;
34886
34887
  }, [q]);
@@ -34932,15 +34933,15 @@ function JsonMapEditor({
34932
34933
  ] }),
34933
34934
  (e.fields ?? []).map((z) => /* @__PURE__ */ jsxs("div", { children: [
34934
34935
  /* @__PURE__ */ jsx("p", { className: "mb-1 text-[11px] font-medium text-slate-500", children: z.label ?? z.field }),
34935
- /* @__PURE__ */ jsx("div", { className: "inline-flex gap-0.5 rounded-md border border-slate-200 p-0.5 dark:border-border", children: z.options.map((U) => /* @__PURE__ */ jsx(
34936
+ /* @__PURE__ */ jsx("div", { className: "inline-flex gap-0.5 rounded-md border border-slate-200 p-0.5 dark:border-border", children: z.options.map((Q) => /* @__PURE__ */ jsx(
34936
34937
  "button",
34937
34938
  {
34938
34939
  type: "button",
34939
- onClick: () => _((ee) => ({ ...ee, [z.field]: U })),
34940
- className: `rounded px-2 py-1 text-[12px] font-medium transition-colors ${(L(z.field) || z.options[0]) === U ? "bg-[#00ceff1a] text-slate-800 dark:text-slate-100" : "text-slate-500 hover:text-slate-700 dark:hover:text-slate-300"}`,
34941
- children: U.replace(/_/g, " ")
34940
+ onClick: () => _((ee) => ({ ...ee, [z.field]: Q })),
34941
+ className: `rounded px-2 py-1 text-[12px] font-medium transition-colors ${(L(z.field) || z.options[0]) === Q ? "bg-[#00ceff1a] text-slate-800 dark:text-slate-100" : "text-slate-500 hover:text-slate-700 dark:hover:text-slate-300"}`,
34942
+ children: Q.replace(/_/g, " ")
34942
34943
  },
34943
- U
34944
+ Q
34944
34945
  )) })
34945
34946
  ] }, z.field)),
34946
34947
  /* @__PURE__ */ jsxs(
@@ -34971,7 +34972,7 @@ function JsonMapEditor({
34971
34972
  /* @__PURE__ */ jsx("th", { className: "py-1.5 pr-3 font-medium text-slate-500", children: "Category" }),
34972
34973
  e.map_columns.map((z) => /* @__PURE__ */ jsx("th", { className: "w-36 py-1.5 pr-2 text-right font-medium text-slate-500", children: z.label }, z.json_field))
34973
34974
  ] }) }),
34974
- /* @__PURE__ */ jsx("tbody", { children: Q.map((z, U) => /* @__PURE__ */ jsx(
34975
+ /* @__PURE__ */ jsx("tbody", { children: U.map((z, Q) => /* @__PURE__ */ jsx(
34975
34976
  FragmentRows,
34976
34977
  {
34977
34978
  header: z.section ? /* @__PURE__ */ jsx("tr", { className: "border-b border-slate-200 bg-slate-100/80 dark:border-border dark:bg-muted", children: /* @__PURE__ */ jsx(
@@ -35005,11 +35006,11 @@ function JsonMapEditor({
35005
35006
  ee.key
35006
35007
  ))
35007
35008
  },
35008
- `${z.section ?? ""}-${U}`
35009
+ `${z.section ?? ""}-${Q}`
35009
35010
  )) }),
35010
35011
  /* @__PURE__ */ jsx("tfoot", { children: /* @__PURE__ */ jsxs("tr", { className: "border-t border-slate-300 font-semibold dark:border-border", children: [
35011
35012
  /* @__PURE__ */ jsx("td", { className: "py-1.5 pr-3", children: "Total" }),
35012
- e.map_columns.map((z) => /* @__PURE__ */ jsx("td", { className: "py-1.5 pr-2 text-right tabular-nums", children: q.reduce((U, ee) => U + (Number(b(z.json_field, ee.key)) || 0), 0).toLocaleString("en-US", { maximumFractionDigits: 2 }) }, z.json_field))
35013
+ e.map_columns.map((z) => /* @__PURE__ */ jsx("td", { className: "py-1.5 pr-2 text-right tabular-nums", children: q.reduce((Q, ee) => Q + (Number(b(z.json_field, ee.key)) || 0), 0).toLocaleString("en-US", { maximumFractionDigits: 2 }) }, z.json_field))
35013
35014
  ] }) })
35014
35015
  ] }) }) : /* @__PURE__ */ jsx("p", { className: "text-[12px] text-slate-400", children: "Pick a record or create a new one." })
35015
35016
  ] });
@@ -35048,7 +35049,7 @@ function RecordGridEditor({ config: e }) {
35048
35049
  (E) => n[E.field] !== null && n[E.field] !== void 0 && n[E.field] !== ""
35049
35050
  ), f = JSON.stringify(n), y = useMemo(() => {
35050
35051
  const E = [];
35051
- for (const K of e.month_sets ?? []) for (const Q of MONTHS) E.push(`${Q}${K.suffix}`);
35052
+ for (const K of e.month_sets ?? []) for (const U of MONTHS) E.push(`${U}${K.suffix}`);
35052
35053
  for (const K of e.columns ?? []) E.push(K.field);
35053
35054
  return E;
35054
35055
  }, [e]), { data: v = [], isLoading: N } = useQuery({
@@ -35070,12 +35071,12 @@ function RecordGridEditor({ config: e }) {
35070
35071
  queryFn: () => {
35071
35072
  const E = e.row_source;
35072
35073
  if (!E) return Promise.resolve([]);
35073
- const K = resolveScopeTokens(E.filter, n), Q = K && !hasUnresolved(K) ? K : void 0;
35074
+ const K = resolveScopeTokens(E.filter, n), U = K && !hasUnresolved(K) ? K : void 0;
35074
35075
  return t.request(
35075
35076
  get$1(`/items/${E.collection}`, {
35076
35077
  limit: 1e3,
35077
35078
  ...E.sort ? { sort: E.sort } : {},
35078
- ...Q ? { filter: JSON.stringify(Q) } : {}
35079
+ ...U ? { filter: JSON.stringify(U) } : {}
35079
35080
  })
35080
35081
  ).then((ie) => ie.data ?? []);
35081
35082
  },
@@ -35085,13 +35086,13 @@ function RecordGridEditor({ config: e }) {
35085
35086
  if (e.row_source) {
35086
35087
  const E = e.row_source;
35087
35088
  return C.map((K) => {
35088
- const Q = v.find((ie) => String(ie[E.fk_field]) === String(K.id)) ?? null;
35089
+ const U = v.find((ie) => String(ie[E.fk_field]) === String(K.id)) ?? null;
35089
35090
  return {
35090
35091
  key: `src-${K.id}`,
35091
- record: Q,
35092
+ record: U,
35092
35093
  sourceId: K.id,
35093
35094
  sourceLabel: String(K[E.label_field] ?? K.id),
35094
- isNew: !Q
35095
+ isNew: !U
35095
35096
  };
35096
35097
  });
35097
35098
  }
@@ -35100,20 +35101,20 @@ function RecordGridEditor({ config: e }) {
35100
35101
  ...i.map((E) => ({ key: E, record: null, isNew: !0 }))
35101
35102
  ];
35102
35103
  }, [e.row_source, C, v, i, d]), q = (E, K) => {
35103
- var z, U;
35104
- const Q = (z = r[E.key]) == null ? void 0 : z[K];
35105
- if (Q !== void 0) return Q;
35106
- const ie = (U = E.record) == null ? void 0 : U[K];
35104
+ var z, Q;
35105
+ const U = (z = r[E.key]) == null ? void 0 : z[K];
35106
+ if (U !== void 0) return U;
35107
+ const ie = (Q = E.record) == null ? void 0 : Q[K];
35107
35108
  return ie == null ? "" : String(ie);
35108
- }, g = (E, K, Q) => l((ie) => ({ ...ie, [E]: { ...ie[E] ?? {}, [K]: Q } })), b = Object.values(r).some((E) => Object.keys(E).length > 0) || i.length > 0 || d.size > 0;
35109
+ }, g = (E, K, U) => l((ie) => ({ ...ie, [E]: { ...ie[E] ?? {}, [K]: U } })), b = Object.values(r).some((E) => Object.keys(E).length > 0) || i.length > 0 || d.size > 0;
35109
35110
  async function j(E) {
35110
35111
  var z;
35111
35112
  m(!0), w(null);
35112
- let K = 0, Q = 0, ie = 0;
35113
+ let K = 0, U = 0, ie = 0;
35113
35114
  try {
35114
- for (const U of F) {
35115
- const ee = r[U.key] ?? {}, le = Object.keys(ee).length > 0;
35116
- if (!U.record && !le) continue;
35115
+ for (const Q of F) {
35116
+ const ee = r[Q.key] ?? {}, le = Object.keys(ee).length > 0;
35117
+ if (!Q.record && !le) continue;
35117
35118
  const J = {};
35118
35119
  for (const [V, oe] of Object.entries(ee))
35119
35120
  !y.includes(V) && !(e.key_columns ?? []).some((ye) => ye.field === V) || (J[V] = oe === "" ? null : Number.isNaN(Number(oe)) ? oe : Number(oe));
@@ -35121,37 +35122,37 @@ function RecordGridEditor({ config: e }) {
35121
35122
  const V = e.month_sets[0];
35122
35123
  J[e.computed_total_field] = MONTHS.reduce((oe, ye) => {
35123
35124
  var ae;
35124
- const he = `${ye}${V.suffix}`, de = ee[he] !== void 0 ? Number(ee[he]) || 0 : Number((ae = U.record) == null ? void 0 : ae[he]) || 0;
35125
+ const he = `${ye}${V.suffix}`, de = ee[he] !== void 0 ? Number(ee[he]) || 0 : Number((ae = Q.record) == null ? void 0 : ae[he]) || 0;
35125
35126
  return oe + de;
35126
35127
  }, 0);
35127
35128
  }
35128
- if (U.record) {
35129
+ if (Q.record) {
35129
35130
  if (Object.keys(J).length === 0) continue;
35130
- E && (J._change_reason = E), await t.request(patch$1(`/items/${e.collection}/${U.record.id}`, J)), Q++;
35131
+ E && (J._change_reason = E), await t.request(patch$1(`/items/${e.collection}/${Q.record.id}`, J)), U++;
35131
35132
  } else {
35132
35133
  if (!le) continue;
35133
35134
  for (const V of e.scope ?? []) J[V.field] = n[V.field];
35134
- e.row_source && (J[e.row_source.fk_field] = U.sourceId), await t.request(post$1(`/items/${e.collection}`, J)), K++;
35135
+ e.row_source && (J[e.row_source.fk_field] = Q.sourceId), await t.request(post$1(`/items/${e.collection}`, J)), K++;
35135
35136
  }
35136
35137
  }
35137
- for (const U of d)
35138
- await t.request(del$1(`/items/${e.collection}/${U}`)), ie++;
35138
+ for (const Q of d)
35139
+ await t.request(del$1(`/items/${e.collection}/${Q}`)), ie++;
35139
35140
  if (e.after_save) {
35140
- const U = resolveScopeTokens(e.after_save.params ?? {}, n);
35141
+ const Q = resolveScopeTokens(e.after_save.params ?? {}, n);
35141
35142
  await t.request(
35142
- post$1(`/custom-queries/${e.after_save.query_slug}/execute`, { params: U })
35143
+ post$1(`/custom-queries/${e.after_save.query_slug}/execute`, { params: Q })
35143
35144
  );
35144
35145
  }
35145
- l({}), o([]), c(/* @__PURE__ */ new Set()), await s.invalidateQueries({ queryKey: ["record-grid-rows", e.collection] }), w(`Saved — ${Q} updated, ${K} created${ie ? `, ${ie} deleted` : ""}`);
35146
- } catch (U) {
35147
- const ee = changeReasonChallenge(U);
35148
- ee ? (_(ee), w(null)) : w(`Save failed: ${U instanceof Error ? U.message : "unknown error"}`);
35146
+ l({}), o([]), c(/* @__PURE__ */ new Set()), await s.invalidateQueries({ queryKey: ["record-grid-rows", e.collection] }), w(`Saved — ${U} updated, ${K} created${ie ? `, ${ie} deleted` : ""}`);
35147
+ } catch (Q) {
35148
+ const ee = changeReasonChallenge(Q);
35149
+ ee ? (_(ee), w(null)) : w(`Save failed: ${Q instanceof Error ? Q.message : "unknown error"}`);
35149
35150
  } finally {
35150
35151
  m(!1);
35151
35152
  }
35152
35153
  }
35153
35154
  const A = [...(e.month_sets ?? []).flatMap(
35154
- (E) => MONTHS.map((K, Q) => ({ field: `${K}${E.suffix}`, label: `${MONTH_LABELS[Q]} ${E.label}` }))
35155
+ (E) => MONTHS.map((K, U) => ({ field: `${K}${E.suffix}`, label: `${MONTH_LABELS[U]} ${E.label}` }))
35155
35156
  ), ...(e.columns ?? []).map((E) => ({ field: E.field, label: E.label ?? E.field }))];
35156
35157
  return /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col gap-3 overflow-auto p-3", children: [
35157
35158
  /* @__PURE__ */ jsx(
@@ -35166,7 +35167,7 @@ function RecordGridEditor({ config: e }) {
35166
35167
  ),
35167
35168
  /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-end gap-3", children: [
35168
35169
  (e.scope ?? []).map((E) => {
35169
- const K = resolveScopeTokens(E.filter, n), Q = K && !hasUnresolved(K) ? K : void 0;
35170
+ const K = resolveScopeTokens(E.filter, n), U = K && !hasUnresolved(K) ? K : void 0;
35170
35171
  return /* @__PURE__ */ jsxs("div", { className: "w-52", children: [
35171
35172
  /* @__PURE__ */ jsx("p", { className: "mb-1 text-[11px] font-medium text-slate-500", children: E.label ?? E.field.replace(/_/g, " ").replace(/\b\w/g, (ie) => ie.toUpperCase()) }),
35172
35173
  /* @__PURE__ */ jsx(
@@ -35177,7 +35178,7 @@ function RecordGridEditor({ config: e }) {
35177
35178
  onChange: (ie) => {
35178
35179
  a((z) => ({ ...z, [E.field]: ie })), l({}), o([]), c(/* @__PURE__ */ new Set());
35179
35180
  },
35180
- extraFilter: Q,
35181
+ extraFilter: U,
35181
35182
  placeholder: "Select…"
35182
35183
  }
35183
35184
  )
@@ -35206,15 +35207,15 @@ function RecordGridEditor({ config: e }) {
35206
35207
  }
35207
35208
  ),
35208
35209
  (e.toolbar_editors ?? []).map((E, K) => {
35209
- const Q = (E.require_scope ?? []).every(
35210
+ const U = (E.require_scope ?? []).every(
35210
35211
  (ie) => n[ie] !== null && n[ie] !== void 0 && n[ie] !== ""
35211
35212
  );
35212
35213
  return /* @__PURE__ */ jsx(
35213
35214
  "button",
35214
35215
  {
35215
35216
  type: "button",
35216
- disabled: !Q,
35217
- title: Q ? void 0 : `Choose ${(E.require_scope ?? []).join(", ")} first`,
35217
+ disabled: !U,
35218
+ title: U ? void 0 : `Choose ${(E.require_scope ?? []).join(", ")} first`,
35218
35219
  onClick: () => u(K),
35219
35220
  className: "inline-flex h-9 items-center rounded-md border border-slate-200 bg-white px-3 text-[13px] text-slate-700 hover:border-slate-400 disabled:opacity-50 dark:border-border dark:bg-card dark:text-slate-200",
35220
35221
  children: E.button_label
@@ -35278,7 +35279,7 @@ function RecordGridEditor({ config: e }) {
35278
35279
  {
35279
35280
  collection: K.collection,
35280
35281
  value: q(E, K.field) || null,
35281
- onChange: (Q) => g(E.key, K.field, Q == null ? "" : String(Q)),
35282
+ onChange: (U) => g(E.key, K.field, U == null ? "" : String(U)),
35282
35283
  placeholder: "Select…"
35283
35284
  }
35284
35285
  ) }, K.field)),
@@ -35287,7 +35288,7 @@ function RecordGridEditor({ config: e }) {
35287
35288
  {
35288
35289
  type: "number",
35289
35290
  value: q(E, K.field),
35290
- onChange: (Q) => g(E.key, K.field, Q.target.value),
35291
+ onChange: (U) => g(E.key, K.field, U.target.value),
35291
35292
  className: "h-7 w-[84px] rounded border border-slate-200 bg-white px-1.5 text-right text-[12px] tabular-nums outline-none focus:border-[#00ceff] dark:border-border dark:bg-background"
35292
35293
  }
35293
35294
  ) }, K.field)),
@@ -35297,11 +35298,11 @@ function RecordGridEditor({ config: e }) {
35297
35298
  type: "button",
35298
35299
  onClick: () => {
35299
35300
  E.record ? c((K) => {
35300
- var Q;
35301
- return new Set(K).add(String((Q = E.record) == null ? void 0 : Q.id));
35302
- }) : o((K) => K.filter((Q) => Q !== E.key)), l((K) => {
35303
- const Q = { ...K };
35304
- return delete Q[E.key], Q;
35301
+ var U;
35302
+ return new Set(K).add(String((U = E.record) == null ? void 0 : U.id));
35303
+ }) : o((K) => K.filter((U) => U !== E.key)), l((K) => {
35304
+ const U = { ...K };
35305
+ return delete U[E.key], U;
35305
35306
  });
35306
35307
  },
35307
35308
  className: "rounded px-1.5 text-[12px] text-slate-400 hover:text-red-600",
@@ -35314,7 +35315,7 @@ function RecordGridEditor({ config: e }) {
35314
35315
  /* @__PURE__ */ jsx("tfoot", { children: /* @__PURE__ */ jsxs("tr", { className: "border-t border-slate-300 font-semibold dark:border-border", children: [
35315
35316
  e.row_source && /* @__PURE__ */ jsx("td", { className: "py-1.5 pr-3", children: "Total" }),
35316
35317
  (e.key_columns ?? []).map((E, K) => /* @__PURE__ */ jsx("td", { className: "py-1.5 pr-3", children: !e.row_source && K === 0 ? "Total" : "" }, E.field)),
35317
- A.map((E) => /* @__PURE__ */ jsx("td", { className: "py-1.5 pr-2 text-right tabular-nums", children: F.reduce((K, Q) => K + (Number(q(Q, E.field)) || 0), 0).toLocaleString("en-US", { maximumFractionDigits: 2 }) }, E.field)),
35318
+ A.map((E) => /* @__PURE__ */ jsx("td", { className: "py-1.5 pr-2 text-right tabular-nums", children: F.reduce((K, U) => K + (Number(q(U, E.field)) || 0), 0).toLocaleString("en-US", { maximumFractionDigits: 2 }) }, E.field)),
35318
35319
  e.allow_delete && /* @__PURE__ */ jsx("td", {})
35319
35320
  ] }) })
35320
35321
  ] }) }) : /* @__PURE__ */ jsxs("p", { className: "text-[12px] text-slate-400", children: [
@@ -35791,7 +35792,7 @@ function QueryWidgetView({ config: e }) {
35791
35792
  return e.display === "drawer" ? /* @__PURE__ */ jsx(QueryDrawerButton, { cfg: e }) : /* @__PURE__ */ jsx(QueryWidgetInner, { config: e });
35792
35793
  }
35793
35794
  function QueryWidgetInner({ config: e }) {
35794
- var ie, z, U, ee, le, J, V;
35795
+ var ie, z, Q, ee, le, J, V;
35795
35796
  const t = useNivaroClient(), s = useDrilldown(), [n, a] = useState(null), [r, l] = useState(null), [i, o] = useState(null), [d, c] = useState(
35796
35797
  () => defaultFilterSelection(e.filters)
35797
35798
  ), [p, m] = useState(null), [h, _] = useState(null), k = (h == null ? void 0 : h.phase) === "running", w = useQueryClient();
@@ -35951,7 +35952,7 @@ function QueryWidgetInner({ config: e }) {
35951
35952
  layoutId: M.drill.layout_id,
35952
35953
  width: M.drill.width
35953
35954
  }));
35954
- } : void 0, Q = (U = e.row_actions) != null && U.length ? e.row_actions.map((oe) => ({
35955
+ } : void 0, U = (Q = e.row_actions) != null && Q.length ? e.row_actions.map((oe) => ({
35955
35956
  label: oe.label,
35956
35957
  onClick: (ye) => E(oe.sheet, ye)
35957
35958
  })) : void 0;
@@ -35978,7 +35979,7 @@ function QueryWidgetInner({ config: e }) {
35978
35979
  ) === (/* @__PURE__ */ new Date()).getFullYear() ? e.table : { ...e.table, highlight_group: void 0 } : e.table
35979
35980
  ),
35980
35981
  onRowClick: K,
35981
- rowActions: Q,
35982
+ rowActions: U,
35982
35983
  pivotYear: (V = (J = e.table) == null ? void 0 : J.pivot) != null && V.year_param && Number(String(C[e.table.pivot.year_param] ?? "").split(",")[0]) || void 0
35983
35984
  }
35984
35985
  ),
@@ -36900,7 +36901,7 @@ function InlineGridField({
36900
36901
  }
36901
36902
  function N(b, j, L, A, I) {
36902
36903
  if (A) {
36903
- _((E) => E.map((K, Q) => Q === I ? { ...K, [j]: L } : K));
36904
+ _((E) => E.map((K, U) => U === I ? { ...K, [j]: L } : K));
36904
36905
  return;
36905
36906
  }
36906
36907
  const M = String(b.id);
@@ -38018,7 +38019,7 @@ function PipelineSlot({
38018
38019
  ] }),
38019
38020
  !r && C && /* @__PURE__ */ jsx("span", { "data-nf-slot-inline-actions": !0, children: Array.from(g.entries()).map(([A, I]) => {
38020
38021
  var K;
38021
- const M = ((K = I[0]) == null ? void 0 : K.color) ?? null, E = I.some((Q) => Q.id === p);
38022
+ const M = ((K = I[0]) == null ? void 0 : K.color) ?? null, E = I.some((U) => U.id === p);
38022
38023
  return /* @__PURE__ */ jsx(
38023
38024
  "button",
38024
38025
  {
@@ -38026,8 +38027,8 @@ function PipelineSlot({
38026
38027
  "data-nf-transition-btn": !0,
38027
38028
  "data-active": E ? "true" : "false",
38028
38029
  style: M ? E ? { backgroundColor: M, borderColor: M, color: "#fff" } : { borderColor: M, color: M } : void 0,
38029
- onClick: (Q) => {
38030
- Q.stopPropagation(), L(I[0].id);
38030
+ onClick: (U) => {
38031
+ U.stopPropagation(), L(I[0].id);
38031
38032
  },
38032
38033
  children: A
38033
38034
  },
@@ -38130,7 +38131,7 @@ function PipelineSlot({
38130
38131
  C && /* @__PURE__ */ jsxs("div", { "data-nf-transitions": !0, "data-nf-pipeline-section": !0, children: [
38131
38132
  /* @__PURE__ */ jsx("div", { "data-nf-transition-btns": !0, children: Array.from(g.entries()).map(([A, I]) => {
38132
38133
  var K;
38133
- const M = ((K = I[0]) == null ? void 0 : K.color) ?? null, E = I.some((Q) => Q.id === p);
38134
+ const M = ((K = I[0]) == null ? void 0 : K.color) ?? null, E = I.some((U) => U.id === p);
38134
38135
  return /* @__PURE__ */ jsx(
38135
38136
  "button",
38136
38137
  {
@@ -38603,7 +38604,7 @@ function LayoutForm({
38603
38604
  [C]
38604
38605
  ), [q, g] = useState(0), [b, j] = useState(/* @__PURE__ */ new Set()), [L, A] = useState(null);
38605
38606
  if (!x) return null;
38606
- const I = x.groups.filter((ae) => ae.type === "tab"), M = x.groups.filter((ae) => ae.type === "section"), E = I.length > 0, K = E && x.tabMode === "steps", Q = L ?? ((de = I[0]) == null ? void 0 : de.key) ?? null, ie = (e.fieldsByGroup.get(null) ?? []).filter((ae) => y(ae.field));
38607
+ const I = x.groups.filter((ae) => ae.type === "tab"), M = x.groups.filter((ae) => ae.type === "section"), E = I.length > 0, K = E && x.tabMode === "steps", U = L ?? ((de = I[0]) == null ? void 0 : de.key) ?? null, ie = (e.fieldsByGroup.get(null) ?? []).filter((ae) => y(ae.field));
38607
38608
  function z(ae) {
38608
38609
  return y(ae.field) ? /* @__PURE__ */ jsx(
38609
38610
  "div",
@@ -38627,7 +38628,7 @@ function LayoutForm({
38627
38628
  ae.field
38628
38629
  ) : null;
38629
38630
  }
38630
- function U(ae) {
38631
+ function Q(ae) {
38631
38632
  const B = ae.filter((ue) => y(ue.field));
38632
38633
  return B.length === 0 ? null : /* @__PURE__ */ jsx(
38633
38634
  "div",
@@ -38656,11 +38657,11 @@ function LayoutForm({
38656
38657
  children: ae.label
38657
38658
  }
38658
38659
  ),
38659
- !Z && U(ue)
38660
+ !Z && Q(ue)
38660
38661
  ] }, ae.key);
38661
38662
  }
38662
38663
  function le() {
38663
- return ie.length === 0 ? null : /* @__PURE__ */ jsx("div", { "data-nivaro-ungrouped": !0, children: U(ie) }, "__ungrouped__");
38664
+ return ie.length === 0 ? null : /* @__PURE__ */ jsx("div", { "data-nivaro-ungrouped": !0, children: Q(ie) }, "__ungrouped__");
38664
38665
  }
38665
38666
  function J(ae) {
38666
38667
  if (!ae.isVisible) return null;
@@ -38698,9 +38699,9 @@ function LayoutForm({
38698
38699
  {
38699
38700
  type: "button",
38700
38701
  role: "tab",
38701
- "aria-selected": Q === ue.key,
38702
+ "aria-selected": U === ue.key,
38702
38703
  onClick: () => A(ue.key),
38703
- className: Q === ue.key ? l : i,
38704
+ className: U === ue.key ? l : i,
38704
38705
  children: ue.label
38705
38706
  },
38706
38707
  ue.key
@@ -38710,9 +38711,9 @@ function LayoutForm({
38710
38711
  {
38711
38712
  type: "button",
38712
38713
  role: "tab",
38713
- "aria-selected": Q === "__general__",
38714
+ "aria-selected": U === "__general__",
38714
38715
  onClick: () => A("__general__"),
38715
- className: Q === "__general__" ? l : i,
38716
+ className: U === "__general__" ? l : i,
38716
38717
  children: "General"
38717
38718
  }
38718
38719
  )
@@ -38724,13 +38725,13 @@ function LayoutForm({
38724
38725
  {
38725
38726
  role: "tabpanel",
38726
38727
  "data-nivaro-tab": ue.key,
38727
- style: Q !== ue.key ? { display: "none" } : void 0,
38728
- children: U(Z)
38728
+ style: U !== ue.key ? { display: "none" } : void 0,
38729
+ children: Q(Z)
38729
38730
  },
38730
38731
  ue.key
38731
38732
  );
38732
38733
  }),
38733
- Q === "__general__" && M.length > 0 && /* @__PURE__ */ jsx("div", { role: "tabpanel", "data-nivaro-tab": "__general__", children: M.map(ee) }),
38734
+ U === "__general__" && M.length > 0 && /* @__PURE__ */ jsx("div", { role: "tabpanel", "data-nivaro-tab": "__general__", children: M.map(ee) }),
38734
38735
  ae && le(),
38735
38736
  B.sort((ue, Z) => ue.sort - Z.sort).map(J)
38736
38737
  ] });
@@ -38776,7 +38777,7 @@ function LayoutForm({
38776
38777
  "data-nf-step-content": G.key,
38777
38778
  style: pe !== B ? { display: "none" } : void 0,
38778
38779
  children: [
38779
- U(me),
38780
+ Q(me),
38780
38781
  ce && ke && le(),
38781
38782
  ce && M.map(ee)
38782
38783
  ]
@@ -39456,7 +39457,7 @@ function useNivaroForm(e, t, s) {
39456
39457
  S(V ?? f), N({});
39457
39458
  },
39458
39459
  [f]
39459
- ), Q = useCallback(
39460
+ ), U = useCallback(
39460
39461
  (V) => {
39461
39462
  const oe = k == null ? void 0 : k.fields.find((ye) => ye.field === V);
39462
39463
  return oe ? isFieldVisible(oe.visibilityRules, u) : !0;
@@ -39493,7 +39494,7 @@ function useNivaroForm(e, t, s) {
39493
39494
  he && (V[oe] == null && (V[oe] = []), V[oe].push(he));
39494
39495
  }
39495
39496
  return V;
39496
- }, [k, u, c]), U = useCallback(
39497
+ }, [k, u, c]), Q = useCallback(
39497
39498
  async (V) => {
39498
39499
  var ye;
39499
39500
  (ye = V == null ? void 0 : V.preventDefault) == null || ye.call(V);
@@ -39553,12 +39554,12 @@ function useNivaroForm(e, t, s) {
39553
39554
  isDirty: ee,
39554
39555
  isSubmitting: C,
39555
39556
  isLoading: w || q,
39556
- isVisible: Q,
39557
+ isVisible: U,
39557
39558
  isLocked: ie,
39558
39559
  setValue: M,
39559
39560
  setValues: E,
39560
39561
  reset: K,
39561
- handleSubmit: U,
39562
+ handleSubmit: Q,
39562
39563
  fieldsByGroup: le,
39563
39564
  visibleGroups: J,
39564
39565
  gridFlushersRef: L