@nivaro/react 0.1.26 → 0.1.28

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.
package/dist/index.js CHANGED
@@ -1877,11 +1877,30 @@ function useCreateChannel() {
1877
1877
  });
1878
1878
  }
1879
1879
  let prevUnread = 0;
1880
- function useUnreadChirp(e) {
1881
- const t = useChatConfig();
1880
+ const prevByRoom = /* @__PURE__ */ new Map();
1881
+ function useUnreadChirp(e, t) {
1882
+ const s = useChatConfig();
1882
1883
  useEffect(() => {
1883
- t.sound && e > prevUnread && playChirp(), prevUnread = e;
1884
- }, [e, t.sound]);
1884
+ const n = e > prevUnread;
1885
+ if (s.sound && n && playChirp(), t) {
1886
+ const r = prevByRoom.size > 0;
1887
+ for (const a of t) {
1888
+ const l = prevByRoom.get(a.room) ?? 0;
1889
+ if (r && !a.muted && a.unread > l) {
1890
+ const i = a.lastMessage, o = i != null && i.sender_name ? String(i.sender_name).trim() : null;
1891
+ toast(
1892
+ a.kind === "dm" ? `New message from ${o || a.label}` : `New message in ${a.label}${o ? ` — ${o}` : ""}`,
1893
+ {
1894
+ description: i != null && i.message ? String(i.message).replace(/<[^>]*>/g, "").slice(0, 90) : void 0,
1895
+ duration: 4e3
1896
+ }
1897
+ );
1898
+ }
1899
+ prevByRoom.set(a.room, a.unread);
1900
+ }
1901
+ }
1902
+ prevUnread = e;
1903
+ }, [e, s.sound, t]);
1885
1904
  }
1886
1905
  function useMarkRoomRead() {
1887
1906
  const e = useNivaroClient(), t = useQueryClient();
@@ -7505,7 +7524,7 @@ function InlineTableField({
7505
7524
  _exists_junction: { table: pe.table, self_fk: pe.self_fk, filter_fk: pe.filter_fk, value: _e }
7506
7525
  }));
7507
7526
  }), A;
