@nivaro/react 0.3.137 → 0.3.139

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 (50) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +95 -4
  4. package/dist/index.js +748 -743
  5. package/dist/shared/components/CollectionBrowserView.js +392 -389
  6. package/dist/shared/components/DelegateCoverLine.js +80 -87
  7. package/dist/shared/components/ItemEditForm.js +589 -588
  8. package/dist/shared/components/MyWorkView.js +284 -286
  9. package/dist/shared/components/NotificationBell.js +251 -205
  10. package/dist/shared/components/ai/AiAnalyticsView.js +878 -417
  11. package/dist/shared/components/ai/AiPlanCard.js +164 -122
  12. package/dist/shared/components/ai/AiPlanUndo.js +291 -0
  13. package/dist/shared/components/ai/call-log/CallDrawer.js +357 -0
  14. package/dist/shared/components/ai/call-log/RawJson.js +126 -0
  15. package/dist/shared/components/ai/call-log/ThreadView.js +223 -0
  16. package/dist/shared/components/ai/call-log/TranscriptView.js +227 -0
  17. package/dist/shared/components/ai/call-log/controls.js +364 -0
  18. package/dist/shared/components/ai/call-log/format.js +46 -0
  19. package/dist/shared/components/ai/call-log/url.js +105 -0
  20. package/dist/shared/components/chat/chat-core.js +422 -346
  21. package/dist/shared/components/integrations/IntegrationObligationsView.js +98 -98
  22. package/dist/shared/components/integrations/RecordIntegrationPreview.js +102 -93
  23. package/dist/shared/components/integrations/console/api.js +11 -1
  24. package/dist/shared/components/item-edit/HeaderRollupExplainer.js +5 -1
  25. package/dist/shared/components/item-edit/RecordLiveSync.js +241 -229
  26. package/dist/shared/components/item-edit/RecordRecapChanges.js +166 -0
  27. package/dist/shared/components/item-edit/RecordRecapStrip.js +254 -84
  28. package/dist/shared/components/item-edit/live-related.js +34 -18
  29. package/dist/shared/components/panels/RevisionsPanel.js +735 -683
  30. package/dist/shared/components/queue/QueueWorklist.js +323 -316
  31. package/dist/shared/components/support/SupportRequestDialog.js +198 -181
  32. package/dist/shared/components/trackers/use-tracker-link.js +74 -65
  33. package/dist/shared/lib/activity-sentence.js +167 -151
  34. package/dist/shared/lib/config-update-refresh.js +34 -0
  35. package/dist/shared/lib/config-watch.js +17 -17
  36. package/dist/shared/lib/gap-refresh.js +49 -0
  37. package/dist/shared/lib/integration-dots.js +8 -8
  38. package/dist/shared/lib/live-ops.js +26 -23
  39. package/dist/shared/lib/live-pickers.js +1 -1
  40. package/dist/shared/lib/live-queries.js +223 -195
  41. package/dist/shared/lib/live.js +56 -51
  42. package/dist/shared/lib/obligation-banner.js +11 -10
  43. package/dist/shared/lib/obligation-filters.js +22 -18
  44. package/dist/shared/lib/obligation-reason-text.js +18 -8
  45. package/dist/shared/lib/presence-hooks.js +133 -132
  46. package/dist/shared/lib/reconnect-resync.js +90 -0
  47. package/dist/shared/lib/record-room-holds.js +43 -0
  48. package/dist/shared/lib/socket-realtime.js +116 -105
  49. package/dist/shared/lib/user-sync.js +1 -6
  50. package/package.json +1 -1
@@ -1,20 +1,21 @@
1
- import { jsxs as r, jsx as a, Fragment as C } from "react/jsx-runtime";
2
- import { ListChecks as G, Filter as K, Loader2 as N, Clock as I, RotateCcw as Q, Check as V, X as Z, SkipForward as ee, Ban as te, CircleDashed as ae } from "lucide-react";
3
- import { useState as k, useRef as E, useEffect as _, useCallback as re } from "react";
4
- import { useOptionalNivaroClient as ne } from "../../context.js";
5
- import { get as se, post as de } from "../../lib/commands.js";
1
+ import { jsxs as r, jsx as a, Fragment as S } from "react/jsx-runtime";
2
+ import { ListChecks as te, Filter as ae, Loader2 as N, Clock as I, RotateCcw as re, Undo2 as ne, Check as se, X as de, SkipForward as le, Ban as ie, CircleDashed as ce } from "lucide-react";
3
+ import { useState as f, useRef as X, useEffect as _, useCallback as oe } from "react";
4
+ import { useOptionalNivaroClient as pe } from "../../context.js";
5
+ import { get as me, post as ue } from "../../lib/commands.js";
6
6
  import { cn as d } from "../../lib/utils.js";
