@oomol-lab/open-flow 0.1.0-beta.2 → 0.1.0-beta.20

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