@burdenoff/microfe-headshotmarketing 2026.928.2 → 2026.1029.1

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 (63) hide show
  1. package/dist/generated/global-types.d.ts +5145 -1627
  2. package/dist/generated/global-types.d.ts.map +1 -1
  3. package/dist/generated/wspace-operations.d.ts +464 -248
  4. package/dist/generated/wspace-operations.d.ts.map +1 -1
  5. package/dist/generated/wspace-operations.js +320 -292
  6. package/dist/generated/wspace-operations.js.map +1 -1
  7. package/dist/generated/wspace-types.d.ts +21251 -468
  8. package/dist/generated/wspace-types.d.ts.map +1 -1
  9. package/dist/generated/wspace-types.js +20 -20
  10. package/dist/generated/wspace-types.js.map +1 -1
  11. package/dist/headshotmarketing/components/PageLayout.d.ts +5 -0
  12. package/dist/headshotmarketing/components/PageLayout.d.ts.map +1 -1
  13. package/dist/headshotmarketing/components/PageLayout.js +12 -6
  14. package/dist/headshotmarketing/components/PageLayout.js.map +1 -1
  15. package/dist/headshotmarketing/components/StatusBadge.d.ts.map +1 -1
  16. package/dist/headshotmarketing/components/StatusBadge.js +3 -0
  17. package/dist/headshotmarketing/components/StatusBadge.js.map +1 -1
  18. package/dist/headshotmarketing/pages/automation/AutomationPage.d.ts.map +1 -1
  19. package/dist/headshotmarketing/pages/automation/AutomationPage.js +172 -167
  20. package/dist/headshotmarketing/pages/automation/AutomationPage.js.map +1 -1
  21. package/dist/headshotmarketing/pages/automation/TriggersPage.d.ts.map +1 -1
  22. package/dist/headshotmarketing/pages/automation/TriggersPage.js +127 -143
  23. package/dist/headshotmarketing/pages/automation/TriggersPage.js.map +1 -1
  24. package/dist/headshotmarketing/pages/automation/WorkflowActions.d.ts +16 -16
  25. package/dist/headshotmarketing/pages/automation/WorkflowActions.d.ts.map +1 -1
  26. package/dist/headshotmarketing/pages/automation/WorkflowActions.js +104 -221
  27. package/dist/headshotmarketing/pages/automation/WorkflowActions.js.map +1 -1
  28. package/dist/headshotmarketing/pages/automation/WorkflowBuilderPage.d.ts +16 -0
  29. package/dist/headshotmarketing/pages/automation/WorkflowBuilderPage.d.ts.map +1 -1
  30. package/dist/headshotmarketing/pages/automation/WorkflowBuilderPage.js +470 -549
  31. package/dist/headshotmarketing/pages/automation/WorkflowBuilderPage.js.map +1 -1
  32. package/dist/headshotmarketing/pages/automation/WorkflowCanvasNode.d.ts +2 -0
  33. package/dist/headshotmarketing/pages/automation/WorkflowCanvasNode.d.ts.map +1 -1
  34. package/dist/headshotmarketing/pages/automation/WorkflowCanvasNode.js +19 -19
  35. package/dist/headshotmarketing/pages/automation/WorkflowCanvasNode.js.map +1 -1
  36. package/dist/headshotmarketing/pages/automation/WorkflowNodeConfigPanel.d.ts.map +1 -1
  37. package/dist/headshotmarketing/pages/automation/WorkflowNodeConfigPanel.js +341 -164
  38. package/dist/headshotmarketing/pages/automation/WorkflowNodeConfigPanel.js.map +1 -1
  39. package/dist/headshotmarketing/pages/automation/WorkflowRunsPanel.d.ts +13 -0
  40. package/dist/headshotmarketing/pages/automation/WorkflowRunsPanel.d.ts.map +1 -0
  41. package/dist/headshotmarketing/pages/automation/WorkflowRunsPanel.js +294 -0
  42. package/dist/headshotmarketing/pages/automation/WorkflowRunsPanel.js.map +1 -0
  43. package/dist/headshotmarketing/pages/automation/WorkflowsPage.d.ts +2 -0
  44. package/dist/headshotmarketing/pages/automation/WorkflowsPage.d.ts.map +1 -1
  45. package/dist/headshotmarketing/pages/automation/WorkflowsPage.js +198 -220
  46. package/dist/headshotmarketing/pages/automation/WorkflowsPage.js.map +1 -1
  47. package/dist/headshotmarketing/pages/automation/useAutomationData.d.ts +24 -0
  48. package/dist/headshotmarketing/pages/automation/useAutomationData.d.ts.map +1 -0
  49. package/dist/headshotmarketing/pages/automation/useAutomationData.js +77 -0
  50. package/dist/headshotmarketing/pages/automation/useAutomationData.js.map +1 -0
  51. package/dist/headshotmarketing/pages/automation/workflowBuilderModel.d.ts +73 -16
  52. package/dist/headshotmarketing/pages/automation/workflowBuilderModel.d.ts.map +1 -1
  53. package/dist/headshotmarketing/pages/automation/workflowBuilderModel.js +220 -80
  54. package/dist/headshotmarketing/pages/automation/workflowBuilderModel.js.map +1 -1
  55. package/dist/headshotmarketing/pages/automation/workflowCompiler.d.ts +51 -0
  56. package/dist/headshotmarketing/pages/automation/workflowCompiler.d.ts.map +1 -0
  57. package/dist/headshotmarketing/pages/automation/workflowCompiler.js +453 -0
  58. package/dist/headshotmarketing/pages/automation/workflowCompiler.js.map +1 -0
  59. package/dist/headshotmarketing/utils/automationMapper.d.ts +50 -29
  60. package/dist/headshotmarketing/utils/automationMapper.d.ts.map +1 -1
  61. package/dist/headshotmarketing/utils/automationMapper.js +55 -99
  62. package/dist/headshotmarketing/utils/automationMapper.js.map +1 -1
  63. package/package.json +1 -1
@@ -1,645 +1,566 @@
1
- import { HeadshotmarketingBootstrapDataDocument as e, useCreateHeadshotmarketingWorkflowMutation as t, useTriggerHeadshotmarketingWorkflowMutation as n } from "../../../generated/wspace-operations.js";
2
- import "../../context/HeadshotmarketingBootstrapContext.js";
3
- import { useHeadshotMarketing as r } from "../../context/HeadshotMarketingContext.js";
4
- import { cn as i, formatDate as a } from "../../utils/helpers.js";
1
+ import { useActivateHeadshotmarketingAutomationWorkflowMutation as e, useCreateHeadshotmarketingAutomationWorkflowMutation as t, useHeadshotmarketingAutomationWorkflowQuery as n, useUpdateHeadshotmarketingAutomationWorkflowMutation as r } from "../../../generated/wspace-operations.js";
2
+ import { useHeadshotMarketing as i } from "../../context/HeadshotMarketingContext.js";
3
+ import { cn as a } from "../../utils/helpers.js";
5
4
  import { PageLayout as o } from "../../components/PageLayout.js";
6
- import { ToastContainer as s } from "../../components/Toast.js";
5
+ import { StatusBadge as s } from "../../components/StatusBadge.js";
6
+ import { ToastContainer as c } from "../../components/Toast.js";
7
7
  import "../../components/index.js";