7
- import { Button as u } from "../ui/button.js";
8
- import { AiPlanChanges as le } from "./AiPlanChanges.js";
9
- const ie = 3e3;
10
- function ce(n) {
7
+ import { Button as p } from "../ui/button.js";
8
+ import { AiPlanChanges as he } from "./AiPlanChanges.js";
9
+ import { ProgressLine as ge, AiPlanUndo as xe } from "./AiPlanUndo.js";
10
+ const fe = 3e3;
11
+ function be(n) {
11
12
  return (n == null ? void 0 : n.message) || "The request failed";
12
13
  }
13
- function oe({ status: n }) {
14
+ function ke({ status: n }) {
14
15
  const l = "h-3.5 w-3.5 shrink-0";
15
- return n === "running" ? /* @__PURE__ */ a(N, { className: d(l, "animate-spin text-nvr-cyan") }) : n === "done" ? /* @__PURE__ */ a(V, { className: d(l, "text-emerald-600 dark:text-emerald-400") }) : n === "failed" ? /* @__PURE__ */ a(Z, { className: d(l, "text-rose-600 dark:text-rose-400") }) : n === "skipped" ? /* @__PURE__ */ a(ee, { className: d(l, "text-amber-600 dark:text-amber-400") }) : n === "cancelled" ? /* @__PURE__ */ a(te, { className: d(l, "text-muted-foreground") }) : /* @__PURE__ */ a(ae, { className: d(l, "text-muted-foreground") });
16
+ return n === "running" ? /* @__PURE__ */ a(N, { className: d(l, "animate-spin text-nvr-cyan") }) : n === "done" ? /* @__PURE__ */ a(se, { className: d(l, "text-emerald-600 dark:text-emerald-400") }) : n === "failed" ? /* @__PURE__ */ a(de, { className: d(l, "text-rose-600 dark:text-rose-400") }) : n === "skipped" ? /* @__PURE__ */ a(le, { className: d(l, "text-amber-600 dark:text-amber-400") }) : n === "cancelled" ? /* @__PURE__ */ a(ie, { className: d(l, "text-muted-foreground") }) : /* @__PURE__ */ a(ce, { className: d(l, "text-muted-foreground") });
16
17
  }
17
- function pe(n) {
18
+ function Ne(n) {
18
19
  const l = new Date(n);
19
20
  return Number.isNaN(l.getTime()) ? n : l.toLocaleString(void 0, {
20
21
  weekday: "short",
@@ -24,16 +25,16 @@ function pe(n) {
24
25
  minute: "2-digit"
25
26
  });
26
27
  }
27
- function me() {
28
+ function we() {
28
29
  const n = new Date(Date.now() + 36e5);
29
30
  n.setMinutes(Math.ceil(n.getMinutes() / 15) * 15, 0, 0);
30
- const l = (S) => String(S).padStart(2, "0");
31
+ const l = ($) => String($).padStart(2, "0");
31
32
  return `${n.getFullYear()}-${l(n.getMonth() + 1)}-${l(n.getDate())}T${l(n.getHours())}:${l(n.getMinutes())}`;
32
33
  }
33
- function ue(n) {
34
+ function ve(n) {
34
35
  return n == null || n === "" ? "—" : typeof n == "object" ? JSON.stringify(n) : String(n);
35
36
  }
36
- const he = {
37
+ const ye = {
37
38
  amber: {
38
39
  box: "rounded-lg border border-amber-200 bg-amber-50/60 p-3 dark:border-amber-800 dark:bg-amber-900/10",
39
40
  icon: "text-amber-700 dark:text-amber-300",
@@ -57,82 +58,84 @@ const he = {
57
58
  stepTitle: "break-words"
58
59
  }
59
60
  };
60
- function ye({
61
+ function Te({
61
62
  plan: n,
62
63
  subscribe: l,
63
- className: S,
64
- beforeSteps: J,
65
- stepExtra: $,
64
+ className: $,
65
+ beforeSteps: Y,
66
+ stepExtra: L,
66
67
  extraActions: R,
67
68
  runDisabled: D,
68
- onPlan: O,
69
- quiet: M,
70
- stepChanges: T
69
+ onPlan: M,
70
+ quiet: O,
71
+ stepChanges: j,
72
+ hideUndo: G
71
73
  }) {
72
- var B;
73
- const c = he[M ? "quiet" : "amber"], o = ne(), [t, j] = k(n), [i, q] = k(null), [F, P] = k(null), [b, w] = k(null), [U, W] = k(!1), x = n.plan_id, v = E(0), y = E(O);
74
- y.current = O, _(() => {
74
+ var H, E;
75
+ const i = ye[O ? "quiet" : "amber"], o = pe(), [t, z] = f(n), [c, A] = f(null), [P, q] = f(null), [b, w] = f(null), [F, K] = f(!1), [v, Q] = f(!1), g = n.plan_id, y = X(0), C = X(M);
76
+ C.current = M, _(() => {
75
77
  var e;
76
- (e = y.current) == null || e.call(y, t);
78
+ (e = C.current) == null || e.call(C, t);
77
79
  }, [t]);
78
- const f = re(async () => {
80
+ const k = oe(async () => {
79
81
  if (!o) return;
80
82
  const e = Date.now();
81
- v.current = e;
83
+ y.current = e;
82
84
  try {
83
- const s = await o.request(se(`/ai/plans/${encodeURIComponent(x)}`));
84
- v.current === e && (s != null && s.data) && j(s.data);
85
+ const s = await o.request(me(`/ai/plans/${encodeURIComponent(g)}`));
86
+ y.current === e && (s != null && s.data) && z(s.data);
85
87
  } catch {
86
88
  }
87
- }, [o, x]);
89
+ }, [o, g]);
88
90
  _(() => {
89
- f();
90
- }, [f]), _(() => {
91
+ k();
92
+ }, [k]), _(() => {
91
93
  if (l)
92
94
  return l("ai:plan", (e) => {
93
- if (String(e.plan_id ?? "").toUpperCase() !== x.toUpperCase()) return;
95
+ if (String(e.plan_id ?? "").toUpperCase() !== g.toUpperCase()) return;
94
96
  const s = e.plan;
95
- s != null && s.steps && (v.current = Date.now(), j(s));
97
+ s != null && s.steps && (y.current = Date.now(), z(s));
96
98
  });
97
- }, [l, x]), _(() => {
99
+ }, [l, g]), _(() => {
98
100
  if (t.status !== "running") return;
99
- const e = setInterval(() => void f(), ie);
101
+ const e = setInterval(() => void k(), fe);
100
102
  return () => clearInterval(e);
101
- }, [t.status, f]);
103
+ }, [t.status, k]);
102
104
  const h = async (e, s) => {
103
- if (!(!o || i)) {
104
- q(e), P(null);
105
+ if (!(!o || c)) {
106
+ A(e), q(null);
105
107
  try {
106
- const p = await o.request(
107
- de(`/ai/plans/${encodeURIComponent(x)}/${e}`, s)
108
+ const m = await o.request(
109
+ ue(`/ai/plans/${encodeURIComponent(g)}/${e}`, s)
108
110
  );
109
- p != null && p.data && (v.current = Date.now(), j(p.data), e === "schedule" && w(null));
110
- } catch (p) {
111
- P(ce(p)), f();
111
+ m != null && m.data && (y.current = Date.now(), z(m.data), e === "schedule" && w(null));
112
+ } catch (m) {
113
+ q(be(m)), k();
112
114
  } finally {
113
- q(null);
115
+ A(null);
114
116
  }
115
117
  }
116
- }, z = t.steps.filter((e) => e.state.status === "done").length, g = t.steps.filter((e) => e.state.status === "skipped").length, L = t.status === "proposed" || t.status === "paused", X = t.steps.filter((e) => e.state.status === "pending").length;
117
- return /* @__PURE__ */ r("div", { className: d("mt-2", c.box, S), "data-ai-plan": t.status, children: [
118
+ }, T = t.steps.filter((e) => e.state.status === "done").length, x = t.steps.filter((e) => e.state.status === "skipped").length, U = t.status === "proposed" || t.status === "paused", V = t.steps.filter((e) => e.state.status === "pending").length, Z = t.steps.length === 1, B = !G && !!o && t.can_undo === !0 && (((H = t.made_steps) == null ? void 0 : H.length) ?? 0) > 0 && t.status !== "running" && t.status !== "scheduled";
119
+ return /* @__PURE__ */ r("div", { className: d("mt-2", i.box, $), "data-ai-plan": t.status, children: [
118
120
  /* @__PURE__ */ r("div", { className: "flex items-start gap-2", children: [
119
- /* @__PURE__ */ a(G, { className: d("mt-0.5 h-4 w-4 shrink-0", c.icon) }),
121
+ /* @__PURE__ */ a(te, { className: d("mt-0.5 h-4 w-4 shrink-0", i.icon) }),
120
122
  /* @__PURE__ */ r("div", { className: "min-w-0 flex-1", children: [
121
- /* @__PURE__ */ r("p", { className: d("text-[12.5px] font-semibold", c.title), children: [
123
+ /* @__PURE__ */ r("p", { className: d("text-[12.5px] font-semibold", i.title), children: [
122
124
  t.status === "proposed" ? "Proposed plan: " : "Plan: ",
123
125
  t.title
124
126
  ] }),
125
- ((B = t.impact) == null ? void 0 : B.summary) && /* @__PURE__ */ a("p", { className: d("text-[11.5px]", c.impact), "data-ai-plan-impact": !0, children: t.impact.summary }),
126
- /* @__PURE__ */ r("p", { className: d("text-[11px]", c.progress), "data-ai-plan-progress": !0, children: [
127
+ ((E = t.impact) == null ? void 0 : E.summary) && /* @__PURE__ */ a("p", { className: d("text-[11.5px]", i.impact), "data-ai-plan-impact": !0, children: t.impact.summary }),
128
+ /* @__PURE__ */ r("p", { className: d("text-[11px]", i.progress), "data-ai-plan-progress": !0, children: [
127
129
  t.steps.length,
128
130
  " step",
129
131
  t.steps.length === 1 ? "" : "s",
130
- z + g > 0 ? ` · ${z} done` : "",
131
- g > 0 ? ` · ${g} skipped` : "",
132
- t.records_changed > 0 ? ` · ${t.records_changed} record${t.records_changed === 1 ? "" : "s"} changed` : ""
132
+ T + x > 0 ? ` · ${T} done` : "",
133
+ x > 0 ? ` · ${x} skipped` : "",
134
+ t.records_changed > 0 ? ` · ${t.records_changed.toLocaleString()} record${t.records_changed === 1 ? "" : "s"} changed` : ""
133
135
  ] })
134
136
  ] })
135
137
  ] }),
138
+ t.admin_unbounded && (t.status === "proposed" || t.status === "paused" || t.status === "scheduled") && /* @__PURE__ */ a("p", { className: d("mt-1.5 pl-6 text-[11.5px]", i.impact), "data-ai-plan-admin": !0, children: "Runs in the background — you can stop it at any time. Every change is logged as Ask AI for you and can be undone from AI plans for 30 days." }),
136
139
  t.held && (t.status === "proposed" || t.status === "paused") && /* @__PURE__ */ r(
137
140
  "p",
138
141
  {
@@ -145,18 +148,18 @@ function ye({
145
148
  ]
146
149
  }
147
150
  ),
148
- J,
151
+ Y,
149
152
  /* @__PURE__ */ a("ol", { className: "mt-2 space-y-1.5", children: t.steps.map((e) => {
150
- var A;
151
- const s = e.preview ?? {}, p = s.changes && typeof s.changes == "object" ? s.changes : null, H = T == null ? void 0 : T(e);
153
+ var W;
154
+ const s = e.preview ?? {}, m = s.changes && typeof s.changes == "object" ? s.changes : null, J = j == null ? void 0 : j(e);
152
155
  return /* @__PURE__ */ r(
153
156
  "li",
154
157
  {
155
- className: d("rounded-md border px-2.5 py-1.5", c.step),
158
+ className: d("rounded-md border px-2.5 py-1.5", i.step),
156
159
  "data-ai-plan-step": e.state.status,
157
160
  children: [
158
161
  /* @__PURE__ */ r("div", { className: "flex items-center gap-1.5", children: [
159
- /* @__PURE__ */ a(oe, { status: e.state.status }),
162
+ /* @__PURE__ */ a(ke, { status: e.state.status }),
160
163
  /* @__PURE__ */ r("span", { className: "text-[11px] font-medium tabular-nums text-muted-foreground", children: [
161
164
  e.n,
162
165
  "."
@@ -164,44 +167,67 @@ function ye({
164
167
  /* @__PURE__ */ a(
165
168
  "span",
166
169
  {
167
- className: d("min-w-0 flex-1 text-[12.5px] text-foreground", c.stepTitle),
170
+ className: d("min-w-0 flex-1 text-[12.5px] text-foreground", i.stepTitle),
168
171
  children: e.title
169
172
  }
170
173
  ),
171
174
  /* @__PURE__ */ a("span", { className: "shrink-0 rounded bg-muted px-1.5 py-px text-[10px] text-muted-foreground", children: e.kind_label })
172
175
  ] }),
173
176
  e.condition && /* @__PURE__ */ r("p", { className: "mt-0.5 flex items-center gap-1 pl-5 text-[11px] text-muted-foreground", children: [
174
- /* @__PURE__ */ a(K, { className: "h-3 w-3" }),
177
+ /* @__PURE__ */ a(ae, { className: "h-3 w-3" }),
175
178
  " ",
176
179
  e.condition
177
180
  ] }),
178
181
  e.preview_changed && /* @__PURE__ */ a("p", { className: "mt-0.5 pl-5 text-[11px] font-medium text-amber-700 dark:text-amber-300", children: "Re-checked — this step changed since it was proposed." }),
179
- H,
180
- H === void 0 && p && Object.keys(p).length > 0 && /* @__PURE__ */ a("div", { className: "mt-0.5 space-y-px pl-5", children: Object.entries(p).slice(0, 6).map(([m, Y]) => /* @__PURE__ */ r(
182
+ J,
183
+ J === void 0 && m && Object.keys(m).length > 0 && /* @__PURE__ */ a("div", { className: "mt-0.5 space-y-px pl-5", children: Object.entries(m).slice(0, 6).map(([u, ee]) => /* @__PURE__ */ r(
181
184
  "p",
182
185
  {
183
186
  className: "truncate text-[11px] text-slate-700 dark:text-slate-300",
184
187
  children: [
185
- /* @__PURE__ */ a("span", { className: "text-muted-foreground", children: m }),
188
+ /* @__PURE__ */ a("span", { className: "text-muted-foreground", children: u }),
186
189
  " → ",
187
- ue(Y)
190
+ ve(ee)
188
191
  ]
189
192
  },
190
- m
193
+ u
191
194
  )) }),
192
195
  s.recipients && s.recipients.length > 0 && /* @__PURE__ */ r("p", { className: "mt-0.5 truncate pl-5 text-[11px] text-muted-foreground", children: [
193
196
  "To ",
194
- s.recipients.map((m) => m.name).join(", "),
197
+ s.recipients.map((u) => u.name).join(", "),
195
198
  (s.count ?? 0) > s.recipients.length ? ` +${(s.count ?? 0) - s.recipients.length} more` : ""
196
199
  ] }),
197
200
  s.sample && s.sample.length > 0 && e.kind !== "create_task" && /* @__PURE__ */ r("p", { className: "mt-0.5 truncate pl-5 text-[11px] text-muted-foreground", children: [
198
201
  "e.g.",
199
202
  " ",
200
- s.sample.slice(0, 4).map((m) => m.label).join(" · "),
201
- (s.count ?? 0) > 4 ? ` +${(s.count ?? 0) - 4} more` : ""
203
+ s.sample.slice(0, 4).map((u) => u.label).join(" · "),
204
+ (s.count ?? 0) > 4 ? ` +${((s.count ?? 0) - 4).toLocaleString()} more` : ""
202
205
  ] }),
206
+ e.state.status === "running" && e.state.progress && e.state.progress.total > 1 && /* @__PURE__ */ r("div", { className: "mt-1 pl-5", "data-ai-plan-step-progress": !0, children: [
207
+ /* @__PURE__ */ r("div", { className: "flex items-center justify-between gap-2 text-[11px] tabular-nums text-muted-foreground", children: [
208
+ /* @__PURE__ */ r("span", { children: [
209
+ e.state.progress.done.toLocaleString(),
210
+ " of",
211
+ " ",
212
+ e.state.progress.total.toLocaleString(),
213
+ " records"
214
+ ] }),
215
+ /* @__PURE__ */ r("span", { children: [
216
+ Math.round(e.state.progress.done / e.state.progress.total * 100),
217
+ "%"
218
+ ] })
219
+ ] }),
220
+ /* @__PURE__ */ a(
221
+ ge,
222
+ {
223
+ pct: Math.round(e.state.progress.done / e.state.progress.total * 100),
224
+ label: `Step ${e.n} progress`
225
+ }
226
+ )
227
+ ] }),
228
+ e.state.status === "cancelled" && e.state.error && /* @__PURE__ */ a("p", { className: "mt-0.5 pl-5 text-[11px] text-muted-foreground", children: e.state.error }),
203
229
  e.state.status === "done" && e.state.records_changed > 0 && /* @__PURE__ */ r("p", { className: "mt-0.5 pl-5 text-[11px] text-emerald-700 dark:text-emerald-400", children: [
204
- e.state.records_changed,
230
+ e.state.records_changed.toLocaleString(),
205
231
  " record",
206
232
  e.state.records_changed === 1 ? "" : "s",
207
233
  " changed"
@@ -210,24 +236,25 @@ function ye({
210
236
  "Skipped — ",
211
237
  e.state.skip_reason
212
238
  ] }),
213
- e.state.status !== "skipped" && (((A = e.state.skipped_records) == null ? void 0 : A.length) ?? 0) > 0 && /* @__PURE__ */ r("p", { className: "mt-0.5 pl-5 text-[11px] text-amber-700 dark:text-amber-300", children: [
239
+ e.state.status !== "skipped" && (((W = e.state.skipped_records) == null ? void 0 : W.length) ?? 0) > 0 && /* @__PURE__ */ r("p", { className: "mt-0.5 pl-5 text-[11px] text-amber-700 dark:text-amber-300", children: [
214
240
  "Left out ",
215
241
  e.state.skipped_records.length,
216
242
  ":",
217
243
  " ",
218
- e.state.skipped_records.slice(0, 3).map((m) => `${m.label ?? m.id} (${m.reason})`).join("; ")
244
+ e.state.skipped_records.slice(0, 3).map((u) => `${u.label ?? u.id} (${u.reason})`).join("; ")
219
245
  ] }),
220
246
  e.state.status === "failed" && e.state.error && /* @__PURE__ */ a("p", { className: "mt-0.5 pl-5 text-[11px] text-rose-700 dark:text-rose-400", children: e.state.error }),
221
- $ == null ? void 0 : $(e, t)
247
+ L == null ? void 0 : L(e, t)
222
248
  ]
223
249
  },
224
250
  e.id
225
251
  );
226
252
  }) }),
227
- U && /* @__PURE__ */ a(le, { planId: x, title: t.title }),
228
- F && /* @__PURE__ */ a("p", { className: "mt-2 text-[11.5px] text-rose-700 dark:text-rose-400", children: F }),
229
- b != null && L && /* @__PURE__ */ r("div", { className: "mt-2 flex flex-wrap items-center gap-2", "data-ai-plan-later": !0, children: [
230
- /* @__PURE__ */ a("span", { className: d("text-[11.5px]", c.title), children: "Run at" }),
253
+ F && /* @__PURE__ */ a(he, { planId: g, title: t.title }),
254
+ v && B && /* @__PURE__ */ a(xe, { id: g, embedded: !0 }),
255
+ P && /* @__PURE__ */ a("p", { className: "mt-2 text-[11.5px] text-rose-700 dark:text-rose-400", children: P }),
256
+ b != null && U && /* @__PURE__ */ r("div", { className: "mt-2 flex flex-wrap items-center gap-2", "data-ai-plan-later": !0, children: [
257
+ /* @__PURE__ */ a("span", { className: d("text-[11.5px]", i.title), children: "Run at" }),
231
258
  /* @__PURE__ */ a(
232
259
  "input",
233
260
  {
@@ -237,31 +264,31 @@ function ye({
237
264
  "aria-label": "Run at",
238
265
  className: d(
239
266
  "h-7 rounded-md border bg-white px-2 text-[12px] text-foreground dark:bg-card",
240
- M ? "border-slate-200 dark:border-border" : "border-amber-300 dark:border-amber-700"
267
+ O ? "border-slate-200 dark:border-border" : "border-amber-300 dark:border-amber-700"
241
268
  )
242
269
  }
243
270
  ),
244
271
  /* @__PURE__ */ r(
245
- u,
272
+ p,
246
273
  {
247
274
  size: "sm",
248
275
  className: "h-7 bg-nvr-cyan text-white hover:bg-nvr-cyan/90",
249
- disabled: !!i || !b,
276
+ disabled: !!c || !b,
250
277
  onClick: () => h("schedule", { run_at: new Date(b).toISOString() }),
251
278
  children: [
252
- i === "schedule" ? /* @__PURE__ */ a(N, { className: "h-3 w-3 animate-spin" }) : null,
279
+ c === "schedule" ? /* @__PURE__ */ a(N, { className: "h-3 w-3 animate-spin" }) : null,
253
280
  "Approve for then"
254
281
  ]
255
282
  }
256
283
  ),
257
- /* @__PURE__ */ a(u, { size: "sm", variant: "ghost", className: "h-7", onClick: () => w(null), children: "Cancel" }),
284
+ /* @__PURE__ */ a(p, { size: "sm", variant: "ghost", className: "h-7", onClick: () => w(null), children: "Cancel" }),
258
285
  /* @__PURE__ */ a("span", { className: "w-full text-[11px] text-muted-foreground", children: "Each step is re-checked first; if the records changed, it waits for you to approve again." })
259
286
  ] }),
260
287
  /* @__PURE__ */ r("div", { className: "mt-2 flex flex-wrap items-center gap-2", children: [
261
- L && o && D && /* @__PURE__ */ r(
288
+ U && o && D && /* @__PURE__ */ r(
262
289
  "span",
263
290
  {
264
- className: d("flex items-center gap-1.5 text-[12px]", c.status),
291
+ className: d("flex items-center gap-1.5 text-[12px]", i.status),
265
292
  "data-ai-plan-run-withheld": !0,
266
293
  children: [
267
294
  /* @__PURE__ */ a(I, { className: "h-3 w-3" }),
@@ -269,41 +296,41 @@ function ye({
269
296
  ]
270
297
  }
271
298
  ),
272
- L && o && !D && /* @__PURE__ */ r(C, { children: [
299
+ U && o && !D && /* @__PURE__ */ r(S, { children: [
273
300
  /* @__PURE__ */ r(
274
- u,
301
+ p,
275
302
  {
276
303
  size: "sm",
277
304
  className: "h-7 bg-nvr-cyan text-white hover:bg-nvr-cyan/90",
278
- disabled: !!i,
305
+ disabled: !!c,
279
306
  onClick: () => h("run", { mode: "all" }),
280
307
  "data-ai-plan-run": "all",
281
308
  children: [
282
- i === "run" ? /* @__PURE__ */ a(N, { className: "h-3 w-3 animate-spin" }) : null,
283
- t.status === "paused" ? "Run the rest" : "Approve & run all"
309
+ c === "run" ? /* @__PURE__ */ a(N, { className: "h-3 w-3 animate-spin" }) : null,
310
+ t.status === "paused" ? "Run the rest" : Z ? "Approve & run" : "Approve & run all"
284
311
  ]
285
312
  }
286
313
  ),
287
- X > 1 && /* @__PURE__ */ a(
288
- u,
314
+ V > 1 && /* @__PURE__ */ a(
315
+ p,
289
316
  {
290
317
  size: "sm",
291
318
  variant: "outline",
292
319
  className: "h-7",
293
- disabled: !!i,
320
+ disabled: !!c,
294
321
  onClick: () => h("run", { mode: "next" }),
295
322
  "data-ai-plan-run": "next",
296
323
  children: "Run next step"
297
324
  }
298
325
  ),
299
326
  b == null && /* @__PURE__ */ r(
300
- u,
327
+ p,
301
328
  {
302
329
  size: "sm",
303
330
  variant: "outline",
304
331
  className: "h-7",
305
- disabled: !!i,
306
- onClick: () => w(me()),
332
+ disabled: !!c,
333
+ onClick: () => w(we()),
307
334
  "data-ai-plan-run": "later",
308
335
  children: [
309
336
  /* @__PURE__ */ a(I, { className: "h-3 w-3" }),
@@ -312,84 +339,84 @@ function ye({
312
339
  }
313
340
  ),
314
341
  /* @__PURE__ */ a(
315
- u,
342
+ p,
316
343
  {
317
344
  size: "sm",
318
345
  variant: "ghost",
319
346
  className: "h-7",
320
- disabled: !!i,
347
+ disabled: !!c,
321
348
  onClick: () => h("cancel"),
322
349
  children: "Discard"
323
350
  }
324
351
  )
325
352
  ] }),
326
- t.status === "scheduled" && /* @__PURE__ */ r(C, { children: [
353
+ t.status === "scheduled" && /* @__PURE__ */ r(S, { children: [
327
354
  /* @__PURE__ */ r(
328
355
  "span",
329
356
  {
330
- className: d("flex items-center gap-1.5 text-[12px]", c.status),
357
+ className: d("flex items-center gap-1.5 text-[12px]", i.status),
331
358
  "data-ai-plan-scheduled": !0,
332
359
  children: [
333
360
  /* @__PURE__ */ a(I, { className: "h-3 w-3" }),
334
361
  "Approved to run ",
335
- t.schedule ? pe(t.schedule.run_at) : "later"
362
+ t.schedule ? Ne(t.schedule.run_at) : "later"
336
363
  ]
337
364
  }
338
365
  ),
339
366
  o && /* @__PURE__ */ a(
340
- u,
367
+ p,
341
368
  {
342
369
  size: "sm",
343
370
  variant: "ghost",
344
371
  className: "h-7",
345
- disabled: !!i,
372
+ disabled: !!c,
346
373
  onClick: () => h("unschedule"),
347
374
  children: "Cancel schedule"
348
375
  }
349
376
  )
350
377
  ] }),
351
- t.status === "running" && /* @__PURE__ */ r(C, { children: [
352
- /* @__PURE__ */ r("span", { className: d("flex items-center gap-1.5 text-[12px]", c.status), children: [
378
+ t.status === "running" && /* @__PURE__ */ r(S, { children: [
379
+ /* @__PURE__ */ r("span", { className: d("flex items-center gap-1.5 text-[12px]", i.status), children: [
353
380
  /* @__PURE__ */ a(N, { className: "h-3 w-3 animate-spin" }),
354
381
  " Running…"
355
382
  ] }),
356
383
  o && /* @__PURE__ */ a(
357
- u,
384
+ p,
358
385
  {
359
386
  size: "sm",
360
387
  variant: "outline",
361
388
  className: "h-7",
362
- disabled: !!i,
389
+ disabled: !!c,
363
390
  onClick: () => h("cancel"),
364
- "data-tip": "Stop before the next step",
391
+ "data-tip": t.admin_unbounded ? "Stop after the records in flight — what ran can be undone" : "Stop before the next step",
365
392
  children: "Stop"
366
393
  }
367
394
  )
368
395
  ] }),
369
- t.status === "failed" && o && /* @__PURE__ */ r(C, { children: [
396
+ t.status === "failed" && o && /* @__PURE__ */ r(S, { children: [
370
397
  /* @__PURE__ */ r(
371
- u,
398
+ p,
372
399
  {
373
400
  size: "sm",
374
401
  variant: "outline",
375
402
  className: "h-7",
376
- disabled: !!i,
403
+ disabled: !!c,
377
404
  onClick: () => h("retry"),
378
405
  "data-ai-plan-retry": !0,
379
406
  "data-tip": "Re-check the failed and remaining steps, then run them again",
380
407
  children: [
381
- i === "retry" ? /* @__PURE__ */ a(N, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ a(Q, { className: "h-3 w-3" }),
408
+ c === "retry" ? /* @__PURE__ */ a(N, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ a(re, { className: "h-3 w-3" }),
382
409
  "Re-check and retry"
383
410
  ]
384
411
  }
385
412
  ),
386
413
  /* @__PURE__ */ a(
387
- u,
414
+ p,
388
415
  {
389
416
  size: "sm",
390
417
  variant: "ghost",
391
418
  className: "h-7",
392
- disabled: !!i,
419
+ disabled: !!c,
393
420
  onClick: () => h("cancel"),
394
421
  children: "Discard the rest"
395
422
  }
@@ -397,14 +424,29 @@ function ye({
397
424
  ] }),
398
425
  t.status === "executed" && /* @__PURE__ */ r("span", { className: "text-[12px] font-medium text-emerald-700 dark:text-emerald-400", children: [
399
426
  "Done — ",
400
- t.records_changed,
427
+ t.records_changed.toLocaleString(),
401
428
  " record",
402
429
  t.records_changed === 1 ? "" : "s",
403
430
  " changed",
404
- g > 0 ? `, ${g} step${g === 1 ? "" : "s"} skipped` : ""
431
+ x > 0 ? `, ${x} step${x === 1 ? "" : "s"} skipped` : ""
405
432
  ] }),
406
- t.status === "rejected" && /* @__PURE__ */ a("span", { className: "text-[12px] text-muted-foreground", children: z > 0 ? "Stopped — the remaining steps did not run." : "Discarded — nothing changed." }),
433
+ t.status === "rejected" && /* @__PURE__ */ a("span", { className: "text-[12px] text-muted-foreground", children: T > 0 ? "Stopped — the remaining steps did not run." : "Discarded — nothing changed." }),
407
434
  t.status === "expired" && /* @__PURE__ */ a("span", { className: "text-[12px] text-muted-foreground", children: "Expired — ask again." }),
435
+ B && /* @__PURE__ */ r(
436
+ p,
437
+ {
438
+ size: "sm",
439
+ variant: v ? "secondary" : "outline",
440
+ className: "h-7",
441
+ onClick: () => Q((e) => !e),
442
+ "aria-expanded": v,
443
+ "data-ai-plan-undo-toggle": !0,
444
+ children: [
445
+ /* @__PURE__ */ a(ne, { className: "h-3 w-3" }),
446
+ v ? "Hide undo" : "Undo…"
447
+ ]
448
+ }
449
+ ),
408
450
  R == null ? void 0 : R(t),
409
451
  o && t.impact !== void 0 && /* @__PURE__ */ a(
410
452
  "button",
@@ -412,16 +454,16 @@ function ye({
412
454
  type: "button",
413
455
  className: d(
414
456
  "ml-auto text-[11.5px] font-medium underline-offset-2 hover:underline",
415
- c.link
457
+ i.link
416
458
  ),
417
- onClick: () => W((e) => !e),
459
+ onClick: () => K((e) => !e),
418
460
  "data-ai-plan-changes-toggle": !0,
419
- children: U ? "Hide changes" : "What changes"
461
+ children: F ? "Hide changes" : "What changes"
420
462
  }
421
463
  )
422
464
  ] })
423
465
  ] });
424
466
  }
425
467
  export {
426
- ye as AiPlanCard
468
+ Te as AiPlanCard
427
469
  };