@oomol-lab/open-flow 0.1.0-beta.1 → 0.1.0-beta.11

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 (69) hide show
  1. package/dist/browser/DesignerIcon-ckcKnxxJ.js +2267 -0
  2. package/dist/browser/createResourceDialog-DhIU-HYW.js +111 -0
  3. package/dist/browser/{dist-CPuF50D9.js → dist-BZ5PTFAs.js} +1 -1
  4. package/dist/browser/dist-Bmb2mZvW.js +795 -0
  5. package/dist/browser/{dist-DWADUsVB.js → dist-By46o5UV.js} +47 -47
  6. package/dist/browser/dist-CP0883sY.js +4 -0
  7. package/dist/browser/{dist-CJpzJrLM.js → dist-Ce71Szg7.js} +894 -895
  8. package/dist/browser/dist-DSe6KRsr.js +1224 -0
  9. package/dist/browser/{dist-DUzA0Ukh.js → dist-DY4qlXTK.js} +140 -141
  10. package/dist/browser/{dist-3Mj8q8Pr.js → dist-DmuE3M0R.js} +53 -54
  11. package/dist/browser/{dist-BN4ZCyOB.js → dist-DpDLsYtO.js} +14 -15
  12. package/dist/browser/dist-DxahK_I8.js +2688 -0
  13. package/dist/browser/{esm-DGQbgYoJ.js → esm-C64_h7HF.js} +58 -59
  14. package/dist/browser/flow-authoring-module.d.ts +2 -2
  15. package/dist/browser/flow-authoring-node.d.ts +17 -7
  16. package/dist/browser/flow-authoring.d.ts +1 -1
  17. package/dist/browser/flow-authoring.js +5329 -286
  18. package/dist/browser/flow-change-schema.d.ts +3 -0
  19. package/dist/browser/flow-change.d.ts +131 -14
  20. package/dist/browser/flow-change.js +5216 -114
  21. package/dist/browser/flow-notifications.d.ts +5 -0
  22. package/dist/browser/flowChanges-BINNGoug.js +12896 -0
  23. package/dist/browser/{flowRunInputEditorStore-BeyUSWpO.js → flowRunInputEditorStore-NPGePkvP.js} +775 -776
  24. package/dist/browser/flowWorkspace-Dp_b8KXF.js +158409 -0
  25. package/dist/browser/{getPseudoElementBounds-ESJExRFX.js → getPseudoElementBounds-Dfqo78k7.js} +2051 -2542
  26. package/dist/browser/{languages-DgJehE1g.js → languages-i3Xmpt6S.js} +6 -15
  27. package/dist/browser/licenses.md +82 -0
  28. package/dist/browser/{markdownContent-DdlIRN3_.js → markdownContent-BawLYUjh.js} +24 -24
  29. package/dist/browser/select-CbQHq-GM.js +6851 -0
  30. package/dist/browser/theme.css +34 -34
  31. package/dist/browser/{typeScriptSession-mPCiA9sV.js → typeScriptSession-BoV-FDl3.js} +68 -69
  32. package/dist/browser/waitNotificationInputs-fzyKN6mk.js +29 -0
  33. package/dist/browser/workbench-contract.d.ts +8 -2
  34. package/dist/browser/workbench.css +1 -1
  35. package/dist/browser/workbench.d.ts +3 -1
  36. package/dist/browser/workbench.js +1647 -1299
  37. package/dist/browser/workbenchSelect-BjbJjlNd.js +435 -0
  38. package/dist/common/control-api-conformance.d.ts +1 -0
  39. package/dist/common/control-api-conformance.js +309 -81
  40. package/dist/common/control-api-errors.d.ts +12 -0
  41. package/dist/common/control-api.d.ts +95 -23
  42. package/dist/common/control-api.js +567 -364
  43. package/dist/common/engine-contract.d.ts +1 -1
  44. package/dist/common/flow-encoding.js +33 -15
  45. package/dist/common/flow-graph.d.ts +6 -0
  46. package/dist/common/flow-modules.d.ts +20 -0
  47. package/dist/common/flow-notifications.d.ts +5 -0
  48. package/dist/common/flow-schema.d.ts +8 -0
  49. package/dist/common/flow-semantics.d.ts +7 -5
  50. package/dist/common/flow-semantics.js +8880 -1702
  51. package/dist/common/integration-trigger.d.ts +2 -0
  52. package/dist/common/provider-triggers.js +4 -1
  53. package/dist/common/run-events.d.ts +2 -2
  54. package/dist/common/run-events.js +10 -16
  55. package/dist/common/run-lifecycle.d.ts +17 -2
  56. package/dist/common/run-lifecycle.js +53 -2
  57. package/dist/common/runtime-contract.d.ts +10 -2
  58. package/dist/common/runtime-contract.js +143 -6
  59. package/dist/common/scheduler.d.ts +52 -13
  60. package/dist/common/scheduler.js +7315 -242
  61. package/dist/index.d.ts +6 -5
  62. package/package.json +1 -1
  63. package/dist/browser/createResourceDialog-DXQz0thK.js +0 -504
  64. package/dist/browser/diagnostics-BGoGFvHA.js +0 -9237
  65. package/dist/browser/dist-BMqL-qR5.js +0 -1894
  66. package/dist/browser/dist-BpopSHwP.js +0 -1543
  67. package/dist/browser/dist-CUSrALSX.js +0 -1620
  68. package/dist/browser/flowWorkspace-DwyxAOBH.js +0 -47615
  69. package/dist/browser/workbenchSelect-B2s1HV-Y.js +0 -1374
@@ -1,13 +1,19 @@
1
1
  import { a as e, f as t, i as n } from "./dist-C46JByB-.js";
2
2
  import { a as r, i, s as a, t as o } from "./main-DmjVyuWr.js";
3
- import { At as s, It as c, Jn as l, Kn as u, Mt as d, Ot as f, Qn as p, Xn as m, Yn as h, Zn as g, er as _, jt as v } from "./getPseudoElementBounds-ESJExRFX.js";
4
- import { A as y, At as b, B as x, C as S, Ct as C, D as w, Dt as ee, E as T, Et as te, Ft as E, G as ne, H as D, I as O, K as re, Lt as k, M as A, Mt as ie, N as j, Nt as ae, O as M, Ot as oe, P as se, Pt as ce, R as N, Rt as P, S as le, Tt as ue, U as de, V as fe, W as pe, _ as me, a as F, b as he, c as ge, d as _e, f as ve, g as ye, h as be, i as xe, j as I, jt as Se, kt as Ce, l as we, m as Te, n as Ee, p as De, q as Oe, s as ke, t as Ae, u as je, v as Me, w as Ne, wt as L, x as Pe, y as Fe, z as R } from "./diagnostics-BGoGFvHA.js";
5
- import { t as Ie } from "./workbenchSelect-B2s1HV-Y.js";
6
- import { a as Le, i as Re, n as ze, r as Be } from "./languages-DgJehE1g.js";
7
- import { Suspense as Ve, lazy as He, useEffect as z, useRef as Ue, useState as B } from "react";
8
- import { Fragment as We, jsx as V, jsxs as H } from "react/jsx-runtime";
3
+ import { $ as s, A as c, B as l, C as u, D as d, E as f, F as p, H as m, I as h, J as g, K as _, M as v, N as y, O as b, P as x, Q as S, R as C, S as w, U as T, V as E, W as D, X as O, Y as ee, Z as k, _ as A, a as j, at as te, b as M, c as N, ct as ne, d as re, dt as ie, et as ae, f as oe, ft as P, g as se, gt as F, h as ce, ht as le, i as ue, it as de, j as I, l as fe, lt as pe, m as me, mt as L, n as R, nt as he, o as ge, ot as _e, p as ve, pt as ye, q as be, rt as xe, s as Se, st as Ce, t as we, tt as z, u as Te, ut as Ee, v as De, w as Oe, x as ke, y as Ae, z as je } from "./flowChanges-BINNGoug.js";
4
+ import { Ot as Me, Un as Ne, Vn as B, jt as V } from "./getPseudoElementBounds-Dfqo78k7.js";
5
+ import { C as Pe, S as Fe, c as H, g as Ie, h as U, l as Le, m as Re, w as ze, x as Be, y as Ve } from "./select-CbQHq-GM.js";
6
+ import { _ as He, c as Ue, f as We, s as Ge, u as Ke } from "./DesignerIcon-ckcKnxxJ.js";
7
+ import { i as qe, n as Je, r as Ye, t as Xe } from "./languages-i3Xmpt6S.js";
8
+ import { a as Ze, c as Qe, i as $e, n as et, o as tt, r as nt, s as rt, t as it } from "./workbenchSelect-BjbJjlNd.js";
9
+ import { Suspense as at, lazy as ot, useEffect as W, useRef as G, useState as K } from "react";
10
+ import { Fragment as st, jsx as q, jsxs as J } from "react/jsx-runtime";
11
+ import * as ct from "effect/Cause";
12
+ import * as Y from "effect/Effect";
13
+ import * as lt from "effect/Exit";
14
+ import * as ut from "effect/Fiber";
9
15
  //#region src/workbench/browser/runtime/navigation.ts
