@nivaro/react 0.3.50 → 0.3.51

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