@burdenoff/microfe-bigconsole 2026.1004.7 → 2026.1005.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 (49) hide show
  1. package/dist/bigconsole/BigConsoleRoutes.d.ts +7 -1
  2. package/dist/bigconsole/BigConsoleRoutes.d.ts.map +1 -1
  3. package/dist/bigconsole/BigConsoleRoutes.js +154 -144
  4. package/dist/bigconsole/BigConsoleRoutes.js.map +1 -1
  5. package/dist/bigconsole/components/datasink/AlertExecutionHistory.d.ts +11 -0
  6. package/dist/bigconsole/components/datasink/AlertExecutionHistory.d.ts.map +1 -0
  7. package/dist/bigconsole/components/datasink/AlertExecutionHistory.js +248 -0
  8. package/dist/bigconsole/components/datasink/AlertExecutionHistory.js.map +1 -0
  9. package/dist/bigconsole/components/datasink/AlertRuleEditor.d.ts +23 -0
  10. package/dist/bigconsole/components/datasink/AlertRuleEditor.d.ts.map +1 -0
  11. package/dist/bigconsole/components/datasink/AlertRuleEditor.js +357 -0
  12. package/dist/bigconsole/components/datasink/AlertRuleEditor.js.map +1 -0
  13. package/dist/bigconsole/components/workflow/WorkflowOpenGuard.d.ts +25 -0
  14. package/dist/bigconsole/components/workflow/WorkflowOpenGuard.d.ts.map +1 -0
  15. package/dist/bigconsole/components/workflow/WorkflowOpenGuard.js +89 -0
  16. package/dist/bigconsole/components/workflow/WorkflowOpenGuard.js.map +1 -0
  17. package/dist/bigconsole/hooks/useDataSinkAlerts.d.ts +146 -0
  18. package/dist/bigconsole/hooks/useDataSinkAlerts.d.ts.map +1 -0
  19. package/dist/bigconsole/hooks/useDataSinkAlerts.js +221 -0
  20. package/dist/bigconsole/hooks/useDataSinkAlerts.js.map +1 -0
  21. package/dist/bigconsole/pages/DataSinkAlertsPage.d.ts +2 -0
  22. package/dist/bigconsole/pages/DataSinkAlertsPage.d.ts.map +1 -0
  23. package/dist/bigconsole/pages/DataSinkAlertsPage.js +422 -0
  24. package/dist/bigconsole/pages/DataSinkAlertsPage.js.map +1 -0
  25. package/dist/bigconsole/pages/DataSinkViewPage.d.ts.map +1 -1
  26. package/dist/bigconsole/pages/DataSinkViewPage.js +151 -144
  27. package/dist/bigconsole/pages/DataSinkViewPage.js.map +1 -1
  28. package/dist/bigconsole/pages/WorkflowViewPage.js +4 -4
  29. package/dist/bigconsole/pages/WorkflowsPage.d.ts.map +1 -1
  30. package/dist/bigconsole/pages/WorkflowsPage.js +61 -60
  31. package/dist/bigconsole/pages/WorkflowsPage.js.map +1 -1
  32. package/dist/bigconsole/utils/alertRules.d.ts +40 -0
  33. package/dist/bigconsole/utils/alertRules.d.ts.map +1 -0
  34. package/dist/bigconsole/utils/alertRules.js +83 -0
  35. package/dist/bigconsole/utils/alertRules.js.map +1 -0
  36. package/dist/bigconsole/workflowOpen.d.ts +78 -0
  37. package/dist/bigconsole/workflowOpen.d.ts.map +1 -0
  38. package/dist/bigconsole/workflowOpen.js +33 -0
  39. package/dist/bigconsole/workflowOpen.js.map +1 -0
  40. package/dist/generated/wspace-operations.d.ts +418 -0
  41. package/dist/generated/wspace-operations.d.ts.map +1 -1
  42. package/dist/generated/wspace-operations.js +329 -200
  43. package/dist/generated/wspace-operations.js.map +1 -1
  44. package/dist/generated/wspace-types.d.ts +122 -0
  45. package/dist/generated/wspace-types.d.ts.map +1 -1
  46. package/dist/generated/wspace-types.js +7 -1
  47. package/dist/generated/wspace-types.js.map +1 -1
  48. package/dist/translations/en.d.ts.map +1 -1
  49. package/package.json +1 -1
