@nivaro/react 0.3.63 → 0.3.65

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