8
- import { ACTION_TYPES as c, CHIP_TONE as l, TRIGGER_TYPES as ee, actionMeta as u, inPort as d, isConditionNode as te, outPort as f, serializeGraph as ne, triggerLabel as p } from "./workflowBuilderModel.js";
9
- import { WorkflowCanvasNode as re } from "./WorkflowCanvasNode.js";
10
- import { WorkflowConfigEmpty as ie, WorkflowNodeConfigPanel as ae } from "./WorkflowNodeConfigPanel.js";
11
- import { useCallback as m, useEffect as oe, useMemo as h, useRef as g, useState as _ } from "react";
12
- import { ArrowLeft as se, FlaskConical as ce, Maximize2 as le, Minus as ue, Move as de, Play as fe, Plus as v, Save as pe, Zap as me } from "lucide-react";
8
+ import { ACTION_TYPES as l, CHIP_TONE as u, TRIGGER_TYPES as ee, actionMeta as te, defaultConfig as ne, inPort as re, isConditionNode as d, nodeSubtitle as ie, outPort as f } from "./workflowBuilderModel.js";
9
+ import { WorkflowCompileError as ae, compileGraph as oe, decompileWorkflow as se, layoutGraph as p, seedGraph as ce } from "./workflowCompiler.js";
10
+ import { WorkflowRunsPanel as le } from "./WorkflowRunsPanel.js";
11
+ import { WorkflowCanvasNode as ue } from "./WorkflowCanvasNode.js";
12
+ import { WorkflowConfigEmpty as de, WorkflowNodeConfigPanel as fe } from "./WorkflowNodeConfigPanel.js";
13
+ import { useCallback as m, useEffect as h, useMemo as g, useRef as _, useState as v } from "react";
14
+ import { ChevronRight as pe, Maximize2 as me, Minus as he, Move as ge, Play as _e, Plus as ve, Save as ye } from "lucide-react";
15
+ import { useSearchParams as be } from "react-router";
13
16
  import { jsx as y, jsxs as b } from "react/jsx-runtime";
14
- import { PagePurpose as he } from "@burdenoff/fe-libs/ui";
17
+ import { PagePurpose as xe } from "@burdenoff/fe-libs/ui";
15
18
  //#region src/headshotmarketing/pages/automation/WorkflowBuilderPage.tsx