@@ -0,0 +1,357 @@
1
+ import { SECTION_FOCUS_RING as e } from "../common/sectionStyles.js";
2
+ import { Section as t } from "../common/Section.js";
3
+ import "../common/index.js";
4
+ import { AlertSeverity as n, DataSinkAlertChannel as r, DataSinkAlertConditionType as i } from "../../../generated/wspace-types.js";
5
+ import { Loader2 as a, Play as o, Plus as s, Save as c, Trash2 as l } from "lucide-react";
6
+ import { Button as u } from "@burdenoff/fe-libs/ui";
7
+ import { jsx as d, jsxs as f } from "react/jsx-runtime";
8
+ import { useI18n as p } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
9
+ //#region src/bigconsole/components/datasink/AlertRuleEditor.tsx
10
+ var m = `w-full min-w-0 rounded-control border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary ${e}`;
11
+ function h(h) {
12
+ let { t: g } = p(), { draft: _, channels: v, channelError: y, canUpdate: b, pending: x, previewing: S, preview: C, previewError: w, previewStale: T, error: E, onChange: D, onSave: O, onCancel: k, onPreview: A, onReloadChannels: j } = h, M = x || !b, N = v.filter((e) => e.status.toUpperCase() === "ACTIVE"), P = (e) => D({
13
+ ..._,
14
+ ...e
15
+ });
16
+ return /* @__PURE__ */ d(t, {
17
+ title: g("bigconsole.alerts.rule.title", "Alert rule"),
18
+ headingLevel: 2,
19
+ emphasis: "primary",
20
+ children: /* @__PURE__ */ f("form", {
21
+ onSubmit: (e) => {
22
+ e.preventDefault(), O();
23
+ },
24
+ className: "flex min-w-0 flex-col gap-form-gap",
25
+ "aria-label": g("bigconsole.alerts.rule.form", "Alert rule editor"),
26
+ children: [
27
+ !b && /* @__PURE__ */ d("p", {
28
+ className: "text-sm text-text-secondary",
29
+ children: g("bigconsole.alerts.rule.readOnly", "You have read-only access to these alert rules.")
30
+ }),
31
+ E && /* @__PURE__ */ d("p", {
32
+ role: "alert",
33
+ className: "break-words text-sm text-status-error-text",
34
+ children: E
35
+ }),
36
+ /* @__PURE__ */ f("div", { children: [/* @__PURE__ */ d("label", {
37
+ htmlFor: "alert-name",
38
+ className: "mb-1 block text-sm font-medium text-text-primary",
39
+ children: g("bigconsole.alerts.rule.name", "Name")
40
+ }), /* @__PURE__ */ d("input", {
41
+ id: "alert-name",
42
+ className: m,
43
+ value: _.name,
44
+ onChange: (e) => P({ name: e.target.value }),
45
+ required: !0,
46
+ maxLength: 200,
47
+ disabled: M
48
+ })] }),
49
+ /* @__PURE__ */ f("div", {
50
+ className: "grid min-w-0 gap-form-gap sm:grid-cols-2",
51
+ children: [/* @__PURE__ */ f("div", { children: [/* @__PURE__ */ d("label", {
52
+ htmlFor: "alert-condition-type",
53
+ className: "mb-1 block text-sm font-medium text-text-primary",
54
+ children: g("bigconsole.alerts.rule.language", "Condition language")
55
+ }), /* @__PURE__ */ f("select", {
56
+ id: "alert-condition-type",
57
+ className: m,
58
+ value: _.conditionType,
59
+ onChange: (e) => P({ conditionType: e.target.value === i.Jsonata ? i.Jsonata : i.Jq }),
60
+ disabled: M,
61
+ children: [/* @__PURE__ */ d("option", {
62
+ value: i.Jq,
63
+ children: "JQ"
64
+ }), /* @__PURE__ */ d("option", {
65
+ value: i.Jsonata,
66
+ children: "JSONata"
67
+ })]
68
+ })] }), /* @__PURE__ */ f("div", { children: [/* @__PURE__ */ d("label", {
69
+ htmlFor: "alert-severity",
70
+ className: "mb-1 block text-sm font-medium text-text-primary",
71
+ children: g("bigconsole.alerts.rule.severity", "Severity")
72
+ }), /* @__PURE__ */ d("select", {
73
+ id: "alert-severity",
74
+ className: m,
75
+ value: _.severity,
76
+ onChange: (e) => P({ severity: Object.values(n).find((t) => t === e.target.value) ?? n.Medium }),
77
+ disabled: M,
78
+ children: Object.values(n).map((e) => /* @__PURE__ */ d("option", {
79
+ value: e,
80
+ children: g(`bigconsole.alerts.severity.${e}`, e.charAt(0).toUpperCase() + e.slice(1))
81
+ }, e))
82
+ })] })]
83
+ }),
84
+ /* @__PURE__ */ f("div", { children: [
85
+ /* @__PURE__ */ d("label", {
86
+ htmlFor: "alert-condition",
87
+ className: "mb-1 block text-sm font-medium text-text-primary",
88
+ children: g("bigconsole.alerts.rule.condition", "Condition")
89
+ }),
90
+ /* @__PURE__ */ d("textarea", {
91
+ id: "alert-condition",
92
+ className: `${m} min-h-32 font-mono`,
93
+ value: _.condition,
94
+ onChange: (e) => P({ condition: e.target.value }),
95
+ rows: 5,
96
+ required: !0,
97
+ disabled: M,
98
+ "aria-describedby": "alert-condition-help"
99
+ }),
100
+ /* @__PURE__ */ d("p", {
101
+ id: "alert-condition-help",
102
+ className: "mt-2 text-xs text-text-secondary",
103
+ children: g("bigconsole.alerts.rule.conditionHelp", "Evaluates the entire current sink payload and must return one boolean. Preview does not send notifications.")
104
+ }),
105
+ /* @__PURE__ */ d("p", {
106
+ className: "mt-1 break-words text-xs text-text-muted",
107
+ children: _.conditionType === i.Jq ? "JQ: any(.[]; .boarding_minutes > 240)" : "JSONata: $count($[boarding_minutes > 240]) > 0"
108
+ }),
109
+ /* @__PURE__ */ f(u, {
110
+ type: "button",
111
+ variant: "secondary",
112
+ size: "sm",
113
+ onClick: A,
114
+ disabled: x || S || !_.condition.trim(),
115
+ className: "mt-3",
116
+ children: [S ? /* @__PURE__ */ d(a, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ d(o, { className: "mr-2 h-4 w-4" }), S ? g("bigconsole.alerts.rule.previewing", "Evaluating…") : g("bigconsole.alerts.rule.preview", "Preview condition")]
117
+ }),
118
+ w && /* @__PURE__ */ d("p", {
119
+ role: "alert",
120
+ className: "mt-2 break-words text-sm text-status-error-text",
121
+ children: w
122
+ }),
123
+ T && /* @__PURE__ */ d("p", {
124
+ role: "status",
125
+ className: "mt-2 text-xs text-text-secondary",
126
+ children: g("bigconsole.alerts.rule.previewStale", "The condition or data changed. Preview again to see the current result.")
127
+ }),
128
+ C && !T && /* @__PURE__ */ f("div", {
129
+ role: "status",
130
+ className: "mt-3 rounded-control border border-border-subtle bg-bg-sunken p-3 text-sm",
131
+ children: [C.error ? /* @__PURE__ */ d("p", {
132
+ className: "break-words text-status-error-text",
133
+ children: C.error
134
+ }) : /* @__PURE__ */ d("p", {
135
+ className: "font-medium text-text-primary",
136
+ children: C.matched ? g("bigconsole.alerts.rule.matched", "Condition matched") : g("bigconsole.alerts.rule.noMatch", "Condition did not match")
137
+ }), /* @__PURE__ */ f("p", {
138
+ className: "mt-1 text-xs text-text-secondary",
139
+ children: [
140
+ g("bigconsole.alerts.rule.previewMetadata", "Evaluated data version"),
141
+ " ",
142
+ C.version,
143
+ " ·",
144
+ " ",
145
+ C.durationMs,
146
+ " ms"
147
+ ]
148
+ })]
149
+ })
150
+ ] }),
151
+ /* @__PURE__ */ f("fieldset", {
152
+ disabled: M,
153
+ className: "min-w-0",
154
+ children: [
155
+ /* @__PURE__ */ d("legend", {
156
+ className: "mb-2 text-sm font-medium text-text-primary",
157
+ children: g("bigconsole.alerts.rule.destinations", "Delivery destinations")
158
+ }),
159
+ /* @__PURE__ */ d("p", {
160
+ className: "mb-3 text-xs text-text-secondary",
161
+ children: g("bigconsole.alerts.rule.destinationHelp", "Choose an available active delivery channel and its actual recipient.")
162
+ }),
163
+ y && /* @__PURE__ */ f("div", {
164
+ className: "mb-3 text-sm",
165
+ children: [/* @__PURE__ */ d("p", {
166
+ role: "alert",
167
+ className: "break-words text-status-error-text",
168
+ children: y
169
+ }), /* @__PURE__ */ d(u, {
170
+ type: "button",
171
+ variant: "secondary",
172
+ size: "sm",
173
+ onClick: j,
174
+ children: g("bigconsole.alerts.rule.reloadChannels", "Reload channels")
175
+ })]
176
+ }),
177
+ !y && N.length === 0 && /* @__PURE__ */ d("p", {
178
+ className: "mb-3 text-sm text-text-secondary",
179
+ children: g("bigconsole.alerts.rule.noChannels", "No active delivery channels are available to BigConsole in this organization. You can save this rule disabled.")
180
+ }),
181
+ !_.deliveries.length && /* @__PURE__ */ d("p", {
182
+ className: "mb-3 text-xs text-text-muted",
183
+ children: g("bigconsole.alerts.rule.noDestinations", "No delivery destinations selected.")
184
+ }),
185
+ _.deliveries.map((e, t) => /* @__PURE__ */ f("div", {
186
+ className: "mb-3 min-w-0 rounded-control border border-border-subtle p-3",
187
+ children: [
188
+ /* @__PURE__ */ f("label", {
189
+ htmlFor: `alert-channel-${e.key}`,
190
+ className: "mb-1 block text-xs font-medium text-text-primary",
191
+ children: [
192
+ g("bigconsole.alerts.rule.channel", "Configured channel"),
193
+ " ",
194
+ t + 1
195
+ ]
196
+ }),
197
+ /* @__PURE__ */ f("select", {
198
+ id: `alert-channel-${e.key}`,
199
+ className: m,
200
+ value: e.channelId,
201
+ onChange: (t) => {
202
+ let n = v.find((e) => e.id === t.target.value);
203
+ P({ deliveries: _.deliveries.map((t) => t.key === e.key ? {
204
+ ...t,
205
+ channelId: n?.id ?? "",
206
+ channel: n?.platform ?? r.Email,
207
+ recipient: n?.platform === t.channel ? t.recipient : ""
208
+ } : t) });
209
+ },
210
+ children: [
211
+ /* @__PURE__ */ d("option", {
212
+ value: "",
213
+ children: g("bigconsole.alerts.rule.chooseChannel", "Choose a configured channel")
214
+ }),
215
+ e.channelId && !N.some((t) => t.id === e.channelId) && /* @__PURE__ */ f("option", {
216
+ value: e.channelId,
217
+ children: [
218
+ g("bigconsole.alerts.rule.unavailableChannel", "Unavailable channel"),
219
+ " · ",
220
+ e.channelId
221
+ ]
222
+ }),
223
+ N.map((e) => /* @__PURE__ */ f("option", {
224
+ value: e.id,
225
+ children: [
226
+ e.name,
227
+ " · ",
228
+ e.platform
229
+ ]
230
+ }, e.id))
231
+ ]
232
+ }),
233
+ /* @__PURE__ */ d("label", {
234
+ htmlFor: `alert-recipient-${e.key}`,
235
+ className: "mb-1 mt-3 block text-xs font-medium text-text-primary",
236
+ children: e.channel === r.Email ? g("bigconsole.alerts.rule.emailRecipient", "Email address") : e.channel === r.Slack ? g("bigconsole.alerts.rule.slackRecipient", "Slack recipient ID") : g("bigconsole.alerts.rule.webhookRecipient", "HTTPS webhook URL")
237
+ }),
238
+ /* @__PURE__ */ d("input", {
239
+ id: `alert-recipient-${e.key}`,
240
+ className: m,
241
+ type: e.channel === r.Email ? "email" : e.channel === r.Webhook ? "url" : "text",
242
+ value: e.recipient,
243
+ onChange: (t) => P({ deliveries: _.deliveries.map((n) => n.key === e.key ? {
244
+ ...n,
245
+ recipient: t.target.value
246
+ } : n) }),
247
+ required: !0
248
+ }),
249
+ /* @__PURE__ */ f(u, {
250
+ type: "button",
251
+ variant: "ghost",
252
+ size: "sm",
253
+ onClick: () => P({ deliveries: _.deliveries.filter((t) => t.key !== e.key) }),
254
+ className: "mt-2",
255
+ children: [/* @__PURE__ */ d(l, { className: "mr-2 h-4 w-4" }), g("bigconsole.alerts.rule.removeDestination", "Remove destination")]
256
+ })
257
+ ]
258
+ }, e.key)),
259
+ /* @__PURE__ */ f(u, {
260
+ type: "button",
261
+ variant: "secondary",
262
+ size: "sm",
263
+ onClick: () => P({ deliveries: [..._.deliveries, {
264
+ key: crypto.randomUUID(),
265
+ channel: r.Email,
266
+ channelId: "",
267
+ recipient: ""
268
+ }] }),
269
+ disabled: N.length === 0,
270
+ children: [/* @__PURE__ */ d(s, { className: "mr-2 h-4 w-4" }), g("bigconsole.alerts.rule.addDestination", "Add destination")]
271
+ })
272
+ ]
273
+ }),
274
+ /* @__PURE__ */ f("fieldset", {
275
+ disabled: M,
276
+ className: "min-w-0",
277
+ children: [
278
+ /* @__PURE__ */ d("legend", {
279
+ className: "mb-2 text-sm font-medium text-text-primary",
280
+ children: g("bigconsole.alerts.rule.throttle", "Throttle")
281
+ }),
282
+ /* @__PURE__ */ f("label", {
283
+ className: "flex items-center gap-2 text-sm text-text-primary",
284
+ children: [/* @__PURE__ */ d("input", {
285
+ type: "checkbox",
286
+ checked: _.throttleEnabled,
287
+ onChange: (e) => P({ throttleEnabled: e.target.checked }),
288
+ className: e
289
+ }), g("bigconsole.alerts.rule.limitFrequency", "Limit alert frequency")]
290
+ }),
291
+ _.throttleEnabled && /* @__PURE__ */ f("div", {
292
+ className: "mt-3 grid gap-form-gap sm:grid-cols-2",
293
+ children: [/* @__PURE__ */ f("div", { children: [/* @__PURE__ */ d("label", {
294
+ htmlFor: "alert-window",
295
+ className: "mb-1 block text-xs font-medium text-text-primary",
296
+ children: g("bigconsole.alerts.rule.window", "Time window (minutes)")
297
+ }), /* @__PURE__ */ d("input", {
298
+ id: "alert-window",
299
+ type: "number",
300
+ min: 1,
301
+ step: 1,
302
+ className: m,
303
+ value: _.windowMinutes,
304
+ onChange: (e) => P({ windowMinutes: e.target.value }),
305
+ required: !0
306
+ })] }), /* @__PURE__ */ f("div", { children: [/* @__PURE__ */ d("label", {
307
+ htmlFor: "alert-max",
308
+ className: "mb-1 block text-xs font-medium text-text-primary",
309
+ children: g("bigconsole.alerts.rule.maxAlerts", "Maximum alerts per window")
310
+ }), /* @__PURE__ */ d("input", {
311
+ id: "alert-max",
312
+ type: "number",
313
+ min: 1,
314
+ step: 1,
315
+ className: m,
316
+ value: _.maxAlerts,
317
+ onChange: (e) => P({ maxAlerts: e.target.value }),
318
+ required: !0
319
+ })] })]
320
+ })
321
+ ]
322
+ }),
323
+ /* @__PURE__ */ f("label", {
324
+ className: "flex items-start gap-2 text-sm text-text-primary",
325
+ children: [/* @__PURE__ */ d("input", {
326
+ type: "checkbox",
327
+ checked: _.enabled,
328
+ onChange: (e) => P({ enabled: e.target.checked }),
329
+ disabled: M,
330
+ className: `mt-1 ${e}`
331
+ }), /* @__PURE__ */ f("span", { children: [g("bigconsole.alerts.rule.enabled", "Rule enabled"), /* @__PURE__ */ d("span", {
332
+ className: "mt-1 block text-xs text-text-secondary",
333
+ children: g("bigconsole.alerts.rule.enabledHelp", "Enabled rules evaluate when this sink is updated or refreshed. Saving a disabled rule does not send notifications.")
334
+ })] })]
335
+ }),
336
+ /* @__PURE__ */ f("div", {
337
+ className: "flex flex-wrap justify-end gap-control-gap border-t border-border-subtle pt-4",
338
+ children: [/* @__PURE__ */ d(u, {
339
+ type: "button",
340
+ variant: "secondary",
341
+ onClick: k,
342
+ disabled: x,
343
+ children: g("bigconsole.alerts.rule.cancel", "Cancel")
344
+ }), /* @__PURE__ */ f(u, {
345
+ type: "submit",
346
+ disabled: M,
347
+ children: [x ? /* @__PURE__ */ d(a, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ d(c, { className: "mr-2 h-4 w-4" }), x ? g("bigconsole.alerts.rule.saving", "Saving…") : g("bigconsole.alerts.rule.save", "Save rule")]
348
+ })]
349
+ })
350
+ ]
351
+ })
352
+ });
353
+ }
354
+ //#endregion
355
+ export { h as AlertRuleEditor };
356
+
357
+ //# sourceMappingURL=AlertRuleEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AlertRuleEditor.js","names":[],"sources":["../../../../src/bigconsole/components/datasink/AlertRuleEditor.tsx"],"sourcesContent":["import type { FormEvent } from 'react';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { Loader2, Plus, Save, Trash2, Play } from 'lucide-react';\nimport { Section, SECTION_FOCUS_RING } from '../common';\nimport { AlertSeverity, DataSinkAlertConditionType, DataSinkAlertChannel } from '../../../generated/wspace-types';\nimport type { AlertChannel, AlertPreview } from '../../hooks/useDataSinkAlerts';\nimport type { AlertDraft } from '../../utils/alertRules';\n\nconst FIELD = `w-full min-w-0 rounded-control border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary ${SECTION_FOCUS_RING}`;\ninterface Props {\n draft: AlertDraft;\n channels: AlertChannel[];\n channelError: string | null;\n canUpdate: boolean;\n pending: boolean;\n previewing: boolean;\n preview: AlertPreview | null;\n previewError: string | null;\n previewStale: boolean;\n error: string | null;\n onChange: (draft: AlertDraft) => void;\n onSave: () => void;\n onCancel: () => void;\n onPreview: () => void;\n onReloadChannels: () => void;\n}\n\nexport function AlertRuleEditor(props: Props) {\n const { t } = useI18n();\n const {\n draft,\n channels,\n channelError,\n canUpdate,\n pending,\n previewing,\n preview,\n previewError,\n previewStale,\n error,\n onChange,\n onSave,\n onCancel,\n onPreview,\n onReloadChannels,\n } = props;\n const disabled = pending || !canUpdate;\n const activeChannels = channels.filter((channel) => channel.status.toUpperCase() === 'ACTIVE');\n const change = (patch: Partial<AlertDraft>) => onChange({ ...draft, ...patch });\n const submit = (event: FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n onSave();\n };\n return (\n <Section title={t('bigconsole.alerts.rule.title', 'Alert rule')} headingLevel={2} emphasis=\"primary\">\n <form\n onSubmit={submit}\n className=\"flex min-w-0 flex-col gap-form-gap\"\n aria-label={t('bigconsole.alerts.rule.form', 'Alert rule editor')}\n >\n {!canUpdate && (\n <p className=\"text-sm text-text-secondary\">\n {t('bigconsole.alerts.rule.readOnly', 'You have read-only access to these alert rules.')}\n </p>\n )}\n {error && (\n <p role=\"alert\" className=\"break-words text-sm text-status-error-text\">\n {error}\n </p>\n )}\n <div>\n <label htmlFor=\"alert-name\" className=\"mb-1 block text-sm font-medium text-text-primary\">\n {t('bigconsole.alerts.rule.name', 'Name')}\n </label>\n <input\n id=\"alert-name\"\n className={FIELD}\n value={draft.name}\n onChange={(event) => change({ name: event.target.value })}\n required\n maxLength={200}\n disabled={disabled}\n />\n </div>\n <div className=\"grid min-w-0 gap-form-gap sm:grid-cols-2\">\n <div>\n <label htmlFor=\"alert-condition-type\" className=\"mb-1 block text-sm font-medium text-text-primary\">\n {t('bigconsole.alerts.rule.language', 'Condition language')}\n </label>\n <select\n id=\"alert-condition-type\"\n className={FIELD}\n value={draft.conditionType}\n onChange={(event) =>\n change({\n conditionType:\n event.target.value === DataSinkAlertConditionType.Jsonata\n ? DataSinkAlertConditionType.Jsonata\n : DataSinkAlertConditionType.Jq,\n })\n }\n disabled={disabled}\n >\n <option value={DataSinkAlertConditionType.Jq}>JQ</option>\n <option value={DataSinkAlertConditionType.Jsonata}>JSONata</option>\n </select>\n </div>\n <div>\n <label htmlFor=\"alert-severity\" className=\"mb-1 block text-sm font-medium text-text-primary\">\n {t('bigconsole.alerts.rule.severity', 'Severity')}\n </label>\n <select\n id=\"alert-severity\"\n className={FIELD}\n value={draft.severity}\n onChange={(event) =>\n change({\n severity:\n Object.values(AlertSeverity).find((value) => value === event.target.value) ?? AlertSeverity.Medium,\n })\n }\n disabled={disabled}\n >\n {Object.values(AlertSeverity).map((value) => (\n <option key={value} value={value}>\n {t(`bigconsole.alerts.severity.${value}`, value.charAt(0).toUpperCase() + value.slice(1))}\n </option>\n ))}\n </select>\n </div>\n </div>\n <div>\n <label htmlFor=\"alert-condition\" className=\"mb-1 block text-sm font-medium text-text-primary\">\n {t('bigconsole.alerts.rule.condition', 'Condition')}\n </label>\n <textarea\n id=\"alert-condition\"\n className={`${FIELD} min-h-32 font-mono`}\n value={draft.condition}\n onChange={(event) => change({ condition: event.target.value })}\n rows={5}\n required\n disabled={disabled}\n aria-describedby=\"alert-condition-help\"\n />\n <p id=\"alert-condition-help\" className=\"mt-2 text-xs text-text-secondary\">\n {t(\n 'bigconsole.alerts.rule.conditionHelp',\n 'Evaluates the entire current sink payload and must return one boolean. Preview does not send notifications.'\n )}\n </p>\n <p className=\"mt-1 break-words text-xs text-text-muted\">\n {draft.conditionType === DataSinkAlertConditionType.Jq\n ? 'JQ: any(.[]; .boarding_minutes > 240)'\n : 'JSONata: $count($[boarding_minutes > 240]) > 0'}\n </p>\n <Button\n type=\"button\"\n variant=\"secondary\"\n size=\"sm\"\n onClick={onPreview}\n disabled={pending || previewing || !draft.condition.trim()}\n className=\"mt-3\"\n >\n {previewing ? <Loader2 className=\"mr-2 h-4 w-4 animate-spin\" /> : <Play className=\"mr-2 h-4 w-4\" />}\n {previewing\n ? t('bigconsole.alerts.rule.previewing', 'Evaluating…')\n : t('bigconsole.alerts.rule.preview', 'Preview condition')}\n </Button>\n {previewError && (\n <p role=\"alert\" className=\"mt-2 break-words text-sm text-status-error-text\">\n {previewError}\n </p>\n )}\n {previewStale && (\n <p role=\"status\" className=\"mt-2 text-xs text-text-secondary\">\n {t(\n 'bigconsole.alerts.rule.previewStale',\n 'The condition or data changed. Preview again to see the current result.'\n )}\n </p>\n )}\n {preview && !previewStale && (\n <div role=\"status\" className=\"mt-3 rounded-control border border-border-subtle bg-bg-sunken p-3 text-sm\">\n {preview.error ? (\n <p className=\"break-words text-status-error-text\">{preview.error}</p>\n ) : (\n <p className=\"font-medium text-text-primary\">\n {preview.matched\n ? t('bigconsole.alerts.rule.matched', 'Condition matched')\n : t('bigconsole.alerts.rule.noMatch', 'Condition did not match')}\n </p>\n )}\n <p className=\"mt-1 text-xs text-text-secondary\">\n {t('bigconsole.alerts.rule.previewMetadata', 'Evaluated data version')} {preview.version} ·{' '}\n {preview.durationMs} ms\n </p>\n </div>\n )}\n </div>\n <fieldset disabled={disabled} className=\"min-w-0\">\n <legend className=\"mb-2 text-sm font-medium text-text-primary\">\n {t('bigconsole.alerts.rule.destinations', 'Delivery destinations')}\n </legend>\n <p className=\"mb-3 text-xs text-text-secondary\">\n {t(\n 'bigconsole.alerts.rule.destinationHelp',\n 'Choose an available active delivery channel and its actual recipient.'\n )}\n </p>\n {channelError && (\n <div className=\"mb-3 text-sm\">\n <p role=\"alert\" className=\"break-words text-status-error-text\">\n {channelError}\n </p>\n <Button type=\"button\" variant=\"secondary\" size=\"sm\" onClick={onReloadChannels}>\n {t('bigconsole.alerts.rule.reloadChannels', 'Reload channels')}\n </Button>\n </div>\n )}\n {!channelError && activeChannels.length === 0 && (\n <p className=\"mb-3 text-sm text-text-secondary\">\n {t(\n 'bigconsole.alerts.rule.noChannels',\n 'No active delivery channels are available to BigConsole in this organization. You can save this rule disabled.'\n )}\n </p>\n )}\n {!draft.deliveries.length && (\n <p className=\"mb-3 text-xs text-text-muted\">\n {t('bigconsole.alerts.rule.noDestinations', 'No delivery destinations selected.')}\n </p>\n )}\n {draft.deliveries.map((delivery, index) => (\n <div key={delivery.key} className=\"mb-3 min-w-0 rounded-control border border-border-subtle p-3\">\n <label\n htmlFor={`alert-channel-${delivery.key}`}\n className=\"mb-1 block text-xs font-medium text-text-primary\"\n >\n {t('bigconsole.alerts.rule.channel', 'Configured channel')} {index + 1}\n </label>\n <select\n id={`alert-channel-${delivery.key}`}\n className={FIELD}\n value={delivery.channelId}\n onChange={(event) => {\n const channel = channels.find((item) => item.id === event.target.value);\n change({\n deliveries: draft.deliveries.map((item) =>\n item.key === delivery.key\n ? {\n ...item,\n channelId: channel?.id ?? '',\n channel: channel?.platform ?? DataSinkAlertChannel.Email,\n recipient: channel?.platform === item.channel ? item.recipient : '',\n }\n : item\n ),\n });\n }}\n >\n <option value=\"\">{t('bigconsole.alerts.rule.chooseChannel', 'Choose a configured channel')}</option>\n {delivery.channelId && !activeChannels.some((channel) => channel.id === delivery.channelId) && (\n <option value={delivery.channelId}>\n {t('bigconsole.alerts.rule.unavailableChannel', 'Unavailable channel')} · {delivery.channelId}\n </option>\n )}\n {activeChannels.map((channel) => (\n <option key={channel.id} value={channel.id}>\n {channel.name} · {channel.platform}\n </option>\n ))}\n </select>\n <label\n htmlFor={`alert-recipient-${delivery.key}`}\n className=\"mb-1 mt-3 block text-xs font-medium text-text-primary\"\n >\n {delivery.channel === DataSinkAlertChannel.Email\n ? t('bigconsole.alerts.rule.emailRecipient', 'Email address')\n : delivery.channel === DataSinkAlertChannel.Slack\n ? t('bigconsole.alerts.rule.slackRecipient', 'Slack recipient ID')\n : t('bigconsole.alerts.rule.webhookRecipient', 'HTTPS webhook URL')}\n </label>\n <input\n id={`alert-recipient-${delivery.key}`}\n className={FIELD}\n type={\n delivery.channel === DataSinkAlertChannel.Email\n ? 'email'\n : delivery.channel === DataSinkAlertChannel.Webhook\n ? 'url'\n : 'text'\n }\n value={delivery.recipient}\n onChange={(event) =>\n change({\n deliveries: draft.deliveries.map((item) =>\n item.key === delivery.key ? { ...item, recipient: event.target.value } : item\n ),\n })\n }\n required\n />\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => change({ deliveries: draft.deliveries.filter((item) => item.key !== delivery.key) })}\n className=\"mt-2\"\n >\n <Trash2 className=\"mr-2 h-4 w-4\" />\n {t('bigconsole.alerts.rule.removeDestination', 'Remove destination')}\n </Button>\n </div>\n ))}\n <Button\n type=\"button\"\n variant=\"secondary\"\n size=\"sm\"\n onClick={() =>\n change({\n deliveries: [\n ...draft.deliveries,\n { key: crypto.randomUUID(), channel: DataSinkAlertChannel.Email, channelId: '', recipient: '' },\n ],\n })\n }\n disabled={activeChannels.length === 0}\n >\n <Plus className=\"mr-2 h-4 w-4\" />\n {t('bigconsole.alerts.rule.addDestination', 'Add destination')}\n </Button>\n </fieldset>\n <fieldset disabled={disabled} className=\"min-w-0\">\n <legend className=\"mb-2 text-sm font-medium text-text-primary\">\n {t('bigconsole.alerts.rule.throttle', 'Throttle')}\n </legend>\n <label className=\"flex items-center gap-2 text-sm text-text-primary\">\n <input\n type=\"checkbox\"\n checked={draft.throttleEnabled}\n onChange={(event) => change({ throttleEnabled: event.target.checked })}\n className={SECTION_FOCUS_RING}\n />\n {t('bigconsole.alerts.rule.limitFrequency', 'Limit alert frequency')}\n </label>\n {draft.throttleEnabled && (\n <div className=\"mt-3 grid gap-form-gap sm:grid-cols-2\">\n <div>\n <label htmlFor=\"alert-window\" className=\"mb-1 block text-xs font-medium text-text-primary\">\n {t('bigconsole.alerts.rule.window', 'Time window (minutes)')}\n </label>\n <input\n id=\"alert-window\"\n type=\"number\"\n min={1}\n step={1}\n className={FIELD}\n value={draft.windowMinutes}\n onChange={(event) => change({ windowMinutes: event.target.value })}\n required\n />\n </div>\n <div>\n <label htmlFor=\"alert-max\" className=\"mb-1 block text-xs font-medium text-text-primary\">\n {t('bigconsole.alerts.rule.maxAlerts', 'Maximum alerts per window')}\n </label>\n <input\n id=\"alert-max\"\n type=\"number\"\n min={1}\n step={1}\n className={FIELD}\n value={draft.maxAlerts}\n onChange={(event) => change({ maxAlerts: event.target.value })}\n required\n />\n </div>\n </div>\n )}\n </fieldset>\n <label className=\"flex items-start gap-2 text-sm text-text-primary\">\n <input\n type=\"checkbox\"\n checked={draft.enabled}\n onChange={(event) => change({ enabled: event.target.checked })}\n disabled={disabled}\n className={`mt-1 ${SECTION_FOCUS_RING}`}\n />\n <span>\n {t('bigconsole.alerts.rule.enabled', 'Rule enabled')}\n <span className=\"mt-1 block text-xs text-text-secondary\">\n {t(\n 'bigconsole.alerts.rule.enabledHelp',\n 'Enabled rules evaluate when this sink is updated or refreshed. Saving a disabled rule does not send notifications.'\n )}\n </span>\n </span>\n </label>\n <div className=\"flex flex-wrap justify-end gap-control-gap border-t border-border-subtle pt-4\">\n <Button type=\"button\" variant=\"secondary\" onClick={onCancel} disabled={pending}>\n {t('bigconsole.alerts.rule.cancel', 'Cancel')}\n </Button>\n <Button type=\"submit\" disabled={disabled}>\n {pending ? <Loader2 className=\"mr-2 h-4 w-4 animate-spin\" /> : <Save className=\"mr-2 h-4 w-4\" />}\n {pending ? t('bigconsole.alerts.rule.saving', 'Saving…') : t('bigconsole.alerts.rule.save', 'Save rule')}\n </Button>\n </div>\n </form>\n </Section>\n );\n}\n"],"mappings":";;;;;;;;;AASA,IAAM,IAAQ,gHAAgH;AAmB9H,SAAgB,EAAgB,GAAc;CAC5C,IAAM,EAAE,SAAM,GAAS,EACjB,EACJ,UACA,aACA,iBACA,cACA,YACA,eACA,YACA,iBACA,iBACA,UACA,aACA,WACA,aACA,cACA,wBACE,GACE,IAAW,KAAW,CAAC,GACvB,IAAiB,EAAS,QAAQ,MAAY,EAAQ,OAAO,aAAa,KAAK,SAAS,EACxF,KAAU,MAA+B,EAAS;EAAE,GAAG;EAAO,GAAG;EAAO,CAAC;AAK/E,QACE,kBAAC,GAAD;EAAS,OAAO,EAAE,gCAAgC,aAAa;EAAE,cAAc;EAAG,UAAS;YACzF,kBAAC,QAAD;GACE,WAPU,MAAsC;AAEpD,IADA,EAAM,gBAAgB,EACtB,GAAQ;;GAMJ,WAAU;GACV,cAAY,EAAE,+BAA+B,oBAAoB;aAHnE;IAKG,CAAC,KACA,kBAAC,KAAD;KAAG,WAAU;eACV,EAAE,mCAAmC,kDAAkD;KACtF,CAAA;IAEL,KACC,kBAAC,KAAD;KAAG,MAAK;KAAQ,WAAU;eACvB;KACC,CAAA;IAEN,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,SAAD;KAAO,SAAQ;KAAa,WAAU;eACnC,EAAE,+BAA+B,OAAO;KACnC,CAAA,EACR,kBAAC,SAAD;KACE,IAAG;KACH,WAAW;KACX,OAAO,EAAM;KACb,WAAW,MAAU,EAAO,EAAE,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MACV,WAAW,QAAQ;MACnB,CAAA,EACF,kBAAC,QAAD,EAAA,UAAA,CACG,EAAE,kCAAkC,eAAe,EACpD,kBAAC,QAAD;MAAM,WAAU;gBACb,EACC,sCACA,qHACD;MACI,CAAA,CACF,EAAA,CAAA,CACD;;IACR,kBAAC,OAAD;KAAK,WAAU;eAAf,CACE,kBAAC,GAAD;MAAQ,MAAK;MAAS,SAAQ;MAAY,SAAS;MAAU,UAAU;gBACpE,EAAE,iCAAiC,SAAS;MACtC,CAAA,EACT,kBAAC,GAAD;MAAQ,MAAK;MAAmB;gBAAhC,CACG,IAAU,kBAAC,GAAD,EAAS,WAAU,6BAA8B,CAAA,GAAG,kBAAC,GAAD,EAAM,WAAU,gBAAiB,CAAA,EAC/F,IAAU,EAAE,iCAAiC,UAAU,GAAG,EAAE,+BAA+B,YAAY,CACjG;QACL;;IACD;;EACC,CAAA"}
@@ -0,0 +1,25 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ interface WorkflowOpenGuardProps {
4
+ /** The workflow KEY from the URL (`:id`). */
5
+ workflowKey: string;
6
+ /** The SDK builder — mounted only once the open is known to be read-only. */
7
+ children: ReactNode;
8
+ }
9
+ /**
10
+ * Mounts the SDK builder only when opening the key cannot create anything
11
+ * (BOFF-8060 F2). The SDK builder creates a definition for an unknown key on
12
+ * mount, so a link to a key that does not exist must never reach it.
13
+ *
14
+ * - explicit "new workflow" navigation -> builder (the person asked to create)
15
+ * - key exists -> builder
16
+ * - key does not exist -> not-found state, nothing is written
17
+ * - lookup failed -> retry state, nothing is written
18
+ *
19
+ * A key stays trusted once seen, so the SDK's own `navigate(../workflow/key/vN)`
20
+ * after a save (same key, new version) does not unmount an editor with unsaved
21
+ * work behind another lookup.
22
+ */
23
+ export declare const WorkflowOpenGuard: import('react').NamedExoticComponent<WorkflowOpenGuardProps>;
24
+ export {};
25
+ //# sourceMappingURL=WorkflowOpenGuard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkflowOpenGuard.d.ts","sourceRoot":"","sources":["../../../../src/bigconsole/components/workflow/WorkflowOpenGuard.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AASlE,UAAU,sBAAsB;IAC9B,6CAA6C;IAC7C,WAAW,EAAE,MAAM,CAAC;IACpB,6EAA6E;IAC7E,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iBAAiB,8DAiG5B,CAAC"}
@@ -0,0 +1,89 @@
1
+ import { useAppNavigate as e } from "../../contexts/NavigationContext.js";
2
+ import "../../contexts/index.js";
3
+ import { decideWorkflowOpenView as t, isCreateIntent as n, toLookupClient as r, verifyWorkflowKey as i } from "../../workflowOpen.js";
4
+ import { memo as a, useEffect as o, useState as s } from "react";
5
+ import { useLocation as c } from "react-router";
6
+ import { Spinner as l } from "@burdenoff/fe-libs/ui";
7
+ import { useApolloClient as u } from "@apollo/client/react";
8
+ import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
9
+ import { useI18n as m } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
10
+ //#region src/bigconsole/components/workflow/WorkflowOpenGuard.tsx
11
+ var h = a(function({ workflowKey: a, children: h }) {
12
+ let { t: g } = m(), _ = e(), v = u(), y = n(c().state), [b, x] = s(null), [S, C] = s(null), [w, T] = s(null), [E, D] = s(0);
13
+ o(() => {
14
+ if (!a) return;
15
+ if (y) {
16
+ x(a);
17
+ return;
18
+ }
19
+ if (b === a) return;
20
+ let e = !1;
21
+ return i(r(v), a).then((t) => {
22
+ e || (t === "found" ? x(a) : t === "absent" ? C(a) : T(a));
23
+ }), () => {
24
+ e = !0;
25
+ };
26
+ }, [
27
+ a,
28
+ y,
29
+ b,
30
+ v,
31
+ E
32
+ ]);
33
+ let O = t({
34
+ key: a,
35
+ createIntent: y,
36
+ verifiedKey: b,
37
+ absentKey: S,
38
+ failedKey: w
39
+ });
40
+ return O === "builder" ? /* @__PURE__ */ f(d, { children: h }) : O === "not-found" ? /* @__PURE__ */ p("div", {
41
+ className: "p-6 flex flex-col items-center justify-center min-h-[400px] text-center gap-4",
42
+ role: "alert",
43
+ children: [
44
+ /* @__PURE__ */ f("p", {
45
+ className: "text-base font-medium text-text-primary",
46
+ children: g("bigconsole.workflows.builder.notFoundTitle", "Workflow not found")
47
+ }),
48
+ /* @__PURE__ */ f("p", {
49
+ className: "text-sm text-text-secondary",
50
+ children: g("bigconsole.workflows.builder.notFoundDescription", "No workflow with this key exists in this workspace. Nothing was created.")
51
+ }),
52
+ /* @__PURE__ */ f("button", {
53
+ type: "button",
54
+ onClick: () => _("/workflows"),
55
+ className: "px-4 py-2 text-sm font-medium text-text-primary bg-bg-sunken hover:bg-border-default rounded-md transition-colors",
56
+ children: g("bigconsole.workflows.view.backToWorkflows", "Back to Workflows")
57
+ })
58
+ ]
59
+ }) : O === "failed" ? /* @__PURE__ */ p("div", {
60
+ className: "p-6 flex flex-col items-center justify-center min-h-[400px] text-center gap-4",
61
+ role: "alert",
62
+ children: [/* @__PURE__ */ f("p", {
63
+ className: "text-sm text-text-secondary",
64
+ children: g("bigconsole.workflows.builder.loadFailed", "Couldn't load this workflow. Please try again.")
65
+ }), /* @__PURE__ */ p("div", {
66
+ className: "flex items-center gap-2",
67
+ children: [/* @__PURE__ */ f("button", {
68
+ type: "button",
69
+ onClick: () => {
70
+ T(null), D((e) => e + 1);
71
+ },
72
+ className: "px-4 py-2 text-sm font-medium text-action-primary-fg bg-action-primary-bg hover:bg-action-primary-bgHover rounded-md transition-colors",
73
+ children: g("bigconsole.workflows.actions.tryAgain", "Try Again")
74
+ }), /* @__PURE__ */ f("button", {
75
+ type: "button",
76
+ onClick: () => _("/workflows"),
77
+ className: "px-4 py-2 text-sm font-medium text-text-primary bg-bg-sunken hover:bg-border-default rounded-md transition-colors",
78
+ children: g("bigconsole.workflows.view.backToWorkflows", "Back to Workflows")
79
+ })]
80
+ })]
81
+ }) : /* @__PURE__ */ f("div", {
82
+ className: "flex items-center justify-center min-h-[400px]",
83
+ children: /* @__PURE__ */ f(l, { className: "h-8 w-8" })
84
+ });
85
+ });
86
+ //#endregion
87
+ export { h as WorkflowOpenGuard };
88
+
89
+ //# sourceMappingURL=WorkflowOpenGuard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkflowOpenGuard.js","names":[],"sources":["../../../../src/bigconsole/components/workflow/WorkflowOpenGuard.tsx"],"sourcesContent":["import { memo, useEffect, useState, type ReactNode } from 'react';\nimport { useLocation } from 'react-router';\nimport { Spinner } from '@burdenoff/fe-libs/ui';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { useApolloClient } from '@apollo/client/react';\n\nimport { useAppNavigate } from '../../contexts';\nimport { decideWorkflowOpenView, isCreateIntent, toLookupClient, verifyWorkflowKey } from '../../workflowOpen';\n\ninterface WorkflowOpenGuardProps {\n /** The workflow KEY from the URL (`:id`). */\n workflowKey: string;\n /** The SDK builder — mounted only once the open is known to be read-only. */\n children: ReactNode;\n}\n\n/**\n * Mounts the SDK builder only when opening the key cannot create anything\n * (BOFF-8060 F2). The SDK builder creates a definition for an unknown key on\n * mount, so a link to a key that does not exist must never reach it.\n *\n * - explicit \"new workflow\" navigation -> builder (the person asked to create)\n * - key exists -> builder\n * - key does not exist -> not-found state, nothing is written\n * - lookup failed -> retry state, nothing is written\n *\n * A key stays trusted once seen, so the SDK's own `navigate(../workflow/key/vN)`\n * after a save (same key, new version) does not unmount an editor with unsaved\n * work behind another lookup.\n */\nexport const WorkflowOpenGuard = memo(function WorkflowOpenGuard({ workflowKey, children }: WorkflowOpenGuardProps) {\n const { t } = useI18n();\n const navigate = useAppNavigate();\n const client = useApolloClient();\n const location = useLocation();\n const createIntent = isCreateIntent(location.state);\n\n // Each verdict is keyed by the key it describes so navigating between\n // workflows never reuses a stale answer.\n const [verifiedKey, setVerifiedKey] = useState<string | null>(null);\n const [absentKey, setAbsentKey] = useState<string | null>(null);\n const [failedKey, setFailedKey] = useState<string | null>(null);\n // Bumped by \"Try again\" to re-run the lookup after a failure.\n const [retryNonce, setRetryNonce] = useState(0);\n\n useEffect(() => {\n if (!workflowKey) return;\n if (createIntent) {\n // The person pressed \"New workflow\": trust this key from here on.\n setVerifiedKey(workflowKey);\n return;\n }\n if (verifiedKey === workflowKey) return;\n\n let cancelled = false;\n verifyWorkflowKey(toLookupClient(client), workflowKey).then((verdict) => {\n if (cancelled) return;\n if (verdict === 'found') setVerifiedKey(workflowKey);\n else if (verdict === 'absent') setAbsentKey(workflowKey);\n else setFailedKey(workflowKey);\n });\n return () => {\n cancelled = true;\n };\n }, [workflowKey, createIntent, verifiedKey, client, retryNonce]);\n\n const view = decideWorkflowOpenView({ key: workflowKey, createIntent, verifiedKey, absentKey, failedKey });\n\n if (view === 'builder') return <>{children}</>;\n\n if (view === 'not-found') {\n return (\n <div className=\"p-6 flex flex-col items-center justify-center min-h-[400px] text-center gap-4\" role=\"alert\">\n <p className=\"text-base font-medium text-text-primary\">\n {t('bigconsole.workflows.builder.notFoundTitle', 'Workflow not found')}\n </p>\n <p className=\"text-sm text-text-secondary\">\n {t(\n 'bigconsole.workflows.builder.notFoundDescription',\n 'No workflow with this key exists in this workspace. Nothing was created.'\n )}\n </p>\n <button\n type=\"button\"\n onClick={() => navigate('/workflows')}\n className=\"px-4 py-2 text-sm font-medium text-text-primary bg-bg-sunken hover:bg-border-default rounded-md transition-colors\"\n >\n {t('bigconsole.workflows.view.backToWorkflows', 'Back to Workflows')}\n </button>\n </div>\n );\n }\n\n if (view === 'failed') {\n return (\n <div className=\"p-6 flex flex-col items-center justify-center min-h-[400px] text-center gap-4\" role=\"alert\">\n <p className=\"text-sm text-text-secondary\">\n {t('bigconsole.workflows.builder.loadFailed', \"Couldn't load this workflow. Please try again.\")}\n </p>\n <div className=\"flex items-center gap-2\">\n <button\n type=\"button\"\n onClick={() => {\n setFailedKey(null);\n setRetryNonce((n) => n + 1);\n }}\n className=\"px-4 py-2 text-sm font-medium text-action-primary-fg bg-action-primary-bg hover:bg-action-primary-bgHover rounded-md transition-colors\"\n >\n {t('bigconsole.workflows.actions.tryAgain', 'Try Again')}\n </button>\n <button\n type=\"button\"\n onClick={() => navigate('/workflows')}\n className=\"px-4 py-2 text-sm font-medium text-text-primary bg-bg-sunken hover:bg-border-default rounded-md transition-colors\"\n >\n {t('bigconsole.workflows.view.backToWorkflows', 'Back to Workflows')}\n </button>\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"flex items-center justify-center min-h-[400px]\">\n <Spinner className=\"h-8 w-8\" />\n </div>\n );\n});\n"],"mappings":";;;;;;;;;;AA8BA,IAAa,IAAoB,EAAK,SAA2B,EAAE,gBAAa,eAAoC;CAClH,IAAM,EAAE,SAAM,GAAS,EACjB,IAAW,GAAgB,EAC3B,IAAS,GAAiB,EAE1B,IAAe,EADJ,GAAa,CACe,MAAM,EAI7C,CAAC,GAAa,KAAkB,EAAwB,KAAK,EAC7D,CAAC,GAAW,KAAgB,EAAwB,KAAK,EACzD,CAAC,GAAW,KAAgB,EAAwB,KAAK,EAEzD,CAAC,GAAY,KAAiB,EAAS,EAAE;AAE/C,SAAgB;AACd,MAAI,CAAC,EAAa;AAClB,MAAI,GAAc;AAEhB,KAAe,EAAY;AAC3B;;AAEF,MAAI,MAAgB,EAAa;EAEjC,IAAI,IAAY;AAOhB,SANA,EAAkB,EAAe,EAAO,EAAE,EAAY,CAAC,MAAM,MAAY;AACnE,SACA,MAAY,UAAS,EAAe,EAAY,GAC3C,MAAY,WAAU,EAAa,EAAY,GACnD,EAAa,EAAY;IAC9B,QACW;AACX,OAAY;;IAEb;EAAC;EAAa;EAAc;EAAa;EAAQ;EAAW,CAAC;CAEhE,IAAM,IAAO,EAAuB;EAAE,KAAK;EAAa;EAAc;EAAa;EAAW;EAAW,CAAC;AAwD1G,QAtDI,MAAS,YAAkB,kBAAA,GAAA,EAAG,aAAY,CAAA,GAE1C,MAAS,cAET,kBAAC,O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