7508
- }, [_s, Ms, xe]), te = i === "pending", ke = E ? E.getPendingRows(e, t) : [], Se = te && E ? E.getPendingEdits(e, t) : /* @__PURE__ */ new Map(), Le = te && E ? E.getPendingDeletes(e, t) : /* @__PURE__ */ new Set(), Qe = useMemo(
7527
+ }, [_s, Ms, xe]), te = i === "pending", ke = E ? E.getPendingRows(e, t) : [], Se = te && E ? E.getPendingEdits(e, t) : /* @__PURE__ */ new Map(), Le = te && E ? E.getPendingDeletes(e, t) : /* @__PURE__ */ new Set(), Ue = useMemo(
7509
7528
  () => new Map(
7510
7529
  De.filter((A) => A.computed_type === "write" && !!A.computed_formula).map((A) => [A.field, String(A.computed_formula)])
7511
7530
  ),
@@ -7710,9 +7729,9 @@ function InlineTableField({
7710
7729
  const ms = useRef(() => {
7711
7730
  });
7712
7731
  ms.current = () => Ss == null ? void 0 : Ss(e, t, null), useEffect(() => () => ms.current(), []);
7713
- const Ut = De.filter(
7732
+ const Qt = De.filter(
7714
7733
  (A) => !A.hidden && (!NON_DISPLAY_TYPES$1.has(A.type) || Ls(A.interface)) && A.field !== t && A.field !== "id" && (!ie || A.layout_assigned === !0) && !SENTINEL_FIELDS.has(A.field) && !js.has(A.group_key ?? "")
7715
- ), ts = m && m.length >= 2 && _t !== ALL_PRESET_SENTINEL ? m.find((A) => A.name === _t) : void 0, Un = ts ? new Set(ts.columns.filter((A) => !A.includes("."))) : null, Gn = Un ? Ut.filter((A) => Un.has(A.field)) : [], gs = useMemo(() => {
7734
+ ), ts = m && m.length >= 2 && _t !== ALL_PRESET_SENTINEL ? m.find((A) => A.name === _t) : void 0, Qn = ts ? new Set(ts.columns.filter((A) => !A.includes("."))) : null, Gn = Qn ? Qt.filter((A) => Qn.has(A.field)) : [], gs = useMemo(() => {
7716
7735
  if (!ts) return [];
7717
7736
  const A = [];
7718
7737
  for (const V of ts.columns) {
@@ -7793,7 +7812,7 @@ function InlineTableField({
7793
7812
  staleTime: 3e4
7794
7813
  };
7795
7814
  })
7796
- }), Us = useMemo(() => {
7815
+ }), Qs = useMemo(() => {
7797
7816
  const A = /* @__PURE__ */ new Map();
7798
7817
  return Ks.forEach((V, oe) => {
7799
7818
  var Fe;
@@ -7809,7 +7828,7 @@ function InlineTableField({
7809
7828
  const A = /* @__PURE__ */ new Map(), V = (oe, pe) => {
7810
7829
  pe == null || pe === "" || (A.has(oe) || A.set(oe, []), A.get(oe).push(String(pe)));
7811
7830
  };
7812
- for (const [oe, pe] of Us) {
7831
+ for (const [oe, pe] of Qs) {
7813
7832
  const _e = As.get(oe);
7814
7833
  if (!(!_e || _e.size === 0)) {
7815
7834
  for (const Fe of pe.values())
@@ -7827,7 +7846,7 @@ function InlineTableField({
7827
7846
  }
7828
7847
  for (const [oe, pe] of A) A.set(oe, [...new Set(pe)].sort());
7829
7848
  return A;
7830
- }, [Us, As, ke]), { data: Qn = {} } = useQuery({
7849
+ }, [Qs, As, ke]), { data: Un = {} } = useQuery({
7831
7850
  queryKey: ["summary-m2o-display", e, ...Array.from(os.entries()).flat(2)],
7832
7851
  queryFn: async () => {
7833
7852
  const A = {};
@@ -7876,12 +7895,12 @@ function InlineTableField({
7876
7895
  var Ge, ct;
7877
7896
  const pe = A.field.indexOf(".");
7878
7897
  if (pe < 0) return "—";
7879
- const _e = A.field.slice(0, pe), Fe = A.field.slice(pe + 1), Me = V[`__o2m_${_e}`], Ee = oe ? Array.isArray(Me) ? Me : [] : ((Ge = Us.get(_e)) == null ? void 0 : Ge.get(String(V.id))) ?? [];
7898
+ const _e = A.field.slice(0, pe), Fe = A.field.slice(pe + 1), Me = V[`__o2m_${_e}`], Ee = oe ? Array.isArray(Me) ? Me : [] : ((Ge = Qs.get(_e)) == null ? void 0 : Ge.get(String(V.id))) ?? [];
7880
7899
  if (Ee.length === 0) return "—";
7881
7900
  const rt = (ct = As.get(_e)) == null ? void 0 : ct.get(Fe), ze = Ee.map((gt) => {
7882
7901
  var it;
7883
7902
  const Wt = gt[Fe];
7884
- return Wt == null || Wt === "" ? null : rt != null && rt.one_collection ? ((it = Qn[rt.one_collection]) == null ? void 0 : it[String(Wt)]) ?? String(Wt) : String(Wt);
7903
+ return Wt == null || Wt === "" ? null : rt != null && rt.one_collection ? ((it = Un[rt.one_collection]) == null ? void 0 : it[String(Wt)]) ?? String(Wt) : String(Wt);
7885
7904
  }).filter((gt) => !!gt);
7886
7905
  return ze.length > 0 ? ze.join(", ") : "—";
7887
7906
  }
@@ -7889,14 +7908,14 @@ function InlineTableField({
7889
7908
  var ze, Ge;
7890
7909
  const oe = A.field.indexOf(".");
7891
7910
  if (oe < 0) return "—";
7892
- const pe = A.field.slice(0, oe), _e = A.field.slice(oe + 1), Fe = ((ze = Us.get(pe)) == null ? void 0 : ze.get(String(V.id))) ?? [];
7911
+ const pe = A.field.slice(0, oe), _e = A.field.slice(oe + 1), Fe = ((ze = Qs.get(pe)) == null ? void 0 : ze.get(String(V.id))) ?? [];
7893
7912
  if (Fe.length === 0) return "—";
7894
7913
  const Me = (Ge = As.get(pe)) == null ? void 0 : Ge.get(_e);
7895
7914
  if (!(Me != null && Me.one_collection) || !L) return Zs(A, V, !1);
7896
7915
  const Ee = Me.one_collection, rt = Fe.map((ct) => {
7897
7916
  var Wt;
7898
7917
  const gt = ct[_e];
7899
- return gt == null || gt === "" ? null : { id: String(gt), label: ((Wt = Qn[Ee]) == null ? void 0 : Wt[String(gt)]) ?? String(gt) };
7918
+ return gt == null || gt === "" ? null : { id: String(gt), label: ((Wt = Un[Ee]) == null ? void 0 : Wt[String(gt)]) ?? String(gt) };
7900
7919
  }).filter((ct) => !!ct);
7901
7920
  return rt.length === 0 ? "—" : /* @__PURE__ */ jsx("span", { className: "inline-flex flex-wrap gap-x-1.5", children: rt.map((ct, gt) => /* @__PURE__ */ jsx(
7902
7921
  "button",
@@ -7911,7 +7930,7 @@ function InlineTableField({
7911
7930
  `${ct.id}:${gt}`
7912
7931
  )) });
7913
7932
  }
7914
- const ls = ts && (Gn.length > 0 || Wn.length > 0) ? [...Gn, ...Wn] : Ut, Cs = useMemo(
7933
+ const ls = ts && (Gn.length > 0 || Wn.length > 0) ? [...Gn, ...Wn] : Qt, Cs = useMemo(
7915
7934
  () => De.filter((A) => A.group_key === "__apply_values__" && !NON_DISPLAY_TYPES$1.has(A.type ?? "") && !SENTINEL_FIELDS.has(A.field)),
7916
7935
  [De]
7917
7936
  ), vn = useMemo(
@@ -7919,14 +7938,14 @@ function InlineTableField({
7919
7938
  [De]
7920
7939
  ), Os = useMemo(() => {
7921
7940
  const A = /* @__PURE__ */ new Map();
7922
- for (const V of Ut) {
7941
+ for (const V of Qt) {
7923
7942
  const oe = lt.find(
7924
7943
  (pe) => pe.many_collection === e && pe.many_field === V.field && !pe.junction_field
7925
7944
  );
7926
7945
  oe != null && oe.one_collection && A.set(V.field, oe);
7927
7946
  }
7928
7947
  return A;
7929
- }, [Ut, lt, e]), Qs = useMemo(() => {
7948
+ }, [Qt, lt, e]), Us = useMemo(() => {
7930
7949
  const A = [];
7931
7950
  for (const [V, oe] of Object.entries(Bt)) {
7932
7951
  const pe = Os.get(V);
@@ -7940,7 +7959,7 @@ function InlineTableField({
7940
7959
  }
7941
7960
  return A;
7942
7961
  }, [Bt, Os, tt, ke]), ps = useQueries({
7943
- queries: Qs.map((A) => ({
7962
+ queries: Us.map((A) => ({
7944
7963
  queryKey: [
7945
7964
  "cascade-stale-sweep",
7946
7965
  e,
@@ -7959,14 +7978,14 @@ function InlineTableField({
7959
7978
  }))
7960
7979
  }), en = useMemo(() => {
7961
7980
  const A = /* @__PURE__ */ new Map();
7962
- return Qs.forEach((V, oe) => {
7981
+ return Us.forEach((V, oe) => {
7963
7982
  var Fe;
7964
7983
  const pe = (Fe = ps[oe]) == null ? void 0 : Fe.data;
7965
7984
  if (!pe) return;
7966
7985
  const _e = V.ids.filter((Me) => !pe.has(Me));
7967
7986
  _e.length && A.set(V.field, new Set(_e));
7968
7987
  }), A;
7969
- }, [Qs, ps]), Zt = useMemo(() => {
7988
+ }, [Us, ps]), Zt = useMemo(() => {
7970
7989
  const A = /* @__PURE__ */ new Map(), V = [...tt, ...ke], oe = [...Se.values()], pe = H.flatMap((_e) => _e.rows);
7971
7990
  for (const [_e, Fe] of Os) {
7972
7991
  if (!Fe.one_collection) continue;
@@ -7976,7 +7995,7 @@ function InlineTableField({
7976
7995
  return A;
7977
7996
  }, [tt, ke, Se, Os, H]), Yn = useMemo(() => {
7978
7997
  const A = /* @__PURE__ */ new Map();
7979
- for (const V of Ut) {
7998
+ for (const V of Qt) {
7980
7999
  const oe = Os.get(V.field);
7981
8000
  if (oe != null && oe.one_collection && V.interface === "relation-grouped") {
7982
8001
  const pe = parseJson(V.options);
@@ -7984,7 +8003,7 @@ function InlineTableField({
7984
8003
  }
7985
8004
  }
7986
8005
  return A;
7987
- }, [Ut, Os]), qn = useMemo(
8006
+ }, [Qt, Os]), qn = useMemo(
7988
8007
  () => ["m2o-display", e, ...Array.from(Zt.entries()).flat(2)],
7989
8008
  [e, Zt]
7990
8009
  ), { data: jn = {}, isFetching: tn } = useQuery({
@@ -8115,7 +8134,7 @@ function InlineTableField({
8115
8134
  }
8116
8135
  P.invalidateQueries({ queryKey: ["o2m-rows", e, t, s] });
8117
8136
  } else {
8118
- const V = new Set(Ut.map((pe) => pe.field).filter((pe) => !pe.startsWith("__m2m_"))), oe = Object.fromEntries(Object.entries(ge.draft).filter(([pe]) => V.has(pe)));
8137
+ const V = new Set(Qt.map((pe) => pe.field).filter((pe) => !pe.startsWith("__m2m_"))), oe = Object.fromEntries(Object.entries(ge.draft).filter(([pe]) => V.has(pe)));
8119
8138
  if (te && E) {
8120
8139
  const pe = Object.entries(ge.draft).filter(([Me]) => Me.startsWith("__nested_ops_")), _e = tt.find((Me) => String(Me.id) === ge.rowId), Fe = _e ? Object.fromEntries(Object.entries(oe).filter(([Me, Ee]) => String(Ee ?? "") !== String(_e[Me] ?? ""))) : oe;
8121
8140
  E.queueEdit(e, t, ge.rowId, { ...Fe, ...Object.fromEntries(pe) }), He(null);
@@ -8146,7 +8165,7 @@ function InlineTableField({
8146
8165
  }
8147
8166
  }
8148
8167
  }
8149
- const [wn, $s] = useState(/* @__PURE__ */ new Set()), [Ts, Rn] = useState(null), [Hs, Dn] = useState(null), [U, w] = useState(!1), [Q, se] = useState(1), [$e, Oe] = useState(!1), [Ve, dt] = useState(!1), [Nt, We] = useState({}), [Ct, Ft] = useState(!1), [Gt, ds] = useState({}), [nn, On] = useState(!1);
8168
+ const [wn, $s] = useState(/* @__PURE__ */ new Set()), [Ts, Rn] = useState(null), [Hs, Dn] = useState(null), [Q, w] = useState(!1), [U, se] = useState(1), [$e, Oe] = useState(!1), [Ve, dt] = useState(!1), [Nt, We] = useState({}), [Ct, Ft] = useState(!1), [Gt, ds] = useState({}), [nn, On] = useState(!1);
8150
8169
  function zn(A, V) {
8151
8170
  We((oe) => ({ ...oe, [A]: V }));
8152
8171
  }
@@ -8168,7 +8187,7 @@ function InlineTableField({
8168
8187
  }
8169
8188
  }
8170
8189
  async function Is(A) {
8171
- const V = Math.max(1, Math.min(100, Q)), oe = A ? { ...ss, ...Nt } : { ...ss };
8190
+ const V = Math.max(1, Math.min(100, U)), oe = A ? { ...ss, ...Nt } : { ...ss };
8172
8191
  if ((K || te) && E) {
8173
8192
  for (let pe = 0; pe < V; pe++) E.queueRow(e, t, { ...oe });
8174
8193
  return;
@@ -8390,7 +8409,7 @@ function InlineTableField({
8390
8409
  }
8391
8410
  if (at || !K && Vt)
8392
8411
  return /* @__PURE__ */ jsx("div", { className: "py-3 text-center text-[12px] text-slate-400", children: /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin inline" }) });
8393
- const Pn = (ge == null ? void 0 : ge.rowId) === "new", Qt = ls.length + (K || te ? 2 : 1) + (et || K || te ? 1 : 0), Fn = ls.filter((A) => !Xs(A)).length >= 6 ? "panel" : "inline", hn = (A) => {
8412
+ const Pn = (ge == null ? void 0 : ge.rowId) === "new", Ut = ls.length + (K || te ? 2 : 1) + (et || K || te ? 1 : 0), Fn = ls.filter((A) => !Xs(A)).length >= 6 ? "panel" : "inline", hn = (A) => {
8394
8413
  for (const V of ls) {
8395
8414
  if (Xs(V)) continue;
8396
8415
  const oe = A[V.field];
@@ -8420,7 +8439,7 @@ function InlineTableField({
8420
8439
  },
8421
8440
  pe
8422
8441
  );
8423
- }) }), tr = (A) => A.computed_type === "write" && !!A.computed_formula || A.interface === "formula-column" || A.interface === "match-agg-column" || A.interface === "relation-path" || !!A.readonly || Xs(A), cr = (A) => /* @__PURE__ */ jsx("td", { colSpan: Qt, className: "p-0", children: /* @__PURE__ */ jsxs(
8442
+ }) }), tr = (A) => A.computed_type === "write" && !!A.computed_formula || A.interface === "formula-column" || A.interface === "match-agg-column" || A.interface === "relation-path" || !!A.readonly || Xs(A), cr = (A) => /* @__PURE__ */ jsx("td", { colSpan: Ut, className: "p-0", children: /* @__PURE__ */ jsxs(
8424
8443
  "div",
8425
8444
  {
8426
8445
  className: "my-1.5 rounded-lg border border-nvr-cyan/40 bg-white px-4 py-3 shadow-[0_6px_24px_-8px_rgba(15,23,42,0.35)] ring-1 ring-nvr-cyan/15 dark:border-nvr-cyan/30 dark:bg-card",
@@ -8551,7 +8570,7 @@ function InlineTableField({
8551
8570
  type: "number",
8552
8571
  min: 1,
8553
8572
  max: 100,
8554
- value: Q,
8573
+ value: U,
8555
8574
  onChange: (A) => se(Math.max(1, Math.min(100, parseInt(A.target.value, 10) || 1))),
8556
8575
  className: "w-14 h-6 rounded border border-slate-200 px-2 text-[11px] text-slate-700 text-center focus:outline-none focus:ring-1 focus:ring-[#00ceff]"
8557
8576
  }
@@ -8565,7 +8584,7 @@ function InlineTableField({
8565
8584
  className: "h-6 px-2.5 rounded border border-slate-200 text-slate-600 hover:border-slate-400 hover:text-slate-800 disabled:opacity-40 transition-colors",
8566
8585
  children: [
8567
8586
  "blank ",
8568
- Q === 1 ? "row" : "rows"
8587
+ U === 1 ? "row" : "rows"
8569
8588
  ]
8570
8589
  }
8571
8590
  ),
@@ -8613,7 +8632,7 @@ function InlineTableField({
8613
8632
  ...ke.map((V, oe) => ({ ...V, __pendingIndex: oe }))
8614
8633
  ],
8615
8634
  relatedCollection: e,
8616
- computedWriteFields: Qe,
8635
+ computedWriteFields: Ue,
8617
8636
  applyRow: async (V, oe) => {
8618
8637
  const pe = V.__pendingIndex;
8619
8638
  if (typeof pe == "number" && E) {
@@ -8725,7 +8744,7 @@ function InlineTableField({
8725
8744
  ] }),
8726
8745
  g && In,
8727
8746
  /* @__PURE__ */ jsxs("div", { className: z ? "hidden" : "relative rounded-lg border border-slate-200 text-[12px]", children: [
8728
- U && /* @__PURE__ */ jsx("div", { className: "absolute inset-0 z-10 flex items-center justify-center rounded-lg bg-white/60 backdrop-blur-[1px]", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 rounded-md border border-slate-200 bg-white px-3 py-1.5 shadow-sm text-[12px] text-slate-500", children: [
8747
+ Q && /* @__PURE__ */ jsx("div", { className: "absolute inset-0 z-10 flex items-center justify-center rounded-lg bg-white/60 backdrop-blur-[1px]", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 rounded-md border border-slate-200 bg-white px-3 py-1.5 shadow-sm text-[12px] text-slate-500", children: [
8729
8748
  /* @__PURE__ */ jsx(Loader2, { className: "h-3.5 w-3.5 animate-spin" }),
8730
8749
  "Saving order…"
8731
8750
  ] }) }),
@@ -8760,7 +8779,7 @@ function InlineTableField({
8760
8779
  disabled: $e,
8761
8780
  onClick: () => Is(!0),
8762
8781
  className: "rounded px-2 h-9 bg-[#00ceff] text-white text-[11px] font-medium hover:brightness-110 disabled:opacity-50 whitespace-nowrap",
8763
- children: $e ? "…" : `Add ${Q}`
8782
+ children: $e ? "…" : `Add ${U}`
8764
8783
  }
8765
8784
  ) })
8766
8785
  ] }),
@@ -8908,7 +8927,7 @@ function InlineTableField({
8908
8927
  Wt && /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsxs(
8909
8928
  "td",
8910
8929
  {
8911
- colSpan: Qt,
8930
+ colSpan: Ut,
8912
8931
  className: "border-b border-red-100 bg-red-50/60 px-3 py-1 text-[11px] leading-snug text-red-700 dark:border-red-900/30 dark:bg-red-900/10 dark:text-red-400",
8913
8932
  children: [
8914
8933
  "⚠ ",
@@ -8916,7 +8935,7 @@ function InlineTableField({
8916
8935
  ]
8917
8936
  }
8918
8937
  ) }),
8919
- Ee && !ct && Fn !== "panel" && N && N.length > 0 && /* @__PURE__ */ jsx("tr", { className: "border-b border-slate-100 bg-[#f0fbff]/60 dark:bg-nvr-cyan/5", children: /* @__PURE__ */ jsx("td", { colSpan: Qt, className: "px-3 py-2", children: /* @__PURE__ */ jsx("div", { className: "space-y-2", children: N.map((it) => {
8938
+ Ee && !ct && Fn !== "panel" && N && N.length > 0 && /* @__PURE__ */ jsx("tr", { className: "border-b border-slate-100 bg-[#f0fbff]/60 dark:bg-nvr-cyan/5", children: /* @__PURE__ */ jsx("td", { colSpan: Ut, className: "px-3 py-2", children: /* @__PURE__ */ jsx("div", { className: "space-y-2", children: N.map((it) => {
8920
8939
  const ns = typeof it == "string" ? it : it.field, xs = typeof it == "string" ? void 0 : it.hint, Dt = typeof it == "string" ? void 0 : it.match, rn = (ge == null ? void 0 : ge.draft) ?? gt, Js = Dt ? buildMatchedDrawer(Dt, rn, s, xe == null ? void 0 : xe.draft) : null;
8921
8940
  return /* @__PURE__ */ jsx(
8922
8941
  NestedRelationEditor,
@@ -9004,7 +9023,7 @@ function InlineTableField({
9004
9023
  const A = H.find((oe) => oe.addendumId === st), V = (d && (et || te) ? 1 : 0) + (o ? 1 : 0) + (te ? 1 : 0) + ls.length + 1;
9005
9024
  return A ? A.rows.length === 0 ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan: V, className: "px-3 py-8 text-center text-[11px] text-amber-500", children: "No proposed rows in this addendum" }) }) : A.rows.map((oe, pe) => {
9006
9025
  const _e = rs({ ...oe }), Fe = tt.find((Ge) => String(Ge.id) === String(_e.id)), Me = Fe ? rs({ ...Fe }) : void 0, Ee = !Me, rt = new Set(
9007
- Ee ? Ut.map((Ge) => Ge.field) : Ut.filter((Ge) => String(_e[Ge.field] ?? "") !== String(Me[Ge.field] ?? "")).map((Ge) => Ge.field)
9026
+ Ee ? Qt.map((Ge) => Ge.field) : Qt.filter((Ge) => String(_e[Ge.field] ?? "") !== String(Me[Ge.field] ?? "")).map((Ge) => Ge.field)
9008
9027
  ), ze = Ee || rt.size > 0;
9009
9028
  return /* @__PURE__ */ jsxs("tr", { className: ze ? "border-b border-amber-100 bg-amber-50/40" : "border-b border-slate-100", children: [
9010
9029
  d && (et || te) && /* @__PURE__ */ jsx("td", { className: "w-6" }),
@@ -9138,7 +9157,7 @@ function InlineTableField({
9138
9157
  ]
9139
9158
  }
9140
9159
  ),
9141
- pe && N && N.length > 0 && /* @__PURE__ */ jsx("tr", { className: "border-b border-slate-100 bg-[#f0fbff]/60 dark:bg-nvr-cyan/5", children: /* @__PURE__ */ jsx("td", { colSpan: Qt, className: "px-3 py-2", children: /* @__PURE__ */ jsx("div", { className: "space-y-2", children: N.map((Ee) => {
9160
+ pe && N && N.length > 0 && /* @__PURE__ */ jsx("tr", { className: "border-b border-slate-100 bg-[#f0fbff]/60 dark:bg-nvr-cyan/5", children: /* @__PURE__ */ jsx("td", { colSpan: Ut, className: "px-3 py-2", children: /* @__PURE__ */ jsx("div", { className: "space-y-2", children: N.map((Ee) => {
9142
9161
  const rt = typeof Ee == "string" ? Ee : Ee.field, ze = typeof Ee == "string" ? void 0 : Ee.hint;
9143
9162
  return /* @__PURE__ */ jsx(
9144
9163
  NestedRelationEditor,
@@ -9233,7 +9252,7 @@ function InlineTableField({
9233
9252
  DeletedRowsSection,
9234
9253
  {
9235
9254
  deletedRows: oe,
9236
- displayCols: Ut,
9255
+ displayCols: Qt,
9237
9256
  onOpenHistory: (pe, _e) => ve({ id: pe, ..._e })
9238
9257
  }
9239
9258
  );
@@ -9384,10 +9403,10 @@ function CatalogPickerField({
9384
9403
  }), T = q == null ? void 0 : q.display_template, j = d == null ? void 0 : d.draft, { resolvedFilter: _, missingParents: g } = useMemo(() => {
9385
9404
  const te = [], ke = (Le) => {
9386
9405
  if (typeof Le == "string" && Le.startsWith("$parent.")) {
9387
- const Qe = Le.slice(8), Ye = j == null ? void 0 : j[Qe];
9388
- return Ye == null || Ye === "" ? (te.push(Qe), Le) : Ye;
9406
+ const Ue = Le.slice(8), Ye = j == null ? void 0 : j[Ue];
9407
+ return Ye == null || Ye === "" ? (te.push(Ue), Le) : Ye;
9389
9408
  }
9390
- return Array.isArray(Le) ? Le.map(ke) : Le && typeof Le == "object" ? Object.fromEntries(Object.entries(Le).map(([Qe, Ye]) => [Qe, ke(Ye)])) : Le;
9409
+ return Array.isArray(Le) ? Le.map(ke) : Le && typeof Le == "object" ? Object.fromEntries(Object.entries(Le).map(([Ue, Ye]) => [Ue, ke(Ye)])) : Le;
9391
9410
  };
9392
9411
  return { resolvedFilter: r.filter ? ke(r.filter) : void 0, missingParents: [...new Set(te)] };
9393
9412
  }, [r.filter, j]), M = useMemo(() => {
@@ -9508,9 +9527,9 @@ function CatalogPickerField({
9508
9527
  ce.join(",")
9509
9528
  ],
9510
9529
  queryFn: async () => {
9511
- const Se = {}, Le = te.aggregate === "sum", Qe = Le ? 150 : 400;
9512
- for (let Ye = 0; Ye < ce.length; Ye += Qe) {
9513
- const Re = ce.slice(Ye, Ye + Qe);
9530
+ const Se = {}, Le = te.aggregate === "sum", Ue = Le ? 150 : 400;
9531
+ for (let Ye = 0; Ye < ce.length; Ye += Ue) {
9532
+ const Re = ce.slice(Ye, Ye + Ue);
9514
9533
  let wt = 1;
9515
9534
  for (; ; ) {
9516
9535
  const Rt = await l.request(
@@ -9541,10 +9560,10 @@ function CatalogPickerField({
9541
9560
  };
9542
9561
  })
9543
9562
  }), le = (te, ke) => {
9544
- var Le, Qe;
9563
+ var Le, Ue;
9545
9564
  const Se = (r.related_columns ?? []).findIndex((Ye) => Ye.key === te);
9546
9565
  if (Se !== -1)
9547
- return (Qe = (Le = I[Se]) == null ? void 0 : Le.data) == null ? void 0 : Qe[ke];
9566
+ return (Ue = (Le = I[Se]) == null ? void 0 : Le.data) == null ? void 0 : Ue[ke];
9548
9567
  }, J = (te) => {
9549
9568
  var wt;
9550
9569
  const ke = r.qty_warning;
@@ -9553,9 +9572,9 @@ function CatalogPickerField({
9553
9572
  if (Se <= 0) return null;
9554
9573
  const Le = (r.related_columns ?? []).findIndex((Rt) => Rt.key === ke.column);
9555
9574
  if (Le === -1) return null;
9556
- const Qe = (wt = I[Le]) == null ? void 0 : wt.data;
9557
- if (Qe === void 0) return null;
9558
- const Ye = Qe[te], Re = Ye == null || Ye === "" ? 0 : Number(Ye);
9575
+ const Ue = (wt = I[Le]) == null ? void 0 : wt.data;
9576
+ if (Ue === void 0) return null;
9577
+ const Ye = Ue[te], Re = Ye == null || Ye === "" ? 0 : Number(Ye);
9559
9578
  return Number.isNaN(Re) ? null : Se > Re ? { available: Re, qty: Se } : null;
9560
9579
  }, be = r.qty_warning ? r.qty_warning.label ?? ((Bt = (r.related_columns ?? []).find((te) => {
9561
9580
  var ke;
@@ -9577,8 +9596,8 @@ function CatalogPickerField({
9577
9596
  if (!te || te.status !== "failed") return null;
9578
9597
  const ke = te.payload, Se = /* @__PURE__ */ new Set();
9579
9598
  for (const Le of Array.isArray(ke == null ? void 0 : ke.products) ? ke.products : [])
9580
- for (const Qe of Object.values(Le ?? {}))
9581
- (typeof Qe == "string" || typeof Qe == "number") && Qe !== "" && Se.add(String(Qe));
9599
+ for (const Ue of Object.values(Le ?? {}))
9600
+ (typeof Ue == "string" || typeof Ue == "number") && Ue !== "" && Se.add(String(Ue));
9582
9601
  return Se.size === 0 ? null : { idents: Se, error: te.last_error ?? "Submission failed" };
9583
9602
  }, [Y]), de = ne.map((te) => te.key).join(","), { data: he } = useQuery({
9584
9603
  queryKey: ["catalog-suberr-idents", C, Ne.join(","), de],
@@ -9602,8 +9621,8 @@ function CatalogPickerField({
9602
9621
  return [
9603
9622
  Ht(te),
9604
9623
  ...Ne.map((Le) => {
9605
- const Qe = (ke == null ? void 0 : ke[Le]) ?? $t(te)[Le];
9606
- return Qe != null && Qe !== "" ? String(Qe) : null;
9624
+ const Ue = (ke == null ? void 0 : ke[Le]) ?? $t(te)[Le];
9625
+ return Ue != null && Ue !== "" ? String(Ue) : null;
9607
9626
  })
9608
9627
  ].some((Le) => Le && ue.idents.has(Le)) ? ue.error : null;
9609
9628
  }, qe = r.summary_fields ?? [], Pe = H.map((te) => String(te.id)).join(","), ge = useQueries({
@@ -9618,11 +9637,11 @@ function CatalogPickerField({
9618
9637
  fields: `${Se.fk_to_child},${Se.related_field}`,
9619
9638
  filter: JSON.stringify({ [Se.fk_to_child]: { _in: ke } })
9620
9639
  })
9621
- ).then((vt) => vt.data ?? []).catch(() => []), Qe = [...new Set(Le.map((vt) => String(vt[Se.related_field])))], Ye = Se.label_field ?? "name", Re = Qe.length ? await l.request(
9640
+ ).then((vt) => vt.data ?? []).catch(() => []), Ue = [...new Set(Le.map((vt) => String(vt[Se.related_field])))], Ye = Se.label_field ?? "name", Re = Ue.length ? await l.request(
9622
9641
  get$1(`/items/${Se.related_collection}`, {
9623
9642
  limit: 500,
9624
9643
  fields: `id,${Ye}`,
9625
- filter: JSON.stringify({ id: { _in: Qe } })
9644
+ filter: JSON.stringify({ id: { _in: Ue } })
9626
9645
  })
9627
9646
  ).then((vt) => vt.data ?? []).catch(() => []) : [], wt = new Map(Re.map((vt) => [String(vt.id), String(vt[Ye] ?? vt.id)])), Rt = {};
9628
9647
  for (const vt of Le) {
@@ -9635,13 +9654,13 @@ function CatalogPickerField({
9635
9654
  staleTime: 15e3
9636
9655
  }))
9637
9656
  }), He = (te, ke) => {
9638
- var Qe, Ye;
9657
+ var Ue, Ye;
9639
9658
  if (!te.m2m) return ke.row[te.field];
9640
9659
  const Se = qe.filter((Re) => Re.m2m).findIndex((Re) => Re.field === te.field);
9641
9660
  if (Se === -1) return;
9642
9661
  const Le = ke.row.id;
9643
9662
  if (Le != null)
9644
- return (Ye = (Qe = ge[Se]) == null ? void 0 : Qe.data) == null ? void 0 : Ye[String(Le)];
9663
+ return (Ye = (Ue = ge[Se]) == null ? void 0 : Ue.data) == null ? void 0 : Ye[String(Le)];
9645
9664
  }, mt = r.columns ?? [], yt = r.related_columns ?? [], jt = mt.filter((te) => !te.summary_only), Tt = yt.filter((te) => !te.summary_only), ot = mt.filter((te) => !te.sections_only), ht = yt.filter((te) => !te.sections_only), Pt = jt.length > 0 || Tt.length > 0, st = (te, ke) => {
9646
9665
  let Se = te;
9647
9666
  for (const Le of ke.split(".")) {
@@ -9696,14 +9715,14 @@ function CatalogPickerField({
9696
9715
  for (const Se of P) {
9697
9716
  const Le = applyDisplayTemplate(T, Se);
9698
9717
  if (te && !Le.toLowerCase().includes(te)) continue;
9699
- const Qe = De(Se) || "Uncategorized";
9700
- ke.has(Qe) || ke.set(Qe, []), ke.get(Qe).push({ id: String(Se.id), label: Le, row: Se });
9718
+ const Ue = De(Se) || "Uncategorized";
9719
+ ke.has(Ue) || ke.set(Ue, []), ke.get(Ue).push({ id: String(Se.id), label: Le, row: Se });
9701
9720
  }
9702
9721
  return [...ke.entries()].sort(
9703
9722
  ([Se], [Le]) => Se === "Uncategorized" ? 1 : Le === "Uncategorized" ? -1 : Se.localeCompare(Le)
9704
9723
  ).map(([Se, Le]) => ({
9705
9724
  name: Se,
9706
- items: Le.sort((Qe, Ye) => Qe.label.localeCompare(Ye.label))
9725
+ items: Le.sort((Ue, Ye) => Ue.label.localeCompare(Ye.label))
9707
9726
  }));
9708
9727
  }, [P, T, x, r.section_by]);
9709
9728
  if (!k.current && at.length > 0) {
@@ -9719,13 +9738,13 @@ function CatalogPickerField({
9719
9738
  if (!Se.copy_to) continue;
9720
9739
  let Le = le(Se.key, te);
9721
9740
  if (Le === void 0) {
9722
- const Qe = resolveRelatedMatch(Se.match, j);
9723
- if (Qe === null) continue;
9741
+ const Ue = resolveRelatedMatch(Se.match, j);
9742
+ if (Ue === null) continue;
9724
9743
  Le = await l.request(
9725
9744
  get$1(`/items/${Se.collection}`, {
9726
9745
  limit: 1,
9727
9746
  fields: `${Se.item_field},${Se.value_field}`,
9728
- filter: JSON.stringify({ ...Qe, [Se.item_field]: { _eq: te } })
9747
+ filter: JSON.stringify({ ...Ue, [Se.item_field]: { _eq: te } })
9729
9748
  })
9730
9749
  ).then((Ye) => {
9731
9750
  var Re, wt;
@@ -9738,18 +9757,18 @@ function CatalogPickerField({
9738
9757
  return ke;
9739
9758
  }
9740
9759
  function qt(te, ke, Se, Le = {}) {
9741
- const Qe = {
9760
+ const Ue = {
9742
9761
  [r.item_field]: Se.id ?? te,
9743
9762
  [h]: ke
9744
9763
  };
9745
9764
  for (const [Ye, Re] of Object.entries(r.copy_fields ?? {}))
9746
- Se[Re] !== void 0 && (Qe[Ye] = Se[Re]);
9747
- Object.assign(Qe, Le);
9765
+ Se[Re] !== void 0 && (Ue[Ye] = Se[Re]);
9766
+ Object.assign(Ue, Le);
9748
9767
  for (const [Ye, Re] of Object.entries(r.compute_fields ?? {})) {
9749
- const wt = evalClientFormula(Re, Qe);
9750
- wt !== null && (Qe[Ye] = wt);
9768
+ const wt = evalClientFormula(Re, Ue);
9769
+ wt !== null && (Ue[Ye] = wt);
9751
9770
  }
9752
- return Qe;
9771
+ return Ue;
9753
9772
  }
9754
9773
  async function et(te, ke, Se) {
9755
9774
  const Le = ke.trim() === "" ? 0 : Number(ke);
@@ -9801,7 +9820,7 @@ function CatalogPickerField({
9801
9820
  async function Jt(te, ke, Se) {
9802
9821
  const Le = Se.trim() === "" ? null : Number(Se);
9803
9822
  if (Se.trim() !== "" && Number.isNaN(Le)) return;
9804
- const Qe = (Re) => {
9823
+ const Ue = (Re) => {
9805
9824
  const wt = { ...Re, [ke]: Le };
9806
9825
  for (const [Rt, vt] of Object.entries(r.compute_fields ?? {})) {
9807
9826
  const Kt = evalClientFormula(vt, wt);
@@ -9812,14 +9831,14 @@ function CatalogPickerField({
9812
9831
  if (m) {
9813
9832
  const Re = B.get(te);
9814
9833
  if (Re === void 0) return;
9815
- o == null || o.updateRow(e, t, Re, Qe(K[Re]));
9834
+ o == null || o.updateRow(e, t, Re, Ue(K[Re]));
9816
9835
  return;
9817
9836
  }
9818
9837
  const Ye = G.get(te);
9819
9838
  if ((Ye == null ? void 0 : Ye.id) != null) {
9820
9839
  f((Re) => new Set(Re).add(te));
9821
9840
  try {
9822
- const { id: Re, ...wt } = Qe(Ye);
9841
+ const { id: Re, ...wt } = Ue(Ye);
9823
9842
  await l.request(patch$1(`/items/${e}/${Ye.id}`, wt)), i.invalidateQueries({ queryKey: ["o2m-rows", e, t, s] });
9824
9843
  } catch {
9825
9844
  } finally {
@@ -9844,18 +9863,18 @@ function CatalogPickerField({
9844
9863
  var Re;
9845
9864
  return ((Re = Ye.data) == null ? void 0 : Re[0]) ?? { id: te };
9846
9865
  }).catch(() => ({ id: te })));
9847
- const Qe = (ie(ke) ?? 0) + 1;
9848
- await et(ke, String(Qe), Le);
9866
+ const Ue = (ie(ke) ?? 0) + 1;
9867
+ await et(ke, String(Ue), Le);
9849
9868
  }
9850
9869
  const is = ne.length, Vt = Object.keys(r.copy_fields ?? {}), _s = Object.keys(r.compute_fields ?? {}), Ms = (te, ke) => {
9851
- const Se = ie(te), Le = F[te], Qe = Le !== void 0 ? Le : Se && Se > 0 ? String(Se) : "";
9870
+ const Se = ie(te), Le = F[te], Ue = Le !== void 0 ? Le : Se && Se > 0 ? String(Se) : "";
9852
9871
  return /* @__PURE__ */ jsx(
9853
9872
  "input",
9854
9873
  {
9855
9874
  type: "number",
9856
9875
  min: 0,
9857
9876
  disabled: a,
9858
- value: Qe,
9877
+ value: Ue,
9859
9878
  placeholder: "0",
9860
9879
  onChange: (Ye) => y((Re) => ({ ...Re, [te]: Ye.target.value })),
9861
9880
  onBlur: (Ye) => {
@@ -9946,7 +9965,7 @@ function CatalogPickerField({
9946
9965
  !N.has("__favorites__") && we.filter(
9947
9966
  (te) => !x.trim() || applyDisplayTemplate(T, te).toLowerCase().includes(x.trim().toLowerCase())
9948
9967
  ).map((te, ke) => {
9949
- const Se = String(te.id), Le = ie(Se), Qe = J(Se);
9968
+ const Se = String(te.id), Le = ie(Se), Ue = J(Se);
9950
9969
  return /* @__PURE__ */ jsxs(
9951
9970
  "div",
9952
9971
  {
@@ -9954,17 +9973,17 @@ function CatalogPickerField({
9954
9973
  "flex items-center gap-2 border-b border-slate-100 px-3 py-1 dark:border-border/50",
9955
9974
  ke % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
9956
9975
  (Le ?? 0) > 0 && "bg-[#00ceff0d]",
9957
- Qe && "bg-amber-50 dark:bg-amber-900/15"
9976
+ Ue && "bg-amber-50 dark:bg-amber-900/15"
9958
9977
  ),
9959
9978
  children: [
9960
9979
  ve(Se),
9961
9980
  /* @__PURE__ */ jsx("span", { className: Xt, children: applyDisplayTemplate(T, te) }),
9962
9981
  It(Se, te),
9963
- Qe && /* @__PURE__ */ jsx(
9982
+ Ue && /* @__PURE__ */ jsx(
9964
9983
  AlertTriangle,
9965
9984
  {
9966
9985
  className: "h-3.5 w-3.5 shrink-0 text-amber-500",
9967
- "aria-label": `${be} ${Qe.available} — ${Qe.qty} requested`
9986
+ "aria-label": `${be} ${Ue.available} — ${Ue.qty} requested`
9968
9987
  }
9969
9988
  ),
9970
9989
  b.has(Se) && /* @__PURE__ */ jsx(Loader2, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" }),
@@ -9977,7 +9996,7 @@ function CatalogPickerField({
9977
9996
  ] }),
9978
9997
  g.length === 0 && at.map((te) => {
9979
9998
  const ke = N.has(te.name), Se = te.items.reduce(
9980
- (Le, Qe) => Le + ((ie(Qe.id) ?? 0) > 0 ? 1 : 0),
9999
+ (Le, Ue) => Le + ((ie(Ue.id) ?? 0) > 0 ? 1 : 0),
9981
10000
  0
9982
10001
  );
9983
10002
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
@@ -9986,8 +10005,8 @@ function CatalogPickerField({
9986
10005
  {
9987
10006
  type: "button",
9988
10007
  onClick: () => v((Le) => {
9989
- const Qe = new Set(Le);
9990
- return Qe.has(te.name) ? Qe.delete(te.name) : Qe.add(te.name), Qe;
10008
+ const Ue = new Set(Le);
10009
+ return Ue.has(te.name) ? Ue.delete(te.name) : Ue.add(te.name), Ue;
9991
10010
  }),
9992
10011
  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",
9993
10012
  children: [
@@ -10009,14 +10028,14 @@ function CatalogPickerField({
10009
10028
  ]
10010
10029
  }
10011
10030
  ),
10012
- !ke && te.items.map((Le, Qe) => {
10031
+ !ke && te.items.map((Le, Ue) => {
10013
10032
  const Ye = ie(Le.id), Re = J(Le.id);
10014
10033
  return /* @__PURE__ */ jsxs(
10015
10034
  "div",
10016
10035
  {
10017
10036
  className: cn$1(
10018
10037
  "flex items-center gap-2 border-b border-slate-100 px-3 py-1 dark:border-border/50",
10019
- Qe % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
10038
+ Ue % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
10020
10039
  (Ye ?? 0) > 0 && "bg-[#00ceff0d]",
10021
10040
  Re && "bg-amber-50 dark:bg-amber-900/15"
10022
10041
  ),
@@ -10086,7 +10105,7 @@ function CatalogPickerField({
10086
10105
  ] })
10087
10106
  ] }),
10088
10107
  ne.length === 0 ? /* @__PURE__ */ jsx("p", { className: "px-3 py-4 text-center text-slate-400", children: "Nothing picked yet" }) : (() => {
10089
- const te = ot.filter((Re) => !Re.format), ke = te[0], Se = te.slice(1), Le = ot.filter((Re) => !!Re.format), Qe = (Re, wt) => Re === !0 || Re === "true" ? "✓" : Re === !1 || Re === "false" || Re == null || Re === "" ? "—" : _t(Re, wt), Ye = (Re) => /* @__PURE__ */ jsx("span", { className: "w-20 shrink-0 text-right text-[11px] font-medium text-slate-500", children: Re });
10108
+ const te = ot.filter((Re) => !Re.format), ke = te[0], Se = te.slice(1), Le = ot.filter((Re) => !!Re.format), Ue = (Re, wt) => Re === !0 || Re === "true" ? "✓" : Re === !1 || Re === "false" || Re == null || Re === "" ? "—" : _t(Re, wt), Ye = (Re) => /* @__PURE__ */ jsx("span", { className: "w-20 shrink-0 text-right text-[11px] font-medium text-slate-500", children: Re });
10090
10109
  return /* @__PURE__ */ jsxs("div", { children: [
10091
10110
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 border-b border-slate-200 px-3 py-1.5 dark:border-border", children: [
10092
10111
  /* @__PURE__ */ jsx("span", { className: "flex-1 text-[11px] font-medium text-slate-500", children: "Item" }),
@@ -10210,19 +10229,19 @@ function CatalogPickerField({
10210
10229
  Le.map((bt) => /* @__PURE__ */ jsxs("span", { className: "whitespace-nowrap", children: [
10211
10230
  /* @__PURE__ */ jsx("span", { className: "text-slate-500 dark:text-muted-foreground", children: bt.label ?? titleCase$2(bt.field.split(".")[0]) }),
10212
10231
  " ",
10213
- /* @__PURE__ */ jsx("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: Qe(st($t(Re.key), bt.field), bt.format) })
10232
+ /* @__PURE__ */ jsx("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: Ue(st($t(Re.key), bt.field), bt.format) })
10214
10233
  ] }, bt.field)),
10215
10234
  ht.map((bt) => /* @__PURE__ */ jsxs("span", { className: "whitespace-nowrap", children: [
10216
10235
  /* @__PURE__ */ jsx("span", { className: "text-slate-500 dark:text-muted-foreground", children: bt.label ?? titleCase$2(bt.key) }),
10217
10236
  " ",
10218
- /* @__PURE__ */ jsx("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: Qe(le(bt.key, Re.key), bt.format) })
10237
+ /* @__PURE__ */ jsx("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: Ue(le(bt.key, Re.key), bt.format) })
10219
10238
  ] }, bt.key)),
10220
10239
  qe.map((bt) => {
10221
10240
  const St = He(bt, Re);
10222
10241
  return /* @__PURE__ */ jsxs("span", { className: "whitespace-nowrap", children: [
10223
10242
  /* @__PURE__ */ jsx("span", { className: "text-slate-500 dark:text-muted-foreground", children: bt.label ?? titleCase$2(bt.field) }),
10224
10243
  " ",
10225
- /* @__PURE__ */ jsx("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: Qe(St, bt.format) })
10244
+ /* @__PURE__ */ jsx("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: Ue(St, bt.format) })
10226
10245
  ] }, bt.field);
10227
10246
  })
10228
10247
  ] }),
@@ -15336,7 +15355,7 @@ function ItemActionButtons({
15336
15355
  ),
15337
15356
  onSuccess: (o) => {
15338
15357
  var d;
15339
- toast.success(((d = o == null ? void 0 : o.data) == null ? void 0 : d.message) ?? "Action completed"), n.invalidateQueries({ queryKey: ["item", e, String(t)] }), n.invalidateQueries({ queryKey: ["erp-submissions", e, String(t)] });
15358
+ toast.success(((d = o == null ? void 0 : o.data) == null ? void 0 : d.message) ?? "Action completed"), n.invalidateQueries({ queryKey: ["item", e, String(t)] }), n.invalidateQueries({ queryKey: ["erp-submissions", e, String(t)] }), n.invalidateQueries({ queryKey: ["o2m-rows"] }), n.invalidateQueries({ queryKey: ["pipeline-instance", e, String(t)] });
15340
15359
  },
15341
15360
  onError: (o, d) => {
15342
15361
  const c = o == null ? void 0 : o.response;
@@ -18572,7 +18591,7 @@ function ItemEditForm({
18572
18591
  is((O) => [...O, $]);
18573
18592
  }, []), [_s, Ms] = useState([]), Bt = useCallback(($) => {
18574
18593
  Ms((O) => [...O, $]);
18575
- }, []), [te, ke] = useState(/* @__PURE__ */ new Map()), [Se, Le] = useState(/* @__PURE__ */ new Map()), [Qe, Ye] = useState(/* @__PURE__ */ new Map()), Re = useMemo(() => ({
18594
+ }, []), [te, ke] = useState(/* @__PURE__ */ new Map()), [Se, Le] = useState(/* @__PURE__ */ new Map()), [Ue, Ye] = useState(/* @__PURE__ */ new Map()), Re = useMemo(() => ({
18576
18595
  getPendingRows: ($, O) => te.get(`${$}.${O}`) ?? [],
18577
18596
  queueRow: ($, O, W) => ke((Z) => {
18578
18597
  const ae = new Map(Z), ye = `${$}.${O}`;
@@ -18591,7 +18610,7 @@ function ItemEditForm({
18591
18610
  return Ke.splice(Z, 0, Ae), ye.set(Te, Ke), ye;
18592
18611
  }),
18593
18612
  getPendingEdits: ($, O) => Se.get(`${$}.${O}`) ?? /* @__PURE__ */ new Map(),
18594
- getPendingDeletes: ($, O) => Qe.get(`${$}.${O}`) ?? /* @__PURE__ */ new Set(),
18613
+ getPendingDeletes: ($, O) => Ue.get(`${$}.${O}`) ?? /* @__PURE__ */ new Set(),
18595
18614
  queueEdit: ($, O, W, Z) => Le((ae) => {
18596
18615
  const ye = new Map(ae), Te = `${$}.${O}`, Ke = new Map(ye.get(Te) ?? []);
18597
18616
  return Ke.set(W, { ...Ke.get(W) ?? {}, ...Z }), ye.set(Te, Ke), ye;
@@ -18613,7 +18632,7 @@ function ItemEditForm({
18613
18632
  const ae = new Map(Z), ye = `${$}.${O}`, Te = new Set(ae.get(ye) ?? []);
18614
18633
  return Te.delete(W), ae.set(ye, Te), ae;
18615
18634
  })
18616
- }), [te, Se, Qe]), [wt, Rt] = useState([]), vt = useRef(!1), Kt = useRef(!1), [xt, bt] = useState(/* @__PURE__ */ new Map()), [St, bs] = useState(/* @__PURE__ */ new Map()), tt = useMemo(
18635
+ }), [te, Se, Ue]), [wt, Rt] = useState([]), vt = useRef(!1), Kt = useRef(!1), [xt, bt] = useState(/* @__PURE__ */ new Map()), [St, bs] = useState(/* @__PURE__ */ new Map()), tt = useMemo(
18617
18636
  () => ({
18618
18637
  getStagedLinks: ($) => xt.get($) ?? [],
18619
18638
  getStagedUnlinks: ($) => St.get($) ?? /* @__PURE__ */ new Set(),
@@ -18667,9 +18686,9 @@ function ItemEditForm({
18667
18686
  }
18668
18687
  const Ze = [];
18669
18688
  let ut = !1;
18670
- const Ue = 10;
18671
- for (let Be = 0; Be < $.lines.length; Be += Ue) {
18672
- const Xe = $.lines.slice(Be, Be + Ue), pt = await Promise.all(
18689
+ const Qe = 10;
18690
+ for (let Be = 0; Be < $.lines.length; Be += Qe) {
18691
+ const Xe = $.lines.slice(Be, Be + Qe), pt = await Promise.all(
18673
18692
  Xe.map(
18674
18693
  (kt) => q.request(
18675
18694
  post$1("/field-rules/evaluate", {
@@ -18724,7 +18743,7 @@ function ItemEditForm({
18724
18743
  }, [e, K, Re, tt, E, q]), [es, un] = useState(null), [ln, Ln] = useState(!1), En = useCallback(
18725
18744
  async ($, O) => {
18726
18745
  const W = O.reimport;
18727
- if (!W || (It || [...te.values()].some((Ae) => Ae.length > 0) || [...Se.values()].some((Ae) => Ae.size > 0) || [...Qe.values()].some((Ae) => Ae.size > 0)) && !window.confirm(
18746
+ if (!W || (It || [...te.values()].some((Ae) => Ae.length > 0) || [...Se.values()].some((Ae) => Ae.size > 0) || [...Ue.values()].some((Ae) => Ae.size > 0)) && !window.confirm(
18728
18747
  "Unsaved changes will be combined with the re-import staging. Continue?"
18729
18748
  ))
18730
18749
  return;
@@ -18771,7 +18790,7 @@ function ItemEditForm({
18771
18790
  }
18772
18791
  Rt([]), un({ diff: Ke, result: $, template: O, existingRows: Te });
18773
18792
  },
18774
- [It, te, Se, Qe, K, e, q, g]
18793
+ [It, te, Se, Ue, K, e, q, g]
18775
18794
  ), rs = useCallback(
18776
18795
  async ($, O, W, Z) => {
18777
18796
  const ae = W.reimport;
@@ -18784,8 +18803,8 @@ function ItemEditForm({
18784
18803
  if (ae.header_fields === "overwrite")
18785
18804
  Je[Ze] = ut;
18786
18805
  else {
18787
- const Ue = ge.current[Ze];
18788
- (Ue == null || Ue === "") && (Je[Ze] = ut);
18806
+ const Qe = ge.current[Ze];
18807
+ (Qe == null || Qe === "") && (Je[Ze] = ut);
18789
18808
  }
18790
18809
  Object.keys(Je).length > 0 && (ge.current = { ...ge.current, ...Je }, Pe((Ze) => ({ ...Ze, ...Je })));
18791
18810
  }
@@ -18796,7 +18815,7 @@ function ItemEditForm({
18796
18815
  const Je = Ke.many_collection, Ze = Ke.many_field;
18797
18816
  let ut = $.creates;
18798
18817
  if (ut.length > 0) {
18799
- const Ue = (E ?? []).find((kt) => kt.field === O.line_target_field), Be = Ue == null ? void 0 : Ue.options, Xe = typeof Be == "string" ? (() => {
18818
+ const Qe = (E ?? []).find((kt) => kt.field === O.line_target_field), Be = Qe == null ? void 0 : Qe.options, Xe = typeof Be == "string" ? (() => {
18800
18819
  try {
18801
18820
  return JSON.parse(Be);
18802
18821
  } catch {
@@ -18841,18 +18860,18 @@ function ItemEditForm({
18841
18860
  }), ut = ut.map((Ie, nt) => ({ ...Ie, ...Ot[nt] }));
18842
18861
  }
18843
18862
  }
18844
- for (const Ue of ut)
18845
- Re.queueRow(Je, Ze, Ue);
18846
- for (const Ue of $.updates)
18847
- Re.queueEdit(Je, Ze, Ue.id, Ue.changes);
18848
- for (const Ue of $.deletes)
18849
- Re.queueDelete(Je, Ze, Ue);
18863
+ for (const Qe of ut)
18864
+ Re.queueRow(Je, Ze, Qe);
18865
+ for (const Qe of $.updates)
18866
+ Re.queueEdit(Je, Ze, Qe.id, Qe.changes);
18867
+ for (const Qe of $.deletes)
18868
+ Re.queueDelete(Je, Ze, Qe);
18850
18869
  if (ae.lines === "upsert" || ae.lines === "upsert_delete") {
18851
- const Ue = buildReimportFileRows(O), Be = /* @__PURE__ */ new Map();
18870
+ const Qe = buildReimportFileRows(O), Be = /* @__PURE__ */ new Map();
18852
18871
  for (const pt of Z)
18853
18872
  Be.set(reimportMatchKey(pt, ae.match_by), String(pt.id));
18854
18873
  const Xe = /* @__PURE__ */ new Map();
18855
- for (const pt of Ue) {
18874
+ for (const pt of Qe) {
18856
18875
  const kt = Be.get(reimportMatchKey(pt, ae.match_by));
18857
18876
  if (kt)
18858
18877
  for (const [Et, Ot] of Object.entries(pt)) {
@@ -18928,8 +18947,8 @@ function ItemEditForm({
18928
18947
  fields: "id",
18929
18948
  limit: 2e3
18930
18949
  })
18931
- ).then((Ue) => Ue.data ?? []);
18932
- for (const Ue of ut) tt.stageUnlink(Ze, Ue.id);
18950
+ ).then((Qe) => Qe.data ?? []);
18951
+ for (const Qe of ut) tt.stageUnlink(Ze, Qe.id);
18933
18952
  } catch {
18934
18953
  Te.push({
18935
18954
  severity: "error",
@@ -18945,7 +18964,7 @@ function ItemEditForm({
18945
18964
  if (ye && Je === ye) continue;
18946
18965
  const ut = Ae(Je);
18947
18966
  if (ut) {
18948
- const Ue = ut.one_field ?? `${ut.many_collection}.${ut.junction_field}`;
18967
+ const Qe = ut.one_field ?? `${ut.many_collection}.${ut.junction_field}`;
18949
18968
  let Be = /* @__PURE__ */ new Set();
18950
18969
  try {
18951
18970
  const Xe = await q.request(
@@ -18961,7 +18980,7 @@ function ItemEditForm({
18961
18980
  } catch {
18962
18981
  }
18963
18982
  for (const Xe of Ze)
18964
- Be.has(String(Xe)) || tt.stageLink(Ue, Xe);
18983
+ Be.has(String(Xe)) || tt.stageLink(Qe, Xe);
18965
18984
  } else
18966
18985
  Te.push({
18967
18986
  severity: "error",
@@ -19065,15 +19084,15 @@ function ItemEditForm({
19065
19084
  St.get(W.stagingKey)
19066
19085
  );
19067
19086
  }), $;
19068
- }, [Bs, Ss, xt, St, g, M]), Ut = useRef(ms);
19069
- Ut.current = ms;
19087
+ }, [Bs, Ss, xt, St, g, M]), Qt = useRef(ms);
19088
+ Qt.current = ms;
19070
19089
  const ts = useCallback(
19071
19090
  ($) => {
19072
19091
  var O;
19073
19092
  return (O = ms[$]) == null ? void 0 : O.ids;
19074
19093
  },
19075
19094
  [ms]
19076
- ), Un = useCallback(
19095
+ ), Qn = useCallback(
19077
19096
  ($) => {
19078
19097
  var O;
19079
19098
  return ((O = ms[$]) == null ? void 0 : O.known) ?? !0;
@@ -19108,16 +19127,16 @@ function ItemEditForm({
19108
19127
  const Ze = Je.data;
19109
19128
  if (!Ze) return;
19110
19129
  const ut = {};
19111
- for (const [Ue, Be] of Object.entries(Ke)) {
19130
+ for (const [Qe, Be] of Object.entries(Ke)) {
19112
19131
  const Xe = String(Be).split("||").map((kt) => kt.trim());
19113
19132
  let pt = null;
19114
19133
  for (const kt of Xe)
19115
19134
  if (pt = Ze[kt], pt != null && pt !== "") break;
19116
- ut[Ue] = pt ?? null;
19135
+ ut[Qe] = pt ?? null;
19117
19136
  }
19118
- ge.current = { ...ge.current, ...ut }, Pe((Ue) => ({ ...Ue, ...ut })), Xt(!0);
19119
- for (const [Ue, Be] of Object.entries(ut))
19120
- Ue !== $ && Be != null && Be !== "" && gs(Ue, Be, W + 1);
19137
+ ge.current = { ...ge.current, ...ut }, Pe((Qe) => ({ ...Qe, ...ut })), Xt(!0);
19138
+ for (const [Qe, Be] of Object.entries(ut))
19139
+ Qe !== $ && Be != null && Be !== "" && gs(Qe, Be, W + 1);
19121
19140
  }).catch(() => {
19122
19141
  });
19123
19142
  }
@@ -19130,7 +19149,7 @@ function ItemEditForm({
19130
19149
  for (const [ye, Te] of Object.entries(Z)) {
19131
19150
  const Ke = Bs.get(ye);
19132
19151
  if (!Ke) continue;
19133
- const Ae = idsNeedingStaging(Te, (ae = Ut.current[ye]) == null ? void 0 : ae.ids);
19152
+ const Ae = idsNeedingStaging(Te, (ae = Qt.current[ye]) == null ? void 0 : ae.ids);
19134
19153
  for (const Je of Ae) tt.stageLink(Ke.stagingKey, Je);
19135
19154
  }
19136
19155
  if (Object.keys(O).length > 0) {
@@ -19189,14 +19208,14 @@ function ItemEditForm({
19189
19208
  }
19190
19209
  for (const [$, O] of Tn) {
19191
19210
  const W = xt.get(O.stagingKey), Z = St.get(O.stagingKey), ae = gn.current[$];
19192
- ae && ae.links === W && ae.unlinks === Z || (gn.current[$] = { links: W, unlinks: Z }, Un($) && zs($, ts($) ?? []));
19211
+ ae && ae.links === W && ae.unlinks === Z || (gn.current[$] = { links: W, unlinks: Z }, Qn($) && zs($, ts($) ?? []));
19193
19212
  }
19194
19213
  }, [
19195
19214
  xt,
19196
19215
  St,
19197
19216
  Tn,
19198
19217
  ts,
19199
- Un,
19218
+ Qn,
19200
19219
  zs
19201
19220
  ]);
19202
19221
  const Es = useCallback(
@@ -19237,7 +19256,7 @@ function ItemEditForm({
19237
19256
  enabled: !!g && !M,
19238
19257
  staleTime: 3e4
19239
19258
  }))
19240
- }), Us = useMemo(() => {
19259
+ }), Qs = useMemo(() => {
19241
19260
  const $ = {};
19242
19261
  return on.forEach((O, W) => {
19243
19262
  var ae;
@@ -19254,13 +19273,13 @@ function ItemEditForm({
19254
19273
  });
19255
19274
  },
19256
19275
  [E]
19257
- ), Qn = N && !M && !!(B != null && B.item_locking_enabled), {
19276
+ ), Un = N && !M && !!(B != null && B.item_locking_enabled), {
19258
19277
  lockHolder: Wn,
19259
19278
  acquired: Xs,
19260
19279
  isReadOnly: Zs,
19261
19280
  takeOver: Vn,
19262
19281
  takingOver: ls
19263
- } = useItemLock(e, M ? void 0 : g, Qn), Cs = (L == null ? void 0 : L.assignments) ?? [], vn = Cs.some(($) => $.lock_conditions), Os = !!(B != null && B.addendums_enabled) && !M, { data: Qs } = useQuery({
19282
+ } = useItemLock(e, M ? void 0 : g, Un), Cs = (L == null ? void 0 : L.assignments) ?? [], vn = Cs.some(($) => $.lock_conditions), Os = !!(B != null && B.addendums_enabled) && !M, { data: Us } = useQuery({
19264
19283
  queryKey: ["current-user-me"],
19265
19284
  queryFn: () => q.request(get$1("/users/me")).then(($) => $.data ?? null),
19266
19285
  staleTime: 5 * 6e4,
@@ -19277,7 +19296,7 @@ function ItemEditForm({
19277
19296
  try {
19278
19297
  const Z = JSON.parse(B.addendum_allowed_roles);
19279
19298
  if (Array.isArray(Z) && Z.length > 0) {
19280
- const ae = (Qs == null ? void 0 : Qs.role) ?? null;
19299
+ const ae = (Us == null ? void 0 : Us.role) ?? null;
19281
19300
  if (!ae || !Z.includes(ae)) return !1;
19282
19301
  }
19283
19302
  } catch {
@@ -19292,7 +19311,7 @@ function ItemEditForm({
19292
19311
  } catch {
19293
19312
  }
19294
19313
  return !0;
19295
- }, [Os, B == null ? void 0 : B.addendum_allowed_roles, B == null ? void 0 : B.addendum_allowed_states, Qs == null ? void 0 : Qs.role, ps]), { data: Zt = [] } = useQuery({
19314
+ }, [Os, B == null ? void 0 : B.addendum_allowed_roles, B == null ? void 0 : B.addendum_allowed_states, Us == null ? void 0 : Us.role, ps]), { data: Zt = [] } = useQuery({
19296
19315
  queryKey: ["addendums", e, g],
19297
19316
  queryFn: () => q.request(
19298
19317
  get$1(`/addendums/${e}/${g}`)
@@ -19387,7 +19406,7 @@ function ItemEditForm({
19387
19406
  })
19388
19407
  );
19389
19408
  }), $;
19390
- }, [$s, Ts]), [Hs, Dn] = useState(() => /* @__PURE__ */ new Set()), U = useCallback(($, O) => {
19409
+ }, [$s, Ts]), [Hs, Dn] = useState(() => /* @__PURE__ */ new Set()), Q = useCallback(($, O) => {
19391
19410
  Dn((W) => {
19392
19411
  if (W.has($) === O) return W;
19393
19412
  const Z = new Set(W);
@@ -19403,7 +19422,7 @@ function ItemEditForm({
19403
19422
  Z !== null && $.set(O.field, Z);
19404
19423
  }
19405
19424
  return $;
19406
- }, [E, pn, Rn]), Q = useMemo(
19425
+ }, [E, pn, Rn]), U = useMemo(
19407
19426
  () => tn ? { ...qe, ...tn } : qe,
19408
19427
  [qe, tn]
19409
19428
  ), se = J !== "original", $e = se ? "nivaro_addendums" : e, Oe = se ? J : g, Ve = useMemo(() => {
@@ -19468,22 +19487,22 @@ function ItemEditForm({
19468
19487
  if (!O.one_field || !O.many_collection || !O.many_field) return;
19469
19488
  const Z = ((ut = nn[W]) == null ? void 0 : ut.data) ?? [], ae = ds[O.one_field];
19470
19489
  if (!ae) return;
19471
- const ye = `${O.many_collection}.${O.many_field}`, Te = Se.get(ye) ?? /* @__PURE__ */ new Map(), Ke = Qe.get(ye) ?? /* @__PURE__ */ new Set(), Ae = te.get(ye) ?? [], Je = [
19472
- ...Z.filter((Ue) => !Ke.has(String(Ue.id))).map((Ue) => Te.has(String(Ue.id)) ? { ...Ue, ...Te.get(String(Ue.id)) } : Ue),
19490
+ const ye = `${O.many_collection}.${O.many_field}`, Te = Se.get(ye) ?? /* @__PURE__ */ new Map(), Ke = Ue.get(ye) ?? /* @__PURE__ */ new Set(), Ae = te.get(ye) ?? [], Je = [
19491
+ ...Z.filter((Qe) => !Ke.has(String(Qe.id))).map((Qe) => Te.has(String(Qe.id)) ? { ...Qe, ...Te.get(String(Qe.id)) } : Qe),
19473
19492
  ...Ae
19474
19493
  ];
19475
19494
  if (ae.agg === "count") {
19476
19495
  $[O.one_field] = Je.length;
19477
19496
  return;
19478
19497
  }
19479
- const Ze = Je.map((Ue) => Number(Ue[ae.agg_field])).filter((Ue) => !Number.isNaN(Ue));
19498
+ const Ze = Je.map((Qe) => Number(Qe[ae.agg_field])).filter((Qe) => !Number.isNaN(Qe));
19480
19499
  if (!Ze.length) {
19481
19500
  $[O.one_field] = 0;
19482
19501
  return;
19483
19502
  }
19484
- ae.agg === "sum" ? $[O.one_field] = Ze.reduce((Ue, Be) => Ue + Be, 0) : ae.agg === "avg" ? $[O.one_field] = Ze.reduce((Ue, Be) => Ue + Be, 0) / Ze.length : ae.agg === "min" ? $[O.one_field] = Math.min(...Ze) : ae.agg === "max" && ($[O.one_field] = Math.max(...Ze));
19503
+ ae.agg === "sum" ? $[O.one_field] = Ze.reduce((Qe, Be) => Qe + Be, 0) : ae.agg === "avg" ? $[O.one_field] = Ze.reduce((Qe, Be) => Qe + Be, 0) / Ze.length : ae.agg === "min" ? $[O.one_field] = Math.min(...Ze) : ae.agg === "max" && ($[O.one_field] = Math.max(...Ze));
19485
19504
  }), $;
19486
- }, [Ft, nn, Ct, te, Se, Qe]), zn = useMemo(() => {
19505
+ }, [Ft, nn, Ct, te, Se, Ue]), zn = useMemo(() => {
19487
19506
  const $ = /* @__PURE__ */ new Set();
19488
19507
  return on.forEach((O, W) => {
19489
19508
  var Z;
@@ -19523,7 +19542,7 @@ function ItemEditForm({
19523
19542
  () => Nt.filter(($) => SYSTEM_FIELDS.has($.field) || $.readonly),
19524
19543
  [Nt]
19525
19544
  );
19526
- const Nn = useMemo(() => We.filter(($) => $.type === "container"), [We]), ys = useMemo(() => We.filter(($) => $.type === "tab" && !$.container_id), [We]), gr = useMemo(() => We.filter(($) => $.type === "tab").sort(($, O) => $.sort - O.sort), [We]), Ws = useMemo(() => We.filter(($) => $.type === "section" || $.type === "metadata"), [We]), fn = Nn.length > 0, Pn = ys.length > 0, Qt = L == null ? void 0 : L.layout, Fn = Qt ? !!Qt.ai_enabled : !0, hn = Pn && (Qt == null ? void 0 : Qt.tab_mode) === "steps", dr = !!(Qt != null && Qt.validate_before_next), tr = !!(Qt != null && Qt.summary_enabled), cr = !!(Qt != null && Qt.summary_hide_empty), ur = Qt ? !Qt.disable_revisions && o : o, Hn = Qt ? !Qt.disable_comments && m : m, In = Qt ? !Qt.disable_tasks && h : h, mr = Qt ? !Qt.disable_clone && d : d, A = Qt ? !Qt.disable_delete : !0, V = !!(Qt != null && Qt.accordion_mode), [oe, pe] = useState(!1), [_e, Fe] = useState(null), [Me, Ee] = useState(/* @__PURE__ */ new Set()), rt = useRef(!1);
19545
+ const Nn = useMemo(() => We.filter(($) => $.type === "container"), [We]), ys = useMemo(() => We.filter(($) => $.type === "tab" && !$.container_id), [We]), gr = useMemo(() => We.filter(($) => $.type === "tab").sort(($, O) => $.sort - O.sort), [We]), Ws = useMemo(() => We.filter(($) => $.type === "section" || $.type === "metadata"), [We]), fn = Nn.length > 0, Pn = ys.length > 0, Ut = L == null ? void 0 : L.layout, Fn = Ut ? !!Ut.ai_enabled : !0, hn = Pn && (Ut == null ? void 0 : Ut.tab_mode) === "steps", dr = !!(Ut != null && Ut.validate_before_next), tr = !!(Ut != null && Ut.summary_enabled), cr = !!(Ut != null && Ut.summary_hide_empty), ur = Ut ? !Ut.disable_revisions && o : o, Hn = Ut ? !Ut.disable_comments && m : m, In = Ut ? !Ut.disable_tasks && h : h, mr = Ut ? !Ut.disable_clone && d : d, A = Ut ? !Ut.disable_delete : !0, V = !!(Ut != null && Ut.accordion_mode), [oe, pe] = useState(!1), [_e, Fe] = useState(null), [Me, Ee] = useState(/* @__PURE__ */ new Set()), rt = useRef(!1);
19527
19546
  useEffect(() => {
19528
19547
  if (!V) {
19529
19548
  rt.current = !1;
@@ -19754,8 +19773,8 @@ function ItemEditForm({
19754
19773
  const O = (E ?? []).find((ut) => ut.field === $.field);
19755
19774
  let W = "text", Z, ae, ye, Te;
19756
19775
  try {
19757
- const ut = $.input_bindings, Ue = typeof ut == "string" ? JSON.parse(ut) : Array.isArray(ut) ? ut : [], Be = Ue.find((Xe) => Xe.key === "__display_format__");
19758
- Be != null && Be.binding_value && (W = Be.binding_value), Z = ((Ke = Ue.find((Xe) => Xe.key === "__color__")) == null ? void 0 : Ke.binding_value) || void 0, ae = ((Ae = Ue.find((Xe) => Xe.key === "__weight__")) == null ? void 0 : Ae.binding_value) || void 0, ye = ((Je = Ue.find((Xe) => Xe.key === "__display_as__")) == null ? void 0 : Je.binding_value) || void 0, Te = ((Ze = Ue.find((Xe) => Xe.key === "__link_template__")) == null ? void 0 : Ze.binding_value) || void 0;
19776
+ const ut = $.input_bindings, Qe = typeof ut == "string" ? JSON.parse(ut) : Array.isArray(ut) ? ut : [], Be = Qe.find((Xe) => Xe.key === "__display_format__");
19777
+ Be != null && Be.binding_value && (W = Be.binding_value), Z = ((Ke = Qe.find((Xe) => Xe.key === "__color__")) == null ? void 0 : Ke.binding_value) || void 0, ae = ((Ae = Qe.find((Xe) => Xe.key === "__weight__")) == null ? void 0 : Ae.binding_value) || void 0, ye = ((Je = Qe.find((Xe) => Xe.key === "__display_as__")) == null ? void 0 : Je.binding_value) || void 0, Te = ((Ze = Qe.find((Xe) => Xe.key === "__link_template__")) == null ? void 0 : Ze.binding_value) || void 0;
19759
19778
  } catch {
19760
19779
  }
19761
19780
  return {
@@ -19911,14 +19930,14 @@ function ItemEditForm({
19911
19930
  return ((ft = nt == null ? void 0 : nt.data) == null ? void 0 : ft.error) ?? (Ie instanceof Error ? Ie.message : "Failed");
19912
19931
  }
19913
19932
  let O = null;
19914
- const W = [...xt.entries()].some(([, Ie]) => Ie.length > 0) || [...St.entries()].some(([, Ie]) => Ie.size > 0), Z = [...te.entries()].filter(([, Ie]) => Ie.length > 0).map(([Ie]) => Ie), ae = [...Se.entries()].filter(([, Ie]) => Ie.size > 0).map(([Ie]) => Ie), ye = [...Qe.entries()].filter(([, Ie]) => Ie.size > 0).map(([Ie]) => Ie), Te = M ? Nt.filter((Ie) => !SYSTEM_FIELDS.has(Ie.field) && !Ie.readonly && Ie.field in qe).length : Nt.filter((Ie) => SYSTEM_FIELDS.has(Ie.field) || Ie.readonly || !(Ie.field in qe) ? !1 : !valuesEqual(qe[Ie.field], lt.current[Ie.field])).length, Ke = M ? `${Te} field${Te !== 1 ? "s" : ""} set` : Te === 0 ? "No field changes" : `${Te} field${Te !== 1 ? "s" : ""} changed`;
19933
+ const W = [...xt.entries()].some(([, Ie]) => Ie.length > 0) || [...St.entries()].some(([, Ie]) => Ie.size > 0), Z = [...te.entries()].filter(([, Ie]) => Ie.length > 0).map(([Ie]) => Ie), ae = [...Se.entries()].filter(([, Ie]) => Ie.size > 0).map(([Ie]) => Ie), ye = [...Ue.entries()].filter(([, Ie]) => Ie.size > 0).map(([Ie]) => Ie), Te = M ? Nt.filter((Ie) => !SYSTEM_FIELDS.has(Ie.field) && !Ie.readonly && Ie.field in qe).length : Nt.filter((Ie) => SYSTEM_FIELDS.has(Ie.field) || Ie.readonly || !(Ie.field in qe) ? !1 : !valuesEqual(qe[Ie.field], lt.current[Ie.field])).length, Ke = M ? `${Te} field${Te !== 1 ? "s" : ""} set` : Te === 0 ? "No field changes" : `${Te} field${Te !== 1 ? "s" : ""} changed`;
19915
19934
  let Ae = 0, Je = 0;
19916
19935
  for (const [, Ie] of xt.entries()) Ae += Ie.length;
19917
19936
  for (const [, Ie] of St.entries()) Je += Ie.size;
19918
19937
  const Ze = [
19919
19938
  Ae > 0 ? `+${Ae} linked` : "",
19920
19939
  Je > 0 ? `-${Je} unlinked` : ""
19921
- ].filter(Boolean).join(" · "), ut = [...mt.current.entries()], Ue = [
19940
+ ].filter(Boolean).join(" · "), ut = [...mt.current.entries()], Qe = [
19922
19941
  ...ut.length > 0 ? [{ id: "flush", label: "Save attachments", status: "pending", detail: `${ut.length} field${ut.length !== 1 ? "s" : ""} with pending changes` }] : [],
19923
19942
  { id: "main", label: M ? `Create ${(B == null ? void 0 : B.singular) || titleCase$2(e)}` : `Save ${(B == null ? void 0 : B.singular) || titleCase$2(e)}`, status: "pending", detail: Ke },
19924
19943
  ...W ? [{ id: "m2m", label: "Update relationships", status: "pending", detail: Ze }] : [],
@@ -19934,11 +19953,11 @@ function ItemEditForm({
19934
19953
  }),
19935
19954
  ...ye.map((Ie) => {
19936
19955
  var ft;
19937
- const nt = ((ft = Qe.get(Ie)) == null ? void 0 : ft.size) ?? 0;
19956
+ const nt = ((ft = Ue.get(Ie)) == null ? void 0 : ft.size) ?? 0;
19938
19957
  return { id: `o2m:del:${Ie}`, label: `Remove from ${titleCase$2(Ie.split(".")[0])}`, status: "pending", detail: `${nt} row${nt !== 1 ? "s" : ""} deleted`, progress: { done: 0, total: nt } };
19939
19958
  })
19940
19959
  ];
19941
- if (De(Ue), $t(!0), ut.length > 0) {
19960
+ if (De(Qe), $t(!0), ut.length > 0) {
19942
19961
  at("flush", { status: "running" });
19943
19962
  try {
19944
19963
  for (const [, Ie] of ut) await Ie();
@@ -20102,9 +20121,9 @@ function ItemEditForm({
20102
20121
  })), Mt.size > 0 ? Ot.set(Ie, Mt) : Ot.delete(Ie), !Yt && zt === 0 ? at(nt, { status: "done" }) : Yt || at(nt, { status: "error", error: `${zt} nested row${zt !== 1 ? "s" : ""} failed` });
20103
20122
  }
20104
20123
  Le(Ot), O && ht(O);
20105
- const vs = new Map(Qe);
20124
+ const vs = new Map(Ue);
20106
20125
  for (const Ie of ye) {
20107
- const nt = `o2m:del:${Ie}`, [ft] = Ie.split("."), Lt = Qe.get(Ie) ?? /* @__PURE__ */ new Set();
20126
+ const nt = `o2m:del:${Ie}`, [ft] = Ie.split("."), Lt = Ue.get(Ie) ?? /* @__PURE__ */ new Set();
20108
20127
  at(nt, { status: "running", progress: { done: 0, total: Lt.size } });
20109
20128
  let Yt = !1;
20110
20129
  await Promise.all([...Lt].map(async (zt) => {
@@ -20126,7 +20145,7 @@ function ItemEditForm({
20126
20145
  const O = /* @__PURE__ */ new Set([
20127
20146
  ...te.keys(),
20128
20147
  ...Se.keys(),
20129
- ...Qe.keys()
20148
+ ...Ue.keys()
20130
20149
  ]);
20131
20150
  for (const W of O) {
20132
20151
  const Z = W.indexOf("."), ae = W.slice(0, Z), ye = W.slice(Z + 1);
@@ -20150,7 +20169,7 @@ function ItemEditForm({
20150
20169
  if (Zs)
20151
20170
  for (const $ of E ?? []) hr.add($.field);
20152
20171
  if (vn) {
20153
- const $ = (Qs == null ? void 0 : Qs.role) ?? null, O = ((zr = ps == null ? void 0 : ps.instance) == null ? void 0 : zr.current_state) ?? null, W = O ? ((Hr = ((ps == null ? void 0 : ps.states) ?? []).find((Z) => Z.id === O)) == null ? void 0 : Hr.key) ?? null : null;
20172
+ const $ = (Us == null ? void 0 : Us.role) ?? null, O = ((zr = ps == null ? void 0 : ps.instance) == null ? void 0 : zr.current_state) ?? null, W = O ? ((Hr = ((ps == null ? void 0 : ps.states) ?? []).find((Z) => Z.id === O)) == null ? void 0 : Hr.key) ?? null : null;
20154
20173
  for (const Z of Cs) {
20155
20174
  if (!Z.lock_conditions) continue;
20156
20175
  let ae = [];
@@ -20280,7 +20299,7 @@ function ItemEditForm({
20280
20299
  FieldRow,
20281
20300
  {
20282
20301
  field: W,
20283
- draft: Q,
20302
+ draft: U,
20284
20303
  onChange: Es,
20285
20304
  relations: K,
20286
20305
  collection: e,
@@ -20306,7 +20325,7 @@ function ItemEditForm({
20306
20325
  }) }) }, "__ungrouped__");
20307
20326
  }
20308
20327
  function na($) {
20309
- var Ue;
20328
+ var Qe;
20310
20329
  const O = We.filter((Be) => Be.type === "tab" && Be.container_id === $.id).sort((Be, Xe) => Be.sort - Xe.sort);
20311
20330
  if (O.length === 0) return null;
20312
20331
  const W = $.tab_mode === "steps", Z = it($, O), ae = O.find((Be) => Be.key === Z) ?? O[0], ye = (() => {
@@ -20386,7 +20405,7 @@ function ItemEditForm({
20386
20405
  FieldRow,
20387
20406
  {
20388
20407
  field: At,
20389
- draft: Q,
20408
+ draft: U,
20390
20409
  onChange: Es,
20391
20410
  relations: K,
20392
20411
  collection: e,
@@ -20406,7 +20425,7 @@ function ItemEditForm({
20406
20425
  FieldRow,
20407
20426
  {
20408
20427
  field: Xe,
20409
- draft: Q,
20428
+ draft: U,
20410
20429
  onChange: Es,
20411
20430
  relations: K,
20412
20431
  collection: e,
@@ -20458,7 +20477,7 @@ function ItemEditForm({
20458
20477
  /* @__PURE__ */ jsx("line", { x1: "9", y1: "13", x2: "15", y2: "13" }),
20459
20478
  /* @__PURE__ */ jsx("line", { x1: "9", y1: "17", x2: "13", y2: "17" })
20460
20479
  ] }),
20461
- ve ? "Generating…" : ((Ue = cs == null ? void 0 : cs.label_override) == null ? void 0 : Ue.trim()) || "Generate PDF"
20480
+ ve ? "Generating…" : ((Qe = cs == null ? void 0 : cs.label_override) == null ? void 0 : Qe.trim()) || "Generate PDF"
20462
20481
  ]
20463
20482
  }
20464
20483
  ) }),
@@ -20514,15 +20533,15 @@ function ItemEditForm({
20514
20533
  } catch {
20515
20534
  return null;
20516
20535
  }
20517
- })(), Z = ((W == null ? void 0 : W.alternate_fields) ?? []).map((Ue) => typeof Ue == "string" ? { field: Ue, width: 2 } : Ue), ae = W != null && W.enabled ? Me.has(O.id) : !1, Te = (Is[O.key] ?? []).map((Ue) => {
20518
- const Be = w.get(Ue.field);
20519
- if (Be === void 0) return Ue;
20520
- const Xe = qe[Ue.field];
20521
- return Xe != null && Math.round(Number(Xe) * 100) === Math.round(Number(Be) * 100) ? Ue : {
20522
- ...Ue,
20523
- options: { ...Ue.options ?? {}, __live_delta: { original: Xe, live: Be } }
20536
+ })(), Z = ((W == null ? void 0 : W.alternate_fields) ?? []).map((Qe) => typeof Qe == "string" ? { field: Qe, width: 2 } : Qe), ae = W != null && W.enabled ? Me.has(O.id) : !1, Te = (Is[O.key] ?? []).map((Qe) => {
20537
+ const Be = w.get(Qe.field);
20538
+ if (Be === void 0) return Qe;
20539
+ const Xe = qe[Qe.field];
20540
+ return Xe != null && Math.round(Number(Xe) * 100) === Math.round(Number(Be) * 100) ? Qe : {
20541
+ ...Qe,
20542
+ options: { ...Qe.options ?? {}, __live_delta: { original: Xe, live: Be } }
20524
20543
  };
20525
- }), Ke = xr && or === O.key && c, Ae = pr && ir === O.key && !M, Je = yr.filter((Ue) => (Ue.group_key ?? null) === O.key);
20544
+ }), Ke = xr && or === O.key && c, Ae = pr && ir === O.key && !M, Je = yr.filter((Qe) => (Qe.group_key ?? null) === O.key);
20526
20545
  if (Te.length === 0 && !Ke && !Ae && Je.length === 0) return null;
20527
20546
  const Ze = V && O.type !== "tab";
20528
20547
  return /* @__PURE__ */ jsx(
@@ -20549,12 +20568,12 @@ function ItemEditForm({
20549
20568
  renderField: x,
20550
20569
  onCountChange: os,
20551
20570
  isNew: M,
20552
- fieldValues: Te.map((Ue) => qe[Ue.field]),
20571
+ fieldValues: Te.map((Qe) => qe[Qe.field]),
20553
20572
  isOpen: Ze ? _e === O.id : void 0,
20554
- onToggle: Ze ? () => Fe((Ue) => Ue === O.id ? null : O.id) : void 0,
20573
+ onToggle: Ze ? () => Fe((Qe) => Qe === O.id ? null : O.id) : void 0,
20555
20574
  summaryFields: parseSummaryFields(O.summary_fields),
20556
20575
  m2mCounts: As,
20557
- o2mCounts: Us,
20576
+ o2mCounts: Qs,
20558
20577
  o2mAggValues: On,
20559
20578
  summaryAggConfigs: ds,
20560
20579
  o2mLoading: zn,
@@ -20562,12 +20581,12 @@ function ItemEditForm({
20562
20581
  fieldInlineDisplay: Bn,
20563
20582
  swapConfig: W,
20564
20583
  swapped: ae,
20565
- onSwapToggle: W != null && W.enabled ? () => Ee((Ue) => {
20566
- const Be = new Set(Ue);
20584
+ onSwapToggle: W != null && W.enabled ? () => Ee((Qe) => {
20585
+ const Be = new Set(Qe);
20567
20586
  return Be.has(O.id) ? Be.delete(O.id) : Be.add(O.id), Be;
20568
20587
  }) : void 0,
20569
- alternateFields: W != null && W.enabled ? (E ?? []).filter((Ue) => Z.some((Be) => Be.field === Ue.field)) : void 0,
20570
- alternateWidths: W != null && W.enabled ? Object.fromEntries(Z.map((Ue) => [Ue.field, Ue.width])) : void 0
20588
+ alternateFields: W != null && W.enabled ? (E ?? []).filter((Qe) => Z.some((Be) => Be.field === Qe.field)) : void 0,
20589
+ alternateWidths: W != null && W.enabled ? Object.fromEntries(Z.map((Qe) => [Qe.field, Qe.width])) : void 0
20571
20590
  },
20572
20591
  O.key
20573
20592
  );
@@ -20600,7 +20619,7 @@ function ItemEditForm({
20600
20619
  )
20601
20620
  ] });
20602
20621
  }
20603
- function Ur($, O = !1) {
20622
+ function Qr($, O = !1) {
20604
20623
  const W = ($ === "__general__" ? O ? ws : [...ws, ...Ws.flatMap((Ke) => Is[Ke.key] ?? [])] : Is[$] ?? []).filter((Ke) => !Ke.hidden), Z = xr && or === $ && c, ae = pr && ir === $ && !M, ye = yr.filter((Ke) => (Ke.group_key ?? null) === $), Te = W.map((Ke) => ({ _k: Ke.field, sort: Ke.sort ?? 0, _t: "field", f: Ke }));
20605
20624
  Z && Fs && Te.push({ _k: "__owners__", sort: Fs.sort, _t: "owners", slot: Fs }), ae && cs && Te.push({ _k: "__pdf__", sort: cs.sort, _t: "pdf", slot: cs });
20606
20625
  for (const Ke of ye)
@@ -20646,13 +20665,13 @@ function ItemEditForm({
20646
20665
  }
20647
20666
  ) }, Ae.slot.field);
20648
20667
  }
20649
- const Je = Ae.f, Ze = Bn == null ? void 0 : Bn[Je.field], ut = Ze == null ? void 0 : Ze.entries, Ue = (Ze == null ? void 0 : Ze.separator) ?? null, Be = qe[Je.field], Xe = Be != null && Be !== "", pt = ut != null && ut.length && Xe ? ((Et = K.find((Ot) => Ot.many_collection === e && Ot.many_field === Je.field && !Ot.junction_field)) == null ? void 0 : Et.one_collection) ?? null : null;
20668
+ const Je = Ae.f, Ze = Bn == null ? void 0 : Bn[Je.field], ut = Ze == null ? void 0 : Ze.entries, Qe = (Ze == null ? void 0 : Ze.separator) ?? null, Be = qe[Je.field], Xe = Be != null && Be !== "", pt = ut != null && ut.length && Xe ? ((Et = K.find((Ot) => Ot.many_collection === e && Ot.many_field === Je.field && !Ot.junction_field)) == null ? void 0 : Et.one_collection) ?? null : null;
20650
20669
  return /* @__PURE__ */ jsxs("div", { style: { gridColumn: `span ${resolveColSpan(Je.options, Ke)}` }, children: [
20651
20670
  /* @__PURE__ */ jsx(
20652
20671
  FieldRow,
20653
20672
  {
20654
20673
  field: Je,
20655
- draft: Q,
20674
+ draft: U,
20656
20675
  onChange: Es,
20657
20676
  relations: K,
20658
20677
  collection: e,
@@ -20671,7 +20690,7 @@ function ItemEditForm({
20671
20690
  relCollection: pt,
20672
20691
  relId: Be,
20673
20692
  entries: ut,
20674
- separator: Ue
20693
+ separator: Qe
20675
20694
  }
20676
20695
  )
20677
20696
  ] }, Je.field);
@@ -20707,7 +20726,7 @@ function ItemEditForm({
20707
20726
  W.key
20708
20727
  );
20709
20728
  }) }),
20710
- Ur(Dt),
20729
+ Qr(Dt),
20711
20730
  wr.filter((W) => typeof W == "string" && W !== "__ungrouped__").map((W) => Br(W)),
20712
20731
  !fs && c && /* @__PURE__ */ jsx(PipelinePanel, { collection: $e, item: Oe, onBeforeTransition: nr, addendumPending: !se && I > 0 && !!(B != null && B.addendums_enabled), addendumView: se }),
20713
20732
  !Rs && In && /* @__PURE__ */ jsx(TaskPanel, { collection: e, item: g, queuedTasks: M ? _s : void 0, onQueueTask: M ? Bt : void 0 }),
@@ -20816,7 +20835,7 @@ function ItemEditForm({
20816
20835
  onStepClick: Xn
20817
20836
  }
20818
20837
  ),
20819
- Ur(Dt, !0),
20838
+ Qr(Dt, !0),
20820
20839
  Te.map((Ae, Je) => {
20821
20840
  const Ze = typeof Ae == "string" ? Ae : Ae.key;
20822
20841
  return /* @__PURE__ */ jsx("div", { children: Tr(Ae) }, Ze ?? Je);
@@ -20860,8 +20879,8 @@ function ItemEditForm({
20860
20879
  /* @__PURE__ */ jsx(Skeleton, { className: "h-32 rounded-xl" })
20861
20880
  ] })
20862
20881
  ] });
20863
- const Qr = (B == null ? void 0 : B.display_name) ?? titleCase$2(e ?? ""), ia = (B == null ? void 0 : B.singular) || Qr, qr = !M && ue && (B != null && B.display_template) ? applyDisplayTemplate(B.display_template, ue) : Qr, Wr = !M && j && A;
20864
- return /* @__PURE__ */ jsx(ReimportHandlerContext.Provider, { value: M ? null : En, children: /* @__PURE__ */ jsx(RelationPathDataContext.Provider, { value: An, children: /* @__PURE__ */ jsx(AddendumO2MContext.Provider, { value: Ve, children: /* @__PURE__ */ jsx(AddendumViewContext.Provider, { value: J, children: /* @__PURE__ */ jsx(AddendumFieldContext.Provider, { value: Yn, children: /* @__PURE__ */ jsx(ParentDraftContext.Provider, { value: { draft: Gn, collection: e, dirtyFields: He.current }, children: /* @__PURE__ */ jsx(GridFlushContext.Provider, { value: M ? null : yt, children: /* @__PURE__ */ jsx(StaleFieldReportContext.Provider, { value: U, children: /* @__PURE__ */ jsx(O2MStagingContext.Provider, { value: Re, children: /* @__PURE__ */ jsx(LiveRowsContext.Provider, { value: wn, children: /* @__PURE__ */ jsxs(M2MStagingContext.Provider, { value: tt, children: [
20882
+ const Ur = (B == null ? void 0 : B.display_name) ?? titleCase$2(e ?? ""), ia = (B == null ? void 0 : B.singular) || Ur, qr = !M && ue && (B != null && B.display_template) ? applyDisplayTemplate(B.display_template, ue) : Ur, Wr = !M && j && A;
20883
+ return /* @__PURE__ */ jsx(ReimportHandlerContext.Provider, { value: M ? null : En, children: /* @__PURE__ */ jsx(RelationPathDataContext.Provider, { value: An, children: /* @__PURE__ */ jsx(AddendumO2MContext.Provider, { value: Ve, children: /* @__PURE__ */ jsx(AddendumViewContext.Provider, { value: J, children: /* @__PURE__ */ jsx(AddendumFieldContext.Provider, { value: Yn, children: /* @__PURE__ */ jsx(ParentDraftContext.Provider, { value: { draft: Gn, collection: e, dirtyFields: He.current }, children: /* @__PURE__ */ jsx(GridFlushContext.Provider, { value: M ? null : yt, children: /* @__PURE__ */ jsx(StaleFieldReportContext.Provider, { value: Q, children: /* @__PURE__ */ jsx(O2MStagingContext.Provider, { value: Re, children: /* @__PURE__ */ jsx(LiveRowsContext.Provider, { value: wn, children: /* @__PURE__ */ jsxs(M2MStagingContext.Provider, { value: tt, children: [
20865
20884
  /* @__PURE__ */ jsx(TipLayer, {}),
20866
20885
  /* @__PURE__ */ jsx(
20867
20886
  SaveProgressDialog,
@@ -21222,41 +21241,41 @@ function ItemEditForm({
21222
21241
  ...jr.map(($) => ({ type: "widget", sort: $.sort, key: $.field, data: $ })),
21223
21242
  ...Or.map(($) => ({ type: "field", sort: $.sort, key: $.field, data: $ }))
21224
21243
  ].sort(($, O) => $.sort - O.sort).map(($) => {
21225
- const O = (Ue, Be) => {
21244
+ const O = (Qe, Be) => {
21226
21245
  var kt;
21227
- if (!Ue) return;
21228
- const Xe = Ue.cloneNode(!0);
21246
+ if (!Qe) return;
21247
+ const Xe = Qe.cloneNode(!0);
21229
21248
  Xe.querySelectorAll("[data-copy-skip], button").forEach((Et) => Et.remove());
21230
21249
  const pt = ((kt = Xe.textContent) == null ? void 0 : kt.trim()) ?? "";
21231
21250
  pt && (navigator.clipboard.writeText(pt).catch(() => {
21232
21251
  }), Jt(Be), setTimeout(() => Jt((Et) => Et === Be ? null : Et), 1500));
21233
21252
  };
21234
21253
  if ($.type === "widget") {
21235
- const Ue = $.data, Be = fe[Ue.field] === "button-group";
21254
+ const Qe = $.data, Be = fe[Qe.field] === "button-group";
21236
21255
  return /* @__PURE__ */ jsxs("div", { className: "group relative self-stretch border-r border-slate-200 dark:border-border", children: [
21237
21256
  /* @__PURE__ */ jsx(
21238
21257
  WidgetSlot,
21239
21258
  {
21240
- widgetId: Ue.widgetId,
21241
- inputBindings: Ue.inputBindings,
21242
- itemDraft: Q,
21259
+ widgetId: Qe.widgetId,
21260
+ inputBindings: Qe.inputBindings,
21261
+ itemDraft: U,
21243
21262
  itemCollection: e,
21244
- label: Ue.label ?? void 0,
21263
+ label: Qe.label ?? void 0,
21245
21264
  compact: !0,
21246
21265
  strip: !0,
21247
- onWidgetType: (Xe) => ee((pt) => ({ ...pt, [Ue.field]: Xe }))
21266
+ onWidgetType: (Xe) => ee((pt) => ({ ...pt, [Qe.field]: Xe }))
21248
21267
  }
21249
21268
  ),
21250
- !Be && (et === Ue.field ? /* @__PURE__ */ jsx(Check, { className: "absolute top-2 right-2 h-3 w-3 text-green-500" }) : /* @__PURE__ */ jsx(
21269
+ !Be && (et === Qe.field ? /* @__PURE__ */ jsx(Check, { className: "absolute top-2 right-2 h-3 w-3 text-green-500" }) : /* @__PURE__ */ jsx(
21251
21270
  "button",
21252
21271
  {
21253
21272
  type: "button",
21254
21273
  className: "absolute top-2 right-2 cursor-pointer opacity-0 group-hover:opacity-100 transition-opacity",
21255
- onClick: (Xe) => O(Xe.currentTarget.closest(".group"), Ue.field),
21274
+ onClick: (Xe) => O(Xe.currentTarget.closest(".group"), Qe.field),
21256
21275
  children: /* @__PURE__ */ jsx(Copy, { className: "h-3 w-3 text-slate-300 dark:text-slate-600 hover:text-slate-500 dark:hover:text-slate-400" })
21257
21276
  }
21258
21277
  ))
21259
- ] }, Ue.field);
21278
+ ] }, Qe.field);
21260
21279
  }
21261
21280
  const W = $.data;
21262
21281
  if (W.field === "__owners__")
@@ -21268,12 +21287,12 @@ function ItemEditForm({
21268
21287
  {
21269
21288
  type: "button",
21270
21289
  className: "absolute top-2 right-2 cursor-pointer opacity-0 group-hover:opacity-100 transition-opacity",
21271
- onClick: (Ue) => O(Ue.currentTarget.closest(".group"), "__owners__"),
21290
+ onClick: (Qe) => O(Qe.currentTarget.closest(".group"), "__owners__"),
21272
21291
  children: /* @__PURE__ */ jsx(Copy, { className: "h-3 w-3 text-slate-300 dark:text-slate-600 hover:text-slate-500 dark:hover:text-slate-400" })
21273
21292
  }
21274
21293
  )
21275
21294
  ] }, "__owners__");
21276
- const Z = ms[W.field], ae = w.get(W.field), ye = Z ? Z.ids : ae ?? Q[W.field], Ke = se && !Z && tn != null && W.field in tn && String(qe[W.field] ?? "") !== String(tn[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", Ae = W.weight === "bold" ? "font-bold" : W.weight === "semibold" ? "font-semibold" : W.weight === "medium" ? "font-medium" : "font-semibold", Je = `${Ke} ${Ae}`, Ze = W.displayAs === "pill", ut = W.displayAs === "tag";
21295
+ const Z = ms[W.field], ae = w.get(W.field), ye = Z ? Z.ids : ae ?? U[W.field], Ke = se && !Z && tn != null && W.field in tn && String(qe[W.field] ?? "") !== String(tn[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", Ae = W.weight === "bold" ? "font-bold" : W.weight === "semibold" ? "font-semibold" : W.weight === "medium" ? "font-medium" : "font-semibold", Je = `${Ke} ${Ae}`, Ze = W.displayAs === "pill", ut = W.displayAs === "tag";
21277
21296
  return /* @__PURE__ */ jsxs(
21278
21297
  "div",
21279
21298
  {
@@ -21282,8 +21301,8 @@ function ItemEditForm({
21282
21301
  children: [
21283
21302
  /* @__PURE__ */ jsx("span", { className: "flex h-4 items-end truncate text-[10px] font-medium leading-none text-slate-400 dark:text-slate-500", children: W.label }),
21284
21303
  /* @__PURE__ */ jsx("span", { className: ["mt-1 leading-tight truncate max-w-[220px] pb-px", Ze ? `rounded-full px-2 py-0.5 text-[11px] inline-block ${Ke} bg-current/10` : ut ? `rounded px-1.5 py-0.5 border border-current/30 text-[11px] inline-block ${Ke}` : ""].filter(Boolean).join(" "), children: (() => {
21285
- const Ue = W.cmsField ? /* @__PURE__ */ jsx(StripFieldValue, { field: W.cmsField, val: ye, relations: K, collection: e, displayFormat: W.displayFormat, textClassName: Je }) : /* @__PURE__ */ jsx("span", { className: `text-[13px] ${Je}`, children: formatHeaderFieldValue(ye, W.displayFormat) }), Be = W.linkTemplate;
21286
- if (!Be || ye === null || ye === void 0 || ye === "" || Array.isArray(ye)) return Ue;
21304
+ const Qe = W.cmsField ? /* @__PURE__ */ jsx(StripFieldValue, { field: W.cmsField, val: ye, relations: K, collection: e, displayFormat: W.displayFormat, textClassName: Je }) : /* @__PURE__ */ jsx("span", { className: `text-[13px] ${Je}`, children: formatHeaderFieldValue(ye, W.displayFormat) }), Be = W.linkTemplate;
21305
+ if (!Be || ye === null || ye === void 0 || ye === "" || Array.isArray(ye)) return Qe;
21287
21306
  const Xe = Be.replace(/\{\{\s*value\s*\}\}/g, encodeURIComponent(String(ye))).replace(/\{\{\s*([\w.]+)\s*\}\}/g, (pt, kt) => encodeURIComponent(String(qe[kt] ?? "")));
21288
21307
  return /^https?:\/\//i.test(Xe) ? /* @__PURE__ */ jsx(
21289
21308
  "a",
@@ -21293,18 +21312,18 @@ function ItemEditForm({
21293
21312
  rel: "noopener noreferrer",
21294
21313
  className: "underline decoration-dotted underline-offset-2 hover:decoration-solid",
21295
21314
  onClick: (pt) => pt.stopPropagation(),
21296
- children: Ue
21315
+ children: Qe
21297
21316
  }
21298
- ) : Ue;
21317
+ ) : Qe;
21299
21318
  })() }),
21300
21319
  et === W.field ? /* @__PURE__ */ jsx(Check, { className: "absolute top-2 right-2 h-3 w-3 text-green-500" }) : /* @__PURE__ */ jsx(
21301
21320
  "button",
21302
21321
  {
21303
21322
  type: "button",
21304
21323
  className: "absolute top-2 right-2 cursor-pointer opacity-0 group-hover:opacity-100 transition-opacity",
21305
- onClick: (Ue) => {
21324
+ onClick: (Qe) => {
21306
21325
  var kt;
21307
- const Be = Ue.currentTarget.closest(".group"), Xe = Be == null ? void 0 : Be.querySelectorAll(":scope > span")[1];
21326
+ const Be = Qe.currentTarget.closest(".group"), Xe = Be == null ? void 0 : Be.querySelectorAll(":scope > span")[1];
21308
21327
  let pt = "";
21309
21328
  if (Xe) {
21310
21329
  const Et = Xe.cloneNode(!0);
@@ -26465,166 +26484,166 @@ function CollectionBrowserView({
26465
26484
  Pt.current !== e && (Pt.current = e, v(1), x(a), y([]), f(n ?? ""), C(s ?? null), T({}), M({}), de([]), Ce(null), xe({}), B({}), I({}), fe([]), J != null && J.length && le.back(J.length), je(null), ot.current = !1);
26466
26485
  }, [e]), useEffect(() => {
26467
26486
  if (!Ne) return;
26468
- const U = (w) => {
26469
- var Q;
26470
- (Q = jt.current) != null && Q.contains(w.target) || Y(!1);
26487
+ const Q = (w) => {
26488
+ var U;
26489
+ (U = jt.current) != null && U.contains(w.target) || Y(!1);
26471
26490
  };
26472
- return window.addEventListener("mousedown", U), () => window.removeEventListener("mousedown", U);
26491
+ return window.addEventListener("mousedown", Q), () => window.removeEventListener("mousedown", Q);
26473
26492
  }, [Ne]);
26474
26493
  const { data: st } = useQuery({
26475
26494
  queryKey: ["cbv-collection-meta", e],
26476
- queryFn: () => c.request(get$1(`/collections/${e}`)).then((U) => U.data),
26495
+ queryFn: () => c.request(get$1(`/collections/${e}`)).then((Q) => Q.data),
26477
26496
  staleTime: 10 * 6e4,
26478
26497
  retry: !1
26479
- }), _t = useMemo(() => ((st == null ? void 0 : st.fields) ?? []).filter((U) => !U.hidden), [st]), It = (st == null ? void 0 : st.browser_config) ?? {}, Xt = It.checkbox_selection !== !1, Ht = It.show_actions !== !1, $t = o && It.allow_create !== !1, ie = It.page_size && It.page_size > 0 ? Math.min(It.page_size, 200) : r, De = t.length > 0 ? t : It.quick_filters ?? [];
26498
+ }), _t = useMemo(() => ((st == null ? void 0 : st.fields) ?? []).filter((Q) => !Q.hidden), [st]), It = (st == null ? void 0 : st.browser_config) ?? {}, Xt = It.checkbox_selection !== !1, Ht = It.show_actions !== !1, $t = o && It.allow_create !== !1, ie = It.page_size && It.page_size > 0 ? Math.min(It.page_size, 200) : r, De = t.length > 0 ? t : It.quick_filters ?? [];
26480
26499
  useEffect(() => {
26481
26500
  if (re || !z || t.length === 0 && !st) return;
26482
- const U = ee, w = Object.values((U == null ? void 0 : U.defaults) ?? {}).some((Q) => Q.length > 0) || Object.values((U == null ? void 0 : U.restricted) ?? {}).some((Q) => Q.length > 0);
26483
- if (!U || De.length === 0 || !w) {
26501
+ const Q = ee, w = Object.values((Q == null ? void 0 : Q.defaults) ?? {}).some((U) => U.length > 0) || Object.values((Q == null ? void 0 : Q.restricted) ?? {}).some((U) => U.length > 0);
26502
+ if (!Q || De.length === 0 || !w) {
26484
26503
  we(!0);
26485
26504
  return;
26486
26505
  }
26487
26506
  (async () => {
26488
- const Q = {};
26507
+ const U = {};
26489
26508
  for (const se of De) {
26490
- const $e = matchScopeDimension(U, { key: se.key, collection: se.collection });
26509
+ const $e = matchScopeDimension(Q, { key: se.key, collection: se.collection });
26491
26510
  if (!$e) continue;
26492
- const Oe = effectiveScopeSeedIds(U, $e.name);
26511
+ const Oe = effectiveScopeSeedIds(Q, $e.name);
26493
26512
  if (Oe.length === 0) continue;
26494
26513
  const Ve = await translateScopeValues(c, $e, Oe, se.value_field).catch(
26495
26514
  () => []
26496
26515
  );
26497
- Ve.length > 0 && (Q[se.key] = Ve);
26516
+ Ve.length > 0 && (U[se.key] = Ve);
26498
26517
  }
26499
- if (Object.keys(Q).length > 0) {
26518
+ if (Object.keys(U).length > 0) {
26500
26519
  const se = ($e) => {
26501
26520
  var Ve;
26502
26521
  const Oe = { ...$e };
26503
- for (const [dt, Nt] of Object.entries(Q))
26522
+ for (const [dt, Nt] of Object.entries(U))
26504
26523
  (((Ve = Oe[dt]) == null ? void 0 : Ve.length) ?? 0) > 0 || (Oe[dt] = Nt);
26505
26524
  return Oe;
26506
26525
  };
26507
- xe(se), B(se), ve(new Set(Object.keys(Q)));
26526
+ xe(se), B(se), ve(new Set(Object.keys(U)));
26508
26527
  }
26509
26528
  we(!0);
26510
26529
  })();
26511
26530
  }, [re, z, ee, st, De]);
26512
- const at = (U) => {
26513
- const w = matchScopeDimension(ee, { key: U.key, collection: U.collection }), Q = w ? (ee == null ? void 0 : ee.restricted[w.name]) ?? [] : [];
26514
- return Q.length > 0 ? Q : void 0;
26515
- }, lt = useMemo(() => new Map(_t.map((U) => [U.field, U])), [_t]), qt = (st == null ? void 0 : st.relations) ?? [], et = useMemo(() => (S ?? _t.slice(0, 7).map((w) => w.field)).filter((w) => w.includes(".") || lt.has(w)), [S, _t, lt]), [Jt, ss] = useState(null), is = useMemo(
26531
+ const at = (Q) => {
26532
+ const w = matchScopeDimension(ee, { key: Q.key, collection: Q.collection }), U = w ? (ee == null ? void 0 : ee.restricted[w.name]) ?? [] : [];
26533
+ return U.length > 0 ? U : void 0;
26534
+ }, lt = useMemo(() => new Map(_t.map((Q) => [Q.field, Q])), [_t]), qt = (st == null ? void 0 : st.relations) ?? [], et = useMemo(() => (S ?? _t.slice(0, 7).map((w) => w.field)).filter((w) => w.includes(".") || lt.has(w)), [S, _t, lt]), [Jt, ss] = useState(null), is = useMemo(
26516
26535
  () => Jt ?? (et[0] ? { [et[0]]: "left" } : {}),
26517
26536
  [Jt, et]
26518
- ), Vt = (U) => is[U], _s = (U) => {
26519
- const w = { ...is }, Q = w[U];
26520
- Q ? Q === "left" ? w[U] = "right" : delete w[U] : w[U] = "left", ss(w);
26521
- }, Ms = (U) => q[U] ?? (U.includes(".") ? U.split(".").map(titleCase$1).join(" › ") : U === "id" ? "ID" : titleCase$1(U)), Bt = useMemo(
26522
- () => et.filter((U) => !U.includes(".")).map((U) => ({ field: U, info: aliasRelationFor(qt, e, U) })).filter((U) => !!U.info),
26537
+ ), Vt = (Q) => is[Q], _s = (Q) => {
26538
+ const w = { ...is }, U = w[Q];
26539
+ U ? U === "left" ? w[Q] = "right" : delete w[Q] : w[Q] = "left", ss(w);
26540
+ }, Ms = (Q) => q[Q] ?? (Q.includes(".") ? Q.split(".").map(titleCase$1).join(" › ") : Q === "id" ? "ID" : titleCase$1(Q)), Bt = useMemo(
26541
+ () => et.filter((Q) => !Q.includes(".")).map((Q) => ({ field: Q, info: aliasRelationFor(qt, e, Q) })).filter((Q) => !!Q.info),
26523
26542
  [et, lt, qt, e]
26524
26543
  ), te = useMemo(
26525
- () => [...new Set(Bt.map((U) => U.info.relation.many_collection ?? "").filter(Boolean))],
26544
+ () => [...new Set(Bt.map((Q) => Q.info.relation.many_collection ?? "").filter(Boolean))],
26526
26545
  [Bt]
26527
26546
  ), ke = useQueries({
26528
- queries: te.map((U) => ({
26529
- queryKey: ["cbv-collection-meta", U],
26530
- queryFn: () => c.request(get$1(`/collections/${U}`)).then((w) => w.data),
26547
+ queries: te.map((Q) => ({
26548
+ queryKey: ["cbv-collection-meta", Q],
26549
+ queryFn: () => c.request(get$1(`/collections/${Q}`)).then((w) => w.data),
26531
26550
  staleTime: 10 * 6e4,
26532
26551
  retry: !1
26533
26552
  }))
26534
26553
  }), Se = useMemo(() => {
26535
- const U = /* @__PURE__ */ new Map();
26536
- return te.forEach((w, Q) => {
26554
+ const Q = /* @__PURE__ */ new Map();
26555
+ return te.forEach((w, U) => {
26537
26556
  var se;
26538
- return U.set(w, (se = ke[Q]) == null ? void 0 : se.data);
26539
- }), U;
26557
+ return Q.set(w, (se = ke[U]) == null ? void 0 : se.data);
26558
+ }), Q;
26540
26559
  }, [te, ke]), Le = useMemo(
26541
26560
  () => [
26542
26561
  ...new Set(
26543
- Bt.filter((U) => U.info.kind === "m2m").map((U) => {
26544
- const w = U.info.relation.many_collection ?? "", Q = Se.get(w), se = Q == null ? void 0 : Q.relations.find(
26545
- ($e) => $e.many_collection === w && $e.many_field === U.info.relation.junction_field
26562
+ Bt.filter((Q) => Q.info.kind === "m2m").map((Q) => {
26563
+ const w = Q.info.relation.many_collection ?? "", U = Se.get(w), se = U == null ? void 0 : U.relations.find(
26564
+ ($e) => $e.many_collection === w && $e.many_field === Q.info.relation.junction_field
26546
26565
  );
26547
26566
  return (se == null ? void 0 : se.one_collection) ?? "";
26548
26567
  }).filter(Boolean)
26549
26568
  )
26550
26569
  ],
26551
26570
  [Bt, Se]
26552
- ), Qe = useQueries({
26553
- queries: Le.map((U) => ({
26554
- queryKey: ["cbv-collection-meta", U],
26555
- queryFn: () => c.request(get$1(`/collections/${U}`)).then((w) => w.data),
26571
+ ), Ue = useQueries({
26572
+ queries: Le.map((Q) => ({
26573
+ queryKey: ["cbv-collection-meta", Q],
26574
+ queryFn: () => c.request(get$1(`/collections/${Q}`)).then((w) => w.data),
26556
26575
  staleTime: 10 * 6e4,
26557
26576
  retry: !1
26558
26577
  }))
26559
26578
  }), Ye = useMemo(() => {
26560
- const U = /* @__PURE__ */ new Map();
26561
- return Le.forEach((w, Q) => {
26579
+ const Q = /* @__PURE__ */ new Map();
26580
+ return Le.forEach((w, U) => {
26562
26581
  var se;
26563
- return U.set(w, (se = Qe[Q]) == null ? void 0 : se.data);
26564
- }), U;
26565
- }, [Le, Qe]), Re = useMemo(() => {
26566
- const U = {};
26582
+ return Q.set(w, (se = Ue[U]) == null ? void 0 : se.data);
26583
+ }), Q;
26584
+ }, [Le, Ue]), Re = useMemo(() => {
26585
+ const Q = {};
26567
26586
  for (const w of Bt) {
26568
- const Q = w.info.relation.many_collection ?? "";
26587
+ const U = w.info.relation.many_collection ?? "";
26569
26588
  if (w.info.kind === "o2m")
26570
- U[w.field] = `${w.field}.${labelFieldFor(Se.get(Q))}`;
26589
+ Q[w.field] = `${w.field}.${labelFieldFor(Se.get(U))}`;
26571
26590
  else {
26572
- const se = Se.get(Q), $e = se == null ? void 0 : se.relations.find(
26573
- (Ve) => Ve.many_collection === Q && Ve.many_field === w.info.relation.junction_field
26591
+ const se = Se.get(U), $e = se == null ? void 0 : se.relations.find(
26592
+ (Ve) => Ve.many_collection === U && Ve.many_field === w.info.relation.junction_field
26574
26593
  ), Oe = ($e == null ? void 0 : $e.one_collection) ?? "";
26575
- U[w.field] = `${w.field}.${labelFieldFor(Oe ? Ye.get(Oe) : void 0)}`;
26594
+ Q[w.field] = `${w.field}.${labelFieldFor(Oe ? Ye.get(Oe) : void 0)}`;
26576
26595
  }
26577
26596
  }
26578
- return U;
26597
+ return Q;
26579
26598
  }, [Bt, Se, Ye]), wt = useMemo(() => {
26580
- const U = {};
26599
+ const Q = {};
26581
26600
  for (const w of Bt)
26582
26601
  if (w.info.kind === "o2m")
26583
- U[w.field] = { kind: "o2m" };
26602
+ Q[w.field] = { kind: "o2m" };
26584
26603
  else {
26585
- const Q = w.info.relation.many_collection ?? "", se = Se.get(Q), $e = se == null ? void 0 : se.relations.find(
26586
- (Oe) => Oe.many_collection === Q && Oe.many_field === w.info.relation.junction_field
26604
+ const U = w.info.relation.many_collection ?? "", se = Se.get(U), $e = se == null ? void 0 : se.relations.find(
26605
+ (Oe) => Oe.many_collection === U && Oe.many_field === w.info.relation.junction_field
26587
26606
  );
26588
- $e != null && $e.one_collection && (U[w.field] = { kind: "m2m", target: $e.one_collection });
26607
+ $e != null && $e.one_collection && (Q[w.field] = { kind: "m2m", target: $e.one_collection });
26589
26608
  }
26590
- return U;
26609
+ return Q;
26591
26610
  }, [Bt, Se]), Rt = useDebounced(ce, 350), vt = useMemo(() => {
26592
26611
  var w;
26593
- const U = [];
26594
- for (const Q of F) {
26595
- const se = Q.fieldType === "date" || Q.fieldType === "datetime" || Q.fieldType === "timestamp";
26596
- if (Q.op === "_between") {
26597
- const [Ve, dt] = String(Q.value).split("..");
26598
- Ve && U.push({ path: Q.path, op: "_gte", value: Ve }), dt && U.push({ path: Q.path, op: "_lte", value: se ? `${dt}T23:59:59` : dt });
26612
+ const Q = [];
26613
+ for (const U of F) {
26614
+ const se = U.fieldType === "date" || U.fieldType === "datetime" || U.fieldType === "timestamp";
26615
+ if (U.op === "_between") {
26616
+ const [Ve, dt] = String(U.value).split("..");
26617
+ Ve && Q.push({ path: U.path, op: "_gte", value: Ve }), dt && Q.push({ path: U.path, op: "_lte", value: se ? `${dt}T23:59:59` : dt });
26599
26618
  continue;
26600
26619
  }
26601
- const $e = Q.op.includes(":") ? Q.op.split(":")[0] : Q.op;
26602
- let Oe = Q.op.includes(":") ? Q.op.split(":")[1] : Q.value || null;
26603
- Q.fieldType === "boolean" && (Oe === "true" || Oe === "false") && (Oe = Oe === "true"), U.push({ path: Q.path, op: $e, value: Oe });
26620
+ const $e = U.op.includes(":") ? U.op.split(":")[0] : U.op;
26621
+ let Oe = U.op.includes(":") ? U.op.split(":")[1] : U.value || null;
26622
+ U.fieldType === "boolean" && (Oe === "true" || Oe === "false") && (Oe = Oe === "true"), Q.push({ path: U.path, op: $e, value: Oe });
26604
26623
  }
26605
- for (const Q of De) {
26606
- const se = G[Q.key] ?? [];
26607
- se.length !== 0 && ((w = Q.or_paths) != null && w.length ? U.push({ or: Q.or_paths.map(($e) => ({ path: $e, op: "_in", value: se })) }) : U.push({ path: Q.path, op: "_in", value: se }));
26624
+ for (const U of De) {
26625
+ const se = G[U.key] ?? [];
26626
+ se.length !== 0 && ((w = U.or_paths) != null && w.length ? Q.push({ or: U.or_paths.map(($e) => ({ path: $e, op: "_in", value: se })) }) : Q.push({ path: U.path, op: "_in", value: se }));
26608
26627
  }
26609
- for (const [Q, se] of Object.entries(Rt))
26628
+ for (const [U, se] of Object.entries(Rt))
26610
26629
  if (se) {
26611
- if (se.kind === "in" && se.value.length) U.push({ path: [Q], op: "_in", value: se.value });
26612
- else if (se.kind === "state" && se.value.length) U.push({ path: ["$state"], op: "_in", value: se.value });
26630
+ if (se.kind === "in" && se.value.length) Q.push({ path: [U], op: "_in", value: se.value });
26631
+ else if (se.kind === "state" && se.value.length) Q.push({ path: ["$state"], op: "_in", value: se.value });
26613
26632
  else if (se.kind === "text" && se.value.trim())
26614
- U.push({ path: se.path, op: "_contains", value: se.value.trim() });
26633
+ Q.push({ path: se.path, op: "_contains", value: se.value.trim() });
26615
26634
  else if (se.kind === "num" && se.value !== "" && !Number.isNaN(Number(se.value)))
26616
- U.push({ path: [Q], op: se.op, value: Number(se.value) });
26617
- else if (se.kind === "bool") U.push({ path: [Q], op: "_eq", value: se.value === "true" });
26635
+ Q.push({ path: [U], op: se.op, value: Number(se.value) });
26636
+ else if (se.kind === "bool") Q.push({ path: [U], op: "_eq", value: se.value === "true" });
26618
26637
  else if (se.kind === "date" && se.value) {
26619
26638
  const $e = se.value.startsWith("r:") ? (() => {
26620
26639
  const [Oe, Ve] = se.value.slice(2).split("..");
26621
26640
  return Oe ? { from: Oe, to: Ve || Oe } : null;
26622
26641
  })() : dateRangeFor(se.value);
26623
- $e && (U.push({ path: [Q], op: "_gte", value: $e.from }), U.push({ path: [Q], op: "_lte", value: `${$e.to}T23:59:59` }));
26642
+ $e && (Q.push({ path: [U], op: "_gte", value: $e.from }), Q.push({ path: [U], op: "_lte", value: `${$e.to}T23:59:59` }));
26624
26643
  }
26625
26644
  }
26626
- for (const Q of ne) U.push({ path: Q.path, op: Q.op, value: Q.value });
26627
- return U.length > 0 ? JSON.stringify(U) : void 0;
26645
+ for (const U of ne) Q.push({ path: U.path, op: U.op, value: U.value });
26646
+ return Q.length > 0 ? JSON.stringify(Q) : void 0;
26628
26647
  }, [F, De, G, Rt, ne]), Kt = useRef(vt);
26629
26648
  useEffect(() => {
26630
26649
  Kt.current !== vt && (Kt.current = vt, v(1));
@@ -26647,39 +26666,39 @@ function CollectionBrowserView({
26647
26666
  })
26648
26667
  ),
26649
26668
  enabled: !!e && re,
26650
- placeholderData: (U) => U,
26669
+ placeholderData: (Q) => Q,
26651
26670
  retry: !1
26652
26671
  }), us = (xt == null ? void 0 : xt.data) ?? [], es = (xt == null ? void 0 : xt.total) ?? 0, un = Math.max(1, Math.ceil(es / ie)), { data: ln = [] } = useQuery({
26653
26672
  queryKey: ["cbv-risk-rules", e],
26654
26673
  queryFn: () => c.request(
26655
26674
  get$1("/at-risk/rules/active", { collection: e })
26656
- ).then((U) => U.data ?? []).catch(() => []),
26675
+ ).then((Q) => Q.data ?? []).catch(() => []),
26657
26676
  enabled: !!e,
26658
26677
  staleTime: 6e4,
26659
26678
  retry: !1
26660
- }), Ln = ((xt == null ? void 0 : xt.data) ?? []).map((U) => String(U.id)).join(","), { data: En = {} } = useQuery({
26679
+ }), Ln = ((xt == null ? void 0 : xt.data) ?? []).map((Q) => String(Q.id)).join(","), { data: En = {} } = useQuery({
26661
26680
  queryKey: ["cbv-risk", e, Ln],
26662
26681
  queryFn: () => c.request(
26663
26682
  post$1("/at-risk/evaluate", {
26664
26683
  collection: e,
26665
- ids: ((xt == null ? void 0 : xt.data) ?? []).map((U) => String(U.id))
26684
+ ids: ((xt == null ? void 0 : xt.data) ?? []).map((Q) => String(Q.id))
26666
26685
  })
26667
- ).then((U) => U.data ?? {}).catch(() => ({})),
26686
+ ).then((Q) => Q.data ?? {}).catch(() => ({})),
26668
26687
  enabled: !!e && ln.length > 0 && ((xt == null ? void 0 : xt.data) ?? []).length > 0,
26669
26688
  staleTime: 3e4,
26670
26689
  retry: !1
26671
- }), rs = ((xt == null ? void 0 : xt.data) ?? []).map((U) => String(U.id)).join(","), { data: js } = useQuery({
26690
+ }), rs = ((xt == null ? void 0 : xt.data) ?? []).map((Q) => String(Q.id)).join(","), { data: js } = useQuery({
26672
26691
  queryKey: ["cbv-pipeline-instances", e, rs],
26673
26692
  queryFn: () => c.request(
26674
26693
  get$1(`/pipelines/instances/${e}`, rs ? { ids: rs } : void 0)
26675
- ).then((U) => U.data),
26694
+ ).then((Q) => Q.data),
26676
26695
  enabled: !!e && rs.length > 0,
26677
- placeholderData: (U) => U,
26696
+ placeholderData: (Q) => Q,
26678
26697
  staleTime: 3e4,
26679
26698
  retry: !1
26680
26699
  }), Ls = (Dn = js == null ? void 0 : js.binding) == null ? void 0 : Dn.template, { data: ks } = useQuery({
26681
26700
  queryKey: ["cbv-pipeline-template", Ls],
26682
- queryFn: () => c.request(get$1(`/pipelines/${Ls}`)).then((U) => U.data),
26701
+ queryFn: () => c.request(get$1(`/pipelines/${Ls}`)).then((Q) => Q.data),
26683
26702
  enabled: !!Ls,
26684
26703
  retry: !1
26685
26704
  }), An = !!(js != null && js.binding), { data: Bs } = useQuery({
@@ -26688,62 +26707,62 @@ function CollectionBrowserView({
26688
26707
  post$1(`/pipelines/instance/${e}/owners/batch`, {
26689
26708
  ids: rs.split(",").filter(Boolean)
26690
26709
  })
26691
- ).then((U) => U.data ?? {}),
26710
+ ).then((Q) => Q.data ?? {}),
26692
26711
  enabled: An && rs.length > 0,
26693
26712
  staleTime: 6e4,
26694
26713
  retry: !1
26695
- }), $n = useMemo(() => et.filter((U) => U.includes(".")), [et]), Ss = useMemo(
26714
+ }), $n = useMemo(() => et.filter((Q) => Q.includes(".")), [et]), Ss = useMemo(
26696
26715
  () => [.../* @__PURE__ */ new Set([...$n, ...Object.values(Re)])].slice(0, 20),
26697
26716
  [$n, Re]
26698
- ), ms = us.map((U) => String(U.id)).join(","), { data: Ut } = useQuery({
26717
+ ), ms = us.map((Q) => String(Q.id)).join(","), { data: Qt } = useQuery({
26699
26718
  queryKey: ["cbv-resolved", e, ms, Ss.join(",")],
26700
- queryFn: () => c.request(get$1(`/items/${e}/resolve-paths`, { ids: ms, paths: Ss.join(",") })).then((U) => U.data ?? { rows: {}, targets: {} }),
26719
+ queryFn: () => c.request(get$1(`/items/${e}/resolve-paths`, { ids: ms, paths: Ss.join(",") })).then((Q) => Q.data ?? { rows: {}, targets: {} }),
26701
26720
  enabled: us.length > 0 && Ss.length > 0,
26702
26721
  staleTime: 3e4,
26703
26722
  retry: !1
26704
- }), ts = (U, w) => {
26723
+ }), ts = (Q, w) => {
26705
26724
  var $e, Oe, Ve;
26706
- const Q = w.includes(".") ? w : Re[w];
26707
- if (!Q) return null;
26708
- const se = (Ve = (Oe = ($e = Ut == null ? void 0 : Ut.rows) == null ? void 0 : $e[String(U)]) == null ? void 0 : Oe[Q]) == null ? void 0 : Ve.value;
26725
+ const U = w.includes(".") ? w : Re[w];
26726
+ if (!U) return null;
26727
+ const se = (Ve = (Oe = ($e = Qt == null ? void 0 : Qt.rows) == null ? void 0 : $e[String(Q)]) == null ? void 0 : Oe[U]) == null ? void 0 : Ve.value;
26709
26728
  return se == null || se === "" ? "—" : se;
26710
- }, Un = (U) => {
26711
- var Q;
26712
- const w = U.includes(".") ? U : Re[U];
26713
- return w ? ((Q = Ut == null ? void 0 : Ut.targets) == null ? void 0 : Q[w]) ?? null : null;
26714
- }, Gn = (U, w) => {
26729
+ }, Qn = (Q) => {
26730
+ var U;
26731
+ const w = Q.includes(".") ? Q : Re[Q];
26732
+ return w ? ((U = Qt == null ? void 0 : Qt.targets) == null ? void 0 : U[w]) ?? null : null;
26733
+ }, Gn = (Q, w) => {
26715
26734
  var Oe, Ve, dt, Nt;
26716
- const Q = w.includes(".") ? w : Re[w];
26717
- if (!Q) return null;
26718
- const se = (Oe = Ut == null ? void 0 : Ut.targets) == null ? void 0 : Oe[Q], $e = ((Nt = (dt = (Ve = Ut == null ? void 0 : Ut.rows) == null ? void 0 : Ve[String(U)]) == null ? void 0 : dt[Q]) == null ? void 0 : Nt.ids) ?? [];
26735
+ const U = w.includes(".") ? w : Re[w];
26736
+ if (!U) return null;
26737
+ const se = (Oe = Qt == null ? void 0 : Qt.targets) == null ? void 0 : Oe[U], $e = ((Nt = (dt = (Ve = Qt == null ? void 0 : Qt.rows) == null ? void 0 : Ve[String(Q)]) == null ? void 0 : dt[U]) == null ? void 0 : Nt.ids) ?? [];
26719
26738
  return !se || isSystemCol(se) || $e.length === 0 ? null : { target: se, id: String($e[0]) };
26720
- }, gs = (U) => U.includes(".") || U in Re, Ks = (U) => {
26721
- if (U.includes(".")) return { kind: "text", path: U.split(".") };
26722
- const w = isM2OField(qt, e, U);
26739
+ }, gs = (Q) => Q.includes(".") || Q in Re, Ks = (Q) => {
26740
+ if (Q.includes(".")) return { kind: "text", path: Q.split(".") };
26741
+ const w = isM2OField(qt, e, Q);
26723
26742
  if (w != null && w.one_collection)
26724
26743
  return isSystemCol(w.one_collection) && w.one_collection !== "nivaro_users" ? null : { kind: "in", target: w.one_collection };
26725
- const Q = wt[U];
26726
- if (Q) {
26727
- if (Q.kind === "m2m") return { kind: "in", target: Q.target };
26728
- const $e = Re[U];
26744
+ const U = wt[Q];
26745
+ if (U) {
26746
+ if (U.kind === "m2m") return { kind: "in", target: U.target };
26747
+ const $e = Re[Q];
26729
26748
  return $e ? { kind: "text", path: $e.split(".") } : null;
26730
26749
  }
26731
- const se = lt.get(U);
26732
- return !se || se.computed_formula && !se.computed_store ? null : se.type === "integer" || se.type === "decimal" || se.type === "float" ? { kind: "num" } : se.type === "boolean" ? { kind: "bool" } : se.type === "date" || se.type === "datetime" || se.type === "timestamp" ? { kind: "date" } : se.interface === "select-dropdown" ? { kind: "enum" } : se.type === "string" || se.type === "text" ? { kind: "text", path: [U] } : null;
26733
- }, as = (U, w) => I((Q) => {
26734
- const se = { ...Q };
26735
- return w ? se[U] = w : delete se[U], se;
26736
- }), zs = (U) => {
26737
- const w = Ks(U);
26750
+ const se = lt.get(Q);
26751
+ return !se || se.computed_formula && !se.computed_store ? null : se.type === "integer" || se.type === "decimal" || se.type === "float" ? { kind: "num" } : se.type === "boolean" ? { kind: "bool" } : se.type === "date" || se.type === "datetime" || se.type === "timestamp" ? { kind: "date" } : se.interface === "select-dropdown" ? { kind: "enum" } : se.type === "string" || se.type === "text" ? { kind: "text", path: [Q] } : null;
26752
+ }, as = (Q, w) => I((U) => {
26753
+ const se = { ...U };
26754
+ return w ? se[Q] = w : delete se[Q], se;
26755
+ }), zs = (Q) => {
26756
+ const w = Ks(Q);
26738
26757
  if (!w) return null;
26739
- const Q = ce[U];
26758
+ const U = ce[Q];
26740
26759
  if (w.kind === "in")
26741
26760
  return /* @__PURE__ */ jsx(
26742
26761
  RelationColFilter,
26743
26762
  {
26744
26763
  target: w.target,
26745
- selected: (Q == null ? void 0 : Q.kind) === "in" ? Q.value : [],
26746
- onChange: (se) => as(U, se.length ? { kind: "in", value: se } : null)
26764
+ selected: (U == null ? void 0 : U.kind) === "in" ? U.value : [],
26765
+ onChange: (se) => as(Q, se.length ? { kind: "in", value: se } : null)
26747
26766
  }
26748
26767
  );
26749
26768
  if (w.kind === "enum")
@@ -26751,32 +26770,32 @@ function CollectionBrowserView({
26751
26770
  EnumColFilter,
26752
26771
  {
26753
26772
  collection: e,
26754
- field: U,
26755
- selected: (Q == null ? void 0 : Q.kind) === "in" ? Q.value : [],
26756
- onChange: (se) => as(U, se.length ? { kind: "in", value: se } : null)
26773
+ field: Q,
26774
+ selected: (U == null ? void 0 : U.kind) === "in" ? U.value : [],
26775
+ onChange: (se) => as(Q, se.length ? { kind: "in", value: se } : null)
26757
26776
  }
26758
26777
  );
26759
26778
  if (w.kind === "text")
26760
26779
  return /* @__PURE__ */ jsx(
26761
26780
  "input",
26762
26781
  {
26763
- value: (Q == null ? void 0 : Q.kind) === "text" ? Q.value : "",
26764
- onChange: (se) => as(U, se.target.value ? { kind: "text", value: se.target.value, path: w.path } : null),
26782
+ value: (U == null ? void 0 : U.kind) === "text" ? U.value : "",
26783
+ onChange: (se) => as(Q, se.target.value ? { kind: "text", value: se.target.value, path: w.path } : null),
26765
26784
  placeholder: "Filter…",
26766
- "aria-label": `Filter ${U}`,
26785
+ "aria-label": `Filter ${Q}`,
26767
26786
  className: "h-6 w-full min-w-[64px] rounded border border-slate-200 bg-white px-1.5 text-[11px] font-normal normal-case tracking-normal outline-none focus:border-[#00ceff80] dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100"
26768
26787
  }
26769
26788
  );
26770
26789
  if (w.kind === "num") {
26771
- const se = (Q == null ? void 0 : Q.kind) === "num" ? Q.op : "_eq", $e = (Q == null ? void 0 : Q.kind) === "num" ? Q.value : "";
26790
+ const se = (U == null ? void 0 : U.kind) === "num" ? U.op : "_eq", $e = (U == null ? void 0 : U.kind) === "num" ? U.value : "";
26772
26791
  return /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-0.5", children: [
26773
26792
  /* @__PURE__ */ jsx(
26774
26793
  SimpleSelectXs,
26775
26794
  {
26776
26795
  value: se,
26777
- onChange: (Oe) => as(U, { kind: "num", op: Oe, value: $e }),
26796
+ onChange: (Oe) => as(Q, { kind: "num", op: Oe, value: $e }),
26778
26797
  options: NUM_FILTER_OPS.map((Oe) => ({ value: Oe.value, label: Oe.label })),
26779
- ariaLabel: `Filter operator ${U}`
26798
+ ariaLabel: `Filter operator ${Q}`
26780
26799
  }
26781
26800
  ),
26782
26801
  /* @__PURE__ */ jsx(
@@ -26784,8 +26803,8 @@ function CollectionBrowserView({
26784
26803
  {
26785
26804
  type: "number",
26786
26805
  value: $e,
26787
- onChange: (Oe) => as(U, Oe.target.value ? { kind: "num", op: se, value: Oe.target.value } : null),
26788
- "aria-label": `Filter value ${U}`,
26806
+ onChange: (Oe) => as(Q, Oe.target.value ? { kind: "num", op: se, value: Oe.target.value } : null),
26807
+ "aria-label": `Filter value ${Q}`,
26789
26808
  className: "h-6 w-full min-w-[52px] rounded border border-slate-200 bg-white px-1.5 text-[11px] font-normal outline-none focus:border-[#00ceff80] dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100"
26790
26809
  }
26791
26810
  )
@@ -26794,52 +26813,52 @@ function CollectionBrowserView({
26794
26813
  return w.kind === "bool" ? /* @__PURE__ */ jsx(
26795
26814
  SimpleSelectXs,
26796
26815
  {
26797
- value: (Q == null ? void 0 : Q.kind) === "bool" ? Q.value : "",
26798
- onChange: (se) => as(U, se ? { kind: "bool", value: se } : null),
26816
+ value: (U == null ? void 0 : U.kind) === "bool" ? U.value : "",
26817
+ onChange: (se) => as(Q, se ? { kind: "bool", value: se } : null),
26799
26818
  options: [
26800
26819
  { value: "", label: "All" },
26801
26820
  { value: "true", label: "Yes" },
26802
26821
  { value: "false", label: "No" }
26803
26822
  ],
26804
- ariaLabel: `Filter ${U}`,
26823
+ ariaLabel: `Filter ${Q}`,
26805
26824
  className: "w-full"
26806
26825
  }
26807
26826
  ) : w.kind === "date" ? /* @__PURE__ */ jsx(
26808
26827
  DateColFilter,
26809
26828
  {
26810
- value: (Q == null ? void 0 : Q.kind) === "date" ? Q.value : "",
26811
- onChange: (se) => as(U, se ? { kind: "date", value: se } : null)
26829
+ value: (U == null ? void 0 : U.kind) === "date" ? U.value : "",
26830
+ onChange: (se) => as(Q, se ? { kind: "date", value: se } : null)
26812
26831
  }
26813
26832
  ) : null;
26814
- }, gn = et.some((U) => Ks(U) != null), mn = (U) => {
26815
- var Q, se;
26816
- if (((Q = g[U]) == null ? void 0 : Q.type) === "number") return !0;
26817
- if (U.includes(".") || U in Re || isM2OField(qt, e, U)) return !1;
26818
- const w = (se = lt.get(U)) == null ? void 0 : se.type;
26833
+ }, gn = et.some((Q) => Ks(Q) != null), mn = (Q) => {
26834
+ var U, se;
26835
+ if (((U = g[Q]) == null ? void 0 : U.type) === "number") return !0;
26836
+ if (Q.includes(".") || Q in Re || isM2OField(qt, e, Q)) return !1;
26837
+ const w = (se = lt.get(Q)) == null ? void 0 : se.type;
26819
26838
  return w === "integer" || w === "decimal" || w === "float";
26820
- }, Tn = (U, w) => {
26821
- const Q = g[w];
26822
- return Q && U && U !== "—" ? formatMultiValue(U, Q) : U;
26839
+ }, Tn = (Q, w) => {
26840
+ const U = g[w];
26841
+ return U && Q && Q !== "—" ? formatMultiValue(Q, U) : Q;
26823
26842
  }, { data: Es = [] } = useQuery({
26824
26843
  queryKey: ["cbv-views", e],
26825
- queryFn: () => c.request(get$1("/saved-views", { collection: e })).then((U) => U.data ?? []),
26844
+ queryFn: () => c.request(get$1("/saved-views", { collection: e })).then((Q) => Q.data ?? []),
26826
26845
  staleTime: 3e4
26827
- }), As = () => p.invalidateQueries({ queryKey: ["cbv-views", e] }), yn = (U) => {
26846
+ }), As = () => p.invalidateQueries({ queryKey: ["cbv-views", e] }), yn = (Q) => {
26828
26847
  var w;
26829
- if (Ce(U.id), y(U.filters ?? []), f(U.sort ?? ""), (w = U.columns) != null && w.length) {
26830
- const se = U.columns.map(viewColumnKey).filter((dt) => dt.includes(".") || lt.has(dt));
26848
+ if (Ce(Q.id), y(Q.filters ?? []), f(Q.sort ?? ""), (w = Q.columns) != null && w.length) {
26849
+ const se = Q.columns.map(viewColumnKey).filter((dt) => dt.includes(".") || lt.has(dt));
26831
26850
  se.length > 0 && C(se);
26832
26851
  const $e = {}, Oe = {}, Ve = {};
26833
- for (const dt of U.columns)
26852
+ for (const dt of Q.columns)
26834
26853
  typeof dt != "string" && dt.label && ($e[dt.key] = dt.label), typeof dt != "string" && dt.format && (Oe[dt.key] = dt.format), typeof dt != "string" && dt.pin && (Ve[dt.key] = dt.pin);
26835
26854
  T($e), M(Oe), ss(Object.keys(Ve).length ? Ve : null);
26836
26855
  } else
26837
26856
  ss(null);
26838
26857
  v(1);
26839
26858
  }, on = () => {
26840
- const U = Es.find((w) => w.is_default);
26841
- if (U) {
26842
- yn(U);
26859
+ const Q = Es.find((w) => w.is_default);
26860
+ if (Q) {
26861
+ yn(Q);
26843
26862
  return;
26844
26863
  }
26845
26864
  Ce(null), y([]), f(n ?? ""), C(s ?? null), T({}), M({}), ss(null), v(1);
@@ -26847,43 +26866,43 @@ function CollectionBrowserView({
26847
26866
  filters: F,
26848
26867
  sort: b,
26849
26868
  columns: [
26850
- ...et.map((U) => {
26851
- const w = q[U], Q = g[U], se = is[U];
26852
- return !w && !Q && !se ? U : {
26853
- key: U,
26869
+ ...et.map((Q) => {
26870
+ const w = q[Q], U = g[Q], se = is[Q];
26871
+ return !w && !U && !se ? Q : {
26872
+ key: Q,
26854
26873
  ...w ? { label: w } : {},
26855
- ...Q ? { format: Q } : {},
26874
+ ...U ? { format: U } : {},
26856
26875
  ...se ? { pin: se } : {}
26857
26876
  };
26858
26877
  }),
26859
26878
  // Synthetic columns (State/Owners/Actions) persist pins as pin-only
26860
26879
  // entries; applyView drops them from the display-column list.
26861
- ...["__state__", "__owners__", "__actions__"].filter((U) => is[U]).map((U) => ({ key: U, pin: is[U] }))
26880
+ ...["__state__", "__owners__", "__actions__"].filter((Q) => is[Q]).map((Q) => ({ key: Q, pin: is[Q] }))
26862
26881
  ]
26863
26882
  });
26864
26883
  useEffect(() => {
26865
26884
  if (ot.current || Es.length === 0 || _t.length === 0) return;
26866
26885
  ot.current = !0;
26867
- const U = Es.find((w) => w.is_default);
26868
- U && he == null && yn(U);
26886
+ const Q = Es.find((w) => w.is_default);
26887
+ Q && he == null && yn(Q);
26869
26888
  }, [Es, _t]);
26870
- const Us = useMutation({
26889
+ const Qs = useMutation({
26871
26890
  mutationFn: () => c.request(
26872
26891
  post$1("/saved-views", { collection: e, name: ge.trim(), ...Ds() })
26873
26892
  ),
26874
- onSuccess: (U) => {
26875
- Pe(!1), He(""), Ce(U.data.id), As();
26893
+ onSuccess: (Q) => {
26894
+ Pe(!1), He(""), Ce(Q.data.id), As();
26876
26895
  }
26877
26896
  }), os = useMutation({
26878
- mutationFn: (U) => c.request(patch$1(`/saved-views/${U}`, Ds())),
26897
+ mutationFn: (Q) => c.request(patch$1(`/saved-views/${Q}`, Ds())),
26879
26898
  onSuccess: As
26880
- }), Qn = useMutation({
26881
- mutationFn: ({ id: U, on: w }) => c.request(patch$1(`/saved-views/${U}`, { is_default: w })),
26899
+ }), Un = useMutation({
26900
+ mutationFn: ({ id: Q, on: w }) => c.request(patch$1(`/saved-views/${Q}`, { is_default: w })),
26882
26901
  onSuccess: As
26883
26902
  }), Wn = useMutation({
26884
26903
  mutationFn: () => {
26885
- const U = Es.find((w) => w.is_default);
26886
- return U ? c.request(patch$1(`/saved-views/${U.id}`, { ...Ds(), is_default: !0 })) : c.request(
26904
+ const Q = Es.find((w) => w.is_default);
26905
+ return Q ? c.request(patch$1(`/saved-views/${Q.id}`, { ...Ds(), is_default: !0 })) : c.request(
26887
26906
  post$1("/saved-views", { collection: e, name: "Default", is_default: !0, ...Ds() })
26888
26907
  );
26889
26908
  },
@@ -26891,18 +26910,18 @@ function CollectionBrowserView({
26891
26910
  Y(!1), As();
26892
26911
  }
26893
26912
  }), Xs = useMutation({
26894
- mutationFn: (U) => c.request(del$1(`/items/${e}/${U}`)),
26913
+ mutationFn: (Q) => c.request(del$1(`/items/${e}/${Q}`)),
26895
26914
  onSuccess: () => void p.invalidateQueries({ queryKey: ["cbv-items", e] })
26896
26915
  }), Zs = useMutation({
26897
- mutationFn: (U) => c.request(del$1(`/saved-views/${U}`)),
26898
- onSuccess: (U, w) => {
26916
+ mutationFn: (Q) => c.request(del$1(`/saved-views/${Q}`)),
26917
+ onSuccess: (Q, w) => {
26899
26918
  he === w && on(), As();
26900
26919
  }
26901
26920
  }), Vn = async () => {
26902
26921
  if (!mt) {
26903
26922
  yt(!0);
26904
26923
  try {
26905
- const U = await c.request(
26924
+ const Q = await c.request(
26906
26925
  get$1(`/items/${e}`, {
26907
26926
  limit: 2e3,
26908
26927
  ...u ? { search: u } : {},
@@ -26910,12 +26929,12 @@ function CollectionBrowserView({
26910
26929
  ...vt ? { conditions: vt } : {}
26911
26930
  })
26912
26931
  ).then((We) => We.data ?? []), w = et;
26913
- let Q = {};
26932
+ let U = {};
26914
26933
  if (Ss.length > 0)
26915
26934
  try {
26916
- Q = await c.request(
26935
+ U = await c.request(
26917
26936
  get$1(`/items/${e}/resolve-paths`, {
26918
- ids: U.slice(0, 500).map((We) => String(We.id)).join(","),
26937
+ ids: Q.slice(0, 500).map((We) => String(We.id)).join(","),
26919
26938
  paths: Ss.join(",")
26920
26939
  })
26921
26940
  ).then((We) => {
@@ -26923,7 +26942,7 @@ function CollectionBrowserView({
26923
26942
  return ((Ct = We.data) == null ? void 0 : Ct.rows) ?? {};
26924
26943
  });
26925
26944
  } catch {
26926
- Q = {};
26945
+ U = {};
26927
26946
  }
26928
26947
  const se = (We) => {
26929
26948
  const Ct = We == null ? "" : String(typeof We == "object" ? JSON.stringify(We) : We);
@@ -26932,14 +26951,14 @@ function CollectionBrowserView({
26932
26951
  var ds, nn;
26933
26952
  const Ft = g[Ct];
26934
26953
  if (Ct.includes(".") || Ct in Re) {
26935
- const On = Ct.includes(".") ? Ct : Re[Ct], zn = ((nn = (ds = Q[String(We.id)]) == null ? void 0 : ds[On]) == null ? void 0 : nn.value) ?? "";
26954
+ const On = Ct.includes(".") ? Ct : Re[Ct], zn = ((nn = (ds = U[String(We.id)]) == null ? void 0 : ds[On]) == null ? void 0 : nn.value) ?? "";
26936
26955
  return Ft && zn ? formatMultiValue(zn, Ft) : zn;
26937
26956
  }
26938
26957
  const Gt = We[Ct];
26939
26958
  return Ft && Gt != null ? formatValue$1(String(Gt), Ft) : Gt;
26940
26959
  }, Oe = [
26941
26960
  ["id", ...w.map((We) => Ms(We))].map(se).join(","),
26942
- ...U.map((We) => [We.id, ...w.map((Ct) => $e(We, Ct))].map(se).join(","))
26961
+ ...Q.map((We) => [We.id, ...w.map((Ct) => $e(We, Ct))].map(se).join(","))
26943
26962
  ], Ve = new Blob([Oe.join(`
26944
26963
  `)], { type: "text/csv;charset=utf-8" }), dt = URL.createObjectURL(Ve), Nt = document.createElement("a");
26945
26964
  Nt.href = dt, Nt.download = `${e}.csv`, Nt.click(), URL.revokeObjectURL(dt);
@@ -26947,73 +26966,73 @@ function CollectionBrowserView({
26947
26966
  yt(!1);
26948
26967
  }
26949
26968
  }
26950
- }, ls = (U) => {
26951
- i ? i(U) : m({ collection: e, itemId: String(U) });
26952
- }, Cs = (U) => {
26953
- b === U ? f(`-${U}`) : b === `-${U}` ? f("") : f(U), v(1);
26954
- }, vn = us.length > 0 && us.every((U) => ue.includes(U.id)), Os = () => de(
26955
- vn ? ue.filter((U) => !us.some((w) => w.id === U)) : [.../* @__PURE__ */ new Set([...ue, ...us.map((U) => U.id)])]
26956
- ), Qs = (U) => de((w) => w.includes(U) ? w.filter((Q) => Q !== U) : [...w, U]), ps = es === 0 ? 0 : (N - 1) * ie + 1, en = Math.min(N * ie, es), Zt = !!(js != null && js.instances), Yn = (Xt ? 1 : 0) + (Zt ? 2 : 0) + (Ht ? 1 : 0), qn = [
26957
- ...et.map((U) => ({ key: U, kind: "data" })),
26969
+ }, ls = (Q) => {
26970
+ i ? i(Q) : m({ collection: e, itemId: String(Q) });
26971
+ }, Cs = (Q) => {
26972
+ b === Q ? f(`-${Q}`) : b === `-${Q}` ? f("") : f(Q), v(1);
26973
+ }, vn = us.length > 0 && us.every((Q) => ue.includes(Q.id)), Os = () => de(
26974
+ vn ? ue.filter((Q) => !us.some((w) => w.id === Q)) : [.../* @__PURE__ */ new Set([...ue, ...us.map((Q) => Q.id)])]
26975
+ ), Us = (Q) => de((w) => w.includes(Q) ? w.filter((U) => U !== Q) : [...w, Q]), ps = es === 0 ? 0 : (N - 1) * ie + 1, en = Math.min(N * ie, es), Zt = !!(js != null && js.instances), Yn = (Xt ? 1 : 0) + (Zt ? 2 : 0) + (Ht ? 1 : 0), qn = [
26976
+ ...et.map((Q) => ({ key: Q, kind: "data" })),
26958
26977
  ...Zt ? [
26959
26978
  { key: "__state__", kind: "state" },
26960
26979
  { key: "__owners__", kind: "owners" }
26961
26980
  ] : [],
26962
26981
  ...Ht ? [{ key: "__actions__", kind: "actions" }] : []
26963
26982
  ], jn = [
26964
- ...qn.filter((U) => Vt(U.key) === "left"),
26965
- ...qn.filter((U) => !Vt(U.key)),
26966
- ...qn.filter((U) => Vt(U.key) === "right")
26967
- ], tn = jn.filter((U) => Vt(U.key) === "left").map((U) => U.key), pn = jn.filter((U) => Vt(U.key) === "right").map((U) => U.key), xn = useRef(/* @__PURE__ */ new Map()), [sn, kn] = useState({});
26983
+ ...qn.filter((Q) => Vt(Q.key) === "left"),
26984
+ ...qn.filter((Q) => !Vt(Q.key)),
26985
+ ...qn.filter((Q) => Vt(Q.key) === "right")
26986
+ ], tn = jn.filter((Q) => Vt(Q.key) === "left").map((Q) => Q.key), pn = jn.filter((Q) => Vt(Q.key) === "right").map((Q) => Q.key), xn = useRef(/* @__PURE__ */ new Map()), [sn, kn] = useState({});
26968
26987
  useLayoutEffect(() => {
26969
- const U = {};
26970
- for (const [Q, se] of xn.current)
26971
- se != null && se.isConnected && (U[Q] = se.getBoundingClientRect().width);
26972
- const w = /* @__PURE__ */ new Set([...Object.keys(U), ...Object.keys(sn)]);
26973
- for (const Q of w)
26974
- if (Math.abs((U[Q] ?? -1) - (sn[Q] ?? -1)) > 0.5) {
26975
- kn(U);
26988
+ const Q = {};
26989
+ for (const [U, se] of xn.current)
26990
+ se != null && se.isConnected && (Q[U] = se.getBoundingClientRect().width);
26991
+ const w = /* @__PURE__ */ new Set([...Object.keys(Q), ...Object.keys(sn)]);
26992
+ for (const U of w)
26993
+ if (Math.abs((Q[U] ?? -1) - (sn[U] ?? -1)) > 0.5) {
26994
+ kn(Q);
26976
26995
  return;
26977
26996
  }
26978
26997
  });
26979
- const Ps = 36, dn = (U) => {
26980
- if (Vt(U) === "left") {
26998
+ const Ps = 36, dn = (Q) => {
26999
+ if (Vt(Q) === "left") {
26981
27000
  let se = Xt ? sn.__checkbox__ ?? Ps : 0;
26982
27001
  for (const $e of tn) {
26983
- if ($e === U) break;
27002
+ if ($e === Q) break;
26984
27003
  se += sn[$e] ?? 0;
26985
27004
  }
26986
27005
  return Math.floor(se);
26987
27006
  }
26988
- let Q = 0;
27007
+ let U = 0;
26989
27008
  for (const se of [...pn].reverse()) {
26990
- if (se === U) break;
26991
- Q += sn[se] ?? 0;
27009
+ if (se === Q) break;
27010
+ U += sn[se] ?? 0;
26992
27011
  }
26993
- return Math.floor(Q);
26994
- }, wn = (U, w, Q) => {
26995
- const se = Vt(U);
27012
+ return Math.floor(U);
27013
+ }, wn = (Q, w, U) => {
27014
+ const se = Vt(Q);
26996
27015
  if (!se) return "";
26997
- const $e = se === "left" && tn[tn.length - 1] === U ? "border-r border-slate-200 dark:border-slate-700" : se === "right" && pn[0] === U ? "border-l border-slate-200 dark:border-slate-700" : "";
26998
- return `sticky ${w} ${Q} ${$e}`;
26999
- }, $s = (U) => {
27000
- const w = Vt(U);
27016
+ const $e = se === "left" && tn[tn.length - 1] === Q ? "border-r border-slate-200 dark:border-slate-700" : se === "right" && pn[0] === Q ? "border-l border-slate-200 dark:border-slate-700" : "";
27017
+ return `sticky ${w} ${U} ${$e}`;
27018
+ }, $s = (Q) => {
27019
+ const w = Vt(Q);
27001
27020
  if (w)
27002
- return w === "left" ? { left: dn(U) } : { right: dn(U) };
27003
- }, Ts = (U) => (w) => {
27004
- w ? xn.current.set(U, w) : xn.current.delete(U);
27021
+ return w === "left" ? { left: dn(Q) } : { right: dn(Q) };
27022
+ }, Ts = (Q) => (w) => {
27023
+ w ? xn.current.set(Q, w) : xn.current.delete(Q);
27005
27024
  }, Rn = {
27006
27025
  left: "Pinned left — click to pin right",
27007
27026
  right: "Pinned right — click to unpin",
27008
27027
  none: "Pin column left"
27009
- }, Hs = (U) => {
27010
- const w = Vt(U);
27028
+ }, Hs = (Q) => {
27029
+ const w = Vt(Q);
27011
27030
  return /* @__PURE__ */ jsx(
27012
27031
  "button",
27013
27032
  {
27014
27033
  type: "button",
27015
- onClick: (Q) => {
27016
- Q.stopPropagation(), _s(U);
27034
+ onClick: (U) => {
27035
+ U.stopPropagation(), _s(Q);
27017
27036
  },
27018
27037
  title: Rn[w ?? "none"],
27019
27038
  "aria-label": Rn[w ?? "none"],
@@ -27096,12 +27115,12 @@ function CollectionBrowserView({
27096
27115
  collection: e,
27097
27116
  meta: st,
27098
27117
  search: k,
27099
- onSearch: (U) => {
27100
- x(U), v(1);
27118
+ onSearch: (Q) => {
27119
+ x(Q), v(1);
27101
27120
  },
27102
27121
  filters: F,
27103
- onFiltersChange: (U) => {
27104
- y(U), v(1);
27122
+ onFiltersChange: (Q) => {
27123
+ y(Q), v(1);
27105
27124
  }
27106
27125
  }
27107
27126
  ),
@@ -27121,7 +27140,7 @@ function CollectionBrowserView({
27121
27140
  "button",
27122
27141
  {
27123
27142
  type: "button",
27124
- onClick: () => Y((U) => !U),
27143
+ onClick: () => Y((Q) => !Q),
27125
27144
  className: "h-8 rounded-md border border-slate-200 px-2.5 text-[12px] font-medium text-slate-500 hover:text-slate-700 dark:border-slate-700 dark:text-slate-400",
27126
27145
  children: "Columns"
27127
27146
  }
@@ -27129,13 +27148,13 @@ function CollectionBrowserView({
27129
27148
  Ne && /* @__PURE__ */ jsxs("div", { className: "absolute right-0 top-full z-50 mt-1 flex max-h-[440px] w-72 flex-col overflow-hidden rounded-xl border border-slate-200 bg-white shadow-lg dark:border-slate-700 dark:bg-slate-900", children: [
27130
27149
  /* @__PURE__ */ jsxs("div", { className: "flex-1 overflow-y-auto p-1.5", children: [
27131
27150
  /* @__PURE__ */ jsx("p", { className: "px-1.5 pb-1 pt-0.5 text-[10.5px] font-semibold uppercase tracking-wide text-slate-400", children: "Visible columns" }),
27132
- et.map((U, w) => {
27133
- var Q;
27151
+ et.map((Q, w) => {
27152
+ var U;
27134
27153
  return /* @__PURE__ */ jsxs("div", { children: [
27135
27154
  /* @__PURE__ */ jsxs(
27136
27155
  "div",
27137
27156
  {
27138
- draggable: j !== U,
27157
+ draggable: j !== Q,
27139
27158
  onDragStart: () => {
27140
27159
  H.current = w;
27141
27160
  },
@@ -27150,15 +27169,15 @@ function CollectionBrowserView({
27150
27169
  className: "group flex items-center gap-1.5 rounded px-1.5 py-1 hover:bg-slate-50 dark:hover:bg-slate-800",
27151
27170
  children: [
27152
27171
  /* @__PURE__ */ jsx("span", { "aria-hidden": !0, className: "cursor-grab text-[10px] leading-none text-slate-300 group-hover:text-slate-400", children: "⠿" }),
27153
- j === U ? /* @__PURE__ */ jsx(
27172
+ j === Q ? /* @__PURE__ */ jsx(
27154
27173
  "input",
27155
27174
  {
27156
27175
  autoFocus: !0,
27157
- value: q[U] ?? "",
27158
- placeholder: U.includes(".") ? U.split(".").map(titleCase$1).join(" › ") : titleCase$1(U),
27176
+ value: q[Q] ?? "",
27177
+ placeholder: Q.includes(".") ? Q.split(".").map(titleCase$1).join(" › ") : titleCase$1(Q),
27159
27178
  onChange: (se) => T(($e) => {
27160
27179
  const Oe = { ...$e };
27161
- return se.target.value ? Oe[U] = se.target.value : delete Oe[U], Oe;
27180
+ return se.target.value ? Oe[Q] = se.target.value : delete Oe[Q], Oe;
27162
27181
  }),
27163
27182
  onKeyDown: (se) => {
27164
27183
  (se.key === "Enter" || se.key === "Escape") && _(null);
@@ -27166,14 +27185,14 @@ function CollectionBrowserView({
27166
27185
  onBlur: () => _(null),
27167
27186
  className: "h-5 w-full min-w-0 flex-1 rounded border border-slate-200 bg-slate-50 px-1 text-[11.5px] outline-none focus:border-[#00ceff80] dark:border-slate-700 dark:bg-slate-800 dark:text-slate-100"
27168
27187
  }
27169
- ) : /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-[12px] text-slate-700 dark:text-slate-200", children: Ms(U) }),
27170
- j !== U && /* @__PURE__ */ jsx(
27188
+ ) : /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-[12px] text-slate-700 dark:text-slate-200", children: Ms(Q) }),
27189
+ j !== Q && /* @__PURE__ */ jsx(
27171
27190
  "button",
27172
27191
  {
27173
27192
  type: "button",
27174
- onClick: () => _(U),
27193
+ onClick: () => _(Q),
27175
27194
  title: "Rename column",
27176
- "aria-label": `Rename ${U}`,
27195
+ "aria-label": `Rename ${Q}`,
27177
27196
  className: "text-slate-300 opacity-0 hover:text-slate-500 group-hover:opacity-100",
27178
27197
  children: "✎"
27179
27198
  }
@@ -27182,10 +27201,10 @@ function CollectionBrowserView({
27182
27201
  "button",
27183
27202
  {
27184
27203
  type: "button",
27185
- onClick: () => P(L === U ? null : U),
27204
+ onClick: () => P(L === Q ? null : Q),
27186
27205
  title: "Format column",
27187
- "aria-label": `Format ${U}`,
27188
- className: g[U] ? "text-[11px] font-bold text-[#00a5cc]" : "text-[11px] text-slate-300 opacity-0 hover:text-slate-500 group-hover:opacity-100",
27206
+ "aria-label": `Format ${Q}`,
27207
+ className: g[Q] ? "text-[11px] font-bold text-[#00a5cc]" : "text-[11px] text-slate-300 opacity-0 hover:text-slate-500 group-hover:opacity-100",
27189
27208
  children: "$"
27190
27209
  }
27191
27210
  ),
@@ -27193,9 +27212,9 @@ function CollectionBrowserView({
27193
27212
  "button",
27194
27213
  {
27195
27214
  type: "button",
27196
- onClick: () => C(et.filter((se) => se !== U)),
27215
+ onClick: () => C(et.filter((se) => se !== Q)),
27197
27216
  title: "Remove column",
27198
- "aria-label": `Remove ${U}`,
27217
+ "aria-label": `Remove ${Q}`,
27199
27218
  className: "text-slate-300 hover:text-slate-500",
27200
27219
  children: "✕"
27201
27220
  }
@@ -27203,9 +27222,9 @@ function CollectionBrowserView({
27203
27222
  ]
27204
27223
  }
27205
27224
  ),
27206
- L === U && /* @__PURE__ */ jsxs("div", { className: "mb-1 ml-5 mr-1 rounded-md border border-slate-100 bg-slate-50 p-1.5 dark:border-slate-800 dark:bg-slate-800/60", children: [
27225
+ L === Q && /* @__PURE__ */ jsxs("div", { className: "mb-1 ml-5 mr-1 rounded-md border border-slate-100 bg-slate-50 p-1.5 dark:border-slate-800 dark:bg-slate-800/60", children: [
27207
27226
  /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1", children: FORMAT_PRESETS.map((se) => {
27208
- const $e = JSON.stringify(g[U] ?? null) === JSON.stringify(se.cfg);
27227
+ const $e = JSON.stringify(g[Q] ?? null) === JSON.stringify(se.cfg);
27209
27228
  return /* @__PURE__ */ jsx(
27210
27229
  "button",
27211
27230
  {
@@ -27213,7 +27232,7 @@ function CollectionBrowserView({
27213
27232
  onClick: () => {
27214
27233
  M((Oe) => {
27215
27234
  const Ve = { ...Oe };
27216
- return se.cfg ? Ve[U] = se.cfg : delete Ve[U], Ve;
27235
+ return se.cfg ? Ve[Q] = se.cfg : delete Ve[Q], Ve;
27217
27236
  }), P(null);
27218
27237
  },
27219
27238
  className: `rounded border px-1.5 py-0.5 text-[10.5px] ${$e ? "border-[#00ceff66] bg-[#00ceff14] text-slate-800 dark:text-slate-100" : "border-slate-200 bg-white text-slate-500 hover:text-slate-700 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-400"}`,
@@ -27226,11 +27245,11 @@ function CollectionBrowserView({
27226
27245
  "input",
27227
27246
  {
27228
27247
  placeholder: "Custom date… e.g. DD MMM YY hh:mm A — Enter",
27229
- defaultValue: ((Q = g[U]) == null ? void 0 : Q.type) === "datetime" ? g[U].template : "",
27248
+ defaultValue: ((U = g[Q]) == null ? void 0 : U.type) === "datetime" ? g[Q].template : "",
27230
27249
  onKeyDown: (se) => {
27231
27250
  if (se.key === "Enter") {
27232
27251
  const $e = se.target.value.trim();
27233
- $e && M((Oe) => ({ ...Oe, [U]: { type: "datetime", template: $e } })), P(null);
27252
+ $e && M((Oe) => ({ ...Oe, [Q]: { type: "datetime", template: $e } })), P(null);
27234
27253
  }
27235
27254
  se.key === "Escape" && P(null);
27236
27255
  },
@@ -27238,21 +27257,21 @@ function CollectionBrowserView({
27238
27257
  }
27239
27258
  )
27240
27259
  ] })
27241
- ] }, U);
27260
+ ] }, Q);
27242
27261
  }),
27243
27262
  /* @__PURE__ */ jsx("p", { className: "mt-2 border-t border-slate-100 px-1.5 pb-1 pt-2 text-[10.5px] font-semibold uppercase tracking-wide text-slate-400 dark:border-slate-800", children: "Add column" }),
27244
- _t.filter((U) => !et.includes(U.field)).map((U) => /* @__PURE__ */ jsxs(
27263
+ _t.filter((Q) => !et.includes(Q.field)).map((Q) => /* @__PURE__ */ jsxs(
27245
27264
  "button",
27246
27265
  {
27247
27266
  type: "button",
27248
- onClick: () => C([...et, U.field]),
27267
+ onClick: () => C([...et, Q.field]),
27249
27268
  className: "flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-left text-[12px] text-slate-600 hover:bg-slate-50 dark:text-slate-300 dark:hover:bg-slate-800",
27250
27269
  children: [
27251
27270
  /* @__PURE__ */ jsx("span", { "aria-hidden": !0, className: "text-slate-400", children: "+" }),
27252
- /* @__PURE__ */ jsx("span", { className: "truncate", children: titleCase$1(U.field) })
27271
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: titleCase$1(Q.field) })
27253
27272
  ]
27254
27273
  },
27255
- U.field
27274
+ Q.field
27256
27275
  )),
27257
27276
  st && /* @__PURE__ */ jsxs("div", { className: "mt-1 border-t border-slate-100 pt-1.5 dark:border-slate-800", children: [
27258
27277
  /* @__PURE__ */ jsx("p", { className: "px-1.5 pb-1 text-[10.5px] font-semibold uppercase tracking-wide text-slate-400", children: "+ Related column" }),
@@ -27261,8 +27280,8 @@ function CollectionBrowserView({
27261
27280
  {
27262
27281
  collection: e,
27263
27282
  meta: st,
27264
- onPick: (U) => {
27265
- const w = U.join(".");
27283
+ onPick: (Q) => {
27284
+ const w = Q.join(".");
27266
27285
  et.includes(w) || C([...et, w]), Y(!1);
27267
27286
  }
27268
27287
  }
@@ -27278,9 +27297,9 @@ function CollectionBrowserView({
27278
27297
  autoFocus: !0,
27279
27298
  value: ge,
27280
27299
  placeholder: "Preset name…",
27281
- onChange: (U) => He(U.target.value),
27282
- onKeyDown: (U) => {
27283
- U.key === "Enter" && ge.trim() && (Us.mutate(), D(!1)), U.key === "Escape" && D(!1);
27300
+ onChange: (Q) => He(Q.target.value),
27301
+ onKeyDown: (Q) => {
27302
+ Q.key === "Enter" && ge.trim() && (Qs.mutate(), D(!1)), Q.key === "Escape" && D(!1);
27284
27303
  },
27285
27304
  className: "h-6 w-full min-w-0 flex-1 rounded border border-slate-200 bg-slate-50 px-1.5 text-[11.5px] outline-none focus:border-[#00ceff80] dark:border-slate-700 dark:bg-slate-800 dark:text-slate-100"
27286
27305
  }
@@ -27289,9 +27308,9 @@ function CollectionBrowserView({
27289
27308
  "button",
27290
27309
  {
27291
27310
  type: "button",
27292
- disabled: !ge.trim() || Us.isPending,
27311
+ disabled: !ge.trim() || Qs.isPending,
27293
27312
  onClick: () => {
27294
- Us.mutate(), D(!1);
27313
+ Qs.mutate(), D(!1);
27295
27314
  },
27296
27315
  className: "text-[11.5px] font-medium text-[#00a5cc] disabled:opacity-40",
27297
27316
  children: "Save"
@@ -27350,11 +27369,11 @@ function CollectionBrowserView({
27350
27369
  ] }),
27351
27370
  ne.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 flex-wrap items-center gap-1.5 border-b border-slate-100 bg-[#00ceff08] px-4 py-1.5 dark:border-slate-800", children: [
27352
27371
  /* @__PURE__ */ jsx("span", { className: "text-[11px] font-medium text-slate-500 dark:text-slate-400", children: "Showing:" }),
27353
- ne.map((U, w) => /* @__PURE__ */ jsx(
27372
+ ne.map((Q, w) => /* @__PURE__ */ jsx(
27354
27373
  "span",
27355
27374
  {
27356
27375
  className: "rounded border border-[#00ceff66] bg-[#00ceff14] px-1.5 py-px text-[11px] text-slate-800 dark:text-slate-100",
27357
- children: U.label ?? U.path.join(".")
27376
+ children: Q.label ?? Q.path.join(".")
27358
27377
  },
27359
27378
  w
27360
27379
  )),
@@ -27369,16 +27388,16 @@ function CollectionBrowserView({
27369
27388
  )
27370
27389
  ] }),
27371
27390
  De.length > 0 && /* @__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: [
27372
- De.map((U) => /* @__PURE__ */ jsx(
27391
+ De.map((Q) => /* @__PURE__ */ jsx(
27373
27392
  QuickFilterSelect,
27374
27393
  {
27375
- def: U,
27376
- allowedIds: at(U),
27377
- scopeDefault: me.has(U.key),
27378
- selected: K[U.key] ?? [],
27379
- onChange: (w) => xe((Q) => ({ ...Q, [U.key]: w }))
27394
+ def: Q,
27395
+ allowedIds: at(Q),
27396
+ scopeDefault: me.has(Q.key),
27397
+ selected: K[Q.key] ?? [],
27398
+ onChange: (w) => xe((U) => ({ ...U, [Q.key]: w }))
27380
27399
  },
27381
- U.key
27400
+ Q.key
27382
27401
  )),
27383
27402
  /* @__PURE__ */ jsx(
27384
27403
  "button",
@@ -27409,7 +27428,7 @@ function CollectionBrowserView({
27409
27428
  ] })
27410
27429
  ] }),
27411
27430
  /* @__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: [
27412
- !Es.some((U) => U.is_default) && /* @__PURE__ */ jsx(
27431
+ !Es.some((Q) => Q.is_default) && /* @__PURE__ */ jsx(
27413
27432
  "button",
27414
27433
  {
27415
27434
  type: "button",
@@ -27418,39 +27437,39 @@ function CollectionBrowserView({
27418
27437
  children: "Default"
27419
27438
  }
27420
27439
  ),
27421
- Es.map((U) => /* @__PURE__ */ jsxs(
27440
+ Es.map((Q) => /* @__PURE__ */ jsxs(
27422
27441
  "span",
27423
27442
  {
27424
- className: `inline-flex h-6 items-center gap-1 rounded-full border px-2.5 text-[12px] transition-colors ${he === U.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"}`,
27443
+ className: `inline-flex h-6 items-center gap-1 rounded-full border px-2.5 text-[12px] transition-colors ${he === Q.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"}`,
27425
27444
  children: [
27426
- U.is_default && /* @__PURE__ */ jsx("span", { title: "Collection default view", className: "text-[#00a5cc]", children: "★" }),
27427
- U.is_shared && !U.is_default && /* @__PURE__ */ jsx("span", { title: "Shared", children: "⚭" }),
27428
- /* @__PURE__ */ jsx("button", { type: "button", onClick: () => yn(U), children: U.name }),
27429
- he === U.id && /* @__PURE__ */ jsxs(Fragment, { children: [
27430
- /* @__PURE__ */ jsx("button", { type: "button", onClick: () => os.mutate(U.id), title: "Update with current state", "aria-label": `Update ${U.name}`, children: "↺" }),
27445
+ Q.is_default && /* @__PURE__ */ jsx("span", { title: "Collection default view", className: "text-[#00a5cc]", children: "★" }),
27446
+ Q.is_shared && !Q.is_default && /* @__PURE__ */ jsx("span", { title: "Shared", children: "⚭" }),
27447
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: () => yn(Q), children: Q.name }),
27448
+ he === Q.id && /* @__PURE__ */ jsxs(Fragment, { children: [
27449
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: () => os.mutate(Q.id), title: "Update with current state", "aria-label": `Update ${Q.name}`, children: "↺" }),
27431
27450
  ht && /* @__PURE__ */ jsx(
27432
27451
  "button",
27433
27452
  {
27434
27453
  type: "button",
27435
- onClick: () => Qn.mutate({ id: U.id, on: !U.is_default }),
27436
- title: U.is_default ? "Unset collection default" : "Make collection default",
27437
- "aria-label": `Toggle default ${U.name}`,
27438
- className: U.is_default ? "text-[#00a5cc]" : "text-slate-400 hover:text-[#00a5cc]",
27454
+ onClick: () => Un.mutate({ id: Q.id, on: !Q.is_default }),
27455
+ title: Q.is_default ? "Unset collection default" : "Make collection default",
27456
+ "aria-label": `Toggle default ${Q.name}`,
27457
+ className: Q.is_default ? "text-[#00a5cc]" : "text-slate-400 hover:text-[#00a5cc]",
27439
27458
  children: "★"
27440
27459
  }
27441
27460
  ),
27442
- /* @__PURE__ */ jsx("button", { type: "button", onClick: () => Zs.mutate(U.id), title: "Delete view", "aria-label": `Delete ${U.name}`, className: "hover:text-red-500", children: "✕" })
27461
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: () => Zs.mutate(Q.id), title: "Delete view", "aria-label": `Delete ${Q.name}`, className: "hover:text-red-500", children: "✕" })
27443
27462
  ] })
27444
27463
  ]
27445
27464
  },
27446
- U.id
27465
+ Q.id
27447
27466
  )),
27448
27467
  qe ? /* @__PURE__ */ jsxs(
27449
27468
  "form",
27450
27469
  {
27451
27470
  className: "flex items-center gap-1",
27452
- onSubmit: (U) => {
27453
- U.preventDefault(), ge.trim() && Us.mutate();
27471
+ onSubmit: (Q) => {
27472
+ Q.preventDefault(), ge.trim() && Qs.mutate();
27454
27473
  },
27455
27474
  children: [
27456
27475
  /* @__PURE__ */ jsx(
@@ -27458,7 +27477,7 @@ function CollectionBrowserView({
27458
27477
  {
27459
27478
  autoFocus: !0,
27460
27479
  value: ge,
27461
- onChange: (U) => He(U.target.value),
27480
+ onChange: (Q) => He(Q.target.value),
27462
27481
  placeholder: "View name…",
27463
27482
  className: "h-6 w-32 rounded border border-slate-200 bg-slate-50 px-1.5 text-[11.5px] outline-none focus:border-[#00ceff80] dark:border-slate-700 dark:bg-slate-800 dark:text-slate-100"
27464
27483
  }
@@ -27485,16 +27504,16 @@ function CollectionBrowserView({
27485
27504
  "data-cbv-scroll": !0,
27486
27505
  className: "min-h-0 flex-1 overflow-y-auto overflow-x-hidden",
27487
27506
  children: et.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "p-0", children: [
27488
- /* @__PURE__ */ jsx("div", { className: "flex h-8 items-center gap-6 border-b border-slate-200 bg-slate-50 px-4 dark:border-slate-700 dark:bg-slate-800", children: [64, 90, 140, 80, 110, 70, 96, 120].map((U, w) => /* @__PURE__ */ jsx("span", { className: "cbv-shimmer h-2.5 rounded", style: { width: U } }, w)) }),
27489
- Array.from({ length: 14 }, (U, w) => /* @__PURE__ */ jsx(
27507
+ /* @__PURE__ */ jsx("div", { className: "flex h-8 items-center gap-6 border-b border-slate-200 bg-slate-50 px-4 dark:border-slate-700 dark:bg-slate-800", children: [64, 90, 140, 80, 110, 70, 96, 120].map((Q, w) => /* @__PURE__ */ jsx("span", { className: "cbv-shimmer h-2.5 rounded", style: { width: Q } }, w)) }),
27508
+ Array.from({ length: 14 }, (Q, w) => /* @__PURE__ */ jsx(
27490
27509
  "div",
27491
27510
  {
27492
27511
  className: "flex h-8 items-center gap-6 border-b border-slate-100 px-4 dark:border-slate-800",
27493
- children: [64, 90, 140, 80, 110, 70, 96, 120].map((Q, se) => /* @__PURE__ */ jsx(
27512
+ children: [64, 90, 140, 80, 110, 70, 96, 120].map((U, se) => /* @__PURE__ */ jsx(
27494
27513
  "span",
27495
27514
  {
27496
27515
  className: "cbv-shimmer h-3 rounded",
27497
- style: { width: Q * (0.6 + (w * 7 + se * 3) % 5 * 0.12) }
27516
+ style: { width: U * (0.6 + (w * 7 + se * 3) % 5 * 0.12) }
27498
27517
  },
27499
27518
  se
27500
27519
  ))
@@ -27512,16 +27531,16 @@ function CollectionBrowserView({
27512
27531
  children: /* @__PURE__ */ jsx("input", { type: "checkbox", checked: vn, onChange: Os, "aria-label": "Select all" })
27513
27532
  }
27514
27533
  ),
27515
- jn.map((U) => {
27516
- const w = U.key, Q = !!Vt(w), se = `group/hcell sticky top-0 h-8 select-none whitespace-nowrap bg-slate-50 px-3 py-0 text-[10px] font-bold uppercase tracking-wider text-slate-500 dark:bg-slate-800 dark:text-slate-400 ${Q ? "z-[4]" : "z-[2]"}`, $e = wn(w, "", "");
27517
- if (U.kind !== "data") {
27518
- const Ft = U.kind === "state" ? "State" : U.kind === "owners" ? "Owners" : "";
27534
+ jn.map((Q) => {
27535
+ const w = Q.key, U = !!Vt(w), se = `group/hcell sticky top-0 h-8 select-none whitespace-nowrap bg-slate-50 px-3 py-0 text-[10px] font-bold uppercase tracking-wider text-slate-500 dark:bg-slate-800 dark:text-slate-400 ${U ? "z-[4]" : "z-[2]"}`, $e = wn(w, "", "");
27536
+ if (Q.kind !== "data") {
27537
+ const Ft = Q.kind === "state" ? "State" : Q.kind === "owners" ? "Owners" : "";
27519
27538
  return /* @__PURE__ */ jsxs(
27520
27539
  "th",
27521
27540
  {
27522
- ref: Q ? Ts(w) : void 0,
27541
+ ref: U ? Ts(w) : void 0,
27523
27542
  style: $s(w),
27524
- className: `${se} text-left ${U.kind === "actions" ? "w-20 px-2" : ""} ${$e}`,
27543
+ className: `${se} text-left ${Q.kind === "actions" ? "w-20 px-2" : ""} ${$e}`,
27525
27544
  children: [
27526
27545
  Ft,
27527
27546
  Hs(w)
@@ -27534,7 +27553,7 @@ function CollectionBrowserView({
27534
27553
  return /* @__PURE__ */ jsxs(
27535
27554
  "th",
27536
27555
  {
27537
- ref: Q ? Ts(w) : void 0,
27556
+ ref: U ? Ts(w) : void 0,
27538
27557
  style: $s(w),
27539
27558
  onClick: () => {
27540
27559
  Ve || Cs(w);
@@ -27553,10 +27572,10 @@ function CollectionBrowserView({
27553
27572
  ] }),
27554
27573
  (gn || Zt) && /* @__PURE__ */ jsxs("tr", { className: "border-b border-slate-200 dark:border-slate-700", children: [
27555
27574
  Xt && /* @__PURE__ */ jsx("th", { className: "sticky left-0 top-8 z-[4] w-9 bg-slate-50 px-3 py-1 dark:bg-slate-800" }),
27556
- jn.map((U) => {
27575
+ jn.map((Q) => {
27557
27576
  var $e;
27558
- const w = U.key, se = `sticky top-8 bg-slate-50 px-2 py-1 text-left font-normal dark:bg-slate-800 ${!!Vt(w) ? "z-[4]" : "z-[2]"} ${wn(w, "", "")}`;
27559
- return U.kind === "state" ? /* @__PURE__ */ jsx("th", { style: $s(w), className: se, children: /* @__PURE__ */ jsx(
27577
+ const w = Q.key, se = `sticky top-8 bg-slate-50 px-2 py-1 text-left font-normal dark:bg-slate-800 ${!!Vt(w) ? "z-[4]" : "z-[2]"} ${wn(w, "", "")}`;
27578
+ return Q.kind === "state" ? /* @__PURE__ */ jsx("th", { style: $s(w), className: se, children: /* @__PURE__ */ jsx(
27560
27579
  MultiPick,
27561
27580
  {
27562
27581
  block: !0,
@@ -27571,18 +27590,18 @@ function CollectionBrowserView({
27571
27590
  Oe.length ? { kind: "state", value: Oe.map(String) } : null
27572
27591
  )
27573
27592
  }
27574
- ) }, w) : U.kind !== "data" ? /* @__PURE__ */ jsx(
27593
+ ) }, w) : Q.kind !== "data" ? /* @__PURE__ */ jsx(
27575
27594
  "th",
27576
27595
  {
27577
27596
  style: $s(w),
27578
- className: `${se} ${U.kind === "actions" ? "w-20" : ""}`
27597
+ className: `${se} ${Q.kind === "actions" ? "w-20" : ""}`
27579
27598
  },
27580
27599
  w
27581
27600
  ) : /* @__PURE__ */ jsx("th", { style: $s(w), className: se, children: zs(w) }, w);
27582
27601
  })
27583
27602
  ] })
27584
27603
  ] }),
27585
- /* @__PURE__ */ jsx("tbody", { className: "text-[12px] tabular-nums", children: bt ? Array.from({ length: 12 }, (U, w) => /* @__PURE__ */ jsx("tr", { className: "border-b border-slate-100 dark:border-slate-800", children: /* @__PURE__ */ jsx("td", { className: "px-3 py-2", colSpan: et.length + Yn, children: /* @__PURE__ */ jsx(
27604
+ /* @__PURE__ */ jsx("tbody", { className: "text-[12px] tabular-nums", children: bt ? Array.from({ length: 12 }, (Q, w) => /* @__PURE__ */ jsx("tr", { className: "border-b border-slate-100 dark:border-slate-800", children: /* @__PURE__ */ jsx("td", { className: "px-3 py-2", colSpan: et.length + Yn, children: /* @__PURE__ */ jsx(
27586
27605
  "span",
27587
27606
  {
27588
27607
  className: "cbv-shimmer block h-3.5 rounded",
@@ -27592,7 +27611,7 @@ function CollectionBrowserView({
27592
27611
  /* @__PURE__ */ jsx("span", { className: "flex h-10 w-10 items-center justify-center rounded-full bg-slate-100 dark:bg-slate-800", children: /* @__PURE__ */ jsx(Search, { "aria-hidden": !0, className: "h-4.5 w-4.5 h-5 w-5 text-slate-400" }) }),
27593
27612
  /* @__PURE__ */ jsx("p", { className: "text-[13.5px] font-medium text-slate-600 dark:text-slate-300", children: "No records match" }),
27594
27613
  /* @__PURE__ */ jsx("p", { className: "text-[12px] text-slate-400", children: "Try adjusting your search or filters." }),
27595
- (F.length > 0 || Object.keys(ce).length > 0 || Object.values(G).some((U) => U.length > 0) || u) && /* @__PURE__ */ jsx(
27614
+ (F.length > 0 || Object.keys(ce).length > 0 || Object.values(G).some((Q) => Q.length > 0) || u) && /* @__PURE__ */ jsx(
27596
27615
  "button",
27597
27616
  {
27598
27617
  type: "button",
@@ -27603,15 +27622,15 @@ function CollectionBrowserView({
27603
27622
  children: "Clear all filters"
27604
27623
  }
27605
27624
  )
27606
- ] }) }) }) : us.map((U) => {
27625
+ ] }) }) }) : us.map((Q) => {
27607
27626
  var dt;
27608
- const w = U.id, Q = ue.includes(w), se = (dt = js == null ? void 0 : js.instances) == null ? void 0 : dt[String(w)], $e = En[String(w)], Oe = !Q && $e ? rowHighlightClass($e.color) : void 0, Ve = Q ? "bg-[#e6fafe] dark:bg-[#0c2a33]" : Oe ?? "bg-white group-hover:bg-[#f2fcff] dark:bg-slate-900 dark:group-hover:bg-[#0e2d3a]";
27627
+ const w = Q.id, U = ue.includes(w), se = (dt = js == null ? void 0 : js.instances) == null ? void 0 : dt[String(w)], $e = En[String(w)], Oe = !U && $e ? rowHighlightClass($e.color) : void 0, Ve = U ? "bg-[#e6fafe] dark:bg-[#0c2a33]" : Oe ?? "bg-white group-hover:bg-[#f2fcff] dark:bg-slate-900 dark:group-hover:bg-[#0e2d3a]";
27609
27628
  return /* @__PURE__ */ jsxs(
27610
27629
  "tr",
27611
27630
  {
27612
27631
  onClick: () => ls(w),
27613
27632
  title: $e ? `At risk — ${$e.rule}` : void 0,
27614
- className: `group h-8 cursor-pointer border-b border-slate-100 transition-colors duration-75 hover:bg-[#00ceff0a] dark:border-slate-800 dark:hover:bg-[#00ceff14] ${Q ? "bg-[#00ceff14]" : Oe ?? ""}`,
27633
+ className: `group h-8 cursor-pointer border-b border-slate-100 transition-colors duration-75 hover:bg-[#00ceff0a] dark:border-slate-800 dark:hover:bg-[#00ceff14] ${U ? "bg-[#00ceff14]" : Oe ?? ""}`,
27615
27634
  children: [
27616
27635
  Xt && /* @__PURE__ */ jsx(
27617
27636
  "td",
@@ -27622,8 +27641,8 @@ function CollectionBrowserView({
27622
27641
  "input",
27623
27642
  {
27624
27643
  type: "checkbox",
27625
- checked: Q,
27626
- onChange: () => Qs(w),
27644
+ checked: U,
27645
+ onChange: () => Us(w),
27627
27646
  "aria-label": `Select ${w}`
27628
27647
  }
27629
27648
  )
@@ -27705,9 +27724,9 @@ function CollectionBrowserView({
27705
27724
  {
27706
27725
  style: $s(We),
27707
27726
  className: `whitespace-nowrap px-3 py-1.5 ${mn(We) ? "text-right" : ""} ${wn(We, "z-[1]", Ve)}`,
27708
- children: gs(We) ? Un(We) === "nivaro_users" ? (() => {
27727
+ children: gs(We) ? Qn(We) === "nivaro_users" ? (() => {
27709
27728
  var lr, Is, ws;
27710
- const ds = We.includes(".") ? We : Re[We], nn = ((ws = (Is = (lr = Ut == null ? void 0 : Ut.rows) == null ? void 0 : lr[String(w)]) == null ? void 0 : Is[ds]) == null ? void 0 : ws.ids) ?? [], On = ts(w, We) ?? "";
27729
+ const ds = We.includes(".") ? We : Re[We], nn = ((ws = (Is = (lr = Qt == null ? void 0 : Qt.rows) == null ? void 0 : lr[String(w)]) == null ? void 0 : Is[ds]) == null ? void 0 : ws.ids) ?? [], On = ts(w, We) ?? "";
27711
27730
  if (nn.length === 0 || !On || On === "—")
27712
27731
  return /* @__PURE__ */ jsx("span", { className: "text-[12px] text-slate-300", children: "—" });
27713
27732
  if (nn.length === 1)
@@ -27741,7 +27760,7 @@ function CollectionBrowserView({
27741
27760
  "data-tip": ts(w, We) ?? void 0,
27742
27761
  children: ts(w, We) != null ? Tn(ts(w, We) ?? "", We) : /* @__PURE__ */ jsx("span", { className: "inline-block h-3.5 w-16 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" })
27743
27762
  }
27744
- ) : (Ft == null ? void 0 : Ft.one_collection) === "nivaro_users" && U[We] != null ? /* @__PURE__ */ jsx("span", { onClick: (ds) => ds.stopPropagation(), children: /* @__PURE__ */ jsx(UserChip, { userId: String(U[We]), size: "compact" }) }) : Ft != null && Ft.one_collection && U[We] != null && !isSystemCol(Ft.one_collection) ? /* @__PURE__ */ jsx(
27763
+ ) : (Ft == null ? void 0 : Ft.one_collection) === "nivaro_users" && Q[We] != null ? /* @__PURE__ */ jsx("span", { onClick: (ds) => ds.stopPropagation(), children: /* @__PURE__ */ jsx(UserChip, { userId: String(Q[We]), size: "compact" }) }) : Ft != null && Ft.one_collection && Q[We] != null && !isSystemCol(Ft.one_collection) ? /* @__PURE__ */ jsx(
27745
27764
  "button",
27746
27765
  {
27747
27766
  type: "button",
@@ -27749,20 +27768,20 @@ function CollectionBrowserView({
27749
27768
  ds.stopPropagation(), le.push([
27750
27769
  {
27751
27770
  collection: Ft.one_collection,
27752
- itemId: String(U[We])
27771
+ itemId: String(Q[We])
27753
27772
  }
27754
27773
  ]);
27755
27774
  },
27756
27775
  className: "text-left text-[12px] font-medium text-slate-700 underline decoration-slate-300 underline-offset-2 transition-colors hover:text-[#0284c7] hover:decoration-[#0284c7] dark:text-slate-200 dark:decoration-slate-600 dark:hover:text-[#38bdf8]",
27757
- children: /* @__PURE__ */ jsx(RelationLabel, { relatedCollection: Ft.one_collection, id: U[We] })
27776
+ children: /* @__PURE__ */ jsx(RelationLabel, { relatedCollection: Ft.one_collection, id: Q[We] })
27758
27777
  }
27759
- ) : g[We] && U[We] != null ? /* @__PURE__ */ jsx("span", { className: "text-[12px] tabular-nums text-slate-700 dark:text-slate-200", children: formatValue$1(String(U[We]), g[We]) }) : /* @__PURE__ */ jsx(
27778
+ ) : g[We] && Q[We] != null ? /* @__PURE__ */ jsx("span", { className: "text-[12px] tabular-nums text-slate-700 dark:text-slate-200", children: formatValue$1(String(Q[We]), g[We]) }) : /* @__PURE__ */ jsx(
27760
27779
  CellValue,
27761
27780
  {
27762
27781
  collection: e,
27763
27782
  field: We,
27764
27783
  fieldType: ((Gt = lt.get(We)) == null ? void 0 : Gt.type) ?? null,
27765
- value: U[We],
27784
+ value: Q[We],
27766
27785
  relations: qt
27767
27786
  }
27768
27787
  )
@@ -27815,7 +27834,7 @@ function CollectionBrowserView({
27815
27834
  {
27816
27835
  type: "button",
27817
27836
  disabled: N <= 1,
27818
- onClick: () => v((U) => Math.max(1, U - 1)),
27837
+ onClick: () => v((Q) => Math.max(1, Q - 1)),
27819
27838
  className: "h-7 rounded px-2.5 text-[12px] text-slate-600 hover:bg-slate-100 disabled:opacity-30 dark:text-slate-300 dark:hover:bg-slate-800",
27820
27839
  children: "← Prev"
27821
27840
  }
@@ -27830,7 +27849,7 @@ function CollectionBrowserView({
27830
27849
  {
27831
27850
  type: "button",
27832
27851
  disabled: N >= un,
27833
- onClick: () => v((U) => U + 1),
27852
+ onClick: () => v((Q) => Q + 1),
27834
27853
  className: "h-7 rounded px-2.5 text-[12px] text-slate-600 hover:bg-slate-100 disabled:opacity-30 dark:text-slate-300 dark:hover:bg-slate-800",
27835
27854
  children: "Next →"
27836
27855
  }
@@ -27856,7 +27875,7 @@ function CollectionBrowserView({
27856
27875
  itemId: J[0].itemId,
27857
27876
  width: "85%",
27858
27877
  stack: J,
27859
- onPush: (U) => le.push([...J, U]),
27878
+ onPush: (Q) => le.push([...J, Q]),
27860
27879
  onPop: () => le.back(),
27861
27880
  onClose: () => le.back(J.length)
27862
27881
  }
@@ -27867,8 +27886,8 @@ function CollectionBrowserView({
27867
27886
  collection: e,
27868
27887
  item: be,
27869
27888
  open: !0,
27870
- onOpenChange: (U) => {
27871
- U || je(null);
27889
+ onOpenChange: (Q) => {
27890
+ Q || je(null);
27872
27891
  }
27873
27892
  }
27874
27893
  ),
@@ -28071,7 +28090,7 @@ function SortableColumnToggle({
28071
28090
  ] });
28072
28091
  }
28073
28092
  function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28074
- var Rn, Hs, Dn, U;
28093
+ var Rn, Hs, Dn, Q;
28075
28094
  const n = useQueryClient(), r = useNivaroClient(), { userId: a } = useItemEditAuth(), l = useItemNavigation(), { navigate: i } = useNavigation(), [o, d] = useState("all"), [c, p] = useState(1), [m, h] = useState("table"), [N, v] = useState(""), [k, x] = useState({}), [u, F] = useState(null), [y, b] = useState(/* @__PURE__ */ new Set()), [f, S] = useState(null), [C, q] = useState(null), [T, j] = useState(0), _ = 25, { data: g, error: M } = useQuery({
28076
28095
  queryKey: ["queue-meta", e],
28077
28096
  queryFn: () => r.request(get$1(`/queues/${e}`)).then((w) => w.data),
@@ -28081,14 +28100,14 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28081
28100
  if (E.current || !P || !g) return;
28082
28101
  E.current = !0;
28083
28102
  const w = (g.extra_field_meta ?? []).filter(
28084
- (Q) => Q.kind === "relation" && Q.target_collection && Q.display_field
28103
+ (U) => U.kind === "relation" && U.target_collection && U.display_field
28085
28104
  );
28086
28105
  if (w.length === 0 || !L) {
28087
28106
  H(!0);
28088
28107
  return;
28089
28108
  }
28090
28109
  (async () => {
28091
- const Q = {}, se = {}, $e = async (Oe, Ve) => {
28110
+ const U = {}, se = {}, $e = async (Oe, Ve) => {
28092
28111
  const dt = await r.request(
28093
28112
  get$1(`/items/${Oe.target_collection}`, {
28094
28113
  filter: JSON.stringify({ id: { _in: Ve } }),
@@ -28115,21 +28134,21 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28115
28134
  const Ct = k[dt];
28116
28135
  if (Ct && (Array.isArray(Ct) ? Ct.length > 0 : Ct !== "")) continue;
28117
28136
  const Ft = We.length ? await $e(Oe, We) : [];
28118
- Ft.length > 0 && (Q[dt] = Ft);
28137
+ Ft.length > 0 && (U[dt] = Ft);
28119
28138
  } catch {
28120
28139
  }
28121
28140
  }
28122
- Object.keys(se).length > 0 && xe(se), Object.keys(Q).length > 0 && (G.current = Q, x((Oe) => ({ ...Oe, ...Q }))), H(!0);
28141
+ Object.keys(se).length > 0 && xe(se), Object.keys(U).length > 0 && (G.current = U, x((Oe) => ({ ...Oe, ...U }))), H(!0);
28123
28142
  })();
28124
28143
  }, [P, L, g]);
28125
28144
  const B = ((Hs = (Rn = g == null ? void 0 : g.sources) == null ? void 0 : Rn.find((w) => w.type === "collection")) == null ? void 0 : Hs.collection) ?? null, ne = useMemo(() => {
28126
- const w = /* @__PURE__ */ new Set(), Q = [];
28145
+ const w = /* @__PURE__ */ new Set(), U = [];
28127
28146
  for (const se of (g == null ? void 0 : g.sources) ?? [])
28128
- se.type !== "collection" || !se.collection || w.has(se.collection) || (w.add(se.collection), Q.push(se.collection));
28129
- return Q;
28130
- }, [g == null ? void 0 : g.sources]), fe = (g == null ? void 0 : g.claims_enabled) !== !1, ee = g == null ? void 0 : g.display_config, z = (ee == null ? void 0 : ee.views) ?? ["table", "kanban", "workload"], re = (ee == null ? void 0 : ee.work_next) !== !1, we = (ee == null ? void 0 : ee.bulk_actions) !== !1, me = (w, Q) => {
28147
+ se.type !== "collection" || !se.collection || w.has(se.collection) || (w.add(se.collection), U.push(se.collection));
28148
+ return U;
28149
+ }, [g == null ? void 0 : g.sources]), fe = (g == null ? void 0 : g.claims_enabled) !== !1, ee = g == null ? void 0 : g.display_config, z = (ee == null ? void 0 : ee.views) ?? ["table", "kanban", "workload"], re = (ee == null ? void 0 : ee.work_next) !== !1, we = (ee == null ? void 0 : ee.bulk_actions) !== !1, me = (w, U) => {
28131
28150
  var se, $e;
28132
- return (($e = (se = g == null ? void 0 : g.column_aliases) == null ? void 0 : se[w]) == null ? void 0 : $e.trim()) || Q;
28151
+ return (($e = (se = g == null ? void 0 : g.column_aliases) == null ? void 0 : se[w]) == null ? void 0 : $e.trim()) || U;
28133
28152
  }, ve = useRef(!1);
28134
28153
  useEffect(() => {
28135
28154
  !g || ve.current || (ve.current = !0, v("-priority"));
@@ -28141,36 +28160,36 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28141
28160
  if (!t || !(g != null && g.sources)) return;
28142
28161
  const w = [
28143
28162
  ...new Set(
28144
- g.sources.filter((Q) => Q.type === "collection" && Q.collection).map((Q) => Q.collection)
28163
+ g.sources.filter((U) => U.type === "collection" && U.collection).map((U) => U.collection)
28145
28164
  )
28146
28165
  ];
28147
28166
  if (w.length !== 0)
28148
- return t.subscribe(w, () => j((Q) => Q + 1));
28167
+ return t.subscribe(w, () => j((U) => U + 1));
28149
28168
  }, [t, g == null ? void 0 : g.sources]);
28150
28169
  const le = useDebounced(k, 350), J = (() => {
28151
28170
  const w = {};
28152
- for (const [Q, se] of Object.entries(le))
28171
+ for (const [U, se] of Object.entries(le))
28153
28172
  if (se) {
28154
28173
  if (Array.isArray(se)) {
28155
- se.length > 0 && (w[Q] = se);
28174
+ se.length > 0 && (w[U] = se);
28156
28175
  continue;
28157
28176
  }
28158
- if (Q === "aging_hours") {
28177
+ if (U === "aging_hours") {
28159
28178
  const [$e, Oe] = se.split(":"), Ve = {};
28160
- $e && (Ve.min = Number($e)), Oe && (Ve.max = Number(Oe)), (Ve.min !== void 0 || Ve.max !== void 0) && (w[Q] = Ve);
28179
+ $e && (Ve.min = Number($e)), Oe && (Ve.max = Number(Oe)), (Ve.min !== void 0 || Ve.max !== void 0) && (w[U] = Ve);
28161
28180
  continue;
28162
28181
  }
28163
- w[Q] = se;
28182
+ w[U] = se;
28164
28183
  }
28165
28184
  return w;
28166
28185
  })();
28167
- function be(w, Q) {
28168
- x((se) => ({ ...se, [w]: se[w] === Q ? "" : Q })), p(1);
28186
+ function be(w, U) {
28187
+ x((se) => ({ ...se, [w]: se[w] === U ? "" : U })), p(1);
28169
28188
  }
28170
28189
  function je(w) {
28171
- x((Q) => {
28172
- const se = Q.state, $e = Array.isArray(se) ? se : se ? [se] : [], Oe = $e.includes(w) ? $e.filter((Ve) => Ve !== w) : [...$e, w];
28173
- return { ...Q, state: Oe };
28190
+ x((U) => {
28191
+ const se = U.state, $e = Array.isArray(se) ? se : se ? [se] : [], Oe = $e.includes(w) ? $e.filter((Ve) => Ve !== w) : [...$e, w];
28192
+ return { ...U, state: Oe };
28174
28193
  }), p(1);
28175
28194
  }
28176
28195
  const Ne = Array.isArray(k.state) ? k.state : k.state ? [k.state] : [], Y = (w) => !w || Array.isArray(w) && w.length === 0;
@@ -28217,11 +28236,11 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28217
28236
  // swapping to skeletons collapsed the table height and jittered the page.
28218
28237
  placeholderData: (w) => w
28219
28238
  }), mt = Pe && !qe || !ce || !D && !qe, yt = ge && !Pe || He && ge;
28220
- async function jt(w, Q) {
28239
+ async function jt(w, U) {
28221
28240
  const $e = (await r.request(get$1(`/pipelines/instance/${w.collection}/${w.item_id}`))).data;
28222
28241
  if (!$e || $e.states.length === 0)
28223
28242
  throw new Error("This item has no workflow instance");
28224
- const Oe = $e.states.find((dt) => dt.key === Q);
28243
+ const Oe = $e.states.find((dt) => dt.key === U);
28225
28244
  if (!Oe) throw new Error("Target state not found");
28226
28245
  const Ve = $e.available_transitions.find(
28227
28246
  (dt) => dt.to_state === Oe.id
@@ -28234,8 +28253,8 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28234
28253
  );
28235
28254
  }
28236
28255
  const Tt = useMutation({
28237
- mutationFn: async ({ item: w, targetState: Q }) => {
28238
- await jt(w, Q);
28256
+ mutationFn: async ({ item: w, targetState: U }) => {
28257
+ await jt(w, U);
28239
28258
  },
28240
28259
  onSuccess: () => {
28241
28260
  n.invalidateQueries({ queryKey: ["queue-items", e, o] });
@@ -28309,51 +28328,51 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28309
28328
  queryKey: ["queue-collection-states", w],
28310
28329
  queryFn: () => r.request(
28311
28330
  get$1(`/queues/collection-states/${w}`)
28312
- ).then((Q) => Q.data),
28331
+ ).then((U) => U.data),
28313
28332
  staleTime: 300 * 1e3
28314
28333
  }))
28315
- }), is = (w) => w.replace(/_/g, " ").replace(/\b\w/g, (Q) => Q.toUpperCase()), Vt = useMemo(() => {
28334
+ }), is = (w) => w.replace(/_/g, " ").replace(/\b\w/g, (U) => U.toUpperCase()), Vt = useMemo(() => {
28316
28335
  const w = {};
28317
- for (const Q of ss)
28318
- (Q.data ?? []).forEach((se, $e) => {
28336
+ for (const U of ss)
28337
+ (U.data ?? []).forEach((se, $e) => {
28319
28338
  w[se.key] = { label: se.label, color: se.color, sort: $e };
28320
28339
  });
28321
28340
  return w;
28322
28341
  }, [ss.map((w) => w.data)]), _s = $t ? Object.entries($t.by_state).sort(
28323
- (w, Q) => {
28342
+ (w, U) => {
28324
28343
  var se, $e;
28325
- return (((se = Vt[w[0]]) == null ? void 0 : se.sort) ?? Number.MAX_SAFE_INTEGER) - ((($e = Vt[Q[0]]) == null ? void 0 : $e.sort) ?? Number.MAX_SAFE_INTEGER);
28344
+ return (((se = Vt[w[0]]) == null ? void 0 : se.sort) ?? Number.MAX_SAFE_INTEGER) - ((($e = Vt[U[0]]) == null ? void 0 : $e.sort) ?? Number.MAX_SAFE_INTEGER);
28326
28345
  }
28327
28346
  ) : [], Ms = useMemo(() => {
28328
28347
  const w = {};
28329
- for (const [Q, se] of Object.entries(Vt)) w[Q] = se.label;
28348
+ for (const [U, se] of Object.entries(Vt)) w[U] = se.label;
28330
28349
  return w;
28331
28350
  }, [Vt]), Bt = (w) => w ? w === "none" ? "No State" : Ms[w] ?? is(w) : "—", te = (w) => {
28332
- const Q = (Jt ?? []).find((se) => se.collection === w);
28333
- return (Q == null ? void 0 : Q.display_name) || (Q == null ? void 0 : Q.plural) || is(w);
28351
+ const U = (Jt ?? []).find((se) => se.collection === w);
28352
+ return (U == null ? void 0 : U.display_name) || (U == null ? void 0 : U.plural) || is(w);
28334
28353
  }, ke = useMemo(() => u ? buildGroups(Ht, u) : null, [Ht, u]);
28335
28354
  useEffect(() => {
28336
28355
  !u || !ke || b(Ht.length > 200 ? new Set(ke.map((w) => w.key)) : /* @__PURE__ */ new Set());
28337
28356
  }, [u]);
28338
28357
  function Se(w) {
28339
- b((Q) => {
28340
- const se = new Set(Q);
28358
+ b((U) => {
28359
+ const se = new Set(U);
28341
28360
  return se.has(w) ? se.delete(w) : se.add(w), se;
28342
28361
  });
28343
28362
  }
28344
- const Le = useMemo(() => ke ? ke.filter((w) => !y.has(w.key)).flatMap((w) => w.rows) : Ht, [ke, Ht, y]), Qe = (w) => `${w.collection}:${w.item_id}`, [Ye, Re] = useState(null), [wt, Rt] = useState(!1), [vt, Kt] = useState(null), xt = (w) => l.open({
28363
+ const Le = useMemo(() => ke ? ke.filter((w) => !y.has(w.key)).flatMap((w) => w.rows) : Ht, [ke, Ht, y]), Ue = (w) => `${w.collection}:${w.item_id}`, [Ye, Re] = useState(null), [wt, Rt] = useState(!1), [vt, Kt] = useState(null), xt = (w) => l.open({
28345
28364
  collection: w.collection,
28346
28365
  itemId: w.item_id,
28347
28366
  layoutSlug: (ee == null ? void 0 : ee.item_layout) ?? null
28348
28367
  }), bt = (w) => {
28349
- Kt(Qe(w));
28350
- const Q = (ee == null ? void 0 : ee.row_click) ?? "preview";
28351
- if (Q === "full") {
28368
+ Kt(Ue(w));
28369
+ const U = (ee == null ? void 0 : ee.row_click) ?? "preview";
28370
+ if (U === "full") {
28352
28371
  xt(w);
28353
28372
  return;
28354
28373
  }
28355
- if (Q === "layout") {
28356
- Qn({
28374
+ if (U === "layout") {
28375
+ Un({
28357
28376
  collection: w.collection,
28358
28377
  itemId: w.item_id,
28359
28378
  rootLayoutSlug: (ee == null ? void 0 : ee.item_layout) ?? null,
@@ -28366,17 +28385,17 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28366
28385
  };
28367
28386
  useEffect(() => {
28368
28387
  if (!Ye) return;
28369
- const w = Ht.find((Q) => Qe(Q) === Qe(Ye));
28388
+ const w = Ht.find((U) => Ue(U) === Ue(Ye));
28370
28389
  w && w !== Ye && Re(w);
28371
28390
  }, [Ht]);
28372
28391
  const St = (w) => !w.claimed_by || w.claimed_by.id === a;
28373
28392
  function bs(w) {
28374
- const Q = w ? Le.findIndex(($e) => Qe($e) === Qe(w)) + 1 : 0, se = Le.slice(Q).find(St);
28393
+ const U = w ? Le.findIndex(($e) => Ue($e) === Ue(w)) + 1 : 0, se = Le.slice(U).find(St);
28375
28394
  if (!se) {
28376
28395
  Rt(!1), Re(null), toast.info("Nothing left to work on — queue clear!");
28377
28396
  return;
28378
28397
  }
28379
- if (Kt(Qe(se)), fe && !se.claimed_by && ot.mutate(se), (ee == null ? void 0 : ee.row_click) === "full") {
28398
+ if (Kt(Ue(se)), fe && !se.claimed_by && ot.mutate(se), (ee == null ? void 0 : ee.row_click) === "full") {
28380
28399
  xt(se);
28381
28400
  return;
28382
28401
  }
@@ -28384,27 +28403,27 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28384
28403
  }
28385
28404
  useEffect(() => {
28386
28405
  if (m !== "table") return;
28387
- function w(Q) {
28406
+ function w(U) {
28388
28407
  var Oe;
28389
- const se = Q.target;
28408
+ const se = U.target;
28390
28409
  if (se && (se.tagName === "INPUT" || se.tagName === "TEXTAREA" || se.tagName === "SELECT" || se.isContentEditable))
28391
28410
  return;
28392
- const $e = vt ? Le.findIndex((Ve) => Qe(Ve) === vt) : -1;
28393
- if (Q.key === "j" || Q.key === "ArrowDown") {
28394
- Q.preventDefault();
28411
+ const $e = vt ? Le.findIndex((Ve) => Ue(Ve) === vt) : -1;
28412
+ if (U.key === "j" || U.key === "ArrowDown") {
28413
+ U.preventDefault();
28395
28414
  const Ve = Le[Math.min($e + 1, Le.length - 1)];
28396
- Ve && Kt(Qe(Ve));
28397
- } else if (Q.key === "k" || Q.key === "ArrowUp") {
28398
- Q.preventDefault();
28415
+ Ve && Kt(Ue(Ve));
28416
+ } else if (U.key === "k" || U.key === "ArrowUp") {
28417
+ U.preventDefault();
28399
28418
  const Ve = Le[Math.max($e - 1, 0)];
28400
- Ve && Kt(Qe(Ve));
28401
- } else if (Q.key === "Enter" && $e >= 0 && !Ye)
28402
- Q.preventDefault(), bt(Le[$e]);
28403
- else if (Q.key === "c" && $e >= 0 && fe) {
28404
- Q.preventDefault();
28419
+ Ve && Kt(Ue(Ve));
28420
+ } else if (U.key === "Enter" && $e >= 0 && !Ye)
28421
+ U.preventDefault(), bt(Le[$e]);
28422
+ else if (U.key === "c" && $e >= 0 && fe) {
28423
+ U.preventDefault();
28405
28424
  const Ve = Le[$e];
28406
28425
  ((Oe = Ve.claimed_by) == null ? void 0 : Oe.id) === a ? ht.mutate(Ve) : ot.mutate(Ve);
28407
- } else Q.key === "o" && $e >= 0 && (Q.preventDefault(), xt(Le[$e]));
28426
+ } else U.key === "o" && $e >= 0 && (U.preventDefault(), xt(Le[$e]));
28408
28427
  }
28409
28428
  return window.addEventListener("keydown", w), () => window.removeEventListener("keydown", w);
28410
28429
  }, [m, Le, vt, Ye, a, ot, ht, fe]);
@@ -28414,30 +28433,30 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28414
28433
  enabled: !!e
28415
28434
  }), [us, es] = useState(null), [un, ln] = useState(!1), [Ln, En] = useState(""), [rs, js] = useState(!1), [Ls, ks] = useState(!1);
28416
28435
  function An(w) {
28417
- const Q = w.state ?? {};
28418
- d(Q.scope ?? "all"), x({ ...G.current, ...Q.filters ?? {} }), v(Q.sort ?? ""), F(Q.group_by ?? null), _t(Q.columns ?? null), q(Q.pins ?? null), Q.view && h(z.includes(Q.view) ? Q.view : z[0]), p(1), es(w.id);
28436
+ const U = w.state ?? {};
28437
+ d(U.scope ?? "all"), x({ ...G.current, ...U.filters ?? {} }), v(U.sort ?? ""), F(U.group_by ?? null), _t(U.columns ?? null), q(U.pins ?? null), U.view && h(z.includes(U.view) ? U.view : z[0]), p(1), es(w.id);
28419
28438
  }
28420
28439
  function Bs() {
28421
- var Q, se;
28440
+ var U, se;
28422
28441
  const w = tt == null ? void 0 : tt.data.find(($e) => $e.is_default);
28423
28442
  if (w) {
28424
28443
  An(w);
28425
28444
  return;
28426
28445
  }
28427
- d(((Q = g == null ? void 0 : g.display_config) == null ? void 0 : Q.default_scope) ?? "all"), x({ ...G.current }), v(""), F(null), _t(null), q(null), (se = g == null ? void 0 : g.display_config) != null && se.default_view && h(g.display_config.default_view), p(1), es(null);
28446
+ d(((U = g == null ? void 0 : g.display_config) == null ? void 0 : U.default_scope) ?? "all"), x({ ...G.current }), v(""), F(null), _t(null), q(null), (se = g == null ? void 0 : g.display_config) != null && se.default_view && h(g.display_config.default_view), p(1), es(null);
28428
28447
  }
28429
28448
  useEffect(() => {
28430
28449
  if (ce || !(g != null && g.display_config) || Pt === void 0 || tt === void 0) return;
28431
- const w = Pt.data.default_view_id, Q = w != null ? tt.data.find(($e) => $e.id === w) : void 0, se = tt.data.find(($e) => $e.is_default);
28432
- Q ? An(Q) : se ? An(se) : (h(g.display_config.default_view), d(g.display_config.default_scope)), I(!0);
28450
+ const w = Pt.data.default_view_id, U = w != null ? tt.data.find(($e) => $e.id === w) : void 0, se = tt.data.find(($e) => $e.is_default);
28451
+ U ? An(U) : se ? An(se) : (h(g.display_config.default_view), d(g.display_config.default_scope)), I(!0);
28433
28452
  }, [g, Pt, tt, ce]);
28434
28453
  const { isAdmin: $n } = useItemEditAuth(), Ss = $n || (g == null ? void 0 : g.owner) != null && g.owner === a, ms = useMutation({
28435
- mutationFn: ({ viewId: w, on: Q }) => r.request(patch$1(`/queues/views/${w}`, { is_default: Q })),
28454
+ mutationFn: ({ viewId: w, on: U }) => r.request(patch$1(`/queues/views/${w}`, { is_default: U })),
28436
28455
  onSuccess: () => {
28437
28456
  n.invalidateQueries({ queryKey: ["queue-views", e] }), toast.success("Queue default view updated");
28438
28457
  },
28439
28458
  onError: () => toast.error("Could not update the queue default view")
28440
- }), Ut = useMutation({
28459
+ }), Qt = useMutation({
28441
28460
  mutationFn: () => r.request(
28442
28461
  post$1(`/queues/${e}/views`, {
28443
28462
  name: Ln.trim(),
@@ -28476,34 +28495,34 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28476
28495
  n.invalidateQueries({ queryKey: ["queue-views", e] }), toast.success("View updated");
28477
28496
  },
28478
28497
  onError: () => toast.error("Failed to update view")
28479
- }), Un = useMutation({
28498
+ }), Qn = useMutation({
28480
28499
  mutationFn: (w) => r.request(del$1(`/queues/views/${w}`)),
28481
- onSuccess: (w, Q) => {
28482
- n.invalidateQueries({ queryKey: ["queue-views", e] }), es(null), It === Q && Xt(null);
28500
+ onSuccess: (w, U) => {
28501
+ n.invalidateQueries({ queryKey: ["queue-views", e] }), es(null), It === U && Xt(null);
28483
28502
  },
28484
28503
  onError: () => toast.error("Failed to delete view")
28485
28504
  }), Gn = useMutation({
28486
28505
  mutationFn: (w) => r.request(put(`/queues/${e}/default-view`, { view_id: w })),
28487
28506
  onMutate: (w) => Xt(w),
28488
- onSuccess: (w, Q) => {
28507
+ onSuccess: (w, U) => {
28489
28508
  n.invalidateQueries({ queryKey: ["queue-column-prefs", e] }), toast.success(
28490
- Q === null ? "Reverted to the general default" : "Set as your default view"
28509
+ U === null ? "Reverted to the general default" : "Set as your default view"
28491
28510
  );
28492
28511
  },
28493
28512
  onError: () => {
28494
28513
  n.invalidateQueries({ queryKey: ["queue-column-prefs", e] }), toast.error("Failed to update default view");
28495
28514
  }
28496
28515
  }), [gs, Ks] = useState([]), [as, zs] = useState(!1);
28497
- async function gn(w, Q) {
28498
- const se = Ht.filter((dt) => gs.includes(Qe(dt)));
28516
+ async function gn(w, U) {
28517
+ const se = Ht.filter((dt) => gs.includes(Ue(dt)));
28499
28518
  zs(!0);
28500
- const $e = await Promise.allSettled(se.map(Q)), Oe = $e.filter((dt) => dt.status === "fulfilled").length, Ve = $e.length - Oe;
28519
+ const $e = await Promise.allSettled(se.map(U)), Oe = $e.filter((dt) => dt.status === "fulfilled").length, Ve = $e.length - Oe;
28501
28520
  zs(!1), Ks([]), n.invalidateQueries({ queryKey: ["queue-items", e] }), Ve ? toast.warning(`${w}: ${Oe} succeeded, ${Ve} failed`) : toast.success(`${w}: ${Oe} succeeded`);
28502
28521
  }
28503
28522
  const mn = (w) => {
28504
- var Q;
28523
+ var U;
28505
28524
  for (const se of (g == null ? void 0 : g.sources) ?? []) {
28506
- const $e = (Q = se.column_formats) == null ? void 0 : Q[w];
28525
+ const $e = (U = se.column_formats) == null ? void 0 : U[w];
28507
28526
  if ($e) return $e;
28508
28527
  }
28509
28528
  return null;
@@ -28511,8 +28530,8 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28511
28530
  if (u === "state") return w === "No state" ? w : Bt(w);
28512
28531
  if (u === "collection") return te(w);
28513
28532
  if (u != null && u.startsWith("extra.") && w !== "—") {
28514
- const Q = mn(u.slice(6));
28515
- if (Q) return formatMultiValue(w, Q);
28533
+ const U = mn(u.slice(6));
28534
+ if (U) return formatMultiValue(w, U);
28516
28535
  }
28517
28536
  return w;
28518
28537
  }, Es = ke == null ? void 0 : ke.map((w) => ({
@@ -28609,8 +28628,8 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28609
28628
  "button",
28610
28629
  {
28611
28630
  type: "button",
28612
- onClick: (Q) => {
28613
- Q.stopPropagation(), ht.mutate(w);
28631
+ onClick: (U) => {
28632
+ U.stopPropagation(), ht.mutate(w);
28614
28633
  },
28615
28634
  className: "text-[11px] text-slate-400 underline hover:text-slate-600",
28616
28635
  children: "Release"
@@ -28619,17 +28638,17 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28619
28638
  "button",
28620
28639
  {
28621
28640
  type: "button",
28622
- onClick: (Q) => {
28623
- Q.stopPropagation(), ot.mutate(w);
28641
+ onClick: (U) => {
28642
+ U.stopPropagation(), ot.mutate(w);
28624
28643
  },
28625
28644
  className: "text-[11px] font-medium text-nvr-navy underline dark:text-nvr-cyan",
28626
28645
  children: "Claim"
28627
28646
  }
28628
28647
  )
28629
- }, Ds = (g == null ? void 0 : g.available_extra_fields) ?? [], Us = useOverlayState("drill.queue"), os = Us.value, Qn = (w) => Us.push([w]), Wn = (w) => {
28630
- var Q;
28648
+ }, Ds = (g == null ? void 0 : g.available_extra_fields) ?? [], Qs = useOverlayState("drill.queue"), os = Qs.value, Un = (w) => Qs.push([w]), Wn = (w) => {
28649
+ var U;
28631
28650
  for (const se of (g == null ? void 0 : g.sources) ?? []) {
28632
- const $e = (Q = se.drilldown) == null ? void 0 : Q[w];
28651
+ const $e = (U = se.drilldown) == null ? void 0 : U[w];
28633
28652
  if ($e)
28634
28653
  return {
28635
28654
  enabled: $e.enabled !== !1,
@@ -28640,19 +28659,19 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28640
28659
  return { enabled: !0, layout_id: null, width: null };
28641
28660
  }, Xs = useMemo(() => {
28642
28661
  const w = {};
28643
- for (const Q of (g == null ? void 0 : g.sources) ?? [])
28644
- for (const [se, $e] of Object.entries(Q.column_formats ?? {}))
28662
+ for (const U of (g == null ? void 0 : g.sources) ?? [])
28663
+ for (const [se, $e] of Object.entries(U.column_formats ?? {}))
28645
28664
  se in w || (w[se] = $e);
28646
28665
  return w;
28647
28666
  }, [g == null ? void 0 : g.sources]), Zs = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, Vn = /^\d{4}-\d{2}-\d{2}T\d{2}:/;
28648
28667
  function ls(w) {
28649
28668
  if (Zs.test(w)) return { text: w.split("@")[0], title: w };
28650
28669
  if (Vn.test(w)) {
28651
- const Q = new Date(w);
28652
- if (!Number.isNaN(Q.getTime()))
28670
+ const U = new Date(w);
28671
+ if (!Number.isNaN(U.getTime()))
28653
28672
  return {
28654
- text: formatDate(Q, { month: "2-digit", day: "2-digit", year: "2-digit" }),
28655
- title: formatDateTime(Q)
28673
+ text: formatDate(U, { month: "2-digit", day: "2-digit", year: "2-digit" }),
28674
+ title: formatDateTime(U)
28656
28675
  };
28657
28676
  }
28658
28677
  return { text: w, title: w };
@@ -28661,17 +28680,17 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28661
28680
  key: `extra.${w}`,
28662
28681
  header: me(`extra.${w}`, formatColumnHeader(w)),
28663
28682
  sortable: !0,
28664
- render: (Q) => {
28683
+ render: (U) => {
28665
28684
  var Ft, Gt;
28666
- const se = (Ft = Q.extra) == null ? void 0 : Ft[w];
28685
+ const se = (Ft = U.extra) == null ? void 0 : Ft[w];
28667
28686
  if (se == null || se === "") return /* @__PURE__ */ jsx("span", { className: "text-slate-300", children: "—" });
28668
- const $e = mn(w), Oe = $e ? formatMultiValue(String(se), $e) : String(se), { text: Ve, title: dt } = ls(Oe), Nt = ((g == null ? void 0 : g.extra_field_meta) ?? []).find((ds) => ds.path === w), We = ((Gt = Q.extra_ids) == null ? void 0 : Gt[w]) ?? [], Ct = Wn(w);
28687
+ const $e = mn(w), Oe = $e ? formatMultiValue(String(se), $e) : String(se), { text: Ve, title: dt } = ls(Oe), Nt = ((g == null ? void 0 : g.extra_field_meta) ?? []).find((ds) => ds.path === w), We = ((Gt = U.extra_ids) == null ? void 0 : Gt[w]) ?? [], Ct = Wn(w);
28669
28688
  return (Nt == null ? void 0 : Nt.kind) === "relation" && Nt.target_collection && We.length > 0 && Ct.enabled && !Nt.aggregate ? /* @__PURE__ */ jsx(
28670
28689
  "button",
28671
28690
  {
28672
28691
  type: "button",
28673
28692
  onClick: (ds) => {
28674
- ds.stopPropagation(), Qn({
28693
+ ds.stopPropagation(), Un({
28675
28694
  collection: Nt.target_collection,
28676
28695
  itemId: We[0],
28677
28696
  layoutId: Ct.layout_id,
@@ -28701,14 +28720,14 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28701
28720
  "sla_status",
28702
28721
  "at_risk",
28703
28722
  ...Ds.slice(0, 2).map((w) => `extra.${w}`)
28704
- ], Qs = (ee == null ? void 0 : ee.default_columns) ?? null, ps = st ?? Qs, en = new Set(ps ?? Os), Zt = [
28723
+ ], Us = (ee == null ? void 0 : ee.default_columns) ?? null, ps = st ?? Us, en = new Set(ps ?? Os), Zt = [
28705
28724
  ...(ps ?? []).filter((w) => vn.includes(w)),
28706
28725
  ...vn.filter((w) => !(ps ?? []).includes(w))
28707
28726
  ], Yn = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 4 } }));
28708
28727
  function qn(w) {
28709
- const { active: Q, over: se } = w;
28710
- if (!se || Q.id === se.id) return;
28711
- const $e = Zt.indexOf(String(Q.id)), Oe = Zt.indexOf(String(se.id));
28728
+ const { active: U, over: se } = w;
28729
+ if (!se || U.id === se.id) return;
28730
+ const $e = Zt.indexOf(String(U.id)), Oe = Zt.indexOf(String(se.id));
28712
28731
  $e === -1 || Oe === -1 || _t(
28713
28732
  arrayMove(Zt, $e, Oe).filter((Ve) => en.has(Ve))
28714
28733
  );
@@ -28716,7 +28735,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28716
28735
  const jn = yn.find((w) => w.key === "label"), tn = [...yn, ...Cs], pn = {
28717
28736
  key: "__actions__",
28718
28737
  header: "",
28719
- render: (w) => w.collection === "tasks" ? null : /* @__PURE__ */ jsx("span", { onClick: (Q) => Q.stopPropagation(), children: /* @__PURE__ */ jsx(
28738
+ render: (w) => w.collection === "tasks" ? null : /* @__PURE__ */ jsx("span", { onClick: (U) => U.stopPropagation(), children: /* @__PURE__ */ jsx(
28720
28739
  RowActionsMenu,
28721
28740
  {
28722
28741
  collection: w.collection,
@@ -28729,7 +28748,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28729
28748
  r.request(del$1(`/items/${w.collection}/${w.item_id}`)).then(() => {
28730
28749
  toast.success("Moved to trash"), n.invalidateQueries({ queryKey: ["queue-items", e] });
28731
28750
  }).catch(
28732
- (Q) => toast.error(Q instanceof Error ? Q.message : "Delete failed")
28751
+ (U) => toast.error(U instanceof Error ? U.message : "Delete failed")
28733
28752
  );
28734
28753
  },
28735
28754
  onAfterTransition: () => void n.invalidateQueries({ queryKey: ["queue-items", e] })
@@ -28737,13 +28756,13 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28737
28756
  ) })
28738
28757
  }, xn = [
28739
28758
  jn,
28740
- ...Zt.filter((w) => en.has(w)).map((w) => tn.find((Q) => Q.key === w)).filter((w) => w !== void 0),
28759
+ ...Zt.filter((w) => en.has(w)).map((w) => tn.find((U) => U.key === w)).filter((w) => w !== void 0),
28741
28760
  ...fe ? [on] : [],
28742
28761
  pn
28743
28762
  ], sn = useMemo(() => {
28744
28763
  var $e;
28745
- const w = ee == null ? void 0 : ee.default_pins, Q = C ?? (w && Object.keys(w).length > 0 ? w : { [(($e = xn[0]) == null ? void 0 : $e.key) ?? "label"]: "left" }), se = new Set(xn.map((Oe) => Oe.key));
28746
- return Object.fromEntries(Object.entries(Q).filter(([Oe]) => se.has(Oe)));
28764
+ const w = ee == null ? void 0 : ee.default_pins, U = C ?? (w && Object.keys(w).length > 0 ? w : { [(($e = xn[0]) == null ? void 0 : $e.key) ?? "label"]: "left" }), se = new Set(xn.map((Oe) => Oe.key));
28765
+ return Object.fromEntries(Object.entries(U).filter(([Oe]) => se.has(Oe)));
28747
28766
  }, [C, ee == null ? void 0 : ee.default_pins, xn.map((w) => w.key).join("|")]), kn = [
28748
28767
  { value: "state", label: "State" },
28749
28768
  { value: "collection", label: "Collection" },
@@ -28752,13 +28771,13 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28752
28771
  { value: "owners", label: "Owner" },
28753
28772
  { value: "aging", label: "Aging" },
28754
28773
  ...Ds.filter((w) => en.has(`extra.${w}`)).map((w) => ({ value: `extra.${w}`, label: me(`extra.${w}`, formatColumnHeader(w)) }))
28755
- ], Ps = (w) => async (Q) => {
28774
+ ], Ps = (w) => async (U) => {
28756
28775
  if (!w.target_collection || !w.display_field) return [];
28757
28776
  const se = {
28758
28777
  limit: 25,
28759
28778
  sort: w.display_field
28760
28779
  };
28761
- Q.trim() && (se.filter = JSON.stringify({ [w.display_field]: { _contains: Q.trim() } }));
28780
+ U.trim() && (se.filter = JSON.stringify({ [w.display_field]: { _contains: U.trim() } }));
28762
28781
  const Oe = (await r.request(
28763
28782
  get$1(`/items/${w.target_collection}`, se)
28764
28783
  )).data ?? [], Ve = mn(w.path), dt = K[w.path] ? new Set(K[w.path]) : null, Nt = /* @__PURE__ */ new Set(), We = [];
@@ -28769,15 +28788,15 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28769
28788
  Nt.has(Gt) || dt && !dt.has(Gt) || (Nt.add(Gt), We.push({ label: Ve ? formatMultiValue(Gt, Ve) : Gt, value: Gt }));
28770
28789
  }
28771
28790
  return We;
28772
- }, dn = new Map(((g == null ? void 0 : g.extra_field_meta) ?? []).map((w) => [w.path, w])), wn = (w, Q) => {
28791
+ }, dn = new Map(((g == null ? void 0 : g.extra_field_meta) ?? []).map((w) => [w.path, w])), wn = (w, U) => {
28773
28792
  if (w.key.startsWith("extra.")) {
28774
28793
  const se = mn(w.key.slice(6));
28775
28794
  if (se) {
28776
- const Oe = (Array.isArray(Q) ? Q : [Q]).filter((Ve) => Ve !== "").map((Ve) => formatMultiValue(String(Ve), se));
28795
+ const Oe = (Array.isArray(U) ? U : [U]).filter((Ve) => Ve !== "").map((Ve) => formatMultiValue(String(Ve), se));
28777
28796
  return Oe.slice(0, 2).join(", ") + (Oe.length > 2 ? ` +${Oe.length - 2}` : "");
28778
28797
  }
28779
28798
  }
28780
- return filterValueDisplay(w, Q);
28799
+ return filterValueDisplay(w, U);
28781
28800
  }, $s = [
28782
28801
  {
28783
28802
  key: "collection",
@@ -28840,14 +28859,14 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28840
28859
  },
28841
28860
  ...Ds.map((w) => {
28842
28861
  var se;
28843
- const Q = dn.get(w);
28844
- return (Q == null ? void 0 : Q.kind) === "relation" ? {
28862
+ const U = dn.get(w);
28863
+ return (U == null ? void 0 : U.kind) === "relation" ? {
28845
28864
  key: `extra.${w}`,
28846
28865
  placeholder: me(`extra.${w}`, formatColumnHeader(w)),
28847
28866
  type: "combobox",
28848
28867
  multi: !0,
28849
28868
  restricted: !!((se = K[w]) != null && se.length),
28850
- loadOptions: Ps(Q)
28869
+ loadOptions: Ps(U)
28851
28870
  } : {
28852
28871
  key: `extra.${w}`,
28853
28872
  placeholder: `Search ${me(`extra.${w}`, formatColumnHeader(w))}…`,
@@ -28856,8 +28875,8 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28856
28875
  })
28857
28876
  ].filter((w) => en.has(w.key) || w.key === "label" || w.key === "owners");
28858
28877
  function Ts(w) {
28859
- const Q = new Set(en);
28860
- Q.has(w) ? Q.delete(w) : Q.add(w), _t([...Q]);
28878
+ const U = new Set(en);
28879
+ U.has(w) ? U.delete(w) : U.add(w), _t([...U]);
28861
28880
  }
28862
28881
  return M ? (s == null ? void 0 : s((M == null ? void 0 : M.status) ?? 500)) ?? null : /* @__PURE__ */ jsxs("div", { className: "flex flex-1 min-h-0 flex-col", children: [
28863
28882
  /* @__PURE__ */ jsxs("div", { className: "shrink-0 px-6 pt-6", children: [
@@ -28948,13 +28967,13 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28948
28967
  }
28949
28968
  )
28950
28969
  ] }),
28951
- _s.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex min-w-0 flex-wrap items-center gap-1.5", children: _s.map(([w, Q]) => {
28970
+ _s.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex min-w-0 flex-wrap items-center gap-1.5", children: _s.map(([w, U]) => {
28952
28971
  var se;
28953
28972
  return /* @__PURE__ */ jsx(
28954
28973
  StateChip,
28955
28974
  {
28956
28975
  label: Bt(w),
28957
- count: Q,
28976
+ count: U,
28958
28977
  filteredCount: ie ? ie.by_state[w] ?? 0 : null,
28959
28978
  color: ((se = Vt[w]) == null ? void 0 : se.color) ?? null,
28960
28979
  active: Ne.includes(w),
@@ -28966,7 +28985,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28966
28985
  ] }),
28967
28986
  /* @__PURE__ */ jsxs("div", { className: "mb-4 flex flex-wrap items-center gap-2", children: [
28968
28987
  ce ? /* @__PURE__ */ jsx("div", { className: "flex overflow-hidden rounded-md border border-slate-200 dark:border-border", children: SCOPE_TABS.filter((w) => fe || w.value !== "claimed").map(
28969
- (w, Q) => /* @__PURE__ */ jsx(
28988
+ (w, U) => /* @__PURE__ */ jsx(
28970
28989
  "button",
28971
28990
  {
28972
28991
  type: "button",
@@ -28975,7 +28994,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28975
28994
  },
28976
28995
  className: cn$1(
28977
28996
  "px-3 py-1.5 text-[12px] font-medium transition-colors",
28978
- Q > 0 && "border-l border-slate-200 dark:border-border",
28997
+ U > 0 && "border-l border-slate-200 dark:border-border",
28979
28998
  o === w.value ? "bg-nvr-cyan/10 text-nvr-navy dark:text-nvr-cyan" : "bg-white text-slate-500 hover:text-slate-700 dark:bg-card dark:hover:text-foreground"
28980
28999
  ),
28981
29000
  children: w.label
@@ -29004,14 +29023,14 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29004
29023
  { value: "table", label: "Table" },
29005
29024
  { value: "kanban", label: "Kanban" },
29006
29025
  { value: "workload", label: "Workload" }
29007
- ].filter((w) => z.includes(w.value)).map((w, Q) => /* @__PURE__ */ jsx(
29026
+ ].filter((w) => z.includes(w.value)).map((w, U) => /* @__PURE__ */ jsx(
29008
29027
  "button",
29009
29028
  {
29010
29029
  type: "button",
29011
29030
  onClick: () => h(w.value),
29012
29031
  className: cn$1(
29013
29032
  "px-3 py-1.5 text-[12px] font-medium transition-colors",
29014
- Q > 0 && "border-l border-slate-200 dark:border-border",
29033
+ U > 0 && "border-l border-slate-200 dark:border-border",
29015
29034
  m === w.value ? "bg-nvr-cyan/10 text-nvr-navy dark:text-nvr-cyan" : "bg-white text-slate-500 hover:text-slate-700 dark:bg-card dark:hover:text-foreground"
29016
29035
  ),
29017
29036
  children: w.label
@@ -29029,7 +29048,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29029
29048
  ),
29030
29049
  children: [
29031
29050
  /* @__PURE__ */ jsx(Rows3, { className: "h-3.5 w-3.5" }),
29032
- u ? `Group: ${((U = kn.find((w) => w.value === u)) == null ? void 0 : U.label) ?? u}` : "Group"
29051
+ u ? `Group: ${((Q = kn.find((w) => w.value === u)) == null ? void 0 : Q.label) ?? u}` : "Group"
29033
29052
  ]
29034
29053
  }
29035
29054
  ) }),
@@ -29189,7 +29208,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29189
29208
  "button",
29190
29209
  {
29191
29210
  type: "button",
29192
- onClick: () => Un.mutate(w.id),
29211
+ onClick: () => Qn.mutate(w.id),
29193
29212
  className: "hidden text-slate-400 hover:text-red-500 group-hover:inline",
29194
29213
  "aria-label": `Delete view ${w.name}`,
29195
29214
  children: "×"
@@ -29210,7 +29229,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29210
29229
  ) }),
29211
29230
  /* @__PURE__ */ jsxs(PopoverContent, { className: "w-[240px] p-3", align: "end", children: [
29212
29231
  (() => {
29213
- const w = tt == null ? void 0 : tt.data.find((Q) => Q.id === us);
29232
+ const w = tt == null ? void 0 : tt.data.find((U) => U.id === us);
29214
29233
  return !w || w.user !== a && !$n ? null : /* @__PURE__ */ jsxs(
29215
29234
  "button",
29216
29235
  {
@@ -29262,8 +29281,8 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29262
29281
  "button",
29263
29282
  {
29264
29283
  type: "button",
29265
- disabled: !Ln.trim() || Ut.isPending,
29266
- onClick: () => Ut.mutate(),
29284
+ disabled: !Ln.trim() || Qt.isPending,
29285
+ onClick: () => Qt.mutate(),
29267
29286
  className: "w-full rounded-md bg-nvr-cyan px-2 py-1.5 text-[12px] font-semibold text-white hover:bg-nvr-cyan/90 disabled:opacity-50",
29268
29287
  children: "Save current view"
29269
29288
  }
@@ -29294,12 +29313,12 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29294
29313
  items: Zt,
29295
29314
  strategy: verticalListSortingStrategy,
29296
29315
  children: /* @__PURE__ */ jsx("div", { className: "space-y-1.5", children: Zt.map((w) => {
29297
- const Q = tn.find((se) => se.key === w);
29316
+ const U = tn.find((se) => se.key === w);
29298
29317
  return /* @__PURE__ */ jsx(
29299
29318
  SortableColumnToggle,
29300
29319
  {
29301
29320
  id: w,
29302
- label: typeof (Q == null ? void 0 : Q.header) == "string" ? Q.header : w,
29321
+ label: typeof (U == null ? void 0 : U.header) == "string" ? U.header : w,
29303
29322
  checked: en.has(w),
29304
29323
  onCheckedChange: () => Ts(w)
29305
29324
  },
@@ -29377,8 +29396,8 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29377
29396
  ImportFromFileButton,
29378
29397
  {
29379
29398
  collection: B,
29380
- onParsed: (w, Q) => i(`/collections/${B}/new`, {
29381
- state: { importResult: w, importTemplateId: Q.id }
29399
+ onParsed: (w, U) => i(`/collections/${B}/new`, {
29400
+ state: { importResult: w, importTemplateId: U.id }
29382
29401
  })
29383
29402
  }
29384
29403
  )
@@ -29415,9 +29434,9 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29415
29434
  type: "button",
29416
29435
  "aria-label": `Clear ${filterDefLabel(w)} filter`,
29417
29436
  onClick: () => {
29418
- x((Q) => ({
29419
- ...Q,
29420
- [w.key]: Array.isArray(Q[w.key]) ? [] : ""
29437
+ x((U) => ({
29438
+ ...U,
29439
+ [w.key]: Array.isArray(U[w.key]) ? [] : ""
29421
29440
  })), p(1);
29422
29441
  },
29423
29442
  className: "self-stretch px-1.5 text-slate-400 hover:bg-slate-100 hover:text-slate-600 dark:hover:bg-muted dark:hover:text-foreground",
@@ -29474,8 +29493,8 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29474
29493
  def: w,
29475
29494
  layout: "stacked",
29476
29495
  value: k[w.key] ?? "",
29477
- onChange: (Q) => {
29478
- x((se) => ({ ...se, [w.key]: Q })), p(1);
29496
+ onChange: (U) => {
29497
+ x((se) => ({ ...se, [w.key]: U })), p(1);
29479
29498
  }
29480
29499
  },
29481
29500
  w.key
@@ -29503,7 +29522,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29503
29522
  isLoading: mt,
29504
29523
  onPageChange: p,
29505
29524
  onRowClick: (w) => bt(w),
29506
- rowClassName: (w) => vt === Qe(w) ? (
29525
+ rowClassName: (w) => vt === Ue(w) ? (
29507
29526
  // Pinned sticky cells use bg-inherit — the highlight must be
29508
29527
  // OPAQUE (nvr-cyan/5-over-white equivalents) or horizontally
29509
29528
  // scrolled content bleeds through the pinned columns. Same
@@ -29517,8 +29536,8 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29517
29536
  },
29518
29537
  filterDefs: $s,
29519
29538
  filterValues: k,
29520
- onFilterChange: (w, Q) => {
29521
- x((se) => ({ ...se, [w]: Q })), p(1);
29539
+ onFilterChange: (w, U) => {
29540
+ x((se) => ({ ...se, [w]: U })), p(1);
29522
29541
  },
29523
29542
  rowGroups: Es ?? void 0,
29524
29543
  collapsedGroups: y,
@@ -29528,10 +29547,10 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29528
29547
  hideFilterRow: !0,
29529
29548
  nowrapCells: !0,
29530
29549
  columnPins: sn,
29531
- onColumnPinChange: (w, Q) => {
29550
+ onColumnPinChange: (w, U) => {
29532
29551
  q((se) => {
29533
29552
  const $e = { ...se ?? sn };
29534
- return Q ? $e[w] = Q : delete $e[w], $e;
29553
+ return U ? $e[w] = U : delete $e[w], $e;
29535
29554
  });
29536
29555
  },
29537
29556
  columnFilterRow: !0,
@@ -29546,7 +29565,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29546
29565
  {
29547
29566
  items: Ht,
29548
29567
  onCardClick: (w) => bt(w),
29549
- onDrop: (w, Q) => Tt.mutate({ item: w, targetState: Q }),
29568
+ onDrop: (w, U) => Tt.mutate({ item: w, targetState: U }),
29550
29569
  onClaim: (w) => ot.mutate(w),
29551
29570
  onRelease: (w) => ht.mutate(w),
29552
29571
  swimlaneBy: f,
@@ -29583,7 +29602,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29583
29602
  })
29584
29603
  )
29585
29604
  ),
29586
- onTransition: (w) => gn("Transition", (Q) => jt(Q, w)),
29605
+ onTransition: (w) => gn("Transition", (U) => jt(U, w)),
29587
29606
  onClear: () => Ks([])
29588
29607
  }
29589
29608
  ),
@@ -29597,9 +29616,9 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29597
29616
  width: os[0].width,
29598
29617
  title: os[0].title,
29599
29618
  stack: os,
29600
- onPush: (w) => Us.push([...os, w]),
29601
- onPop: () => Us.back(),
29602
- onClose: () => Us.back(os.length)
29619
+ onPush: (w) => Qs.push([...os, w]),
29620
+ onPop: () => Qs.back(),
29621
+ onClose: () => Qs.back(os.length)
29603
29622
  }
29604
29623
  ) : null,
29605
29624
  /* @__PURE__ */ jsx(