10
- var Ge = class {
16
+ var dt = class {
11
17
  #e;
12
18
  #t;
13
19
  #n;
@@ -66,7 +72,7 @@ var Ge = class {
66
72
  this.#s = !0, await this.#n.selectFlow(void 0), e == this.#i && (this.#u("design", !1), this.#s = !1);
67
73
  }
68
74
  async apply(e) {
69
- if (Ke(e, this.#t)) return;
75
+ if (ft(e, this.#t)) return;
70
76
  this.#t = e;
71
77
  let t = ++this.#i;
72
78
  this.#s = !0;
@@ -78,53 +84,63 @@ var Ge = class {
78
84
  }
79
85
  #l;
80
86
  #u(e, t) {
81
- let n = {
82
- flowId: this.#n.workspace.$.flowId.value,
83
- view: e
87
+ let n = this.#n.workspace.$.flowId.value, r = {
88
+ flowId: n,
89
+ view: n == null ? "design" : e
84
90
  };
85
- Ke(n, this.#t) || (this.#t = n, this.#e(n, { replace: t })), this.#r.set(e);
91
+ ft(r, this.#t) || (this.#t = r, this.#e(r, { replace: t })), this.#r.set(r.view);
86
92
  }
87
93
  };
88
- function Ke(e, t) {
94
+ function ft(e, t) {
89
95
  return e.flowId == t.flowId && e.view == t.view;
90
96
  }
91
97
  //#endregion
92
98
  //#region src/workbench/browser/runtime/shell/resourceBrowser.tsx
93
- var qe = He(() => import("./createResourceDialog-DXQz0thK.js")), Je = Le.map((e) => ({
94
- label: Re[e],
99
+ var pt = ot(() => import("./createResourceDialog-DhIU-HYW.js")), mt = qe.map((e) => ({
100
+ label: Ye[e],
95
101
  value: e
96
102
  }));
97
- function Ye({ language: e, onLanguageChange: t }) {
98
- let n = r(), [i, a] = B(null);
99
- return t == null ? null : /* @__PURE__ */ H("div", {
103
+ function ht({ language: e, onLanguageChange: t }) {
104
+ let n = r(), [i, a] = K(null);
105
+ return t == null ? null : /* @__PURE__ */ J("div", {
100
106
  className: "resource-language",
101
107
  ref: a,
102
- children: [/* @__PURE__ */ V("span", {
108
+ children: [/* @__PURE__ */ q("span", {
103
109
  className: "sr-only",
104
110
  children: n("language.label")
105
- }), /* @__PURE__ */ V(Ie, {
111
+ }), /* @__PURE__ */ q(it, {
106
112
  ariaLabel: n("language.label"),
107
113
  onValueChange: (e) => t(e),
108
- options: Je,
114
+ options: mt,
109
115
  portalRoot: i,
110
116
  value: e
111
117
  })]
112
118
  });
113
119
  }
114
- function Xe({ badge: e, busy: t, flow: n, href: a, onSelect: o, store: s }) {
115
- let l = i(), u = r(), [d, m] = B("idle"), [h, y] = B(n.name), b = v(h);
116
- async function x(e) {
120
+ function gt({ badge: e, busy: t, flow: n, href: a, onSelect: o, store: s }) {
121
+ let [c, l] = K(null), u = G(null), d = G(null), f = G(null), p = i(), m = r(), [h, g] = K("idle"), [_, v] = K(n.name), [y, b] = K(), x = n.live != null && n.live.revisionId != n.draftRevisionId;
122
+ async function S(e) {
123
+ b(e == "publish" ? "publish" : "enabled");
124
+ try {
125
+ e == "publish" ? await s.workspace.publishFlow(n) : await s.workspace.setFlowEnabled(n, e);
126
+ } finally {
127
+ b(void 0);
128
+ }
129
+ }
130
+ let C = U(_);
131
+ async function w(e) {
117
132
  e.preventDefault();
118
- let t = h.trim();
119
- v(t) == null && await s.workspace.renameFlow(n.flowId, t) && m("idle");
133
+ let t = _.trim();
134
+ U(t) == null && await s.workspace.renameFlow(n.flowId, t) && g("idle");
120
135
  }
121
- async function S() {
122
- await s.workspace.deleteFlow(n.flowId) && m("idle");
136
+ async function T() {
137
+ await s.workspace.deleteFlow(n.flowId) && g("idle");
123
138
  }
124
- return /* @__PURE__ */ H("div", {
139
+ return /* @__PURE__ */ J("div", {
125
140
  className: "resource-item-row",
141
+ ref: l,
126
142
  children: [
127
- /* @__PURE__ */ H(p, {
143
+ /* @__PURE__ */ J(B, {
128
144
  "aria-disabled": n.status == "retiring",
129
145
  className: "resource-list-row flow-columns",
130
146
  nativeButton: !1,
@@ -133,308 +149,353 @@ function Xe({ badge: e, busy: t, flow: n, href: a, onSelect: o, store: s }) {
133
149
  e.preventDefault();
134
150
  return;
135
151
  }
136
- C(e, () => o(n));
152
+ ae(e, () => o(n));
137
153
  },
138
- render: /* @__PURE__ */ V("a", { href: n.status == "retiring" ? void 0 : a }),
154
+ render: /* @__PURE__ */ q("a", { href: n.status == "retiring" ? void 0 : a }),
139
155
  tabIndex: n.status == "retiring" ? -1 : void 0,
140
156
  variant: "ghost",
141
157
  children: [
142
- /* @__PURE__ */ H("span", {
158
+ /* @__PURE__ */ J("span", {
143
159
  className: "resource-primary-cell",
144
- children: [/* @__PURE__ */ V("span", {
160
+ children: [/* @__PURE__ */ q("span", {
145
161
  className: "resource-icon",
146
- children: /* @__PURE__ */ V(f, { name: "flow" })
147
- }), /* @__PURE__ */ H("span", { children: [/* @__PURE__ */ H("span", {
162
+ children: /* @__PURE__ */ q(H, { name: "flow" })
163
+ }), /* @__PURE__ */ J("span", { children: [/* @__PURE__ */ J("span", {
148
164
  className: "flex min-w-0 items-center gap-2",
149
- children: [/* @__PURE__ */ V("strong", {
165
+ children: [/* @__PURE__ */ q("strong", {
150
166
  className: "min-w-0 truncate",
151
167
  children: n.name
152
- }), e != null && /* @__PURE__ */ V(ce, {
168
+ }), e != null && /* @__PURE__ */ q(ie, {
153
169
  className: "min-w-0 shrink",
154
170
  title: e,
155
171
  variant: "secondary",
156
- children: /* @__PURE__ */ V("span", {
172
+ children: /* @__PURE__ */ q("span", {
157
173
  className: "truncate",
158
174
  children: e
159
175
  })
160
176
  })]
161
- }), /* @__PURE__ */ V("code", {
177
+ }), /* @__PURE__ */ q("code", {
162
178
  translate: "no",
163
179
  children: n.flowId
164
180
  })] })]
165
181
  }),
166
- /* @__PURE__ */ V("time", {
182
+ /* @__PURE__ */ q("time", {
167
183
  dateTime: n.updatedAt,
168
- children: new Date(n.updatedAt).toLocaleString(l)
184
+ children: new Date(n.updatedAt).toLocaleString(p)
169
185
  }),
170
- /* @__PURE__ */ H("span", {
171
- className: `resource-status ${n.status == "active" ? "active" : "warning"}`,
172
- children: [/* @__PURE__ */ V("span", {
173
- "aria-hidden": "true",
174
- className: `status-dot ${n.status == "active" ? "success" : "running"}`
175
- }), u(n.status == "active" ? "resource.active" : "resource.retiring")]
186
+ /* @__PURE__ */ q("span", {
187
+ className: "resource-status",
188
+ children: m(n.status == "retiring" ? "resource.retiring" : n.live == null ? "resource.notPublished" : x ? "resource.unpublishedChanges" : "resource.isPublished")
176
189
  })
177
190
  ]
178
191
  }),
179
- n.status == "active" && /* @__PURE__ */ V(p, {
180
- "aria-expanded": d != "idle",
181
- "aria-label": u("sidebar.flowActions", { name: n.name }),
182
- className: _("resource-row-more", d != "idle" && "active"),
183
- disabled: t != null,
184
- onClick: () => m(d == "idle" ? "actions" : "idle"),
185
- size: "icon-sm",
186
- variant: "ghost",
187
- children: /* @__PURE__ */ V(f, { name: "more" })
192
+ /* @__PURE__ */ J("div", {
193
+ className: "resource-live-controls",
194
+ "aria-busy": y != null,
195
+ children: [n.live == null ? /* @__PURE__ */ q("span", {
196
+ className: "resource-status",
197
+ title: m("resource.publishFirst"),
198
+ children: ""
199
+ }) : /* @__PURE__ */ J(ze, {
200
+ className: "resource-enable",
201
+ title: m("resource.enabledHint"),
202
+ children: [/* @__PURE__ */ q(Ge, {
203
+ "aria-label": m("resource.enableFlow", { name: n.name }),
204
+ checked: n.live?.enabled ?? !1,
205
+ disabled: n.status != "active" || n.live == null || t != null || y != null,
206
+ onCheckedChange: (e) => void S(e),
207
+ size: "sm"
208
+ }), /* @__PURE__ */ q("span", { children: m(n.live?.enabled ? "resource.enabled" : "resource.disabled") })]
209
+ }), /* @__PURE__ */ q(B, {
210
+ disabled: n.status != "active" || t != null || y != null || n.live != null && !x,
211
+ onClick: () => void S("publish"),
212
+ size: "sm",
213
+ variant: "outline",
214
+ children: m(y == "publish" ? "workspace.publishing" : n.live == null ? "resource.publish" : "resource.publishUpdate")
215
+ })]
188
216
  }),
189
- d == "actions" && /* @__PURE__ */ H("div", {
190
- className: "resource-row-actions",
191
- children: [/* @__PURE__ */ V(p, {
217
+ n.status == "active" && /* @__PURE__ */ J(Ue, { children: [/* @__PURE__ */ q(He, {
218
+ "aria-label": m("sidebar.flowActions", { name: n.name }),
219
+ disabled: t != null || y != null,
220
+ render: /* @__PURE__ */ q(B, {
221
+ className: "resource-row-more",
222
+ ref: u,
223
+ size: "icon-sm",
224
+ variant: "ghost",
225
+ children: /* @__PURE__ */ q(H, { name: "more" })
226
+ })
227
+ }), /* @__PURE__ */ J(Ke, {
228
+ align: "end",
229
+ className: "min-w-36",
230
+ container: c,
231
+ finalFocus: h == "idle",
232
+ children: [/* @__PURE__ */ q(We, {
192
233
  onClick: () => {
193
- y(n.name), m("rename");
234
+ v(n.name), g("rename");
194
235
  },
195
- size: "sm",
196
- variant: "outline",
197
- children: u("common.rename")
198
- }), /* @__PURE__ */ V(p, {
199
- onClick: () => m("delete"),
200
- size: "sm",
236
+ children: m("common.rename")
237
+ }), /* @__PURE__ */ q(We, {
238
+ onClick: () => g("delete"),
201
239
  variant: "destructive",
202
- children: u("common.delete")
240
+ children: m("common.delete")
203
241
  })]
242
+ })] }),
243
+ /* @__PURE__ */ q(et, {
244
+ open: h == "rename",
245
+ onOpenChange: (e) => {
246
+ e || g("idle");
247
+ },
248
+ children: /* @__PURE__ */ q($e, {
249
+ container: c,
250
+ initialFocus: d,
251
+ finalFocus: u,
252
+ closeLabel: m("common.cancel"),
253
+ children: /* @__PURE__ */ J("form", {
254
+ className: "flex flex-col gap-4",
255
+ onSubmit: (e) => void w(e),
256
+ children: [
257
+ /* @__PURE__ */ q(rt, { children: /* @__PURE__ */ q(Qe, { children: m("sidebar.renameFlow", { name: n.name }) }) }),
258
+ /* @__PURE__ */ J(Ve, {
259
+ "data-invalid": _.length > 0 && C != null,
260
+ children: [
261
+ /* @__PURE__ */ q(Pe, {
262
+ htmlFor: `rename-flow-${n.flowId}`,
263
+ children: m("resource.flowName")
264
+ }),
265
+ /* @__PURE__ */ q(V, {
266
+ autoComplete: "off",
267
+ "aria-invalid": _.length > 0 && C != null,
268
+ "aria-describedby": _.length > 0 && C != null ? `rename-error-${n.flowId}` : void 0,
269
+ id: `rename-flow-${n.flowId}`,
270
+ name: "flow-name",
271
+ onChange: (e) => v(e.target.value),
272
+ ref: d,
273
+ required: !0,
274
+ value: _
275
+ }),
276
+ _.length > 0 && C != null && /* @__PURE__ */ q(Be, {
277
+ id: `rename-error-${n.flowId}`,
278
+ children: m(`resource.nameIssue.${C}`, { max: 80 })
279
+ })
280
+ ]
281
+ }),
282
+ /* @__PURE__ */ J(tt, { children: [/* @__PURE__ */ q(nt, {
283
+ render: /* @__PURE__ */ q(B, { variant: "outline" }),
284
+ type: "button",
285
+ children: m("common.cancel")
286
+ }), /* @__PURE__ */ q(B, {
287
+ disabled: t != null || C != null,
288
+ type: "submit",
289
+ children: m("common.save")
290
+ })] })
291
+ ]
292
+ })
293
+ })
204
294
  }),
205
- d == "rename" && /* @__PURE__ */ H("form", {
206
- className: "resource-row-form",
207
- onSubmit: (e) => void x(e),
208
- children: [
209
- /* @__PURE__ */ V(g, {
210
- htmlFor: `rename-flow-${n.flowId}`,
211
- children: u("sidebar.renameFlow", { name: n.name })
212
- }),
213
- /* @__PURE__ */ H("span", {
214
- className: "resource-row-field",
215
- children: [/* @__PURE__ */ V(c, {
216
- autoComplete: "off",
217
- "aria-invalid": h.length > 0 && b != null,
218
- autoFocus: !0,
219
- id: `rename-flow-${n.flowId}`,
220
- name: "flow-name",
221
- onChange: (e) => y(e.target.value),
222
- required: !0,
223
- value: h
224
- }), h.length > 0 && b != null && /* @__PURE__ */ V("small", {
225
- className: "resource-name-message error",
226
- children: u(`resource.nameIssue.${b}`, { max: 80 })
227
- })]
228
- }),
229
- /* @__PURE__ */ H("div", { children: [/* @__PURE__ */ V(p, {
230
- onClick: () => m("idle"),
231
- size: "sm",
232
- variant: "outline",
233
- children: u("common.cancel")
234
- }), /* @__PURE__ */ V(p, {
235
- disabled: t != null || b != null,
236
- size: "sm",
237
- type: "submit",
238
- children: u("common.save")
239
- })] })
240
- ]
241
- }),
242
- d == "delete" && /* @__PURE__ */ H("div", {
243
- className: "resource-row-confirm",
244
- role: "group",
245
- "aria-label": u("sidebar.deleteFlow", { name: n.name }),
246
- children: [/* @__PURE__ */ V("span", { children: /* @__PURE__ */ V("strong", { children: u("sidebar.deleteFlowConfirm", { name: n.name }) }) }), /* @__PURE__ */ H("div", { children: [/* @__PURE__ */ V(p, {
247
- onClick: () => m("idle"),
248
- size: "sm",
249
- variant: "outline",
250
- children: u("common.cancel")
251
- }), /* @__PURE__ */ V(p, {
252
- disabled: t != null,
253
- onClick: () => void S(),
254
- size: "sm",
255
- variant: "destructive",
256
- children: u(t == "flow" ? "common.deleting" : "common.delete")
257
- })] })]
295
+ /* @__PURE__ */ q(et, {
296
+ open: h == "delete",
297
+ onOpenChange: (e) => {
298
+ e || g("idle");
299
+ },
300
+ children: /* @__PURE__ */ J($e, {
301
+ container: c,
302
+ initialFocus: f,
303
+ finalFocus: u,
304
+ showCloseButton: !1,
305
+ children: [/* @__PURE__ */ J(rt, { children: [/* @__PURE__ */ q(Qe, { children: m("sidebar.deleteFlowConfirm", { name: n.name }) }), /* @__PURE__ */ q(Ze, { children: m("resource.deleteDescription") })] }), /* @__PURE__ */ J(tt, { children: [/* @__PURE__ */ q(nt, {
306
+ render: /* @__PURE__ */ q(B, {
307
+ ref: f,
308
+ variant: "outline"
309
+ }),
310
+ children: m("common.cancel")
311
+ }), /* @__PURE__ */ q(B, {
312
+ disabled: t != null,
313
+ onClick: () => void T(),
314
+ variant: "destructive",
315
+ children: m(t == "flow" ? "common.deleting" : "common.delete")
316
+ })] })]
317
+ })
258
318
  })
259
319
  ]
260
320
  });
261
321
  }
262
- function Ze() {
263
- return /* @__PURE__ */ H("div", {
322
+ function _t() {
323
+ return /* @__PURE__ */ J("div", {
264
324
  "aria-hidden": "true",
265
325
  className: "resource-list-row resource-skeleton-row flow-columns",
266
326
  children: [
267
- /* @__PURE__ */ H("span", {
327
+ /* @__PURE__ */ J("span", {
268
328
  className: "resource-primary-cell",
269
- children: [/* @__PURE__ */ V(L, { className: "size-8 shrink-0" }), /* @__PURE__ */ H("span", {
329
+ children: [/* @__PURE__ */ q(z, { className: "size-8 shrink-0" }), /* @__PURE__ */ J("span", {
270
330
  className: "resource-skeleton-copy",
271
- children: [/* @__PURE__ */ V(L, { className: "h-3.5 w-36" }), /* @__PURE__ */ V(L, { className: "h-2.5 w-48 max-w-full" })]
331
+ children: [/* @__PURE__ */ q(z, { className: "h-3.5 w-36" }), /* @__PURE__ */ q(z, { className: "h-2.5 w-48 max-w-full" })]
272
332
  })]
273
333
  }),
274
- /* @__PURE__ */ V(L, { className: "h-3 w-28" }),
275
- /* @__PURE__ */ V(L, { className: "h-3 w-16" })
334
+ /* @__PURE__ */ q(z, { className: "h-3 w-28" }),
335
+ /* @__PURE__ */ q(z, { className: "h-3 w-16" })
276
336
  ]
277
337
  });
278
338
  }
279
- function Qe({ createFlowDisabled: e, createFlowField: t, flowBadges: n, hrefForFlow: i, hostAction: o, hostTitle: s, language: c, onCreateFlow: l, onHostAction: u, onLanguageChange: d, onSelectFlow: m, store: h }) {
280
- let g = r(), _ = a(h.workspace.$.busy), y = a(h.workspace.$.flowLoadFailed), x = a(h.workspace.$.flowLoadMoreFailed), S = a(h.workspace.$.flowLoading), C = a(h.workspace.$.flowLoadingMore), w = a(h.workspace.$.flowNextCursor), T = a(h.workspace.$.flows), E = a(h.workspace.$.flowTotal), [ne, D] = B(!1), [O, re] = B(""), [k, A] = B(""), j = O.trim().toLocaleLowerCase(), M = T.filter((e) => e.name.toLocaleLowerCase().includes(j));
281
- async function se(e) {
339
+ function vt({ catalogWidth: e, createFlowDisabled: t, createFlowField: n, flowBadges: i, hrefForFlow: o, hostAction: c, hostTitle: l, language: u, onCreateFlow: d, onHostAction: f, onLanguageChange: p, onSelectFlow: m, store: h }) {
340
+ let g = r(), _ = a(h.workspace.$.busy), v = a(h.workspace.$.flowLoadFailed), y = a(h.workspace.$.flowLoadMoreFailed), b = a(h.workspace.$.flowLoading), x = a(h.workspace.$.flowLoadingMore), S = a(h.workspace.$.flowNextCursor), C = a(h.workspace.$.flowRefreshing), w = a(h.workspace.$.flows), T = a(h.workspace.$.flowTotal), [E, D] = K(!1), [O, ee] = K(""), [k, A] = K(""), j = O.trim().toLocaleLowerCase(), M = w.filter((e) => e.name.toLocaleLowerCase().includes(j));
341
+ async function N(e) {
282
342
  e.preventDefault();
283
343
  let t = k.trim();
284
- v(t) != null || !await l(t) || (D(!1), A(""));
344
+ U(t) != null || !await d(t) || (D(!1), A(""));
285
345
  }
286
- return /* @__PURE__ */ V("main", {
346
+ return /* @__PURE__ */ q("main", {
287
347
  className: "resource-browser",
288
- children: /* @__PURE__ */ H("div", {
289
- className: "resource-page",
348
+ children: /* @__PURE__ */ J("div", {
349
+ className: Ne("resource-page", e != "default" && "resource-page-full"),
290
350
  children: [
291
- /* @__PURE__ */ H("header", {
292
- className: "resource-page-header",
293
- children: [/* @__PURE__ */ V("div", {
294
- className: "resource-heading",
295
- children: /* @__PURE__ */ V("h1", { children: g("resource.flows") })
296
- }), /* @__PURE__ */ H("div", {
297
- className: "resource-page-actions",
298
- children: [
299
- /* @__PURE__ */ V(Ye, {
300
- language: c,
301
- onLanguageChange: d
302
- }),
303
- /* @__PURE__ */ H(p, {
304
- disabled: _ != null,
305
- onClick: () => D(!0),
306
- children: [/* @__PURE__ */ V(f, {
307
- "data-icon": "inline-start",
308
- name: "plus"
309
- }), g("resource.newFlow")]
310
- }),
311
- o != null && s != null && u != null && /* @__PURE__ */ V(Oe, {
312
- action: o,
313
- onAction: u,
314
- title: s
315
- })
316
- ]
317
- })]
351
+ /* @__PURE__ */ q("h1", {
352
+ className: "sr-only",
353
+ children: g("resource.flows")
318
354
  }),
319
- /* @__PURE__ */ H("section", {
355
+ /* @__PURE__ */ J("section", {
320
356
  "aria-labelledby": "flow-list-title",
321
357
  className: "resource-list-section",
322
358
  children: [
323
- /* @__PURE__ */ H("div", {
359
+ /* @__PURE__ */ J("div", {
324
360
  className: "resource-list-title",
325
- children: [/* @__PURE__ */ H("div", {
361
+ children: [/* @__PURE__ */ J("div", {
326
362
  className: "resource-list-heading",
327
- children: [/* @__PURE__ */ V("h2", {
363
+ children: [/* @__PURE__ */ q("h2", {
328
364
  id: "flow-list-title",
329
365
  children: g("resource.allFlows")
330
- }), !S && /* @__PURE__ */ V("span", { children: g("resource.flowCount", { count: E ?? T.length }) })]
331
- }), /* @__PURE__ */ H("div", {
366
+ }), !b && /* @__PURE__ */ q("span", { children: g("resource.flowCount", { count: T ?? w.length }) })]
367
+ }), /* @__PURE__ */ J("div", {
332
368
  className: "resource-list-actions",
333
- children: [/* @__PURE__ */ H(ue, {
334
- className: "w-full sm:w-56",
335
- children: [/* @__PURE__ */ V(te, { children: /* @__PURE__ */ V(f, {
336
- name: "search",
337
- size: 17
338
- }) }), /* @__PURE__ */ V(ee, {
339
- autoComplete: "off",
340
- "aria-label": g("resource.searchFlows"),
341
- name: "flow-search",
342
- onChange: (e) => re(e.target.value),
343
- placeholder: g("resource.searchFlows"),
344
- value: O
345
- })]
346
- }), /* @__PURE__ */ V(p, {
347
- "aria-label": g("common.refresh"),
348
- disabled: S || _ != null,
349
- onClick: () => void h.workspace.reloadFlows(),
350
- size: "icon",
351
- title: g("common.refresh"),
352
- variant: "outline",
353
- children: /* @__PURE__ */ V(f, { name: "refresh" })
354
- })]
369
+ children: [
370
+ /* @__PURE__ */ q(ht, {
371
+ language: u,
372
+ onLanguageChange: p
373
+ }),
374
+ /* @__PURE__ */ J(he, {
375
+ className: "w-full sm:w-56",
376
+ children: [/* @__PURE__ */ q(xe, { children: /* @__PURE__ */ q(H, {
377
+ name: "search",
378
+ size: 17
379
+ }) }), /* @__PURE__ */ q(de, {
380
+ autoComplete: "off",
381
+ "aria-label": g("resource.searchFlows"),
382
+ name: "flow-search",
383
+ onChange: (e) => ee(e.target.value),
384
+ placeholder: g("resource.searchFlows"),
385
+ value: O
386
+ })]
387
+ }),
388
+ /* @__PURE__ */ q(B, {
389
+ "aria-label": g("common.refresh"),
390
+ disabled: b || C || _ != null,
391
+ onClick: () => void h.workspace.reloadFlows(),
392
+ size: "icon",
393
+ title: g("common.refresh"),
394
+ variant: "outline",
395
+ children: /* @__PURE__ */ q(H, {
396
+ className: C ? "animate-spin" : void 0,
397
+ name: "refresh"
398
+ })
399
+ }),
400
+ /* @__PURE__ */ J(B, {
401
+ className: "resource-page-primary-action",
402
+ disabled: _ != null,
403
+ onClick: () => D(!0),
404
+ children: [/* @__PURE__ */ q(H, {
405
+ "data-icon": "inline-start",
406
+ name: "plus"
407
+ }), g("resource.newFlow")]
408
+ }),
409
+ c != null && l != null && f != null && /* @__PURE__ */ q(s, {
410
+ action: c,
411
+ onAction: f,
412
+ title: l
413
+ })
414
+ ]
355
415
  })]
356
416
  }),
357
- /* @__PURE__ */ H("div", {
417
+ /* @__PURE__ */ J("div", {
358
418
  "aria-hidden": "true",
359
419
  className: "resource-list-columns flow-columns",
360
420
  children: [
361
- /* @__PURE__ */ V("span", { children: g("resource.name") }),
362
- /* @__PURE__ */ V("span", { children: g("resource.updated") }),
363
- /* @__PURE__ */ V("span", { children: g("resource.status") })
421
+ /* @__PURE__ */ q("span", { children: g("resource.name") }),
422
+ /* @__PURE__ */ q("span", { children: g("resource.updated") }),
423
+ /* @__PURE__ */ q("span", { children: g("resource.publication") }),
424
+ /* @__PURE__ */ q("span", { children: g("resource.enabledColumn") })
364
425
  ]
365
426
  }),
366
- /* @__PURE__ */ V("div", {
427
+ /* @__PURE__ */ q("div", {
367
428
  className: "resource-list",
368
- children: S ? Array.from({ length: 5 }, (e, t) => /* @__PURE__ */ V(Ze, {}, t)) : y ? /* @__PURE__ */ H(oe, {
429
+ children: b ? Array.from({ length: 5 }, (e, t) => /* @__PURE__ */ q(_t, {}, t)) : v ? /* @__PURE__ */ J(te, {
369
430
  className: "min-h-64",
370
431
  role: "alert",
371
- children: [/* @__PURE__ */ H(Se, { children: [
372
- /* @__PURE__ */ V(ie, {
432
+ children: [/* @__PURE__ */ J(ne, { children: [
433
+ /* @__PURE__ */ q(pe, {
373
434
  variant: "icon",
374
- children: /* @__PURE__ */ V(f, {
435
+ children: /* @__PURE__ */ q(H, {
375
436
  name: "alert",
376
437
  size: 20
377
438
  })
378
439
  }),
379
- /* @__PURE__ */ V(ae, { children: g("resource.flowsLoadFailed") }),
380
- /* @__PURE__ */ V(b, { children: g("resource.flowsLoadFailedDescription") })
381
- ] }), /* @__PURE__ */ V(Ce, { children: /* @__PURE__ */ V(p, {
440
+ /* @__PURE__ */ q(Ee, { children: g("resource.flowsLoadFailed") }),
441
+ /* @__PURE__ */ q(Ce, { children: g("resource.flowsLoadFailedDescription") })
442
+ ] }), /* @__PURE__ */ q(_e, { children: /* @__PURE__ */ q(B, {
382
443
  onClick: () => void h.retryFlows(),
383
444
  variant: "outline",
384
445
  children: g("empty.retry")
385
446
  }) })]
386
- }) : M.length == 0 ? /* @__PURE__ */ H(oe, {
447
+ }) : M.length == 0 ? /* @__PURE__ */ J(te, {
387
448
  className: "min-h-64",
388
- children: [/* @__PURE__ */ H(Se, { children: [
389
- /* @__PURE__ */ V(ie, {
449
+ children: [/* @__PURE__ */ J(ne, { children: [
450
+ /* @__PURE__ */ q(pe, {
390
451
  variant: "icon",
391
- children: /* @__PURE__ */ V(f, {
452
+ children: /* @__PURE__ */ q(H, {
392
453
  name: "flow",
393
454
  size: 20
394
455
  })
395
456
  }),
396
- /* @__PURE__ */ V(ae, { children: g(j.length == 0 ? "resource.noFlows" : "resource.noMatchingFlows") }),
397
- /* @__PURE__ */ V(b, { children: g(j.length == 0 ? "resource.noFlowsDescription" : "resource.noMatchingDescription") })
398
- ] }), j.length == 0 && /* @__PURE__ */ V(Ce, { children: /* @__PURE__ */ H(p, {
457
+ /* @__PURE__ */ q(Ee, { children: g(j.length == 0 ? "resource.noFlows" : "resource.noMatchingFlows") }),
458
+ /* @__PURE__ */ q(Ce, { children: g(j.length == 0 ? "resource.noFlowsDescription" : "resource.noMatchingDescription") })
459
+ ] }), j.length == 0 && /* @__PURE__ */ q(_e, { children: /* @__PURE__ */ J(B, {
399
460
  onClick: () => D(!0),
400
461
  variant: "outline",
401
- children: [/* @__PURE__ */ V(f, {
462
+ children: [/* @__PURE__ */ q(H, {
402
463
  "data-icon": "inline-start",
403
464
  name: "plus"
404
465
  }), g("resource.newFlow")]
405
466
  }) })]
406
- }) : M.map((e) => /* @__PURE__ */ V(Xe, {
407
- badge: n?.[e.flowId],
467
+ }) : M.map((e) => /* @__PURE__ */ q(gt, {
468
+ badge: i?.[e.flowId],
408
469
  busy: _,
409
470
  flow: e,
410
- href: i(e),
471
+ href: o(e),
411
472
  onSelect: m,
412
473
  store: h
413
474
  }, e.flowId))
414
475
  }),
415
- w != null && /* @__PURE__ */ V("div", {
476
+ S != null && /* @__PURE__ */ q("div", {
416
477
  className: "resource-list-footer",
417
- children: /* @__PURE__ */ V(p, {
418
- disabled: C,
478
+ children: /* @__PURE__ */ q(B, {
479
+ disabled: x || C,
419
480
  onClick: () => void h.workspace.loadMoreFlows(),
420
481
  variant: "outline",
421
- children: g(C ? "resource.loadingMore" : x ? "resource.retryLoadMore" : "resource.loadMore")
482
+ children: g(x ? "resource.loadingMore" : y ? "resource.retryLoadMore" : "resource.loadMore")
422
483
  })
423
484
  })
424
485
  ]
425
486
  }),
426
- ne && /* @__PURE__ */ V(Ve, {
487
+ E && /* @__PURE__ */ q(at, {
427
488
  fallback: null,
428
- children: /* @__PURE__ */ V(qe, {
429
- disabled: e,
430
- field: t,
489
+ children: /* @__PURE__ */ q(pt, {
490
+ disabled: t,
491
+ field: n,
431
492
  id: "flow-name",
432
- issue: v(k),
493
+ issue: U(k),
433
494
  label: g("resource.flowName"),
434
495
  name: k,
435
496
  onNameChange: A,
436
497
  onOpenChange: D,
437
- onSubmit: (e) => void se(e),
498
+ onSubmit: (e) => void N(e),
438
499
  pending: _ == "flow",
439
500
  title: g("resource.newFlow")
440
501
  })
@@ -445,7 +506,7 @@ function Qe({ createFlowDisabled: e, createFlowField: t, flowBadges: n, hrefForF
445
506
  }
446
507
  //#endregion
447
508
  //#region ../../node_modules/.bun/nanoid@6.0.1/node_modules/nanoid/index.browser.js
448
- var $e = (e) => crypto.getRandomValues(new Uint8Array(e)), et = (e, t, n) => {
509
+ var yt = (e) => crypto.getRandomValues(new Uint8Array(e)), bt = (e, t, n) => {
449
510
  let r = 256 - 256 % e.length;
450
511
  if (r === 256) {
451
512
  let r = e.length - 1;
@@ -467,41 +528,29 @@ var $e = (e) => crypto.getRandomValues(new Uint8Array(e)), et = (e, t, n) => {
467
528
  for (; s--;) if (t[s] < r && (o += e[t[s] % e.length], o.length >= a)) return o;
468
529
  }
469
530
  };
470
- }, tt = (e, t = 21) => et(e, t | 0, $e);
531
+ }, xt = (e, t = 21) => bt(e, t | 0, yt);
471
532
  //#endregion
472
533
  //#region src/flow/common/edgeChanges.ts
473
- function nt(e, t, n) {
474
- let r = {
475
- source: n.source,
476
- sourceHandle: n.sourceHandle,
477
- target: n.target,
478
- targetHandle: n.targetHandle
479
- }, i = it(e, t)?.nodes[n.target], a = i != null && "inputs" in i ? i.inputs[n.targetHandle] : void 0;
480
- return a?.kind == "sources" && a.sources.some((e) => e.kind == "node" && e.nodeId == n.source && e.output == n.sourceHandle) ? [] : fe(e, [{
481
- edge: r,
534
+ function St(e, t, n) {
535
+ return wt(e, t)?.edges.some((e) => Me(e, n)) ? [] : [{
536
+ edge: n,
482
537
  kind: "graph.edge.connect",
483
538
  target: t
484
- }]);
539
+ }];
485
540
  }
486
- function rt(e, t, n) {
487
- let r = {
488
- source: n.source,
489
- sourceHandle: n.sourceHandle,
490
- target: n.target,
491
- targetHandle: n.targetHandle
492
- }, i = it(e, t)?.nodes[n.target], a = i != null && "inputs" in i ? i.inputs[n.targetHandle] : void 0;
493
- return a?.kind != "sources" || !a.sources.some((e) => e.kind == "node" && e.nodeId == n.source && e.output == n.sourceHandle) ? [] : [{
494
- edge: r,
541
+ function Ct(e, t, n) {
542
+ return wt(e, t)?.edges.some((e) => Me(e, n)) ? [{
543
+ edge: n,
495
544
  kind: "graph.edge.disconnect",
496
545
  target: t
497
- }];
546
+ }] : [];
498
547
  }
499
- function it(e, t) {
548
+ function wt(e, t) {
500
549
  return t.kind == "flow" ? e.document.graph : e.document.subflows[t.id]?.graph;
501
550
  }
502
551
  //#endregion
503
552
  //#region src/flow/common/moduleChanges.ts
504
- async function at(e) {
553
+ async function Tt(e) {
505
554
  try {
506
555
  let { parse: t } = await import("./lib-C5Ipyfps.js").then((e) => e.t), n = t(e, {
507
556
  errorRecovery: !0,
@@ -517,182 +566,212 @@ async function at(e) {
517
566
  return [];
518
567
  }
519
568
  }
520
- function ot(e, t, n) {
569
+ function Et(e, t, n, r, i) {
521
570
  return [{
522
- imports: n,
571
+ beforeImports: n,
572
+ beforeSource: t,
573
+ imports: i,
523
574
  kind: "module.source.replace",
524
575
  moduleId: e,
525
- source: t
576
+ source: r
526
577
  }];
527
578
  }
528
- var st = tt("23456789abcdefghjkmnpqrstuvwxyz", 10), U = {
579
+ var Dt = xt("23456789abcdefghjkmnpqrstuvwxyz", 10), X = {
529
580
  activities: [],
530
581
  activitiesLoadFailed: !1,
531
582
  activitiesLoading: !1,
532
583
  activitiesLoadingMore: !1,
533
584
  bindings: [],
534
585
  detailLoading: !1,
586
+ loaded: !1,
535
587
  loadFailed: !1,
536
588
  loading: !1,
537
589
  loadMoreFailed: !1,
538
590
  loadingMore: !1,
539
591
  publications: [],
540
- publishing: !1
541
- }, ct = 20, lt = 50;
542
- function W(e, t) {
592
+ publishing: !1,
593
+ refreshing: !1
594
+ }, Ot = 20, kt = 50, At = 750;
595
+ function Z(e, t) {
543
596
  return e?.flowId == t.flowId;
544
597
  }
545
- var ut = class {
598
+ var jt = class {
546
599
  #e;
547
600
  #t;
548
601
  #n;
549
- #r = new x();
550
- #i = new x();
551
- #a = new x();
552
- #o = new x();
553
- #s;
554
- #c = t(U);
555
- #l;
602
+ #r = new m();
603
+ #i = new m();
604
+ #a;
605
+ #o = new m();
606
+ #s = new m();
607
+ #c;
608
+ #l = t(X);
556
609
  #u;
557
- constructor(t, n, r, i = () => crypto.randomUUID(), a = E()) {
558
- this.#e = t, this.#t = i, this.#n = a, this.#s = r, this.#l = n, this.$ = {
559
- activities: e(this.#c, (e) => e.activities),
560
- activitiesLoadFailed: e(this.#c, (e) => e.activitiesLoadFailed),
561
- activitiesLoading: e(this.#c, (e) => e.activitiesLoading),
562
- activitiesLoadingMore: e(this.#c, (e) => e.activitiesLoadingMore),
563
- activitiesNextCursor: e(this.#c, (e) => e.activitiesNextCursor),
564
- bindings: e(this.#c, (e) => e.bindings),
565
- changingTriggerId: e(this.#c, (e) => e.changingTriggerId),
566
- detail: e(this.#c, (e) => e.detail),
567
- detailLoading: e(this.#c, (e) => e.detailLoading),
568
- live: e(this.#c, (e) => e.live),
569
- loadFailed: e(this.#c, (e) => e.loadFailed),
570
- loading: e(this.#c, (e) => e.loading),
571
- loadMoreFailed: e(this.#c, (e) => e.loadMoreFailed),
572
- loadingMore: e(this.#c, (e) => e.loadingMore),
573
- nextCursor: e(this.#c, (e) => e.nextCursor),
574
- publications: e(this.#c, (e) => e.publications),
575
- publishing: e(this.#c, (e) => e.publishing),
576
- rollingBackPublicationId: e(this.#c, (e) => e.rollingBackPublicationId),
577
- selectedTriggerId: e(this.#c, (e) => e.selectedTriggerId),
578
- testingTriggerId: e(this.#c, (e) => e.testingTriggerId),
579
- testResult: e(this.#c, (e) => e.testResult),
580
- total: e(this.#c, (e) => e.total)
610
+ #d;
611
+ #f;
612
+ constructor(t, n, r, i, a = F, o = P()) {
613
+ this.#e = t, this.#t = a, this.#n = o, this.#a = i, this.#c = r, this.#u = n, this.$ = {
614
+ activities: e(this.#l, (e) => e.activities),
615
+ activitiesLoadFailed: e(this.#l, (e) => e.activitiesLoadFailed),
616
+ activitiesLoading: e(this.#l, (e) => e.activitiesLoading),
617
+ activitiesLoadingMore: e(this.#l, (e) => e.activitiesLoadingMore),
618
+ activitiesNextCursor: e(this.#l, (e) => e.activitiesNextCursor),
619
+ bindings: e(this.#l, (e) => e.bindings),
620
+ changingTriggerId: e(this.#l, (e) => e.changingTriggerId),
621
+ detail: e(this.#l, (e) => e.detail),
622
+ detailLoading: e(this.#l, (e) => e.detailLoading),
623
+ live: e(this.#l, (e) => e.live),
624
+ loadFailed: e(this.#l, (e) => e.loadFailed),
625
+ loading: e(this.#l, (e) => e.loading),
626
+ loadMoreFailed: e(this.#l, (e) => e.loadMoreFailed),
627
+ loadingMore: e(this.#l, (e) => e.loadingMore),
628
+ nextCursor: e(this.#l, (e) => e.nextCursor),
629
+ operation: e(this.#l, (e) => e.operation),
630
+ publications: e(this.#l, (e) => e.publications),
631
+ publishing: e(this.#l, (e) => e.publishing),
632
+ refreshing: e(this.#l, (e) => e.refreshing),
633
+ rollingBackPublicationId: e(this.#l, (e) => e.rollingBackPublicationId),
634
+ selectedTriggerId: e(this.#l, (e) => e.selectedTriggerId),
635
+ testingTriggerId: e(this.#l, (e) => e.testingTriggerId),
636
+ testResult: e(this.#l, (e) => e.testResult),
637
+ total: e(this.#l, (e) => e.total)
581
638
  };
582
639
  }
583
640
  dispose() {
584
- this.#r.invalidate(), this.#i.invalidate(), this.#a.invalidate(), this.#o.invalidate();
641
+ this.#r.invalidate(), this.#i.invalidate(), this.#v(), this.#o.invalidate(), this.#s.invalidate();
585
642
  for (let e of Object.values(this.$)) e.dispose();
586
- this.#c.dispose();
643
+ this.#l.dispose();
587
644
  }
588
645
  reset() {
589
- this.#r.invalidate(), this.#i.invalidate(), this.#a.invalidate(), this.#o.invalidate(), this.#u = void 0, this.#c.set(U);
646
+ this.#r.invalidate(), this.#i.invalidate(), this.#v(), this.#o.invalidate(), this.#s.invalidate(), this.#f = void 0, this.#l.set(X);
590
647
  }
591
648
  async load(e) {
592
- let t = { flowId: e }, n = this.#r.begin();
593
- W(this.#c.value.target, t) || (this.#u = void 0), this.#s(void 0), this.#c.set({
594
- ...U,
649
+ let t = { flowId: e }, n = this.#l.value, r = n.loaded && Z(n.target, t), i = this.#r.begin();
650
+ Z(n.target, t) || (this.#i.invalidate(), this.#v(), this.#f = void 0), r ? this.#x({
651
+ loadFailed: !1,
652
+ loadingMore: !1,
653
+ loadMoreFailed: !1,
654
+ refreshing: !0
655
+ }) : (this.#c(void 0), this.#l.set({
656
+ ...X,
595
657
  loading: !0,
596
658
  target: t
597
- });
659
+ }));
598
660
  try {
599
- let [e, r, i] = await this.#p(t);
600
- if (!n()) return;
601
- this.#h({
602
- bindings: i,
603
- live: e,
661
+ let e = r ? n.operation : await this.#g(t), [a, o, s] = await this.#h(t);
662
+ if (!i()) return;
663
+ if (this.#u.updateLive(a), this.#x({
664
+ bindings: s,
665
+ live: a,
666
+ loaded: !0,
604
667
  loading: !1,
605
- nextCursor: r.nextCursor,
606
- publications: r.publications,
607
- total: r.total
608
- });
668
+ nextCursor: o.nextCursor,
669
+ publications: o.publications,
670
+ refreshing: !1,
671
+ total: o.total,
672
+ ...r ? {} : {
673
+ operation: e,
674
+ publishing: e?.status == "pending"
675
+ }
676
+ }), !r && e?.status == "pending") {
677
+ let n = this.#u.$.targetFlow.value;
678
+ this.#_(t, e, this.#i.begin(), n?.flowId == t.flowId ? n.name : t.flowId);
679
+ }
609
680
  } catch (e) {
610
- if (!n()) return;
611
- this.#h({
612
- loadFailed: !0,
613
- loading: !1
614
- }), this.#s(R(e, this.#n.t));
681
+ if (!i()) return;
682
+ this.#x({
683
+ loadFailed: !r,
684
+ loading: !1,
685
+ refreshing: !1
686
+ }), this.#c(E(e, this.#n.t));
615
687
  }
616
688
  }
617
689
  async loadMore() {
618
- let { loadingMore: e, nextCursor: t, target: n } = this.#c.value;
690
+ let { loadingMore: e, nextCursor: t, target: n } = this.#l.value;
619
691
  if (e || t == null || n == null) return;
620
692
  let r = this.#r.capture();
621
- this.#h({
693
+ this.#x({
622
694
  loadMoreFailed: !1,
623
695
  loadingMore: !0
624
696
  });
625
697
  try {
626
698
  let e = await this.#e.listPublications(n.flowId, {
627
699
  cursor: t,
628
- limit: lt
700
+ limit: kt
629
701
  });
630
702
  if (!r()) return;
631
- let i = new Set(this.#c.value.publications.map((e) => e.publicationId));
632
- this.#h({
703
+ let i = new Set(this.#l.value.publications.map((e) => e.publicationId));
704
+ this.#x({
633
705
  loadingMore: !1,
634
706
  loadMoreFailed: !1,
635
707
  nextCursor: e.nextCursor,
636
- publications: [...this.#c.value.publications, ...e.publications.filter((e) => !i.has(e.publicationId))]
708
+ publications: [...this.#l.value.publications, ...e.publications.filter((e) => !i.has(e.publicationId))]
637
709
  });
638
710
  } catch (e) {
639
711
  if (!r()) return;
640
- this.#h({
712
+ this.#x({
641
713
  loadMoreFailed: !0,
642
714
  loadingMore: !1
643
- }), this.#s(R(e, this.#n.t));
715
+ }), this.#c(E(e, this.#n.t));
644
716
  }
645
717
  }
646
718
  async publish() {
647
- let e = this.#l.$.targetFlow.value, t = this.#l.$.draft.value;
648
- if (e == null || t == null || this.#c.value.changingTriggerId != null || this.#c.value.publishing || this.#c.value.rollingBackPublicationId != null) return !1;
649
- let n = { flowId: e.flowId }, r = this.#l.$.live.value?.publication?.publicationId ?? null, i = JSON.stringify({
650
- expectedLivePublicationId: r,
651
- flowId: e.flowId,
719
+ let e = this.#u.$.flowId.value;
720
+ if (!await this.#u.saveModuleEditor() || e != this.#u.$.flowId.value) return !1;
721
+ let t = this.#u.$.targetFlow.value, n = this.#u.$.draft.value;
722
+ if (t == null || n == null || this.#l.value.changingTriggerId != null || this.#l.value.publishing || this.#l.value.rollingBackPublicationId != null) return !1;
723
+ let r = { flowId: t.flowId }, i = this.#u.$.live.value?.publication?.publicationId ?? null, a = JSON.stringify({
724
+ expectedLivePublicationId: i,
725
+ flowId: t.flowId,
652
726
  kind: "publish",
653
- revisionId: t.revisionId
654
- }), a = this.#u?.signature == i ? this.#u : {
727
+ revisionId: n.revisionId
728
+ }), o = this.#f?.signature == a ? this.#f : {
655
729
  key: this.#t(),
656
- signature: i
657
- }, o = this.#i.begin();
658
- this.#u = a, this.#s(void 0), this.#m(n, { publishing: !0 });
730
+ signature: a
731
+ };
732
+ this.#v();
733
+ let s = this.#i.begin();
734
+ this.#f = o, this.#c(void 0), this.#b(r, { publishing: !0 });
659
735
  try {
660
- return await this.#e.publishFlow(e.flowId, t.revisionId, r, { idempotencyKey: a.key }), !o() || (await this.#d(n), !o()) ? !1 : (this.#u = void 0, this.#s({
661
- kind: "success",
662
- message: this.#n.t("notice.published", { name: e.name })
663
- }), !0);
736
+ let e = await this.#e.publishFlow(t.flowId, n.revisionId, i, { idempotencyKey: o.key });
737
+ return s() ? (this.#a.setItem(this.#y(r.flowId), e.operationId), this.#x({
738
+ operation: e,
739
+ publishing: e.status == "pending"
740
+ }), await this.#_(r, e, s, t.name)) : !1;
664
741
  } catch (e) {
665
- return o() ? (e instanceof P && e.code == "live.conflict" && await this.#f(n), this.#s(R(e, this.#n.t)), !1) : !1;
742
+ return s() ? (e instanceof L && e.code == "live.conflict" && await this.#m(r), this.#c(E(e, this.#n.t)), !1) : !1;
666
743
  } finally {
667
- o() && this.#h({ publishing: !1 });
744
+ s() && this.#x({ publishing: !1 });
668
745
  }
669
746
  }
670
747
  async rollback(e) {
671
- let { live: t, rollingBackPublicationId: n, target: r } = this.#c.value, i = t?.publication?.publicationId;
672
- if (r == null || i == null || this.#c.value.changingTriggerId != null || n != null || this.#c.value.publishing || e.flowId != r.flowId) return !1;
748
+ let { live: t, rollingBackPublicationId: n, target: r } = this.#l.value, i = t?.publication?.publicationId;
749
+ if (r == null || i == null || this.#l.value.changingTriggerId != null || n != null || this.#l.value.publishing || e.flowId != r.flowId) return !1;
673
750
  let a = JSON.stringify({
674
751
  currentPublicationId: i,
675
752
  flowId: r.flowId,
676
753
  kind: "rollback",
677
754
  targetPublicationId: e.publicationId
678
- }), o = this.#u?.signature == a ? this.#u : {
755
+ }), o = this.#f?.signature == a ? this.#f : {
679
756
  key: this.#t(),
680
757
  signature: a
681
- }, s = this.#i.begin();
682
- this.#u = o, this.#s(void 0), this.#h({ rollingBackPublicationId: e.publicationId });
758
+ };
759
+ this.#v();
760
+ let s = this.#i.begin();
761
+ this.#f = o, this.#c(void 0), this.#x({ rollingBackPublicationId: e.publicationId });
683
762
  try {
684
- return await this.#e.rollbackFlow(r.flowId, e.publicationId, i, { idempotencyKey: o.key }), !s() || (await this.#d(r), !s()) ? !1 : (this.#u = void 0, this.#s({
763
+ return await this.#e.rollbackFlow(r.flowId, e.publicationId, i, { idempotencyKey: o.key }), !s() || (await this.#p(r), !s()) ? !1 : (this.#f = void 0, this.#c({
685
764
  kind: "success",
686
765
  message: this.#n.t("notice.rolledBack", { revision: e.revisionId })
687
766
  }), !0);
688
767
  } catch (e) {
689
- return s() ? (e instanceof P && e.code == "live.conflict" && await this.#f(r), this.#s(R(e, this.#n.t)), !1) : !1;
768
+ return s() ? (e instanceof L && e.code == "live.conflict" && await this.#m(r), this.#c(E(e, this.#n.t)), !1) : !1;
690
769
  } finally {
691
- s() && this.#h({ rollingBackPublicationId: void 0 });
770
+ s() && this.#x({ rollingBackPublicationId: void 0 });
692
771
  }
693
772
  }
694
773
  closeTrigger() {
695
- this.#a.invalidate(), this.#o.invalidate(), this.#h({
774
+ this.#o.invalidate(), this.#s.invalidate(), this.#x({
696
775
  activities: [],
697
776
  activitiesLoadFailed: !1,
698
777
  activitiesLoading: !1,
@@ -706,10 +785,10 @@ var ut = class {
706
785
  });
707
786
  }
708
787
  async openTrigger(e) {
709
- let t = this.#c.value.target;
788
+ let t = this.#l.value.target;
710
789
  if (t == null) return;
711
- let n = this.#a.begin();
712
- this.#o.invalidate(), this.#h({
790
+ let n = this.#o.begin();
791
+ this.#s.invalidate(), this.#x({
713
792
  activities: [],
714
793
  activitiesLoadFailed: !1,
715
794
  activitiesLoading: !0,
@@ -721,335 +800,483 @@ var ut = class {
721
800
  testingTriggerId: void 0,
722
801
  testResult: void 0
723
802
  });
724
- let [r, i] = await Promise.allSettled([this.#e.getFlowTriggerBinding(t.flowId, e), this.#e.listFlowTriggerActivities(t.flowId, e, { limit: ct })]);
803
+ let [r, i] = await Promise.allSettled([this.#e.getFlowTriggerBinding(t.flowId, e), this.#e.listFlowTriggerActivities(t.flowId, e, { limit: Ot })]);
725
804
  if (n()) {
726
805
  if (r.status == "rejected") {
727
- this.#h({
806
+ this.#x({
728
807
  activitiesLoading: !1,
729
808
  detailLoading: !1
730
- }), this.#s(R(r.reason, this.#n.t));
809
+ }), this.#c(E(r.reason, this.#n.t));
731
810
  return;
732
811
  }
733
- this.#h({
812
+ this.#x({
734
813
  detail: r.value,
735
814
  detailLoading: !1
736
- }), i.status == "fulfilled" ? this.#h({
815
+ }), i.status == "fulfilled" ? this.#x({
737
816
  activities: i.value.activities,
738
817
  activitiesLoadFailed: !1,
739
818
  activitiesLoading: !1,
740
819
  activitiesNextCursor: i.value.nextCursor
741
- }) : (this.#h({
820
+ }) : (this.#x({
742
821
  activitiesLoadFailed: !0,
743
822
  activitiesLoading: !1
744
- }), this.#s(R(i.reason, this.#n.t)));
823
+ }), this.#c(E(i.reason, this.#n.t)));
745
824
  }
746
825
  }
747
826
  async loadMoreTriggerActivities() {
748
- let { activitiesLoadingMore: e, activitiesNextCursor: t, selectedTriggerId: n, target: r } = this.#c.value;
827
+ let { activitiesLoadingMore: e, activitiesNextCursor: t, selectedTriggerId: n, target: r } = this.#l.value;
749
828
  if (e || t == null || n == null || r == null) return;
750
- let i = this.#a.capture();
751
- this.#h({
829
+ let i = this.#o.capture();
830
+ this.#x({
752
831
  activitiesLoadFailed: !1,
753
832
  activitiesLoadingMore: !0
754
833
  });
755
834
  try {
756
835
  let e = await this.#e.listFlowTriggerActivities(r.flowId, n, {
757
836
  cursor: t,
758
- limit: ct
837
+ limit: Ot
759
838
  });
760
- if (!i() || this.#c.value.selectedTriggerId != n) return;
761
- let a = new Set(this.#c.value.activities.map((e) => e.activityId));
762
- this.#h({
763
- activities: [...this.#c.value.activities, ...e.activities.filter((e) => !a.has(e.activityId))],
839
+ if (!i() || this.#l.value.selectedTriggerId != n) return;
840
+ let a = new Set(this.#l.value.activities.map((e) => e.activityId));
841
+ this.#x({
842
+ activities: [...this.#l.value.activities, ...e.activities.filter((e) => !a.has(e.activityId))],
764
843
  activitiesLoadFailed: !1,
765
844
  activitiesLoadingMore: !1,
766
845
  activitiesNextCursor: e.nextCursor
767
846
  });
768
847
  } catch (e) {
769
- if (!i() || this.#c.value.selectedTriggerId != n) return;
770
- this.#h({
848
+ if (!i() || this.#l.value.selectedTriggerId != n) return;
849
+ this.#x({
771
850
  activitiesLoadFailed: !0,
772
851
  activitiesLoadingMore: !1
773
- }), this.#s(R(e, this.#n.t));
852
+ }), this.#c(E(e, this.#n.t));
774
853
  }
775
854
  }
776
855
  async testTrigger() {
777
- let { detail: e, selectedTriggerId: t, target: n, testingTriggerId: r } = this.#c.value;
856
+ let { detail: e, selectedTriggerId: t, target: n, testingTriggerId: r } = this.#l.value;
778
857
  if (e?.binding.kind != "poll" || e.binding.currentPublicationId == null || t == null || n == null || r != null) return !1;
779
- let i = this.#o.begin();
780
- this.#h({
858
+ let i = this.#s.begin();
859
+ this.#x({
781
860
  testingTriggerId: t,
782
861
  testResult: void 0
783
862
  });
784
863
  try {
785
864
  let e = await this.#e.testFlowPollTrigger(n.flowId, t);
786
- return !i() || this.#c.value.selectedTriggerId != t ? !1 : (this.#h({ testResult: e }), !0);
865
+ return !i() || this.#l.value.selectedTriggerId != t ? !1 : (this.#x({ testResult: e }), !0);
787
866
  } catch (e) {
788
- return i() && this.#c.value.selectedTriggerId == t && this.#s(R(e, this.#n.t)), !1;
867
+ return i() && this.#l.value.selectedTriggerId == t && this.#c(E(e, this.#n.t)), !1;
789
868
  } finally {
790
- i() && this.#c.value.selectedTriggerId == t && this.#h({ testingTriggerId: void 0 });
869
+ i() && this.#l.value.selectedTriggerId == t && this.#x({ testingTriggerId: void 0 });
791
870
  }
792
871
  }
793
872
  async toggleTrigger(e) {
794
- let t = this.#c.value.target;
795
- if (t == null || this.#c.value.changingTriggerId != null || this.#c.value.publishing || this.#c.value.rollingBackPublicationId != null) return !1;
873
+ let t = this.#l.value.target;
874
+ if (t == null || this.#l.value.changingTriggerId != null || this.#l.value.publishing || this.#l.value.rollingBackPublicationId != null) return !1;
875
+ this.#v();
796
876
  let n = this.#i.begin();
797
- this.#h({ changingTriggerId: e.triggerNodeId });
877
+ this.#x({ changingTriggerId: e.triggerNodeId });
798
878
  try {
799
879
  if (e.operatorState == "active" ? await this.#e.pauseFlowTrigger(t.flowId, e.triggerNodeId) : await this.#e.resumeFlowTrigger(t.flowId, e.triggerNodeId), !n()) return !1;
800
880
  let r = await this.#e.listFlowTriggerBindings(t.flowId);
801
- return n() ? (this.#h({ bindings: r }), this.#c.value.selectedTriggerId == e.triggerNodeId && this.openTrigger(e.triggerNodeId), this.#s({
881
+ return n() ? (this.#x({ bindings: r }), this.#l.value.selectedTriggerId == e.triggerNodeId && this.openTrigger(e.triggerNodeId), this.#c({
802
882
  kind: "success",
803
883
  message: this.#n.t(e.operatorState == "active" ? "notice.triggerPaused" : "notice.triggerResumed")
804
884
  }), !0) : !1;
805
885
  } catch (e) {
806
- return n() && this.#s(R(e, this.#n.t)), !1;
886
+ return n() && this.#c(E(e, this.#n.t)), !1;
807
887
  } finally {
808
- n() && this.#h({ changingTriggerId: void 0 });
888
+ n() && this.#x({ changingTriggerId: void 0 });
809
889
  }
810
890
  }
811
- async #d(e) {
812
- let [t, n, r] = await this.#p(e);
813
- this.#l.updateLive(t), await this.#l.refreshFlows(), W(this.#c.value.target, e) && this.#h({
814
- bindings: r,
815
- live: t,
816
- loadFailed: !1,
817
- nextCursor: n.nextCursor,
818
- publications: n.publications,
819
- total: n.total
891
+ async #p(e, t) {
892
+ let n = this.#r.begin(), [r, i, a] = await this.#h(e, t).catch((t) => {
893
+ throw n() && Z(this.#l.value.target, e) && this.#x({ refreshing: !1 }), t;
820
894
  });
895
+ t?.throwIfAborted(), n() && this.#u.updateLive(r), n() && Z(this.#l.value.target, e) && this.#x({
896
+ bindings: a,
897
+ live: r,
898
+ loaded: !0,
899
+ loadFailed: !1,
900
+ loadingMore: !1,
901
+ nextCursor: i.nextCursor,
902
+ publications: i.publications,
903
+ refreshing: !1,
904
+ total: i.total
905
+ }), await this.#u.refreshFlows();
821
906
  }
822
- async #f(e) {
907
+ async #m(e) {
823
908
  try {
824
- await this.#d(e), this.#u = void 0;
909
+ await this.#p(e), this.#f = void 0;
825
910
  } catch {
826
911
  return;
827
912
  }
828
913
  }
829
- async #p(e) {
914
+ async #h(e, t) {
830
915
  return await Promise.all([
831
- this.#e.getLive(e.flowId),
916
+ this.#e.getLive(e.flowId, t),
832
917
  this.#e.listPublications(e.flowId, {
833
918
  includeTotal: !0,
834
- limit: lt
835
- }),
836
- this.#e.listFlowTriggerBindings(e.flowId)
919
+ limit: kt
920
+ }, t),
921
+ this.#e.listFlowTriggerBindings(e.flowId, t)
837
922
  ]);
838
923
  }
839
- #m(e, t) {
840
- W(this.#c.value.target, e) ? this.#h(t) : this.#c.set({
841
- ...U,
924
+ async #g(e) {
925
+ let t = this.#a.getItem(this.#y(e.flowId));
926
+ if (t != null && t != "") try {
927
+ return await this.#e.getPublishOperation(e.flowId, t);
928
+ } catch (t) {
929
+ if (t instanceof L && t.code == "publication.operation-not-found") {
930
+ this.#a.setItem(this.#y(e.flowId), "");
931
+ return;
932
+ }
933
+ throw t;
934
+ }
935
+ }
936
+ async #_(e, t, n, r) {
937
+ this.#v();
938
+ let i = Y.runFork(Y.gen({ self: this }, function* () {
939
+ let i = t;
940
+ for (; i.status == "pending";) {
941
+ if (yield* Y.sleep(At), !n()) return !1;
942
+ let t = yield* Y.tryPromise({
943
+ try: (t) => this.#e.getPublishOperation(e.flowId, i.operationId, t),
944
+ catch: (e) => e
945
+ }).pipe(Y.match({
946
+ onFailure: (e) => ({ error: e }),
947
+ onSuccess: (e) => ({ value: e })
948
+ }));
949
+ if (!n()) return !1;
950
+ if ("error" in t) {
951
+ let n = t.error;
952
+ if (n instanceof L && n.code == "publication.operation-not-found") return this.#a.setItem(this.#y(e.flowId), ""), this.#b(e, {
953
+ operation: void 0,
954
+ publishing: !1
955
+ }), this.#c(E(n, this.#n.t)), !1;
956
+ this.#c(E(n, this.#n.t));
957
+ continue;
958
+ }
959
+ i = t.value, this.#b(e, { operation: i });
960
+ }
961
+ if (!n()) return !1;
962
+ if (this.#f = void 0, this.#b(e, {
963
+ operation: i,
964
+ publishing: !1
965
+ }), i.status == "failed") return this.#c({
966
+ kind: "error",
967
+ message: i.issue.message
968
+ }), !1;
969
+ let a = yield* Y.tryPromise({
970
+ try: (t) => this.#p(e, t),
971
+ catch: (e) => e
972
+ }).pipe(Y.match({
973
+ onFailure: (e) => (n() && this.#c(E(e, this.#n.t)), !1),
974
+ onSuccess: () => !0
975
+ }));
976
+ return n() ? (a && this.#c({
977
+ kind: "success",
978
+ message: this.#n.t("notice.published", { name: r })
979
+ }), !0) : !1;
980
+ }));
981
+ this.#d = i;
982
+ let a = await Y.runPromiseExit(ut.join(i));
983
+ if (lt.isSuccess(a)) return a.value;
984
+ if (ct.hasInterruptsOnly(a.cause)) return !1;
985
+ throw ct.squash(a.cause);
986
+ }
987
+ #v() {
988
+ this.#d?.interruptUnsafe(), this.#d = void 0;
989
+ }
990
+ #y(e) {
991
+ return `publish-operation:${e}`;
992
+ }
993
+ #b(e, t) {
994
+ Z(this.#l.value.target, e) ? this.#x(t) : this.#l.set({
995
+ ...X,
842
996
  ...t,
843
997
  target: e
844
998
  });
845
999
  }
846
- #h(e) {
847
- this.#c.set({
848
- ...this.#c.value,
1000
+ #x(e) {
1001
+ this.#l.set({
1002
+ ...this.#l.value,
849
1003
  ...e
850
1004
  });
851
1005
  }
852
- }, dt = { starting: !1 };
853
- function ft(e) {
1006
+ }, Mt = { starting: !1 };
1007
+ function Nt(e) {
854
1008
  switch (e.kind) {
855
1009
  case "condition": return { [e.node.input.handle]: e.node.input };
856
- case "subflow": return s(e.definition?.inputs ?? []);
857
- case "task": return s(e.definition?.inputs ?? []);
1010
+ case "subflow": return Re(e.definition?.inputs ?? []);
1011
+ case "task": return Re(e.definition?.inputs ?? []);
858
1012
  case "value": return {};
1013
+ case "wait": return { [e.node.input.handle]: e.node.input };
859
1014
  }
860
1015
  }
861
- function pt(e) {
1016
+ function Pt(e) {
862
1017
  return e.node.name == null ? e.kind == "task" || e.kind == "subflow" ? e.definition?.name ?? e.id : e.id : e.node.name;
863
1018
  }
864
- async function mt(e, t) {
865
- let { FlowRunInputEditorStore: n } = await import("./flowRunInputEditorStore-BeyUSWpO.js").then((e) => e.n), r = N(e), i = r.graph({ kind: "flow" });
866
- return i == null ? [] : Object.entries(i.nodes).toSorted(([e], [t]) => e.localeCompare(t)).flatMap(([e, i]) => {
867
- let a = r.resolveNode(e, i);
868
- if (a.kind == "trigger") return [];
869
- let o = Object.entries(ft(a)).filter(([e, t]) => a.node.inputs[e] == null && !Object.hasOwn(t, "value")).toSorted(([e], [t]) => e.localeCompare(t)).map(([e, t]) => Object.assign({
1019
+ async function Ft(e, t, n) {
1020
+ let { FlowRunInputEditorStore: r } = await import("./flowRunInputEditorStore-NPGePkvP.js").then((e) => e.r), i = C(e), a = i.graph({ kind: "flow" });
1021
+ if (a == null) return [];
1022
+ let o = /* @__PURE__ */ new Set([n]), s = [n];
1023
+ for (; s.length > 0;) {
1024
+ let e = s.pop();
1025
+ for (let t of a.edges) t.source != e || o.has(t.target) || (o.add(t.target), s.push(t.target));
1026
+ }
1027
+ return Object.entries(a.nodes).filter(([e]) => o.has(e)).toSorted(([e], [t]) => e.localeCompare(t)).flatMap(([e, n]) => {
1028
+ let a = i.resolveNode(e, n);
1029
+ if (a.kind == "trigger") {
1030
+ if (a.trigger.kind == "manual" || a.trigger.kind == "cron") return [];
1031
+ let n = new r([{
1032
+ handle: "payload",
1033
+ jsonSchema: l(a.trigger),
1034
+ nullable: !1
1035
+ }], t);
1036
+ return n.replaceValues({ payload: {} }), [{
1037
+ editor: n,
1038
+ nodeId: e,
1039
+ title: a.trigger.name
1040
+ }];
1041
+ }
1042
+ let o = Object.entries(Nt(a)).filter(([e, t]) => a.node.inputs[e] == null && !Object.hasOwn(t, "value")).toSorted(([e], [t]) => e.localeCompare(t)).map(([e, t]) => Object.assign({
870
1043
  handle: e,
871
1044
  jsonSchema: t.jsonSchema,
872
1045
  nullable: t.nullable
873
1046
  }, t.description == null ? {} : { description: t.description }));
874
1047
  return o.length == 0 ? [] : [{
875
- editor: new n(o, t),
1048
+ editor: new r(o, t),
876
1049
  nodeId: e,
877
- title: pt(a)
1050
+ title: Pt(a)
878
1051
  }];
879
1052
  });
880
1053
  }
881
- var ht = class {
1054
+ var It = class {
882
1055
  #e;
883
1056
  #t;
884
1057
  #n;
885
- #r = new x();
886
- #i = new x();
887
- #a;
1058
+ #r;
1059
+ #i = new m();
1060
+ #a = new m();
888
1061
  #o;
889
- #s = t(dt);
890
- #c;
891
- constructor(t, n, r, i = E(), a = () => crypto.randomUUID()) {
892
- this.#e = t, this.#a = n, this.#o = r, this.#n = i, this.#t = a, this.$ = {
893
- inputRequest: e(this.#s, (e) => e.inputRequest),
894
- starting: e(this.#s, (e) => e.starting),
895
- submitting: e(this.#s, (e) => e.submitting)
1062
+ #s;
1063
+ #c = t(Mt);
1064
+ #l;
1065
+ constructor(t, n, r, i, a = P(), o = F) {
1066
+ this.#e = i, this.#t = t, this.#o = n, this.#s = r, this.#r = a, this.#n = o, this.$ = {
1067
+ inputRequest: e(this.#c, (e) => e.inputRequest),
1068
+ starting: e(this.#c, (e) => e.starting),
1069
+ submitting: e(this.#c, (e) => e.submitting)
896
1070
  };
897
1071
  }
898
1072
  dispose() {
899
- this.#r.invalidate(), this.#i.invalidate(), this.#d();
1073
+ this.#i.invalidate(), this.#a.invalidate(), this.#f();
900
1074
  for (let e of Object.values(this.$)) e.dispose();
901
- this.#s.dispose();
1075
+ this.#c.dispose();
902
1076
  }
903
1077
  reset() {
904
- this.#r.invalidate(), this.#i.invalidate(), this.#c = void 0;
905
- let e = this.#s.value.inputRequest;
906
- this.#s.set(dt), this.#d(e);
1078
+ this.#i.invalidate(), this.#a.invalidate(), this.#l = void 0;
1079
+ let e = this.#c.value.inputRequest;
1080
+ this.#c.set(Mt), this.#f(e);
907
1081
  }
908
- async requestDraft(e, t) {
909
- let n = this.#i.begin();
910
- return await this.#l("draft", e, t, t.revisionId, n);
1082
+ async requestDraft(e, t, n) {
1083
+ let r = this.#a.begin();
1084
+ try {
1085
+ return await this.#u("draft", e, t, t.revisionId, r, void 0, n);
1086
+ } catch (e) {
1087
+ return r() && this.#s(E(e, this.#r.t)), "unavailable";
1088
+ } finally {
1089
+ r() && this.#p({ starting: !1 });
1090
+ }
911
1091
  }
912
1092
  async requestLive(e) {
913
- let t = this.#i.begin();
914
- this.#o(void 0), this.#f({ starting: !0 });
1093
+ let t = this.#a.begin();
1094
+ this.#s(void 0), this.#p({ starting: !0 });
915
1095
  try {
916
- let n = (await this.#e.getLive(e.flowId)).publication;
1096
+ let n = (await this.#t.getLive(e.flowId)).publication;
917
1097
  if (n == null) return "unavailable";
918
- let r = await this.#e.getRevision(e.flowId, n.revisionId);
919
- return t() ? await this.#l("live", e, r, n.revisionId, t, n.publicationId) : "unavailable";
1098
+ let r = await this.#t.getRevision(e.flowId, n.revisionId);
1099
+ return t() ? await this.#u("live", e, r, n.revisionId, t, n.publicationId) : "unavailable";
920
1100
  } catch (e) {
921
- return t() && this.#o(R(e, this.#n.t)), "unavailable";
1101
+ return t() && this.#s(E(e, this.#r.t)), "unavailable";
922
1102
  } finally {
923
- t() && this.#f({ starting: !1 });
1103
+ t() && this.#p({ starting: !1 });
924
1104
  }
925
1105
  }
926
1106
  dismissInputs() {
927
- let e = this.#s.value.inputRequest;
928
- this.#f({ inputRequest: void 0 }), this.#d(e);
1107
+ let e = this.#c.value.inputRequest;
1108
+ this.#p({ inputRequest: void 0 }), this.#f(e);
929
1109
  }
930
1110
  async confirmInputs() {
931
- let e = this.#s.value.inputRequest;
932
- if (e == null) return !1;
933
- if (!e.valid.value) return this.#f({ inputRequest: {
1111
+ let e = this.#c.value.inputRequest;
1112
+ if (e == null || e.triggerId == null) return !1;
1113
+ if (!e.valid.value) return this.#p({ inputRequest: {
934
1114
  ...e,
935
1115
  attempted: !0
936
1116
  } }), !1;
937
- let t = Object.fromEntries(e.groups.map((e) => [e.nodeId, e.editor.values()])), n = await this.#u(e.source, e.flow, e.revisionId, t, e.publicationId);
938
- return n && this.#s.value.inputRequest === e && this.dismissInputs(), n;
1117
+ let t = Object.fromEntries(e.groups.filter((t) => t.nodeId != e.triggerId).map((e) => [e.nodeId, e.editor.values()])), n = e.groups.find((t) => t.nodeId == e.triggerId)?.editor.values().payload ?? {}, r = await this.#d(e.source, e.flow, e.revisionId, {
1118
+ nodeId: e.triggerId,
1119
+ payload: n
1120
+ }, t, e.publicationId);
1121
+ return r && this.#c.value.inputRequest === e && this.dismissInputs(), r;
1122
+ }
1123
+ async selectTrigger(e) {
1124
+ let t = this.#c.value.inputRequest;
1125
+ if (t == null || !t.triggers.some((t) => t.nodeId == e)) return;
1126
+ let r = this.#a.begin();
1127
+ this.#p({ starting: !0 });
1128
+ try {
1129
+ let i = await Ft(t.revision, this.#r.lang$, e);
1130
+ if (!r() || this.#c.value.inputRequest !== t) {
1131
+ for (let e of i) e.editor.dispose();
1132
+ return;
1133
+ }
1134
+ let a = n((e) => i.every((t) => e(t.editor.valid$)));
1135
+ this.#p({ inputRequest: {
1136
+ ...t,
1137
+ attempted: !1,
1138
+ groups: i,
1139
+ triggerId: e,
1140
+ valid: a
1141
+ } }), this.#f(t);
1142
+ } catch (e) {
1143
+ r() && this.#s(E(e, this.#r.t));
1144
+ } finally {
1145
+ r() && this.#p({ starting: !1 });
1146
+ }
939
1147
  }
940
- async #l(e, t, r, i, a, o) {
941
- let s = this.#s.value.inputRequest;
942
- this.#f({
1148
+ async #u(e, t, r, i, a, o, s) {
1149
+ let c = this.#c.value.inputRequest;
1150
+ this.#p({
943
1151
  inputRequest: void 0,
944
1152
  starting: !0,
945
1153
  submitting: void 0
946
- }), this.#d(s);
947
- let c;
948
- try {
949
- c = await mt(r, this.#n.lang$);
950
- } catch (e) {
951
- throw a() && this.#f({
952
- starting: !1,
953
- submitting: void 0
954
- }), e;
955
- }
1154
+ }), this.#f(c);
1155
+ let l = C(r).graph({ kind: "flow" }), u = Object.entries(l?.nodes ?? {}).flatMap(([e, t]) => "inputs" in t ? [] : [{
1156
+ nodeId: e,
1157
+ title: t.name
1158
+ }]);
1159
+ if (u.length == 0) return this.#p({ starting: !1 }), this.#s({
1160
+ kind: "error",
1161
+ message: this.#r.t("runInput.noTrigger")
1162
+ }), "unavailable";
1163
+ let d = s == null ? u.length == 1 ? u[0] : void 0 : u.find((e) => e.nodeId == s);
1164
+ if (s != null && d == null) return this.#p({ starting: !1 }), this.#s({
1165
+ kind: "error",
1166
+ message: this.#r.t("runInput.selectTrigger")
1167
+ }), "unavailable";
1168
+ let f = d == null ? [] : await Ft(r, this.#r.lang$, d.nodeId);
956
1169
  if (!a()) {
957
- for (let e of c) e.editor.dispose();
1170
+ for (let e of f) e.editor.dispose();
958
1171
  return "unavailable";
959
1172
  }
960
- if (c.length == 0) return await this.#u(e, t, i, {}, o) ? "started" : "unavailable";
961
- let l = n((e) => c.every((t) => e(t.editor.valid$)));
962
- return this.#f({
1173
+ if (d != null && f.length == 0) return await this.#d(e, t, i, {
1174
+ nodeId: d.nodeId,
1175
+ payload: {}
1176
+ }, {}, o) ? "started" : "unavailable";
1177
+ let p = n((e) => d != null && f.every((t) => e(t.editor.valid$)));
1178
+ return this.#p({
963
1179
  inputRequest: {
964
1180
  attempted: !1,
965
1181
  flow: t,
966
- groups: c,
1182
+ groups: f,
1183
+ revision: r,
1184
+ triggers: u,
1185
+ triggerId: d?.nodeId,
967
1186
  ...o == null ? {} : { publicationId: o },
968
1187
  revisionId: i,
969
1188
  source: e,
970
- valid: l
1189
+ valid: p
971
1190
  },
972
1191
  starting: !1,
973
1192
  submitting: void 0
974
1193
  }), "input";
975
1194
  }
976
- async #u(e, t, n, r = {}, i) {
977
- if (e == "live" && i == null) return !1;
978
- let a = this.#r.capture(), o = this.#a.prepareStart();
979
- this.#o(void 0), this.#f({
1195
+ async #d(e, t, n, r, i = {}, a) {
1196
+ if (e == "live" && a == null) return !1;
1197
+ let o = this.#i.capture(), s = this.#o.prepareStart();
1198
+ this.#s(void 0), this.#p({
980
1199
  starting: !0,
981
1200
  submitting: e
982
1201
  });
983
- let s = e == "draft" ? {
984
- flowId: t.flowId,
985
- revisionId: n
986
- } : { publicationId: i }, c = JSON.stringify({
987
- inputs: r,
988
- source: e,
989
- ...s
990
- }), l = this.#c?.signature == c ? this.#c : {
991
- key: this.#t(),
992
- signature: c
993
- };
994
- this.#c = l;
995
1202
  try {
996
- let s = e == "draft" ? await this.#e.createDraftRun(t.flowId, n, {
997
- idempotencyKey: l.key,
998
- inputs: r
999
- }) : await this.#e.createLiveRun(i, {
1000
- idempotencyKey: l.key,
1001
- inputs: r
1203
+ if (e == "draft") {
1204
+ let e = await this.#e(t.flowId);
1205
+ if (e == null || !o() || !s()) return !1;
1206
+ n = e;
1207
+ }
1208
+ let c = e == "draft" ? {
1209
+ flowId: t.flowId,
1210
+ revisionId: n
1211
+ } : { publicationId: a }, l = JSON.stringify({
1212
+ inputs: i,
1213
+ trigger: r,
1214
+ source: e,
1215
+ ...c
1216
+ }), u = this.#l?.signature == l ? this.#l : {
1217
+ key: this.#n(),
1218
+ signature: l
1219
+ };
1220
+ this.#l = u;
1221
+ let d = e == "draft" ? await this.#t.createDraftRun(t.flowId, n, {
1222
+ idempotencyKey: u.key,
1223
+ inputs: i,
1224
+ trigger: r
1225
+ }) : await this.#t.createLiveRun(a, {
1226
+ idempotencyKey: u.key,
1227
+ inputs: i,
1228
+ trigger: r
1002
1229
  });
1003
- return !a() || !o() ? !1 : (this.#c = void 0, this.#a.follow(s, o));
1230
+ return !o() || !s() ? !1 : (this.#l = void 0, this.#o.follow(d, s));
1004
1231
  } catch (e) {
1005
- return a() && o() && this.#o(R(e, this.#n.t)), !1;
1232
+ return o() && s() && this.#s(E(e, this.#r.t)), !1;
1006
1233
  } finally {
1007
- a() && this.#f({
1234
+ o() && this.#p({
1008
1235
  starting: !1,
1009
1236
  submitting: void 0
1010
1237
  });
1011
1238
  }
1012
1239
  }
1013
- #d(e = this.#s.value.inputRequest) {
1240
+ #f(e = this.#c.value.inputRequest) {
1014
1241
  if (e != null) {
1015
1242
  e.valid.dispose();
1016
1243
  for (let t of e.groups) t.editor.dispose();
1017
1244
  }
1018
1245
  }
1019
- #f(e) {
1020
- this.#s.set({
1021
- ...this.#s.value,
1246
+ #p(e) {
1247
+ this.#c.set({
1248
+ ...this.#c.value,
1022
1249
  ...e
1023
1250
  });
1024
1251
  }
1025
- }, gt = {
1252
+ }, Lt = {
1026
1253
  actions: {},
1027
1254
  catalogs: {}
1028
1255
  };
1029
- function _t(e) {
1256
+ function Rt(e) {
1030
1257
  return Object.entries(e).map(([e, t]) => ({
1031
1258
  description: t.description,
1032
1259
  handle: e,
1033
1260
  jsonSchema: t.jsonSchema
1034
1261
  }));
1035
1262
  }
1036
- function G(e, t) {
1263
+ function Q(e, t) {
1037
1264
  return {
1038
1265
  connector: e,
1039
- description: e.defaultConnection == null ? t("addNode.connectorNeedsConnection", {
1266
+ description: e.authenticated && e.defaultConnection == null ? t("addNode.connectorNeedsConnection", {
1040
1267
  description: e.description,
1041
1268
  service: e.serviceName
1042
1269
  }) : e.description,
1043
1270
  group: t("addNode.connectorActions"),
1044
- icon: e.icon ?? ":carbon:connection-signal:",
1271
+ icon: p(e),
1045
1272
  id: `connector:${e.actionId}`,
1046
- inputs: _t(e.inputs),
1273
+ inputs: Rt(e.inputs),
1047
1274
  kind: "connector",
1048
1275
  label: e.name,
1049
- outputs: _t(e.outputs)
1276
+ outputs: Rt(e.outputs)
1050
1277
  };
1051
1278
  }
1052
- function vt(e, t) {
1279
+ function zt(e, t) {
1053
1280
  let n = /* @__PURE__ */ new Map();
1054
1281
  for (let t of e) {
1055
1282
  let e = n.get(t.serviceId) ?? [];
@@ -1057,7 +1284,7 @@ function vt(e, t) {
1057
1284
  }
1058
1285
  return [...n.values()].toSorted((e, t) => e[0].serviceName.localeCompare(t[0].serviceName)).map((e) => {
1059
1286
  let n = e[0], r = e.map((e) => {
1060
- let n = G(e, t);
1287
+ let n = Q(e, t);
1061
1288
  return {
1062
1289
  description: n.description,
1063
1290
  label: n.label,
@@ -1068,7 +1295,7 @@ function vt(e, t) {
1068
1295
  choices: r,
1069
1296
  description: t(r.length == 1 ? "addNode.connectorActionCountOne" : "addNode.connectorActionCount", { count: r.length }),
1070
1297
  group: t("addNode.connectorActions"),
1071
- icon: n.icon ?? ":carbon:connection-signal:",
1298
+ icon: p(n),
1072
1299
  id: `connector-provider:${n.serviceId}`,
1073
1300
  inputs: [],
1074
1301
  kind: "connector-group",
@@ -1078,12 +1305,12 @@ function vt(e, t) {
1078
1305
  };
1079
1306
  });
1080
1307
  }
1081
- function yt(e, t) {
1308
+ function Bt(e, t) {
1082
1309
  return {
1083
1310
  choices: [],
1084
1311
  description: t("addNode.connectorBrowseActions"),
1085
1312
  group: t("addNode.connectorActions"),
1086
- icon: e.icon ?? ":carbon:connection-signal:",
1313
+ icon: p(e),
1087
1314
  id: `connector-provider:${e.serviceId}`,
1088
1315
  inputs: [],
1089
1316
  kind: "connector-group",
@@ -1092,17 +1319,39 @@ function yt(e, t) {
1092
1319
  serviceId: e.serviceId
1093
1320
  };
1094
1321
  }
1095
- function bt(e) {
1096
- if (e?.kind != "task" || e.node.task != null) return;
1097
- let t = e.definition;
1098
- if (!(t == null || !("executor" in t) || t.executor.kind != "connector")) return {
1099
- actionId: t.executor.action,
1100
- connectionId: t.executor.connectionId,
1322
+ function Vt(e, t) {
1323
+ if (e == null) return;
1324
+ let n = e.kind == "wait" ? e.node.notification?.taskId : e.kind == "task" && e.node.task == null ? e.node.taskId : void 0;
1325
+ if (n == null) return;
1326
+ let r = e.kind == "task" ? e.definition : t?.task(n);
1327
+ if (!(r == null || !("executor" in r) || r.executor.kind != "connector")) return {
1328
+ actionId: r.executor.action,
1329
+ connectionId: r.executor.connectionId,
1101
1330
  nodeId: e.id,
1102
- taskId: e.node.taskId
1331
+ taskId: n
1103
1332
  };
1104
1333
  }
1105
- var xt = class {
1334
+ function Ht(e, t, n) {
1335
+ if (e == null) return [];
1336
+ let r = [];
1337
+ for (let i of [...je(e.revision.content).tasks].toSorted()) {
1338
+ let a = e.task(i);
1339
+ if (a?.executor.kind != "connector") continue;
1340
+ let o = t[a.executor.action];
1341
+ if (o?.authenticated != 1) continue;
1342
+ let s = a.executor.connectionId == null ? void 0 : n[o.serviceId]?.byId.get(a.executor.connectionId);
1343
+ s == null && o.defaultConnection?.connectionId == a.executor.connectionId && (s = o.defaultConnection), (a.executor.connectionId == null || n[o.serviceId] != null && s?.status != "active") && r.push({
1344
+ code: "task.connector-connection-required",
1345
+ column: 0,
1346
+ line: 1,
1347
+ message: `Connector Task "${i}" requires an active Connection.`,
1348
+ path: `/document/tasks/${i}/executor/connectionId`,
1349
+ values: { taskId: i }
1350
+ });
1351
+ }
1352
+ return r;
1353
+ }
1354
+ var Ut = class {
1106
1355
  #e;
1107
1356
  #t;
1108
1357
  #n;
@@ -1118,43 +1367,44 @@ var xt = class {
1118
1367
  #f;
1119
1368
  #p;
1120
1369
  #m;
1121
- constructor(r, i, a, o, s = E()) {
1122
- this.#r = /* @__PURE__ */ new Map(), this.#i = /* @__PURE__ */ new Set(), this.#a = new x(), this.#u = t(gt), this.#m = !1, this.browseAddNodeOptions = async (e) => {
1123
- if (this.#m) return;
1124
- let t = this.#d.$.flowId.value;
1370
+ #h;
1371
+ constructor(r, i, a, o, s = P()) {
1372
+ this.#r = /* @__PURE__ */ new Map(), this.#i = /* @__PURE__ */ new Set(), this.#a = new m(), this.#o = new m(), this.#d = t(Lt), this.#h = !1, this.browseAddNodeOptions = async (e) => {
1373
+ if (this.#h) return;
1374
+ let t = this.#f.$.flowId.value;
1125
1375
  if (t == null) return;
1126
- let n = this.#p ?? await this.#e.listConnectorProviders(e, t);
1127
- if (!(e.aborted || this.#m || t != this.#d.$.flowId.value)) return this.#p = n, n.toSorted((e, t) => e.serviceName.localeCompare(t.serviceName)).map((e) => yt(e, this.#t.t));
1376
+ let n = this.#m ?? await this.#e.listConnectorProviders(e, t);
1377
+ if (!(e.aborted || this.#h || t != this.#f.$.flowId.value)) return this.#m = n, n.toSorted((e, t) => e.serviceName.localeCompare(t.serviceName)).map((e) => Bt(e, this.#t.t));
1128
1378
  }, this.provideAddNodeOptionChoices = async (e, t) => {
1129
- if (this.#m) return;
1130
- let n = this.#d.$.flowId.value, r = this.#p?.find((t) => `connector-provider:${t.serviceId}` == e);
1379
+ if (this.#h) return;
1380
+ let n = this.#f.$.flowId.value, r = this.#m?.find((t) => `connector-provider:${t.serviceId}` == e);
1131
1381
  if (n == null || r == null) return;
1132
1382
  let i = this.#r.get(r.serviceId) ?? await this.#e.listConnectorActions(r.serviceId, t, n);
1133
- if (t.aborted || this.#m || n != this.#d.$.flowId.value) return;
1383
+ if (t.aborted || this.#h || n != this.#f.$.flowId.value) return;
1134
1384
  let a = i.map((e) => Object.assign({}, e, e.icon == null && r.icon != null ? { icon: r.icon } : {}, { serviceName: r.serviceName }));
1135
- return this.#r.set(r.serviceId, a), this.#y({ actions: {
1136
- ...this.#u.value.actions,
1385
+ return this.#r.set(r.serviceId, a), this.#b({ actions: {
1386
+ ...this.#d.value.actions,
1137
1387
  ...Object.fromEntries(a.map((e) => [e.actionId, e]))
1138
- } }), a.map((e) => G(e, this.#t.t));
1388
+ } }), a.map((e) => Q(e, this.#t.t));
1139
1389
  }, this.provideAddNodeOptions = async (e, t) => {
1140
- if (this.#m) return;
1141
- let n = this.#d.$.flowId.value;
1390
+ if (this.#h) return;
1391
+ let n = this.#f.$.flowId.value;
1142
1392
  if (n == null) return;
1143
- let r = e.trim(), i = r.length == 0 ? Object.values(this.#u.value.actions) : await this.#e.searchConnectorActions(r, t, n);
1144
- if (t.aborted || this.#m || n != this.#d.$.flowId.value) return;
1145
- let a = { ...this.#u.value.actions };
1393
+ let r = e.trim(), i = r.length == 0 ? Object.values(this.#d.value.actions) : await this.#e.searchConnectorActions(r, t, n);
1394
+ if (t.aborted || this.#h || n != this.#f.$.flowId.value) return;
1395
+ let a = { ...this.#d.value.actions };
1146
1396
  for (let e of i) a[e.actionId] = e;
1147
- if (this.#y({ actions: a }), r.length != 0) return i.map((e) => G(e, this.#t.t));
1397
+ if (this.#b({ actions: a }), r.length != 0) return i.map((e) => Q(e, this.#t.t));
1148
1398
  let o = new Map(i.map((e) => [e.actionId, e]));
1149
- for (let e of this.#d.$.revision.value?.connectorActionIds ?? []) {
1399
+ for (let e of this.#f.$.revision.value?.connectorActionIds ?? []) {
1150
1400
  let t = a[e];
1151
1401
  t != null && o.set(e, t);
1152
1402
  }
1153
- return vt([...o.values()], this.#t.t);
1154
- }, this.#e = r, this.#n = o, this.#d = i, this.#l = a, this.#t = s;
1155
- let c = e(this.#u, (e) => e.actions), l = e(this.#u, (e) => e.catalogs);
1156
- this.#c = n((e) => {
1157
- let t = bt(e(i.$.selection)), n = e(this.#u);
1403
+ return zt([...o.values()], this.#t.t);
1404
+ }, this.#e = r, this.#n = o, this.#f = i, this.#u = a, this.#t = s;
1405
+ let c = e(this.#d, (e) => e.actions), l = e(this.#d, (e) => e.catalogs);
1406
+ this.#l = n((e) => {
1407
+ let t = Vt(e(i.$.selection), e(i.$.revision)), n = e(this.#d);
1158
1408
  if (t == null) return { authorizationPending: !1 };
1159
1409
  let r = n.actions[t.actionId], a = r == null ? void 0 : n.catalogs[r.serviceId], o = t.connectionId == null ? void 0 : a?.byId.get(t.connectionId);
1160
1410
  return o == null && r?.defaultConnection?.connectionId == t.connectionId && (o = r.defaultConnection), {
@@ -1166,157 +1416,185 @@ var xt = class {
1166
1416
  connectionError: r != null && n.connectionError?.serviceId == r.serviceId ? n.connectionError.message : void 0
1167
1417
  };
1168
1418
  }), this.$ = {
1169
- actionLoading: e(this.#u, (e) => e.actionLoading),
1419
+ actionLoading: e(this.#d, (e) => e.actionLoading),
1170
1420
  actions: c,
1171
1421
  catalogs: l,
1172
- connectionLoading: e(this.#u, (e) => e.connectionLoading),
1173
- selectedAction: e(this.#c, (e) => e.action),
1174
- selectedActionError: e(this.#c, (e) => e.actionError),
1175
- selectedActiveConnections: e(this.#c, (e) => e.activeConnections),
1176
- selectedAuthorizationPending: e(this.#c, (e) => e.authorizationPending),
1177
- selectedConnection: e(this.#c, (e) => e.connection),
1178
- selectedConnectionError: e(this.#c, (e) => e.connectionError)
1179
- }, this.#o = i.$.flowId.reaction(() => this.reset()), this.#s = i.$.revision.reaction(() => void this.#x());
1422
+ connectionLoading: e(this.#d, (e) => e.connectionLoading),
1423
+ diagnostics: n((e) => Ht(e(i.$.revision), e(c), e(l))),
1424
+ selectedAction: e(this.#l, (e) => e.action),
1425
+ selectedActionError: e(this.#l, (e) => e.actionError),
1426
+ selectedActiveConnections: e(this.#l, (e) => e.activeConnections),
1427
+ selectedAuthorizationPending: e(this.#l, (e) => e.authorizationPending),
1428
+ selectedConnection: e(this.#l, (e) => e.connection),
1429
+ selectedConnectionError: e(this.#l, (e) => e.connectionError)
1430
+ }, this.#s = i.$.flowId.reaction(() => this.reset()), this.#c = i.$.revision.reaction(() => void this.#S());
1180
1431
  }
1181
1432
  dispose() {
1182
- this.#m = !0, this.#a.invalidate(), this.#o(), this.#s();
1433
+ this.#h = !0, this.#a.invalidate(), this.#o.invalidate(), this.#s(), this.#c();
1183
1434
  for (let e of Object.values(this.$)) e.dispose();
1184
- this.#c.dispose(), this.#u.dispose();
1435
+ this.#l.dispose(), this.#d.dispose();
1185
1436
  }
1186
1437
  reset() {
1187
- this.#m || (this.#a.invalidate(), this.#f = void 0, this.#r.clear(), this.#p = void 0, this.#i.clear(), this.#u.set(gt));
1438
+ this.#h || (this.#a.invalidate(), this.#o.invalidate(), this.#p = void 0, this.#r.clear(), this.#m = void 0, this.#i.clear(), this.#d.set(Lt));
1188
1439
  }
1189
1440
  async refresh(e = !1) {
1190
- if (this.#m) return;
1191
- let t = this.#a.begin(), n = this.#d.$.flowId.value, r = bt(this.#d.$.selection.value);
1441
+ if (this.#h) return;
1442
+ let t = this.#o.begin(), n = this.#f.$.flowId.value, r = Vt(this.#f.$.selection.value, this.#f.$.revision.value);
1192
1443
  if (n == null || r == null) {
1193
- (this.#u.value.actionLoading != null || this.#u.value.connectionLoading != null) && this.#y({
1444
+ (this.#d.value.actionLoading != null || this.#d.value.connectionLoading != null) && this.#b({
1194
1445
  actionLoading: void 0,
1195
1446
  connectionLoading: void 0
1196
1447
  });
1197
1448
  return;
1198
1449
  }
1199
- this.#y({
1450
+ this.#b({
1200
1451
  actionError: void 0,
1201
1452
  actionLoading: r.actionId,
1202
1453
  connectionError: void 0,
1203
1454
  connectionLoading: void 0
1204
1455
  });
1205
1456
  try {
1206
- let i = await this.#h(r.actionId, e);
1207
- if (!this.#b(t, n)) return;
1208
- this.#y({ actions: {
1209
- ...this.#u.value.actions,
1457
+ let i = await this.#g(r.actionId, e);
1458
+ if (!this.#x(t, n)) return;
1459
+ this.#b({ actions: {
1460
+ ...this.#d.value.actions,
1210
1461
  [i.actionId]: i
1211
- } }), await this.#g(n, r, i.serviceId, e, t);
1462
+ } }), i.authenticated && await this.#_(n, r, i.serviceId, e, t);
1212
1463
  } catch (e) {
1213
- this.#b(t, n) && this.#y({ actionError: {
1464
+ this.#x(t, n) && this.#b({ actionError: {
1214
1465
  actionId: r.actionId,
1215
- message: R(e, this.#t.t).message
1466
+ message: E(e, this.#t.t).message
1216
1467
  } });
1217
1468
  } finally {
1218
- this.#b(t, n) && this.#u.value.actionLoading == r.actionId && this.#y({ actionLoading: void 0 });
1469
+ this.#x(t, n) && this.#d.value.actionLoading == r.actionId && this.#b({ actionLoading: void 0 });
1219
1470
  }
1220
1471
  }
1472
+ async loadCodeConnections(e, t) {
1473
+ let n = this.#f.$.flowId.value;
1474
+ if (n == null || this.#h) return;
1475
+ let r = await this.#e.listConnectorConnections(e, t, n);
1476
+ t.aborted || this.#h || n != this.#f.$.flowId.value || this.#b({ catalogs: {
1477
+ ...this.#d.value.catalogs,
1478
+ [e]: d(r)
1479
+ } });
1480
+ }
1481
+ async loadCodeAction(e, t) {
1482
+ let n = this.#f.$.flowId.value;
1483
+ if (n == null || this.#h) return;
1484
+ let r = await this.#e.getConnectorAction(e, t, n);
1485
+ t.aborted || this.#h || n != this.#f.$.flowId.value || this.#b({ actions: {
1486
+ ...this.#d.value.actions,
1487
+ [e]: r
1488
+ } });
1489
+ }
1221
1490
  async connect(e) {
1222
- if (this.#m) return;
1223
- let t = this.#d.$.flowId.value;
1491
+ if (this.#h) return;
1492
+ let t = this.#f.$.flowId.value;
1224
1493
  if (t == null) return;
1225
- let n = this.#u.value.catalogs[e];
1494
+ let n = this.#d.value.catalogs[e];
1226
1495
  try {
1227
1496
  if (!await this.#n.openExternalPage(() => this.#e.createConnectorConnectionPage(e, t))) {
1228
- this.#l({
1497
+ this.#u({
1229
1498
  kind: "error",
1230
1499
  message: this.#t.t("notice.connectionPopupBlocked")
1231
1500
  });
1232
1501
  return;
1233
1502
  }
1234
- if (this.#m || t != this.#d.$.flowId.value) return;
1235
- this.#f = {
1503
+ if (this.#h || t != this.#f.$.flowId.value) return;
1504
+ this.#p = {
1236
1505
  connectionIds: new Set(n?.all.map((e) => e.connectionId)),
1237
1506
  serviceId: e
1238
- }, this.#y({ authorizationServiceId: e });
1507
+ }, this.#b({ authorizationServiceId: e });
1239
1508
  } catch (e) {
1240
- this.#m || this.#l(R(e, this.#t.t));
1509
+ this.#h || this.#u(E(e, this.#t.t));
1241
1510
  }
1242
1511
  }
1243
1512
  async setConnection(e, t) {
1244
- return await this.#d.setConnectorConnection(e, t);
1513
+ return await this.#f.setConnectorConnection(e, t);
1245
1514
  }
1246
1515
  async refreshAfterAuthorization() {
1247
- if (this.#m || this.#f == null) return;
1248
- let e = this.#f.serviceId;
1249
- this.#r.delete(e), this.#y({ authorizationServiceId: void 0 }), this.$.selectedAction.value?.serviceId == e && await this.refresh(!0), !this.#m && this.#f?.serviceId == e && (this.#f = void 0);
1516
+ if (this.#h || this.#p == null) return;
1517
+ let e = this.#p.serviceId;
1518
+ this.#r.delete(e), this.#b({ authorizationServiceId: void 0 }), this.$.selectedAction.value?.serviceId == e && await this.refresh(!0), !this.#h && this.#p?.serviceId == e && (this.#p = void 0);
1250
1519
  }
1251
- async #h(e, t) {
1252
- let n = this.#u.value.actions[e];
1253
- return !t && n != null ? n : await this.#e.getConnectorAction(e, void 0, this.#d.$.flowId.value);
1520
+ async #g(e, t) {
1521
+ let n = this.#d.value.actions[e];
1522
+ return !t && n != null ? n : await this.#e.getConnectorAction(e, void 0, this.#f.$.flowId.value);
1254
1523
  }
1255
- async #g(e, t, n, r, i) {
1256
- this.#y({ connectionLoading: n });
1524
+ async #_(e, t, n, r, i) {
1525
+ this.#b({ connectionLoading: n });
1257
1526
  try {
1258
- let a = await this.#_(e, n, r, i);
1259
- if (a == null || !this.#b(i, e)) return;
1260
- await this.#v(t, n, a);
1527
+ let a = await this.#v(e, n, r, i);
1528
+ if (a == null || !this.#x(i, e)) return;
1529
+ await this.#y(t, n, a);
1261
1530
  } finally {
1262
- this.#b(i, e) && this.#u.value.connectionLoading == n && this.#y({ connectionLoading: void 0 });
1531
+ this.#x(i, e) && this.#d.value.connectionLoading == n && this.#b({ connectionLoading: void 0 });
1263
1532
  }
1264
1533
  }
1265
- async #_(e, t, n, r) {
1266
- let i = this.#u.value.catalogs[t];
1534
+ async #v(e, t, n, r) {
1535
+ let i = this.#d.value.catalogs[t];
1267
1536
  if (!n && i != null) return i;
1268
1537
  let a;
1269
1538
  try {
1270
1539
  a = await this.#e.listConnectorConnections(t, void 0, e);
1271
1540
  } catch (n) {
1272
- this.#b(r, e) && this.#y({ connectionError: {
1273
- message: R(n, this.#t.t).message,
1541
+ this.#x(r, e) && this.#b({ connectionError: {
1542
+ message: E(n, this.#t.t).message,
1274
1543
  serviceId: t
1275
1544
  } });
1276
1545
  return;
1277
1546
  }
1278
- if (!this.#b(r, e)) return;
1279
- let o = w(a);
1280
- return this.#y({ catalogs: {
1281
- ...this.#u.value.catalogs,
1547
+ if (!this.#x(r, e)) return;
1548
+ let o = d(a);
1549
+ return this.#b({ catalogs: {
1550
+ ...this.#d.value.catalogs,
1282
1551
  [t]: o
1283
1552
  } }), o;
1284
1553
  }
1285
- async #v(e, t, n) {
1286
- let r = this.#f?.serviceId == t ? this.#f : void 0, i = r == null ? [] : n.active.filter((e) => !r.connectionIds.has(e.connectionId)), a = i.length == 1 ? i[0] : n.preferred, o = this.#d.$.revision.value?.task(e.taskId);
1287
- a != null && this.#d.$.selectedNodeIds.value.includes(e.nodeId) && o != null && "executor" in o && o.executor.kind == "connector" && o.executor.connectionId == null && await this.#d.setConnectorConnection(e.taskId, a.connectionId);
1554
+ async #y(e, t, n) {
1555
+ let r = this.#p?.serviceId == t ? this.#p : void 0, i = r == null ? [] : n.active.filter((e) => !r.connectionIds.has(e.connectionId)), a = i.length == 1 ? i[0] : n.preferred, o = this.#f.$.revision.value?.task(e.taskId);
1556
+ a != null && this.#f.$.selectedNodeIds.value.includes(e.nodeId) && o != null && "executor" in o && o.executor.kind == "connector" && o.executor.connectionId == null && await this.#f.setConnectorConnection(e.taskId, a.connectionId);
1288
1557
  }
1289
- #y(e) {
1290
- this.#m || this.#u.set({
1291
- ...this.#u.value,
1558
+ #b(e) {
1559
+ this.#h || this.#d.set({
1560
+ ...this.#d.value,
1292
1561
  ...e
1293
1562
  });
1294
1563
  }
1295
- #b(e, t) {
1296
- return !this.#m && e() && t == this.#d.$.flowId.value;
1564
+ #x(e, t) {
1565
+ return !this.#h && e() && t == this.#f.$.flowId.value;
1297
1566
  }
1298
- async #x() {
1299
- if (this.#m) return;
1300
- let e = this.#a.capture(), t = this.#d.$.flowId.value, n = this.#d.$.revision.value;
1567
+ async #S() {
1568
+ if (this.#h) return;
1569
+ let e = this.#a.begin(), t = this.#f.$.flowId.value, n = this.#f.$.revision.value;
1301
1570
  if (t == null || n == null) return;
1302
- let r = [...n.connectorActionIds].filter((e) => this.#u.value.actions[e] == null && !this.#i.has(e));
1303
- if (r.length != 0) {
1571
+ let r = [...n.connectorActionIds].filter((e) => this.#d.value.actions[e] == null && !this.#i.has(e));
1572
+ if (r.length > 0) {
1304
1573
  for (let e of r) this.#i.add(e);
1305
1574
  try {
1306
1575
  let n = await Promise.all(r.map((e) => this.#e.getConnectorAction(e, void 0, t)));
1307
- if (!this.#b(e, t)) return;
1308
- let i = { ...this.#u.value.actions };
1576
+ if (!this.#x(e, t)) return;
1577
+ let i = { ...this.#d.value.actions };
1309
1578
  for (let e of n) i[e.actionId] = e;
1310
- this.#y({ actions: i });
1579
+ this.#b({ actions: i });
1311
1580
  } catch {
1312
1581
  return;
1313
1582
  } finally {
1314
1583
  for (let e of r) this.#i.delete(e);
1315
1584
  }
1316
1585
  }
1586
+ if (!this.#x(e, t)) return;
1587
+ let i = /* @__PURE__ */ new Set();
1588
+ for (let e of je(n.revision.content).tasks) {
1589
+ let t = n.task(e);
1590
+ if (t?.executor.kind != "connector") continue;
1591
+ let r = this.#d.value.actions[t.executor.action];
1592
+ r?.authenticated == 1 && i.add(r.serviceId);
1593
+ }
1594
+ await Promise.all([...i].map((n) => this.#v(t, n, !1, e)));
1317
1595
  }
1318
- }, St = { catalogs: {} }, Ct = 4, K = "trigger:";
1319
- function q(e, t) {
1596
+ }, Wt = { catalogs: {} }, Gt = "trigger:";
1597
+ function Kt(e, t) {
1320
1598
  if (e?.kind != "trigger") return;
1321
1599
  let n = e.trigger;
1322
1600
  if (n.kind != "poll" && n.kind != "integration") return;
@@ -1327,11 +1605,15 @@ function q(e, t) {
1327
1605
  triggerId: e.id
1328
1606
  };
1329
1607
  }
1330
- function J(e, t, n, r) {
1608
+ function qt(e, t) {
1331
1609
  return {
1332
- description: n,
1333
- group: r,
1334
- id: `trigger:${e.key}:${t}`,
1610
+ description: t.t("addNode.triggerNeedsConnection", { provider: e.provider }),
1611
+ group: t.t("addNode.integrationTriggers"),
1612
+ icon: p({
1613
+ serviceId: e.provider,
1614
+ serviceName: e.provider
1615
+ }),
1616
+ id: `${Gt}${e.key}`,
1335
1617
  inputs: [],
1336
1618
  kind: "trigger",
1337
1619
  label: e.displayName,
@@ -1340,59 +1622,12 @@ function J(e, t, n, r) {
1340
1622
  jsonSchema: e.payloadSchema
1341
1623
  }],
1342
1624
  trigger: {
1343
- connectionId: t,
1344
1625
  definition: e,
1345
1626
  kind: "catalog"
1346
1627
  }
1347
1628
  };
1348
1629
  }
1349
- function wt(e, t) {
1350
- return {
1351
- choices: [],
1352
- description: t.t("addNode.triggerChooseConnection"),
1353
- group: t.t("addNode.triggers"),
1354
- id: `${K}${e.key}`,
1355
- inputs: [],
1356
- kind: "trigger",
1357
- label: e.displayName,
1358
- outputs: []
1359
- };
1360
- }
1361
- function Tt(e, t, n) {
1362
- let r = n.t("addNode.triggers"), i = t.preferred;
1363
- return i == null ? t.active.length > 0 ? t.active.map((t) => J(e, t.connectionId, t.displayName, r)) : [{
1364
- description: n.t("addNode.triggerNeedsConnection", { provider: e.provider }),
1365
- group: r,
1366
- id: `${K}${e.key}:connect`,
1367
- inputs: [],
1368
- kind: "trigger",
1369
- label: n.t("addNode.triggerAddConnection"),
1370
- outputs: [],
1371
- trigger: {
1372
- kind: "connect",
1373
- provider: e.provider
1374
- }
1375
- }] : [J(e, i.connectionId, i.displayName, r)];
1376
- }
1377
- function Et(e, t, n) {
1378
- let r = t.preferred;
1379
- if (r != null) return J(e, r.connectionId, r.displayName, n.t("addNode.triggers"));
1380
- let i = wt(e, n), a = Tt(e, t, n);
1381
- return {
1382
- ...i,
1383
- description: t.active.length == 0 ? n.t("addNode.triggerNeedsConnection", { provider: e.provider }) : i.description,
1384
- outputs: t.active.length == 0 ? [] : [{
1385
- handle: "payload",
1386
- jsonSchema: e.payloadSchema
1387
- }],
1388
- choices: a.map((n) => ({
1389
- description: t.active.length == 0 ? e.provider : void 0,
1390
- label: n.label,
1391
- option: n
1392
- }))
1393
- };
1394
- }
1395
- var Dt = class {
1630
+ var Jt = class {
1396
1631
  #e;
1397
1632
  #t;
1398
1633
  #n;
@@ -1404,52 +1639,29 @@ var Dt = class {
1404
1639
  #c;
1405
1640
  #l;
1406
1641
  #u;
1407
- constructor(r, i, a, o, s = E()) {
1408
- this.#t = new AbortController(), this.#a = new x(), this.#c = t(St), this.#u = !1, this.browseAddNodeOptions = async (e) => {
1409
- let t = this.#l.$.flowId.value;
1410
- if (e.aborted || this.#u || t == null || this.#l.$.target.value?.kind != "flow") return [];
1411
- let n = await this.#d();
1412
- if (!(e.aborted || this.#u || t != this.#l.$.flowId.value)) return [...n.values()].map((e) => wt(e, this.#i));
1642
+ #d;
1643
+ constructor(r, i, a, o, s = P()) {
1644
+ this.#t = new AbortController(), this.#a = new m(), this.#o = /* @__PURE__ */ new Set(), this.#l = t(Wt), this.#d = !1, this.browseAddNodeOptions = async (e) => {
1645
+ let t = this.#u.$.flowId.value;
1646
+ if (e.aborted || this.#d || t == null || this.#u.$.target.value?.kind != "flow") return [];
1647
+ let n = await this.#f();
1648
+ if (!(e.aborted || this.#d || t != this.#u.$.flowId.value)) return [...n.values()].map((e) => qt(e, this.#i));
1413
1649
  }, this.provideAddNodeOptions = async (e, t) => {
1414
- let n = this.#l.$.flowId.value;
1415
- if (t.aborted || this.#u || n == null || this.#l.$.target.value?.kind != "flow") return [];
1650
+ let n = this.#u.$.flowId.value;
1651
+ if (t.aborted || this.#d || n == null || this.#u.$.target.value?.kind != "flow") return [];
1416
1652
  let r = e.trim().toLowerCase();
1417
1653
  if (r.length == 0) return [];
1418
- let i = await this.#d();
1419
- if (t.aborted || this.#u || n != this.#l.$.flowId.value) return;
1420
- let a = [...i.values()].filter((e) => [
1654
+ let i = await this.#f();
1655
+ if (!(t.aborted || this.#d || n != this.#u.$.flowId.value)) return [...i.values()].filter((e) => [
1421
1656
  e.description,
1422
1657
  e.displayName,
1423
1658
  e.key,
1424
1659
  e.name,
1425
1660
  e.provider,
1426
1661
  e.type
1427
- ].some((e) => e.toLowerCase().includes(r))), o = [...new Set(a.map((e) => e.provider))].filter((e) => this.#c.value.catalogs[e] == null);
1428
- for (let e = 0; e < o.length; e += Ct) {
1429
- let r = await Promise.all(o.slice(e, e + Ct).map(async (e) => [e, w(await this.#n.listConnectorConnections(e, t, n))]));
1430
- if (t.aborted || this.#u || n != this.#l.$.flowId.value) return;
1431
- this.#f({ catalogs: {
1432
- ...this.#c.value.catalogs,
1433
- ...Object.fromEntries(r)
1434
- } });
1435
- }
1436
- return a.map((e) => Et(e, this.#c.value.catalogs[e.provider], this.#i));
1437
- }, this.provideAddNodeOptionChoices = async (e, t) => {
1438
- let n = this.#l.$.flowId.value, r = e.startsWith(K) ? e.slice(8) : void 0;
1439
- if (t.aborted || this.#u || n == null || r == null || this.#l.$.target.value?.kind != "flow") return;
1440
- let i = (await this.#d()).get(r);
1441
- if (t.aborted || this.#u || n != this.#l.$.flowId.value || i == null) return;
1442
- let a = this.#c.value.catalogs[i.provider];
1443
- if (a == null) {
1444
- if (a = w(await this.#n.listConnectorConnections(i.provider, t, n)), t.aborted || this.#u || n != this.#l.$.flowId.value) return;
1445
- this.#f({ catalogs: {
1446
- ...this.#c.value.catalogs,
1447
- [i.provider]: a
1448
- } });
1449
- }
1450
- return Tt(i, a, this.#i);
1451
- }, this.#n = r, this.#r = o, this.#i = s, this.#s = a, this.#l = i, this.#o = n((e) => {
1452
- let t = e(i.$.selection), n = q(t, i), r = e(this.#c);
1662
+ ].some((e) => e.toLowerCase().includes(r))).map((e) => qt(e, this.#i));
1663
+ }, this.#n = r, this.#r = o, this.#i = s, this.#c = a, this.#u = i, this.#s = n((e) => {
1664
+ let t = e(i.$.selection), n = Kt(t, i), r = e(this.#l);
1453
1665
  if (t?.kind != "trigger") return { authorizationPending: !1 };
1454
1666
  let a = t.trigger;
1455
1667
  if (a.kind != "poll" && a.kind != "integration") return { authorizationPending: !1 };
@@ -1462,140 +1674,116 @@ var Dt = class {
1462
1674
  definition: a.definition
1463
1675
  };
1464
1676
  }), this.$ = {
1465
- connectionLoading: e(this.#c, (e) => e.connectionLoading),
1466
- selectedActiveConnections: e(this.#o, (e) => e.activeConnections),
1467
- selectedAuthorizationPending: e(this.#o, (e) => e.authorizationPending),
1468
- selectedConnection: e(this.#o, (e) => e.connection),
1469
- selectedConnectionError: e(this.#o, (e) => e.connectionError),
1470
- selectedDefinition: e(this.#o, (e) => e.definition)
1677
+ connectionLoading: e(this.#l, (e) => e.connectionLoading),
1678
+ selectedActiveConnections: e(this.#s, (e) => e.activeConnections),
1679
+ selectedAuthorizationPending: e(this.#s, (e) => e.authorizationPending),
1680
+ selectedConnection: e(this.#s, (e) => e.connection),
1681
+ selectedConnectionError: e(this.#s, (e) => e.connectionError),
1682
+ selectedDefinition: e(this.#s, (e) => e.definition)
1471
1683
  };
1472
1684
  }
1473
1685
  dispose() {
1474
- this.#u = !0, this.#t.abort(), this.#a.invalidate();
1686
+ this.#d = !0, this.#t.abort(), this.#a.invalidate();
1475
1687
  for (let e of Object.values(this.$)) e.dispose();
1476
- this.#o.dispose(), this.#c.dispose();
1688
+ this.#s.dispose(), this.#l.dispose();
1477
1689
  }
1478
1690
  reset() {
1479
- this.#u || (this.#t.abort(), this.#t = new AbortController(), this.#e = void 0, this.#a.invalidate(), this.#c.set(St));
1691
+ this.#d || (this.#t.abort(), this.#t = new AbortController(), this.#e = void 0, this.#o.clear(), this.#a.invalidate(), this.#l.set(Wt));
1480
1692
  }
1481
1693
  async refresh(e = !1) {
1482
- let t = this.#a.begin(), n = this.#l.$.flowId.value, r = q(this.#l.$.selection.value, this.#l);
1483
- if (!this.#u) {
1484
- if (n == null || r == null) {
1485
- this.#c.value.connectionLoading != null && this.#f({ connectionLoading: void 0 });
1486
- return;
1487
- }
1488
- if (!(!e && this.#c.value.catalogs[r.provider] != null)) {
1489
- this.#f({
1490
- connectionError: void 0,
1491
- connectionLoading: r.provider
1492
- });
1493
- try {
1494
- let e = w(await this.#n.listConnectorConnections(r.provider, void 0, n));
1495
- if (!this.#p(t, n)) return;
1496
- this.#f({ catalogs: {
1497
- ...this.#c.value.catalogs,
1498
- [r.provider]: e
1499
- } });
1500
- } catch (e) {
1501
- this.#p(t, n) && this.#f({ connectionError: {
1502
- message: R(e, this.#i.t).message,
1503
- provider: r.provider
1504
- } });
1505
- } finally {
1506
- this.#p(t, n) && this.#c.value.connectionLoading == r.provider && this.#f({ connectionLoading: void 0 });
1507
- }
1508
- }
1694
+ if (this.#d) return;
1695
+ let t = this.#a.begin(), n = this.#u.$.flowId.value, r = Kt(this.#u.$.selection.value, this.#u);
1696
+ if (n == null || r == null) {
1697
+ this.#l.value.connectionLoading != null && this.#p({ connectionLoading: void 0 });
1698
+ return;
1699
+ }
1700
+ if (!e && !this.#o.has(r.provider) && this.#l.value.catalogs[r.provider] != null) {
1701
+ this.#l.value.connectionLoading != null && this.#p({ connectionLoading: void 0 });
1702
+ return;
1703
+ }
1704
+ this.#p({
1705
+ connectionError: void 0,
1706
+ connectionLoading: r.provider
1707
+ });
1708
+ try {
1709
+ let e = d(await this.#n.listConnectorConnections(r.provider, void 0, n));
1710
+ if (!this.#m(t, n)) return;
1711
+ this.#o.delete(r.provider), this.#p({ catalogs: {
1712
+ ...this.#l.value.catalogs,
1713
+ [r.provider]: e
1714
+ } });
1715
+ } catch (e) {
1716
+ this.#m(t, n) && this.#p({ connectionError: {
1717
+ message: E(e, this.#i.t).message,
1718
+ provider: r.provider
1719
+ } });
1720
+ } finally {
1721
+ this.#m(t, n) && this.#l.value.connectionLoading == r.provider && this.#p({ connectionLoading: void 0 });
1509
1722
  }
1510
1723
  }
1511
1724
  async connect(e) {
1512
- let t = this.#l.$.flowId.value;
1513
- if (!(this.#u || t == null)) try {
1725
+ let t = this.#u.$.flowId.value;
1726
+ if (!(this.#d || t == null)) try {
1514
1727
  if (!await this.#r.openExternalPage(() => this.#n.createConnectorConnectionPage(e, t))) {
1515
- this.#s({
1728
+ this.#c({
1516
1729
  kind: "error",
1517
1730
  message: this.#i.t("notice.connectionPopupBlocked")
1518
1731
  });
1519
1732
  return;
1520
1733
  }
1521
- !this.#u && t == this.#l.$.flowId.value && this.#f({ authorizationProvider: e });
1734
+ !this.#d && t == this.#u.$.flowId.value && this.#p({ authorizationProvider: e });
1522
1735
  } catch (e) {
1523
- this.#u || this.#s(R(e, this.#i.t));
1736
+ this.#d || this.#c(E(e, this.#i.t));
1524
1737
  }
1525
1738
  }
1526
1739
  async setConnection(e, t) {
1527
- return await this.#l.setTriggerConnection(e, t);
1528
- }
1529
- async saveSettings(e, t) {
1530
- return await this.#l.saveTriggerSettings(e, t);
1740
+ return await this.#u.setTriggerConnection(e, t);
1531
1741
  }
1532
1742
  async refreshAfterAuthorization() {
1533
- let e = this.#c.value.authorizationProvider;
1534
- if (this.#u || e == null) return;
1535
- let t = { ...this.#c.value.catalogs };
1536
- delete t[e], this.#f({
1537
- authorizationProvider: void 0,
1538
- catalogs: t
1539
- }), q(this.#l.$.selection.value, this.#l)?.provider == e && await this.refresh(!0);
1540
- }
1541
- #d() {
1743
+ if (this.#d) return;
1744
+ let e = this.#l.value.authorizationProvider;
1745
+ e != null && (this.#o.add(e), this.#p({ authorizationProvider: void 0 }), Kt(this.#u.$.selection.value, this.#u)?.provider == e && await this.refresh(!0));
1746
+ }
1747
+ #f() {
1542
1748
  if (this.#e != null) return this.#e;
1543
1749
  let e = this.#n.listTriggerDefinitions(this.#t.signal).then((e) => new Map(e.map((e) => [e.key, e])));
1544
1750
  return this.#e = e, e.catch(() => {
1545
1751
  this.#e == e && (this.#e = void 0);
1546
1752
  }), e;
1547
1753
  }
1548
- #f(e) {
1549
- this.#u || this.#c.set({
1550
- ...this.#c.value,
1754
+ #p(e) {
1755
+ this.#d || this.#l.set({
1756
+ ...this.#l.value,
1551
1757
  ...e
1552
1758
  });
1553
1759
  }
1554
- #p(e, t) {
1555
- return !this.#u && e() && t == this.#l.$.flowId.value;
1760
+ #m(e, t) {
1761
+ return !this.#d && e() && t == this.#u.$.flowId.value;
1556
1762
  }
1557
1763
  };
1558
1764
  //#endregion
1559
- //#region src/workbench/browser/runtime/designer/remoteChangeTargets.ts
1560
- function Ot(e, t) {
1561
- return e.kind == t.kind && (e.kind != "subflow" || t.kind == "subflow" && e.id == t.id);
1562
- }
1563
- function Y(e, t, n, r) {
1564
- for (let [i, a] of Object.entries(t.graph(n)?.nodes ?? {})) r(a) && e.add(i);
1565
- }
1566
- function kt(e, t, n, r) {
1567
- let i = /* @__PURE__ */ new Set();
1568
- for (let a of r) switch (a.kind) {
1569
- case "graph.node.create":
1570
- case "graph.node.replace":
1571
- Ot(a.target, n) && i.add(a.nodeId);
1572
- break;
1573
- case "task.replace":
1574
- Y(i, e, n, (e) => e.kind == "task" && e.task == null && e.taskId == a.taskId), Y(i, t, n, (e) => e.kind == "task" && e.task == null && e.taskId == a.taskId);
1575
- break;
1576
- case "module.source.replace":
1577
- Y(i, e, n, (e) => e.kind == "task" && e.task?.moduleId == a.moduleId), Y(i, t, n, (e) => e.kind == "task" && e.task?.moduleId == a.moduleId);
1578
- break;
1579
- case "subflow.definition.replace": Y(i, e, n, (e) => e.kind == "subflow" && e.subflowId == a.subflowId), Y(i, t, n, (e) => e.kind == "subflow" && e.subflowId == a.subflowId);
1580
- }
1581
- return new Set([...i].filter((e) => t.selection(n, e) != null));
1582
- }
1583
- //#endregion
1584
1765
  //#region src/workbench/browser/runtime/stores/draftChanges.ts
1585
- function At(e) {
1586
- if (e.length != 1) return;
1587
- let t = e[0];
1588
- switch (t.kind) {
1589
- case "binding.replace": return `${t.kind}:${t.bindingId}`;
1590
- case "graph.node.replace": return `${t.kind}:${t.target.kind}:${t.target.kind == "subflow" ? t.target.id : ""}:${t.nodeId}`;
1591
- case "module.rename":
1592
- case "module.source.replace": return `${t.kind}:${t.moduleId}`;
1593
- case "subflow.definition.replace": return `${t.kind}:${t.subflowId}`;
1594
- case "task.replace": return `${t.kind}:${t.taskId}`;
1595
- default: return;
1596
- }
1766
+ function Yt(e, t) {
1767
+ if (e.length != 1 || t.length != 1) return;
1768
+ let n = e[0], r = t[0];
1769
+ if (n?.kind == "graph.node.field.set" && r?.kind == "graph.node.field.set") return n.nodeId != r.nodeId || n.field != r.field || n.target.kind != r.target.kind || n.target.kind == "subflow" && (r.target.kind != "subflow" || n.target.id != r.target.id) ? void 0 : [{
1770
+ before: n.before,
1771
+ field: r.field,
1772
+ kind: r.kind,
1773
+ nodeId: r.nodeId,
1774
+ target: r.target,
1775
+ value: r.value
1776
+ }];
1777
+ if (n?.kind == "graph.node.input.set" && r?.kind == "graph.node.input.set") return n.nodeId != r.nodeId || n.handle != r.handle || n.target.kind != r.target.kind || n.target.kind == "subflow" && (r.target.kind != "subflow" || n.target.id != r.target.id) ? void 0 : [{
1778
+ before: n.before,
1779
+ handle: r.handle,
1780
+ kind: r.kind,
1781
+ nodeId: r.nodeId,
1782
+ target: r.target,
1783
+ value: r.value
1784
+ }];
1597
1785
  }
1598
- var jt = class {
1786
+ var Xt = class {
1599
1787
  #e;
1600
1788
  #t;
1601
1789
  #n;
@@ -1621,54 +1809,70 @@ var jt = class {
1621
1809
  }
1622
1810
  replaceCommitted(e) {
1623
1811
  this.#a = e;
1812
+ let t = e, n = [];
1813
+ for (let e of this.#o) try {
1814
+ t = R(t, e.changes), n.push(e);
1815
+ } catch (t) {
1816
+ if (!(t instanceof Le)) throw t;
1817
+ e.active = !1;
1818
+ }
1819
+ return this.#o = n, t;
1624
1820
  }
1625
1821
  project(e) {
1626
- return this.#o.reduce((e, t) => F(e, t.changes), e);
1822
+ return this.#o.reduce((e, t) => R(e, t.changes), e);
1627
1823
  }
1628
1824
  enqueue(e) {
1629
1825
  let t = this.#s.then(e);
1630
1826
  return this.#s = t, t;
1631
1827
  }
1632
1828
  async change(e, t, n, r = !0) {
1633
- this.#t.beforeChange(r), this.#t.apply(F(t, n));
1634
- let i = At(n), a = this.#o.at(-1), o = i != null && a != null && !a.started && At(a.changes) == i ? a : void 0;
1635
- if (o != null) return o.changes = n, await o.result;
1636
- let s = {
1829
+ let i = this.#o.at(-1), a = i == null || i.started || !i.active ? void 0 : Yt(i.changes, n);
1830
+ if (i != null && a != null) return i.changes = a, this.#a != null && this.#t.apply(this.project(this.#a)), i.result;
1831
+ this.#t.beforeChange(r);
1832
+ let o = {
1637
1833
  ...e,
1834
+ active: !0,
1835
+ changeId: F(),
1638
1836
  changes: n,
1639
1837
  started: !1
1640
1838
  };
1641
- this.#a ??= t, this.#o.push(s), this.#i += 1;
1642
- let c = this.#s.then(() => (s.started = !0, this.#c(s)));
1643
- s.result = c, this.#s = c.then(() => void 0);
1839
+ this.#a ??= t, this.#o.push(o), this.#t.apply(this.project(this.#a)), this.#i += 1;
1840
+ let s = this.#s.then(() => (o.started = !0, this.#c(o)));
1841
+ o.result = s, this.#s = s.then(() => void 0);
1644
1842
  try {
1645
- return await c;
1843
+ return await s;
1646
1844
  } finally {
1647
1845
  --this.#i, this.#i == 0 && this.#t.finishChanges();
1648
1846
  }
1649
1847
  }
1650
1848
  async #c(e) {
1651
1849
  let t = !1;
1652
- for (; this.#t.current(e);) {
1850
+ for (; e.active && this.#t.current(e);) {
1653
1851
  let n = this.#a;
1654
1852
  if (n == null) return;
1655
1853
  try {
1656
- let t = await this.#e.changeDraft(e.flowId, n.revisionId, e.changes);
1854
+ let t = await this.#e.changeDraft(e.flowId, n.revisionId, e.changes, e.changeId);
1657
1855
  if (!this.#t.current(e)) return;
1658
1856
  if (t.revision.parentRevisionId != n.revisionId) throw Error("Invalid Draft change response.");
1659
1857
  let r = this.#l(e, n, t);
1660
1858
  return this.#o.length == 0 && this.#t.check(), r;
1661
1859
  } catch (n) {
1662
- if (n instanceof P && n.code == "flow.revision-conflict") {
1860
+ if (n instanceof L && n.code == "flow.revision-conflict") {
1663
1861
  if (!t && await this.#t.recover(e)) {
1664
- t = !0;
1862
+ t = !0, e.changeId = F();
1665
1863
  continue;
1666
1864
  }
1667
- t && await this.#t.recover(e), this.#u(e), this.#t.current(e) && this.#r({
1668
- kind: "error",
1669
- message: this.#n.t("notice.draftConflict")
1670
- });
1671
- } else this.#u(e), this.#t.current(e) && this.#r(R(n, this.#n.t));
1865
+ t && await this.#t.recover(e), this.#u(e);
1866
+ } else {
1867
+ if (!(n instanceof L) && !t) {
1868
+ let n = this.#a?.revisionId;
1869
+ if (await this.#t.recover(e)) {
1870
+ t = !0, e.active && this.#a?.revisionId != n && (e.changeId = F());
1871
+ continue;
1872
+ }
1873
+ }
1874
+ this.#u(e), this.#t.current(e) && this.#r(E(n, this.#n.t));
1875
+ }
1672
1876
  return;
1673
1877
  }
1674
1878
  }
@@ -1676,35 +1880,39 @@ var jt = class {
1676
1880
  #l(e, t, n) {
1677
1881
  let r = {
1678
1882
  ...n.revision,
1679
- content: F(t, e.changes).content
1883
+ content: R(t, e.changes).content
1680
1884
  };
1681
1885
  this.#o = this.#o.filter((t) => t !== e), this.#a = r;
1682
1886
  let i = this.#t.diagnostics(), a = this.#o.length == 0 && i?.revisionId == r.revisionId;
1683
1887
  return this.#t.apply(this.project(r), a), this.#t.headChanged(e.flowId, r.revisionId), r;
1684
1888
  }
1685
1889
  #u(e) {
1686
- this.#o = this.#o.filter((t) => t !== e), !(!this.#t.current(e) || this.#a == null) && this.#t.apply(this.project(this.#a));
1890
+ e.active = !1, this.#o = this.#o.filter((t) => t !== e), !(!this.#t.current(e) || this.#a == null) && this.#t.apply(this.project(this.#a));
1687
1891
  }
1688
- }, X = 50, Mt = {
1892
+ }, Zt = 50, Qt = {
1689
1893
  failed: !1,
1690
1894
  loaded: !1,
1691
1895
  loading: !0,
1692
1896
  loadingMore: !1,
1693
1897
  loadMoreFailed: !1,
1898
+ refreshing: !1,
1694
1899
  flows: []
1695
- }, Nt = class {
1900
+ }, $t = class {
1696
1901
  #e;
1697
1902
  #t;
1698
- #n = new x();
1903
+ #n = new m();
1699
1904
  #r;
1700
- #i = t(Mt);
1701
- #a = !1;
1905
+ #i = t(Qt);
1906
+ #a = new AbortController();
1907
+ #o = /* @__PURE__ */ new Set();
1908
+ #s = !1;
1702
1909
  constructor(t, n, r) {
1703
1910
  this.#e = t, this.#t = r, this.#r = n, this.$ = {
1704
1911
  failed: e(this.#i, (e) => e.failed),
1705
1912
  loading: e(this.#i, (e) => e.loading),
1706
1913
  loadingMore: e(this.#i, (e) => e.loadingMore),
1707
1914
  loadMoreFailed: e(this.#i, (e) => e.loadMoreFailed),
1915
+ refreshing: e(this.#i, (e) => e.refreshing),
1708
1916
  nextCursor: e(this.#i, (e) => e.nextCursor),
1709
1917
  flows: e(this.#i, (e) => e.flows),
1710
1918
  total: e(this.#i, (e) => e.total)
@@ -1714,24 +1922,26 @@ var jt = class {
1714
1922
  return this.#i.value.loaded;
1715
1923
  }
1716
1924
  dispose() {
1717
- this.#a = !0, this.#n.invalidate();
1925
+ this.#s = !0, this.#a.abort(), this.#n.invalidate();
1718
1926
  for (let e of Object.values(this.$)) e.dispose();
1719
1927
  this.#i.dispose();
1720
1928
  }
1721
- capture() {
1722
- return this.#n.capture();
1723
- }
1724
1929
  flow(e) {
1725
1930
  return this.#i.value.flows.find((t) => t.flowId == e);
1726
1931
  }
1727
1932
  async reload() {
1728
- let e = this.#n.begin();
1729
- this.#o({
1933
+ let e = this.#n.begin(), t = this.#i.value.loaded;
1934
+ t ? this.#c({
1935
+ failed: !1,
1936
+ loadingMore: !1,
1937
+ loadMoreFailed: !1,
1938
+ refreshing: !0
1939
+ }) : this.#c({
1730
1940
  failed: !1,
1731
- loaded: !1,
1732
1941
  loading: !0,
1733
1942
  loadingMore: !1,
1734
1943
  loadMoreFailed: !1,
1944
+ refreshing: !1,
1735
1945
  nextCursor: void 0,
1736
1946
  flows: [],
1737
1947
  total: void 0
@@ -1739,92 +1949,130 @@ var jt = class {
1739
1949
  try {
1740
1950
  let t = await this.#e.listFlows({
1741
1951
  includeTotal: !0,
1742
- limit: X
1952
+ limit: Zt
1743
1953
  });
1744
1954
  if (!e()) return;
1745
- this.#o({
1955
+ this.#c({
1746
1956
  loaded: !0,
1747
1957
  loading: !1,
1958
+ refreshing: !1,
1748
1959
  nextCursor: t.nextCursor,
1749
1960
  flows: t.flows,
1750
1961
  total: t.total
1751
1962
  });
1752
- } catch (t) {
1963
+ } catch (n) {
1753
1964
  if (!e()) return;
1754
- this.#o({
1755
- failed: !0,
1756
- loading: !1
1757
- }), this.#r(R(t, this.#t.t));
1965
+ this.#c({
1966
+ failed: !t,
1967
+ loading: !1,
1968
+ refreshing: !1
1969
+ }), this.#r(E(n, this.#t.t));
1758
1970
  }
1759
1971
  }
1760
1972
  async loadMore() {
1761
- let { loadingMore: e, nextCursor: t } = this.#i.value;
1762
- if (e || t == null) return;
1763
- let n = this.#n.capture();
1764
- this.#o({
1973
+ let { loadingMore: e, nextCursor: t, refreshing: n } = this.#i.value;
1974
+ if (e || n || t == null) return;
1975
+ let r = this.#n.capture();
1976
+ this.#c({
1765
1977
  loadingMore: !0,
1766
1978
  loadMoreFailed: !1
1767
1979
  });
1768
1980
  try {
1769
1981
  let e = await this.#e.listFlows({
1770
1982
  cursor: t,
1771
- limit: X
1983
+ limit: Zt
1772
1984
  });
1773
- if (!n()) return;
1774
- let r = new Set(this.#i.value.flows.map((e) => e.flowId));
1775
- this.#o({
1985
+ if (!r()) return;
1986
+ let n = new Set(this.#i.value.flows.map((e) => e.flowId));
1987
+ this.#c({
1776
1988
  loadingMore: !1,
1777
1989
  nextCursor: e.nextCursor,
1778
- flows: [...this.#i.value.flows, ...e.flows.filter((e) => !r.has(e.flowId))]
1990
+ flows: [...this.#i.value.flows, ...e.flows.filter((e) => !n.has(e.flowId))]
1779
1991
  });
1780
1992
  } catch (e) {
1781
- if (!n()) return;
1782
- this.#o({
1993
+ if (!r()) return;
1994
+ this.#c({
1783
1995
  loadingMore: !1,
1784
1996
  loadMoreFailed: !0
1785
- }), this.#r(R(e, this.#t.t));
1997
+ }), this.#r(E(e, this.#t.t));
1998
+ }
1999
+ }
2000
+ async setEnabled(e, t) {
2001
+ if (!(e.live == null || this.#o.has(e.flowId))) {
2002
+ this.#o.add(e.flowId);
2003
+ try {
2004
+ let n = await this.#e.setFlowEnabled(e.flowId, e.live.publicationId, t);
2005
+ this.#s || this.include(n);
2006
+ } catch (e) {
2007
+ this.#s || (this.#r(E(e, this.#t.t)), await this.reload());
2008
+ } finally {
2009
+ this.#o.delete(e.flowId);
2010
+ }
2011
+ }
2012
+ }
2013
+ async publish(e) {
2014
+ if (!this.#o.has(e.flowId)) {
2015
+ this.#o.add(e.flowId);
2016
+ try {
2017
+ let t = await this.#e.publishFlow(e.flowId, e.draftRevisionId, e.live?.publicationId ?? null);
2018
+ if (this.#s) return;
2019
+ let n = await Y.runPromise(Y.gen({ self: this }, function* () {
2020
+ let n = t;
2021
+ for (; n.status == "pending";) yield* Y.sleep(1e3), n = yield* Y.tryPromise((t) => this.#e.getPublishOperation(e.flowId, n.operationId, t));
2022
+ return n;
2023
+ }), { signal: this.#a.signal });
2024
+ if (this.#s) return;
2025
+ n.status == "failed" ? this.#r({
2026
+ kind: "error",
2027
+ message: n.issue.message
2028
+ }) : this.#r({
2029
+ kind: "success",
2030
+ message: this.#t.t("notice.published", { name: e.name })
2031
+ }), this.include(await this.#e.getFlow(e.flowId));
2032
+ } catch (e) {
2033
+ this.#s || this.#r(E(e, this.#t.t));
2034
+ } finally {
2035
+ this.#o.delete(e.flowId);
2036
+ }
1786
2037
  }
1787
2038
  }
1788
2039
  async create(e) {
1789
2040
  let t = await this.#e.createFlow(e);
1790
- if (!this.#a) return this.#o({
1791
- flows: [...this.#i.value.flows, t],
1792
- total: this.#i.value.total == null ? void 0 : this.#i.value.total + 1
1793
- }), t;
2041
+ if (!this.#s) return this.insert(t), t;
1794
2042
  }
1795
2043
  include(e) {
1796
2044
  let t = this.#i.value.flows.findIndex((t) => t.flowId == e.flowId);
1797
2045
  if (t < 0) {
1798
- this.#o({ flows: [...this.#i.value.flows, e] });
2046
+ this.#c({ flows: [...this.#i.value.flows, e] });
1799
2047
  return;
1800
2048
  }
1801
- this.#o({ flows: this.#i.value.flows.with(t, e) });
2049
+ this.#c({ flows: this.#i.value.flows.with(t, e) });
1802
2050
  }
1803
2051
  insert(e) {
1804
- this.#i.value.flows.some((t) => t.flowId == e.flowId) || this.#o({
2052
+ this.#i.value.flows.some((t) => t.flowId == e.flowId) || this.#c({
1805
2053
  flows: [...this.#i.value.flows, e],
1806
2054
  total: this.#i.value.total == null ? void 0 : this.#i.value.total + 1
1807
2055
  });
1808
2056
  }
1809
2057
  remove(e) {
1810
- this.#o({
2058
+ this.#c({
1811
2059
  flows: this.#i.value.flows.filter((t) => t.flowId != e),
1812
2060
  total: this.#i.value.total == null ? void 0 : this.#i.value.total - 1
1813
2061
  });
1814
2062
  }
1815
2063
  advanceHead(e, t) {
1816
- this.#o({ flows: this.#i.value.flows.map((n) => n.flowId == e ? {
2064
+ this.#c({ flows: this.#i.value.flows.map((n) => n.flowId == e ? {
1817
2065
  ...n,
1818
2066
  draftRevisionId: t
1819
2067
  } : n) });
1820
2068
  }
1821
- #o(e) {
1822
- this.#a || this.#i.set({
2069
+ #c(e) {
2070
+ this.#s || this.#i.set({
1823
2071
  ...this.#i.value,
1824
2072
  ...e
1825
2073
  });
1826
2074
  }
1827
- }, Pt = class {
2075
+ }, en = class {
1828
2076
  #e;
1829
2077
  #t;
1830
2078
  #n;
@@ -1867,7 +2115,7 @@ var jt = class {
1867
2115
  this.#c(a, r);
1868
2116
  } catch (r) {
1869
2117
  if (this.#o || !n()) return;
1870
- if (r instanceof P && r.code == "flow.presentation-conflict") try {
2118
+ if (r instanceof L && r.code == "flow.presentation-conflict") try {
1871
2119
  let t = await this.#e.getPresentation(e);
1872
2120
  if (this.#o || !n()) return;
1873
2121
  this.#c(a, t), this.#n({
@@ -1875,9 +2123,9 @@ var jt = class {
1875
2123
  message: this.#t.t("notice.layoutConflict")
1876
2124
  });
1877
2125
  } catch (e) {
1878
- !this.#o && n() && this.#n(R(e, this.#t.t));
2126
+ !this.#o && n() && this.#n(E(e, this.#t.t));
1879
2127
  }
1880
- else this.#c(a, t), this.#n(R(r, this.#t.t));
2128
+ else this.#c(a, t), this.#n(E(r, this.#t.t));
1881
2129
  }
1882
2130
  }), await this.#i;
1883
2131
  }
@@ -1889,21 +2137,21 @@ var jt = class {
1889
2137
  value: n
1890
2138
  });
1891
2139
  }
1892
- }, Ft = {
2140
+ }, tn = {
1893
2141
  checkLoading: !1,
1894
2142
  selectedNodeIds: [],
1895
2143
  workspaceLoadFailed: !1,
1896
2144
  workspaceLoading: !1
1897
2145
  };
1898
- function It(e) {
1899
- return e.workspaceLoading ? "loading" : e.busy == "designer" ? "saving" : e.draft == null ? "noDraft" : "saved";
2146
+ function nn(e) {
2147
+ return e.workspaceLoading ? "loading" : e.moduleSaveStatus == null ? e.busy == "designer" ? "saving" : e.draft == null ? "noDraft" : "saved" : e.moduleSaveStatus;
1900
2148
  }
1901
- function Z(e, t) {
2149
+ function $(e, t) {
1902
2150
  if (t.phase != null) return t.phase;
1903
2151
  let n = e?.content.modules[t.moduleId];
1904
2152
  return n == null ? "failed" : t.source == n.source ? "saved" : "dirty";
1905
2153
  }
1906
- function Q(e, t, n) {
2154
+ function rn(e, t, n) {
1907
2155
  if (e == null || t == null || n.length != 1) return;
1908
2156
  let r = e.node(t, n[0]);
1909
2157
  if (!(r?.kind != "task" || r.definition == null || !("moduleId" in r.definition) || r.module == null)) return {
@@ -1911,9 +2159,9 @@ function Q(e, t, n) {
1911
2159
  source: r.module.source
1912
2160
  };
1913
2161
  }
1914
- var Lt = class {
2162
+ var an = class {
1915
2163
  #e;
1916
- #t = t(Ft);
2164
+ #t = t(tn);
1917
2165
  #n;
1918
2166
  constructor(t, r) {
1919
2167
  let i = e(this.#t, (e) => e.busy), a = e(this.#t, (e) => e.checkLoading), o = e(this.#t, (e) => e.diagnosticFocus), s = e(this.#t, (e) => e.diagnostics), c = e(this.#t, (e) => e.draft), l = e(this.#t, (e) => {
@@ -1921,25 +2169,25 @@ var Lt = class {
1921
2169
  let { phase: t, ...n } = e.moduleEditor;
1922
2170
  return {
1923
2171
  ...n,
1924
- status: Z(e.draft, e.moduleEditor)
2172
+ status: $(e.draft, e.moduleEditor)
1925
2173
  };
1926
- }), u = e(this.#t, (e) => e.nodeFocus), d = e(this.#t, (e) => e.presentation), f = e(this.#t, (e) => e.flowId), p = e(this.#t, (e) => e.live), m = e(this.#t, (e) => e.draft == null ? void 0 : N(e.draft)), h = e(this.#t, (e) => e.selectedNodeIds), g = e(this.#t, (e) => e.target), _ = e(this.#t, (e) => e.workspaceLoadFailed), v = e(this.#t, (e) => e.workspaceLoading);
2174
+ }), u = e(this.#t, (e) => e.nodeFocus), d = e(this.#t, (e) => e.presentation), f = e(this.#t, (e) => e.flowId), p = e(this.#t, (e) => e.live), m = e(this.#t, (e) => e.draft == null ? void 0 : C(e.draft)), h = e(this.#t, (e) => e.selectedNodeIds), g = e(this.#t, (e) => e.target), _ = e(this.#t, (e) => e.workspaceLoadFailed), v = e(this.#t, (e) => e.workspaceLoading);
1927
2175
  this.#e = e(this.#t, (e) => ({
1928
- revision: e.draft == null ? void 0 : N(e.draft),
2176
+ revision: e.draft == null ? void 0 : C(e.draft),
1929
2177
  target: e.target
1930
2178
  }), { equal: (e, t) => e.revision === t.revision && e.target === t.target });
1931
2179
  let y = e(this.#t, (e) => {
1932
- if (e.draft != null && e.target != null && e.selectedNodeIds.length == 1) return N(e.draft).selection(e.target, e.selectedNodeIds[0]);
2180
+ if (e.draft != null && e.target != null && e.selectedNodeIds.length == 1) return C(e.draft).selection(e.target, e.selectedNodeIds[0]);
1933
2181
  });
1934
2182
  this.$ = {
1935
2183
  addNodeOptions: n((e) => {
1936
2184
  let { revision: n, target: r } = e(this.#e);
1937
- return Ne(n?.revision, r, e(t.t$));
2185
+ return Oe(n?.revision, r, e(t.t$));
1938
2186
  }),
1939
2187
  busy: i,
1940
2188
  checkLoading: a,
1941
2189
  diagnosticFocus: o,
1942
- diagnosticItems: e(this.#t, (e) => Ee(e.draft == null ? void 0 : N(e.draft), e.target, e.diagnostics)),
2190
+ diagnosticItems: e(this.#t, (e) => D(e.draft == null ? void 0 : C(e.draft), e.target, e.diagnostics)),
1943
2191
  diagnostics: s,
1944
2192
  draft: c,
1945
2193
  flow: n((e) => {
@@ -1952,9 +2200,10 @@ var Lt = class {
1952
2200
  flowLoading: r.$.loading,
1953
2201
  flowLoadingMore: r.$.loadingMore,
1954
2202
  flowNextCursor: r.$.nextCursor,
2203
+ flowRefreshing: r.$.refreshing,
1955
2204
  flowTotal: r.$.total,
1956
2205
  flows: r.$.flows,
1957
- inspectorDiagnostics: e(this.#t, (e) => Ae(e.draft == null ? void 0 : N(e.draft), e.target, e.diagnostics, y.value)),
2206
+ inspectorDiagnostics: e(this.#t, (e) => T(e.draft == null ? void 0 : C(e.draft), e.target, e.diagnostics, y.value)),
1958
2207
  live: p,
1959
2208
  moduleDiagnostics: e(this.#t, (e) => {
1960
2209
  let t = e.moduleEditor?.moduleId;
@@ -1966,11 +2215,11 @@ var Lt = class {
1966
2215
  revision: m,
1967
2216
  selection: y,
1968
2217
  selectedNodeIds: h,
1969
- status: e(this.#t, It),
2218
+ status: e(this.#t, nn),
1970
2219
  target: g,
1971
2220
  targetFlow: n((e) => e(g)?.kind == "flow" ? e(r.$.flows).find((t) => t.flowId == e(f)) : void 0),
1972
2221
  targetName: e(this.#t, (e) => {
1973
- if (e.target != null) return e.target.kind == "flow" ? r.flow(e.flowId ?? "")?.name : e.draft == null ? e.target.id : N(e.draft).subflow(e.target.id)?.name ?? e.target.id;
2222
+ if (e.target != null) return e.target.kind == "flow" ? r.flow(e.flowId ?? "")?.name : e.draft == null ? e.target.id : C(e.draft).subflow(e.target.id)?.name ?? e.target.id;
1974
2223
  }),
1975
2224
  workspaceLoadFailed: _,
1976
2225
  workspaceLoading: v
@@ -1989,17 +2238,16 @@ var Lt = class {
1989
2238
  for (let e of Object.values(this.$)) this.#n.has(e) || e.dispose();
1990
2239
  this.#e.dispose(), this.#t.dispose();
1991
2240
  }
1992
- }, Rt = 250;
1993
- function zt(e, t) {
2241
+ };
2242
+ //#endregion
2243
+ //#region src/workbench/browser/runtime/stores/workspaceStore.ts
2244
+ function on(e, t) {
1994
2245
  if (t != null) return t.kind == "flow" || e.subflow(t.id) != null ? t : { kind: "flow" };
1995
2246
  }
1996
- function $(e, t) {
1997
- return e?.kind == t?.kind ? e?.kind != "subflow" || t?.kind == "subflow" && e.id == t.id : !1;
1998
- }
1999
- var Bt = class {
2247
+ var sn = class {
2000
2248
  #e;
2001
2249
  #t;
2002
- #n = new x();
2250
+ #n = new m();
2003
2251
  #r;
2004
2252
  #i;
2005
2253
  #a;
@@ -2007,51 +2255,60 @@ var Bt = class {
2007
2255
  #s;
2008
2256
  #c;
2009
2257
  #l;
2010
- #u;
2011
- #d = 0;
2012
- #f = 0;
2258
+ #u = /* @__PURE__ */ new Map();
2259
+ #d;
2260
+ #f;
2013
2261
  #p;
2014
2262
  #m = 0;
2015
- #h = !1;
2263
+ #h = 0;
2016
2264
  #g = !1;
2017
2265
  #_ = !1;
2018
2266
  #v = !1;
2019
2267
  #y = 0;
2020
2268
  #b;
2021
2269
  #x;
2022
- constructor(e, t, n = st, r = E(), i = () => {}) {
2023
- this.#e = e, this.#c = t, this.#i = n, this.#r = r, this.#s = i, this.#o = new Nt(e, t, r), this.#l = new Lt(r, this.#o), this.#t = new jt(e, t, r, {
2024
- apply: (e, t) => this.#w(e, t),
2270
+ constructor(e, t, n = Dt, r = P(), i = () => {}) {
2271
+ this.#e = e, this.#c = t, this.#i = n, this.#r = r, this.#s = i, this.#o = new $t(e, t, r), this.#l = new an(r, this.#o), this.#t = new Xt(e, t, r, {
2272
+ apply: (e, t) => this.#D(e, t),
2025
2273
  beforeChange: (e) => {
2026
- this.#M(), this.#h = !1, e && (this.#B({ busy: "designer" }), this.#c(void 0));
2274
+ e && (this.#R({ busy: "designer" }), this.#c(void 0));
2027
2275
  },
2028
- check: () => void this.#E(),
2029
- current: (e) => this.#z(e),
2276
+ check: () => void this.#k(),
2277
+ current: (e) => this.#L(e),
2030
2278
  diagnostics: () => this.#l.value.diagnostics,
2031
2279
  finishChanges: () => {
2032
- !this.#_ && this.#l.value.busy == "designer" && this.#B({ busy: void 0 });
2280
+ !this.#_ && this.#l.value.busy == "designer" && this.#R({ busy: void 0 });
2033
2281
  },
2034
- headChanged: (e, t) => this.#N(e, t),
2035
- recover: (e) => this.#O(e, !0)
2036
- }), this.#a = new Pt(e, t, (e) => this.#B({ presentation: e }), r), this.$ = this.#l.$;
2282
+ headChanged: (e, t) => this.#M(e, t),
2283
+ recover: (e) => this.#j(e, !0)
2284
+ }), this.#a = new en(e, t, (e) => this.#R({ presentation: e }), r), this.$ = this.#l.$;
2037
2285
  }
2038
2286
  dispose() {
2039
- this.#M(), this.#_ = !0, this.#n.invalidate(), this.#a.dispose(), this.#b?.(), this.#x?.(), this.#l.dispose(), this.#o.dispose();
2287
+ this.#_ = !0, clearTimeout(this.#d), this.#n.invalidate(), this.#a.dispose(), this.#b?.(), this.#x?.(), this.#l.dispose(), this.#o.dispose();
2040
2288
  }
2041
2289
  async start(e) {
2042
- this.#b ??= this.#e.watchFlowCatalog(() => void this.reloadFlows()), await this.reloadFlows(), await this.selectFlow(e);
2290
+ if (this.#b == null) {
2291
+ let e = this.#e.watchFlowCatalog(() => void this.reloadFlows());
2292
+ this.#b = e.stop, await e.ready;
2293
+ }
2294
+ this.#_ || (await this.reloadFlows(), this.#_ || await this.selectFlow(e));
2043
2295
  }
2044
2296
  async reloadFlows() {
2045
2297
  await this.#o.reload();
2046
2298
  }
2299
+ async setFlowEnabled(e, t) {
2300
+ await this.#o.setEnabled(e, t);
2301
+ }
2302
+ async publishFlow(e) {
2303
+ await this.#o.publish(e);
2304
+ }
2047
2305
  async loadMoreFlows() {
2048
2306
  await this.#o.loadMore();
2049
2307
  }
2050
2308
  async selectFlow(e) {
2051
- if (!this.#F()) return !1;
2052
- this.#M();
2309
+ if (!await this.saveModuleEditor()) return !1;
2053
2310
  let t = this.#n.begin();
2054
- if (this.#t.reset(), this.#a.reset(), this.#f = 0, this.#h = !1, this.#g = !1, this.#v = !1, this.#x?.(), this.#x = void 0, this.#B({
2311
+ if (this.#t.reset(), this.#a.reset(), this.#h = 0, this.#g = !1, this.#v = !1, this.#x?.(), this.#x = void 0, this.#R({
2055
2312
  checkLoading: !1,
2056
2313
  diagnosticFocus: void 0,
2057
2314
  diagnostics: void 0,
@@ -2067,85 +2324,95 @@ var Bt = class {
2067
2324
  workspaceLoading: e != null
2068
2325
  }), e == null) return !0;
2069
2326
  try {
2070
- let n = this.#o.flow(e), [r, i, a, o] = await Promise.all([
2071
- n ?? this.#e.getFlow(e),
2072
- this.#e.getDraft(e),
2073
- this.#e.getLive(e),
2074
- this.#e.getPresentation(e)
2075
- ]);
2327
+ let n = !1, r, i = this.#e.watchFlow(e, (e) => {
2328
+ t() && (this.#t.committed == null ? (n = !0, r = e) : e != this.#t.committed.revisionId && this.#A(e));
2329
+ }, (e) => {
2330
+ t() && this.#s(e);
2331
+ });
2332
+ if (this.#x = i.stop, await i.ready, !t()) return !1;
2333
+ let { flow: a, draft: o, live: s, presentation: c } = await this.#e.getEditor(e);
2076
2334
  if (!t()) return !1;
2077
- this.#t.reset(i), this.#a.reset(o), this.#o.include(r), this.#B({
2078
- draft: i,
2079
- live: a,
2080
- presentation: o,
2335
+ this.#t.reset(o), this.#a.reset(c), this.#o.include(a), this.#R({
2336
+ draft: o,
2337
+ live: s,
2338
+ presentation: c,
2081
2339
  target: { kind: "flow" },
2082
2340
  workspaceLoadFailed: !1,
2083
2341
  workspaceLoading: !1
2084
- }), this.#E(), this.#x = this.#e.watchFlow(e, (e) => {
2085
- !this.#_ && e != this.#t.committed?.revisionId && this.#D(e);
2086
- }, this.#s);
2342
+ }), await this.#E(t), n && r != o.revisionId && this.#A(r);
2087
2343
  } catch (e) {
2088
- return t() ? (this.#B({
2344
+ if (!t()) return !1;
2345
+ this.#x?.(), this.#x = void 0;
2346
+ let n = e instanceof L && e.code == le.flowNotFound;
2347
+ return this.#R(n ? {
2348
+ flowId: void 0,
2349
+ target: void 0,
2350
+ workspaceLoadFailed: !1,
2351
+ workspaceLoading: !1
2352
+ } : {
2089
2353
  workspaceLoadFailed: !0,
2090
2354
  workspaceLoading: !1
2091
- }), this.#c(R(e, this.#r.t)), !1) : !1;
2355
+ }), this.#c(n ? {
2356
+ kind: "error",
2357
+ message: this.#r.t("notice.flowMissing")
2358
+ } : E(e, this.#r.t)), !1;
2092
2359
  }
2093
2360
  return !0;
2094
2361
  }
2095
2362
  selectTarget(e) {
2096
- return this.#F() ? (this.#M(), this.#B({
2363
+ return this.#S(), this.#R({
2097
2364
  diagnosticFocus: void 0,
2098
2365
  diagnostics: void 0,
2099
2366
  moduleEditor: void 0,
2100
2367
  nodeFocus: void 0,
2101
2368
  selectedNodeIds: [],
2102
2369
  target: e
2103
- }), this.#E(), !0) : !1;
2370
+ }), this.#k(), !0;
2104
2371
  }
2105
2372
  selectNodes(e) {
2106
- return e.length == this.#l.value.selectedNodeIds.length && e.every((e, t) => e == this.#l.value.selectedNodeIds[t]) ? !0 : this.#F() ? (this.#M(), this.#B({
2373
+ return e.length == this.#l.value.selectedNodeIds.length && e.every((e, t) => e == this.#l.value.selectedNodeIds[t]) ? !0 : (this.#S(), this.#R({
2107
2374
  diagnosticFocus: void 0,
2108
- moduleEditor: Q(this.#l.value.draft == null ? void 0 : N(this.#l.value.draft), this.#l.value.target, e),
2375
+ moduleEditor: rn(this.#l.value.draft == null ? void 0 : C(this.#l.value.draft), this.#l.value.target, e),
2109
2376
  nodeFocus: void 0,
2110
2377
  selectedNodeIds: e
2111
- }), !0) : !1;
2378
+ }), !0);
2112
2379
  }
2113
2380
  async createFlow(e, t) {
2114
- if (this.#F()) {
2115
- this.#B({ busy: "flow" }), this.#c(void 0);
2381
+ if (await this.saveModuleEditor()) {
2382
+ this.#R({ busy: "flow" }), this.#c(void 0);
2116
2383
  try {
2117
2384
  if (t == null) return await this.#o.create(e);
2118
2385
  let n = await this.#e.getFlow(await t(e));
2119
2386
  return this.#o.insert(n), n;
2120
2387
  } catch (e) {
2121
- this.#_ || this.#c(R(e, this.#r.t));
2388
+ this.#_ || this.#c(E(e, this.#r.t));
2122
2389
  } finally {
2123
- this.#B({ busy: void 0 });
2390
+ this.#R({ busy: void 0 });
2124
2391
  }
2125
2392
  }
2126
2393
  }
2127
2394
  async deleteFlow(e) {
2128
- if (!this.#F()) return !1;
2395
+ if (!await this.saveModuleEditor()) return !1;
2129
2396
  let t = this.#o.flow(e);
2130
2397
  if (t == null || t.status == "retiring") return !1;
2131
- this.#B({ busy: "flow" }), this.#c(void 0);
2398
+ this.#R({ busy: "flow" }), this.#c(void 0);
2132
2399
  try {
2133
2400
  return await this.#e.deleteFlow(e), !this.#_ && (this.#o.remove(e), this.#c({
2134
2401
  kind: "success",
2135
2402
  message: this.#r.t("notice.flowDeleteAccepted", { name: t.name })
2136
2403
  }), !0);
2137
2404
  } catch (e) {
2138
- return this.#_ || this.#c(R(e, this.#r.t)), !1;
2405
+ return this.#_ || this.#c(E(e, this.#r.t)), !1;
2139
2406
  } finally {
2140
- this.#B({ busy: void 0 });
2407
+ this.#R({ busy: void 0 });
2141
2408
  }
2142
2409
  }
2143
2410
  async createResource(e) {
2144
- if (!this.#F() || this.#l.value.draft == null) return !1;
2411
+ if (!await this.saveModuleEditor() || this.#l.value.draft == null) return !1;
2145
2412
  let t = this.#i();
2146
- this.#B({ busy: "resource" }), this.#c(void 0);
2147
- let n = await this.#C(ge(t, e), !1);
2148
- return this.#B({ busy: void 0 }), n != null && (this.selectTarget({
2413
+ this.#R({ busy: "resource" }), this.#c(void 0);
2414
+ let n = await this.#T(j(t, e), !1);
2415
+ return this.#R({ busy: void 0 }), n != null && (this.selectTarget({
2149
2416
  id: t,
2150
2417
  kind: "subflow"
2151
2418
  }), this.#c({
@@ -2157,32 +2424,36 @@ var Bt = class {
2157
2424
  let n = this.#o.flow(e), r = t.trim();
2158
2425
  if (n == null || r.length == 0) return !1;
2159
2426
  if (n.name == r) return !0;
2160
- this.#B({ busy: "flow" }), this.#c(void 0);
2427
+ this.#R({ busy: "flow" }), this.#c(void 0);
2161
2428
  let i;
2162
2429
  try {
2163
2430
  i = await this.#e.renameFlow(e, r), i != null && this.#o.include(i);
2164
2431
  } catch (e) {
2165
- this.#_ || this.#c(R(e, this.#r.t));
2432
+ this.#_ || this.#c(E(e, this.#r.t));
2166
2433
  }
2167
- return this.#B({ busy: void 0 }), i != null && (this.#c({
2434
+ return this.#R({ busy: void 0 }), i != null && (this.#c({
2168
2435
  kind: "success",
2169
2436
  message: this.#r.t("notice.flowRenamed", { name: r })
2170
2437
  }), !0);
2171
2438
  }
2172
2439
  async addNode(e, t, n) {
2173
- if (!this.#F()) return;
2440
+ if (!await this.saveModuleEditor()) return;
2174
2441
  let r = this.#l.value.draft, i = this.#l.value.target;
2175
2442
  if (r == null || i == null) return;
2176
2443
  let a = this.#i();
2177
- if (e.kind == "comment") return await this.#S(i, a, t);
2178
- let o = N(r), s = S(e, o, i, this.#r.t);
2444
+ if (e.kind == "comment") return await this.#w(i, a, t);
2445
+ let o = C(r), s = u(e, o, i, this.#r.t);
2179
2446
  if (s == null) return;
2180
- let c = xe(o, i, a, s, this.#i);
2181
- if (c == null) return;
2182
- let l = n == null ? c : [...c, ...nt(F(r, c).content, i, n(a))], u = this.#C(l);
2447
+ let c = n?.(a), l = we(o, i, a, s, this.#i);
2448
+ if (l == null) return;
2449
+ let d = c == null ? l : [...l, ...St(R(r, l).content, i, {
2450
+ source: c.source,
2451
+ target: c.target,
2452
+ ...c.sourceHandle.startsWith("$branch:") ? { sourceHandle: c.sourceHandle.slice(8) } : {}
2453
+ })], f = this.#T(d);
2183
2454
  this.selectNodes([a]);
2184
- let d = this.moveNodes({ [a]: t });
2185
- if (await u != null && (await d, !this.#_)) return this.#B({ nodeFocus: {
2455
+ let p = this.moveNodes({ [a]: t });
2456
+ if (await f != null && (await p, !this.#_)) return this.#R({ nodeFocus: {
2186
2457
  nodeId: a,
2187
2458
  requestId: ++this.#y
2188
2459
  } }), a;
@@ -2190,53 +2461,61 @@ var Bt = class {
2190
2461
  async connect(e) {
2191
2462
  let t = this.$.revision.value, n = this.#l.value.target;
2192
2463
  if (t == null || n == null) return;
2193
- let r = nt(t.revision.content, n, e);
2194
- r.length > 0 && await this.#C(r);
2464
+ let r = St(t.revision.content, n, {
2465
+ source: e.source,
2466
+ target: e.target,
2467
+ ...e.sourceHandle.startsWith("$branch:") ? { sourceHandle: e.sourceHandle.slice(8) } : {}
2468
+ });
2469
+ r.length > 0 && await this.#T(r);
2195
2470
  }
2196
2471
  async disconnect(e) {
2197
2472
  let t = this.$.revision.value, n = this.#l.value.target;
2198
2473
  if (t == null || n == null) return;
2199
- let r = rt(t.revision.content, n, e);
2200
- r.length > 0 && await this.#C(r);
2474
+ let r = Ct(t.revision.content, n, {
2475
+ source: e.source,
2476
+ target: e.target,
2477
+ ...e.sourceHandle.startsWith("$branch:") ? { sourceHandle: e.sourceHandle.slice(8) } : {}
2478
+ });
2479
+ r.length > 0 && await this.#T(r);
2201
2480
  }
2202
2481
  async deleteSelectedNodes() {
2203
- if (!this.#F()) return;
2482
+ if (!await this.saveModuleEditor()) return;
2204
2483
  let e = this.$.revision.value, t = this.#l.value.target;
2205
2484
  if (e == null || t == null || this.#l.value.selectedNodeIds.length == 0) return;
2206
- let n = T(this.#l.value.presentation?.value ?? {}, t), r = new Set(this.#l.value.selectedNodeIds.filter((e) => n.has(e))), i = we(e, t, this.#l.value.selectedNodeIds), a = i.length == 0 ? void 0 : this.#C(i), o = r.size == 0 ? void 0 : this.#T((e) => y(e, t, r));
2485
+ let n = f(this.#l.value.presentation?.value ?? {}, t), r = new Set(this.#l.value.selectedNodeIds.filter((e) => n.has(e))), i = ge(e, t, this.#l.value.selectedNodeIds), a = i.length == 0 ? void 0 : this.#T(i), o = r.size == 0 ? void 0 : this.#O((e) => c(e, t, r));
2207
2486
  this.selectNodes([]), (a == null || await a != null) && await o;
2208
2487
  }
2209
2488
  copySelectedNodes() {
2210
2489
  let e = this.$.revision.value, t = this.#l.value.target;
2211
2490
  if (e == null || t == null || this.#l.value.selectedNodeIds.length == 0) return;
2212
2491
  let n = new Set(this.#l.value.selectedNodeIds);
2213
- this.#u = {
2214
- comments: this.#P().nodes.flatMap((e) => e.kind == "comment" && n.has(e.id) ? [{
2492
+ this.#p = {
2493
+ comments: this.#N().nodes.flatMap((e) => e.kind == "comment" && n.has(e.id) ? [{
2215
2494
  content: e.content,
2216
2495
  position: e.position,
2217
2496
  sourceId: e.id,
2218
2497
  title: e.title
2219
2498
  }] : []),
2220
- nodes: ke(e, t, this.#l.value.selectedNodeIds)
2499
+ nodes: ue(e, t, this.#l.value.selectedNodeIds)
2221
2500
  };
2222
2501
  }
2223
2502
  async pasteNodes(e) {
2224
- if (!this.#F()) return;
2503
+ if (!await this.saveModuleEditor()) return;
2225
2504
  let t = this.$.revision.value, n = this.#l.value.target;
2226
- if (t == null || n == null || this.#u == null) return;
2227
- let r = je(t, n, this.#u.nodes, this.#i), i = r.changes.length == 0 ? void 0 : this.#C(r.changes), a = this.#u.comments.map((e) => ({
2505
+ if (t == null || n == null || this.#p == null) return;
2506
+ let r = Se(t, n, this.#p.nodes, this.#i), i = r.changes.length == 0 ? void 0 : this.#T(r.changes), a = this.#p.comments.map((e) => ({
2228
2507
  ...e,
2229
2508
  nodeId: this.#i()
2230
2509
  }));
2231
2510
  if (r.nodeIds.length == 0 && a.length == 0) return;
2232
- let o = new Map(this.#P().nodes.map((e) => [e.id, e])), s = Object.fromEntries(r.sourceIds.map((t, n) => {
2511
+ let o = new Map(this.#N().nodes.map((e) => [e.id, e])), s = Object.fromEntries(r.sourceIds.map((t, n) => {
2233
2512
  let i = e?.[t] ?? o.get(t)?.position;
2234
2513
  return [r.nodeIds[n], {
2235
2514
  x: (i?.x ?? 80) + 40,
2236
2515
  y: (i?.y ?? 80) + 40
2237
2516
  }];
2238
- })), c = this.#T((e) => {
2239
- let t = j(e, n, s);
2517
+ })), c = this.#O((e) => {
2518
+ let t = y(e, n, s);
2240
2519
  for (let e of a) t = I(t, n, e.nodeId, {
2241
2520
  content: e.content,
2242
2521
  position: {
@@ -2255,56 +2534,73 @@ var Bt = class {
2255
2534
  async saveNodeSettings(e, t) {
2256
2535
  let n = this.$.revision.value, r = this.#l.value.target;
2257
2536
  if (n == null || r == null) return !1;
2258
- let i = Me(n, r, e, t);
2259
- return i != null && await this.#C(i) != null;
2537
+ let i = se(n, r, e, t);
2538
+ return i != null && await this.#T(i) != null;
2260
2539
  }
2261
2540
  async saveNodeDescription(e, t) {
2262
2541
  let n = this.$.revision.value, r = this.#l.value.target;
2263
2542
  if (n == null || r == null) return !1;
2264
- let i = be(n, r, e, t);
2265
- return i != null && await this.#C(i) != null;
2543
+ let i = ve(n, r, e, t);
2544
+ return i != null && await this.#T(i) != null;
2266
2545
  }
2267
2546
  async saveNodeIcon(e, t) {
2268
2547
  let n = this.$.revision.value, r = this.#l.value.target;
2269
2548
  if (n == null || r == null) return !1;
2270
- let i = ye(n, r, e, t);
2271
- return i != null && await this.#C(i) != null;
2549
+ let i = me(n, r, e, t);
2550
+ return i != null && await this.#T(i) != null;
2272
2551
  }
2273
2552
  async saveNodeTitle(e, t) {
2274
2553
  let n = this.$.revision.value, r = this.#l.value.target;
2275
2554
  if (n == null || r == null) return !1;
2276
- let i = me(n, r, e, t);
2277
- return i != null && await this.#C(i) != null;
2555
+ let i = ce(n, r, e, t);
2556
+ return i != null && await this.#T(i) != null;
2278
2557
  }
2279
2558
  async setInputValue(e, t, n) {
2280
2559
  let r = this.$.revision.value, i = this.#l.value.target;
2281
2560
  if (r == null || i == null) return !1;
2282
- let a = _e(r, i, e, t, n);
2283
- return a != null && await this.#C(a) != null;
2561
+ let a = N(r, i, e, t, n);
2562
+ return a != null && await this.#T(a) != null;
2563
+ }
2564
+ async setInputSource(e, t, n) {
2565
+ let r = this.$.revision.value, i = this.#l.value.target;
2566
+ return r == null || i == null ? !1 : await this.#T(ee(r.revision.content, i, e, t, [{
2567
+ kind: "node",
2568
+ ...n
2569
+ }])) != null;
2284
2570
  }
2285
2571
  async setInputVariable(e, t, n) {
2286
2572
  let r = this.$.revision.value, i = this.#l.value.target;
2287
2573
  if (r == null || i == null) return !1;
2288
- let a = n == null ? _e(r, i, e, t, void 0) : ve(r, i, e, t, n, this.#i());
2289
- return a != null && await this.#C(a) != null;
2574
+ let a = n == null ? N(r, i, e, t, void 0) : fe(r, i, e, t, n, this.#i());
2575
+ return a != null && await this.#T(a) != null;
2290
2576
  }
2291
2577
  async saveCondition(e, t) {
2292
2578
  let n = this.$.revision.value, r = this.#l.value.target;
2293
2579
  if (n == null || r == null) return !1;
2294
- let i = Te(n, r, e, t);
2295
- return i != null && await this.#C(i) != null;
2580
+ let i = oe(n, r, e, t);
2581
+ return i != null && await this.#T(i) != null;
2296
2582
  }
2297
2583
  async saveValue(e, t) {
2298
2584
  let n = this.$.revision.value, r = this.#l.value.target;
2299
2585
  if (n == null || r == null) return !1;
2300
- let i = Pe(n, r, e, t);
2301
- return i != null && await this.#C(i) != null;
2586
+ let i = M(n, r, e, t);
2587
+ return i != null && await this.#T(i) != null;
2588
+ }
2589
+ async saveWait(e, t) {
2590
+ let n = this.$.revision.value, r = this.#l.value.target;
2591
+ if (n == null || r?.kind != "flow") return !1;
2592
+ let i = ke(n, r, e, t);
2593
+ return i != null && await this.#T(i) != null;
2594
+ }
2595
+ async setWaitNotification(e, t) {
2596
+ let n = this.$.revision.value, r = n == null ? void 0 : Te(n, e, t, this.#i());
2597
+ return r != null && await this.#T(r) != null;
2302
2598
  }
2303
2599
  async saveComment(e, t) {
2304
2600
  let n = this.#l.value.target;
2305
2601
  if (n == null) return;
2306
- let r = this.#P().nodes.find((t) => t.id == e)?.position;
2307
- r != null && await this.#T((i) => I(i, n, e, {
2602
+ let r = this.#N().nodes.find((t) => t.id == e)?.position;
2603
+ r != null && await this.#O((i) => I(i, n, e, {
2308
2604
  ...t,
2309
2605
  position: r
2310
2606
  }));
@@ -2312,187 +2608,265 @@ var Bt = class {
2312
2608
  async saveTaskSettings(e, t) {
2313
2609
  let n = this.$.revision.value, r = this.#l.value.target;
2314
2610
  if (n == null || r == null) return !1;
2315
- let i = he(n, r, e, t);
2316
- return i != null && await this.#C(i) != null;
2611
+ let i = De(n, r, e, t);
2612
+ return i != null && await this.#T(i) != null;
2613
+ }
2614
+ async saveCodeActions(e, t) {
2615
+ let n = this.$.revision.value, r = this.#l.value.target;
2616
+ if (n == null || r == null) return !1;
2617
+ let i = be(n.revision.content, r, e, t);
2618
+ return i == null || await this.#T(i) != null;
2317
2619
  }
2318
2620
  async saveCodeTaskPorts(e, t) {
2319
2621
  let n = this.$.revision.value, r = this.#l.value.target;
2320
2622
  if (n == null || r == null) return !1;
2321
- let i = De(n, r, e, t);
2322
- return i != null && await this.#C(i) != null;
2623
+ let i = re(n, r, e, t);
2624
+ return i != null && await this.#T(i) != null;
2625
+ }
2626
+ async saveTaskAdditionalInputs(e, t) {
2627
+ let n = this.$.revision.value, r = this.#l.value.target;
2628
+ if (n == null || r == null) return !1;
2629
+ let i = Ae(n, r, e, t);
2630
+ return i != null && await this.#T(i) != null;
2323
2631
  }
2324
2632
  async setConnectorConnection(e, t) {
2325
2633
  let n = this.$.revision.value;
2326
2634
  if (n == null) return !1;
2327
- let r = D(n.revision.content, e, t);
2328
- return r != null && await this.#C(r) != null;
2329
- }
2330
- async saveTriggerSettings(e, t) {
2331
- let n = this.$.revision.value, r = this.#l.value.target;
2332
- if (n == null || r?.kind != "flow") return !1;
2333
- let i = pe(n.revision.content, r, e, t);
2334
- return i != null && await this.#C(i) != null;
2635
+ let r = g(n.revision.content, e, t);
2636
+ return r != null && await this.#T(r) != null;
2335
2637
  }
2336
2638
  async saveTriggerConfig(e, t, n) {
2337
2639
  let r = this.$.revision.value, i = this.#l.value.target;
2338
2640
  if (r == null || i?.kind != "flow") return !1;
2339
- let a = ne(r.revision.content, i, e, t, n);
2340
- return a != null && await this.#C(a) != null;
2641
+ let a = k(r.revision.content, i, e, t, n);
2642
+ return a != null && await this.#T(a) != null;
2341
2643
  }
2342
2644
  async saveTriggerSchedule(e, t) {
2343
2645
  let n = this.$.revision.value, r = this.#l.value.target;
2344
2646
  if (n == null || r?.kind != "flow") return !1;
2345
- let i = re(n.revision.content, r, e, t);
2346
- return i != null && await this.#C(i) != null;
2647
+ let i = S(n.revision.content, r, e, t);
2648
+ return i != null && await this.#T(i) != null;
2347
2649
  }
2348
2650
  async saveWebhook(e, t) {
2349
2651
  let n = this.$.revision.value, r = this.#l.value.target;
2350
2652
  if (n == null || r?.kind != "flow") return !1;
2351
- let i = le(n, r, e, t);
2352
- return i != null && await this.#C(i) != null;
2653
+ let i = w(n, r, e, t);
2654
+ return i != null && await this.#T(i) != null;
2353
2655
  }
2354
2656
  async setTriggerConnection(e, t) {
2355
2657
  let n = this.$.revision.value, r = this.#l.value.target;
2356
2658
  if (n == null || r?.kind != "flow") return !1;
2357
- let i = de(n.revision.content, r, e, t);
2358
- return i != null && await this.#C(i) != null;
2659
+ let i = O(n.revision.content, r, e, t);
2660
+ return i != null && await this.#T(i) != null;
2359
2661
  }
2360
2662
  async saveSubflowSettings(e, t) {
2361
2663
  let n = this.$.revision.value;
2362
2664
  if (n == null) return !1;
2363
- let r = Fe(n, e, t);
2364
- return r != null && await this.#C(r) != null;
2665
+ let r = A(n, e, t);
2666
+ return r != null && await this.#T(r) != null;
2365
2667
  }
2366
2668
  updateModuleSource(e) {
2367
2669
  let t = this.#l.value.moduleEditor;
2368
- t != null && t.source != e && this.#B({ moduleEditor: {
2369
- ...t,
2370
- phase: void 0,
2371
- source: e
2372
- } });
2670
+ if (t == null || t.source == e) return;
2671
+ let n = this.#u.get(t.moduleId)?.base ?? this.#l.value.draft?.content.modules[t.moduleId];
2672
+ n != null && (this.#u.set(t.moduleId, {
2673
+ base: n,
2674
+ editor: {
2675
+ ...t,
2676
+ phase: void 0,
2677
+ source: e
2678
+ }
2679
+ }), this.#R({}), clearTimeout(this.#d), this.#d = setTimeout(() => void this.#S(), 800));
2373
2680
  }
2374
2681
  discardModuleChanges() {
2375
2682
  let e = this.#l.value.moduleEditor;
2376
- if (e == null) return;
2683
+ if (e == null || this.#f != null) return;
2684
+ this.#u.delete(e.moduleId);
2377
2685
  let t = this.#l.value.draft?.content.modules[e.moduleId];
2378
- if (t == null) {
2379
- this.#B({ moduleEditor: void 0 });
2380
- return;
2381
- }
2382
- this.#B({ moduleEditor: {
2686
+ this.#R({ moduleEditor: t == null ? void 0 : {
2383
2687
  moduleId: e.moduleId,
2384
2688
  source: t.source
2385
2689
  } });
2386
2690
  }
2691
+ get hasUnsavedCode() {
2692
+ return this.#u.size > 0;
2693
+ }
2387
2694
  async saveModuleEditor() {
2388
- let e = this.#l.value.moduleEditor;
2389
- if (e == null || e.phase == "saving") return !1;
2390
- this.#B({ moduleEditor: {
2391
- ...e,
2392
- phase: "saving"
2393
- } });
2394
- let t = await at(e.source);
2395
2695
  if (this.#_) return !1;
2396
- let n = await this.#C(ot(e.moduleId, e.source, t));
2397
- return !this.#_ && this.#l.value.moduleEditor?.moduleId == e.moduleId && this.#B({ moduleEditor: {
2398
- ...this.#l.value.moduleEditor,
2399
- phase: n == null ? "failed" : void 0
2400
- } }), n != null;
2696
+ for (let e of this.#u.values()) e.editor.phase == "failed" && (e.editor = {
2697
+ ...e.editor,
2698
+ phase: void 0
2699
+ });
2700
+ return this.#R({}), await this.#S();
2701
+ }
2702
+ #S() {
2703
+ if (clearTimeout(this.#d), this.#f != null) return this.#f;
2704
+ if (this.#_) return Promise.resolve(!1);
2705
+ if (![...this.#u.values()].some((e) => e.editor.phase != "failed")) return Promise.resolve(this.#u.size == 0);
2706
+ let e = this.#n.capture();
2707
+ return this.#f = this.#C(e).finally(() => {
2708
+ this.#f = void 0;
2709
+ }), this.#f;
2710
+ }
2711
+ async #C(e) {
2712
+ for (; !this.#_ && e();) {
2713
+ let t = [...this.#u.entries()].find(([, e]) => e.editor.phase != "failed");
2714
+ if (t == null) return this.#u.size == 0;
2715
+ let [n, r] = t, i = r.editor.source;
2716
+ r.editor = {
2717
+ ...r.editor,
2718
+ phase: "saving"
2719
+ }, this.#R({});
2720
+ try {
2721
+ let t = await Tt(i);
2722
+ if (this.#_ || !e()) return !1;
2723
+ let a = this.#l.value.draft?.content.modules[n];
2724
+ if (a == null || a.source != r.base.source || JSON.stringify(a.imports) != JSON.stringify(r.base.imports)) throw Error(this.#r.t("notice.moduleUpdated"));
2725
+ let o = i == a.source && JSON.stringify(t) == JSON.stringify(a.imports) ? this.#l.value.draft : await this.#T(Et(n, r.base.source, r.base.imports, i, t), !1);
2726
+ if (this.#_ || !e()) return !1;
2727
+ let s = this.#u.get(n);
2728
+ if (s == null) continue;
2729
+ o == null ? s.editor = {
2730
+ ...s.editor,
2731
+ phase: "failed"
2732
+ } : s.editor.source == i ? (this.#u.delete(n), this.#l.value.moduleEditor?.moduleId == n && this.#R({ moduleEditor: {
2733
+ moduleId: n,
2734
+ source: i
2735
+ } })) : (s.base = {
2736
+ ...r.base,
2737
+ source: i,
2738
+ imports: t
2739
+ }, s.editor = {
2740
+ ...s.editor,
2741
+ phase: void 0
2742
+ });
2743
+ } catch (t) {
2744
+ if (this.#_ || !e()) return !1;
2745
+ let r = this.#u.get(n);
2746
+ r != null && (r.editor = {
2747
+ ...r.editor,
2748
+ phase: "failed"
2749
+ }), this.#c(E(t, this.#r.t));
2750
+ }
2751
+ this.#R({});
2752
+ }
2753
+ return !1;
2401
2754
  }
2402
- async moveNodes(e, t = "detail") {
2403
- let n = this.#l.value.target;
2404
- n != null && await this.#T((r) => j(r, n, e, t));
2755
+ async moveNodes(e) {
2756
+ let t = this.#l.value.target;
2757
+ t != null && await this.#O((n) => y(n, t, e));
2405
2758
  }
2406
- async moveViewport(e, t = "detail") {
2407
- let n = this.#l.value.target;
2408
- if (n == null) return;
2409
- let r = this.#P().viewport;
2410
- (r.x != e.x || r.y != e.y || r.zoom != e.zoom) && this.#M(), await this.#T((r) => A(r, n, e, t));
2759
+ async moveViewport(e) {
2760
+ let t = this.#l.value.target;
2761
+ t != null && await this.#O((n) => v(n, t, e));
2411
2762
  }
2412
2763
  async check() {
2413
- await this.#E();
2764
+ await this.#k();
2414
2765
  }
2415
2766
  async refreshFlows() {
2416
2767
  await this.reloadFlows();
2417
2768
  }
2418
2769
  updateLive(e) {
2419
- e.flowId == this.#l.value.flowId && this.#B({ live: e });
2770
+ e.flowId == this.#l.value.flowId && this.#R({ live: e });
2420
2771
  }
2421
2772
  locateNode(e) {
2422
2773
  let t = this.$.revision.value, n = this.#l.value.target;
2423
- return t == null || n == null || t.node(n, e) == null || !this.selectNodes([e]) ? !1 : (this.#B({ nodeFocus: {
2774
+ return t == null || n == null || t.node(n, e) == null || !this.selectNodes([e]) ? !1 : (this.#R({ nodeFocus: {
2424
2775
  nodeId: e,
2425
2776
  requestId: ++this.#y
2426
2777
  } }), !0);
2427
2778
  }
2428
2779
  locateDiagnostic(e) {
2429
- return e.location == null || !this.selectNodes([e.location.nodeId]) ? !1 : (this.#B({ diagnosticFocus: {
2780
+ return e.location == null || !this.selectNodes([e.location.nodeId]) ? !1 : (this.#R({ diagnosticFocus: {
2430
2781
  ...e.location,
2431
2782
  diagnostic: e.diagnostic,
2432
- requestId: ++this.#d
2783
+ requestId: ++this.#m
2433
2784
  } }), !0);
2434
2785
  }
2435
- async #S(e, t, n) {
2436
- let r = Math.max(0, ...this.#P().nodes.flatMap((e) => {
2786
+ async #w(e, t, n) {
2787
+ let r = Math.max(0, ...this.#N().nodes.flatMap((e) => {
2437
2788
  if (e.kind != "comment") return [];
2438
2789
  let t = /#(\d+)$/.exec(e.title);
2439
2790
  return t == null ? [] : [Number(t[1])];
2440
- })), i = this.#T((i) => I(i, e, t, {
2791
+ })), i = this.#O((i) => I(i, e, t, {
2441
2792
  content: "",
2442
2793
  position: n,
2443
2794
  title: this.#r.t("addNode.commentName", { number: r + 1 })
2444
2795
  }));
2445
2796
  if (this.selectNodes([t]), await i, !this.#_) return t;
2446
2797
  }
2447
- async #C(e, t = !0) {
2798
+ async #T(e, t = !0) {
2448
2799
  let n = this.#l.value.flowId, r = this.#l.value.draft;
2449
- if (n != null && r != null) return await this.#t.change({
2800
+ if (n != null && r != null) return e.length == 0 ? r : await this.#t.change({
2450
2801
  current: this.#n.capture(),
2451
2802
  flowId: n
2452
2803
  }, r, e, t);
2453
2804
  }
2454
- #w(e, t = !1) {
2455
- let n = this.#l.value.draft, { revision: r, selectedNodeIds: i, target: a } = this.#I(e), o = this.#l.value.moduleEditor;
2456
- return this.#B({
2805
+ async #E(e) {
2806
+ for (let t = 0; t < 2 && e(); t += 1) {
2807
+ let t = this.#l.value.draft;
2808
+ if (t == null) return;
2809
+ let n = _(t.content);
2810
+ if (n.length == 0) {
2811
+ this.#k();
2812
+ return;
2813
+ }
2814
+ if (await this.#T(n, !1) != null || !e()) return;
2815
+ if (this.#l.value.draft?.revisionId == t.revisionId) break;
2816
+ }
2817
+ e() && this.#k();
2818
+ }
2819
+ #D(e, t = !1) {
2820
+ let n = this.#l.value.draft, { revision: r, selectedNodeIds: i, target: a } = this.#P(e), o = this.#l.value.moduleEditor;
2821
+ return this.#R({
2457
2822
  diagnostics: t ? this.#l.value.diagnostics : void 0,
2458
2823
  draft: e,
2459
- moduleEditor: o != null && n != null && Z(n, o) != "saved" ? o : Q(r, a, i),
2824
+ moduleEditor: o != null && n != null && $(n, o) != "saved" ? o : rn(r, a, i),
2460
2825
  selectedNodeIds: i,
2461
2826
  target: a
2462
2827
  }), r;
2463
2828
  }
2464
- async #T(e) {
2829
+ async #O(e) {
2465
2830
  if (this.#_) return;
2466
2831
  let t = this.#l.value.flowId, n = this.#l.value.presentation;
2467
- t != null && n != null && await this.#a.change(t, n, this.#o.capture(), e);
2832
+ t != null && n != null && await this.#a.change(t, n, this.#n.capture(), e);
2468
2833
  }
2469
- async #E() {
2834
+ async #k() {
2470
2835
  if (this.#_) return;
2471
2836
  let e = this.#l.value.flowId, t = this.#l.value.draft, n = this.#l.value.target;
2472
2837
  if (e == null || t == null || n == null) {
2473
- n ?? this.#B({
2838
+ n ?? this.#R({
2474
2839
  checkLoading: !1,
2475
2840
  diagnostics: void 0
2476
2841
  });
2477
2842
  return;
2478
2843
  }
2479
- this.#B({
2844
+ this.#R({
2480
2845
  checkLoading: !0,
2481
2846
  diagnosticFocus: void 0
2482
2847
  });
2483
2848
  try {
2484
2849
  let n = await this.#e.checkFlow(e, t.revisionId);
2485
- !this.#_ && e == this.#l.value.flowId && t.revisionId == this.#l.value.draft?.revisionId && this.#B({ diagnostics: n });
2850
+ if (!this.#_ && e == this.#l.value.flowId && t.revisionId == this.#l.value.draft?.revisionId) {
2851
+ let e = this.#l.value.live;
2852
+ this.#R({
2853
+ diagnostics: n,
2854
+ live: e == null ? void 0 : {
2855
+ ...e,
2856
+ hasUnpublishedChanges: e.publication == null || e.publication.closureDigest != n.closureDigest
2857
+ }
2858
+ });
2859
+ }
2486
2860
  } catch (n) {
2487
- !this.#_ && e == this.#l.value.flowId && t.revisionId == this.#l.value.draft?.revisionId && this.#c(R(n, this.#r.t));
2861
+ !this.#_ && e == this.#l.value.flowId && t.revisionId == this.#l.value.draft?.revisionId && this.#c(E(n, this.#r.t));
2488
2862
  } finally {
2489
- !this.#_ && e == this.#l.value.flowId && t.revisionId == this.#l.value.draft?.revisionId && this.#B({ checkLoading: !1 });
2863
+ !this.#_ && e == this.#l.value.flowId && t.revisionId == this.#l.value.draft?.revisionId && this.#R({ checkLoading: !1 });
2490
2864
  }
2491
2865
  }
2492
- async #D(e) {
2866
+ async #A(e) {
2493
2867
  if (this.#_) return;
2494
2868
  let t = this.#l.value.flowId;
2495
- if (t == null || (this.#f += 1, e != null && (this.#g = !0, this.#t.changing || (this.#h = !0)), this.#v)) return;
2869
+ if (t == null || (this.#h += 1, e != null && (this.#g = !0), this.#v)) return;
2496
2870
  this.#v = !0;
2497
2871
  let n = {
2498
2872
  current: this.#n.capture(),
@@ -2501,145 +2875,83 @@ var Bt = class {
2501
2875
  await this.#t.enqueue(async () => {
2502
2876
  let e;
2503
2877
  do {
2504
- e = this.#f;
2505
- let t = this.#h, r = this.#m, i = this.#g;
2506
- this.#h = !1, this.#g = !1, await this.#O(n, !1, i, t, r);
2507
- } while (this.#z(n) && e != this.#f);
2508
- }), this.#z(n) && (this.#v = !1);
2878
+ e = this.#h;
2879
+ let t = this.#g;
2880
+ this.#g = !1, await this.#j(n, !1, t);
2881
+ } while (this.#L(n) && e != this.#h);
2882
+ }), this.#L(n) && (this.#v = !1);
2509
2883
  }
2510
- async #O(e, t, n = !1, r = !1, i = this.#m) {
2884
+ async #j(e, t, n = !1) {
2511
2885
  try {
2512
- let t = r ? this.#l.value.target : void 0, a = this.#t.committed;
2513
- if (a == null) return !1;
2514
- let o = await this.#e.syncDraft(e.flowId, a.revisionId);
2515
- if (!this.#z(e)) return !1;
2516
- if (o.kind == "changes" && o.revisions.length == 0) return !0;
2517
- let s;
2518
- try {
2519
- s = this.#k(a, o);
2520
- } catch {
2521
- if (o = await this.#e.syncDraft(e.flowId), !this.#z(e)) return !1;
2522
- s = this.#k(a, o);
2523
- }
2524
- if (s.revisionId == a.revisionId) return !0;
2525
- let c = o.kind == "changes" && t != null ? kt(N(a), N(s), t, o.revisions.flatMap((e) => e.operations)) : void 0;
2526
- o.kind == "snapshot" && this.#M();
2527
- let l = this.#L(s, !1);
2528
- return this.#N(e.flowId, s.revisionId), o.kind == "changes" && o.revisions.length > 0 && t != null && c != null && i == this.#m && this.#A(e, t, c, i), n && (this.#c({
2529
- kind: l ? "error" : "success",
2530
- message: this.#r.t(l ? "notice.moduleUpdated" : "notice.draftUpdated")
2531
- }), this.#E()), !0;
2886
+ let t = this.#t.committed;
2887
+ if (t == null) return !1;
2888
+ let r = await this.#e.syncDraft(e.flowId);
2889
+ if (!this.#L(e)) return !1;
2890
+ let i = r.draft;
2891
+ if (i.revisionId == t.revisionId) return !0;
2892
+ let a = this.#F(i, !1);
2893
+ return this.#M(e.flowId, i.revisionId), n && this.#c({
2894
+ kind: a ? "error" : "success",
2895
+ message: this.#r.t(a ? "notice.moduleUpdated" : "notice.draftUpdated")
2896
+ }), this.#k(), !0;
2532
2897
  } catch (n) {
2533
- return t && this.#z(e) && this.#c(R(n, this.#r.t)), !1;
2898
+ return t && this.#L(e) && this.#c(E(n, this.#r.t)), !1;
2534
2899
  }
2535
2900
  }
2536
- #k(e, t) {
2537
- if (t.kind == "snapshot") return t.draft;
2538
- let n = e;
2539
- for (let e of t.revisions) {
2540
- if (e.revision.parentRevisionId != n.revisionId) throw Error("Invalid Draft revision chain.");
2541
- n = {
2542
- ...e.revision,
2543
- content: F(n, e.operations).content
2544
- };
2545
- }
2546
- return n;
2547
- }
2548
- #A(e, t, n, r) {
2549
- let i = this.#l.value;
2550
- if (!this.#z(e) || r != this.#m || !$(i.target, t)) return;
2551
- let a = this.#p;
2552
- if (a != null) {
2553
- if (a.flowId != e.flowId || !$(a.target, t)) {
2554
- this.#M();
2555
- return;
2556
- }
2557
- for (let e of n) a.targets.add(e);
2558
- globalThis.clearTimeout(a.timer), a.timer = globalThis.setTimeout(() => this.#j(), Rt);
2559
- return;
2560
- }
2561
- n.size == 0 || i.selectedNodeIds.length > 0 || (this.#p = {
2562
- current: e.current,
2563
- generation: r,
2564
- flowId: e.flowId,
2565
- target: t,
2566
- targets: new Set(n),
2567
- timer: globalThis.setTimeout(() => this.#j(), Rt),
2568
- viewport: this.#P().viewport
2569
- });
2570
- }
2571
- #j() {
2572
- let e = this.#p;
2573
- if (this.#p = void 0, e == null || !e.current() || e.generation != this.#m) return;
2574
- let t = this.#l.value;
2575
- if (t.flowId != e.flowId || !$(t.target, e.target) || t.selectedNodeIds.length > 0) return;
2576
- let n = this.#P().viewport;
2577
- if (n.x != e.viewport.x || n.y != e.viewport.y || n.zoom != e.viewport.zoom || t.draft == null) return;
2578
- let r = N(t.draft), i = [...e.targets].filter((t) => r.selection(e.target, t) != null);
2579
- i.length == 1 && this.#B({ nodeFocus: {
2580
- nodeId: i[0],
2581
- requestId: ++this.#y
2582
- } });
2583
- }
2584
- #M() {
2585
- this.#m += 1, this.#p != null && globalThis.clearTimeout(this.#p.timer), this.#p = void 0;
2586
- }
2587
- #N(e, t) {
2901
+ #M(e, t) {
2588
2902
  this.#o.advanceHead(e, t);
2589
2903
  }
2590
- #P() {
2904
+ #N() {
2591
2905
  let e = this.#l.value;
2592
- return M(e.draft, e.target, e.presentation?.value, e.diagnostics?.diagnostics, {}, {}, this.#r.t);
2593
- }
2594
- #F() {
2595
- let e = this.#l.value.moduleEditor;
2596
- return e == null || Z(this.#l.value.draft, e) == "saved" || (this.#c({
2597
- kind: "error",
2598
- message: this.#r.t("notice.unsavedCode")
2599
- }), !1);
2906
+ return b(e.draft, e.target, e.presentation?.value, e.diagnostics?.diagnostics, {}, {}, this.#r.t);
2600
2907
  }
2601
- #I(e) {
2602
- let t = N(e), n = zt(t, this.#l.value.target);
2908
+ #P(e) {
2909
+ let t = C(e), n = on(t, this.#l.value.target);
2603
2910
  return {
2604
2911
  revision: t,
2605
2912
  selectedNodeIds: this.#l.value.selectedNodeIds.filter((e) => n != null && t.selection(n, e) != null),
2606
2913
  target: n
2607
2914
  };
2608
2915
  }
2609
- #L(e, t) {
2610
- this.#t.replaceCommitted(e);
2611
- let n = this.#t.project(e), r = this.#l.value.moduleEditor, i = r != null && Z(this.#l.value.draft, r) != "saved", a = this.#I(n), o = a.target;
2612
- return this.#B({
2916
+ #F(e, t) {
2917
+ let n = this.#t.replaceCommitted(e), r = this.#l.value.moduleEditor, i = r != null && $(this.#l.value.draft, r) != "saved", a = this.#P(n), o = a.target;
2918
+ return this.#R({
2613
2919
  diagnostics: t ? this.#l.value.diagnostics : void 0,
2614
2920
  draft: n,
2615
- moduleEditor: this.#R(a.revision, o, a.selectedNodeIds),
2921
+ moduleEditor: this.#I(a.revision, o, a.selectedNodeIds),
2616
2922
  selectedNodeIds: a.selectedNodeIds,
2617
2923
  target: o
2618
2924
  }), i;
2619
2925
  }
2620
- #R(e, t, n) {
2926
+ #I(e, t, n) {
2621
2927
  let r = this.#l.value.moduleEditor;
2622
- return r == null || Z(this.#l.value.draft, r) == "saved" ? Q(e, t, n) : {
2928
+ return r == null || $(this.#l.value.draft, r) == "saved" ? rn(e, t, n) : {
2623
2929
  ...r,
2624
2930
  phase: "failed"
2625
2931
  };
2626
2932
  }
2627
- #z(e) {
2933
+ #L(e) {
2628
2934
  return !this.#_ && e.flowId == this.#l.value.flowId && e.current();
2629
2935
  }
2630
- #B(e) {
2631
- this.#_ || this.#l.set(e);
2936
+ #R(e) {
2937
+ if (this.#_) return;
2938
+ let t = Object.hasOwn(e, "moduleEditor") ? e.moduleEditor : this.#l.value.moduleEditor, n = t == null ? void 0 : this.#u.get(t.moduleId)?.editor ?? t, r = [...this.#u.values()].some((e) => e.editor.phase == "failed") ? "failed" : this.#u.size > 0 ? "saving" : void 0;
2939
+ this.#l.set({
2940
+ ...e,
2941
+ moduleEditor: n,
2942
+ moduleSaveStatus: r
2943
+ });
2632
2944
  }
2633
2945
  };
2634
2946
  //#endregion
2635
2947
  //#region src/workbench/browser/runtime/stores/workbenchStore.ts
2636
- function Vt(e) {
2948
+ function cn(e) {
2637
2949
  return new Map(e.nodes.map((e) => [e.id, e]));
2638
2950
  }
2639
- function Ht(e, t) {
2640
- return e == null || t == null ? [] : N(e).designerInputs(t);
2951
+ function ln(e, t) {
2952
+ return e == null || t == null ? [] : C(e).designerInputs(t);
2641
2953
  }
2642
- function Ut(e, t, n, r, i) {
2954
+ function un(e, t, n, r, i) {
2643
2955
  if (e == null || t?.kind != "flow" || n?.revisionId != e.revisionId || n.flowId != e.flowId) return /* @__PURE__ */ new Map();
2644
2956
  let a = r.find((t) => t.kind == "run.started" && t.payload.flowId == e.flowId)?.payload.scopeId;
2645
2957
  return typeof a == "string" ? new Map(r.flatMap((t) => {
@@ -2647,7 +2959,7 @@ function Ut(e, t, n, r, i) {
2647
2959
  return t.payload.scopeId == a && t.payload.flowId == e.flowId && typeof n == "string" && i.has(n) ? [[t.sequence, n]] : [];
2648
2960
  })) : /* @__PURE__ */ new Map();
2649
2961
  }
2650
- var Wt = { openExternalPage: async () => !1 }, Gt = class {
2962
+ var dn = { openExternalPage: async () => !1 }, fn = class {
2651
2963
  #e;
2652
2964
  #t;
2653
2965
  #n;
@@ -2658,36 +2970,55 @@ var Wt = { openExternalPage: async () => !1 }, Gt = class {
2658
2970
  #s;
2659
2971
  #c;
2660
2972
  #l;
2661
- constructor(r, i, a = () => crypto.randomUUID(), o = E(), s = Wt, c = !0) {
2662
- this.#t = new x(), this.#r = t(), this.#a = t([]), this.#o = t(!1), this.#s = t(!1), this.#c = new x(), this.#l = !1, this.provideAddNodeOptions = async (e, t) => await this.#u([this.triggers.provideAddNodeOptions(e, t), this.connectors.provideAddNodeOptions(e, t)], t), this.browseAddNodeOptions = async (e) => await this.#u([this.triggers.browseAddNodeOptions(e), this.connectors.browseAddNodeOptions(e)], e), this.provideAddNodeOptionChoices = async (e, t) => await (e.startsWith("trigger:") ? this.triggers.provideAddNodeOptionChoices(e, t) : this.connectors.provideAddNodeOptionChoices(e, t)), this.#e = r, this.#n = o, this.#i = c;
2973
+ #u;
2974
+ constructor(r, i, a = F, o = P(), s = dn, c = !0) {
2975
+ this.#t = new m(), this.#r = t(), this.#a = t([]), this.#o = t(!1), this.#s = t(!1), this.#c = !0, this.#u = !1, this.provideAddNodeOptions = async (e, t) => await this.#d([this.triggers.provideAddNodeOptions(e, t), this.connectors.provideAddNodeOptions(e, t)], t), this.browseAddNodeOptions = async (e) => {
2976
+ let t = await Promise.all([this.triggers.browseAddNodeOptions(e), this.connectors.browseAddNodeOptions(e)]);
2977
+ if (!(e.aborted || this.#u)) return t.flatMap((e) => e ?? []);
2978
+ }, this.provideAddNodeOptionChoices = async (e, t) => {
2979
+ if (!e.startsWith("trigger:")) return await this.connectors.provideAddNodeOptionChoices(e, t);
2980
+ }, this.#e = r, this.#n = o, this.#i = c;
2663
2981
  let l = (e) => {
2664
- this.#l || this.#r.set(e);
2982
+ this.#u || this.#r.set(e);
2665
2983
  };
2666
- this.runs = new O(r, l, o), this.workspace = new Bt(r, l, st, o, (e) => void this.#d(r, e)), this.connectors = new xt(r, this.workspace, l, s, o), this.triggers = new Dt(r, this.workspace, l, s, o), this.publications = new ut(r, this.workspace, l, a, o), this.runRequests = new ht(r, this.runs, l, o, a);
2667
- let u = /* @__PURE__ */ new Map(), d, f = n((e) => {
2984
+ this.runs = new h(r, l, o), this.workspace = new sn(r, l, Dt, o, (e) => {
2985
+ e.kind == "run.created" ? this.#f(r, e) : this.runs.changed(e.runId);
2986
+ }), this.connectors = new Ut(r, this.workspace, l, s, o), this.triggers = new Jt(r, this.workspace, l, s, o), this.publications = new jt(r, this.workspace, l, i, a, o), this.runRequests = new It(r, this.runs, l, async (e) => {
2987
+ if (!(e != this.workspace.$.flowId.value || !await this.workspace.saveModuleEditor() || this.#u || e != this.workspace.$.flowId.value)) return this.workspace.$.draft.value?.revisionId;
2988
+ }, o, a);
2989
+ let u = n((e) => {
2990
+ let t = e(this.workspace.$.diagnostics);
2991
+ if (t == null) return;
2992
+ let n = e(this.connectors.$.diagnostics);
2993
+ return n.length == 0 ? t : {
2994
+ ...t,
2995
+ diagnostics: [...t.diagnostics, ...n],
2996
+ valid: !1
2997
+ };
2998
+ }), d = /* @__PURE__ */ new Map(), f, p = n((e) => {
2668
2999
  let t = e(this.workspace.$.draft);
2669
- d != t?.flowId && (u.clear(), d = t?.flowId);
2670
- let n = e(this.workspace.$.target), r = e(this.workspace.$.presentation)?.value, i = e(this.workspace.$.diagnostics)?.diagnostics, a = e(this.connectors.$.actions), s = e(this.connectors.$.catalogs), c = e(o.t$), l = e(this.runs.$.run), f = e(this.runs.$.events), p = e(this.#a), m = e(this.#o), h = e(this.#s), g = n == null ? "" : n.kind == "flow" ? "flow" : `subflow:${n.id}`, _ = [
2671
- ...Ht(t, n),
2672
- r == null || n == null ? void 0 : se(r, n),
3000
+ f != t?.flowId && (d.clear(), f = t?.flowId);
3001
+ let n = e(this.workspace.$.target), r = e(this.workspace.$.presentation)?.value, i = e(u)?.diagnostics ?? e(this.connectors.$.diagnostics), a = e(this.connectors.$.actions), s = e(this.connectors.$.catalogs), c = e(o.t$), l = e(this.runs.$.run), p = e(this.runs.$.events), m = e(this.#a), h = e(this.#o), g = e(this.#s), _ = n == null ? "" : n.kind == "flow" ? "flow" : `subflow:${n.id}`, v = [
3002
+ ...ln(t, n),
3003
+ r == null || n == null ? void 0 : x(r, n),
2673
3004
  i,
2674
3005
  a,
2675
3006
  s,
2676
3007
  c,
2677
3008
  l,
2678
- f,
2679
3009
  p,
2680
3010
  m,
2681
3011
  h,
3012
+ g,
2682
3013
  ...l == null ? [] : [t?.revisionId]
2683
- ], v = u.get(g);
2684
- if (v != null && v.inputs.length == _.length && v.inputs.every((e, t) => e === _[t])) return v.graph;
2685
- let y = M(t, n, r, i, a, s, c, l, f, p, m, h, this.#i);
2686
- return u.set(g, {
2687
- graph: y,
2688
- inputs: _
2689
- }), y;
2690
- }), p = e(f, Vt);
3014
+ ], y = d.get(_);
3015
+ if (y != null && y.inputs.length == v.length && y.inputs.every((e, t) => e === v[t])) return y.graph;
3016
+ let S = b(t, n, r, i, a, s, c, l, p, m, h, g, this.#i);
3017
+ return d.set(_, {
3018
+ graph: S,
3019
+ inputs: v
3020
+ }), S;
3021
+ }), g = e(p, cn);
2691
3022
  this.$ = {
2692
3023
  busy: n((e) => {
2693
3024
  let t = e(this.workspace.$.busy);
@@ -2698,13 +3029,15 @@ var Wt = { openExternalPage: async () => !1 }, Gt = class {
2698
3029
  if (e(this.publications.$.rollingBackPublicationId) != null) return "rollback";
2699
3030
  if (e(this.publications.$.changingTriggerId) != null) return "trigger";
2700
3031
  }),
2701
- designer: f,
2702
- designerNodeById: p,
3032
+ diagnosticItems: n((e) => D(e(this.workspace.$.revision), e(this.workspace.$.target), e(u))),
3033
+ diagnostics: u,
3034
+ designer: p,
3035
+ designerNodeById: g,
2703
3036
  notice: this.#r,
2704
- runEventNodes: n((e) => Ut(e(this.workspace.$.draft), e(this.workspace.$.target), e(this.runs.$.run), e(this.runs.$.events), e(p))),
3037
+ runEventNodes: n((e) => un(e(this.workspace.$.draft), e(this.workspace.$.target), e(this.runs.$.run), e(this.runs.$.events), e(g))),
2705
3038
  selectedDesignerNode: n((e) => {
2706
3039
  let t = e(this.workspace.$.selectedNodeIds);
2707
- return t.length == 1 ? e(p).get(t[0]) : void 0;
3040
+ return t.length == 1 ? e(g).get(t[0]) : void 0;
2708
3041
  }),
2709
3042
  variableNames: this.#a,
2710
3043
  variableNamesLoaded: this.#o,
@@ -2712,7 +3045,7 @@ var Wt = { openExternalPage: async () => !1 }, Gt = class {
2712
3045
  };
2713
3046
  }
2714
3047
  dispose() {
2715
- this.#l = !0, this.#t.invalidate(), this.#c.invalidate();
3048
+ this.#u = !0, this.#t.invalidate();
2716
3049
  for (let e of Object.values(this.$)) e.dispose();
2717
3050
  this.connectors.dispose(), this.publications.dispose(), this.runRequests.dispose(), this.runs.dispose(), this.triggers.dispose(), this.workspace.dispose(), this.#a.dispose(), this.#o.dispose(), this.#s.dispose();
2718
3051
  }
@@ -2723,28 +3056,33 @@ var Wt = { openExternalPage: async () => !1 }, Gt = class {
2723
3056
  await this.workspace.reloadFlows();
2724
3057
  }
2725
3058
  dismissNotice() {
2726
- this.#l || this.#r.set(void 0);
3059
+ this.#u || this.#r.set(void 0);
3060
+ }
3061
+ invalidateVariableNames() {
3062
+ this.#c = !0;
2727
3063
  }
2728
3064
  async refreshVariableNames() {
2729
- if (this.#l || !this.#i) return;
2730
- let e = this.#c.begin();
2731
- this.#s.set(!0);
2732
- try {
2733
- let { variables: t } = await this.#e.listVariables();
2734
- if (!e() || this.#l) return;
2735
- this.#a.set(t.map((e) => e.name)), this.#o.set(!0);
2736
- } catch (t) {
2737
- e() && !this.#l && this.#r.set(R(t, this.#n.t));
2738
- } finally {
2739
- e() && !this.#l && this.#s.set(!1);
3065
+ if (!(this.#u || !this.#i)) {
3066
+ if (this.#l != null) return this.#l;
3067
+ if (this.#c) return this.#c = !1, this.#s.set(!0), this.#l = (async () => {
3068
+ try {
3069
+ let { variables: e } = await this.#e.listVariables();
3070
+ if (this.#u) return;
3071
+ this.#a.set(e.map((e) => e.name)), this.#o.set(!0);
3072
+ } catch (e) {
3073
+ this.#c = !0, this.#u || this.#r.set(E(e, this.#n.t));
3074
+ } finally {
3075
+ this.#l = void 0, this.#u || this.#s.set(!1);
3076
+ }
3077
+ })(), this.#l;
2740
3078
  }
2741
3079
  }
2742
3080
  async selectFlow(e) {
2743
- return this.#l || (this.#t.invalidate(), this.#r.set(void 0), !await this.workspace.selectFlow(e)) ? !1 : (this.connectors.reset(), this.triggers.reset(), this.publications.reset(), this.runRequests.reset(), this.runs.reset(), !0);
3081
+ return this.#u || (this.#t.invalidate(), this.#r.set(void 0), !await this.workspace.selectFlow(e)) ? !1 : (this.connectors.reset(), this.triggers.reset(), this.publications.reset(), this.runRequests.reset(), this.runs.reset(), !0);
2744
3082
  }
2745
3083
  async createFlow(e, t) {
2746
3084
  let n = await this.workspace.createFlow(e, t);
2747
- return this.#l || n == null ? !1 : (await this.selectFlow(n.flowId), this.#l || this.#r.set({
3085
+ return this.#u || n == null ? !1 : (await this.selectFlow(n.flowId), this.#u || this.#r.set({
2748
3086
  kind: "success",
2749
3087
  message: this.#n.t("notice.created", { name: n.name })
2750
3088
  }), !0);
@@ -2760,6 +3098,10 @@ var Wt = { openExternalPage: async () => !1 }, Gt = class {
2760
3098
  let t = this.$.runEventNodes.value.get(e);
2761
3099
  return t != null && this.workspace.locateNode(t);
2762
3100
  }
3101
+ locateRunWait() {
3102
+ let e = this.runs.$.run.value;
3103
+ return e?.status != "waiting" || !("waiting" in e) || e.waiting == null || !this.workspace.selectTarget({ kind: "flow" }) ? !1 : this.workspace.locateNode(e.waiting.nodeId);
3104
+ }
2763
3105
  async addNode(e, t, n) {
2764
3106
  if (e.kind == "trigger" && "trigger" in e && e.trigger.kind == "connect") {
2765
3107
  await this.triggers.connect(e.trigger.provider);
@@ -2768,43 +3110,45 @@ var Wt = { openExternalPage: async () => !1 }, Gt = class {
2768
3110
  let r = await this.workspace.addNode(e, t, n);
2769
3111
  return r != null && e.kind == "connector" && this.connectors.refresh(), r != null && e.kind == "trigger" && this.triggers.refresh(), r;
2770
3112
  }
2771
- async #u(e, t) {
3113
+ async #d(e, t) {
2772
3114
  let n = await Promise.allSettled(e);
2773
- if (t.aborted || this.#l) return;
3115
+ if (t.aborted || this.#u) return;
2774
3116
  let r = n.filter((e) => e.status == "rejected");
2775
3117
  if (r.length > 0 && r.length == n.length) throw r[0].reason;
2776
- return r.length > 0 && this.#r.set(R(r[0].reason, this.#n.t)), n.flatMap((e) => e.status == "fulfilled" ? e.value ?? [] : []);
3118
+ return r.length > 0 && this.#r.set(E(r[0].reason, this.#n.t)), n.flatMap((e) => e.status == "fulfilled" ? e.value ?? [] : []);
2777
3119
  }
2778
3120
  async refreshSelectedConnector(e = !1) {
2779
3121
  await this.connectors.refresh(e);
2780
3122
  }
2781
- async requestDraftRun() {
2782
- let e = this.workspace.$.targetFlow.value, t = this.workspace.$.draft.value;
2783
- return e == null || t == null ? "unavailable" : await this.runRequests.requestDraft(e, t);
3123
+ async requestDraftRun(e) {
3124
+ let t = this.workspace.$.flowId.value;
3125
+ if (!await this.workspace.saveModuleEditor() || this.#u || t != this.workspace.$.flowId.value) return "unavailable";
3126
+ let n = this.workspace.$.targetFlow.value, r = this.workspace.$.draft.value;
3127
+ return n == null || r == null ? "unavailable" : await this.runRequests.requestDraft(n, r, e);
2784
3128
  }
2785
3129
  async requestLiveRun() {
2786
3130
  let e = this.workspace.$.targetFlow.value;
2787
3131
  return e == null ? "unavailable" : await this.runRequests.requestLive(e);
2788
3132
  }
2789
- async #d(e, t) {
3133
+ async #f(e, t) {
2790
3134
  let n = this.workspace.$.target.value;
2791
- if (this.#l || this.runRequests.$.submitting.value != null || n?.kind != "flow" || this.workspace.$.flowId.value != t.flowId) return;
3135
+ if (this.#u || this.runRequests.$.submitting.value != null || n?.kind != "flow" || this.workspace.$.flowId.value != t.flowId) return;
2792
3136
  let r = this.#t.begin();
2793
3137
  try {
2794
3138
  let n = await e.getRun(t.runId), i = this.workspace.$.target.value;
2795
- if (!r() || this.#l || i?.kind != "flow" || this.workspace.$.flowId.value != t.flowId || n.flowId != t.flowId || n.runId != t.runId) return;
3139
+ if (!r() || this.#u || i?.kind != "flow" || this.workspace.$.flowId.value != t.flowId || n.flowId != t.flowId || n.runId != t.runId) return;
2796
3140
  this.runs.followExternal(n);
2797
3141
  } catch {
2798
3142
  return;
2799
3143
  }
2800
3144
  }
2801
- }, Kt = He(() => import("./flowWorkspace-DwyxAOBH.js").then((e) => e.t));
2802
- function qt({ action: e, description: t, error: n, onSubmit: r, onTokenChange: i, pending: a = !1, title: o, token: s, tokenLabel: f }) {
2803
- let g = s != null && f != null && i != null, _ = s ?? "", v = /* @__PURE__ */ H(We, { children: [
2804
- /* @__PURE__ */ V("div", {
3145
+ }, pn = ot(() => import("./flowWorkspace-Dp_b8KXF.js").then((e) => e.t));
3146
+ function mn({ action: e, description: t, error: n, onSubmit: r, onTokenChange: i, pending: a = !1, title: o, token: s, tokenLabel: c }) {
3147
+ let l = s != null && c != null && i != null, u = s ?? "", d = /* @__PURE__ */ J(st, { children: [
3148
+ /* @__PURE__ */ q("div", {
2805
3149
  "aria-hidden": "true",
2806
3150
  className: "flex size-10 items-center justify-center rounded-lg bg-muted text-muted-foreground",
2807
- children: /* @__PURE__ */ H("svg", {
3151
+ children: /* @__PURE__ */ J("svg", {
2808
3152
  className: "size-5",
2809
3153
  fill: "none",
2810
3154
  stroke: "currentColor",
@@ -2812,40 +3156,40 @@ function qt({ action: e, description: t, error: n, onSubmit: r, onTokenChange: i
2812
3156
  strokeLinejoin: "round",
2813
3157
  strokeWidth: "1.8",
2814
3158
  viewBox: "0 0 24 24",
2815
- children: [/* @__PURE__ */ V("rect", {
3159
+ children: [/* @__PURE__ */ q("rect", {
2816
3160
  height: "9",
2817
3161
  rx: "2",
2818
3162
  width: "14",
2819
3163
  x: "5",
2820
3164
  y: "11"
2821
- }), /* @__PURE__ */ V("path", { d: "M8 11V8a4 4 0 0 1 8 0v3" })]
3165
+ }), /* @__PURE__ */ q("path", { d: "M8 11V8a4 4 0 0 1 8 0v3" })]
2822
3166
  })
2823
3167
  }),
2824
- /* @__PURE__ */ H("header", {
3168
+ /* @__PURE__ */ J("header", {
2825
3169
  className: "flex flex-col gap-2",
2826
- children: [/* @__PURE__ */ V("h1", {
3170
+ children: [/* @__PURE__ */ q("h1", {
2827
3171
  className: "text-xl font-semibold tracking-tight text-balance",
2828
3172
  children: o
2829
- }), /* @__PURE__ */ V("p", {
3173
+ }), /* @__PURE__ */ q("p", {
2830
3174
  className: "text-sm/relaxed text-muted-foreground text-pretty",
2831
3175
  children: t
2832
3176
  })]
2833
3177
  }),
2834
- g && /* @__PURE__ */ V(h, { children: /* @__PURE__ */ H(u, {
3178
+ l && /* @__PURE__ */ q(Fe, { children: /* @__PURE__ */ J(Ve, {
2835
3179
  "data-invalid": n != null,
2836
3180
  children: [
2837
- /* @__PURE__ */ V(m, {
3181
+ /* @__PURE__ */ q(Pe, {
2838
3182
  htmlFor: "session-token",
2839
- children: f
3183
+ children: c
2840
3184
  }),
2841
- /* @__PURE__ */ V(c, {
3185
+ /* @__PURE__ */ q(V, {
2842
3186
  autoComplete: "username",
2843
3187
  name: "username",
2844
3188
  type: "hidden",
2845
3189
  value: "open-flow",
2846
3190
  readOnly: !0
2847
3191
  }),
2848
- /* @__PURE__ */ V(c, {
3192
+ /* @__PURE__ */ q(V, {
2849
3193
  autoComplete: "current-password",
2850
3194
  "aria-invalid": n != null,
2851
3195
  autoFocus: !0,
@@ -2855,133 +3199,137 @@ function qt({ action: e, description: t, error: n, onSubmit: r, onTokenChange: i
2855
3199
  onChange: (e) => i?.(e.target.value),
2856
3200
  spellCheck: !1,
2857
3201
  type: "password",
2858
- value: _
3202
+ value: u
2859
3203
  }),
2860
- n != null && /* @__PURE__ */ V(l, { children: n })
3204
+ n != null && /* @__PURE__ */ q(Be, { children: n })
2861
3205
  ]
2862
3206
  }) }),
2863
- e != null && r != null && /* @__PURE__ */ H(p, {
2864
- disabled: a || g && _.length == 0,
3207
+ e != null && r != null && /* @__PURE__ */ J(B, {
3208
+ disabled: a || l && u.length == 0,
2865
3209
  size: "lg",
2866
3210
  type: "submit",
2867
- children: [a && /* @__PURE__ */ V(d, {
3211
+ children: [a && /* @__PURE__ */ q(Ie, {
2868
3212
  "aria-label": e,
2869
3213
  "data-icon": "inline-start"
2870
3214
  }), e]
2871
3215
  }),
2872
- a && e == null && /* @__PURE__ */ V(d, { "aria-label": t })
2873
- ] }), y = "m-auto flex w-full max-w-[420px] flex-col gap-5 rounded-xl bg-card p-6 shadow-lg shadow-black/10";
2874
- return /* @__PURE__ */ V("main", {
3216
+ a && e == null && /* @__PURE__ */ q(Ie, { "aria-label": t })
3217
+ ] }), f = "m-auto flex w-full max-w-[420px] flex-col gap-5 rounded-xl bg-card p-6 shadow-lg shadow-black/10";
3218
+ return /* @__PURE__ */ q("main", {
2875
3219
  className: "open-flow-workbench",
2876
- children: /* @__PURE__ */ V("div", {
3220
+ children: /* @__PURE__ */ q("div", {
2877
3221
  className: "grid h-full overflow-auto bg-muted/20 p-4",
2878
- children: r == null ? /* @__PURE__ */ V("section", {
3222
+ children: r == null ? /* @__PURE__ */ q("section", {
2879
3223
  "aria-busy": a,
2880
- className: y,
2881
- children: v
2882
- }) : /* @__PURE__ */ V("form", {
3224
+ className: f,
3225
+ children: d
3226
+ }) : /* @__PURE__ */ q("form", {
2883
3227
  "aria-busy": a,
2884
- className: y,
3228
+ className: f,
2885
3229
  onSubmit: r,
2886
- children: v
3230
+ children: d
2887
3231
  })
2888
3232
  })
2889
3233
  });
2890
3234
  }
2891
- function Jt({ host: e, store: t }) {
3235
+ function hn({ host: e, store: t }) {
2892
3236
  let n = a(t.$.notice);
2893
- return z(() => e.notify(n), [e, n]), z(() => () => e.notify(void 0), [e]), null;
3237
+ return W(() => e.notify(n), [e, n]), W(() => () => e.notify(void 0), [e]), null;
2894
3238
  }
2895
- function Yt({ createFlow: e, createFlowDisabled: t, createFlowField: n, flowBadges: r, hrefFor: i, hostAction: o, hostTitle: s, language: c, navigation: l, onHostAction: u, onLanguageChange: d, store: f, theme: p }) {
2896
- let m = a(f.workspace.$.flowId);
2897
- return /* @__PURE__ */ V("div", {
3239
+ function gn({ catalogWidth: e, createFlow: t, createFlowDisabled: n, createFlowField: r, flowBadges: i, hrefFor: o, hostAction: s, hostTitle: c, language: l, navigation: u, onConfigureConnector: d, onHostAction: f, onLanguageChange: p, store: m, theme: h }) {
3240
+ let g = a(m.workspace.$.flowId);
3241
+ return /* @__PURE__ */ q("div", {
2898
3242
  className: "app-shell",
2899
- children: m == null ? /* @__PURE__ */ V(Qe, {
2900
- createFlowDisabled: t,
2901
- createFlowField: n,
2902
- flowBadges: r,
2903
- hrefForFlow: (e) => i({
3243
+ children: g == null ? /* @__PURE__ */ q(vt, {
3244
+ catalogWidth: e,
3245
+ createFlowDisabled: n,
3246
+ createFlowField: r,
3247
+ flowBadges: i,
3248
+ hrefForFlow: (e) => o({
2904
3249
  flowId: e.flowId,
2905
3250
  view: "design"
2906
3251
  }),
2907
- hostAction: o,
2908
- hostTitle: s,
2909
- language: c,
2910
- onCreateFlow: (t) => l.createFlow(t, e),
2911
- onHostAction: u,
2912
- onLanguageChange: d,
2913
- onSelectFlow: (e) => void l.selectFlow(e),
2914
- store: f
2915
- }) : /* @__PURE__ */ V(Ve, {
2916
- fallback: /* @__PURE__ */ V("main", {
3252
+ hostAction: s,
3253
+ hostTitle: c,
3254
+ language: l,
3255
+ onCreateFlow: (e) => u.createFlow(e, t),
3256
+ onHostAction: f,
3257
+ onLanguageChange: p,
3258
+ onSelectFlow: (e) => void u.selectFlow(e),
3259
+ store: m
3260
+ }) : /* @__PURE__ */ q(at, {
3261
+ fallback: /* @__PURE__ */ q("main", {
2917
3262
  "aria-busy": "true",
2918
3263
  className: "workspace"
2919
3264
  }),
2920
- children: /* @__PURE__ */ V(Kt, {
2921
- hostAction: o,
2922
- hostTitle: s,
2923
- hrefFor: i,
2924
- navigation: l,
2925
- onHostAction: u,
2926
- store: f,
2927
- theme: p
3265
+ children: /* @__PURE__ */ q(pn, {
3266
+ hostAction: s,
3267
+ hostTitle: c,
3268
+ hrefFor: o,
3269
+ navigation: u,
3270
+ onConfigureConnector: d,
3271
+ onHostAction: f,
3272
+ store: m,
3273
+ theme: h
2928
3274
  })
2929
3275
  })
2930
3276
  });
2931
3277
  }
2932
- function Xt({ createFlow: e, createFlowDisabled: t, createFlowField: n, flowBadges: r, host: i, hostAction: a, hostTitle: s, hrefFor: c, language: l, location: u, onHostAction: d, onLanguageChange: f, onNavigate: p, preferences: m, theme: h, variables: g = !0 }) {
2933
- let _ = Ue(p);
2934
- _.current = p;
2935
- let [{ i18n: v, navigation: y, store: b }] = B(() => {
2936
- let e = E(l), t = new Gt(new k((e, t) => i.request(e, t), (e, t) => i.subscribeFlow(e, t), (e) => i.subscribeFlowCatalog(e)), m, () => crypto.randomUUID(), e, i, g);
3278
+ function _n({ catalogWidth: e, createFlow: t, createFlowDisabled: n, createFlowField: r, flowBadges: i, host: a, hostAction: s, hostTitle: c, hrefFor: l, language: u, location: d, onConfigureConnector: f, onHostAction: p, onLanguageChange: m, onNavigate: h, preferences: g, theme: _, variables: v = !0 }) {
3279
+ let y = G(h);
3280
+ y.current = h;
3281
+ let [{ i18n: b, navigation: x, store: S }] = K(() => {
3282
+ let e = P(u), t = new fn(new ye((e, t) => a.request(e, t), (e, t) => a.subscribeFlow(e, t), (e) => a.subscribeFlowCatalog(e)), g, F, e, a, v);
2937
3283
  return {
2938
3284
  i18n: e,
2939
- navigation: new Ge(t, u, (e, t) => _.current(e, t)),
3285
+ navigation: new dt(t, d, (e, t) => y.current(e, t)),
2940
3286
  store: t
2941
3287
  };
2942
3288
  });
2943
- return z(() => {
2944
- y.start();
3289
+ return W(() => {
3290
+ x.start();
2945
3291
  let e = () => {
2946
- b.connectors.refreshAfterAuthorization(), b.triggers.refreshAfterAuthorization(), b.refreshVariableNames();
3292
+ S.connectors.refreshAfterAuthorization(), S.triggers.refreshAfterAuthorization(), S.invalidateVariableNames();
2947
3293
  };
2948
3294
  return globalThis.addEventListener("focus", e), () => {
2949
- globalThis.removeEventListener("focus", e), y.dispose(), b.dispose(), v.dispose();
3295
+ globalThis.removeEventListener("focus", e), x.dispose(), S.dispose(), b.dispose();
2950
3296
  };
2951
3297
  }, [
2952
- v,
2953
- y,
2954
- b
2955
- ]), z(() => void y.apply(u), [u, y]), z(() => {
2956
- v.lang != l && v.switchLang(l);
2957
- }, [v, l]), /* @__PURE__ */ V(o, {
2958
- i18n: v,
2959
- children: /* @__PURE__ */ H("div", {
3298
+ b,
3299
+ x,
3300
+ S
3301
+ ]), W(() => void x.apply(d), [d, x]), W(() => {
3302
+ b.lang != u && b.switchLang(u);
3303
+ }, [b, u]), /* @__PURE__ */ q(o, {
3304
+ i18n: b,
3305
+ children: /* @__PURE__ */ J("div", {
2960
3306
  className: "open-flow-theme open-flow-workbench",
2961
- "data-theme": h,
2962
- children: [/* @__PURE__ */ V(Jt, {
2963
- host: i,
2964
- store: b
2965
- }), /* @__PURE__ */ V(Yt, {
2966
- createFlow: e,
2967
- createFlowDisabled: t,
2968
- createFlowField: n,
2969
- flowBadges: r,
2970
- hostAction: a,
2971
- hostTitle: s,
2972
- hrefFor: c,
2973
- language: l,
2974
- navigation: y,
2975
- onHostAction: d,
2976
- onLanguageChange: f,
2977
- store: b,
2978
- theme: h
3307
+ "data-theme": _,
3308
+ children: [/* @__PURE__ */ q(hn, {
3309
+ host: a,
3310
+ store: S
3311
+ }), /* @__PURE__ */ q(gn, {
3312
+ catalogWidth: e,
3313
+ createFlow: t,
3314
+ createFlowDisabled: n,
3315
+ createFlowField: r,
3316
+ flowBadges: i,
3317
+ hostAction: s,
3318
+ hostTitle: c,
3319
+ hrefFor: l,
3320
+ language: u,
3321
+ navigation: x,
3322
+ onConfigureConnector: f,
3323
+ onHostAction: p,
3324
+ onLanguageChange: m,
3325
+ store: S,
3326
+ theme: _
2979
3327
  })]
2980
3328
  })
2981
3329
  });
2982
3330
  }
2983
- function Zt({ sessionKey: e, ...t }) {
2984
- return /* @__PURE__ */ V(Xt, { ...t }, e);
3331
+ function vn({ sessionKey: e, ...t }) {
3332
+ return /* @__PURE__ */ q(_n, { ...t }, e);
2985
3333
  }
2986
3334
  //#endregion
2987
- export { qt as OpenFlowSessionGate, Zt as OpenFlowWorkbench, ze as isWorkbenchLanguage, Be as resolveWorkbenchLanguage, Re as workbenchLanguageNames, Le as workbenchLanguages };
3335
+ export { mn as OpenFlowSessionGate, vn as OpenFlowWorkbench, Xe as isWorkbenchLanguage, Je as resolveWorkbenchLanguage, Ye as workbenchLanguageNames, qe as workbenchLanguages };