@nivaro/react 0.3.13 → 0.3.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/components/slots/pipeline/OwnersSection.js +79 -75
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useSessionRecorder.js +1 -1
  4. package/dist/index.d.ts +33 -2
  5. package/dist/index.js +520 -516
  6. package/dist/shared/components/CollectionBrowserView.js +2393 -2318
  7. package/dist/shared/components/DataTable.js +347 -335
  8. package/dist/shared/components/ItemEditForm.js +5278 -5149
  9. package/dist/shared/components/ListLoadError.js +33 -0
  10. package/dist/shared/components/PageRenderer.js +562 -529
  11. package/dist/shared/components/ProfileView.js +53 -51
  12. package/dist/shared/components/RecordReadView.js +119 -117
  13. package/dist/shared/components/ReportView.js +1268 -1241
  14. package/dist/shared/components/cbv/export-rows.js +69 -0
  15. package/dist/shared/components/cbv/saved-view-risk.js +35 -0
  16. package/dist/shared/components/cbv/unknown-fields.js +18 -0
  17. package/dist/shared/components/integrations/console/AlertsView.js +27 -25
  18. package/dist/shared/components/integrations/console/EventsView.js +244 -209
  19. package/dist/shared/components/item-edit/CatalogPickerField.js +946 -878
  20. package/dist/shared/components/item-edit/DraftRecoveryBanner.js +84 -57
  21. package/dist/shared/components/item-edit/FieldAffordances.js +63 -61
  22. package/dist/shared/components/item-edit/FieldRow.js +195 -179
  23. package/dist/shared/components/item-edit/FilePickerField.js +257 -254
  24. package/dist/shared/components/item-edit/HeaderTools.js +139 -95
  25. package/dist/shared/components/item-edit/InlineTableField.js +2087 -2075
  26. package/dist/shared/components/item-edit/RowComments.js +1 -3
  27. package/dist/shared/components/item-edit/SummaryPanel.js +62 -62
  28. package/dist/shared/components/item-edit/UserChip.js +113 -113
  29. package/dist/shared/components/item-edit/file-download.js +18 -0
  30. package/dist/shared/components/item-edit/line-qty.js +67 -32
  31. package/dist/shared/components/item-edit/save-refusal.js +23 -0
  32. package/dist/shared/components/monitoring/TrafficMiniMap.js +9 -9
  33. package/dist/shared/components/panels/CommentPanel.js +30 -30
  34. package/dist/shared/components/panels/ItemLockBanner.js +207 -185
  35. package/dist/shared/components/panels/PipelinePanel.js +915 -786
  36. package/dist/shared/components/pipeline/PipelineEditorView.js +45 -25
  37. package/dist/shared/components/profile/DelegationCard.js +1 -1
  38. package/dist/shared/components/profile/session-actions.js +24 -24
  39. package/dist/shared/components/queue/QueueItemSheet.js +18 -18
  40. package/dist/shared/components/queue/QueueWorklist.js +517 -504
  41. package/dist/shared/components/ui/dropdown-menu.js +8 -7
  42. package/dist/shared/lib/draft-store.js +60 -33
  43. package/dist/shared/lib/leave-guard.js +38 -0
  44. package/dist/shared/lib/load-error.js +38 -17
  45. package/dist/shared/lib/summary-mode.js +25 -25
  46. package/dist/shared/lib/table-pins.js +23 -0
  47. package/dist/shared/lib/validation-rules.js +55 -51
  48. package/package.json +1 -1