16
- var ge = 1600, _e = 1200, x = .5, S = 1.4, C = .82, w = {
19
+ var Se = 1600, Ce = 1400, x = .5, S = 1.4, we = .82, Te = {
17
20
  x: 12,
18
21
  y: 12
19
22
  };
20
- function T() {
21
- return {
22
- nodes: [
23
- {
24
- id: "trigger-1",
25
- kind: "trigger",
26
- actionType: "form_submit",
27
- label: "Trigger",
28
- x: 200,
29
- y: 24,
30
- config: {
31
- source: "form_submit",
32
- description: "When a form is submitted"
33
- }
34
- },
35
- {
36
- id: "node-email-1",
37
- kind: "action",
38
- actionType: "send_email",
39
- label: "Send Email",
40
- x: 200,
41
- y: 150,
42
- config: { emailTemplate: "Welcome Email" }
43
- },
44
- {
45
- id: "node-cond-1",
46
- kind: "action",
47
- actionType: "condition",
48
- label: "Condition",
49
- x: 200,
50
- y: 276,
51
- config: { conditionRule: "Opened email" }
52
- },
53
- {
54
- id: "node-wait-1",
55
- kind: "action",
56
- actionType: "wait",
57
- label: "Wait / Delay",
58
- x: 36,
59
- y: 426,
60
- config: {
61
- waitDuration: 2,
62
- waitUnit: "Days"
63
- }
64
- },
65
- {
66
- id: "node-sms-1",
67
- kind: "action",
68
- actionType: "send_sms",
69
- label: "Send SMS",
70
- x: 372,
71
- y: 426,
72
- config: {}
73
- },
74
- {
75
- id: "node-email-2",
76
- kind: "action",
77
- actionType: "send_email",
78
- label: "Send Email",
79
- x: 36,
80
- y: 560,
81
- config: { emailTemplate: "Case Study" }
82
- }
83
- ],
84
- edges: [
85
- {
86
- id: "e1",
87
- source: "trigger-1",
88
- target: "node-email-1",
89
- branch: null
90
- },
91
- {
92
- id: "e2",
93
- source: "node-email-1",
94
- target: "node-cond-1",
95
- branch: null
96
- },
97
- {
98
- id: "e3",
99
- source: "node-cond-1",
100
- target: "node-wait-1",
101
- branch: "yes"
102
- },
103
- {
104
- id: "e4",
105
- source: "node-cond-1",
106
- target: "node-sms-1",
107
- branch: "no"
108
- },
109
- {
110
- id: "e5",
111
- source: "node-wait-1",
112
- target: "node-email-2",
113
- branch: null
114
- }
115
- ]
116
- };
117
- }
118
- function ve(e) {
119
- switch (e) {
120
- case "send_email": return { emailTemplate: "Welcome Email" };
121
- case "wait": return {
122
- waitDuration: 3,
123
- waitUnit: "Days"
124
- };
125
- case "condition": return { conditionRule: "" };
126
- default: return {};
127
- }
128
- }
129
- function ye(e) {
130
- let t = e.config;
131
- if (e.kind === "trigger") return p(e.actionType);
132
- if (t.description) return t.description;
133
- switch (e.actionType) {
134
- case "send_email": return t.emailTemplate ? `Template: ${t.emailTemplate}` : "Send an email";
135
- case "send_sms": return t.message ? t.message : "Send an SMS";
136
- case "wait": return t.waitDuration ? `Wait ${t.waitDuration} ${(t.waitUnit ?? "days").toLowerCase()}` : "Add a delay";
137
- case "condition": return t.conditionRule ? `${t.conditionRule}?` : "Set a condition";
138
- case "notify": return t.message ? t.message : "Notify your team";
139
- case "webhook": return t.webhookUrl ? t.webhookUrl : "Call a webhook";
140
- case "add_tag": return t.tag ? `Tag: ${t.tag}` : "Add a tag";
141
- case "update_score": return t.points == null ? "Update lead score" : `${t.points} points`;
142
- default: return u(e.actionType)?.label ?? "";
143
- }
144
- }
145
- function E(e) {
23
+ function Ee(e) {
146
24
  return e === "yes" ? "var(--color-status-success-text)" : e === "no" ? "var(--color-status-error-text)" : "var(--color-action-primary-bg)";
147
25
  }
148
- function be(e) {
26
+ function De(e) {
149
27
  return e === "yes" ? "wf-arrow-yes" : e === "no" ? "wf-arrow-no" : "wf-arrow-accent";
150
28
  }
151
- function D(e) {
152
- let t = e.toUpperCase();
153
- return t === "COMPLETED" ? "success" : t === "FAILED" || t === "TIMED_OUT" || t === "CANCELLED" ? "error" : t === "RUNNING" ? "info" : "warning";
29
+ function Oe(e, t) {
30
+ return e instanceof Error && e.message ? e.message : t;
154
31
  }
155
- var O = () => {
156
- let { navigate: p, basePath: O } = r(), [k, { loading: A }] = t(), [xe] = n(), [j, Se] = _("New Workflow"), [M, N] = _(() => T().nodes), [P, F] = _(() => T().edges), [I, L] = _("node-email-1"), [R, z] = _(null), [Ce, we] = _(null), [B, Te] = _(null), [V, H] = _(!1), [Ee, U] = _([]), [W, G] = _(C), [K, De] = _(w), q = g(null), Oe = g(null), J = h(() => {
32
+ function ke(e, t, n) {
33
+ let r = e.find((e) => e.id === n);
34
+ if (!r || r.kind === "trigger") return {
35
+ nodes: e,
36
+ edges: t
37
+ };
38
+ let i = t.filter((e) => e.target === n), a = t.filter((e) => e.source === n), o = i.find((e) => e.branch !== "no") ?? i[0], s = t.filter((e) => e.source !== n && e.target !== n), c = a.length === 1 ? a[0] : void 0;
39
+ return o && c && !d(r) && s.push({
40
+ id: `edge-${o.source}-${c.target}-${Date.now()}`,
41
+ source: o.source,
42
+ target: c.target,
43
+ branch: o.branch
44
+ }), {
45
+ nodes: e.filter((e) => e.id !== n),
46
+ edges: s
47
+ };
48
+ }
49
+ function Ae(e, t, n, r, i) {
50
+ let a = e.find((e) => e.id === n);
51
+ if (!a) return { error: "Select the step to add after." };
52
+ let o = t.filter((e) => e.source === n);
53
+ if (d(a)) {
54
+ let a = o.some((e) => e.branch === "yes"), s = o.some((e) => e.branch === "no");
55
+ return a && s ? { error: "This condition already has a Yes and a No path — select a step on one of them to add after it." } : {
56
+ nodes: [...e, r],
57
+ edges: [...t, {
58
+ id: `edge-${i}`,
59
+ source: n,
60
+ target: r.id,
61
+ branch: a ? "no" : "yes"
62
+ }]
63
+ };
64
+ }
65
+ let s = o[0], c = s ? t.filter((e) => e.id !== s.id) : t, l = [{
66
+ id: `edge-${i}`,
67
+ source: n,
68
+ target: r.id,
69
+ branch: null
70
+ }];
71
+ return s && l.push({
72
+ id: `edge-${i}-next`,
73
+ source: r.id,
74
+ target: s.target,
75
+ branch: d(r) ? "yes" : null
76
+ }), {
77
+ nodes: [...e, r],
78
+ edges: [...c, ...l]
79
+ };
80
+ }
81
+ var C = () => {
82
+ let { navigate: d, basePath: C } = i(), [je, Me] = be(), w = je.get("id"), { data: Ne, loading: T, error: Pe } = n({
83
+ variables: { id: w ?? "" },
84
+ skip: !w,
85
+ fetchPolicy: "network-only"
86
+ }), [Fe] = t(), [Ie] = r(), [Le] = e(), [E, Re] = v("New Workflow"), [D, O] = v(null), [k, A] = v(() => ce().nodes), [j, M] = v(() => ce().edges), [N, P] = v(null), [ze, Be] = v(null), [Ve, F] = v(null), [I, L] = v(null), [R, z] = v(!1), [He, B] = v([]), V = _(null), H = Ne?.headshotmarketingAutomationWorkflow ?? null;
87
+ h(() => {
88
+ if (!H || V.current === H.id) return;
89
+ V.current = H.id;
90
+ let e = se(H);
91
+ A(e.nodes), M(e.edges), Re(H.name), O(H), P(null);
92
+ }, [H]);
93
+ let [U, W] = v(we), [G, Ue] = v(Te), K = _(null), We = _(null), q = g(() => {
157
94
  let e = /* @__PURE__ */ new Map();
158
- for (let t of M) e.set(t.id, t);
95
+ for (let t of k) e.set(t.id, t);
159
96
  return e;
160
- }, [M]), Y = I ? J.get(I) ?? null : null, ke = h(() => M.find((e) => e.kind === "trigger") ?? null, [M]), X = ke?.actionType ?? "form_submit", Z = m((e) => {
161
- U((t) => t.filter((t) => t.id !== e));
162
- }, []), Q = m((e) => {
97
+ }, [k]), J = N ? q.get(N) ?? null : null, Y = g(() => k.find((e) => e.kind === "trigger") ?? null, [k]), X = m((e) => {
98
+ B((t) => t.filter((t) => t.id !== e));
99
+ }, []), Z = m((e) => {
163
100
  let t = `toast-${Date.now()}-${Math.round(performance.now())}`;
164
- U((n) => [...n, {
101
+ B((n) => [...n, {
165
102
  ...e,
166
103
  id: t
167
- }]), window.setTimeout(() => Z(t), 5e3);
168
- }, [Z]), Ae = m((e, t, n) => {
169
- N((r) => r.map((r) => r.id === e ? {
104
+ }]), window.setTimeout(() => X(t), 5e3);
105
+ }, [X]), Q = () => {
106
+ Be(null), F(null);
107
+ }, Ge = m((e, t, n) => {
108
+ A((r) => r.map((r) => r.id === e ? {
170
109
  ...r,
171
110
  x: t,
172
111
  y: n
173
112
  } : r));
174
- }, []), je = m((e, t) => {
175
- N((n) => n.map((n) => n.id === e ? {
113
+ }, []), Ke = m((e, t) => {
114
+ A((n) => n.map((n) => n.id === e ? {
176
115
  ...n,
177
116
  label: t
178
117
  } : n));
179
- }, []), Me = m((e, t) => {
180
- N((n) => n.map((n) => n.id === e ? {
118
+ }, []), qe = m((e, t) => {
119
+ A((n) => n.map((n) => n.id === e ? {
181
120
  ...n,
182
121
  config: {
183
122
  ...n.config,
184
123
  ...t
185
124
  }
186
125
  } : n));
187
- }, []), Ne = m((e) => {
188
- N((t) => t.map((t) => t.kind === "trigger" ? {
126
+ }, []), Je = m((e) => {
127
+ A((t) => t.map((t) => t.kind === "trigger" ? {
189
128
  ...t,
190
- actionType: e,
191
- config: {
192
- ...t.config,
193
- source: e
194
- }
129
+ actionType: e
195
130
  } : t));
196
- }, []), Pe = m((e) => {
197
- let t = J.get(e);
198
- !t || t.kind === "trigger" || (N((t) => t.filter((t) => t.id !== e)), F((t) => t.filter((t) => t.source !== e && t.target !== e)), L((t) => t === e ? null : t));
199
- }, [J]), Fe = m((e) => {
200
- let t = u(e);
131
+ }, []), Ye = m((e) => {
132
+ let t = ke(k, j, e);
133
+ A(p(t.nodes, t.edges)), M(t.edges), P((t) => t === e ? null : t), Q();
134
+ }, [k, j]), Xe = m((e) => {
135
+ let t = te(e);
201
136
  if (!t) return;
202
- let n = Y ?? M[M.length - 1] ?? null, r = null, i = 0;
203
- if (n && te(n)) {
204
- let e = P.filter((e) => e.source === n.id), t = e.some((e) => e.branch === "yes"), a = e.some((e) => e.branch === "no");
205
- t ? a || (r = "no", i = 164) : (r = "yes", i = -164);
206
- }
207
- let a = `node-${Date.now()}`, o = n ? n.x : 200, s = n ? n.y + 78 + 72 : 24, c = {
208
- id: a,
137
+ let n = J?.id ?? Y?.id ?? null;
138
+ if (!n) return;
139
+ let r = Date.now(), i = {
140
+ id: `node-${r}`,
209
141
  kind: "action",
210
142
  actionType: e,
211
143
  label: t.label,
212
- x: o + i,
213
- y: s,
214
- config: ve(e)
215
- };
216
- N((e) => [...e, c]), n && F((e) => [...e, {
217
- id: `edge-${Date.now()}`,
218
- source: n.id,
219
- target: a,
220
- branch: r
221
- }]), L(a);
144
+ x: 0,
145
+ y: 0,
146
+ config: ne(e)
147
+ }, a = Ae(k, j, n, i, r);
148
+ if ("error" in a) {
149
+ F(a.error);
150
+ return;
151
+ }
152
+ A(p(a.nodes, a.edges)), M(a.edges), P(i.id), Q();
222
153
  }, [
154
+ J,
223
155
  Y,
224
- M,
225
- P
156
+ k,
157
+ j
226
158
  ]);
227
- oe(() => {
228
- I && typeof window < "u" && window.innerWidth < 1280 && Oe.current?.scrollIntoView({
159
+ h(() => {
160
+ N && typeof window < "u" && window.innerWidth < 1280 && We.current?.scrollIntoView({
229
161
  behavior: "smooth",
230
162
  block: "nearest"
231
163
  });
232
- }, [I]);
233
- let Ie = (e) => G((t) => Math.min(S, Math.max(x, Math.round((t + e) * 100) / 100))), Le = () => {
234
- G(C), De(w);
235
- }, Re = (e) => {
236
- q.current = {
164
+ }, [N]);
165
+ let Ze = (e) => W((t) => Math.min(S, Math.max(x, Math.round((t + e) * 100) / 100))), Qe = () => {
166
+ W(we), Ue(Te);
167
+ }, $e = (e) => {
168
+ K.current = {
237
169
  startX: e.clientX,
238
170
  startY: e.clientY,
239
- originX: K.x,
240
- originY: K.y,
171
+ originX: G.x,
172
+ originY: G.y,
241
173
  moved: !1
242
174
  }, e.currentTarget.setPointerCapture(e.pointerId);
243
- }, ze = (e) => {
244
- let t = q.current;
175
+ }, et = (e) => {
176
+ let t = K.current;
245
177
  if (!t) return;
246
178
  let n = e.clientX - t.startX, r = e.clientY - t.startY;
247
- !t.moved && Math.hypot(n, r) < 3 || (t.moved = !0, De({
179
+ !t.moved && Math.hypot(n, r) < 3 || (t.moved = !0, Ue({
248
180
  x: t.originX + n,
249
181
  y: t.originY + r
250
182
  }));
251
- }, Be = (e) => {
252
- let t = q.current;
253
- q.current = null, e.currentTarget.releasePointerCapture?.(e.pointerId), t && !t.moved && L(null);
254
- }, Ve = () => j.trim() ? M.length === 0 ? (z("Add at least one workflow step."), !1) : (z(null), !0) : (z("Workflow name is required."), !1), He = (e) => e.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 48) || "workflow", Ue = (e) => {
255
- switch (e) {
256
- case "schedule": return "SCHEDULE";
257
- case "webhook": return "WEBHOOK";
258
- case "event":
259
- case "score_change":
260
- case "tag_added":
261
- case "form_submit": return "EVENT";
262
- default: return "MANUAL";
263
- }
264
- }, We = (e) => {
265
- let t = ne(M, P), n = Ue(X);
266
- return {
267
- workflowKey: `headshotmarketing-${He(j.trim())}-${Date.now()}`,
268
- version: "1.0.0",
269
- name: j.trim(),
270
- description: ke?.config.description ?? null,
271
- category: "headshotmarketing",
272
- tags: [],
273
- context: {
274
- product: "headshotmarketing",
275
- triggerType: n,
276
- triggerConfig: { source: X },
277
- builder: !0
278
- },
279
- definitionJson: {
280
- triggerType: n,
281
- triggerConfig: { source: X },
282
- steps: t,
283
- builder: !0,
284
- version: 2
285
- }
286
- };
287
- }, Ge = async (t) => {
288
- if (Ve()) try {
289
- await k({
290
- variables: { input: We(t) },
291
- refetchQueries: [{
292
- query: e,
293
- variables: { limit: 50 }
294
- }],
295
- awaitRefetchQueries: !0
296
- }), p(O + "/automation/workflows");
183
+ }, tt = (e) => {
184
+ let t = K.current;
185
+ K.current = null, e.currentTarget.releasePointerCapture?.(e.pointerId), t && !t.moved && P(null);
186
+ }, $ = () => {
187
+ if (!E.trim()) return F("Give the workflow a name."), null;
188
+ try {
189
+ let e = oe(k, j);
190
+ return Q(), e;
297
191
  } catch (e) {
298
- let t = e instanceof Error ? e.message : "Failed to save workflow.";
299
- z(t), Q({
300
- title: "Save failed",
301
- description: t,
302
- variant: "error"
303
- });
192
+ if (e instanceof ae) return F(e.message), Be(e.nodeId), e.nodeId && P(e.nodeId), null;
193
+ throw e;
304
194
  }
305
- }, Ke = async () => {
306
- if (Ve()) {
307
- H(!0);
195
+ }, nt = async (e) => {
196
+ let t = e.triggerType, n = D?.description ?? null;
197
+ if (D) return (await Ie({ variables: {
198
+ id: D.id,
199
+ input: {
200
+ name: E.trim(),
201
+ description: n,
202
+ triggerType: t,
203
+ triggerConfig: e.triggerConfig,
204
+ steps: e.steps
205
+ }
206
+ } })).data?.updateHeadshotmarketingAutomationWorkflow ?? null;
207
+ let r = (await Fe({ variables: { input: {
208
+ name: E.trim(),
209
+ description: n,
210
+ triggerType: t,
211
+ triggerConfig: e.triggerConfig,
212
+ steps: e.steps
213
+ } } })).data?.createHeadshotmarketingAutomationWorkflow ?? null;
214
+ return r && (V.current = r.id, Me({ id: r.id }, { replace: !0 })), r;
215
+ }, rt = async () => {
216
+ let e = $();
217
+ if (e) {
218
+ L("save");
308
219
  try {
309
- let e = Ce;
310
- if (!e) {
311
- let t = (await k({ variables: { input: We("draft") } })).data?.createHeadshotmarketingWorkflow;
312
- e = t ? {
313
- id: t.id,
314
- workflowKey: t.workflowKey,
315
- version: t.version
316
- } : null, we(e);
317
- }
318
- if (!e) throw Error("Could not create a workflow to test.");
319
- let t = (await xe({ variables: { input: {
320
- workflowKey: e.workflowKey,
321
- version: e.version,
322
- triggerNodeId: "manual",
323
- triggerData: {
324
- source: X,
325
- test: !0
326
- },
327
- context: { product: "headshotmarketing" }
328
- } } })).data?.triggerHeadshotmarketingWorkflow;
329
- t && (Te({
330
- id: t.id,
331
- status: t.status,
332
- startedAt: (/* @__PURE__ */ new Date()).toISOString()
333
- }), Q({
334
- title: "Test run started",
335
- description: `Execution ${t.id.slice(0, 8)} — ${t.status.toLowerCase()}`,
220
+ let t = await nt(e);
221
+ t && (O(t), Z({
222
+ title: "Workflow saved",
223
+ description: t.status === "ACTIVE" ? "Changes are live for new runs." : "Saved as a draft. Publish it to start running.",
336
224
  variant: "success"
337
225
  }));
338
226
  } catch (e) {
339
- let t = e instanceof Error ? e.message : "Failed to run test.";
340
- z(t), Q({
341
- title: "Test failed",
227
+ let t = Oe(e, "Failed to save the workflow.");
228
+ F(t), Z({
229
+ title: "Save failed",
342
230
  description: t,
343
231
  variant: "error"
344
232
  });
345
233
  } finally {
346
- H(!1);
234
+ L(null);
347
235
  }
348
236
  }
349
- }, qe = Math.round(W * 100), $ = A || V;
350
- return /* @__PURE__ */ b(o, {
237
+ }, it = async () => {
238
+ let e = $();
239
+ if (e) {
240
+ L("publish");
241
+ try {
242
+ let t = await nt(e);
243
+ t && t.status !== "ACTIVE" && (t = (await Le({ variables: { id: t.id } })).data?.activateHeadshotmarketingAutomationWorkflow ?? t), t && O(t), d(C + "/automation/workflows");
244
+ } catch (e) {
245
+ let t = Oe(e, "Failed to publish the workflow.");
246
+ F(t), Z({
247
+ title: "Publish failed",
248
+ description: t,
249
+ variant: "error"
250
+ });
251
+ } finally {
252
+ L(null);
253
+ }
254
+ }
255
+ }, at = () => {
256
+ let e = $();
257
+ if (e) {
258
+ if (D?.status === "ACTIVE") {
259
+ z(!0);
260
+ return;
261
+ }
262
+ Z({
263
+ title: "Workflow is valid",
264
+ description: `${e.steps.length} engine step${e.steps.length === 1 ? "" : "s"}. Publish it to run it for a lead.`,
265
+ variant: "success"
266
+ });
267
+ }
268
+ }, ot = Math.round(U * 100), st = Y?.actionType ?? "LEAD_CREATED";
269
+ return w && T && !D ? /* @__PURE__ */ y(o, {
270
+ title: "Workflow Builder",
271
+ children: /* @__PURE__ */ y("p", {
272
+ className: "text-sm text-text-secondary",
273
+ children: "Loading workflow…"
274
+ })
275
+ }) : w && !T && !H && !D ? /* @__PURE__ */ b(o, {
276
+ title: "Workflow Builder",
277
+ children: [/* @__PURE__ */ y("div", {
278
+ className: "rounded-lg border border-status-error-border bg-status-error-bg px-4 py-3 text-sm text-status-error-text",
279
+ children: Pe ? `Could not load this workflow: ${Pe.message}` : "This workflow does not exist or was deleted."
280
+ }), /* @__PURE__ */ y("button", {
281
+ type: "button",
282
+ onClick: () => d(C + "/automation/workflows"),
283
+ className: "inline-flex min-h-10 w-fit items-center gap-2 rounded-md border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken",
284
+ children: "Back to workflows"
285
+ })]
286
+ }) : /* @__PURE__ */ b(o, {
351
287
  title: "Workflow Builder",
288
+ header: /* @__PURE__ */ b("nav", {
289
+ "aria-label": "Breadcrumb",
290
+ className: "flex min-w-0 items-center gap-1.5 text-base font-normal sm:text-lg",
291
+ children: [
292
+ /* @__PURE__ */ y("button", {
293
+ type: "button",
294
+ onClick: () => d(C + "/automation/workflows"),
295
+ className: "text-text-secondary hover:text-text-primary",
296
+ children: "Automation"
297
+ }),
298
+ /* @__PURE__ */ y(pe, {
299
+ className: "h-4 w-4 flex-shrink-0 text-text-secondary",
300
+ "aria-hidden": !0
301
+ }),
302
+ /* @__PURE__ */ y("input", {
303
+ type: "text",
304
+ value: E,
305
+ onChange: (e) => Re(e.target.value),
306
+ "aria-label": "Workflow name",
307
+ className: "min-w-0 flex-1 rounded-md border border-transparent bg-transparent px-1 py-0.5 font-semibold text-text-primary outline-none hover:border-border-subtle focus:border-border-strong",
308
+ placeholder: "Workflow name"
309
+ }),
310
+ D && /* @__PURE__ */ y(s, {
311
+ status: D.status.toLowerCase(),
312
+ className: "ml-1"
313
+ })
314
+ ]
315
+ }),
352
316
  actions: /* @__PURE__ */ b("div", {
353
317
  className: "flex flex-wrap items-center gap-2",
354
318
  children: [
355
319
  /* @__PURE__ */ b("button", {
356
- onClick: () => p(O + "/automation/workflows"),
357
- className: "inline-flex min-h-10 items-center gap-2 rounded-md border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary transition-colors hover:bg-bg-sunken",
358
- children: [/* @__PURE__ */ y(se, { className: "h-4 w-4" }), "Back"]
359
- }),
360
- /* @__PURE__ */ b("button", {
361
- onClick: () => void Ke(),
362
- disabled: $,
320
+ onClick: at,
321
+ disabled: I !== null,
363
322
  className: "inline-flex min-h-10 items-center gap-2 rounded-md border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary transition-colors hover:bg-bg-sunken disabled:opacity-60",
364
- children: [/* @__PURE__ */ y(fe, { className: "h-4 w-4" }), V ? "Testing…" : "Test"]
323
+ children: [/* @__PURE__ */ y(_e, { className: "h-4 w-4" }), "Test"]
365
324
  }),
366
325
  /* @__PURE__ */ b("button", {
367
- onClick: () => void Ge("draft"),
368
- disabled: $,
326
+ onClick: () => void rt(),
327
+ disabled: I !== null,
369
328
  className: "inline-flex min-h-10 items-center gap-2 rounded-md border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary transition-colors hover:bg-bg-sunken disabled:opacity-60",
370
- children: [/* @__PURE__ */ y(pe, { className: "h-4 w-4" }), A && !V ? "Saving…" : "Save"]
329
+ children: [/* @__PURE__ */ y(ye, { className: "h-4 w-4" }), I === "save" ? "Saving…" : "Save draft"]
371
330
  }),
372
- /* @__PURE__ */ b("button", {
373
- onClick: () => void Ge("active"),
374
- disabled: $,
375
- className: "inline-flex min-h-10 items-center gap-2 rounded-md bg-action-primary-bg px-3.5 py-2 text-sm font-semibold text-action-primary-text transition-colors hover:bg-action-primary-bgHover disabled:opacity-60",
376
- children: [/* @__PURE__ */ y(me, { className: "h-4 w-4" }), "Activate"]
331
+ /* @__PURE__ */ y("button", {
332
+ onClick: () => void it(),
333
+ disabled: I !== null,
334
+ className: "inline-flex min-h-10 items-center gap-2 rounded-md bg-action-primary-bg px-4 py-2 text-sm font-semibold text-action-primary-text transition-colors hover:bg-action-primary-bgHover disabled:opacity-60",
335
+ children: I === "publish" ? "Publishing…" : D?.status === "ACTIVE" ? "Publish changes" : "Publish"
377
336
  })
378
337
  ]
379
338
  }),
380
339
  children: [
381
- /* @__PURE__ */ y(he, { children: "Design an automation visually. Pick the trigger that starts it, drag in the steps it should run — send an email or SMS, wait, branch on a condition — and connect them on the canvas. Test a dry run, save a draft while you iterate, or activate it to put it to work." }),
382
- R && /* @__PURE__ */ y("div", {
383
- className: "rounded-lg border border-status-error-border/30 bg-status-error-bg/10 px-4 py-3 text-sm text-status-error-text",
384
- children: R
340
+ /* @__PURE__ */ y(xe, { children: "Design an automation visually. Pick the trigger that starts it, add the steps it should run — email, notify your team, wait, branch on a condition, tag, update a field, call a webhook — and Publish to put it to work on every new lead or contact. Save a draft while you iterate." }),
341
+ Ve && /* @__PURE__ */ y("div", {
342
+ role: "alert",
343
+ className: "rounded-lg border border-status-error-border bg-status-error-bg px-4 py-3 text-sm text-status-error-text",
344
+ children: Ve
385
345
  }),
386
- B && /* @__PURE__ */ b("div", {
387
- className: "flex flex-wrap items-center gap-3 rounded-card border border-border-seam bg-gloss-card shadow-pop px-4 py-3",
388
- children: [
389
- /* @__PURE__ */ y("span", {
390
- className: i("flex h-9 w-9 items-center justify-center rounded-lg ring-1 ring-inset", l[D(B.status)]),
391
- children: /* @__PURE__ */ y(ce, { className: "h-4 w-4" })
392
- }),
393
- /* @__PURE__ */ b("div", {
394
- className: "min-w-0 flex-1",
395
- children: [/* @__PURE__ */ y("p", {
396
- className: "text-sm font-semibold text-text-primary",
397
- children: "Last test run"
346
+ /* @__PURE__ */ b("div", {
347
+ className: "overflow-hidden rounded-card border border-border-seam bg-gloss-card shadow-pop",
348
+ children: [/* @__PURE__ */ b("div", {
349
+ className: "flex items-center justify-between gap-3 border-b border-border-subtle px-4 py-3",
350
+ children: [/* @__PURE__ */ b("div", {
351
+ className: "min-w-0",
352
+ children: [/* @__PURE__ */ y("h3", {
353
+ className: "text-sm font-semibold uppercase tracking-wide text-text-primary",
354
+ children: "Workflow Builder"
398
355
  }), /* @__PURE__ */ b("p", {
399
- className: "truncate text-xs text-text-secondary",
356
+ className: "text-xs text-text-secondary",
400
357
  children: [
401
- "Execution ",
402
- B.id.slice(0, 8),
403
- B.startedAt ? ` · started ${a(B.startedAt, "relative")}` : ""
358
+ k.length - 1,
359
+ " step",
360
+ k.length === 2 ? "" : "s",
361
+ " ·",
362
+ " ",
363
+ /* @__PURE__ */ b("span", {
364
+ className: "hidden sm:inline",
365
+ children: [/* @__PURE__ */ y(ge, { className: "mr-1 inline h-3.5 w-3.5" }), "drag nodes · drag the canvas to pan"]
366
+ })
404
367
  ]
405
368
  })]
406
- }),
407
- /* @__PURE__ */ y("span", {
408
- className: i("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium capitalize ring-1 ring-inset", l[D(B.status)]),
409
- children: B.status.toLowerCase().replace(/_/g, " ")
410
- })
411
- ]
412
- }),
413
- /* @__PURE__ */ b("div", {
414
- className: "rounded-card border border-border-seam bg-gloss-card shadow-pop p-4",
415
- children: [/* @__PURE__ */ y("label", {
416
- className: "mb-1 block text-xs font-medium text-text-secondary",
417
- children: "Workflow name"
418
- }), /* @__PURE__ */ y("input", {
419
- type: "text",
420
- value: j,
421
- onChange: (e) => Se(e.target.value),
422
- className: "w-full border-none bg-transparent text-lg font-semibold text-text-primary outline-none placeholder:text-text-secondary",
423
- placeholder: "Workflow name"
424
- })]
425
- }),
426
- /* @__PURE__ */ b("div", {
427
- className: "grid grid-cols-1 gap-6 xl:grid-cols-[200px_minmax(0,1fr)_272px]",
428
- children: [
429
- /* @__PURE__ */ b("div", {
430
- className: "space-y-4",
431
- children: [/* @__PURE__ */ b("div", {
432
- className: "rounded-card border border-border-seam bg-gloss-card shadow-pop p-4",
433
- children: [/* @__PURE__ */ y("h4", {
434
- className: "mb-3 text-sm font-semibold text-text-primary",
435
- children: "Trigger"
436
- }), /* @__PURE__ */ y("div", {
437
- className: "space-y-1.5",
438
- children: ee.map((e) => /* @__PURE__ */ b("button", {
439
- onClick: () => Ne(e.type),
440
- className: i("flex min-h-10 w-full items-center gap-2 rounded-md border px-3 py-2 text-left text-sm transition-colors", X === e.type ? "border-[color-mix(in_oklab,var(--color-action-primary-bg)_40%,transparent)] bg-[var(--color-accent-soft)] text-text-primary" : "border-border-subtle text-text-primary hover:bg-bg-sunken"),
441
- children: [/* @__PURE__ */ y("span", {
442
- "aria-hidden": !0,
443
- children: e.icon
444
- }), /* @__PURE__ */ y("span", {
445
- className: "truncate",
446
- children: e.label
447
- })]
448
- }, e.type))
449
- })]
450
- }), /* @__PURE__ */ b("div", {
451
- className: "rounded-card border border-border-seam bg-gloss-card shadow-pop p-4",
369
+ }), /* @__PURE__ */ b("div", {
370
+ className: "flex items-center gap-0.5 rounded-lg border border-border-seam bg-gloss-card p-1",
371
+ children: [
372
+ /* @__PURE__ */ y("button", {
373
+ type: "button",
374
+ onClick: () => Ze(-.1),
375
+ disabled: U <= x,
376
+ "aria-label": "Zoom out",
377
+ className: "flex h-8 w-8 items-center justify-center rounded-md text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary disabled:opacity-40",
378
+ children: /* @__PURE__ */ y(he, { className: "h-4 w-4" })
379
+ }),
380
+ /* @__PURE__ */ b("span", {
381
+ className: "min-w-11 text-center text-xs font-medium tabular-nums text-text-secondary",
382
+ children: [ot, "%"]
383
+ }),
384
+ /* @__PURE__ */ y("button", {
385
+ type: "button",
386
+ onClick: () => Ze(.1),
387
+ disabled: U >= S,
388
+ "aria-label": "Zoom in",
389
+ className: "flex h-8 w-8 items-center justify-center rounded-md text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary disabled:opacity-40",
390
+ children: /* @__PURE__ */ y(ve, { className: "h-4 w-4" })
391
+ }),
392
+ /* @__PURE__ */ y("span", {
393
+ className: "mx-0.5 h-5 w-px bg-border-subtle",
394
+ "aria-hidden": !0
395
+ }),
396
+ /* @__PURE__ */ y("button", {
397
+ type: "button",
398
+ onClick: Qe,
399
+ "aria-label": "Reset view",
400
+ className: "flex h-8 w-8 items-center justify-center rounded-md text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary",
401
+ children: /* @__PURE__ */ y(me, { className: "h-4 w-4" })
402
+ })
403
+ ]
404
+ })]
405
+ }), /* @__PURE__ */ b("div", {
406
+ className: "grid grid-cols-1 lg:grid-cols-[104px_minmax(0,1fr)]",
407
+ children: [/* @__PURE__ */ y("div", {
408
+ className: "flex gap-2 overflow-x-auto border-b border-border-subtle p-3 lg:flex-col lg:overflow-visible lg:border-b-0 lg:border-r",
409
+ "aria-label": "Add a step",
410
+ children: l.map((e) => {
411
+ let t = e.icon;
412
+ return /* @__PURE__ */ b("button", {
413
+ type: "button",
414
+ onClick: () => Xe(e.type),
415
+ title: `Add ${e.label} after the selected step`,
416
+ className: "flex min-w-[76px] flex-col items-center gap-1 rounded-lg border border-border-subtle bg-bg-surface px-2 py-2 text-[11px] font-medium text-text-primary transition-colors hover:border-border-strong hover:bg-bg-sunken",
417
+ children: [/* @__PURE__ */ y("span", {
418
+ className: a("flex h-7 w-7 items-center justify-center rounded-md ring-1 ring-inset", u[e.tone]),
419
+ children: /* @__PURE__ */ y(t, { className: "h-3.5 w-3.5" })
420
+ }), /* @__PURE__ */ y("span", {
421
+ className: "text-center leading-tight",
422
+ children: e.shortLabel
423
+ })]
424
+ }, e.type);
425
+ })
426
+ }), /* @__PURE__ */ y("div", {
427
+ onPointerDown: $e,
428
+ onPointerMove: et,
429
+ onPointerUp: tt,
430
+ onPointerCancel: tt,
431
+ "data-testid": "workflow-canvas",
432
+ className: "relative h-[520px] w-full cursor-grab overflow-hidden bg-bg-sunken active:cursor-grabbing sm:h-[600px]",
433
+ style: {
434
+ touchAction: "none",
435
+ backgroundImage: "radial-gradient(var(--color-border-subtle) 1px, transparent 1px)",
436
+ backgroundSize: `${20 * U}px ${20 * U}px`,
437
+ backgroundPosition: `${G.x}px ${G.y}px`
438
+ },
439
+ children: /* @__PURE__ */ b("div", {
440
+ className: "absolute left-0 top-0 origin-top-left",
441
+ style: { transform: `translate(${G.x}px, ${G.y}px) scale(${U})` },
452
442
  children: [
453
- /* @__PURE__ */ y("h4", {
454
- className: "mb-3 text-sm font-semibold text-text-primary",
455
- children: "Actions"
443
+ /* @__PURE__ */ b("svg", {
444
+ width: Se,
445
+ height: Ce,
446
+ className: "pointer-events-none absolute left-0 top-0 overflow-visible",
447
+ children: [/* @__PURE__ */ y("defs", { children: [
448
+ "accent",
449
+ "yes",
450
+ "no"
451
+ ].map((e) => {
452
+ let t = e === "yes" ? "yes" : e === "no" ? "no" : null;
453
+ return /* @__PURE__ */ y("marker", {
454
+ id: `wf-arrow-${e}`,
455
+ viewBox: "0 0 10 10",
456
+ refX: "8",
457
+ refY: "5",
458
+ markerWidth: "7",
459
+ markerHeight: "7",
460
+ orient: "auto-start-reverse",
461
+ children: /* @__PURE__ */ y("path", {
462
+ d: "M0,0 L10,5 L0,10 z",
463
+ style: { fill: Ee(t) }
464
+ })
465
+ }, e);
466
+ }) }), j.map((e) => {
467
+ let t = q.get(e.source), n = q.get(e.target);
468
+ if (!t || !n) return null;
469
+ let r = f(t, e.branch), i = re(n), a = (r.y + i.y) / 2;
470
+ return /* @__PURE__ */ y("path", {
471
+ d: `M ${r.x} ${r.y} C ${r.x} ${a} ${i.x} ${a} ${i.x} ${i.y}`,
472
+ fill: "none",
473
+ strokeWidth: 2,
474
+ strokeLinecap: "round",
475
+ style: { stroke: Ee(e.branch) },
476
+ markerEnd: `url(#${De(e.branch)})`
477
+ }, e.id);
478
+ })]
456
479
  }),
457
- /* @__PURE__ */ y("p", {
458
- className: "mb-3 text-[11px] text-text-secondary",
459
- children: "Adds after the selected node."
480
+ j.filter((e) => e.branch).map((e) => {
481
+ let t = q.get(e.source), n = q.get(e.target);
482
+ if (!t || !n) return null;
483
+ let r = f(t, e.branch), i = re(n);
484
+ return /* @__PURE__ */ y("span", {
485
+ style: {
486
+ left: (r.x + i.x) / 2,
487
+ top: (r.y + i.y) / 2
488
+ },
489
+ className: a("pointer-events-none absolute -translate-x-1/2 -translate-y-1/2 rounded-md px-1.5 py-0.5 text-[10px] font-semibold uppercase ring-1 ring-inset", e.branch === "yes" ? u.success : u.error),
490
+ children: e.branch
491
+ }, `label-${e.id}`);
460
492
  }),
461
- /* @__PURE__ */ y("div", {
462
- className: "space-y-1.5",
463
- children: c.map((e) => {
464
- let t = e.icon;
465
- return /* @__PURE__ */ b("button", {
466
- onClick: () => Fe(e.type),
467
- className: "flex min-h-10 w-full items-center gap-2.5 rounded-md border border-border-subtle px-2.5 py-2 text-left text-sm text-text-primary transition-colors hover:border-border-strong hover:bg-bg-sunken",
468
- children: [
469
- /* @__PURE__ */ y("span", {
470
- className: i("flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-md ring-1 ring-inset", l[e.tone]),
471
- children: /* @__PURE__ */ y(t, { className: "h-3.5 w-3.5" })
472
- }),
473
- /* @__PURE__ */ y("span", {
474
- className: "truncate",
475
- children: e.label
476
- }),
477
- /* @__PURE__ */ y(v, { className: "ml-auto h-3.5 w-3.5 flex-shrink-0 text-text-secondary" })
478
- ]
479
- }, e.type);
480
- })
481
- })
493
+ k.map((e) => /* @__PURE__ */ y(ue, {
494
+ node: e,
495
+ selected: N === e.id,
496
+ invalid: ze === e.id,
497
+ scale: U,
498
+ subtitle: ie(e),
499
+ onSelect: P,
500
+ onConfigure: P,
501
+ onDelete: Ye,
502
+ onPositionChange: Ge
503
+ }, e.id))
482
504
  ]
483
- })]
484
- }),
485
- /* @__PURE__ */ b("div", {
486
- className: "overflow-hidden rounded-card border border-border-seam bg-gloss-card shadow-pop",
487
- children: [/* @__PURE__ */ b("div", {
488
- className: "flex items-center justify-between gap-3 border-b border-border-subtle px-4 py-3",
489
- children: [/* @__PURE__ */ b("div", {
490
- className: "min-w-0",
491
- children: [/* @__PURE__ */ y("h3", {
492
- className: "text-sm font-semibold uppercase tracking-wide text-text-primary",
493
- children: "Workflow Canvas"
494
- }), /* @__PURE__ */ b("p", {
495
- className: "text-xs text-text-secondary",
496
- children: [
497
- M.length,
498
- " nodes · ",
499
- P.length,
500
- " connections"
501
- ]
505
+ })
506
+ })]
507
+ })]
508
+ }),
509
+ /* @__PURE__ */ b("div", {
510
+ className: "grid grid-cols-1 gap-4 lg:grid-cols-2",
511
+ children: [/* @__PURE__ */ y("div", {
512
+ ref: We,
513
+ children: J ? /* @__PURE__ */ y(fe, {
514
+ node: J,
515
+ onLabelChange: (e) => Ke(J.id, e),
516
+ onConfigChange: (e) => qe(J.id, e),
517
+ onTriggerChange: Je,
518
+ onClose: () => P(null)
519
+ }) : /* @__PURE__ */ y(de, {})
520
+ }), /* @__PURE__ */ b("div", {
521
+ className: "rounded-card border border-border-seam bg-gloss-card p-4 shadow-pop",
522
+ children: [
523
+ /* @__PURE__ */ y("h4", {
524
+ className: "mb-2 text-sm font-semibold text-text-primary",
525
+ children: "Trigger"
526
+ }),
527
+ /* @__PURE__ */ y("div", {
528
+ className: "grid grid-cols-1 gap-1.5 sm:grid-cols-2",
529
+ children: ee.map((e) => /* @__PURE__ */ b("button", {
530
+ type: "button",
531
+ onClick: () => Je(e.type),
532
+ "aria-pressed": st === e.type,
533
+ className: a("rounded-md border px-3 py-2 text-left text-sm transition-colors", st === e.type ? "border-[color-mix(in_oklab,var(--color-action-primary-bg)_40%,transparent)] bg-[var(--color-accent-soft)] text-text-primary" : "border-border-subtle text-text-primary hover:bg-bg-sunken"),
534
+ children: [/* @__PURE__ */ y("span", {
535
+ className: "block font-medium",
536
+ children: e.label
537
+ }), /* @__PURE__ */ y("span", {
538
+ className: "block text-xs text-text-secondary",
539
+ children: e.description
502
540
  })]
503
- }), /* @__PURE__ */ b("div", {
504
- className: "hidden items-center gap-1.5 text-xs text-text-secondary sm:flex",
505
- children: [/* @__PURE__ */ y(de, { className: "h-3.5 w-3.5" }), "Drag nodes · drag canvas to pan"]
506
- })]
507
- }), /* @__PURE__ */ b("div", {
508
- onPointerDown: Re,
509
- onPointerMove: ze,
510
- onPointerUp: Be,
511
- onPointerCancel: Be,
512
- className: "relative h-[520px] w-full cursor-grab overflow-hidden bg-bg-sunken active:cursor-grabbing sm:h-[580px]",
513
- style: {
514
- touchAction: "none",
515
- backgroundImage: "radial-gradient(var(--color-border-subtle) 1px, transparent 1px)",
516
- backgroundSize: `${20 * W}px ${20 * W}px`,
517
- backgroundPosition: `${K.x}px ${K.y}px`
518
- },
519
- children: [/* @__PURE__ */ b("div", {
520
- className: "absolute right-3 top-3 z-20 flex items-center gap-0.5 rounded-lg border border-border-seam bg-gloss-card p-1 shadow-pop",
521
- children: [
522
- /* @__PURE__ */ y("button", {
523
- type: "button",
524
- onClick: () => Ie(-.1),
525
- disabled: W <= x,
526
- "aria-label": "Zoom out",
527
- className: "flex h-8 w-8 items-center justify-center rounded-md text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary disabled:opacity-40",
528
- children: /* @__PURE__ */ y(ue, { className: "h-4 w-4" })
529
- }),
530
- /* @__PURE__ */ b("span", {
531
- className: "min-w-11 text-center text-xs font-medium tabular-nums text-text-secondary",
532
- children: [qe, "%"]
533
- }),
534
- /* @__PURE__ */ y("button", {
535
- type: "button",
536
- onClick: () => Ie(.1),
537
- disabled: W >= S,
538
- "aria-label": "Zoom in",
539
- className: "flex h-8 w-8 items-center justify-center rounded-md text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary disabled:opacity-40",
540
- children: /* @__PURE__ */ y(v, { className: "h-4 w-4" })
541
- }),
542
- /* @__PURE__ */ y("span", {
543
- className: "mx-0.5 h-5 w-px bg-border-subtle",
544
- "aria-hidden": !0
545
- }),
546
- /* @__PURE__ */ y("button", {
547
- type: "button",
548
- onClick: Le,
549
- "aria-label": "Reset view",
550
- className: "flex h-8 w-8 items-center justify-center rounded-md text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary",
551
- children: /* @__PURE__ */ y(le, { className: "h-4 w-4" })
552
- })
553
- ]
554
- }), /* @__PURE__ */ b("div", {
555
- className: "absolute left-0 top-0 origin-top-left",
556
- style: { transform: `translate(${K.x}px, ${K.y}px) scale(${W})` },
557
- children: [
558
- /* @__PURE__ */ b("svg", {
559
- width: ge,
560
- height: _e,
561
- className: "pointer-events-none absolute left-0 top-0 overflow-visible",
562
- children: [/* @__PURE__ */ y("defs", { children: [
563
- "accent",
564
- "yes",
565
- "no"
566
- ].map((e) => {
567
- let t = e === "yes" ? "yes" : e === "no" ? "no" : null;
568
- return /* @__PURE__ */ y("marker", {
569
- id: `wf-arrow-${e}`,
570
- viewBox: "0 0 10 10",
571
- refX: "8",
572
- refY: "5",
573
- markerWidth: "7",
574
- markerHeight: "7",
575
- orient: "auto-start-reverse",
576
- children: /* @__PURE__ */ y("path", {
577
- d: "M0,0 L10,5 L0,10 z",
578
- style: { fill: E(t) }
579
- })
580
- }, e);
581
- }) }), P.map((e) => {
582
- let t = J.get(e.source), n = J.get(e.target);
583
- if (!t || !n) return null;
584
- let r = f(t, e.branch), i = d(n), a = (r.y + i.y) / 2;
585
- return /* @__PURE__ */ y("path", {
586
- d: `M ${r.x} ${r.y} C ${r.x} ${a} ${i.x} ${a} ${i.x} ${i.y}`,
587
- fill: "none",
588
- strokeWidth: 2,
589
- strokeLinecap: "round",
590
- style: { stroke: E(e.branch) },
591
- markerEnd: `url(#${be(e.branch)})`
592
- }, e.id);
593
- })]
594
- }),
595
- P.filter((e) => e.branch).map((e) => {
596
- let t = J.get(e.source), n = J.get(e.target);
597
- if (!t || !n) return null;
598
- let r = f(t, e.branch), a = d(n);
599
- return /* @__PURE__ */ y("span", {
600
- style: {
601
- left: (r.x + a.x) / 2,
602
- top: (r.y + a.y) / 2
603
- },
604
- className: i("pointer-events-none absolute -translate-x-1/2 -translate-y-1/2 rounded-md px-1.5 py-0.5 text-[10px] font-semibold uppercase ring-1 ring-inset", e.branch === "yes" ? l.success : l.error),
605
- children: e.branch
606
- }, `label-${e.id}`);
607
- }),
608
- M.map((e) => /* @__PURE__ */ y(re, {
609
- node: e,
610
- selected: I === e.id,
611
- scale: W,
612
- subtitle: ye(e),
613
- onSelect: L,
614
- onConfigure: L,
615
- onDelete: Pe,
616
- onPositionChange: Ae
617
- }, e.id))
618
- ]
619
- })]
620
- })]
621
- }),
622
- /* @__PURE__ */ y("div", {
623
- ref: Oe,
624
- className: "xl:sticky xl:top-4 xl:self-start",
625
- children: Y ? /* @__PURE__ */ y(ae, {
626
- node: Y,
627
- onLabelChange: (e) => je(Y.id, e),
628
- onConfigChange: (e) => Me(Y.id, e),
629
- onTriggerChange: Ne,
630
- onClose: () => L(null)
631
- }) : /* @__PURE__ */ y(ie, {})
632
- })
633
- ]
541
+ }, e.type))
542
+ }),
543
+ /* @__PURE__ */ y("p", {
544
+ className: "mt-3 text-xs text-text-secondary",
545
+ children: "Steps are added after the selected node. A Condition continues on its Yes path; give its No path steps of its own, or leave it empty to stop there."
546
+ })
547
+ ]
548
+ })]
549
+ }),
550
+ D && R && /* @__PURE__ */ y(le, {
551
+ workflow: D,
552
+ open: R,
553
+ onClose: () => z(!1),
554
+ onChanged: () => void 0
634
555
  }),
635
- /* @__PURE__ */ y(s, { toasts: Ee.map((e) => ({
556
+ /* @__PURE__ */ y(c, { toasts: He.map((e) => ({
636
557
  ...e,
637
- onDismiss: Z
558
+ onDismiss: X
638
559
  })) })
639
560
  ]
640
561
  });
641
562
  };
642
563
  //#endregion
643
- export { O as WorkflowBuilderPage };
564
+ export { C as WorkflowBuilderPage };
644
565
 
645
566
  //# sourceMappingURL=WorkflowBuilderPage.js.map