@@ -1,36 +1,39 @@
1
- import { jsx as e, jsxs as n, Fragment as ae } from "react/jsx-runtime";
2
- import { useQueryClient as De, useQuery as Z, useMutation as ue } from "@tanstack/react-query";
3
- import { ArrowRight as Ae, Loader2 as te, Check as ve, GitBranch as _e, AlertTriangle as ft, ChevronDown as oe, Users as Ge, Minus as ht, UserPlus as xt, X as Je, Zap as Ze, Search as bt } from "lucide-react";
4
- import { useState as U, useRef as se, useEffect as de, useMemo as He, Suspense as Ye, lazy as gt } from "react";
5
- import { toast as X } from "sonner";
6
- import { useNivaroClient as ce } from "../../context.js";
7
- import { get as Y, post as be, del as yt } from "../../lib/commands.js";
8
- import { useRecordSignalWhile as et, useRecordSignalPeers as wt, signalSentence as vt } from "../../lib/presence-signals.js";
9
- import { RUN_TRANSITION_EVENT as ge } from "../../lib/run-transition.js";
10
- import { serverNow as Nt } from "../../lib/server-clock.js";
11
- import { cn as pe, formatRelative as tt, humanHours as kt } from "../../lib/utils.js";
12
- import { PushReadinessChip as _t } from "../integrations/RecordIntegrationPreview.js";
13
- import { invalidateRecordInsights as ye, invalidateRecordData as we } from "../item-edit/RecordInsights.js";
14
- import { OwnerAvatars as Ct } from "../queue/OwnerAvatars.js";
15
- import { UserAvatar as St } from "../UserAvatar.js";
16
- import { Button as V } from "../ui/button.js";
17
- import { DropdownMenu as nt, DropdownMenuTrigger as rt, DropdownMenuContent as at, DropdownMenuItem as st } from "../ui/dropdown-menu.js";
18
- import { Popover as Re, PopoverTrigger as je, PopoverContent as Oe } from "../ui/popover.js";
19
- import { Skeleton as ne } from "../ui/skeleton.js";
20
- import { TooltipProvider as it, Tooltip as Se, TooltipTrigger as $e, TooltipContent as qe } from "../ui/tooltip.js";
21
- import { isAccessRefusal as lt, deniedToastAction as ot, WhyOwnersButton as $t } from "./AccessInsights.js";
22
- import { BranchLanes as qt } from "./BranchLanes.js";
23
- import { SlaClockLine as Tt } from "./SlaClock.js";
24
- const dt = gt(
1
+ import { jsx as e, jsxs as n, Fragment as de } from "react/jsx-runtime";
2
+ import { useQueryClient as Oe, useQuery as te, useMutation as he } from "@tanstack/react-query";
3
+ import { ArrowRight as Be, Loader2 as se, Check as _e, GitBranch as $e, AlertTriangle as wt, ChevronDown as me, Users as st, Minus as Nt, UserPlus as vt, X as it, Zap as lt, Search as kt } from "lucide-react";
4
+ import { useState as K, useRef as ne, useEffect as ue, useMemo as et, Suspense as ot, lazy as _t } from "react";
5
+ import { toast as ee } from "sonner";
6
+ import { useNivaroClient as fe, useItemEditAuth as Ct } from "../../context.js";
7
+ import { get as ie, post as we, del as St } from "../../lib/commands.js";
8
+ import { useRecordSignalWhile as dt, useRecordSignalPeers as $t, signalSentence as Tt } from "../../lib/presence-signals.js";
9
+ import { RUN_TRANSITION_EVENT as Ne } from "../../lib/run-transition.js";
10
+ import { userErrorMessage as Fe } from "../../lib/safe-error.js";
11
+ import { serverNow as qt } from "../../lib/server-clock.js";
12
+ import { userCardQuery as At } from "../../lib/user-cards.js";
13
+ import { cn as xe, formatRelative as ct, humanHours as Pt } from "../../lib/utils.js";
14
+ import { PushReadinessChip as Rt } from "../integrations/RecordIntegrationPreview.js";
15
+ import { useHeaderFold as Dt } from "../item-edit/HeaderTools.js";
16
+ import { invalidateRecordInsights as ve, invalidateRecordData as ke } from "../item-edit/RecordInsights.js";
17
+ import { OwnerAvatars as Mt } from "../queue/OwnerAvatars.js";
18
+ import { UserAvatar as jt } from "../UserAvatar.js";
19
+ import { Button as Y } from "../ui/button.js";
20
+ import { DropdownMenu as qe, DropdownMenuTrigger as Ae, DropdownMenuContent as Pe, DropdownMenuGroup as tt, DropdownMenuSeparator as nt, DropdownMenuItem as ge, DropdownMenuLabel as Lt } from "../ui/dropdown-menu.js";
21
+ import { Popover as Ee, PopoverTrigger as Ie, PopoverContent as Ue } from "../ui/popover.js";
22
+ import { Skeleton as le } from "../ui/skeleton.js";
23
+ import { TooltipProvider as mt, Tooltip as Re, TooltipTrigger as De, TooltipContent as Me } from "../ui/tooltip.js";
24
+ import { isAccessRefusal as ut, deniedToastAction as pt, WhyOwnersButton as Ot } from "./AccessInsights.js";
25
+ import { BranchLanes as Bt } from "./BranchLanes.js";
26
+ import { SlaClockLine as Ft } from "./SlaClock.js";
27
+ const ft = _t(
25
28
  () => import("./TransitionRequirementsDialog.js").then((r) => ({
26
29
  default: r.TransitionRequirementsDialog
27
30
  }))
28
31
  );
29
- function ct(r, t) {
32
+ function ht(r, t) {
30
33
  const u = r || "System";
31
34
  return t.on_behalf_of_name ? `${u}, for ${t.on_behalf_of_name}` : u;
32
35
  }
33
- function Pt(r) {
36
+ function Et(r) {
34
37
  if (r.transition) return null;
35
38
  const t = (r.comment ?? "").trim();
36
39
  if (!t.startsWith("{")) return null;
@@ -44,20 +47,20 @@ function Pt(r) {
44
47
  }
45
48
  return null;
46
49
  }
47
- function xe(r) {
50
+ function ye(r) {
48
51
  return !(r.first_name || r.last_name || r.user_email);
49
52
  }
50
- function Te(r) {
53
+ function je(r) {
51
54
  const t = (r.comment ?? "").trim().toLowerCase();
52
55
  return r.origin === "import" || t.startsWith("import:") ? "Imported" : r.origin === "integration" ? "By an integration" : /-state-sync$/.test(t) || t.startsWith("legacy-") ? "Synced from another system" : t === "state-merge" || t === "instance-migration" ? "Moved by an admin script" : "Moved automatically";
53
56
  }
54
- function Pe(r) {
57
+ function Le(r) {
55
58
  if (r.transition_text) return r.transition_text;
56
59
  if (r.transition_label) return `Rule: ${r.transition_label}`;
57
60
  const t = (r.comment ?? "").trim(), u = /^auto: (.+)$/i.exec(t);
58
61
  return u ? `Rule: ${u[1]}` : /-state-sync$/i.test(t) ? "The state was copied in from the system that owned this record" : /^instance-migration/i.test(t) ? "Moved when the pipeline was reshaped" : /^state-merge/i.test(t) ? "Moved when two states were merged" : null;
59
62
  }
60
- const Ve = {
63
+ const rt = {
61
64
  validation: "the partner refused what we sent",
62
65
  not_found: "the partner could not find what we referred to",
63
66
  auth: "the partner refused our credentials",
@@ -65,18 +68,18 @@ const Ve = {
65
68
  rate_limited: "the partner asked us to slow down",
66
69
  unknown: "the partner refused it"
67
70
  };
68
- function Dt(r) {
69
- const t = Math.ceil((new Date(r).getTime() - Nt()) / 6e4);
71
+ function It(r) {
72
+ const t = Math.ceil((new Date(r).getTime() - qt()) / 6e4);
70
73
  return !Number.isFinite(t) || t <= 0 ? "on the next check" : t < 60 ? `in ${t} min` : `in ${Math.round(t / 60)}h`;
71
74
  }
72
- function At({ held: r }) {
75
+ function Ut({ held: r }) {
73
76
  return r.length === 0 ? null : /* @__PURE__ */ e(
74
77
  "div",
75
78
  {
76
79
  className: "space-y-2 border-b border-amber-100 bg-amber-50 px-5 py-3 dark:border-amber-500/20 dark:bg-amber-500/10",
77
80
  "data-pipeline-auto-held": !0,
78
81
  children: r.map((t) => {
79
- const u = t.transition_label ?? "An automatic move", i = Ve[t.error_class ?? "unknown"] ?? Ve.unknown;
82
+ const u = t.transition_label ?? "An automatic move", i = rt[t.error_class ?? "unknown"] ?? rt.unknown;
80
83
  return /* @__PURE__ */ n("div", { className: "text-[12px] text-amber-800 dark:text-amber-300", children: [
81
84
  /* @__PURE__ */ n("p", { className: "font-medium", children: [
82
85
  "Needs a person: ",
@@ -94,7 +97,7 @@ function At({ held: r }) {
94
97
  }
95
98
  ),
96
99
  /* @__PURE__ */ n("p", { className: "mt-1 text-[11px] text-amber-700 dark:text-amber-400", children: [
97
- t.retry_at ? `It tries the same push again ${Dt(t.retry_at)}. ` : "It will not send the same push again on its own. ",
100
+ t.retry_at ? `It tries the same push again ${It(t.retry_at)}. ` : "It will not send the same push again on its own. ",
98
101
  "Fix the record so what it sends changes, retry the push, or move the record by hand.",
99
102
  t.attempts > 1 ? ` ${t.attempts} attempts so far.` : ""
100
103
  ] })
@@ -103,12 +106,17 @@ function At({ held: r }) {
103
106
  }
104
107
  );
105
108
  }
106
- function mt(r) {
109
+ function xt(r) {
110
+ var u;
111
+ const t = r == null ? void 0 : r.response;
112
+ return ((t == null ? void 0 : t.code) ?? ((u = t == null ? void 0 : t.data) == null ? void 0 : u.code)) === "TRANSITION_DUPLICATE";
113
+ }
114
+ function bt(r) {
107
115
  var u;
108
116
  const t = r;
109
117
  return (t == null ? void 0 : t.status) === 422 && ((u = t.response) == null ? void 0 : u.error) === "TRANSITION_REQUIREMENTS" ? t.response.requirements ?? [] : null;
110
118
  }
111
- function re({
119
+ function oe({
112
120
  label: r,
113
121
  color: t,
114
122
  small: u
@@ -127,176 +135,186 @@ function re({
127
135
  r
128
136
  );
129
137
  }
130
- function Ce(r) {
138
+ function Te(r) {
131
139
  const t = Math.floor(r / 6e4);
132
- return t < 60 ? `${Math.max(1, t)}m` : kt(r / 36e5);
140
+ return t < 60 ? `${Math.max(1, t)}m` : Pt(r / 36e5);
133
141
  }
134
- function Rt({
142
+ function Qt({
135
143
  history: r,
136
144
  completedAt: t
137
145
  }) {
138
146
  const u = [...r].sort(
139
- (x, b) => new Date(x.timestamp).getTime() - new Date(b.timestamp).getTime()
147
+ (f, v) => new Date(f.timestamp).getTime() - new Date(v.timestamp).getTime()
140
148
  );
141
149
  if (u.length === 0) return null;
142
- const i = t ? new Date(t).getTime() : Date.now(), C = u.map((x, b) => {
143
- const T = new Date(x.timestamp).getTime(), P = b + 1 < u.length ? new Date(u[b + 1].timestamp).getTime() : i;
150
+ const i = t ? new Date(t).getTime() : Date.now(), T = u.map((f, v) => {
151
+ const q = new Date(f.timestamp).getTime(), D = v + 1 < u.length ? new Date(u[v + 1].timestamp).getTime() : i;
144
152
  return {
145
- key: x.id,
146
- label: x.to_state_label,
147
- color: x.to_state_color,
148
- ms: Math.max(0, P - T),
149
- current: b === u.length - 1 && !t
153
+ key: f.id,
154
+ label: f.to_state_label,
155
+ color: f.to_state_color,
156
+ ms: Math.max(0, D - q),
157
+ current: v === u.length - 1 && !t
150
158
  };
151
- }).filter((x) => x.ms > 0 || x.current);
152
- if (C.length < 2) return null;
153
- const p = C.reduce((x, b) => x + b.ms, 0);
159
+ }).filter((f) => f.ms > 0 || f.current);
160
+ if (T.length < 2) return null;
161
+ const p = T.reduce((f, v) => f + v.ms, 0);
154
162
  return p <= 0 ? null : /* @__PURE__ */ n("div", { "data-state-timeline": !0, children: [
155
163
  /* @__PURE__ */ n("div", { className: "mb-1 flex items-center justify-between", children: [
156
164
  /* @__PURE__ */ e("p", { className: "text-[10px] font-semibold uppercase tracking-wide text-slate-400 dark:text-slate-500", children: "Time in step" }),
157
165
  /* @__PURE__ */ n("p", { className: "text-[10px] tabular-nums text-slate-400 dark:text-slate-500", children: [
158
- Ce(p),
166
+ Te(p),
159
167
  " total",
160
168
  t ? "" : " · so far"
161
169
  ] })
162
170
  ] }),
163
- /* @__PURE__ */ e("div", { className: "flex h-4 w-full overflow-hidden rounded", children: C.map((x) => {
164
- const b = x.ms / p * 100;
171
+ /* @__PURE__ */ e("div", { className: "flex h-4 w-full overflow-hidden rounded", children: T.map((f) => {
172
+ const v = f.ms / p * 100;
165
173
  return /* @__PURE__ */ n(
166
174
  "div",
167
175
  {
168
- "data-tip": `${x.label} — ${Ce(x.ms)}${x.current ? " (current)" : ""}`,
176
+ "data-tip": `${f.label} — ${Te(f.ms)}${f.current ? " (current)" : ""}`,
169
177
  className: "relative flex min-w-[8px] items-center overflow-hidden border-r border-white/60 last:border-r-0 dark:border-black/30",
170
178
  style: {
171
- width: `${b}%`,
172
- backgroundColor: x.color ? `${x.color}55` : "rgba(100,116,139,.25)"
179
+ width: `${v}%`,
180
+ backgroundColor: f.color ? `${f.color}55` : "rgba(100,116,139,.25)"
173
181
  },
174
182
  children: [
175
- b >= 14 && /* @__PURE__ */ n("span", { className: "truncate px-1.5 text-[9.5px] font-medium leading-none text-slate-700 dark:text-slate-200", children: [
176
- x.label,
183
+ v >= 14 && /* @__PURE__ */ n("span", { className: "truncate px-1.5 text-[9.5px] font-medium leading-none text-slate-700 dark:text-slate-200", children: [
184
+ f.label,
177
185
  " · ",
178
- Ce(x.ms)
186
+ Te(f.ms)
179
187
  ] }),
180
- x.current && /* @__PURE__ */ e(
188
+ f.current && /* @__PURE__ */ e(
181
189
  "span",
182
190
  {
183
191
  className: "absolute inset-y-0 right-0 w-[2px]",
184
- style: { backgroundColor: x.color ?? "#64748b" }
192
+ style: { backgroundColor: f.color ?? "#64748b" }
185
193
  }
186
194
  )
187
195
  ]
188
196
  },
189
- x.key
197
+ f.key
190
198
  );
191
199
  }) })
192
200
  ] });
193
201
  }
194
- function jt({
202
+ function zt({
195
203
  states: r,
196
204
  allTransitions: t,
197
205
  availableTransitions: u,
198
206
  currentStateId: i,
199
- history: C,
207
+ history: T,
200
208
  onPathIds: p,
201
- skippedStates: x
209
+ skippedStates: f
202
210
  }) {
203
- var E;
204
- const b = new Set(C.map((l) => l.to_state)), T = r.find((l) => l.is_initial);
205
- T && T.id !== i && b.add(T.id);
206
- const P = (E = C[0]) == null ? void 0 : E.from_state;
207
- P && P !== i && b.add(P);
208
- const h = (() => {
211
+ var S;
212
+ const v = ne(null);
213
+ ue(() => {
214
+ const s = v.current;
215
+ if (!s || s.scrollWidth <= s.clientWidth) return;
216
+ const w = s.querySelector("[data-track-current]");
217
+ if (!w) return;
218
+ const a = s.getBoundingClientRect(), N = w.getBoundingClientRect();
219
+ s.scrollLeft += N.left + N.width / 2 - (a.left + a.width / 2);
220
+ }, [i]);
221
+ const q = new Set(T.map((s) => s.to_state)), D = r.find((s) => s.is_initial);
222
+ D && D.id !== i && q.add(D.id);
223
+ const x = (S = T[0]) == null ? void 0 : S.from_state;
224
+ x && x !== i && q.add(x);
225
+ const R = (() => {
209
226
  if (p)
210
- return r.filter((s) => p.has(s.id) || b.has(s.id) || s.id === i).filter((s) => {
211
- const a = s.stage_visibility ?? "always";
212
- return a === "hide" ? !1 : a === "hide_unless_active" ? b.has(s.id) || s.id === i : !0;
213
- }).sort((s, a) => s.sort - a.sort);
227
+ return r.filter((c) => p.has(c.id) || q.has(c.id) || c.id === i).filter((c) => {
228
+ const y = c.stage_visibility ?? "always";
229
+ return y === "hide" ? !1 : y === "hide_unless_active" ? q.has(c.id) || c.id === i : !0;
230
+ }).sort((c, y) => c.sort - y.sort);
214
231
  if (t.length === 0) {
215
- const s = /* @__PURE__ */ new Set([...b]);
216
- return i && s.add(i), r.filter((a) => s.has(a.id)).sort((a, A) => a.sort - A.sort);
232
+ const c = /* @__PURE__ */ new Set([...q]);
233
+ return i && c.add(i), r.filter((y) => c.has(y.id)).sort((y, d) => y.sort - d.sort);
217
234
  }
218
- const l = new Set(
219
- C.filter((s) => s.from_state).map((s) => `${s.from_state}:${s.to_state}`)
220
- ), v = new Set(C.map((s) => s.from_state).filter(Boolean)), c = t.filter((s) => s.from_state !== null), o = /* @__PURE__ */ new Map();
221
- for (const s of c) {
222
- const a = s.from_state;
223
- if (v.has(a) && !l.has(`${a}:${s.to_state}`)) continue;
224
- const A = o.get(a) ?? [];
225
- A.push(s.to_state), o.set(a, A);
235
+ const s = new Set(
236
+ T.filter((c) => c.from_state).map((c) => `${c.from_state}:${c.to_state}`)
237
+ ), w = new Set(T.map((c) => c.from_state).filter(Boolean)), a = t.filter((c) => c.from_state !== null), N = /* @__PURE__ */ new Map();
238
+ for (const c of a) {
239
+ const y = c.from_state;
240
+ if (w.has(y) && !s.has(`${y}:${c.to_state}`)) continue;
241
+ const d = N.get(y) ?? [];
242
+ d.push(c.to_state), N.set(y, d);
226
243
  }
227
244
  if (i) {
228
- const s = c.filter((a) => a.from_state === i).map((a) => a.to_state);
229
- o.set(i, [
230
- .../* @__PURE__ */ new Set([...u.map((a) => a.to_state), ...s])
245
+ const c = a.filter((y) => y.from_state === i).map((y) => y.to_state);
246
+ N.set(i, [
247
+ .../* @__PURE__ */ new Set([...u.map((y) => y.to_state), ...c])
231
248
  ]);
232
249
  }
233
- const g = /* @__PURE__ */ new Set(), f = r.filter((s) => s.is_initial).map((s) => s.id);
234
- for (; f.length; ) {
235
- const s = f.shift();
236
- if (!g.has(s)) {
237
- g.add(s);
238
- for (const a of o.get(s) ?? []) g.has(a) || f.push(a);
250
+ const k = /* @__PURE__ */ new Set(), A = r.filter((c) => c.is_initial).map((c) => c.id);
251
+ for (; A.length; ) {
252
+ const c = A.shift();
253
+ if (!k.has(c)) {
254
+ k.add(c);
255
+ for (const y of N.get(c) ?? []) k.has(y) || A.push(y);
239
256
  }
240
257
  }
241
- const y = /* @__PURE__ */ new Set([...g, ...b]);
242
- return i && y.add(i), r.filter((s) => y.has(s.id)).filter((s) => {
243
- const a = s.stage_visibility ?? "always";
244
- return a === "hide" ? !1 : a === "hide_unless_active" ? b.has(s.id) || s.id === i : !0;
245
- }).sort((s, a) => s.sort - a.sort);
258
+ const W = /* @__PURE__ */ new Set([...k, ...q]);
259
+ return i && W.add(i), r.filter((c) => W.has(c.id)).filter((c) => {
260
+ const y = c.stage_visibility ?? "always";
261
+ return y === "hide" ? !1 : y === "hide_unless_active" ? q.has(c.id) || c.id === i : !0;
262
+ }).sort((c, y) => c.sort - y.sort);
246
263
  })();
247
- if (h.length < 2) return null;
248
- const N = new Map(h.map((l, v) => [l.id, v])), q = new Map(r.map((l) => [l.id, l.label]));
249
- function F(l, v) {
250
- const c = N.get(l);
251
- return c == null ? [] : [...C].filter((o) => {
252
- if (!o.from_state) return !1;
253
- const g = N.get(o.from_state), f = N.get(o.to_state);
254
- return g == null || f == null ? !1 : g === c && f > c || f === c && g > c;
255
- }).sort((o, g) => new Date(o.timestamp).getTime() - new Date(g.timestamp).getTime());
264
+ if (R.length < 2) return null;
265
+ const _ = new Map(R.map((s, w) => [s.id, w])), I = new Map(r.map((s) => [s.id, s.label]));
266
+ function L(s, w) {
267
+ const a = _.get(s);
268
+ return a == null ? [] : [...T].filter((N) => {
269
+ if (!N.from_state) return !1;
270
+ const k = _.get(N.from_state), A = _.get(N.to_state);
271
+ return k == null || A == null ? !1 : k === a && A > a || A === a && k > a;
272
+ }).sort((N, k) => new Date(N.timestamp).getTime() - new Date(k.timestamp).getTime());
256
273
  }
257
- function k(l) {
258
- var v, c, o, g;
259
- return xe(l) ? /* @__PURE__ */ e(Ze, { className: "inline h-2.5 w-2.5", "aria-label": Te(l) }) : ((((v = l.first_name) == null ? void 0 : v[0]) ?? "") + (((c = l.last_name) == null ? void 0 : c[0]) ?? "")).toUpperCase() || ((g = (o = l.user_email) == null ? void 0 : o[0]) == null ? void 0 : g.toUpperCase()) || "?";
274
+ function j(s) {
275
+ var w, a, N, k;
276
+ return ye(s) ? /* @__PURE__ */ e(lt, { className: "inline h-2.5 w-2.5", "aria-label": je(s) }) : ((((w = s.first_name) == null ? void 0 : w[0]) ?? "") + (((a = s.last_name) == null ? void 0 : a[0]) ?? "")).toUpperCase() || ((k = (N = s.user_email) == null ? void 0 : N[0]) == null ? void 0 : k.toUpperCase()) || "?";
260
277
  }
261
- function $(l) {
262
- return ct([l.first_name, l.last_name].filter(Boolean).join(" ") || l.user_email, l);
278
+ function M(s) {
279
+ return ht([s.first_name, s.last_name].filter(Boolean).join(" ") || s.user_email, s);
263
280
  }
264
- const D = /* @__PURE__ */ new Map();
265
- for (const l of [...C].sort(
266
- (v, c) => new Date(v.timestamp).getTime() - new Date(c.timestamp).getTime()
281
+ const U = /* @__PURE__ */ new Map();
282
+ for (const s of [...T].sort(
283
+ (w, a) => new Date(w.timestamp).getTime() - new Date(a.timestamp).getTime()
267
284
  )) {
268
- if (!l.from_state) continue;
269
- const v = N.get(l.from_state), c = N.get(l.to_state);
270
- if (!(v == null || c == null || c <= v + 1))
271
- for (let o = v + 1; o < c; o++) {
272
- const g = h[o].id;
273
- !b.has(g) && !D.has(g) && D.set(g, l);
285
+ if (!s.from_state) continue;
286
+ const w = _.get(s.from_state), a = _.get(s.to_state);
287
+ if (!(w == null || a == null || a <= w + 1))
288
+ for (let N = w + 1; N < a; N++) {
289
+ const k = R[N].id;
290
+ !q.has(k) && !U.has(k) && U.set(k, s);
274
291
  }
275
292
  }
276
- function w(l) {
277
- const v = q.get(l.from_state ?? "") ?? "the previous step", c = q.get(l.to_state) ?? "the next step", o = xe(l) ? "it moved automatically" : `${$(l)} moved it`;
278
- return `Passed over on ${new Date(l.timestamp).toLocaleString()} — ${o} straight from ${v} to ${c}`;
293
+ function b(s) {
294
+ const w = I.get(s.from_state ?? "") ?? "the previous step", a = I.get(s.to_state) ?? "the next step", N = ye(s) ? "it moved automatically" : `${M(s)} moved it`;
295
+ return `Passed over on ${new Date(s.timestamp).toLocaleString()} — ${N} straight from ${w} to ${a}`;
279
296
  }
280
- return /* @__PURE__ */ e(it, { delayDuration: 200, children: /* @__PURE__ */ e("div", { className: "flex w-full items-start", children: h.map((l, v) => {
281
- const c = l.id === i, o = b.has(l.id), g = o && !c, f = !o && !c ? D.get(l.id) : void 0, y = !o && !c ? x == null ? void 0 : x.get(l.id) : void 0, s = f || y ? [...f ? [w(f)] : [], ...y ?? []] : void 0, a = s !== void 0, A = l.color ?? "#94a3b8", M = v === h.length - 1, ee = M ? null : h[v + 1], R = ee ? F(l.id, ee.id) : [];
282
- return /* @__PURE__ */ n("div", { className: "flex min-w-[48px] flex-1 items-start", children: [
283
- /* @__PURE__ */ n("div", { className: "flex min-w-0 flex-1 flex-col items-center gap-1.5 px-1", children: [
297
+ return /* @__PURE__ */ e(mt, { delayDuration: 200, children: /* @__PURE__ */ e("div", { ref: v, className: "overflow-x-auto pt-1.5 pb-1", "data-state-track": !0, children: /* @__PURE__ */ e("div", { className: "flex w-full items-start", children: R.map((s, w) => {
298
+ const a = s.id === i, N = q.has(s.id), k = N && !a, A = !N && !a ? U.get(s.id) : void 0, W = !N && !a ? f == null ? void 0 : f.get(s.id) : void 0, c = A || W ? [...A ? [b(A)] : [], ...W ?? []] : void 0, y = c !== void 0, d = s.color ?? "#94a3b8", m = w === R.length - 1, g = m ? null : R[w + 1], C = g ? L(s.id, g.id) : [];
299
+ return /* @__PURE__ */ n("div", { className: "flex flex-1 items-start", children: [
300
+ /* @__PURE__ */ n("div", { className: "flex min-w-[76px] flex-1 flex-col items-center gap-1.5 px-1", children: [
284
301
  /* @__PURE__ */ e(
285
302
  "div",
286
303
  {
287
- className: `flex h-7 w-7 shrink-0 items-center justify-center rounded-full ${c || g ? "nvr-fill-sweep" : ""}`,
288
- "data-tip": l.description || void 0,
304
+ "data-track-current": a || void 0,
305
+ className: `flex h-7 w-7 shrink-0 items-center justify-center rounded-full ${a || k ? "nvr-fill-sweep" : ""}`,
306
+ "data-tip": s.description || void 0,
289
307
  style: {
290
- backgroundColor: c || g ? A : a ? "transparent" : "#f1f5f9",
291
- border: c || g ? "none" : a ? "1.5px dashed #cbd5e1" : "1.5px solid #e2e8f0",
292
- boxShadow: c ? `0 0 0 3px white, 0 0 0 5px ${A}` : void 0
308
+ backgroundColor: a || k ? d : y ? "transparent" : "#f1f5f9",
309
+ border: a || k ? "none" : y ? "1.5px dashed #cbd5e1" : "1.5px solid #e2e8f0",
310
+ boxShadow: a ? `0 0 0 3px white, 0 0 0 5px ${d}` : void 0
293
311
  },
294
- children: g ? /* @__PURE__ */ e(ve, { className: "h-3.5 w-3.5 text-white", strokeWidth: 2.5 }) : c ? /* @__PURE__ */ e("div", { className: "h-2.5 w-2.5 rounded-full bg-white/80" }) : a ? /* @__PURE__ */ e(ht, { className: "h-3 w-3 text-slate-400", strokeWidth: 2.5 }) : /* @__PURE__ */ e("div", { className: "h-2 w-2 rounded-full bg-slate-300" })
312
+ children: k ? /* @__PURE__ */ e(_e, { className: "h-3.5 w-3.5 text-white", strokeWidth: 2.5 }) : a ? /* @__PURE__ */ e("div", { className: "h-2.5 w-2.5 rounded-full bg-white/80" }) : y ? /* @__PURE__ */ e(Nt, { className: "h-3 w-3 text-slate-400", strokeWidth: 2.5 }) : /* @__PURE__ */ e("div", { className: "h-2 w-2 rounded-full bg-slate-300" })
295
313
  },
296
- c ? "cur" : g ? "done" : a ? "skip" : "todo"
314
+ a ? "cur" : k ? "done" : y ? "skip" : "todo"
297
315
  ),
298
- a ? /* @__PURE__ */ n(Se, { children: [
299
- /* @__PURE__ */ e($e, { asChild: !0, children: /* @__PURE__ */ e(
316
+ y ? /* @__PURE__ */ n(Re, { children: [
317
+ /* @__PURE__ */ e(De, { asChild: !0, children: /* @__PURE__ */ e(
300
318
  "span",
301
319
  {
302
320
  className: "w-full cursor-help break-words text-center leading-snug",
@@ -308,12 +326,12 @@ function jt({
308
326
  textDecoration: "line-through",
309
327
  textDecorationColor: "#cbd5e1"
310
328
  },
311
- children: l.label
329
+ children: s.label
312
330
  }
313
331
  ) }),
314
- /* @__PURE__ */ n(qe, { className: "max-w-[260px]", children: [
332
+ /* @__PURE__ */ n(Me, { className: "max-w-[260px]", children: [
315
333
  /* @__PURE__ */ e("p", { className: "text-[11px] font-medium", children: "Skipped for this record" }),
316
- s.length > 0 ? /* @__PURE__ */ e("ul", { className: "mt-1 space-y-0.5 text-[11px] opacity-90", children: s.map((S) => /* @__PURE__ */ e("li", { children: S }, S)) }) : /* @__PURE__ */ e("p", { className: "mt-1 text-[11px] opacity-90", children: "Its skip conditions are met." })
334
+ c.length > 0 ? /* @__PURE__ */ e("ul", { className: "mt-1 space-y-0.5 text-[11px] opacity-90", children: c.map((h) => /* @__PURE__ */ e("li", { children: h }, h)) }) : /* @__PURE__ */ e("p", { className: "mt-1 text-[11px] opacity-90", children: "Its skip conditions are met." })
317
335
  ] })
318
336
  ] }) : /* @__PURE__ */ e(
319
337
  "span",
@@ -321,23 +339,23 @@ function jt({
321
339
  className: "w-full break-words text-center leading-snug",
322
340
  style: {
323
341
  fontSize: "11px",
324
- color: c ? A : g ? "#475569" : "#94a3b8",
325
- fontWeight: c ? 600 : g ? 500 : 400,
342
+ color: a ? d : k ? "#475569" : "#94a3b8",
343
+ fontWeight: a ? 600 : k ? 500 : 400,
326
344
  wordBreak: "break-word"
327
345
  },
328
- children: l.label
346
+ children: s.label
329
347
  }
330
348
  )
331
349
  ] }),
332
- !M && /* @__PURE__ */ n("div", { className: "mt-[13px] flex w-10 shrink-0 flex-col items-center gap-1.5", children: [
350
+ !m && /* @__PURE__ */ n("div", { className: "mt-[13px] flex w-10 shrink-0 flex-col items-center gap-1.5", children: [
333
351
  (() => {
334
- const S = g ? `${A}55` : "#e8ecf0";
352
+ const h = k ? `${d}55` : "#e8ecf0";
335
353
  return /* @__PURE__ */ n("div", { className: "flex w-full shrink-0 items-center", children: [
336
354
  /* @__PURE__ */ e(
337
355
  "div",
338
356
  {
339
357
  className: "h-0.5 flex-1 rounded-l-sm",
340
- style: { backgroundColor: S }
358
+ style: { backgroundColor: h }
341
359
  }
342
360
  ),
343
361
  /* @__PURE__ */ e(
@@ -348,65 +366,65 @@ function jt({
348
366
  height: 0,
349
367
  borderTop: "3px solid transparent",
350
368
  borderBottom: "3px solid transparent",
351
- borderLeft: `5px solid ${S}`
369
+ borderLeft: `5px solid ${h}`
352
370
  }
353
371
  }
354
372
  )
355
373
  ] });
356
374
  })(),
357
- R.map((S) => {
358
- const B = S.from_state !== l.id, I = Math.abs(
359
- (N.get(S.to_state) ?? 0) - (N.get(S.from_state ?? "") ?? 0)
360
- ) > 1 ? q.get(S.to_state) ?? "" : null;
361
- return /* @__PURE__ */ n(Se, { children: [
362
- /* @__PURE__ */ e($e, { asChild: !0, children: /* @__PURE__ */ n("div", { className: "flex w-full cursor-default flex-col items-center gap-0.5", children: [
375
+ C.map((h) => {
376
+ const P = h.from_state !== s.id, Q = Math.abs(
377
+ (_.get(h.to_state) ?? 0) - (_.get(h.from_state ?? "") ?? 0)
378
+ ) > 1 ? I.get(h.to_state) ?? "" : null;
379
+ return /* @__PURE__ */ n(Re, { children: [
380
+ /* @__PURE__ */ e(De, { asChild: !0, children: /* @__PURE__ */ n("div", { className: "flex w-full cursor-default flex-col items-center gap-0.5", children: [
363
381
  /* @__PURE__ */ n(
364
382
  "span",
365
383
  {
366
384
  className: "text-center font-mono text-[9px] font-semibold leading-none",
367
- style: { color: B ? "#d97706" : "#475569" },
385
+ style: { color: P ? "#d97706" : "#475569" },
368
386
  children: [
369
- B && "↩ ",
370
- k(S)
387
+ P && "↩ ",
388
+ j(h)
371
389
  ]
372
390
  }
373
391
  ),
374
- /* @__PURE__ */ e("span", { className: "text-[8.5px] leading-none text-slate-400", children: tt(S.timestamp) })
392
+ /* @__PURE__ */ e("span", { className: "text-[8.5px] leading-none text-slate-400", children: ct(h.timestamp) })
375
393
  ] }) }),
376
- /* @__PURE__ */ n(qe, { side: "top", className: "space-y-0.5 text-[12px]", children: [
377
- xe(S) ? /* @__PURE__ */ n(ae, { children: [
394
+ /* @__PURE__ */ n(Me, { side: "top", className: "space-y-0.5 text-[12px]", children: [
395
+ ye(h) ? /* @__PURE__ */ n(de, { children: [
378
396
  /* @__PURE__ */ n("p", { className: "font-medium", children: [
379
- B ? "↩ Sent back · " : "",
380
- Te(S)
397
+ P ? "↩ Sent back · " : "",
398
+ je(h)
381
399
  ] }),
382
- Pe(S) && /* @__PURE__ */ e("p", { className: "max-w-[280px] text-muted-foreground", children: Pe(S) })
400
+ Le(h) && /* @__PURE__ */ e("p", { className: "max-w-[280px] text-muted-foreground", children: Le(h) })
383
401
  ] }) : /* @__PURE__ */ n("p", { className: "font-medium", children: [
384
- B ? "↩ Sent back by" : "Approved by",
402
+ P ? "↩ Sent back by" : "Approved by",
385
403
  " ",
386
- $(S)
404
+ M(h)
387
405
  ] }),
388
- I && /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: [
406
+ Q && /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: [
389
407
  "→ straight to ",
390
- I
408
+ Q
391
409
  ] }),
392
- /* @__PURE__ */ e("p", { className: "text-muted-foreground", children: new Date(S.timestamp).toLocaleString() })
410
+ /* @__PURE__ */ e("p", { className: "text-muted-foreground", children: new Date(h.timestamp).toLocaleString() })
393
411
  ] })
394
- ] }, S.id);
412
+ ] }, h.id);
395
413
  })
396
414
  ] })
397
- ] }, l.id);
398
- }) }) });
415
+ ] }, s.id);
416
+ }) }) }) });
399
417
  }
400
- function Ot({ history: r }) {
418
+ function Kt({ history: r }) {
401
419
  return r.length === 0 ? /* @__PURE__ */ e("p", { className: "text-[12px] text-slate-400 italic", children: "No transitions yet." }) : /* @__PURE__ */ e("div", { className: "space-y-3", children: r.map((t) => {
402
- const u = xe(t), i = u ? Te(t) : ct([t.first_name, t.last_name].filter(Boolean).join(" ") || t.user_email, t), C = Pt(t), p = t.comment && !u && !C ? t.comment : null, x = C ?? (u ? Pe(t) : null);
420
+ const u = ye(t), i = u ? je(t) : ht([t.first_name, t.last_name].filter(Boolean).join(" ") || t.user_email, t), T = Et(t), p = t.comment && !u && !T ? t.comment : null, f = T ?? (u ? Le(t) : null);
403
421
  return /* @__PURE__ */ n("div", { className: "flex items-start gap-2.5 text-[12px]", children: [
404
422
  /* @__PURE__ */ e("div", { className: "mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full bg-slate-200" }),
405
423
  /* @__PURE__ */ n("div", { className: "flex-1 min-w-0", children: [
406
424
  /* @__PURE__ */ n("div", { className: "flex items-center gap-1.5 flex-wrap", children: [
407
- t.from_state_label ? /* @__PURE__ */ e(re, { label: t.from_state_label, color: t.from_state_color, small: !0 }) : /* @__PURE__ */ e("span", { className: "text-[11px] text-slate-400 italic", children: "started" }),
408
- /* @__PURE__ */ e(Ae, { className: "h-3 w-3 shrink-0 text-slate-300" }),
409
- /* @__PURE__ */ e(re, { label: t.to_state_label, color: t.to_state_color, small: !0 })
425
+ t.from_state_label ? /* @__PURE__ */ e(oe, { label: t.from_state_label, color: t.from_state_color, small: !0 }) : /* @__PURE__ */ e("span", { className: "text-[11px] text-slate-400 italic", children: "started" }),
426
+ /* @__PURE__ */ e(Be, { className: "h-3 w-3 shrink-0 text-slate-300" }),
427
+ /* @__PURE__ */ e(oe, { label: t.to_state_label, color: t.to_state_color, small: !0 })
410
428
  ] }),
411
429
  p && /* @__PURE__ */ n("p", { className: "mt-1 text-slate-500 italic", children: [
412
430
  '"',
@@ -419,11 +437,11 @@ function Ot({ history: r }) {
419
437
  className: "mt-0.5 text-slate-400",
420
438
  "data-history-on-behalf": t.on_behalf_of_name ? t.on_behalf_of ?? "" : void 0,
421
439
  children: [
422
- u && /* @__PURE__ */ e(Ze, { className: "mr-1 inline h-3 w-3", "aria-hidden": !0 }),
440
+ u && /* @__PURE__ */ e(lt, { className: "mr-1 inline h-3 w-3", "aria-hidden": !0 }),
423
441
  i,
424
- x ? ` · ${x}` : "",
442
+ f ? ` · ${f}` : "",
425
443
  " · ",
426
- tt(t.timestamp)
444
+ ct(t.timestamp)
427
445
  ]
428
446
  }
429
447
  )
@@ -431,43 +449,42 @@ function Ot({ history: r }) {
431
449
  ] }, t.id);
432
450
  }) });
433
451
  }
434
- function Lt({ value: r, onChange: t }) {
435
- const u = ce(), [i, C] = U(!1), [p, x] = U(""), [b, T] = U(""), P = se(null), h = se(null);
436
- de(() => {
452
+ function Wt({ value: r, onChange: t }) {
453
+ const u = fe(), [i, T] = K(!1), [p, f] = K(""), [v, q] = K(""), D = ne(null), x = ne(null);
454
+ ue(() => {
437
455
  i ? setTimeout(() => {
438
- var w;
439
- return (w = P.current) == null ? void 0 : w.focus();
440
- }, 50) : x("");
441
- }, [i]), de(() => (h.current && clearTimeout(h.current), h.current = setTimeout(() => T(p), 250), () => {
442
- h.current && clearTimeout(h.current);
456
+ var b;
457
+ return (b = D.current) == null ? void 0 : b.focus();
458
+ }, 50) : f("");
459
+ }, [i]), ue(() => (x.current && clearTimeout(x.current), x.current = setTimeout(() => q(p), 250), () => {
460
+ x.current && clearTimeout(x.current);
443
461
  }), [p]);
444
- const { data: N, isLoading: q } = Z({
445
- queryKey: ["users", "async-search", b],
462
+ const { data: R, isLoading: _ } = te({
463
+ queryKey: ["users", "async-search", v],
446
464
  queryFn: () => u.request(
447
- Y("/users", {
465
+ ie("/users", {
448
466
  limit: 50,
449
467
  sort: "first_name",
450
- ...b ? { search: b } : {}
468
+ ...v ? { search: v } : {}
451
469
  })
452
- ).then((w) => w.data),
470
+ ).then((b) => b.data),
453
471
  enabled: i,
454
472
  staleTime: 3e4
455
- }), { data: F } = Z({
456
- queryKey: ["users", "single", r],
457
- queryFn: () => u.request(Y(`/users/${r}`)).then((w) => w.data),
473
+ }), { data: I } = te({
474
+ ...At(u, r),
458
475
  enabled: !!r,
459
476
  staleTime: 5 * 6e4
460
- }), k = F ? [F.first_name, F.last_name].filter(Boolean).join(" ").trim() || F.email : r || null, $ = N ?? [], D = (w) => [w.first_name, w.last_name].filter(Boolean).join(" ").trim();
461
- return /* @__PURE__ */ n(Re, { open: i, onOpenChange: C, children: [
477
+ }), L = R ?? [], j = I ?? L.find((b) => b.id === r) ?? null, M = j ? [j.first_name, j.last_name].filter(Boolean).join(" ").trim() || j.email : r ? "Selected person" : null, U = (b) => [b.first_name, b.last_name].filter(Boolean).join(" ").trim();
478
+ return /* @__PURE__ */ n(Ee, { open: i, onOpenChange: T, children: [
462
479
  /* @__PURE__ */ n("div", { className: "relative flex h-8 w-full", children: [
463
- /* @__PURE__ */ e(je, { asChild: !0, children: /* @__PURE__ */ n(
480
+ /* @__PURE__ */ e(Ie, { asChild: !0, children: /* @__PURE__ */ n(
464
481
  "button",
465
482
  {
466
483
  type: "button",
467
484
  className: "flex h-full w-full items-center justify-between gap-1.5 rounded-md border border-slate-200 bg-white px-2.5 text-left text-[13px] text-slate-700 hover:border-slate-300",
468
485
  children: [
469
- /* @__PURE__ */ e("span", { className: `flex-1 truncate ${k ? "" : "text-slate-400"}`, children: k ?? "Select a user…" }),
470
- /* @__PURE__ */ e(oe, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
486
+ /* @__PURE__ */ e("span", { className: `flex-1 truncate ${M ? "" : "text-slate-400"}`, children: M ?? "Select a user…" }),
487
+ /* @__PURE__ */ e(me, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
471
488
  ]
472
489
  }
473
490
  ) }),
@@ -475,364 +492,376 @@ function Lt({ value: r, onChange: t }) {
475
492
  "button",
476
493
  {
477
494
  type: "button",
478
- onClick: (w) => {
479
- w.stopPropagation(), t("");
495
+ onClick: (b) => {
496
+ b.stopPropagation(), t("");
480
497
  },
481
498
  className: "absolute right-6 top-1/2 -translate-y-1/2 flex h-5 w-5 items-center justify-center rounded text-slate-400 hover:bg-slate-100 hover:text-slate-600 dark:hover:bg-muted dark:hover:text-slate-300",
482
- children: /* @__PURE__ */ e(Je, { className: "h-3 w-3" })
499
+ children: /* @__PURE__ */ e(it, { className: "h-3 w-3" })
483
500
  }
484
501
  )
485
502
  ] }),
486
- /* @__PURE__ */ n(Oe, { align: "start", className: "w-72 p-0", sideOffset: 4, children: [
503
+ /* @__PURE__ */ n(Ue, { align: "start", className: "w-72 p-0", sideOffset: 4, children: [
487
504
  /* @__PURE__ */ e("div", { className: "border-b border-slate-100 px-2 py-1.5", children: /* @__PURE__ */ n("div", { className: "relative", children: [
488
- /* @__PURE__ */ e(bt, { className: "absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400" }),
505
+ /* @__PURE__ */ e(kt, { className: "absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400" }),
489
506
  /* @__PURE__ */ e(
490
507
  "input",
491
508
  {
492
- ref: P,
509
+ ref: D,
493
510
  value: p,
494
- onChange: (w) => x(w.target.value),
511
+ onChange: (b) => f(b.target.value),
495
512
  placeholder: "Search users…",
496
513
  className: "h-7 w-full rounded-md bg-slate-50 pl-7 pr-2 text-[12px] placeholder-slate-400 focus:outline-none focus:ring-1 focus:ring-nvr-cyan/40"
497
514
  }
498
515
  )
499
516
  ] }) }),
500
- /* @__PURE__ */ e("div", { className: "max-h-56 overflow-y-auto py-1", children: q ? /* @__PURE__ */ n("div", { className: "flex items-center gap-2 px-3 py-2 text-[12px] text-slate-400", children: [
501
- /* @__PURE__ */ e(te, { className: "h-3.5 w-3.5 animate-spin" }),
517
+ /* @__PURE__ */ e("div", { className: "max-h-56 overflow-y-auto py-1", children: _ ? /* @__PURE__ */ n("div", { className: "flex items-center gap-2 px-3 py-2 text-[12px] text-slate-400", children: [
518
+ /* @__PURE__ */ e(se, { className: "h-3.5 w-3.5 animate-spin" }),
502
519
  "Loading…"
503
- ] }) : $.length === 0 ? /* @__PURE__ */ e("div", { className: "px-3 py-2 text-[12px] text-slate-400", children: "No results" }) : $.map((w) => {
504
- const E = D(w), l = E ? `${E} (${w.email})` : w.email, v = w.id === r;
520
+ ] }) : L.length === 0 ? /* @__PURE__ */ e("div", { className: "px-3 py-2 text-[12px] text-slate-400", children: "No results" }) : L.map((b) => {
521
+ const S = U(b), s = S ? `${S} (${b.email})` : b.email, w = b.id === r;
505
522
  return /* @__PURE__ */ n(
506
523
  "button",
507
524
  {
508
525
  type: "button",
509
526
  onClick: () => {
510
- t(w.id), C(!1);
527
+ t(b.id), T(!1);
511
528
  },
512
- className: `flex w-full items-center gap-2 px-3 py-1.5 text-left text-[12px] hover:bg-slate-50 ${v ? "font-medium text-slate-800" : "text-slate-600"}`,
529
+ className: `flex w-full items-center gap-2 px-3 py-1.5 text-left text-[12px] hover:bg-slate-50 ${w ? "font-medium text-slate-800" : "text-slate-600"}`,
513
530
  children: [
514
531
  /* @__PURE__ */ e(
515
- ve,
532
+ _e,
516
533
  {
517
- className: `h-3.5 w-3.5 shrink-0 ${v ? "text-nvr-cyan" : "opacity-0"}`
534
+ className: `h-3.5 w-3.5 shrink-0 ${w ? "text-nvr-cyan" : "opacity-0"}`
518
535
  }
519
536
  ),
520
- l
537
+ s
521
538
  ]
522
539
  },
523
- w.id
540
+ b.id
524
541
  );
525
542
  }) })
526
543
  ] })
527
544
  ] });
528
545
  }
529
- function Ft({
546
+ function Ht({
530
547
  collection: r,
531
548
  item: t,
532
549
  states: u,
533
550
  currentStateId: i,
534
- returned: C = !1
551
+ returned: T = !1
535
552
  }) {
536
- var S, B, I;
537
- const p = ce(), x = De(), [b, T] = U(!1), [P, h] = U(""), [N, q] = U(""), [F, k] = U(!1), $ = ["pipeline-instance-owners", r, t], { data: D, isLoading: w } = Z({
538
- queryKey: $,
539
- queryFn: () => p.request(
540
- Y(`/pipelines/instance/${r}/${t}/owners`)
541
- ).then((m) => m.data)
542
- }), { data: E, isLoading: l } = Z({
553
+ var O, re, F;
554
+ const p = fe(), f = Oe(), { isAdmin: v } = Ct(), [q, D] = K(!1), [x, R] = K(""), [_, I] = K(""), [L, j] = K(!1), M = ["pipeline-instance-owners", r, t], U = ["pipeline-owners-can-add", r, t], b = () => p.request(
555
+ ie(`/pipelines/instance/${r}/${t}/owners`)
556
+ ).then((l) => {
557
+ var B;
558
+ return f.setQueryData(U, ((B = l.meta) == null ? void 0 : B.can_add) ?? null), l;
559
+ }), { data: S, isLoading: s } = te({
560
+ queryKey: M,
561
+ queryFn: () => b().then((l) => l.data)
562
+ }), { data: w } = te({
563
+ queryKey: U,
564
+ queryFn: () => b().then((l) => {
565
+ var B;
566
+ return ((B = l.meta) == null ? void 0 : B.can_add) ?? null;
567
+ }),
568
+ enabled: !s,
569
+ staleTime: 3e4
570
+ }), a = typeof w == "boolean" ? w : v, { data: N, isLoading: k } = te({
543
571
  queryKey: ["pipeline-all-owners", r, t],
544
572
  queryFn: () => p.request(
545
- Y(`/pipelines/instance/${r}/${t}/owners/all`)
546
- ).then((m) => m.data ?? null),
573
+ ie(`/pipelines/instance/${r}/${t}/owners/all`)
574
+ ).then((l) => l.data ?? null),
547
575
  enabled: !!i,
548
576
  staleTime: 3e4
549
- }), v = new Set((D ?? []).map((m) => m.user)), c = i ? (((S = E == null ? void 0 : E[i]) == null ? void 0 : S.owners) ?? []).filter((m) => !v.has(m.id)) : [], o = c.length + ((D == null ? void 0 : D.length) ?? 0), g = !!((B = u.find((m) => m.id === i)) != null && B.is_initial), f = !w && !l, { data: y } = Z({
577
+ }), A = new Set((S ?? []).map((l) => l.user)), W = i ? (((O = N == null ? void 0 : N[i]) == null ? void 0 : O.owners) ?? []).filter((l) => !A.has(l.id)) : [], c = W.length + ((S == null ? void 0 : S.length) ?? 0), y = !!((re = u.find((l) => l.id === i)) != null && re.is_initial), d = !s && !k, { data: m } = te({
550
578
  queryKey: ["pipeline-record-creator", r, t],
551
579
  queryFn: () => p.request(
552
- Y(`/pipelines/instance/${r}/${t}/creator`)
553
- ).then((m) => m.data ?? null),
554
- enabled: g && f && o === 0,
580
+ ie(`/pipelines/instance/${r}/${t}/creator`)
581
+ ).then((l) => l.data ?? null),
582
+ enabled: y && d && c === 0,
555
583
  staleTime: 6e4
556
- }), s = g && o === 0 && (y != null && y.name) ? y : null, a = () => {
557
- x.invalidateQueries({ queryKey: $ }), x.invalidateQueries({ queryKey: ["pipeline-instance", r, t] });
558
- }, A = ue({
584
+ }), g = y && c === 0 && (m != null && m.name) ? m : null, C = () => {
585
+ f.invalidateQueries({ queryKey: M }), f.invalidateQueries({ queryKey: ["pipeline-instance", r, t] });
586
+ }, h = he({
559
587
  mutationFn: () => p.request(
560
- be(`/pipelines/instance/${r}/${t}/owners`, {
561
- user: P,
562
- state: N || void 0
588
+ we(`/pipelines/instance/${r}/${t}/owners`, {
589
+ user: x,
590
+ state: _ || void 0
563
591
  })
564
592
  ),
565
593
  onSuccess: () => {
566
- a(), h(""), q(""), T(!1), X.success("Owner added");
594
+ C(), R(""), I(""), D(!1), ee.success("Owner added");
567
595
  },
568
- onError: () => X.error("Failed to add owner")
569
- }), M = ue({
570
- mutationFn: (m) => p.request(yt(`/pipelines/instance-owners/${m}`)),
596
+ // The server's reason (a 403 says why), not a bare status phrase.
597
+ onError: (l) => ee.error(Fe(l, "Failed to add owner"))
598
+ }), P = he({
599
+ mutationFn: (l) => p.request(St(`/pipelines/instance-owners/${l}`)),
571
600
  onSuccess: () => {
572
- a(), X.success("Owner removed");
601
+ C(), ee.success("Owner removed");
573
602
  },
574
- onError: () => X.error("Failed to remove owner")
575
- }), ee = (m) => {
576
- var z, Q;
577
- const H = ((z = m.first_name) == null ? void 0 : z[0]) ?? "", j = ((Q = m.last_name) == null ? void 0 : Q[0]) ?? "";
578
- return (`${H}${j}`.trim() || m.email[0] || "?").toUpperCase();
579
- }, R = (m) => {
580
- var H;
581
- return m ? ((H = u.find((j) => j.id === m || j.key === m)) == null ? void 0 : H.label) ?? m : null;
603
+ onError: () => ee.error("Failed to remove owner")
604
+ }), Q = (l) => {
605
+ var Z, X;
606
+ const B = ((Z = l.first_name) == null ? void 0 : Z[0]) ?? "", J = ((X = l.last_name) == null ? void 0 : X[0]) ?? "";
607
+ return (`${B}${J}`.trim() || l.email[0] || "?").toUpperCase();
608
+ }, G = (l) => {
609
+ var B;
610
+ return l ? ((B = u.find((J) => J.id === l || J.key === l)) == null ? void 0 : B.label) ?? l : null;
582
611
  };
583
612
  return /* @__PURE__ */ n("div", { children: [
584
613
  /* @__PURE__ */ n("div", { className: "mb-3 flex items-center justify-between", children: [
585
614
  /* @__PURE__ */ n("span", { className: "flex items-center gap-1.5 text-[11px] font-medium text-slate-400", children: [
586
- /* @__PURE__ */ e(Ge, { className: "h-3.5 w-3.5" }),
615
+ /* @__PURE__ */ e(st, { className: "h-3.5 w-3.5" }),
587
616
  "Owners",
588
- w || l ? /* @__PURE__ */ e("span", { className: "inline-block h-3 w-4 animate-pulse rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" }) : s ? null : /* @__PURE__ */ n("span", { className: "text-slate-300", children: [
617
+ s || k ? /* @__PURE__ */ e("span", { className: "inline-block h-3 w-4 animate-pulse rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" }) : g ? null : /* @__PURE__ */ n("span", { className: "text-slate-300", children: [
589
618
  "(",
590
- o,
619
+ c,
591
620
  ")"
592
621
  ] })
593
622
  ] }),
594
623
  /* @__PURE__ */ n("span", { className: "flex items-center gap-3", children: [
595
- i && /* @__PURE__ */ e($t, { collection: r, itemId: String(t) }),
596
- !b && /* @__PURE__ */ n(
624
+ i && /* @__PURE__ */ e(Ot, { collection: r, itemId: String(t) }),
625
+ !q && a && /* @__PURE__ */ n(
597
626
  "button",
598
627
  {
599
628
  type: "button",
600
- onClick: () => T(!0),
629
+ onClick: () => D(!0),
601
630
  className: "flex items-center gap-1 text-[11px] text-slate-400 transition-colors hover:text-nvr-cyan",
602
631
  children: [
603
- /* @__PURE__ */ e(xt, { className: "h-3 w-3" }),
632
+ /* @__PURE__ */ e(vt, { className: "h-3 w-3" }),
604
633
  "Add"
605
634
  ]
606
635
  }
607
636
  )
608
637
  ] })
609
638
  ] }),
610
- w || l ? /* @__PURE__ */ n("div", { className: "flex items-center gap-2 py-1.5 text-[12px] text-slate-400", children: [
611
- /* @__PURE__ */ e(te, { className: "h-3.5 w-3.5 animate-spin" }),
639
+ s || k ? /* @__PURE__ */ n("div", { className: "flex items-center gap-2 py-1.5 text-[12px] text-slate-400", children: [
640
+ /* @__PURE__ */ e(se, { className: "h-3.5 w-3.5 animate-spin" }),
612
641
  "Resolving owners…"
613
- ] }) : s ? /* @__PURE__ */ n("p", { className: "text-[12px] text-slate-500 dark:text-muted-foreground", children: [
614
- C ? "Back with" : "With",
642
+ ] }) : g ? /* @__PURE__ */ n("p", { className: "text-[12px] text-slate-500 dark:text-muted-foreground", children: [
643
+ T ? "Back with" : "With",
615
644
  " ",
616
- /* @__PURE__ */ e("span", { className: "font-medium text-slate-700 dark:text-foreground", children: s.name })
617
- ] }) : o === 0 ? /* @__PURE__ */ e("p", { className: "text-[12px] text-slate-400", children: "No owners assigned." }) : /* @__PURE__ */ n("div", { className: "space-y-px", children: [
618
- c.map((m) => {
619
- var z, Q;
620
- const H = [m.first_name, m.last_name].filter(Boolean).join(" ") || m.email, j = (`${((z = m.first_name) == null ? void 0 : z[0]) ?? ""}${((Q = m.last_name) == null ? void 0 : Q[0]) ?? ""}`.trim() || m.email[0] || "?").toUpperCase();
645
+ /* @__PURE__ */ e("span", { className: "font-medium text-slate-700 dark:text-foreground", children: g.name })
646
+ ] }) : c === 0 ? /* @__PURE__ */ e("p", { className: "text-[12px] text-slate-400", children: "No owners assigned." }) : /* @__PURE__ */ n("div", { className: "space-y-px", children: [
647
+ W.map((l) => {
648
+ var Z, X;
649
+ const B = [l.first_name, l.last_name].filter(Boolean).join(" ") || l.email, J = (`${((Z = l.first_name) == null ? void 0 : Z[0]) ?? ""}${((X = l.last_name) == null ? void 0 : X[0]) ?? ""}`.trim() || l.email[0] || "?").toUpperCase();
621
650
  return /* @__PURE__ */ n(
622
651
  "div",
623
652
  {
624
653
  className: "-mx-2 flex items-center gap-2.5 rounded-md px-2 py-1.5 transition-colors hover:bg-slate-50",
625
654
  children: [
626
655
  /* @__PURE__ */ e(
627
- St,
656
+ jt,
628
657
  {
629
- userId: m.id,
630
- alt: H,
658
+ userId: l.id,
659
+ alt: B,
631
660
  className: "h-6 w-6",
632
- fallback: /* @__PURE__ */ e("span", { className: "flex h-6 w-6 shrink-0 select-none items-center justify-center rounded-full bg-nvr-cyan/10 text-[10px] font-semibold text-nvr-navy/80", children: j })
661
+ fallback: /* @__PURE__ */ e("span", { className: "flex h-6 w-6 shrink-0 select-none items-center justify-center rounded-full bg-nvr-cyan/10 text-[10px] font-semibold text-nvr-navy/80", children: J })
633
662
  }
634
663
  ),
635
664
  /* @__PURE__ */ n("div", { className: "min-w-0 flex-1", children: [
636
- /* @__PURE__ */ e("span", { className: "block truncate text-[12px] font-medium text-slate-700", children: H }),
637
- /* @__PURE__ */ e("span", { className: "block truncate text-[11px] text-slate-400", children: m.email })
665
+ /* @__PURE__ */ e("span", { className: "block truncate text-[12px] font-medium text-slate-700", children: B }),
666
+ /* @__PURE__ */ e("span", { className: "block truncate text-[11px] text-slate-400", children: l.email })
638
667
  ] }),
639
668
  /* @__PURE__ */ e("span", { className: "shrink-0 rounded-full bg-nvr-cyan/10 px-1.5 py-0.5 text-[10px] font-medium text-nvr-navy/70 dark:text-nvr-cyan", children: "owner group" })
640
669
  ]
641
670
  },
642
- `group-${m.id}`
671
+ `group-${l.id}`
643
672
  );
644
673
  }),
645
- (D ?? []).map((m) => /* @__PURE__ */ n(
674
+ (S ?? []).map((l) => /* @__PURE__ */ n(
646
675
  "div",
647
676
  {
648
677
  className: "group -mx-2 flex items-center gap-2.5 rounded-md px-2 py-1.5 transition-colors hover:bg-slate-50",
649
678
  children: [
650
- /* @__PURE__ */ e("span", { className: "flex h-6 w-6 shrink-0 select-none items-center justify-center rounded-full bg-nvr-cyan/10 text-[10px] font-semibold text-nvr-navy/80", children: ee(m) }),
679
+ /* @__PURE__ */ e("span", { className: "flex h-6 w-6 shrink-0 select-none items-center justify-center rounded-full bg-nvr-cyan/10 text-[10px] font-semibold text-nvr-navy/80", children: Q(l) }),
651
680
  /* @__PURE__ */ n("div", { className: "min-w-0 flex-1", children: [
652
- /* @__PURE__ */ e("span", { className: "block truncate text-[12px] font-medium text-slate-700", children: [m.first_name, m.last_name].filter(Boolean).join(" ") || m.email }),
653
- /* @__PURE__ */ e("span", { className: "block truncate text-[11px] text-slate-400", children: m.email })
681
+ /* @__PURE__ */ e("span", { className: "block truncate text-[12px] font-medium text-slate-700", children: [l.first_name, l.last_name].filter(Boolean).join(" ") || l.email }),
682
+ /* @__PURE__ */ e("span", { className: "block truncate text-[11px] text-slate-400", children: l.email })
654
683
  ] }),
655
684
  /* @__PURE__ */ e("span", { className: "shrink-0 rounded-full bg-amber-50 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 dark:bg-amber-500/10 dark:text-amber-400", children: "manual" }),
656
- /* @__PURE__ */ e("span", { className: "shrink-0 rounded-full bg-slate-100 px-1.5 py-0.5 text-[10px] text-slate-500", children: m.state ? R(m.state) : "all states" }),
685
+ /* @__PURE__ */ e("span", { className: "shrink-0 rounded-full bg-slate-100 px-1.5 py-0.5 text-[10px] text-slate-500", children: l.state ? G(l.state) : "all states" }),
657
686
  /* @__PURE__ */ e(
658
687
  "button",
659
688
  {
660
689
  type: "button",
661
- onClick: () => M.mutate(m.id),
690
+ onClick: () => P.mutate(l.id),
662
691
  className: "shrink-0 rounded p-0.5 text-slate-300 opacity-0 transition-all hover:text-red-500 group-hover:opacity-100",
663
- children: /* @__PURE__ */ e(Je, { className: "h-3 w-3" })
692
+ children: /* @__PURE__ */ e(it, { className: "h-3 w-3" })
664
693
  }
665
694
  )
666
695
  ]
667
696
  },
668
- m.id
697
+ l.id
669
698
  ))
670
699
  ] }),
671
- b && /* @__PURE__ */ n("div", { className: "mt-3 space-y-2 rounded-lg border border-slate-200 bg-slate-50 dark:bg-slate-900/30 dark:border-border p-3", children: [
700
+ q && /* @__PURE__ */ n("div", { className: "mt-3 space-y-2 rounded-lg border border-slate-200 bg-slate-50 dark:bg-slate-900/30 dark:border-border p-3", children: [
672
701
  /* @__PURE__ */ e("p", { className: "text-[11px] font-semibold text-slate-500", children: "Add owner" }),
673
- /* @__PURE__ */ e(Lt, { value: P, onChange: h }),
674
- /* @__PURE__ */ n(Re, { open: F, onOpenChange: k, children: [
675
- /* @__PURE__ */ e(je, { asChild: !0, children: /* @__PURE__ */ n(
702
+ /* @__PURE__ */ e(Wt, { value: x, onChange: R }),
703
+ v ? /* @__PURE__ */ n(Ee, { open: L, onOpenChange: j, children: [
704
+ /* @__PURE__ */ e(Ie, { asChild: !0, children: /* @__PURE__ */ n(
676
705
  "button",
677
706
  {
678
707
  type: "button",
679
708
  className: "flex h-8 w-full items-center justify-between rounded-md border border-slate-200 bg-white px-2.5 text-left text-[13px] text-slate-700 transition-colors hover:border-slate-300 dark:border-border dark:bg-transparent dark:text-slate-300",
680
709
  children: [
681
- /* @__PURE__ */ e("span", { className: "truncate", children: N ? ((I = u.find((m) => m.id === N)) == null ? void 0 : I.label) ?? N : "All states" }),
682
- /* @__PURE__ */ e(oe, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
710
+ /* @__PURE__ */ e("span", { className: "truncate", children: _ ? ((F = u.find((l) => l.id === _)) == null ? void 0 : F.label) ?? _ : "All states" }),
711
+ /* @__PURE__ */ e(me, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
683
712
  ]
684
713
  }
685
714
  ) }),
686
- /* @__PURE__ */ e(Oe, { align: "start", sideOffset: 4, className: "w-52 p-1", children: ["", ...u.map((m) => m.id)].map((m) => {
687
- var z;
688
- const H = m === "" ? "All states" : ((z = u.find((Q) => Q.id === m)) == null ? void 0 : z.label) ?? m;
715
+ /* @__PURE__ */ e(Ue, { align: "start", sideOffset: 4, className: "w-52 p-1", children: ["", ...u.map((l) => l.id)].map((l) => {
716
+ var Z;
717
+ const B = l === "" ? "All states" : ((Z = u.find((X) => X.id === l)) == null ? void 0 : Z.label) ?? l;
689
718
  return /* @__PURE__ */ e(
690
719
  "button",
691
720
  {
692
721
  type: "button",
693
- className: pe(
722
+ className: xe(
694
723
  "flex w-full rounded px-2.5 py-1.5 text-left text-[13px] transition-colors hover:bg-slate-50 dark:hover:bg-white/5",
695
- N === m && "font-medium text-slate-800 dark:text-slate-200"
724
+ _ === l && "font-medium text-slate-800 dark:text-slate-200"
696
725
  ),
697
726
  onClick: () => {
698
- q(m), k(!1);
727
+ I(l), j(!1);
699
728
  },
700
- children: H
729
+ children: B
701
730
  },
702
- m
731
+ l
703
732
  );
704
733
  }) })
705
- ] }),
734
+ ] }) : /* @__PURE__ */ e("p", { className: "text-[11px] text-slate-500 dark:text-slate-400", children: "Hands off the current step." }),
706
735
  /* @__PURE__ */ n("div", { className: "flex items-center justify-end gap-2 pt-0.5", children: [
707
736
  /* @__PURE__ */ e(
708
- V,
737
+ Y,
709
738
  {
710
739
  type: "button",
711
740
  size: "sm",
712
741
  variant: "ghost",
713
742
  className: "h-7 text-[12px]",
714
743
  onClick: () => {
715
- T(!1), h(""), q("");
744
+ D(!1), R(""), I("");
716
745
  },
717
746
  children: "Cancel"
718
747
  }
719
748
  ),
720
749
  /* @__PURE__ */ e(
721
- V,
750
+ Y,
722
751
  {
723
752
  type: "button",
724
753
  size: "sm",
725
754
  className: "h-7 text-[12px]",
726
- disabled: !P || A.isPending,
727
- onClick: () => A.mutate(),
728
- children: A.isPending ? /* @__PURE__ */ e(te, { className: "h-3.5 w-3.5 animate-spin" }) : "Add"
755
+ disabled: !x || h.isPending,
756
+ onClick: () => h.mutate(),
757
+ children: h.isPending ? /* @__PURE__ */ e(se, { className: "h-3.5 w-3.5 animate-spin" }) : "Add"
729
758
  }
730
759
  )
731
760
  ] })
732
761
  ] })
733
762
  ] });
734
763
  }
735
- const Xe = {
764
+ const at = {
736
765
  out: "out of office",
737
766
  suspended: "suspended",
738
767
  redacted: "redacted"
739
768
  };
740
- function Mt({
769
+ function Vt({
741
770
  collection: r,
742
771
  item: t,
743
772
  states: u,
744
773
  currentStateId: i
745
774
  }) {
746
- const C = ce(), [p, x] = U(!1), { data: b, isLoading: T } = Z({
775
+ const T = fe(), [p, f] = K(!1), { data: v, isLoading: q } = te({
747
776
  queryKey: ["pipeline-all-owners", r, t],
748
- queryFn: () => C.request(
749
- Y(`/pipelines/instance/${r}/${t}/owners/all`)
750
- ).then((h) => h.data ?? null),
777
+ queryFn: () => T.request(
778
+ ie(`/pipelines/instance/${r}/${t}/owners/all`)
779
+ ).then((x) => x.data ?? null),
751
780
  enabled: p,
752
781
  staleTime: 3e4
753
- }), P = [...u].filter((h) => {
754
- var N;
755
- return !b || ((N = b[h.id]) == null ? void 0 : N.on_path) !== !1;
756
- }).sort((h, N) => h.sort - N.sort);
757
- return /* @__PURE__ */ n(Re, { open: p, onOpenChange: x, children: [
758
- /* @__PURE__ */ e(je, { asChild: !0, children: /* @__PURE__ */ e(
782
+ }), D = [...u].filter((x) => {
783
+ var R;
784
+ return !v || ((R = v[x.id]) == null ? void 0 : R.on_path) !== !1;
785
+ }).sort((x, R) => x.sort - R.sort);
786
+ return /* @__PURE__ */ n(Ee, { open: p, onOpenChange: f, children: [
787
+ /* @__PURE__ */ e(Ie, { asChild: !0, children: /* @__PURE__ */ e(
759
788
  "button",
760
789
  {
761
790
  type: "button",
762
791
  title: "View approval chain",
763
792
  className: "flex h-6 w-6 items-center justify-center rounded text-slate-400 transition-colors hover:bg-slate-100 hover:text-slate-600 dark:hover:bg-muted dark:hover:text-slate-300",
764
- onClick: (h) => h.stopPropagation(),
765
- children: /* @__PURE__ */ e(Ge, { className: "h-3.5 w-3.5" })
793
+ onClick: (x) => x.stopPropagation(),
794
+ children: /* @__PURE__ */ e(st, { className: "h-3.5 w-3.5" })
766
795
  }
767
796
  ) }),
768
- /* @__PURE__ */ n(Oe, { align: "end", sideOffset: 6, className: "w-[576px] p-0 overflow-hidden", children: [
797
+ /* @__PURE__ */ n(Ue, { align: "end", sideOffset: 6, className: "w-[576px] p-0 overflow-hidden", children: [
769
798
  /* @__PURE__ */ n("div", { className: "border-b border-slate-100 px-4 py-3", children: [
770
799
  /* @__PURE__ */ e("p", { className: "text-[12px] font-semibold text-slate-700", children: "Approval Chain" }),
771
800
  /* @__PURE__ */ e("p", { className: "text-[11px] text-slate-400 mt-0.5", children: "Owners per pipeline state" })
772
801
  ] }),
773
- /* @__PURE__ */ e("div", { className: "max-h-[504px] overflow-y-auto", children: T ? /* @__PURE__ */ e("div", { className: "space-y-px p-3", children: [1, 2, 3].map((h) => /* @__PURE__ */ e(ne, { className: "h-10 w-full" }, h)) }) : b ? /* @__PURE__ */ e("div", { className: "divide-y divide-slate-100 dark:divide-border/60", children: P.map((h) => {
774
- var w, E, l, v, c;
775
- const N = (((w = b[h.id]) == null ? void 0 : w.owners) ?? []).map((o) => ({
776
- id: o.id,
777
- name: [o.first_name, o.last_name].filter(Boolean).join(" ") || o.email
778
- })), q = h.id === i, F = ((E = b[h.id]) == null ? void 0 : E.skipped) === !0 && !q, k = (((l = b[h.id]) == null ? void 0 : l.skip_reasons) ?? []).filter(Boolean), $ = ((v = b[h.id]) == null ? void 0 : v.unavailable) ?? [], D = ((c = b[h.id]) == null ? void 0 : c.blocked) === !0 && !F;
802
+ /* @__PURE__ */ e("div", { className: "max-h-[504px] overflow-y-auto", children: q ? /* @__PURE__ */ e("div", { className: "space-y-px p-3", children: [1, 2, 3].map((x) => /* @__PURE__ */ e(le, { className: "h-10 w-full" }, x)) }) : v ? /* @__PURE__ */ e("div", { className: "divide-y divide-slate-100 dark:divide-border/60", children: D.map((x) => {
803
+ var U, b, S, s, w;
804
+ const R = (((U = v[x.id]) == null ? void 0 : U.owners) ?? []).map((a) => ({
805
+ id: a.id,
806
+ name: [a.first_name, a.last_name].filter(Boolean).join(" ") || a.email
807
+ })), _ = x.id === i, I = ((b = v[x.id]) == null ? void 0 : b.skipped) === !0 && !_, L = (((S = v[x.id]) == null ? void 0 : S.skip_reasons) ?? []).filter(Boolean), j = ((s = v[x.id]) == null ? void 0 : s.unavailable) ?? [], M = ((w = v[x.id]) == null ? void 0 : w.blocked) === !0 && !I;
779
808
  return /* @__PURE__ */ n(
780
809
  "div",
781
810
  {
782
- className: pe(
811
+ className: xe(
783
812
  "flex items-center gap-3 px-4 py-2.5",
784
813
  // Hex-with-alpha rather than bg-nvr-cyan/N — the
785
814
  // nvr-cyan token is an opaque var() so Tailwind silently
786
815
  // drops opacity modifiers on it. Kept very light so the
787
816
  // tint doesn't clash with the state badge's own color.
788
- q && "bg-nvr-cyan/[0.06] dark:bg-nvr-cyan/[0.11]",
789
- F && "opacity-60",
790
- D && "bg-red-50 dark:bg-red-500/10"
817
+ _ && "bg-nvr-cyan/[0.06] dark:bg-nvr-cyan/[0.11]",
818
+ I && "opacity-60",
819
+ M && "bg-red-50 dark:bg-red-500/10"
791
820
  ),
792
- "data-chain-blocked": D ? "" : void 0,
821
+ "data-chain-blocked": M ? "" : void 0,
793
822
  children: [
794
- /* @__PURE__ */ e(re, { label: h.label, color: h.color, small: !0 }),
795
- /* @__PURE__ */ e("div", { className: "flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-0.5", children: F ? (
823
+ /* @__PURE__ */ e(oe, { label: x.label, color: x.color, small: !0 }),
824
+ /* @__PURE__ */ e("div", { className: "flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-0.5", children: I ? (
796
825
  // Radix tooltip with zero delay — native `title` waits on
797
826
  // the OS hover timer, and a truncated reason needs its
798
827
  // full text the moment the cursor lands on it.
799
- /* @__PURE__ */ e(it, { delayDuration: 0, children: /* @__PURE__ */ n(Se, { children: [
800
- /* @__PURE__ */ e($e, { asChild: !0, children: /* @__PURE__ */ n("div", { className: "flex min-w-0 flex-1 cursor-default items-center gap-2", children: [
828
+ /* @__PURE__ */ e(mt, { delayDuration: 0, children: /* @__PURE__ */ n(Re, { children: [
829
+ /* @__PURE__ */ e(De, { asChild: !0, children: /* @__PURE__ */ n("div", { className: "flex min-w-0 flex-1 cursor-default items-center gap-2", children: [
801
830
  /* @__PURE__ */ e("span", { className: "inline-flex shrink-0 items-center gap-1 rounded-full border border-dashed border-slate-300 px-2 py-0.5 text-[10.5px] font-medium text-slate-400 dark:border-slate-600 dark:text-slate-500", children: "Skipped" }),
802
- k.length > 0 && /* @__PURE__ */ e("span", { className: "min-w-0 flex-1 truncate text-[11px] text-slate-400 dark:text-slate-500", children: k.join(" · ") })
831
+ L.length > 0 && /* @__PURE__ */ e("span", { className: "min-w-0 flex-1 truncate text-[11px] text-slate-400 dark:text-slate-500", children: L.join(" · ") })
803
832
  ] }) }),
804
833
  /* @__PURE__ */ n(
805
- qe,
834
+ Me,
806
835
  {
807
836
  side: "bottom",
808
837
  align: "start",
809
838
  className: "max-w-[420px] space-y-0.5 text-[11.5px] leading-snug",
810
839
  children: [
811
840
  /* @__PURE__ */ e("p", { className: "text-slate-500 dark:text-slate-400", children: "The pipeline will pass through this state without stopping:" }),
812
- k.length > 0 ? k.map((o) => /* @__PURE__ */ e("p", { children: o }, o)) : /* @__PURE__ */ e("p", { children: "Skip criteria currently match" })
841
+ L.length > 0 ? L.map((a) => /* @__PURE__ */ e("p", { children: a }, a)) : /* @__PURE__ */ e("p", { children: "Skip criteria currently match" })
813
842
  ]
814
843
  }
815
844
  )
816
845
  ] }) })
817
- ) : /* @__PURE__ */ n(ae, { children: [
818
- /* @__PURE__ */ e(Ct, { owners: N, max: 10, emptyLabel: "—" }),
819
- $.map((o) => /* @__PURE__ */ n(
846
+ ) : /* @__PURE__ */ n(de, { children: [
847
+ /* @__PURE__ */ e(Mt, { owners: R, max: 10, emptyLabel: "—" }),
848
+ j.map((a) => /* @__PURE__ */ n(
820
849
  "span",
821
850
  {
822
- "data-tip": `${o.name} is ${Xe[o.reason] ?? o.reason}${o.delegate ? ` — ${o.delegate.name} covers${o.delegate.expires_at ? ` until ${new Date(o.delegate.expires_at).toLocaleDateString()}` : ""}` : " and nobody is covering"}`,
823
- className: pe(
851
+ "data-tip": `${a.name} is ${at[a.reason] ?? a.reason}${a.delegate ? ` — ${a.delegate.name} covers${a.delegate.expires_at ? ` until ${new Date(a.delegate.expires_at).toLocaleDateString()}` : ""}` : " and nobody is covering"}`,
852
+ className: xe(
824
853
  "inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10.5px] font-medium",
825
- o.delegate ? "border-amber-200 bg-amber-50 text-amber-800 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200" : "border-red-200 bg-red-50 text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-300"
854
+ a.delegate ? "border-amber-200 bg-amber-50 text-amber-800 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200" : "border-red-200 bg-red-50 text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-300"
826
855
  ),
827
856
  children: [
828
- o.name,
829
- o.delegate ? /* @__PURE__ */ n(ae, { children: [
857
+ a.name,
858
+ a.delegate ? /* @__PURE__ */ n(de, { children: [
830
859
  " → ",
831
- o.delegate.name,
832
- o.delegate.expires_at && /* @__PURE__ */ n("span", { className: "opacity-70", children: [
860
+ a.delegate.name,
861
+ a.delegate.expires_at && /* @__PURE__ */ n("span", { className: "opacity-70", children: [
833
862
  ", until",
834
863
  " ",
835
- new Date(o.delegate.expires_at).toLocaleDateString(
864
+ new Date(a.delegate.expires_at).toLocaleDateString(
836
865
  void 0,
837
866
  {
838
867
  month: "short",
@@ -843,65 +872,65 @@ function Mt({
843
872
  ] }) : /* @__PURE__ */ n("span", { className: "opacity-80", children: [
844
873
  " ",
845
874
  "· ",
846
- Xe[o.reason] ?? o.reason
875
+ at[a.reason] ?? a.reason
847
876
  ] })
848
877
  ]
849
878
  },
850
- o.id
879
+ a.id
851
880
  )),
852
- D && /* @__PURE__ */ e("span", { className: "inline-flex items-center gap-1 rounded-full bg-red-600 px-2 py-0.5 text-[10.5px] font-semibold text-white", children: "No one can act here" })
881
+ M && /* @__PURE__ */ e("span", { className: "inline-flex items-center gap-1 rounded-full bg-red-600 px-2 py-0.5 text-[10.5px] font-semibold text-white", children: "No one can act here" })
853
882
  ] }) })
854
883
  ]
855
884
  },
856
- h.id
885
+ x.id
857
886
  );
858
887
  }) }) : /* @__PURE__ */ e("p", { className: "px-4 py-3 text-[12px] text-slate-400", children: "No pipeline configured." }) })
859
888
  ] })
860
889
  ] });
861
890
  }
862
- function mn({
891
+ function _n({
863
892
  collection: r,
864
893
  item: t,
865
894
  defaultExpanded: u,
866
895
  title: i,
867
- showApprovalChain: C,
896
+ showApprovalChain: T,
868
897
  hideActionsCollapsed: p,
869
- hideActionsExpanded: x,
870
- onBeforeTransition: b,
871
- addendumPending: T,
872
- addendumView: P,
873
- asRole: h
898
+ hideActionsExpanded: f,
899
+ onBeforeTransition: v,
900
+ addendumPending: q,
901
+ addendumView: D,
902
+ asRole: x
874
903
  }) {
875
904
  return t === "new" ? null : /* @__PURE__ */ e(
876
- Bt,
905
+ Gt,
877
906
  {
878
907
  collection: r,
879
908
  item: t,
880
909
  defaultExpanded: u,
881
910
  title: i,
882
- showApprovalChain: C,
911
+ showApprovalChain: T,
883
912
  hideActionsCollapsed: p,
884
- hideActionsExpanded: x,
885
- onBeforeTransition: b,
886
- addendumPending: T,
887
- addendumView: P,
888
- asRole: h
913
+ hideActionsExpanded: f,
914
+ onBeforeTransition: v,
915
+ addendumPending: q,
916
+ addendumView: D,
917
+ asRole: x
889
918
  },
890
919
  `${r}:${t}`
891
920
  );
892
921
  }
893
- function ut({ collection: r, item: t }) {
894
- const u = ce(), { data: i } = Z({
922
+ function gt({ collection: r, item: t }) {
923
+ const u = fe(), { data: i } = te({
895
924
  queryKey: ["approval-brief", r, String(t)],
896
- queryFn: () => u.request(Y(`/pipelines/instance/${r}/${t}/approval-brief`)).then((p) => p.data),
925
+ queryFn: () => u.request(ie(`/pipelines/instance/${r}/${t}/approval-brief`)).then((p) => p.data),
897
926
  staleTime: 3e4,
898
927
  retry: !1
899
928
  });
900
929
  if (!i) return null;
901
- const C = (p) => {
930
+ const T = (p) => {
902
931
  if (p == null || p === "") return "—";
903
- const x = String(p);
904
- return x.length > 36 ? `${x.slice(0, 36)}…` : x;
932
+ const f = String(p);
933
+ return f.length > 36 ? `${f.slice(0, 36)}…` : f;
905
934
  };
906
935
  return /* @__PURE__ */ n("div", { className: "rounded-md border border-slate-200 bg-white px-3 py-2 text-[11.5px] dark:border-border dark:bg-card", children: [
907
936
  /* @__PURE__ */ n("p", { className: "text-slate-500 dark:text-muted-foreground", children: [
@@ -911,7 +940,7 @@ function ut({ collection: r, item: t }) {
911
940
  i.days_in_state,
912
941
  "d ago):",
913
942
  " ",
914
- i.changed_total === 0 && i.comments === 0 && i.addendums.count === 0 ? /* @__PURE__ */ e("span", { children: "no changes to this record." }) : /* @__PURE__ */ n(ae, { children: [
943
+ i.changed_total === 0 && i.comments === 0 && i.addendums.count === 0 ? /* @__PURE__ */ e("span", { children: "no changes to this record." }) : /* @__PURE__ */ n(de, { children: [
915
944
  i.changed_total > 0 && /* @__PURE__ */ n("span", { children: [
916
945
  i.changed_total,
917
946
  " field",
@@ -943,11 +972,11 @@ function ut({ collection: r, item: t }) {
943
972
  p.field,
944
973
  ":",
945
974
  " ",
946
- p.old !== void 0 && /* @__PURE__ */ n(ae, { children: [
947
- /* @__PURE__ */ e("span", { className: "text-red-600 line-through dark:text-red-400", children: C(p.old) }),
975
+ p.old !== void 0 && /* @__PURE__ */ n(de, { children: [
976
+ /* @__PURE__ */ e("span", { className: "text-red-600 line-through dark:text-red-400", children: T(p.old) }),
948
977
  " "
949
978
  ] }),
950
- /* @__PURE__ */ e("span", { className: "text-emerald-600 dark:text-emerald-400", children: C(p.new) })
979
+ /* @__PURE__ */ e("span", { className: "text-emerald-600 dark:text-emerald-400", children: T(p.new) })
951
980
  ]
952
981
  },
953
982
  p.field
@@ -979,46 +1008,62 @@ function ut({ collection: r, item: t }) {
979
1008
  ))
980
1009
  ] });
981
1010
  }
982
- function Bt({
1011
+ function Gt({
983
1012
  collection: r,
984
1013
  item: t,
985
1014
  defaultExpanded: u,
986
1015
  title: i,
987
- showApprovalChain: C,
1016
+ showApprovalChain: T,
988
1017
  hideActionsCollapsed: p,
989
- hideActionsExpanded: x,
990
- onBeforeTransition: b,
991
- addendumPending: T,
992
- addendumView: P,
993
- asRole: h
1018
+ hideActionsExpanded: f,
1019
+ onBeforeTransition: v,
1020
+ addendumPending: q,
1021
+ addendumView: D,
1022
+ asRole: x
994
1023
  }) {
995
- var Be, Ee, Ie;
996
- const N = ce(), q = De(), [F, k] = U(""), [$, D] = U(null), [w, E] = U(!1), [l, v] = U(!1), [c, o] = U(null);
997
- et(r, t, "transition", !!$ || !!c);
998
- const g = wt(r, t, "transition"), f = se(!1);
999
- de(() => {
1000
- !f.current && u !== void 0 && (f.current = !0, v(u));
1024
+ var We, He, Ve;
1025
+ const R = fe(), _ = Oe(), [I, L] = K(""), [j, M] = K(null), [U, b] = K(!1), [S, s] = K(!1), [w, a] = K(null);
1026
+ dt(r, t, "transition", !!j || !!w);
1027
+ const N = $t(r, t, "transition"), k = ne(!1);
1028
+ ue(() => {
1029
+ !k.current && u !== void 0 && (k.current = !0, s(u));
1001
1030
  }, [u]);
1002
- const y = async (d) => {
1003
- if ($ === d) {
1004
- D(null);
1031
+ const A = ne(!1), W = (o) => {
1032
+ A.current || (A.current = !0, G.mutate(o, {
1033
+ onSettled: () => {
1034
+ A.current = !1;
1035
+ }
1036
+ }));
1037
+ }, c = async (o) => {
1038
+ if (A.current) return;
1039
+ if (j === o) {
1040
+ M(null);
1005
1041
  return;
1006
1042
  }
1007
- if (b && !await b()) return;
1008
- const _ = (z ?? []).find((O) => O.id === d), L = String((_ == null ? void 0 : _.comment_mode) ?? "none");
1009
- if (L !== "optional" && L !== "required") {
1010
- I.mutate({ transition_id: d });
1043
+ if (v) {
1044
+ A.current = !0;
1045
+ let z = !1;
1046
+ try {
1047
+ z = await v();
1048
+ } finally {
1049
+ A.current = !1;
1050
+ }
1051
+ if (!z) return;
1052
+ }
1053
+ const $ = (l ?? []).find((z) => z.id === o), E = String(($ == null ? void 0 : $.comment_mode) ?? "none");
1054
+ if (E !== "optional" && E !== "required") {
1055
+ W({ transition_id: o });
1011
1056
  return;
1012
1057
  }
1013
- D(d);
1014
- }, s = h ? ["pipeline-instance", r, t, h] : ["pipeline-instance", r, t], { data: a, isLoading: A } = Z({
1015
- queryKey: s,
1016
- queryFn: () => N.request(
1017
- Y(
1018
- `/pipelines/instance/${r}/${t}${h ? `?as_role=${encodeURIComponent(h)}` : ""}`
1058
+ M(o);
1059
+ }, y = x ? ["pipeline-instance", r, t, x] : ["pipeline-instance", r, t], { data: d, isLoading: m } = te({
1060
+ queryKey: y,
1061
+ queryFn: () => R.request(
1062
+ ie(
1063
+ `/pipelines/instance/${r}/${t}${x ? `?as_role=${encodeURIComponent(x)}` : ""}`
1019
1064
  )
1020
1065
  ).then(
1021
- (d) => d.data ?? {
1066
+ (o) => o.data ?? {
1022
1067
  instance: null,
1023
1068
  states: [],
1024
1069
  available_transitions: [],
@@ -1029,372 +1074,375 @@ function Bt({
1029
1074
  ),
1030
1075
  staleTime: 1e4
1031
1076
  });
1032
- de(
1033
- () => q.getQueryCache().subscribe((d) => {
1034
- if (d.type !== "updated" || d.action.type !== "success") return;
1035
- const _ = d.query.queryKey;
1036
- Array.isArray(_) && _[0] === "item" && _[1] === r && String(_[2]) === t && q.invalidateQueries({ queryKey: ["pipeline-instance", r, t] });
1077
+ ue(
1078
+ () => _.getQueryCache().subscribe((o) => {
1079
+ if (o.type !== "updated" || o.action.type !== "success") return;
1080
+ const $ = o.query.queryKey;
1081
+ Array.isArray($) && $[0] === "item" && $[1] === r && String($[2]) === t && _.invalidateQueries({ queryKey: ["pipeline-instance", r, t] });
1037
1082
  }),
1038
- [q, r, t]
1083
+ [_, r, t]
1039
1084
  );
1040
- const { data: M, isLoading: ee } = Z({
1085
+ const { data: g, isLoading: C } = te({
1041
1086
  queryKey: ["pipeline-all-owners", r, t],
1042
- queryFn: () => N.request(
1043
- Y(`/pipelines/instance/${r}/${t}/owners/all`)
1044
- ).then((d) => d.data ?? null),
1045
- enabled: l && !!(a != null && a.instance),
1087
+ queryFn: () => R.request(
1088
+ ie(`/pipelines/instance/${r}/${t}/owners/all`)
1089
+ ).then((o) => o.data ?? null),
1090
+ enabled: S && !!(d != null && d.instance),
1046
1091
  staleTime: 3e4
1047
- }), R = He(() => {
1048
- if (!M) return null;
1049
- const d = Object.entries(M);
1050
- return d.length === 0 || d.every(([, _]) => _.on_path === void 0) ? null : new Set(d.filter(([, _]) => _.on_path !== !1).map(([_]) => _));
1051
- }, [M]), S = He(() => {
1052
- if (!M) return null;
1053
- const d = /* @__PURE__ */ new Map();
1054
- for (const [_, L] of Object.entries(M))
1055
- L.skipped && d.set(_, L.skip_reasons ?? []);
1056
- return d;
1057
- }, [M]), B = ue({
1058
- mutationFn: () => N.request(be(`/pipelines/instance/${r}/${t}/start`, {})),
1092
+ }), h = et(() => {
1093
+ if (!g) return null;
1094
+ const o = Object.entries(g);
1095
+ return o.length === 0 || o.every(([, $]) => $.on_path === void 0) ? null : new Set(o.filter(([, $]) => $.on_path !== !1).map(([$]) => $));
1096
+ }, [g]), P = et(() => {
1097
+ if (!g) return null;
1098
+ const o = /* @__PURE__ */ new Map();
1099
+ for (const [$, E] of Object.entries(g))
1100
+ E.skipped && o.set($, E.skip_reasons ?? []);
1101
+ return o;
1102
+ }, [g]), Q = he({
1103
+ mutationFn: () => R.request(we(`/pipelines/instance/${r}/${t}/start`, {})),
1059
1104
  onSuccess: () => {
1060
- q.invalidateQueries({ queryKey: s }), X.success("Pipeline started");
1105
+ _.invalidateQueries({ queryKey: y }), ee.success("Pipeline started");
1061
1106
  },
1062
- onError: () => X.error("Failed to start pipeline")
1063
- }), I = ue({
1107
+ onError: () => ee.error("Failed to start pipeline")
1108
+ }), G = he({
1064
1109
  mutationFn: ({
1065
- transition_id: d,
1066
- comment: _,
1067
- reviewed: L
1068
- }) => N.request(
1069
- be(`/pipelines/instance/${r}/${t}/transition`, {
1070
- transition_id: d,
1071
- comment: _,
1072
- ...L ? { reviewed: !0 } : {}
1110
+ transition_id: o,
1111
+ comment: $,
1112
+ reviewed: E
1113
+ }) => R.request(
1114
+ we(`/pipelines/instance/${r}/${t}/transition`, {
1115
+ transition_id: o,
1116
+ comment: $,
1117
+ ...E ? { reviewed: !0 } : {}
1073
1118
  })
1074
1119
  ),
1075
1120
  onSuccess: () => {
1076
- q.invalidateQueries({ queryKey: s }), r === "nivaro_addendums" && q.invalidateQueries({ queryKey: ["addendums"] }), ye(q, r, String(t)), we(q, r, String(t)), k(""), D(null), o(null), X.success("Transition executed");
1121
+ _.invalidateQueries({ queryKey: y }), r === "nivaro_addendums" && _.invalidateQueries({ queryKey: ["addendums"] }), ve(_, r, String(t)), ke(_, r, String(t)), L(""), M(null), a(null), ee.success("Transition executed");
1077
1122
  },
1078
- onError: (d, _) => {
1079
- var W;
1080
- const L = mt(d);
1081
- if (L) {
1082
- o((G) => ({
1083
- payload: L,
1084
- transitionId: _.transition_id,
1085
- comment: _.comment,
1086
- revision: ((G == null ? void 0 : G.revision) ?? 0) + 1
1123
+ onError: (o, $) => {
1124
+ if (xt(o)) {
1125
+ _.invalidateQueries({ queryKey: y });
1126
+ return;
1127
+ }
1128
+ const E = bt(o);
1129
+ if (E) {
1130
+ a((H) => ({
1131
+ payload: E,
1132
+ transitionId: $.transition_id,
1133
+ comment: $.comment,
1134
+ revision: ((H == null ? void 0 : H.revision) ?? 0) + 1
1087
1135
  }));
1088
1136
  return;
1089
1137
  }
1090
- const O = d == null ? void 0 : d.response;
1091
- X.error((O == null ? void 0 : O.error) ?? ((W = O == null ? void 0 : O.data) == null ? void 0 : W.error) ?? "Failed to execute transition", {
1138
+ const z = o == null ? void 0 : o.response;
1139
+ ee.error(Fe(o, "Failed to execute transition"), {
1092
1140
  duration: 12e3,
1093
1141
  // #1867: a refusal carries "Why?" — the role, owner or access rule
1094
1142
  // that stopped it, and who can change it.
1095
- ...lt(d) ? {
1096
- action: ot(N, {
1143
+ ...ut(o) ? {
1144
+ action: pt(R, {
1097
1145
  collection: r,
1098
1146
  itemId: String(t),
1099
1147
  action: "transition",
1100
- transitionId: _.transition_id
1148
+ transitionId: $.transition_id
1101
1149
  })
1102
1150
  } : {}
1103
- }), o(null), D(null), ye(q, r, String(t)), we(q, r, String(t)), (O == null ? void 0 : O.status) === 409 && q.invalidateQueries({ queryKey: s });
1151
+ }), a(null), M(null), ve(_, r, String(t)), ke(_, r, String(t)), (z == null ? void 0 : z.status) === 409 && _.invalidateQueries({ queryKey: y });
1104
1152
  }
1105
- }), m = se(y);
1106
- m.current = y;
1107
- const H = se((a == null ? void 0 : a.available_transitions) ?? []);
1108
- if (H.current = (a == null ? void 0 : a.available_transitions) ?? [], de(() => {
1109
- const d = (_) => {
1110
- const L = _.detail;
1111
- if (!L || L.claimed || L.collection !== r || String(L.item) !== String(t)) return;
1112
- L.claimed = !0;
1113
- const O = String(L.transition_id).toUpperCase(), W = H.current.find((G) => String(G.id).toUpperCase() === O);
1114
- if (!W) {
1115
- X.error("That step is not available from where the record is now");
1153
+ }), O = ne(c);
1154
+ O.current = c;
1155
+ const re = ne((d == null ? void 0 : d.available_transitions) ?? []);
1156
+ if (re.current = (d == null ? void 0 : d.available_transitions) ?? [], ue(() => {
1157
+ const o = ($) => {
1158
+ const E = $.detail;
1159
+ if (!E || E.claimed || E.collection !== r || String(E.item) !== String(t)) return;
1160
+ E.claimed = !0;
1161
+ const z = String(E.transition_id).toUpperCase(), H = re.current.find((ce) => String(ce.id).toUpperCase() === z);
1162
+ if (!H) {
1163
+ ee.error("That step is not available from where the record is now");
1116
1164
  return;
1117
1165
  }
1118
- m.current(W.id);
1166
+ O.current(H.id);
1119
1167
  };
1120
- return window.addEventListener(ge, d), () => window.removeEventListener(ge, d);
1121
- }, [r, t]), A)
1168
+ return window.addEventListener(Ne, o), () => window.removeEventListener(Ne, o);
1169
+ }, [r, t]), m)
1122
1170
  return /* @__PURE__ */ e("div", { className: "overflow-hidden rounded-xl border border-slate-200 bg-white dark:border-border dark:bg-card", children: /* @__PURE__ */ n("div", { className: "flex w-full items-center gap-2.5 px-5 py-3.5", children: [
1123
- /* @__PURE__ */ e(ne, { className: "h-3.5 w-3.5 shrink-0 rounded" }),
1124
- /* @__PURE__ */ e(ne, { className: "h-4 w-20" }),
1125
- /* @__PURE__ */ e(ne, { className: "h-[22px] w-40 rounded-full" }),
1126
- /* @__PURE__ */ e(ne, { className: "ml-auto h-3.5 w-3.5 rounded" })
1171
+ /* @__PURE__ */ e(le, { className: "h-3.5 w-3.5 shrink-0 rounded" }),
1172
+ /* @__PURE__ */ e(le, { className: "h-4 w-20" }),
1173
+ /* @__PURE__ */ e(le, { className: "h-[22px] w-40 rounded-full" }),
1174
+ /* @__PURE__ */ e(le, { className: "ml-auto h-3.5 w-3.5 rounded" })
1127
1175
  ] }) });
1128
- if (!(a != null && a.binding)) return null;
1129
- const { instance: j, available_transitions: z, history: Q, states: me } = a, fe = new Map((me ?? []).map((d) => [d.id, d])), ie = (j == null ? void 0 : j.current_state_obj) ?? null, J = $ ? (z ?? []).find((d) => d.id === $) : null, Ne = J ? fe.get(J.to_state) : null, pt = j != null && j.completed_at && z ? z.filter(
1130
- (d) => d.from_state && String(d.from_state).toUpperCase() === String(j.current_state).toUpperCase()
1131
- ) : null, ke = j != null && j.completed_at ? pt ?? [] : z ?? [], Le = ke.length > 0, Fe = (d, _ = !1) => {
1132
- const L = /* @__PURE__ */ new Map();
1133
- for (const O of d) {
1134
- const W = L.get(O.label) ?? [];
1135
- W.push(O), L.set(O.label, W);
1176
+ if (!(d != null && d.binding)) return null;
1177
+ const { instance: F, available_transitions: l, history: B, states: J } = d, Z = new Map((J ?? []).map((o) => [o.id, o])), X = (F == null ? void 0 : F.current_state_obj) ?? null, ae = j ? (l ?? []).find((o) => o.id === j) : null, Ce = ae ? Z.get(ae.to_state) : null, yt = F != null && F.completed_at && l ? l.filter(
1178
+ (o) => o.from_state && String(o.from_state).toUpperCase() === String(F.current_state).toUpperCase()
1179
+ ) : null, Se = F != null && F.completed_at ? yt ?? [] : l ?? [], Qe = Se.length > 0, ze = (o, $ = !1) => {
1180
+ const E = /* @__PURE__ */ new Map();
1181
+ for (const z of o) {
1182
+ const H = E.get(z.label) ?? [];
1183
+ H.push(z), E.set(z.label, H);
1136
1184
  }
1137
- return Array.from(L.entries()).map(([O, W]) => {
1138
- var ze, Ke;
1139
- const G = ((ze = W[0]) == null ? void 0 : ze.color) ?? null, he = W.some((K) => K.id === $), Ue = (K) => G ? K ? { backgroundColor: G, borderColor: G } : { borderColor: G, color: G } : void 0;
1140
- if (W.length === 1) {
1141
- const K = W[0], le = I.isPending && ((Ke = I.variables) == null ? void 0 : Ke.transition_id) === K.id;
1185
+ return Array.from(E.entries()).map(([z, H]) => {
1186
+ var Xe, Je;
1187
+ const ce = ((Xe = H[0]) == null ? void 0 : Xe.color) ?? null, be = H.some((V) => V.id === j), Ge = (V) => ce ? V ? { backgroundColor: ce, borderColor: ce } : { borderColor: ce, color: ce } : void 0;
1188
+ if (H.length === 1) {
1189
+ const V = H[0], pe = G.isPending && ((Je = G.variables) == null ? void 0 : Je.transition_id) === V.id;
1142
1190
  return /* @__PURE__ */ n(
1143
- V,
1191
+ Y,
1144
1192
  {
1145
1193
  size: "sm",
1146
- variant: he ? "default" : "outline",
1147
- className: `${_ ? "h-7 text-[11px]" : "text-[12px]"} gap-1.5`,
1148
- style: Ue(he),
1149
- disabled: I.isPending,
1150
- onClick: () => y(K.id),
1194
+ variant: be ? "default" : "outline",
1195
+ className: `${$ ? "h-7 text-[11px]" : "text-[12px]"} gap-1.5`,
1196
+ style: Ge(be),
1197
+ disabled: G.isPending,
1198
+ onClick: () => c(V.id),
1151
1199
  children: [
1152
- le && /* @__PURE__ */ e(te, { className: "h-3 w-3 animate-spin" }),
1153
- O
1200
+ pe && /* @__PURE__ */ e(se, { className: "h-3 w-3 animate-spin" }),
1201
+ z
1154
1202
  ]
1155
1203
  },
1156
- O
1204
+ z
1157
1205
  );
1158
1206
  }
1159
- return /* @__PURE__ */ n(nt, { children: [
1160
- /* @__PURE__ */ e(rt, { asChild: !0, children: /* @__PURE__ */ n(
1161
- V,
1207
+ return /* @__PURE__ */ n(qe, { children: [
1208
+ /* @__PURE__ */ e(Ae, { asChild: !0, children: /* @__PURE__ */ n(
1209
+ Y,
1162
1210
  {
1163
1211
  size: "sm",
1164
- variant: he ? "default" : "outline",
1165
- className: `${_ ? "h-7 text-[11px]" : "text-[12px]"} gap-1.5`,
1166
- style: Ue(he),
1167
- disabled: I.isPending,
1212
+ variant: be ? "default" : "outline",
1213
+ className: `${$ ? "h-7 text-[11px]" : "text-[12px]"} gap-1.5`,
1214
+ style: Ge(be),
1215
+ disabled: G.isPending,
1168
1216
  children: [
1169
- O,
1170
- /* @__PURE__ */ e(oe, { className: "h-3 w-3" })
1217
+ z,
1218
+ /* @__PURE__ */ e(me, { className: "h-3 w-3" })
1171
1219
  ]
1172
1220
  }
1173
1221
  ) }),
1174
- /* @__PURE__ */ e(at, { align: "start", children: [...W].sort(
1175
- (K, le) => {
1176
- var Qe, We;
1177
- return (((Qe = fe.get(K.to_state)) == null ? void 0 : Qe.sort) ?? 999) - (((We = fe.get(le.to_state)) == null ? void 0 : We.sort) ?? 999);
1222
+ /* @__PURE__ */ e(Pe, { align: "start", children: [...H].sort(
1223
+ (V, pe) => {
1224
+ var Ze, Ye;
1225
+ return (((Ze = Z.get(V.to_state)) == null ? void 0 : Ze.sort) ?? 999) - (((Ye = Z.get(pe.to_state)) == null ? void 0 : Ye.sort) ?? 999);
1178
1226
  }
1179
- ).map((K) => {
1180
- var le;
1181
- return /* @__PURE__ */ n(st, { onSelect: () => y(K.id), children: [
1182
- K.color && /* @__PURE__ */ e(
1227
+ ).map((V) => {
1228
+ var pe;
1229
+ return /* @__PURE__ */ n(ge, { onSelect: () => c(V.id), children: [
1230
+ V.color && /* @__PURE__ */ e(
1183
1231
  "span",
1184
1232
  {
1185
1233
  className: "mr-2 inline-block h-2 w-2 shrink-0 rounded-full",
1186
- style: { backgroundColor: K.color }
1234
+ style: { backgroundColor: V.color }
1187
1235
  }
1188
1236
  ),
1189
- ((le = fe.get(K.to_state)) == null ? void 0 : le.label) ?? K.to_state
1190
- ] }, K.id);
1237
+ ((pe = Z.get(V.to_state)) == null ? void 0 : pe.label) ?? V.to_state
1238
+ ] }, V.id);
1191
1239
  }) })
1192
- ] }, O);
1240
+ ] }, z);
1193
1241
  });
1194
- }, Me = /* @__PURE__ */ n("div", { className: "space-y-3 rounded-lg border border-slate-200 bg-slate-50 dark:bg-slate-900/30 dark:border-border p-3.5", children: [
1242
+ }, Ke = /* @__PURE__ */ n("div", { className: "space-y-3 rounded-lg border border-slate-200 bg-slate-50 dark:bg-slate-900/30 dark:border-border p-3.5", children: [
1195
1243
  /* @__PURE__ */ n("div", { className: "flex flex-wrap items-center gap-2", children: [
1196
1244
  /* @__PURE__ */ e("span", { className: "text-[11px] font-semibold text-slate-400", children: "Confirming" }),
1197
- J && /* @__PURE__ */ e("span", { className: "text-[12px] font-medium text-slate-700", children: J.label }),
1198
- ie && Ne && /* @__PURE__ */ n("div", { className: "ml-auto flex items-center gap-1.5", children: [
1199
- /* @__PURE__ */ e(re, { label: ie.label, color: ie.color, small: !0 }),
1200
- /* @__PURE__ */ e(Ae, { className: "h-3 w-3 shrink-0 text-slate-300" }),
1201
- /* @__PURE__ */ e(re, { label: Ne.label, color: Ne.color, small: !0 })
1245
+ ae && /* @__PURE__ */ e("span", { className: "text-[12px] font-medium text-slate-700", children: ae.label }),
1246
+ X && Ce && /* @__PURE__ */ n("div", { className: "ml-auto flex items-center gap-1.5", children: [
1247
+ /* @__PURE__ */ e(oe, { label: X.label, color: X.color, small: !0 }),
1248
+ /* @__PURE__ */ e(Be, { className: "h-3 w-3 shrink-0 text-slate-300" }),
1249
+ /* @__PURE__ */ e(oe, { label: Ce.label, color: Ce.color, small: !0 })
1202
1250
  ] })
1203
1251
  ] }),
1204
- /* @__PURE__ */ e(ut, { collection: r, item: t }),
1252
+ /* @__PURE__ */ e(gt, { collection: r, item: t }),
1205
1253
  /* @__PURE__ */ e(
1206
1254
  "input",
1207
1255
  {
1208
1256
  type: "text",
1209
- value: F,
1210
- onChange: (d) => k(d.target.value),
1211
- placeholder: String((J == null ? void 0 : J.comment_mode) ?? "") === "required" ? "Add a note (required)" : "Add a comment (optional)",
1257
+ value: I,
1258
+ onChange: (o) => L(o.target.value),
1259
+ placeholder: String((ae == null ? void 0 : ae.comment_mode) ?? "") === "required" ? "Add a note (required)" : "Add a comment (optional)",
1212
1260
  className: "w-full rounded-md border border-slate-200 bg-white px-3 py-1.5 text-[13px] placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-nvr-cyan/30"
1213
1261
  }
1214
1262
  ),
1215
1263
  /* @__PURE__ */ n("div", { className: "flex items-center justify-end gap-2", children: [
1216
1264
  /* @__PURE__ */ e(
1217
- V,
1265
+ Y,
1218
1266
  {
1219
1267
  type: "button",
1220
1268
  size: "sm",
1221
1269
  variant: "ghost",
1222
1270
  className: "h-7 text-[12px]",
1223
- onClick: () => D(null),
1271
+ onClick: () => M(null),
1224
1272
  children: "Cancel"
1225
1273
  }
1226
1274
  ),
1227
1275
  /* @__PURE__ */ e(
1228
- V,
1276
+ Y,
1229
1277
  {
1230
1278
  type: "button",
1231
1279
  size: "sm",
1232
1280
  className: "h-7 gap-1.5 text-[12px]",
1233
- disabled: I.isPending || String((J == null ? void 0 : J.comment_mode) ?? "") === "required" && F.trim() === "",
1234
- onClick: () => I.mutate({
1235
- transition_id: $,
1236
- comment: F.trim() || void 0
1281
+ disabled: G.isPending || String((ae == null ? void 0 : ae.comment_mode) ?? "") === "required" && I.trim() === "",
1282
+ onClick: () => W({
1283
+ transition_id: j,
1284
+ comment: I.trim() || void 0
1237
1285
  }),
1238
- children: I.isPending ? /* @__PURE__ */ e(te, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ n(ae, { children: [
1286
+ children: G.isPending ? /* @__PURE__ */ e(se, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ n(de, { children: [
1239
1287
  /* @__PURE__ */ e("span", { children: "Confirm" }),
1240
- /* @__PURE__ */ e(ve, { className: "h-3 w-3" })
1288
+ /* @__PURE__ */ e(_e, { className: "h-3 w-3" })
1241
1289
  ] })
1242
1290
  }
1243
1291
  )
1244
1292
  ] })
1245
1293
  ] });
1246
- return /* @__PURE__ */ n(ae, { children: [
1294
+ return /* @__PURE__ */ n(de, { children: [
1247
1295
  /* @__PURE__ */ n(
1248
1296
  "div",
1249
1297
  {
1250
- className: `overflow-hidden rounded-xl border bg-white dark:bg-card ${P ? "border-amber-300 dark:border-amber-600/50" : "border-slate-200 dark:border-border"}`,
1298
+ className: `overflow-hidden rounded-xl border bg-white dark:bg-card ${D ? "border-amber-300 dark:border-amber-600/50" : "border-slate-200 dark:border-border"}`,
1251
1299
  children: [
1252
1300
  /* @__PURE__ */ n(
1253
1301
  "div",
1254
1302
  {
1255
1303
  role: "button",
1256
1304
  tabIndex: 0,
1257
- onClick: () => v((d) => !d),
1258
- onKeyDown: (d) => (d.key === "Enter" || d.key === " ") && v((_) => !_),
1305
+ onClick: () => s((o) => !o),
1306
+ onKeyDown: (o) => (o.key === "Enter" || o.key === " ") && s(($) => !$),
1259
1307
  className: "flex w-full cursor-pointer items-center gap-2.5 px-5 py-3.5 transition-colors hover:bg-slate-50/50 dark:hover:bg-white/[0.02]",
1260
1308
  children: [
1261
- /* @__PURE__ */ e(_e, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
1309
+ /* @__PURE__ */ e($e, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
1262
1310
  /* @__PURE__ */ e("span", { className: "text-[13px] font-medium text-slate-800 dark:text-slate-200", children: i || "Pipeline" }),
1263
1311
  /* @__PURE__ */ n("div", { className: "flex items-center gap-1.5", children: [
1264
- P && /* @__PURE__ */ e("span", { className: "flex items-center gap-1 rounded-full border border-amber-200 bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-700 dark:border-amber-500/20 dark:bg-amber-500/10 dark:text-amber-400", children: "Addendum workflow" }),
1265
- ie && /* @__PURE__ */ e(re, { label: ie.label, color: ie.color }),
1266
- (((Be = a == null ? void 0 : a.auto_held) == null ? void 0 : Be.length) ?? 0) > 0 && /* @__PURE__ */ n(
1312
+ D && /* @__PURE__ */ e("span", { className: "flex items-center gap-1 rounded-full border border-amber-200 bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-700 dark:border-amber-500/20 dark:bg-amber-500/10 dark:text-amber-400", children: "Addendum workflow" }),
1313
+ X && /* @__PURE__ */ e(oe, { label: X.label, color: X.color }),
1314
+ (((We = d == null ? void 0 : d.auto_held) == null ? void 0 : We.length) ?? 0) > 0 && /* @__PURE__ */ n(
1267
1315
  "span",
1268
1316
  {
1269
1317
  className: "flex items-center gap-1 rounded-full border border-amber-200 bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-700 dark:border-amber-500/20 dark:bg-amber-500/10 dark:text-amber-400",
1270
- "data-tip": ((a == null ? void 0 : a.auto_held) ?? []).map((d) => `${d.transition_label ?? "Automatic move"}: ${d.error ?? "refused"}`).join(`
1318
+ "data-tip": ((d == null ? void 0 : d.auto_held) ?? []).map((o) => `${o.transition_label ?? "Automatic move"}: ${o.error ?? "refused"}`).join(`
1271
1319
  `),
1272
1320
  "data-pipeline-auto-held-pill": !0,
1273
1321
  children: [
1274
- /* @__PURE__ */ e(ft, { className: "h-3 w-3 shrink-0" }),
1322
+ /* @__PURE__ */ e(wt, { className: "h-3 w-3 shrink-0" }),
1275
1323
  "Needs a person"
1276
1324
  ]
1277
1325
  }
1278
1326
  ),
1279
- T && /* @__PURE__ */ n("span", { className: "flex items-center gap-1 rounded-full bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-700 border border-amber-200 dark:bg-amber-500/10 dark:text-amber-400 dark:border-amber-500/20", children: [
1327
+ q && /* @__PURE__ */ n("span", { className: "flex items-center gap-1 rounded-full bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-700 border border-amber-200 dark:bg-amber-500/10 dark:text-amber-400 dark:border-amber-500/20", children: [
1280
1328
  /* @__PURE__ */ e("span", { className: "h-1.5 w-1.5 rounded-full bg-amber-400 animate-pulse shrink-0" }),
1281
1329
  "Addendum in review"
1282
1330
  ] }),
1283
- g.length > 0 && /* @__PURE__ */ n(
1331
+ N.length > 0 && /* @__PURE__ */ n(
1284
1332
  "span",
1285
1333
  {
1286
1334
  className: "flex items-center gap-1 rounded-full border border-sky-200 bg-sky-50 px-2 py-0.5 text-[11px] font-medium text-sky-700 dark:border-sky-500/20 dark:bg-sky-500/10 dark:text-sky-300",
1287
1335
  "data-pipeline-approving": !0,
1288
1336
  children: [
1289
1337
  /* @__PURE__ */ e("span", { className: "h-1.5 w-1.5 shrink-0 animate-pulse rounded-full bg-sky-400" }),
1290
- vt(g, "approving")
1338
+ Tt(N, "approving")
1291
1339
  ]
1292
1340
  }
1293
1341
  )
1294
1342
  ] }),
1295
- /* @__PURE__ */ n("div", { className: "ml-auto flex items-center gap-2", onClick: (d) => d.stopPropagation(), children: [
1296
- !l && Le && !p && /* @__PURE__ */ e("div", { className: "flex flex-wrap items-center gap-1.5", children: Fe(ke, !0) }),
1297
- !l && !j && (a == null ? void 0 : a.binding) && /* @__PURE__ */ n(
1298
- V,
1343
+ /* @__PURE__ */ n("div", { className: "ml-auto flex items-center gap-2", onClick: (o) => o.stopPropagation(), children: [
1344
+ !S && Qe && !p && /* @__PURE__ */ e("div", { className: "flex flex-wrap items-center gap-1.5", children: ze(Se, !0) }),
1345
+ !S && !F && (d == null ? void 0 : d.binding) && /* @__PURE__ */ n(
1346
+ Y,
1299
1347
  {
1300
1348
  size: "sm",
1301
1349
  variant: "outline",
1302
1350
  className: "h-7 gap-1.5 text-[11px]",
1303
- onClick: (d) => {
1304
- d.stopPropagation(), B.mutate();
1351
+ onClick: (o) => {
1352
+ o.stopPropagation(), Q.mutate();
1305
1353
  },
1306
- disabled: B.isPending,
1354
+ disabled: Q.isPending,
1307
1355
  children: [
1308
- B.isPending ? /* @__PURE__ */ e(te, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ e(_e, { className: "h-3 w-3" }),
1356
+ Q.isPending ? /* @__PURE__ */ e(se, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ e($e, { className: "h-3 w-3" }),
1309
1357
  "Start"
1310
1358
  ]
1311
1359
  }
1312
1360
  ),
1313
- C && ((a == null ? void 0 : a.binding) || (a == null ? void 0 : a.instance)) && /* @__PURE__ */ e(
1314
- Mt,
1361
+ T && ((d == null ? void 0 : d.binding) || (d == null ? void 0 : d.instance)) && /* @__PURE__ */ e(
1362
+ Vt,
1315
1363
  {
1316
1364
  collection: r,
1317
1365
  item: t,
1318
- states: me ?? [],
1319
- currentStateId: ((Ee = a == null ? void 0 : a.instance) == null ? void 0 : Ee.current_state) ?? null
1366
+ states: J ?? [],
1367
+ currentStateId: ((He = d == null ? void 0 : d.instance) == null ? void 0 : He.current_state) ?? null
1320
1368
  }
1321
1369
  )
1322
1370
  ] }),
1323
1371
  /* @__PURE__ */ e(
1324
- oe,
1372
+ me,
1325
1373
  {
1326
- className: pe(
1374
+ className: xe(
1327
1375
  "h-3.5 w-3.5 shrink-0 text-slate-400 transition-transform duration-150",
1328
- l && "rotate-180"
1376
+ S && "rotate-180"
1329
1377
  )
1330
1378
  }
1331
1379
  )
1332
1380
  ]
1333
1381
  }
1334
1382
  ),
1335
- !l && $ && /* @__PURE__ */ e("div", { className: "border-t border-slate-100 dark:border-border/60 px-4 py-3", children: Me }),
1336
- l && /* @__PURE__ */ n("div", { className: "border-t border-slate-100 dark:border-border/60", children: [
1337
- /* @__PURE__ */ e(At, { held: (a == null ? void 0 : a.auto_held) ?? [] }),
1338
- T && /* @__PURE__ */ n("div", { className: "flex items-center gap-2 border-b border-amber-100 bg-amber-50 px-5 py-2.5 dark:border-amber-500/20 dark:bg-amber-500/10", children: [
1383
+ !S && j && /* @__PURE__ */ e("div", { className: "border-t border-slate-100 dark:border-border/60 px-4 py-3", children: Ke }),
1384
+ S && /* @__PURE__ */ n("div", { className: "border-t border-slate-100 dark:border-border/60", children: [
1385
+ /* @__PURE__ */ e(Ut, { held: (d == null ? void 0 : d.auto_held) ?? [] }),
1386
+ q && /* @__PURE__ */ n("div", { className: "flex items-center gap-2 border-b border-amber-100 bg-amber-50 px-5 py-2.5 dark:border-amber-500/20 dark:bg-amber-500/10", children: [
1339
1387
  /* @__PURE__ */ e("span", { className: "h-1.5 w-1.5 rounded-full bg-amber-400 shrink-0" }),
1340
1388
  /* @__PURE__ */ e("p", { className: "text-[12px] text-amber-700 dark:text-amber-400", children: "An addendum is in review — coordinate transitions carefully." })
1341
1389
  ] }),
1342
- j ? /* @__PURE__ */ n("div", { className: "divide-y divide-slate-100 dark:divide-border/60", children: [
1343
- (me ?? []).length > 1 && /* @__PURE__ */ n("div", { className: "space-y-3 px-5 py-4", children: [
1344
- ee ? (
1390
+ F ? /* @__PURE__ */ n("div", { className: "divide-y divide-slate-100 dark:divide-border/60", children: [
1391
+ (J ?? []).length > 1 && /* @__PURE__ */ n("div", { className: "space-y-3 px-5 py-4", children: [
1392
+ C ? (
1345
1393
  // Path pruning arrives with the owners query — rendering
1346
1394
  // the UNPRUNED track first meant every state briefly
1347
1395
  // showed, then snapped into formation. Hold a same-height
1348
1396
  // placeholder until the real shape is known.
1349
1397
  /* @__PURE__ */ n("div", { className: "flex h-[52px] items-center gap-2", children: [
1350
- [0, 1, 2, 3, 4].map((d) => /* @__PURE__ */ n("span", { className: "flex items-center gap-2", children: [
1351
- /* @__PURE__ */ e(ne, { className: "h-7 w-7 rounded-full" }),
1352
- d < 4 && /* @__PURE__ */ e(ne, { className: "h-0.5 w-10" })
1353
- ] }, d)),
1354
- /* @__PURE__ */ e(ne, { className: "ml-2 h-3 w-24" })
1398
+ [0, 1, 2, 3, 4].map((o) => /* @__PURE__ */ n("span", { className: "flex items-center gap-2", children: [
1399
+ /* @__PURE__ */ e(le, { className: "h-7 w-7 rounded-full" }),
1400
+ o < 4 && /* @__PURE__ */ e(le, { className: "h-0.5 w-10" })
1401
+ ] }, o)),
1402
+ /* @__PURE__ */ e(le, { className: "ml-2 h-3 w-24" })
1355
1403
  ] })
1356
1404
  ) : /* @__PURE__ */ e(
1357
- jt,
1405
+ zt,
1358
1406
  {
1359
- states: me,
1360
- allTransitions: (a == null ? void 0 : a.all_transitions) ?? [],
1361
- availableTransitions: z ?? [],
1362
- currentStateId: j.current_state,
1363
- history: Q ?? [],
1364
- onPathIds: R,
1365
- skippedStates: S
1407
+ states: J,
1408
+ allTransitions: (d == null ? void 0 : d.all_transitions) ?? [],
1409
+ availableTransitions: l ?? [],
1410
+ currentStateId: F.current_state,
1411
+ history: B ?? [],
1412
+ onPathIds: h,
1413
+ skippedStates: P
1366
1414
  }
1367
1415
  ),
1368
- (a == null ? void 0 : a.branches) && /* @__PURE__ */ e(qt, { data: a.branches }),
1416
+ (d == null ? void 0 : d.branches) && /* @__PURE__ */ e(Bt, { data: d.branches }),
1369
1417
  /* @__PURE__ */ e(
1370
- Rt,
1418
+ Qt,
1371
1419
  {
1372
- history: Q ?? [],
1373
- completedAt: j.completed_at
1420
+ history: B ?? [],
1421
+ completedAt: F.completed_at
1374
1422
  }
1375
1423
  )
1376
1424
  ] }),
1377
1425
  /* @__PURE__ */ n("div", { className: "space-y-3 px-5 py-4", children: [
1378
- !j.completed_at && /* @__PURE__ */ e(Tt, { collection: r, itemId: String(t) }),
1426
+ !F.completed_at && /* @__PURE__ */ e(Ft, { collection: r, itemId: String(t) }),
1379
1427
  /* @__PURE__ */ e(
1380
- Ft,
1428
+ Ht,
1381
1429
  {
1382
1430
  collection: r,
1383
1431
  item: t,
1384
- states: me ?? [],
1385
- currentStateId: ((Ie = a == null ? void 0 : a.instance) == null ? void 0 : Ie.current_state) ?? null,
1386
- returned: ((a == null ? void 0 : a.history) ?? []).some(
1387
- (d) => {
1388
- var _;
1389
- return !!d.from_state && d.to_state === ((_ = a == null ? void 0 : a.instance) == null ? void 0 : _.current_state);
1432
+ states: J ?? [],
1433
+ currentStateId: ((Ve = d == null ? void 0 : d.instance) == null ? void 0 : Ve.current_state) ?? null,
1434
+ returned: ((d == null ? void 0 : d.history) ?? []).some(
1435
+ (o) => {
1436
+ var $;
1437
+ return !!o.from_state && o.to_state === (($ = d == null ? void 0 : d.instance) == null ? void 0 : $.current_state);
1390
1438
  }
1391
1439
  )
1392
1440
  }
1393
1441
  )
1394
1442
  ] }),
1395
- Le && !x && /* @__PURE__ */ n("div", { className: "space-y-3 px-5 py-4", children: [
1396
- /* @__PURE__ */ e("div", { className: "flex flex-wrap justify-end gap-2", children: Fe(ke) }),
1397
- $ && Me
1443
+ Qe && !f && /* @__PURE__ */ n("div", { className: "space-y-3 px-5 py-4", children: [
1444
+ /* @__PURE__ */ e("div", { className: "flex flex-wrap justify-end gap-2", children: ze(Se) }),
1445
+ j && Ke
1398
1446
  ] }),
1399
1447
  /* @__PURE__ */ n("div", { className: "px-5 py-3", children: [
1400
1448
  /* @__PURE__ */ n(
@@ -1402,14 +1450,14 @@ function Bt({
1402
1450
  {
1403
1451
  type: "button",
1404
1452
  className: "flex items-center gap-1.5 text-[12px] text-slate-400 transition-colors hover:text-slate-600",
1405
- onClick: () => E((d) => !d),
1453
+ onClick: () => b((o) => !o),
1406
1454
  children: [
1407
1455
  /* @__PURE__ */ e(
1408
- oe,
1456
+ me,
1409
1457
  {
1410
- className: pe(
1458
+ className: xe(
1411
1459
  "h-3.5 w-3.5 transition-transform duration-200",
1412
- w && "rotate-180"
1460
+ U && "rotate-180"
1413
1461
  )
1414
1462
  }
1415
1463
  ),
@@ -1417,26 +1465,26 @@ function Bt({
1417
1465
  " ",
1418
1466
  /* @__PURE__ */ n("span", { className: "tabular-nums", children: [
1419
1467
  "(",
1420
- (Q == null ? void 0 : Q.length) ?? 0,
1468
+ (B == null ? void 0 : B.length) ?? 0,
1421
1469
  ")"
1422
1470
  ] })
1423
1471
  ]
1424
1472
  }
1425
1473
  ),
1426
- w && /* @__PURE__ */ e("div", { className: "mt-3", children: /* @__PURE__ */ e(Ot, { history: Q ?? [] }) })
1474
+ U && /* @__PURE__ */ e("div", { className: "mt-3", children: /* @__PURE__ */ e(Kt, { history: B ?? [] }) })
1427
1475
  ] })
1428
1476
  ] }) : /* @__PURE__ */ n("div", { className: "flex items-center justify-between gap-4 px-5 py-4", children: [
1429
1477
  /* @__PURE__ */ e("p", { className: "text-[13px] text-slate-500", children: "Pipeline not started for this record." }),
1430
1478
  /* @__PURE__ */ n(
1431
- V,
1479
+ Y,
1432
1480
  {
1433
1481
  size: "sm",
1434
1482
  variant: "outline",
1435
1483
  className: "shrink-0 gap-1.5 text-[12px]",
1436
- onClick: () => B.mutate(),
1437
- disabled: B.isPending,
1484
+ onClick: () => Q.mutate(),
1485
+ disabled: Q.isPending,
1438
1486
  children: [
1439
- B.isPending ? /* @__PURE__ */ e(te, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(_e, { className: "h-3.5 w-3.5" }),
1487
+ Q.isPending ? /* @__PURE__ */ e(se, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e($e, { className: "h-3.5 w-3.5" }),
1440
1488
  "Start Pipeline"
1441
1489
  ]
1442
1490
  }
@@ -1446,36 +1494,36 @@ function Bt({
1446
1494
  ]
1447
1495
  }
1448
1496
  ),
1449
- c && /* @__PURE__ */ e(Ye, { fallback: null, children: /* @__PURE__ */ e(
1450
- dt,
1497
+ w && /* @__PURE__ */ e(ot, { fallback: null, children: /* @__PURE__ */ e(
1498
+ ft,
1451
1499
  {
1452
- payload: c.payload,
1453
- isRetry: c.revision > 1,
1500
+ payload: w.payload,
1501
+ isRetry: w.revision > 1,
1454
1502
  onSubmitted: () => (
1455
1503
  // mutateAsync so the dialog can stay busy until the transition
1456
1504
  // settles; the mutation's own onError/onSuccess handle the outcome.
1457
- I.mutateAsync({
1458
- transition_id: c.transitionId,
1459
- comment: c.comment,
1505
+ G.mutateAsync({
1506
+ transition_id: w.transitionId,
1507
+ comment: w.comment,
1460
1508
  reviewed: !0
1461
1509
  }).catch(() => {
1462
1510
  })
1463
1511
  ),
1464
- executing: I.isPending,
1465
- onClose: () => o(null)
1512
+ executing: G.isPending,
1513
+ onClose: () => a(null)
1466
1514
  },
1467
- c.revision
1515
+ w.revision
1468
1516
  ) })
1469
1517
  ] });
1470
1518
  }
1471
- function un({
1519
+ function Cn({
1472
1520
  collection: r,
1473
1521
  item: t,
1474
1522
  onBeforeTransition: u,
1475
1523
  wrap: i = !0
1476
1524
  }) {
1477
1525
  return t === "new" ? null : /* @__PURE__ */ e(
1478
- Et,
1526
+ Xt,
1479
1527
  {
1480
1528
  collection: r,
1481
1529
  item: t,
@@ -1484,32 +1532,48 @@ function un({
1484
1532
  }
1485
1533
  );
1486
1534
  }
1487
- function Et({
1535
+ function Xt({
1488
1536
  collection: r,
1489
1537
  item: t,
1490
1538
  onBeforeTransition: u,
1491
1539
  wrap: i = !0
1492
1540
  }) {
1493
- const C = ce(), p = De(), [x, b] = U(""), [T, P] = U(null), [h, N] = U(null);
1494
- et(r, t, "transition", !!T || !!h);
1495
- const q = async (f) => {
1496
- if (T === f) {
1497
- P(null);
1541
+ const T = fe(), p = Oe(), [f, v] = K(""), [q, D] = K(null), [x, R] = K(null);
1542
+ dt(r, t, "transition", !!q || !!x);
1543
+ const _ = ne(null), I = Dt(_, !i), L = ne(!1), j = (m) => {
1544
+ L.current || (L.current = !0, S.mutate(m, {
1545
+ onSettled: () => {
1546
+ L.current = !1;
1547
+ }
1548
+ }));
1549
+ }, M = async (m) => {
1550
+ if (L.current) return;
1551
+ if (q === m) {
1552
+ D(null);
1498
1553
  return;
1499
1554
  }
1500
- if (u && !await u()) return;
1501
- const y = (E ?? []).find((a) => a.id === f), s = String((y == null ? void 0 : y.comment_mode) ?? "none");
1502
- if (s !== "optional" && s !== "required") {
1503
- $.mutate({ transition_id: f });
1555
+ if (u) {
1556
+ L.current = !0;
1557
+ let h = !1;
1558
+ try {
1559
+ h = await u();
1560
+ } finally {
1561
+ L.current = !1;
1562
+ }
1563
+ if (!h) return;
1564
+ }
1565
+ const g = (a ?? []).find((h) => h.id === m), C = String((g == null ? void 0 : g.comment_mode) ?? "none");
1566
+ if (C !== "optional" && C !== "required") {
1567
+ j({ transition_id: m });
1504
1568
  return;
1505
1569
  }
1506
- P(f);
1507
- }, F = ["pipeline-instance", r, t], { data: k } = Z({
1508
- queryKey: F,
1509
- queryFn: () => C.request(
1510
- Y(`/pipelines/instance/${r}/${t}`)
1570
+ D(m);
1571
+ }, U = ["pipeline-instance", r, t], { data: b } = te({
1572
+ queryKey: U,
1573
+ queryFn: () => T.request(
1574
+ ie(`/pipelines/instance/${r}/${t}`)
1511
1575
  ).then(
1512
- (f) => f.data ?? {
1576
+ (m) => m.data ?? {
1513
1577
  instance: null,
1514
1578
  states: [],
1515
1579
  available_transitions: [],
@@ -1519,226 +1583,291 @@ function Et({
1519
1583
  }
1520
1584
  ),
1521
1585
  staleTime: 1e4
1522
- }), $ = ue({
1586
+ }), S = he({
1523
1587
  mutationFn: ({
1524
- transition_id: f,
1525
- comment: y,
1526
- reviewed: s
1527
- }) => C.request(
1528
- be(`/pipelines/instance/${r}/${t}/transition`, {
1529
- transition_id: f,
1530
- comment: y,
1531
- ...s ? { reviewed: !0 } : {}
1588
+ transition_id: m,
1589
+ comment: g,
1590
+ reviewed: C
1591
+ }) => T.request(
1592
+ we(`/pipelines/instance/${r}/${t}/transition`, {
1593
+ transition_id: m,
1594
+ comment: g,
1595
+ ...C ? { reviewed: !0 } : {}
1532
1596
  })
1533
1597
  ),
1534
1598
  onSuccess: () => {
1535
- p.invalidateQueries({ queryKey: F }), r === "nivaro_addendums" && p.invalidateQueries({ queryKey: ["addendums"] }), ye(p, r, String(t)), we(p, r, String(t)), b(""), P(null), N(null), X.success("Transition executed");
1599
+ p.invalidateQueries({ queryKey: U }), r === "nivaro_addendums" && p.invalidateQueries({ queryKey: ["addendums"] }), ve(p, r, String(t)), ke(p, r, String(t)), v(""), D(null), R(null), ee.success("Transition executed");
1536
1600
  },
1537
- onError: (f, y) => {
1538
- var A;
1539
- const s = mt(f);
1540
- if (s) {
1541
- N((M) => ({
1542
- payload: s,
1543
- transitionId: y.transition_id,
1544
- comment: y.comment,
1545
- revision: ((M == null ? void 0 : M.revision) ?? 0) + 1
1601
+ onError: (m, g) => {
1602
+ if (xt(m)) {
1603
+ p.invalidateQueries({ queryKey: U });
1604
+ return;
1605
+ }
1606
+ const C = bt(m);
1607
+ if (C) {
1608
+ R((P) => ({
1609
+ payload: C,
1610
+ transitionId: g.transition_id,
1611
+ comment: g.comment,
1612
+ revision: ((P == null ? void 0 : P.revision) ?? 0) + 1
1546
1613
  }));
1547
1614
  return;
1548
1615
  }
1549
- const a = f == null ? void 0 : f.response;
1550
- X.error((a == null ? void 0 : a.error) ?? ((A = a == null ? void 0 : a.data) == null ? void 0 : A.error) ?? "Failed to execute transition", {
1616
+ const h = m == null ? void 0 : m.response;
1617
+ ee.error(Fe(m, "Failed to execute transition"), {
1551
1618
  duration: 12e3,
1552
1619
  // #1867: a refusal carries "Why?" — the role, owner or access rule
1553
1620
  // that stopped it, and who can change it.
1554
- ...lt(f) ? {
1555
- action: ot(C, {
1621
+ ...ut(m) ? {
1622
+ action: pt(T, {
1556
1623
  collection: r,
1557
1624
  itemId: String(t),
1558
1625
  action: "transition",
1559
- transitionId: y.transition_id
1626
+ transitionId: g.transition_id
1560
1627
  })
1561
1628
  } : {}
1562
- }), N(null), P(null), ye(p, r, String(t)), we(p, r, String(t)), (a == null ? void 0 : a.status) === 409 && p.invalidateQueries({ queryKey: F });
1629
+ }), R(null), D(null), ve(p, r, String(t)), ke(p, r, String(t)), (h == null ? void 0 : h.status) === 409 && p.invalidateQueries({ queryKey: U });
1563
1630
  }
1564
- }), D = se(q);
1565
- D.current = q;
1566
- const w = se((k == null ? void 0 : k.available_transitions) ?? []);
1567
- if (w.current = (k == null ? void 0 : k.available_transitions) ?? [], de(() => {
1568
- const f = (y) => {
1569
- const s = y.detail;
1570
- if (!s || s.claimed || s.collection !== r || String(s.item) !== String(t)) return;
1571
- s.claimed = !0;
1572
- const a = String(s.transition_id).toUpperCase(), A = w.current.find((M) => String(M.id).toUpperCase() === a);
1573
- if (!A) {
1574
- X.error("That step is not available from where the record is now");
1631
+ }), s = ne(M);
1632
+ s.current = M;
1633
+ const w = ne((b == null ? void 0 : b.available_transitions) ?? []);
1634
+ if (w.current = (b == null ? void 0 : b.available_transitions) ?? [], ue(() => {
1635
+ const m = (g) => {
1636
+ const C = g.detail;
1637
+ if (!C || C.claimed || C.collection !== r || String(C.item) !== String(t)) return;
1638
+ C.claimed = !0;
1639
+ const h = String(C.transition_id).toUpperCase(), P = w.current.find((Q) => String(Q.id).toUpperCase() === h);
1640
+ if (!P) {
1641
+ ee.error("That step is not available from where the record is now");
1575
1642
  return;
1576
1643
  }
1577
- D.current(A.id);
1644
+ s.current(P.id);
1578
1645
  };
1579
- return window.addEventListener(ge, f), () => window.removeEventListener(ge, f);
1580
- }, [r, t]), !(k != null && k.binding) || !(k != null && k.instance)) return null;
1581
- const E = (k.available_transitions ?? []).filter(
1582
- (f) => !k.instance.completed_at || f.from_state && String(f.from_state).toUpperCase() === String(k.instance.current_state).toUpperCase()
1646
+ return window.addEventListener(Ne, m), () => window.removeEventListener(Ne, m);
1647
+ }, [r, t]), !(b != null && b.binding) || !(b != null && b.instance)) return null;
1648
+ const a = (b.available_transitions ?? []).filter(
1649
+ (m) => !b.instance.completed_at || m.from_state && String(m.from_state).toUpperCase() === String(b.instance.current_state).toUpperCase()
1583
1650
  );
1584
- if (E.length === 0) return null;
1585
- const l = new Map((k.states ?? []).map((f) => [f.id, f])), v = k.instance.current_state_obj ?? null, c = T ? E.find((f) => f.id === T) : null, o = c ? l.get(c.to_state) : null, g = /* @__PURE__ */ new Map();
1586
- for (const f of E) {
1587
- const y = g.get(f.label) ?? [];
1588
- y.push(f), g.set(f.label, y);
1651
+ if (a.length === 0) return null;
1652
+ const N = new Map((b.states ?? []).map((m) => [m.id, m])), k = b.instance.current_state_obj ?? null, A = q ? a.find((m) => m.id === q) : null, W = A ? N.get(A.to_state) : null, c = /* @__PURE__ */ new Map();
1653
+ for (const m of a) {
1654
+ const g = c.get(m.label) ?? [];
1655
+ g.push(m), c.set(m.label, g);
1589
1656
  }
1590
- return /* @__PURE__ */ n("div", { className: "relative", children: [
1591
- /* @__PURE__ */ e(
1657
+ const y = (m) => [...m].sort(
1658
+ (g, C) => {
1659
+ var h, P;
1660
+ return (((h = N.get(g.to_state)) == null ? void 0 : h.sort) ?? 999) - (((P = N.get(C.to_state)) == null ? void 0 : P.sort) ?? 999);
1661
+ }
1662
+ ), d = (() => {
1663
+ var C, h, P;
1664
+ const m = (C = _.current) == null ? void 0 : C.getBoundingClientRect();
1665
+ if (!m) return 600;
1666
+ const g = (P = (h = _.current) == null ? void 0 : h.closest('[role="dialog"]')) == null ? void 0 : P.getBoundingClientRect();
1667
+ return Math.max(260, Math.min(600, m.right - ((g == null ? void 0 : g.left) ?? 0) - 12));
1668
+ })();
1669
+ return /* @__PURE__ */ n("div", { ref: _, className: "relative", children: [
1670
+ I ? /* @__PURE__ */ n(qe, { children: [
1671
+ /* @__PURE__ */ e(Ae, { asChild: !0, children: /* @__PURE__ */ n(
1672
+ Y,
1673
+ {
1674
+ size: "sm",
1675
+ variant: "outline",
1676
+ className: "shrink-0 gap-1.5 text-[12px]",
1677
+ disabled: S.isPending,
1678
+ "data-transitions-folded": !0,
1679
+ children: [
1680
+ S.isPending && /* @__PURE__ */ e(se, { className: "h-3 w-3 animate-spin" }),
1681
+ "Actions",
1682
+ /* @__PURE__ */ e(me, { className: "h-3 w-3" })
1683
+ ]
1684
+ }
1685
+ ) }),
1686
+ /* @__PURE__ */ e(Pe, { align: "end", className: "min-w-[200px]", children: Array.from(c.entries()).map(
1687
+ ([m, g], C, h) => g.length === 1 ? /* @__PURE__ */ n(tt, { children: [
1688
+ C > 0 && h[C - 1][1].length > 1 && /* @__PURE__ */ e(nt, {}),
1689
+ /* @__PURE__ */ n(ge, { onSelect: () => M(g[0].id), children: [
1690
+ g[0].color && /* @__PURE__ */ e(
1691
+ "span",
1692
+ {
1693
+ className: "mr-2 inline-block h-2 w-2 shrink-0 rounded-full",
1694
+ style: { backgroundColor: g[0].color }
1695
+ }
1696
+ ),
1697
+ m
1698
+ ] })
1699
+ ] }, m) : /* @__PURE__ */ n(tt, { children: [
1700
+ C > 0 && /* @__PURE__ */ e(nt, {}),
1701
+ /* @__PURE__ */ e(Lt, { className: "text-[11px] text-muted-foreground", children: m }),
1702
+ y(g).map((P) => {
1703
+ var Q;
1704
+ return /* @__PURE__ */ n(ge, { onSelect: () => M(P.id), children: [
1705
+ P.color && /* @__PURE__ */ e(
1706
+ "span",
1707
+ {
1708
+ className: "mr-2 inline-block h-2 w-2 shrink-0 rounded-full",
1709
+ style: { backgroundColor: P.color }
1710
+ }
1711
+ ),
1712
+ ((Q = N.get(P.to_state)) == null ? void 0 : Q.label) ?? P.to_state
1713
+ ] }, P.id);
1714
+ })
1715
+ ] }, m)
1716
+ ) })
1717
+ ] }) : /* @__PURE__ */ e(
1592
1718
  "div",
1593
1719
  {
1594
1720
  className: i ? "flex flex-wrap justify-end gap-2" : "flex shrink-0 items-center justify-end gap-2",
1595
- children: Array.from(g.entries()).map(([f, y]) => {
1596
- var M, ee;
1597
- const s = ((M = y[0]) == null ? void 0 : M.color) ?? null, a = y.some((R) => R.id === T), A = (R) => s ? R ? { backgroundColor: s, borderColor: s } : { borderColor: s, color: s } : void 0;
1598
- if (y.length === 1) {
1599
- const R = y[0], S = $.isPending && ((ee = $.variables) == null ? void 0 : ee.transition_id) === R.id, B = /* @__PURE__ */ n(
1600
- V,
1721
+ children: Array.from(c.entries()).map(([m, g]) => {
1722
+ var Q, G;
1723
+ const C = ((Q = g[0]) == null ? void 0 : Q.color) ?? null, h = g.some((O) => O.id === q), P = (O) => C ? O ? { backgroundColor: C, borderColor: C } : { borderColor: C, color: C } : void 0;
1724
+ if (g.length === 1) {
1725
+ const O = g[0], re = S.isPending && ((G = S.variables) == null ? void 0 : G.transition_id) === O.id, F = /* @__PURE__ */ n(
1726
+ Y,
1601
1727
  {
1602
1728
  size: "sm",
1603
- variant: a ? "default" : "outline",
1729
+ variant: h ? "default" : "outline",
1604
1730
  className: "gap-1.5 text-[12px]",
1605
- style: A(a),
1606
- disabled: $.isPending,
1607
- onClick: () => q(R.id),
1731
+ style: P(h),
1732
+ disabled: S.isPending,
1733
+ onClick: () => M(O.id),
1608
1734
  children: [
1609
- S && /* @__PURE__ */ e(te, { className: "h-3 w-3 animate-spin" }),
1610
- f
1735
+ re && /* @__PURE__ */ e(se, { className: "h-3 w-3 animate-spin" }),
1736
+ m
1611
1737
  ]
1612
1738
  },
1613
- f
1739
+ m
1614
1740
  );
1615
- return R.pushes && R.pushes > 0 ? /* @__PURE__ */ n("span", { className: "relative inline-flex", children: [
1616
- B,
1741
+ return O.pushes && O.pushes > 0 ? /* @__PURE__ */ n("span", { className: "relative inline-flex", children: [
1742
+ F,
1617
1743
  /* @__PURE__ */ e(
1618
- _t,
1744
+ Rt,
1619
1745
  {
1620
1746
  collection: r,
1621
1747
  itemId: t,
1622
- transitionId: R.id,
1623
- label: f,
1748
+ transitionId: O.id,
1749
+ label: m,
1624
1750
  compact: !0
1625
1751
  }
1626
1752
  )
1627
- ] }, f) : B;
1753
+ ] }, m) : F;
1628
1754
  }
1629
- return /* @__PURE__ */ n(nt, { children: [
1630
- /* @__PURE__ */ e(rt, { asChild: !0, children: /* @__PURE__ */ n(
1631
- V,
1755
+ return /* @__PURE__ */ n(qe, { children: [
1756
+ /* @__PURE__ */ e(Ae, { asChild: !0, children: /* @__PURE__ */ n(
1757
+ Y,
1632
1758
  {
1633
1759
  size: "sm",
1634
- variant: a ? "default" : "outline",
1760
+ variant: h ? "default" : "outline",
1635
1761
  className: "gap-1.5 text-[12px]",
1636
- style: A(a),
1637
- disabled: $.isPending,
1762
+ style: P(h),
1763
+ disabled: S.isPending,
1638
1764
  children: [
1639
- f,
1640
- /* @__PURE__ */ e(oe, { className: "h-3 w-3" })
1765
+ m,
1766
+ /* @__PURE__ */ e(me, { className: "h-3 w-3" })
1641
1767
  ]
1642
1768
  }
1643
1769
  ) }),
1644
- /* @__PURE__ */ e(at, { align: "start", children: [...y].sort(
1645
- (R, S) => {
1646
- var B, I;
1647
- return (((B = l.get(R.to_state)) == null ? void 0 : B.sort) ?? 999) - (((I = l.get(S.to_state)) == null ? void 0 : I.sort) ?? 999);
1648
- }
1649
- ).map((R) => {
1650
- var S;
1651
- return /* @__PURE__ */ n(st, { onSelect: () => q(R.id), children: [
1652
- R.color && /* @__PURE__ */ e(
1770
+ /* @__PURE__ */ e(Pe, { align: "start", children: y(g).map((O) => {
1771
+ var re;
1772
+ return /* @__PURE__ */ n(ge, { onSelect: () => M(O.id), children: [
1773
+ O.color && /* @__PURE__ */ e(
1653
1774
  "span",
1654
1775
  {
1655
1776
  className: "mr-2 inline-block h-2 w-2 shrink-0 rounded-full",
1656
- style: { backgroundColor: R.color }
1777
+ style: { backgroundColor: O.color }
1657
1778
  }
1658
1779
  ),
1659
- ((S = l.get(R.to_state)) == null ? void 0 : S.label) ?? R.to_state
1660
- ] }, R.id);
1780
+ ((re = N.get(O.to_state)) == null ? void 0 : re.label) ?? O.to_state
1781
+ ] }, O.id);
1661
1782
  }) })
1662
- ] }, f);
1783
+ ] }, m);
1663
1784
  })
1664
1785
  }
1665
1786
  ),
1666
- T && /* @__PURE__ */ n("div", { className: "absolute right-0 top-full z-50 mt-1 w-[600px] space-y-3 rounded-lg border border-slate-200 bg-white shadow-lg dark:bg-card dark:border-border p-3.5", children: [
1667
- /* @__PURE__ */ n("div", { className: "flex flex-wrap items-center gap-2", children: [
1668
- /* @__PURE__ */ e("span", { className: "text-[11px] font-semibold text-slate-400", children: "Confirming" }),
1669
- c && /* @__PURE__ */ e("span", { className: "text-[12px] font-medium text-slate-700", children: c.label }),
1670
- v && o && /* @__PURE__ */ n("div", { className: "ml-auto flex items-center gap-1.5", children: [
1671
- /* @__PURE__ */ e(re, { label: v.label, color: v.color, small: !0 }),
1672
- /* @__PURE__ */ e(Ae, { className: "h-3 w-3 shrink-0 text-slate-300" }),
1673
- /* @__PURE__ */ e(re, { label: o.label, color: o.color, small: !0 })
1674
- ] })
1675
- ] }),
1676
- /* @__PURE__ */ e(ut, { collection: r, item: t }),
1677
- /* @__PURE__ */ e(
1678
- "input",
1679
- {
1680
- type: "text",
1681
- value: x,
1682
- onChange: (f) => b(f.target.value),
1683
- placeholder: String((c == null ? void 0 : c.comment_mode) ?? "") === "required" ? "Add a note (required)" : "Add a comment (optional)",
1684
- className: "w-full rounded-md border border-slate-200 bg-white px-3 py-1.5 text-[13px] placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-nvr-cyan/30"
1685
- }
1686
- ),
1687
- /* @__PURE__ */ n("div", { className: "flex items-center justify-end gap-2", children: [
1688
- /* @__PURE__ */ e(
1689
- V,
1690
- {
1691
- type: "button",
1692
- size: "sm",
1693
- variant: "ghost",
1694
- className: "h-7 text-[12px]",
1695
- onClick: () => P(null),
1696
- children: "Cancel"
1697
- }
1698
- ),
1699
- /* @__PURE__ */ e(
1700
- V,
1701
- {
1702
- type: "button",
1703
- size: "sm",
1704
- className: "h-7 gap-1.5 text-[12px]",
1705
- disabled: $.isPending || String((c == null ? void 0 : c.comment_mode) ?? "") === "required" && x.trim() === "",
1706
- onClick: () => $.mutate({
1707
- transition_id: T,
1708
- comment: x.trim() || void 0
1709
- }),
1710
- children: $.isPending ? /* @__PURE__ */ e(te, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ n(ae, { children: [
1711
- /* @__PURE__ */ e("span", { children: "Confirm" }),
1712
- /* @__PURE__ */ e(ve, { className: "h-3 w-3" })
1787
+ q && /* @__PURE__ */ n(
1788
+ "div",
1789
+ {
1790
+ className: "absolute right-0 top-full z-50 mt-1 space-y-3 rounded-lg border border-slate-200 bg-white shadow-lg dark:bg-card dark:border-border p-3.5",
1791
+ style: { width: d },
1792
+ children: [
1793
+ /* @__PURE__ */ n("div", { className: "flex flex-wrap items-center gap-2", children: [
1794
+ /* @__PURE__ */ e("span", { className: "text-[11px] font-semibold text-slate-400", children: "Confirming" }),
1795
+ A && /* @__PURE__ */ e("span", { className: "text-[12px] font-medium text-slate-700", children: A.label }),
1796
+ k && W && /* @__PURE__ */ n("div", { className: "ml-auto flex items-center gap-1.5", children: [
1797
+ /* @__PURE__ */ e(oe, { label: k.label, color: k.color, small: !0 }),
1798
+ /* @__PURE__ */ e(Be, { className: "h-3 w-3 shrink-0 text-slate-300" }),
1799
+ /* @__PURE__ */ e(oe, { label: W.label, color: W.color, small: !0 })
1713
1800
  ] })
1714
- }
1715
- )
1716
- ] })
1717
- ] }),
1718
- h && /* @__PURE__ */ e(Ye, { fallback: null, children: /* @__PURE__ */ e(
1719
- dt,
1801
+ ] }),
1802
+ /* @__PURE__ */ e(gt, { collection: r, item: t }),
1803
+ /* @__PURE__ */ e(
1804
+ "input",
1805
+ {
1806
+ type: "text",
1807
+ value: f,
1808
+ onChange: (m) => v(m.target.value),
1809
+ placeholder: String((A == null ? void 0 : A.comment_mode) ?? "") === "required" ? "Add a note (required)" : "Add a comment (optional)",
1810
+ className: "w-full rounded-md border border-slate-200 bg-white px-3 py-1.5 text-[13px] placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-nvr-cyan/30"
1811
+ }
1812
+ ),
1813
+ /* @__PURE__ */ n("div", { className: "flex items-center justify-end gap-2", children: [
1814
+ /* @__PURE__ */ e(
1815
+ Y,
1816
+ {
1817
+ type: "button",
1818
+ size: "sm",
1819
+ variant: "ghost",
1820
+ className: "h-7 text-[12px]",
1821
+ onClick: () => D(null),
1822
+ children: "Cancel"
1823
+ }
1824
+ ),
1825
+ /* @__PURE__ */ e(
1826
+ Y,
1827
+ {
1828
+ type: "button",
1829
+ size: "sm",
1830
+ className: "h-7 gap-1.5 text-[12px]",
1831
+ disabled: S.isPending || String((A == null ? void 0 : A.comment_mode) ?? "") === "required" && f.trim() === "",
1832
+ onClick: () => j({
1833
+ transition_id: q,
1834
+ comment: f.trim() || void 0
1835
+ }),
1836
+ children: S.isPending ? /* @__PURE__ */ e(se, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ n(de, { children: [
1837
+ /* @__PURE__ */ e("span", { children: "Confirm" }),
1838
+ /* @__PURE__ */ e(_e, { className: "h-3 w-3" })
1839
+ ] })
1840
+ }
1841
+ )
1842
+ ] })
1843
+ ]
1844
+ }
1845
+ ),
1846
+ x && /* @__PURE__ */ e(ot, { fallback: null, children: /* @__PURE__ */ e(
1847
+ ft,
1720
1848
  {
1721
- payload: h.payload,
1722
- isRetry: h.revision > 1,
1849
+ payload: x.payload,
1850
+ isRetry: x.revision > 1,
1723
1851
  onSubmitted: () => (
1724
1852
  // mutateAsync so the dialog can stay busy until the transition
1725
1853
  // settles; the mutation's own onError/onSuccess handle the outcome.
1726
- $.mutateAsync({
1727
- transition_id: h.transitionId,
1728
- comment: h.comment,
1854
+ S.mutateAsync({
1855
+ transition_id: x.transitionId,
1856
+ comment: x.comment,
1729
1857
  reviewed: !0
1730
1858
  }).catch(() => {
1731
1859
  })
1732
1860
  ),
1733
- executing: $.isPending,
1734
- onClose: () => N(null)
1861
+ executing: S.isPending,
1862
+ onClose: () => R(null)
1735
1863
  },
1736
- h.revision
1864
+ x.revision
1737
1865
  ) })
1738
1866
  ] });
1739
1867
  }
1740
1868
  export {
1741
- mn as PipelinePanel,
1742
- un as PipelineTransitionButtons,
1743
- mt as transitionRequirementsFromError
1869
+ _n as PipelinePanel,
1870
+ Cn as PipelineTransitionButtons,
1871
+ xt as isDuplicateTransition,
1872
+ bt as transitionRequirementsFromError
1744
1873
  };