@w6w/ui 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/LICENSE +21 -0
  3. package/README.md +275 -2
  4. package/dist/ActionTestForm.d.ts +76 -0
  5. package/dist/AddConnectionModal.d.ts +24 -0
  6. package/dist/AppPicker.d.ts +83 -0
  7. package/dist/CodeBlock-CZu4TFSi.cjs +15 -0
  8. package/dist/CodeBlock-CZu4TFSi.cjs.map +1 -0
  9. package/dist/CodeBlock-Dot3Pd7P.js +2889 -0
  10. package/dist/CodeBlock-Dot3Pd7P.js.map +1 -0
  11. package/dist/CodeBlock.d.ts +65 -0
  12. package/dist/CodeEditor.d.ts +42 -0
  13. package/dist/ConfirmModal-8avl9Nv8.cjs +11 -0
  14. package/dist/ConfirmModal-8avl9Nv8.cjs.map +1 -0
  15. package/dist/ConfirmModal-CD-P8mhN.js +6335 -0
  16. package/dist/ConfirmModal-CD-P8mhN.js.map +1 -0
  17. package/dist/Copyable-1niV9gUa.js +771 -0
  18. package/dist/Copyable-1niV9gUa.js.map +1 -0
  19. package/dist/Copyable-CYZU1o4X.cjs +2 -0
  20. package/dist/Copyable-CYZU1o4X.cjs.map +1 -0
  21. package/dist/JsonEditor.d.ts +60 -0
  22. package/dist/NodeConfigForm.d.ts +70 -0
  23. package/dist/ParamsForm.d.ts +56 -0
  24. package/dist/PropertyEntryForm.d.ts +56 -0
  25. package/dist/RetryPolicyFields.d.ts +18 -0
  26. package/dist/StepBuilderModal.d.ts +375 -0
  27. package/dist/TriggerFillForm.d.ts +52 -0
  28. package/dist/WaitEditor.d.ts +6 -0
  29. package/dist/WorkflowFlowEditor.d.ts +119 -0
  30. package/dist/YamlEditor.d.ts +46 -0
  31. package/dist/app-categories.d.ts +38 -0
  32. package/dist/app-pages.d.ts +111 -0
  33. package/dist/code.cjs +2 -0
  34. package/dist/code.cjs.map +1 -0
  35. package/dist/code.d.ts +29 -0
  36. package/dist/code.mjs +8 -0
  37. package/dist/code.mjs.map +1 -0
  38. package/dist/components/ApiCallsPanel.d.ts +41 -0
  39. package/dist/components/AppIcon.d.ts +25 -0
  40. package/dist/components/AuthFieldsForm.d.ts +22 -0
  41. package/dist/components/Combobox.d.ts +24 -0
  42. package/dist/components/ConfirmModal.d.ts +33 -0
  43. package/dist/components/Copyable.d.ts +51 -0
  44. package/dist/components/CopyableText.d.ts +40 -0
  45. package/dist/components/DeleteButton.d.ts +16 -0
  46. package/dist/components/EditButton.d.ts +10 -0
  47. package/dist/components/ExecutionDetail.d.ts +70 -0
  48. package/dist/components/ExecutionFilters.d.ts +59 -0
  49. package/dist/components/ExecutionList.d.ts +60 -0
  50. package/dist/components/ExecutionLogPanel.d.ts +98 -0
  51. package/dist/components/ExecutionStats.d.ts +47 -0
  52. package/dist/components/ExpressionEditorModal.d.ts +42 -0
  53. package/dist/components/ExpressionInput.d.ts +36 -0
  54. package/dist/components/ExpressionOptions.d.ts +185 -0
  55. package/dist/components/HealthStatusPill.d.ts +25 -0
  56. package/dist/components/HistoryTimeline.d.ts +56 -0
  57. package/dist/components/Icon.d.ts +34 -0
  58. package/dist/components/IconButton.d.ts +60 -0
  59. package/dist/components/InfoTip.d.ts +15 -0
  60. package/dist/components/InternalIcon.d.ts +19 -0
  61. package/dist/components/ListItem.d.ts +25 -0
  62. package/dist/components/Modal.d.ts +29 -0
  63. package/dist/components/RepoSyncIndicator.d.ts +29 -0
  64. package/dist/components/ResolvedParams.d.ts +31 -0
  65. package/dist/components/ServerResources.d.ts +47 -0
  66. package/dist/components/StepStatusPill.d.ts +51 -0
  67. package/dist/components/UptimeStrip.d.ts +56 -0
  68. package/dist/components/execution-format.d.ts +24 -0
  69. package/dist/components/expression-dom.d.ts +154 -0
  70. package/dist/components/expression-template.d.ts +86 -0
  71. package/dist/components/history-scale.d.ts +33 -0
  72. package/dist/components/icons.d.ts +41 -0
  73. package/dist/components/resolved-clip.d.ts +42 -0
  74. package/dist/components/server-resources-format.d.ts +68 -0
  75. package/dist/components/server-resources.fixture.d.ts +9 -0
  76. package/dist/components/use-copy.d.ts +14 -0
  77. package/dist/createW6WApi.d.ts +31 -0
  78. package/dist/flow-connect.d.ts +138 -0
  79. package/dist/flow-fanout.d.ts +15 -0
  80. package/dist/flow-types.d.ts +356 -0
  81. package/dist/flow-utils.d.ts +284 -0
  82. package/dist/flow.cjs +3 -0
  83. package/dist/flow.cjs.map +1 -0
  84. package/dist/flow.d.ts +24 -0
  85. package/dist/flow.mjs +1978 -0
  86. package/dist/flow.mjs.map +1 -0
  87. package/dist/index.cjs +2 -0
  88. package/dist/index.cjs.map +1 -0
  89. package/dist/index.d.ts +94 -0
  90. package/dist/index.mjs +1812 -0
  91. package/dist/index.mjs.map +1 -0
  92. package/dist/oauth-popup.d.ts +17 -0
  93. package/dist/output-shape.d.ts +58 -0
  94. package/dist/provider.d.ts +421 -0
  95. package/dist/resolve-params.d.ts +112 -0
  96. package/dist/resolved-json.d.ts +21 -0
  97. package/dist/run-visuals.d.ts +90 -0
  98. package/dist/step-preview-state.d.ts +143 -0
  99. package/dist/theme.d.ts +32 -0
  100. package/dist/trigger-fields.d.ts +56 -0
  101. package/dist/types.d.ts +413 -0
  102. package/dist/use-app-action-defs.d.ts +7 -0
  103. package/dist/use-enter-submit.d.ts +23 -0
  104. package/dist/use-seed-sources.d.ts +16 -0
  105. package/package.json +112 -3
  106. package/src/code.css +561 -0
  107. package/src/styles/_buttons.scss +38 -0
  108. package/src/styles/_chips.scss +210 -0
  109. package/src/styles/_code.scss +139 -0
  110. package/src/styles/_copyable.scss +147 -0
  111. package/src/styles/_data-vars.scss +38 -0
  112. package/src/styles/_execution-history.scss +282 -0
  113. package/src/styles/_execution-log.scss +178 -0
  114. package/src/styles/_expression-field.scss +65 -0
  115. package/src/styles/_expression-inline.scss +63 -0
  116. package/src/styles/_expression-modal.scss +292 -0
  117. package/src/styles/_fields.scss +161 -0
  118. package/src/styles/_flow.scss +217 -0
  119. package/src/styles/_fx.scss +158 -0
  120. package/src/styles/_health.scss +46 -0
  121. package/src/styles/_history-timeline.scss +156 -0
  122. package/src/styles/_icon-button.scss +22 -0
  123. package/src/styles/_icon.scss +15 -0
  124. package/src/styles/_icons.scss +31 -0
  125. package/src/styles/_incoming-state.scss +46 -0
  126. package/src/styles/_info-tip.scss +9 -0
  127. package/src/styles/_layout.scss +6 -0
  128. package/src/styles/_lists.scss +64 -0
  129. package/src/styles/_modal.scss +125 -0
  130. package/src/styles/_multiselect.scss +69 -0
  131. package/src/styles/_repo-sync-indicator.scss +99 -0
  132. package/src/styles/_scale.scss +70 -0
  133. package/src/styles/_sections.scss +36 -0
  134. package/src/styles/_server-resources.scss +163 -0
  135. package/src/styles/_step-builder.scss +376 -0
  136. package/src/styles/_step-config.scss +195 -0
  137. package/src/styles/_tabs.scss +54 -0
  138. package/src/styles/_tester.scss +111 -0
  139. package/src/styles/_tokens.scss +160 -0
  140. package/src/styles/_uptime.scss +61 -0
  141. package/src/styles.css +4894 -0
  142. package/src/styles.scss +61 -0
package/dist/index.mjs ADDED
@@ -0,0 +1,1812 @@
1
+ "use client";
2
+ var Tt = Object.defineProperty;
3
+ var At = (e, s, n) => s in e ? Tt(e, s, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[s] = n;
4
+ var V = (e, s, n) => At(e, typeof s != "symbol" ? s + "" : s, n);
5
+ import { j as Et, a0 as Mt, J as z, ab as _t, M as Ve, L as Pt, l as It, am as L } from "./ConfirmModal-CD-P8mhN.js";
6
+ import { aa as en, Q as tn, a9 as sn, an as nn, ao as an, ap as rn, H as ln, a1 as on, a8 as cn, aq as dn, S as un, ar as wn, as as mn, at as hn, au as pn, av as fn, Y as vn, aw as yn, ax as Nn, ay as gn, u as bn } from "./ConfirmModal-CD-P8mhN.js";
7
+ import { jsxs as o, jsx as t, Fragment as k } from "react/jsx-runtime";
8
+ import { useMemo as ye, useState as v, useEffect as G, useId as Ut, useRef as Ft } from "react";
9
+ import { C as ke } from "./CodeBlock-Dot3Pd7P.js";
10
+ import { yaml as Lt } from "@codemirror/lang-yaml";
11
+ import { EditorView as Bt } from "@codemirror/view";
12
+ import Jt from "@uiw/react-codemirror";
13
+ import { u as Dt, a as Ht, b as jt, C as qt, I as ze } from "./Copyable-1niV9gUa.js";
14
+ import { i as xn } from "./Copyable-1niV9gUa.js";
15
+ class ce extends Error {
16
+ constructor(n, l, d, a) {
17
+ super(d);
18
+ V(this, "status");
19
+ V(this, "code");
20
+ /**
21
+ * The parsed error response body, when the server sent one. Carries the
22
+ * fields that ride alongside an error — e.g. an invoke's `logs` and
23
+ * `apiCalls` — which the message alone would drop.
24
+ */
25
+ V(this, "body");
26
+ this.name = "ApiError", this.status = n, this.code = l, this.body = a;
27
+ }
28
+ }
29
+ function _s(e) {
30
+ const s = e.baseUrl.replace(/\/$/, ""), n = e.fetch ?? globalThis.fetch, l = async () => typeof e.token == "function" ? await e.token() : e.token;
31
+ async function d(r, c) {
32
+ const u = new Headers(c == null ? void 0 : c.headers), w = await l();
33
+ w && u.set("authorization", `Bearer ${w}`), c != null && c.body && !u.has("content-type") && u.set("content-type", "application/json");
34
+ let h;
35
+ try {
36
+ h = await n(`${s}${r}`, { ...c, headers: u });
37
+ } catch (N) {
38
+ throw new ce(
39
+ 0,
40
+ "network_error",
41
+ `Could not reach the w6w server (${(c == null ? void 0 : c.method) ?? "GET"} ${s}${r}). It may be down or unreachable. (${N.message})`
42
+ );
43
+ }
44
+ const m = await h.text();
45
+ let p = null;
46
+ if (m)
47
+ try {
48
+ p = JSON.parse(m);
49
+ } catch {
50
+ if (!h.ok)
51
+ throw new ce(
52
+ h.status,
53
+ "bad_response",
54
+ `Server returned a non-JSON ${h.status} response: ${m.slice(0, 200)}`
55
+ );
56
+ }
57
+ if (!h.ok) {
58
+ const N = (p == null ? void 0 : p.error) ?? {};
59
+ throw new ce(h.status, N.code ?? "error", N.message ?? h.statusText, p);
60
+ }
61
+ return { status: h.status, data: p };
62
+ }
63
+ async function a(r, c) {
64
+ const { data: u } = await d(r, c);
65
+ return u;
66
+ }
67
+ return {
68
+ // A bare GET only returns the server's default page (50) — every consumer
69
+ // of this client treats the result as the complete catalog, so page
70
+ // through it here. Capped at 20 pages as a runaway backstop.
71
+ listApps: async () => {
72
+ const r = [];
73
+ let c;
74
+ for (let u = 0; u < 20; u++) {
75
+ const w = new URLSearchParams({ limit: "200" });
76
+ c && w.set("cursor", c);
77
+ const h = await a(`/apps?${w}`);
78
+ if (r.push(...h.apps), !h.nextCursor) break;
79
+ c = h.nextCursor;
80
+ }
81
+ return r;
82
+ },
83
+ // Bounded lookup: dedupe; `[]` sends nothing; chunks of <= 100 (the server's
84
+ // `MAX_IDS_PER_QUERY`), each `GET /apps?ids=a,b` with no limit/cursor.
85
+ listAppsByIds: async (r) => {
86
+ const c = Array.from(new Set(r)), u = [];
87
+ for (let w = 0; w < c.length; w += 100) {
88
+ const m = c.slice(w, w + 100).map(encodeURIComponent).join(","), p = await a(`/apps?ids=${m}`);
89
+ u.push(...p.apps);
90
+ }
91
+ return u;
92
+ },
93
+ getAppAuth: async (r) => (await a(`/apps/${encodeURIComponent(r)}/auths`)).auths ?? [],
94
+ createConnection: (r, c) => a(`/apps/${encodeURIComponent(r)}/connections`, {
95
+ method: "POST",
96
+ body: JSON.stringify(c)
97
+ }).then((u) => u.connection),
98
+ startAppOAuthFlow: (r, c, u) => a(
99
+ `/apps/${encodeURIComponent(r)}/oauth-config/${encodeURIComponent(c)}/authorize-url`,
100
+ { method: "POST", body: JSON.stringify(u) }
101
+ ),
102
+ getAppActions: (r) => a(`/apps/${encodeURIComponent(r)}`).then(
103
+ (c) => c.actions ?? []
104
+ ),
105
+ listConnectionsForApp: (r) => a(
106
+ `/apps/${encodeURIComponent(r)}/connections`
107
+ ).then((c) => c.connections ?? []),
108
+ listConnections: () => a("/connections").then((r) => r.connections ?? []),
109
+ invokeAction: (r, c, u, w = {}) => a(
110
+ `/apps/${encodeURIComponent(r)}/actions/${encodeURIComponent(c)}/invoke`,
111
+ // This body is built KEY BY KEY, not by spreading `opts` — so every new
112
+ // option has to be named here or it is silently dropped before the wire
113
+ // (the caller compiles, the UI looks right, the field never leaves the
114
+ // page). `project` scopes document-expression resolution to the
115
+ // workflow's selected project; `state` is the start state upstream step
116
+ // outputs are seeded from, so `{{ steps.<id>.output.<f> }}` resolves.
117
+ // Undefined keys are dropped by JSON.stringify, so an absent project or
118
+ // state leaves the request byte-identical to one that never had them.
119
+ {
120
+ method: "POST",
121
+ body: JSON.stringify({
122
+ params: u,
123
+ connectionId: w.connectionId,
124
+ project: w.project,
125
+ state: w.state
126
+ })
127
+ }
128
+ ),
129
+ listSavedTests: (r) => a(
130
+ `/connections/${encodeURIComponent(r)}/saved-tests`
131
+ ).then((c) => c.savedTests ?? []),
132
+ createSavedTest: (r, c) => a(
133
+ `/connections/${encodeURIComponent(r)}/saved-tests`,
134
+ { method: "POST", body: JSON.stringify(c) }
135
+ ).then((u) => u.savedTest),
136
+ updateSavedTest: (r, c, u) => a(
137
+ `/connections/${encodeURIComponent(r)}/saved-tests/${encodeURIComponent(c)}`,
138
+ { method: "PATCH", body: JSON.stringify(u) }
139
+ ).then((w) => w.savedTest),
140
+ deleteSavedTest: (r, c) => a(
141
+ `/connections/${encodeURIComponent(r)}/saved-tests/${encodeURIComponent(c)}`,
142
+ { method: "DELETE" }
143
+ ).then(() => {
144
+ }),
145
+ recordTestRun: (r, c) => a(`/connections/${encodeURIComponent(r)}/test-runs`, {
146
+ method: "POST",
147
+ body: JSON.stringify(c)
148
+ }).then(() => {
149
+ }),
150
+ listTestRuns: (r) => a(
151
+ `/connections/${encodeURIComponent(r)}/test-runs`
152
+ ).then((c) => c.runs ?? []),
153
+ saveStepTest: (r, c, u) => a(
154
+ `/workflows/${encodeURIComponent(r)}/steps/${encodeURIComponent(c)}/tests`,
155
+ { method: "POST", body: JSON.stringify(u) }
156
+ ).then((w) => w.stepTest),
157
+ listStepTests: (r, c) => a(
158
+ `/workflows/${encodeURIComponent(r)}/steps/${encodeURIComponent(c)}/tests`
159
+ ).then((u) => u.stepTests ?? []),
160
+ recordStepTestRun: (r, c, u) => a(
161
+ `/workflows/${encodeURIComponent(r)}/steps/${encodeURIComponent(c)}/test-runs`,
162
+ { method: "POST", body: JSON.stringify(u) }
163
+ ).then(() => {
164
+ }),
165
+ listFunctions: () => a("/functions").then((r) => r.functions ?? []),
166
+ getFunction: (r) => a(
167
+ `/functions/${encodeURIComponent(r)}`
168
+ ).then((c) => ({ ...c.function, valid: c.valid })),
169
+ // The real synchronous route (`/functions/:id/invoke`) — deliberately NOT
170
+ // `POST /run`, which would give the test stage a different code path than
171
+ // the `@w6w/call` node it's standing in for. Returns the raw output,
172
+ // pinned against the committed `studio/src/repos/functions.ts` signature.
173
+ invokeFunction: (r, c) => a(`/functions/${encodeURIComponent(r)}/invoke`, {
174
+ method: "POST",
175
+ body: JSON.stringify({ inputs: c })
176
+ }).then((u) => u.output),
177
+ listWorkflows: () => a("/workflows").then((r) => r.workflows ?? []),
178
+ getWorkflow: (r) => a(`/workflows/${encodeURIComponent(r)}`).then(
179
+ (c) => c.workflow
180
+ ),
181
+ // `rawReq`, not `req<T>` — the ONE caller that needs the response's own
182
+ // status code: `200` (the run reached a terminal state inside the wait
183
+ // window) vs `202` (the server's own wait-timeout, still running). Both
184
+ // are 2xx successes; `rawReq` already throws on a non-2xx.
185
+ runWorkflow: (r, c = {}) => d(`/workflows/${encodeURIComponent(r)}/run?wait=true`, {
186
+ method: "POST",
187
+ body: JSON.stringify({ variables: c.variables, input: c.input })
188
+ }).then(({ status: u, data: w }) => ({ ...w ?? {}, terminal: u === 200 }))
189
+ };
190
+ }
191
+ function Ge(e) {
192
+ if (!e) return "";
193
+ try {
194
+ return JSON.stringify(JSON.parse(e), null, 2);
195
+ } catch {
196
+ return e;
197
+ }
198
+ }
199
+ function Kt(e, s) {
200
+ return `${e.method}-${e.url ?? e.host}-${s}`;
201
+ }
202
+ function Wt({ calls: e, defaultOpen: s, keyOf: n, title: l }) {
203
+ if (e.length === 0) return null;
204
+ const d = n ?? Kt;
205
+ return /* @__PURE__ */ o("div", { className: "w6w-stack", style: { gap: 4 }, children: [
206
+ l !== !1 && /* @__PURE__ */ t("strong", { className: "w6w-small", children: l ?? /* @__PURE__ */ o(k, { children: [
207
+ "API ",
208
+ e.length === 1 ? "call" : "calls",
209
+ " (",
210
+ e.length,
211
+ ")"
212
+ ] }) }),
213
+ e.map((a, r) => /* @__PURE__ */ o(
214
+ "details",
215
+ {
216
+ open: s,
217
+ className: "w6w-result",
218
+ style: { padding: 8 },
219
+ children: [
220
+ /* @__PURE__ */ t("summary", { style: { cursor: "pointer" }, children: /* @__PURE__ */ o("span", { className: "w6w-small", children: [
221
+ a.method,
222
+ " ",
223
+ a.url ?? a.host,
224
+ " →",
225
+ " ",
226
+ /* @__PURE__ */ t("strong", { children: a.error ? "failed" : a.status }),
227
+ a.durationMs !== void 0 && /* @__PURE__ */ o("span", { className: "w6w-muted", children: [
228
+ " · ",
229
+ a.durationMs,
230
+ "ms"
231
+ ] })
232
+ ] }) }),
233
+ /* @__PURE__ */ o("div", { className: "w6w-stack", style: { gap: 6, marginTop: 8 }, children: [
234
+ a.error && /* @__PURE__ */ t("div", { className: "w6w-error w6w-small", children: a.error }),
235
+ /* @__PURE__ */ t("div", { className: "w6w-muted w6w-small", children: "Request headers" }),
236
+ /* @__PURE__ */ t("pre", { className: "w6w-result", children: JSON.stringify(a.requestHeaders ?? {}, null, 2) }),
237
+ a.requestBody && /* @__PURE__ */ o(k, { children: [
238
+ /* @__PURE__ */ t("div", { className: "w6w-muted w6w-small", children: "Request body" }),
239
+ /* @__PURE__ */ t("pre", { className: "w6w-result", children: Ge(a.requestBody) })
240
+ ] }),
241
+ /* @__PURE__ */ t("div", { className: "w6w-muted w6w-small", children: "Response headers" }),
242
+ /* @__PURE__ */ t("pre", { className: "w6w-result", children: JSON.stringify(a.responseHeaders ?? {}, null, 2) }),
243
+ a.responseBody && /* @__PURE__ */ o(k, { children: [
244
+ /* @__PURE__ */ t("div", { className: "w6w-muted w6w-small", children: "Response body" }),
245
+ /* @__PURE__ */ t("pre", { className: "w6w-result", children: Ge(a.responseBody) })
246
+ ] }),
247
+ a.truncated && /* @__PURE__ */ t("div", { className: "w6w-muted w6w-small", children: "A captured body exceeded the size cap and was truncated." })
248
+ ] })
249
+ ]
250
+ },
251
+ d(a, r)
252
+ ))
253
+ ] });
254
+ }
255
+ function Ne({
256
+ title: e,
257
+ subtitle: s,
258
+ icon: n,
259
+ trailing: l,
260
+ active: d = !1,
261
+ onClick: a,
262
+ ariaLabel: r
263
+ }) {
264
+ const c = /* @__PURE__ */ o(k, { children: [
265
+ n != null && /* @__PURE__ */ t("span", { className: "w6w-list-item-icon", children: n }),
266
+ /* @__PURE__ */ o("span", { className: "w6w-list-item-body", children: [
267
+ /* @__PURE__ */ t("span", { className: "w6w-list-item-title", children: e }),
268
+ s != null && /* @__PURE__ */ t("span", { className: "w6w-list-item-subtitle", children: s })
269
+ ] }),
270
+ l != null && /* @__PURE__ */ t("span", { className: "w6w-list-item-trailing", children: l })
271
+ ] }), u = `w6w-list-item${d ? " active" : ""}`;
272
+ return a ? /* @__PURE__ */ t(
273
+ "button",
274
+ {
275
+ type: "button",
276
+ className: u,
277
+ "aria-pressed": d,
278
+ "aria-label": r,
279
+ onClick: a,
280
+ children: c
281
+ }
282
+ ) : /* @__PURE__ */ t("div", { className: u, "aria-label": r, children: c });
283
+ }
284
+ function de(e) {
285
+ const s = Date.parse(e);
286
+ if (Number.isNaN(s)) return "";
287
+ const n = Math.max(0, Math.round((Date.now() - s) / 1e3));
288
+ if (n < 45) return "just now";
289
+ const l = Math.round(n / 60);
290
+ if (l < 60) return `${l}m ago`;
291
+ const d = Math.round(l / 60);
292
+ if (d < 24) return `${d}h ago`;
293
+ const a = Math.round(d / 24);
294
+ return a < 7 ? `${a}d ago` : new Date(s).toLocaleDateString();
295
+ }
296
+ function Qe(e) {
297
+ const s = {};
298
+ for (const n of (e == null ? void 0 : e.params) ?? [])
299
+ n.key && n.default !== void 0 && (s[n.key] = n.default);
300
+ return s;
301
+ }
302
+ function Vt(e) {
303
+ var n, l, d;
304
+ const s = e.indexOf("{");
305
+ if (s >= 0)
306
+ try {
307
+ const a = JSON.parse(e.slice(s)), r = ((l = (n = a == null ? void 0 : a.errors) == null ? void 0 : n[0]) == null ? void 0 : l.message) ?? (typeof (a == null ? void 0 : a.error) == "object" ? (d = a.error) == null ? void 0 : d.message : a == null ? void 0 : a.error) ?? (a == null ? void 0 : a.message);
308
+ if (typeof r == "string" && r.trim()) {
309
+ const c = e.slice(0, s).replace(/[:\s]+$/, "");
310
+ return c ? `${c}: ${r.trim()}` : r.trim();
311
+ }
312
+ } catch {
313
+ }
314
+ return e;
315
+ }
316
+ function tt(e) {
317
+ return typeof e == "object" && e !== null && typeof e.status == "number" && typeof e.code == "string";
318
+ }
319
+ function zt(e) {
320
+ if (!tt(e))
321
+ return { headline: (e == null ? void 0 : e.message) ?? "The action failed to run." };
322
+ const s = Vt(e.message ?? ""), n = `${e.status} ${e.code} ${e.message ?? ""}`.toLowerCase();
323
+ return e.status === 401 || e.status === 403 || /\b(401|403)\b|forbidden|unauthorized|not authorized|permission|scope|access denied|invalid api key|invalid credential/.test(
324
+ n
325
+ ) ? {
326
+ headline: "Permission denied by the provider — this is a credential/scope problem, not a w6w error.",
327
+ hint: "The connection's API key is missing the permissions this action needs. Fix it at the provider — e.g. SendGrid → Settings → API Keys → give the key the required scopes (or Full Access), or create a new key — then update this connection's credential and try again.",
328
+ detail: s
329
+ } : { headline: "The action returned an error.", detail: s };
330
+ }
331
+ function Gt(e) {
332
+ const s = tt(e) ? e.body ?? e.raw : null;
333
+ return (s == null ? void 0 : s.apiCalls) ?? [];
334
+ }
335
+ function ue() {
336
+ const [e, s] = v(""), [n, l] = v(void 0), [d, a] = v(!1);
337
+ return { text: e, value: n, invalid: d, onChange: (c) => {
338
+ s(c);
339
+ const u = c.trim();
340
+ if (u === "") {
341
+ a(!1);
342
+ return;
343
+ }
344
+ try {
345
+ const w = JSON.parse(u);
346
+ w !== null && typeof w == "object" && !Array.isArray(w) ? (l(w), a(!1)) : a(!0);
347
+ } catch {
348
+ a(!0);
349
+ }
350
+ } };
351
+ }
352
+ function Ps({
353
+ appId: e,
354
+ actions: s,
355
+ connectionId: n,
356
+ action: l,
357
+ seedValues: d,
358
+ onSavedTestsChanged: a,
359
+ seedTestId: r,
360
+ onDirtyChange: c,
361
+ onTestSaved: u,
362
+ onDeleted: w,
363
+ embedded: h = !1
364
+ }) {
365
+ var qe;
366
+ const m = Et(), p = ye(() => {
367
+ const i = [...s];
368
+ return i.sort((f, g) => (f.title || f.key).localeCompare(g.title || g.key)), i;
369
+ }, [s]), [N, ee] = v((l == null ? void 0 : l.key) ?? ""), y = l ?? s.find((i) => i.key === N) ?? null, [Ce, Oe] = v(!1), [A, _] = v(null), [Re, P] = v(void 0), [nt, E] = v([]), C = ue(), O = ue(), R = ue(), [te, at] = v(""), [se, rt] = v(""), Te = C.invalid || O.invalid || R.invalid, lt = () => {
370
+ const i = {};
371
+ return C.text.trim() !== "" && C.value !== void 0 && (i.body = C.value), O.text.trim() !== "" && O.value !== void 0 && (i.query = O.value), R.text.trim() !== "" && R.value !== void 0 && (i.headers = R.value), te && (i.target = te), se.trim() !== "" && (i.match = se.trim()), Object.keys(i).length > 0 ? i : void 0;
372
+ }, [I, ne] = v("form"), [it, Ae] = v(""), [ot, Ee] = v(!1), [T, Me] = v(!1), b = (y == null ? void 0 : y.key) ?? null, _e = d ? { ...d } : Qe(y), [Pe, D] = v(() => ({
373
+ key: b,
374
+ values: _e
375
+ })), [x, U] = v(r ?? null), [Ie, H] = v(_e);
376
+ if (Pe.key !== b) {
377
+ const i = Qe(y);
378
+ D({ key: b, values: i }), H(i), U(r ?? null), _(null), P(void 0), E([]);
379
+ }
380
+ const [ct, dt] = v(r);
381
+ r !== ct && (dt(r), U(r ?? null));
382
+ const [Ue, ut] = v(d);
383
+ if (d !== Ue) {
384
+ const i = JSON.stringify(d ?? null) !== JSON.stringify(Ue ?? null);
385
+ if (ut(d), d && i) {
386
+ const f = { ...d };
387
+ D({ key: b, values: f }), H(f), _(null), P(void 0), E([]);
388
+ }
389
+ }
390
+ const S = Pe.values, Fe = (i) => D({ key: b, values: i }), Le = ye(
391
+ () => JSON.stringify(S) !== JSON.stringify(Ie),
392
+ [S, Ie]
393
+ );
394
+ G(() => {
395
+ c == null || c(Le);
396
+ }, [Le]);
397
+ const wt = () => {
398
+ Ae(JSON.stringify(S, null, 2)), Ee(!1), ne("json");
399
+ }, mt = async (i) => {
400
+ if (!y || Te) return;
401
+ const f = y.key;
402
+ Oe(!0), _(null), P(void 0), E([]);
403
+ let g;
404
+ const Ke = lt();
405
+ try {
406
+ const M = await m.invokeAction(e, f, i, {
407
+ connectionId: n,
408
+ ...Ke ? { overrides: Ke } : {}
409
+ });
410
+ P(M.value), E(M.apiCalls ?? []), g = { ok: !0, summary: "OK", result: M.value };
411
+ } catch (M) {
412
+ const We = zt(M);
413
+ _(We), E(Gt(M)), g = { ok: !1, summary: We.headline };
414
+ } finally {
415
+ Oe(!1);
416
+ }
417
+ if (n)
418
+ try {
419
+ await m.recordTestRun(n, {
420
+ savedTestId: x ?? null,
421
+ actionKey: f,
422
+ ok: g.ok,
423
+ summary: g.summary.slice(0, 200),
424
+ result: g.result
425
+ }), ie(), kt(), a == null || a();
426
+ } catch {
427
+ }
428
+ }, ht = () => mt(S), [j, Be] = v(null), [q, F] = v(null), [pt, ft] = v(0), [vt, K] = v(!1), [ae, re] = v(""), [yt, le] = v(!1), ie = () => ft((i) => i + 1);
429
+ G(() => {
430
+ if (!n) {
431
+ Be(null);
432
+ return;
433
+ }
434
+ let i = !1;
435
+ return F(null), m.listSavedTests(n).then((f) => !i && Be(f)).catch((f) => !i && F(f.message)), () => {
436
+ i = !0;
437
+ };
438
+ }, [m, n, pt]);
439
+ const Je = b ? (j ?? []).filter((i) => i.actionKey === b) : [], [Nt, oe] = v(null), [gt, bt] = v(0), kt = () => bt((i) => i + 1);
440
+ G(() => {
441
+ const i = m.listTestRuns;
442
+ if (!n || !i) {
443
+ oe(null);
444
+ return;
445
+ }
446
+ let f = !1;
447
+ return i(n).then((g) => !f && oe(g)).catch(() => !f && oe(null)), () => {
448
+ f = !0;
449
+ };
450
+ }, [m, n, gt]);
451
+ const De = b ? (Nt ?? []).filter((i) => i.actionKey === b).slice().sort((i, f) => Date.parse(f.occurredAt) - Date.parse(i.occurredAt)) : [], xt = () => {
452
+ !n || !y || (re(""), F(null), K(!0));
453
+ }, St = () => {
454
+ !n || !y || (x ? He() : xt());
455
+ }, He = async () => {
456
+ if (!(!n || !y))
457
+ try {
458
+ let i;
459
+ if (x)
460
+ i = await m.updateSavedTest(n, x, { values: S });
461
+ else {
462
+ const f = ae.trim();
463
+ if (!f) return;
464
+ i = await m.createSavedTest(n, {
465
+ actionKey: y.key,
466
+ name: f,
467
+ values: S
468
+ }), U(i.id);
469
+ }
470
+ H({ ...S }), K(!1), re(""), ie(), a == null || a(), u == null || u(i);
471
+ } catch (i) {
472
+ F(i.message);
473
+ }
474
+ }, $t = (i) => {
475
+ const f = { ...i.values };
476
+ D({ key: b, values: f }), H(f), U(i.id), ne("form"), _(null), P(void 0), E([]);
477
+ }, Ct = async () => {
478
+ if (!n || !x) return;
479
+ const i = x;
480
+ try {
481
+ await m.deleteSavedTest(n, i), U(null), ie(), a == null || a(), w == null || w(i);
482
+ } catch (f) {
483
+ F(f.message);
484
+ }
485
+ }, Ot = /* @__PURE__ */ o("div", { className: "w6w-stack", style: { gap: "var(--w6w-sp-1-5)" }, children: [
486
+ /* @__PURE__ */ o(
487
+ "div",
488
+ {
489
+ className: "w6w-field-labelrow",
490
+ style: { display: "flex", justifyContent: "space-between", alignItems: "center" },
491
+ children: [
492
+ /* @__PURE__ */ t("span", { className: "w6w-muted w6w-small", children: "Parameters" }),
493
+ /* @__PURE__ */ o("div", { style: { display: "flex", gap: "var(--w6w-sp-1)" }, children: [
494
+ /* @__PURE__ */ t(
495
+ "button",
496
+ {
497
+ type: "button",
498
+ className: `w6w-btn w6w-btn-sm w6w-btn-ghost${I === "form" ? " active" : ""}`,
499
+ "aria-pressed": I === "form",
500
+ onClick: () => ne("form"),
501
+ children: "Form"
502
+ }
503
+ ),
504
+ /* @__PURE__ */ t(
505
+ "button",
506
+ {
507
+ type: "button",
508
+ className: `w6w-btn w6w-btn-sm w6w-btn-ghost${I === "json" ? " active" : ""}`,
509
+ "aria-pressed": I === "json",
510
+ onClick: wt,
511
+ children: "JSON"
512
+ }
513
+ ),
514
+ !h && /* @__PURE__ */ t(
515
+ "button",
516
+ {
517
+ type: "button",
518
+ className: "w6w-btn w6w-btn-sm w6w-btn-ghost",
519
+ "aria-pressed": T,
520
+ title: T ? "Collapse the params editor" : "Open the params editor in a larger view",
521
+ "aria-label": T ? "Collapse the params editor" : "Open the params editor in a larger view",
522
+ onClick: () => Me((i) => !i),
523
+ children: T ? "⤡" : "⤢"
524
+ }
525
+ )
526
+ ] })
527
+ ]
528
+ }
529
+ ),
530
+ I === "form" ? /* @__PURE__ */ t(Mt, { params: (y == null ? void 0 : y.params) ?? [], values: S, onChange: Fe }) : /* @__PURE__ */ o(k, { children: [
531
+ /* @__PURE__ */ t(
532
+ z,
533
+ {
534
+ value: it,
535
+ onChange: Ae,
536
+ minHeight: T ? "50vh" : "200px",
537
+ "aria-label": "Params JSON",
538
+ onValidChange: (i) => {
539
+ i !== null && typeof i == "object" && !Array.isArray(i) && Fe(i);
540
+ },
541
+ onValidityChange: ({ valid: i }) => Ee(!i)
542
+ }
543
+ ),
544
+ ot && /* @__PURE__ */ t("span", { className: "w6w-hint", style: { color: "var(--w6w-danger)" }, children: "Invalid JSON" })
545
+ ] })
546
+ ] }), Rt = /* @__PURE__ */ o("details", { className: "w6w-section", "data-testid": "overrides-region", children: [
547
+ /* @__PURE__ */ o("summary", { className: "w6w-section-summary", children: [
548
+ /* @__PURE__ */ t("span", { className: "w6w-section-title", children: "Overrides" }),
549
+ /* @__PURE__ */ t("span", { className: "w6w-section-subtitle", children: "Reach a vendor field this action's own params don't declare" })
550
+ ] }),
551
+ /* @__PURE__ */ o("div", { className: "w6w-stack w6w-section-body", style: { gap: "var(--w6w-sp-2)" }, children: [
552
+ /* @__PURE__ */ o("div", { className: "w6w-field", children: [
553
+ /* @__PURE__ */ t("span", { children: "Body" }),
554
+ /* @__PURE__ */ t(
555
+ z,
556
+ {
557
+ value: C.text,
558
+ onChange: C.onChange,
559
+ minHeight: "80px",
560
+ "aria-label": "Overrides body (JSON)"
561
+ }
562
+ ),
563
+ C.invalid && /* @__PURE__ */ t("span", { className: "w6w-hint", style: { color: "var(--w6w-danger)" }, children: "Invalid JSON" })
564
+ ] }),
565
+ /* @__PURE__ */ o("div", { className: "w6w-field", children: [
566
+ /* @__PURE__ */ t("span", { children: "Query" }),
567
+ /* @__PURE__ */ t(
568
+ z,
569
+ {
570
+ value: O.text,
571
+ onChange: O.onChange,
572
+ minHeight: "80px",
573
+ "aria-label": "Overrides query (JSON)"
574
+ }
575
+ ),
576
+ O.invalid && /* @__PURE__ */ t("span", { className: "w6w-hint", style: { color: "var(--w6w-danger)" }, children: "Invalid JSON" })
577
+ ] }),
578
+ /* @__PURE__ */ o("div", { className: "w6w-field", children: [
579
+ /* @__PURE__ */ t("span", { children: "Headers" }),
580
+ /* @__PURE__ */ t(
581
+ z,
582
+ {
583
+ value: R.text,
584
+ onChange: R.onChange,
585
+ minHeight: "80px",
586
+ "aria-label": "Overrides headers (JSON)"
587
+ }
588
+ ),
589
+ R.invalid && /* @__PURE__ */ t("span", { className: "w6w-hint", style: { color: "var(--w6w-danger)" }, children: "Invalid JSON" })
590
+ ] }),
591
+ /* @__PURE__ */ o("label", { className: "w6w-field", children: [
592
+ /* @__PURE__ */ t("span", { children: "Target" }),
593
+ /* @__PURE__ */ o(
594
+ "select",
595
+ {
596
+ "aria-label": "Overrides target",
597
+ value: te,
598
+ onChange: (i) => at(i.target.value),
599
+ children: [
600
+ /* @__PURE__ */ t("option", { value: "", children: "— default (first) —" }),
601
+ /* @__PURE__ */ t("option", { value: "first", children: "first" }),
602
+ /* @__PURE__ */ t("option", { value: "first-write", children: "first-write" }),
603
+ /* @__PURE__ */ t("option", { value: "all", children: "all" })
604
+ ]
605
+ }
606
+ )
607
+ ] }),
608
+ /* @__PURE__ */ o("label", { className: "w6w-field", children: [
609
+ /* @__PURE__ */ t("span", { children: "Match" }),
610
+ /* @__PURE__ */ t(
611
+ "input",
612
+ {
613
+ type: "text",
614
+ "aria-label": "Overrides match",
615
+ value: se,
616
+ placeholder: "Restrict to requests whose URL contains…",
617
+ onChange: (i) => rt(i.target.value)
618
+ }
619
+ )
620
+ ] }),
621
+ /* @__PURE__ */ t("span", { className: "w6w-hint", children: "Merged onto the outbound request at the wire, never into the params above — name a field the way the vendor's own API documents it." })
622
+ ] })
623
+ ] }), W = n ? /* @__PURE__ */ o("div", { className: "w6w-stack", style: { gap: "var(--w6w-sp-1-5)" }, children: [
624
+ /* @__PURE__ */ t(
625
+ "div",
626
+ {
627
+ className: "w6w-field-labelrow",
628
+ style: { display: "flex", justifyContent: "space-between", alignItems: "center" },
629
+ children: /* @__PURE__ */ t("span", { className: "w6w-muted w6w-small", children: "Saved tests" })
630
+ }
631
+ ),
632
+ q && /* @__PURE__ */ t("span", { className: "w6w-hint", style: { color: "var(--w6w-danger)" }, children: q }),
633
+ Je.length === 0 ? /* @__PURE__ */ t("p", { className: "w6w-muted w6w-small", children: "No saved tests for this action yet." }) : /* @__PURE__ */ t(
634
+ "ul",
635
+ {
636
+ className: "w6w-stack",
637
+ style: { listStyle: "none", margin: 0, padding: 0, gap: "var(--w6w-sp-1-5)" },
638
+ children: Je.map((i) => /* @__PURE__ */ t("li", { children: /* @__PURE__ */ t(
639
+ Ne,
640
+ {
641
+ title: i.name,
642
+ subtitle: i.lastRunAt ? /* @__PURE__ */ o("span", { children: [
643
+ /* @__PURE__ */ t(
644
+ "span",
645
+ {
646
+ style: { color: i.lastRunOk ? "var(--w6w-success)" : "var(--w6w-danger)" },
647
+ children: i.lastRunOk ? "✓" : "✗"
648
+ }
649
+ ),
650
+ " ",
651
+ i.lastRunSummary ? `${i.lastRunSummary} · ` : "",
652
+ de(i.lastRunAt)
653
+ ] }) : `saved ${de(i.updatedAt)}`,
654
+ active: i.id === x,
655
+ onClick: () => $t(i)
656
+ }
657
+ ) }, i.id))
658
+ }
659
+ ),
660
+ m.listTestRuns && De.length > 0 && /* @__PURE__ */ o(k, { children: [
661
+ /* @__PURE__ */ t(
662
+ "div",
663
+ {
664
+ className: "w6w-field-labelrow",
665
+ style: { display: "flex", justifyContent: "space-between", alignItems: "center" },
666
+ children: /* @__PURE__ */ t("span", { className: "w6w-muted w6w-small", children: "Recent runs" })
667
+ }
668
+ ),
669
+ /* @__PURE__ */ t(
670
+ "ul",
671
+ {
672
+ className: "w6w-stack",
673
+ style: { listStyle: "none", margin: 0, padding: 0, gap: "var(--w6w-sp-1-5)" },
674
+ children: De.map((i) => /* @__PURE__ */ t("li", { children: /* @__PURE__ */ t(
675
+ Ne,
676
+ {
677
+ title: /* @__PURE__ */ o("span", { children: [
678
+ /* @__PURE__ */ t("span", { style: { color: i.ok ? "var(--w6w-success)" : "var(--w6w-danger)" }, children: i.ok ? "✓" : "✗" }),
679
+ " ",
680
+ i.actionKey
681
+ ] }),
682
+ subtitle: /* @__PURE__ */ o("span", { children: [
683
+ i.summary ? `${i.summary} · ` : "",
684
+ de(i.occurredAt)
685
+ ] })
686
+ }
687
+ ) }, i.id))
688
+ }
689
+ )
690
+ ] })
691
+ ] }) : null, je = (qe = j == null ? void 0 : j.find((i) => i.id === x)) == null ? void 0 : qe.name;
692
+ return /* @__PURE__ */ o("div", { className: `w6w-stack${h ? " w6w-tester-embedded-root" : ""}`, children: [
693
+ !l && (s.length === 0 ? /* @__PURE__ */ t("p", { className: "w6w-muted w6w-small", children: "This app exposes no actions." }) : (
694
+ // biome-ignore lint/a11y/noLabelWithoutControl: Combobox renders its own <select>/<input> INSIDE this label, so the field text labels the control at runtime; the rule cannot see through the component boundary.
695
+ /* @__PURE__ */ o("label", { className: "w6w-field", children: [
696
+ /* @__PURE__ */ o("span", { children: [
697
+ "Action",
698
+ b ? "" : " *"
699
+ ] }),
700
+ /* @__PURE__ */ t(
701
+ _t,
702
+ {
703
+ value: N,
704
+ placeholder: "— pick an action —",
705
+ onChange: ee,
706
+ options: p.map((i) => ({
707
+ value: i.key,
708
+ label: `${i.title ?? i.key} (${i.key})`
709
+ }))
710
+ }
711
+ )
712
+ ] })
713
+ )),
714
+ y ? /* @__PURE__ */ o(k, { children: [
715
+ /* @__PURE__ */ o("div", { children: [
716
+ /* @__PURE__ */ o("strong", { children: [
717
+ y.title ?? y.key,
718
+ " ",
719
+ /* @__PURE__ */ t("code", { className: "w6w-muted", children: y.key })
720
+ ] }),
721
+ y.description && /* @__PURE__ */ t("p", { className: "w6w-muted w6w-small", style: { margin: "var(--w6w-sp-0-5) 0 0" }, children: y.description })
722
+ ] }),
723
+ (() => {
724
+ const i = /* @__PURE__ */ o("div", { className: "w6w-stack", style: { gap: "var(--w6w-sp-3)" }, children: [
725
+ Ot,
726
+ Rt,
727
+ A && /* @__PURE__ */ o("div", { className: "w6w-result w6w-error", children: [
728
+ /* @__PURE__ */ t("strong", { children: A.headline }),
729
+ A.hint && /* @__PURE__ */ t("div", { style: { marginTop: "var(--w6w-sp-1-5)" }, children: A.hint }),
730
+ A.detail && /* @__PURE__ */ t(
731
+ "div",
732
+ {
733
+ className: "w6w-muted w6w-small",
734
+ style: {
735
+ marginTop: "var(--w6w-sp-1-5)",
736
+ whiteSpace: "pre-wrap",
737
+ wordBreak: "break-word"
738
+ },
739
+ children: A.detail
740
+ }
741
+ )
742
+ ] }),
743
+ Re !== void 0 && /* @__PURE__ */ o("div", { className: "w6w-stack", style: { gap: "var(--w6w-sp-1)" }, children: [
744
+ /* @__PURE__ */ t("strong", { className: "w6w-small", children: "Result" }),
745
+ /* @__PURE__ */ t("pre", { className: "w6w-result", children: JSON.stringify(Re, null, 2) })
746
+ ] }),
747
+ /* @__PURE__ */ t(Wt, { calls: nt })
748
+ ] }), f = /* @__PURE__ */ o(
749
+ "div",
750
+ {
751
+ className: `w6w-tester-actions${h || T ? " w6w-tester-actions-footer" : ""}`,
752
+ style: { display: "flex", gap: "var(--w6w-sp-2)" },
753
+ children: [
754
+ /* @__PURE__ */ t(
755
+ "button",
756
+ {
757
+ type: "button",
758
+ className: "w6w-btn",
759
+ disabled: Ce || Te,
760
+ onClick: ht,
761
+ children: Ce ? "Running…" : "Run action"
762
+ }
763
+ ),
764
+ n && /* @__PURE__ */ t("button", { type: "button", className: "w6w-btn w6w-btn-ghost", onClick: St, children: "Save test" }),
765
+ n && x && /* @__PURE__ */ t(
766
+ "button",
767
+ {
768
+ type: "button",
769
+ className: "w6w-btn w6w-btn-ghost",
770
+ style: { marginLeft: "auto", color: "var(--w6w-danger)" },
771
+ onClick: () => le(!0),
772
+ children: "Delete"
773
+ }
774
+ )
775
+ ]
776
+ }
777
+ ), g = /* @__PURE__ */ o("div", { className: "w6w-stack", style: { gap: "var(--w6w-sp-3)" }, children: [
778
+ i,
779
+ f
780
+ ] });
781
+ return h ? /* @__PURE__ */ o("div", { className: "w6w-tester-embedded", children: [
782
+ /* @__PURE__ */ t("div", { className: "w6w-tester-embedded-scroll", children: W ? /* @__PURE__ */ o("div", { className: "w6w-tester-embedded-cols", children: [
783
+ /* @__PURE__ */ t("div", { className: "w6w-tester-embedded-main", children: i }),
784
+ /* @__PURE__ */ t("div", { className: "w6w-tester-embedded-rail", children: W })
785
+ ] }) : i }),
786
+ f
787
+ ] }) : T ? /* @__PURE__ */ t(
788
+ Ve,
789
+ {
790
+ title: `Edit params — ${y.title ?? y.key}`,
791
+ onClose: () => Me(!1),
792
+ size: "full",
793
+ children: /* @__PURE__ */ o("div", { className: "w6w-tester-popout", children: [
794
+ /* @__PURE__ */ t("div", { className: "w6w-tester-popout-scroll", children: W ? /* @__PURE__ */ o(
795
+ "div",
796
+ {
797
+ style: {
798
+ display: "flex",
799
+ gap: "var(--w6w-sp-4)",
800
+ alignItems: "flex-start"
801
+ },
802
+ children: [
803
+ /* @__PURE__ */ t("div", { style: { flex: 1, minWidth: 0 }, children: i }),
804
+ /* @__PURE__ */ t("div", { style: { width: 260, flexShrink: 0 }, children: W })
805
+ ]
806
+ }
807
+ ) : i }),
808
+ f
809
+ ] })
810
+ }
811
+ ) : g;
812
+ })(),
813
+ vt && /* @__PURE__ */ t(Ve, { title: "Save test", onClose: () => K(!1), children: /* @__PURE__ */ o(
814
+ "form",
815
+ {
816
+ className: "w6w-stack",
817
+ style: { gap: "var(--w6w-sp-3)" },
818
+ onSubmit: (i) => {
819
+ i.preventDefault(), He();
820
+ },
821
+ children: [
822
+ /* @__PURE__ */ o("label", { className: "w6w-field", children: [
823
+ /* @__PURE__ */ t("span", { children: "Name this saved test" }),
824
+ /* @__PURE__ */ t(
825
+ "input",
826
+ {
827
+ type: "text",
828
+ value: ae,
829
+ placeholder: "e.g. valid sender",
830
+ onChange: (i) => re(i.target.value)
831
+ }
832
+ )
833
+ ] }),
834
+ q && /* @__PURE__ */ t("span", { className: "w6w-hint", style: { color: "var(--w6w-danger)" }, children: q }),
835
+ /* @__PURE__ */ o(
836
+ "div",
837
+ {
838
+ style: { display: "flex", gap: "var(--w6w-sp-2)", justifyContent: "flex-end" },
839
+ children: [
840
+ /* @__PURE__ */ t(
841
+ "button",
842
+ {
843
+ type: "button",
844
+ className: "w6w-btn w6w-btn-ghost",
845
+ onClick: () => K(!1),
846
+ children: "Cancel"
847
+ }
848
+ ),
849
+ /* @__PURE__ */ t("button", { type: "submit", className: "w6w-btn", disabled: !ae.trim(), children: "Save" })
850
+ ]
851
+ }
852
+ )
853
+ ]
854
+ }
855
+ ) }),
856
+ yt && /* @__PURE__ */ t(
857
+ Pt,
858
+ {
859
+ title: "Delete saved test",
860
+ message: je ? `Delete "${je}"? This cannot be undone.` : "Delete this saved test? This cannot be undone.",
861
+ confirmLabel: "Delete",
862
+ onConfirm: () => {
863
+ le(!1), Ct();
864
+ },
865
+ onClose: () => le(!1)
866
+ }
867
+ )
868
+ ] }) : !l && /* @__PURE__ */ t("p", { className: "w6w-muted w6w-small", children: "Pick an action above to test it." })
869
+ ] });
870
+ }
871
+ function Is(e) {
872
+ const s = It(e.theme), { copied: n, copy: l } = Dt(e.value), d = ye(
873
+ () => [
874
+ Lt(),
875
+ Bt.theme({
876
+ "&": {
877
+ fontSize: "13px",
878
+ fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
879
+ backgroundColor: "var(--w6w-panel-2)",
880
+ color: "var(--w6w-text)",
881
+ border: "1px solid var(--w6w-border)",
882
+ borderRadius: "8px"
883
+ },
884
+ "&.cm-focused": { outline: "2px solid var(--w6w-accent)" },
885
+ ".cm-gutters": {
886
+ backgroundColor: "var(--w6w-panel)",
887
+ color: "var(--w6w-muted)",
888
+ border: "none",
889
+ borderRight: "1px solid var(--w6w-border)"
890
+ },
891
+ ".cm-scroller": { overflow: "auto" }
892
+ })
893
+ ],
894
+ []
895
+ );
896
+ function a(r) {
897
+ e.onChange(r);
898
+ }
899
+ return /* @__PURE__ */ o("div", { className: "w6w-yaml-editor", "aria-label": e["aria-label"] ?? "YAML editor", children: [
900
+ /* @__PURE__ */ t(
901
+ Jt,
902
+ {
903
+ value: e.value,
904
+ onChange: a,
905
+ extensions: d,
906
+ placeholder: e.placeholder,
907
+ readOnly: e.readOnly,
908
+ editable: !e.readOnly,
909
+ theme: s,
910
+ height: e.height,
911
+ minHeight: e.minHeight ?? "240px",
912
+ maxHeight: e.maxHeight,
913
+ basicSetup: {
914
+ lineNumbers: !0,
915
+ foldGutter: !0,
916
+ highlightActiveLine: !e.readOnly,
917
+ autocompletion: !0,
918
+ bracketMatching: !0,
919
+ closeBrackets: !0
920
+ }
921
+ }
922
+ ),
923
+ e.copyable && /* @__PURE__ */ o(k, { children: [
924
+ /* @__PURE__ */ t(
925
+ "button",
926
+ {
927
+ type: "button",
928
+ className: `w6w-icon-btn w6w-copyable-btn${n ? " is-copied" : ""}`,
929
+ "aria-label": "Copy",
930
+ onClick: () => void l(),
931
+ children: n ? /* @__PURE__ */ t(Ht, {}) : /* @__PURE__ */ t(jt, {})
932
+ }
933
+ ),
934
+ /* @__PURE__ */ t("span", { className: "w6w-copyable-status", "aria-live": "polite", children: n ? "Copied" : "" })
935
+ ] })
936
+ ] });
937
+ }
938
+ const we = "…";
939
+ function Qt(e, s, n = "end") {
940
+ if (s === void 0 || s < 1 || s >= e.length) return e;
941
+ if (n === "start")
942
+ return `${we}${e.slice(e.length - s)}`;
943
+ if (n === "end")
944
+ return `${e.slice(0, s)}${we}`;
945
+ const l = Math.ceil(s / 2), d = s - l;
946
+ return `${e.slice(0, l)}${we}${e.slice(e.length - d)}`;
947
+ }
948
+ function Us(e) {
949
+ const { value: s, chars: n, crop: l = "end", label: d, className: a, copiedMs: r } = e, c = Qt(s, n, l), u = ["w6w-copyable--bare", a].filter(Boolean).join(" ");
950
+ return /* @__PURE__ */ t(qt, { value: s, readOnly: !0, label: d, className: u, copiedMs: r, children: /* @__PURE__ */ t("span", { children: c }) });
951
+ }
952
+ const Yt = {
953
+ ok: "Operational",
954
+ degraded: "Degraded",
955
+ down: "Down",
956
+ unknown: "Unknown"
957
+ };
958
+ function Fs({ state: e, label: s, ariaLabel: n }) {
959
+ const l = s ?? Yt[e];
960
+ return /* @__PURE__ */ o("span", { className: `w6w-health-pill w6w-health-pill-${e}`, "aria-label": n, children: [
961
+ /* @__PURE__ */ t("span", { className: "w6w-health-pill-dot", "aria-hidden": "true" }),
962
+ /* @__PURE__ */ t("span", { className: "w6w-health-pill-label", children: l })
963
+ ] });
964
+ }
965
+ const Zt = {
966
+ ok: "Operational",
967
+ degraded: "Degraded",
968
+ down: "Down",
969
+ unknown: "Unknown"
970
+ };
971
+ function Ls({ days: e, ariaLabel: s }) {
972
+ return e.length === 0 ? null : /* @__PURE__ */ t(
973
+ "div",
974
+ {
975
+ className: "w6w-uptime-strip",
976
+ role: "img",
977
+ "aria-label": s ?? `${e.length}-day status`,
978
+ children: e.map((n, l) => /* @__PURE__ */ t(
979
+ "span",
980
+ {
981
+ className: `w6w-uptime-cell w6w-uptime-cell-${n.state}`,
982
+ title: n.label ?? `${n.day} — ${Zt[n.state]}`
983
+ },
984
+ `${n.day}-${l}`
985
+ ))
986
+ }
987
+ );
988
+ }
989
+ const st = "—", Ye = ["B", "KiB", "MiB", "GiB", "TiB", "PiB"];
990
+ function Xt(e) {
991
+ if (e === null || !Number.isFinite(e)) return st;
992
+ if (e < 1024) return `${Math.round(e)} B`;
993
+ let s = e, n = 0;
994
+ for (; s >= 1024 && n < Ye.length - 1; )
995
+ s /= 1024, n += 1;
996
+ return `${s.toFixed(1)} ${Ye[n]}`;
997
+ }
998
+ function $(e) {
999
+ return e === null || !Number.isFinite(e) ? st : `${Math.round(e * 100)}%`;
1000
+ }
1001
+ function B(e) {
1002
+ if (e === void 0 || e.load1 === null) return null;
1003
+ const s = e.cpuLimit ?? e.cpus;
1004
+ return s === null || s <= 0 ? null : e.load1 / s;
1005
+ }
1006
+ function J(e) {
1007
+ if (e === void 0) return null;
1008
+ const { memoryTotal: s, memoryAvailable: n } = e;
1009
+ return s === null || n === null || s <= 0 ? null : (s - n) / s;
1010
+ }
1011
+ function es(e, s, n) {
1012
+ return e < s ? s : e > n ? n : e;
1013
+ }
1014
+ function ts(e, s, n, l) {
1015
+ const d = e.length;
1016
+ if (d < 2) return "";
1017
+ const a = [];
1018
+ for (let r = 0; r < d; r++) {
1019
+ const c = e[r];
1020
+ if (c === null) continue;
1021
+ const u = r / (d - 1) * s, w = l <= 0 ? n : n - es(c, 0, l) / l * n;
1022
+ a.push(`${Number(u.toFixed(2))},${Number(w.toFixed(2))}`);
1023
+ }
1024
+ return a.join(" ");
1025
+ }
1026
+ const ss = "—", Ze = 100, Xe = 24;
1027
+ function ge({
1028
+ values: e,
1029
+ max: s,
1030
+ className: n
1031
+ }) {
1032
+ const l = ts(e, Ze, Xe, s);
1033
+ return l === "" ? null : /* @__PURE__ */ t(
1034
+ "svg",
1035
+ {
1036
+ className: n,
1037
+ viewBox: `0 0 ${Ze} ${Xe}`,
1038
+ preserveAspectRatio: "none",
1039
+ "aria-hidden": "true",
1040
+ focusable: "false",
1041
+ children: /* @__PURE__ */ t(
1042
+ "polyline",
1043
+ {
1044
+ points: l,
1045
+ fill: "none",
1046
+ stroke: "var(--w6w-accent)",
1047
+ strokeWidth: 2,
1048
+ vectorEffect: "non-scaling-stroke"
1049
+ }
1050
+ )
1051
+ }
1052
+ );
1053
+ }
1054
+ function me(e) {
1055
+ return e === null ? ss : e.toFixed(2);
1056
+ }
1057
+ function Z(e) {
1058
+ let s = 1;
1059
+ for (const n of e) n !== null && n > s && (s = n);
1060
+ return s;
1061
+ }
1062
+ function Q({
1063
+ label: e,
1064
+ value: s,
1065
+ values: n,
1066
+ max: l
1067
+ }) {
1068
+ return /* @__PURE__ */ o("li", { className: "w6w-server-resources__row", children: [
1069
+ /* @__PURE__ */ t("span", { className: "w6w-server-resources__label", children: e }),
1070
+ /* @__PURE__ */ t("span", { className: "w6w-server-resources__value", children: s }),
1071
+ /* @__PURE__ */ t(ge, { className: "w6w-server-resources__spark", values: n, max: l })
1072
+ ] });
1073
+ }
1074
+ function xe(e) {
1075
+ const s = e[e.length - 1], n = e.map((a) => B(a)), l = e.map((a) => J(a)), d = e.map((a) => a.processRss);
1076
+ return { last: s, cpuValues: n, memoryValues: l, rssValues: d };
1077
+ }
1078
+ function Bs({
1079
+ samples: e,
1080
+ title: s = "Server resources",
1081
+ intervalMs: n
1082
+ }) {
1083
+ const { last: l, cpuValues: d, memoryValues: a, rssValues: r } = xe(e);
1084
+ return /* @__PURE__ */ o("section", { className: "w6w-server-resources w6w-server-resources--card", "aria-label": s, children: [
1085
+ /* @__PURE__ */ t("h3", { className: "w6w-server-resources__title", children: s }),
1086
+ /* @__PURE__ */ o("ul", { className: "w6w-server-resources__rows", children: [
1087
+ /* @__PURE__ */ t(
1088
+ Q,
1089
+ {
1090
+ label: "CPU",
1091
+ value: $(B(l)),
1092
+ values: d,
1093
+ max: Z(d)
1094
+ }
1095
+ ),
1096
+ /* @__PURE__ */ t(
1097
+ Q,
1098
+ {
1099
+ label: "Memory",
1100
+ value: $(J(l)),
1101
+ values: a,
1102
+ max: 1
1103
+ }
1104
+ ),
1105
+ /* @__PURE__ */ t(
1106
+ Q,
1107
+ {
1108
+ label: "Process",
1109
+ value: Xt((l == null ? void 0 : l.processRss) ?? null),
1110
+ values: r,
1111
+ max: Z(r)
1112
+ }
1113
+ )
1114
+ ] }),
1115
+ /* @__PURE__ */ t("p", { className: "w6w-server-resources__meta", children: `Load ${me((l == null ? void 0 : l.load1) ?? null)} / ${me((l == null ? void 0 : l.load5) ?? null)} / ${me(
1116
+ (l == null ? void 0 : l.load15) ?? null
1117
+ )}` }),
1118
+ n !== void 0 && /* @__PURE__ */ t("p", { className: "w6w-server-resources__meta", children: `Sampled every ${n / 1e3}s` })
1119
+ ] });
1120
+ }
1121
+ function Js({ samples: e, title: s = "Server" }) {
1122
+ const { last: n, cpuValues: l } = xe(e);
1123
+ return /* @__PURE__ */ o("section", { className: "w6w-server-resources w6w-server-resources--small", "aria-label": s, children: [
1124
+ /* @__PURE__ */ t("h3", { className: "w6w-server-resources__title", children: s }),
1125
+ /* @__PURE__ */ o("ul", { className: "w6w-server-resources__rows", children: [
1126
+ /* @__PURE__ */ t(
1127
+ Q,
1128
+ {
1129
+ label: "CPU",
1130
+ value: $(B(n)),
1131
+ values: l,
1132
+ max: Z(l)
1133
+ }
1134
+ ),
1135
+ /* @__PURE__ */ o("li", { className: "w6w-server-resources__row", children: [
1136
+ /* @__PURE__ */ t("span", { className: "w6w-server-resources__label", children: "Memory" }),
1137
+ /* @__PURE__ */ t("span", { className: "w6w-server-resources__value", children: $(J(n)) })
1138
+ ] })
1139
+ ] })
1140
+ ] });
1141
+ }
1142
+ function Ds({ samples: e, onExpand: s }) {
1143
+ const { last: n, cpuValues: l, memoryValues: d } = xe(e);
1144
+ return /* @__PURE__ */ o("aside", { className: "w6w-server-resources w6w-server-resources--rail", children: [
1145
+ /* @__PURE__ */ o("div", { className: "w6w-server-resources__rail-row", children: [
1146
+ /* @__PURE__ */ t("span", { className: "w6w-server-resources__label", children: "CPU" }),
1147
+ /* @__PURE__ */ t("span", { className: "w6w-server-resources__value", children: $(B(n)) }),
1148
+ /* @__PURE__ */ t(
1149
+ ge,
1150
+ {
1151
+ className: "w6w-server-resources__spark",
1152
+ values: l,
1153
+ max: Z(l)
1154
+ }
1155
+ )
1156
+ ] }),
1157
+ /* @__PURE__ */ o("div", { className: "w6w-server-resources__rail-row", children: [
1158
+ /* @__PURE__ */ t("span", { className: "w6w-server-resources__label", children: "MEM" }),
1159
+ /* @__PURE__ */ t("span", { className: "w6w-server-resources__value", children: $(J(n)) }),
1160
+ /* @__PURE__ */ t(ge, { className: "w6w-server-resources__spark", values: d, max: 1 })
1161
+ ] }),
1162
+ s !== void 0 && /* @__PURE__ */ t(
1163
+ "button",
1164
+ {
1165
+ type: "button",
1166
+ className: "w6w-server-resources__expand",
1167
+ "aria-label": "Show server resources",
1168
+ onClick: s,
1169
+ children: "Details"
1170
+ }
1171
+ )
1172
+ ] });
1173
+ }
1174
+ function Hs({ samples: e }) {
1175
+ const s = e[e.length - 1], n = $(B(s)), l = $(J(s));
1176
+ return /* @__PURE__ */ t("span", { className: "w6w-server-resources w6w-server-resources--badge", children: `CPU ${n} · MEM ${l}` });
1177
+ }
1178
+ const ns = 1, as = 1440 * 60 * 1e3;
1179
+ function rs(e, s, n) {
1180
+ const l = s.startedAt ?? s.updatedAt;
1181
+ if (l === void 0) return null;
1182
+ const d = Date.parse(l), a = s.resolvedAt !== void 0 ? Date.parse(s.resolvedAt) : s.startedAt !== void 0 ? n : d, r = Date.parse(`${e.from}T00:00:00.000Z`), c = Date.parse(`${e.to}T00:00:00.000Z`) + as, u = c - r;
1183
+ if (a < r || d >= c) return null;
1184
+ const w = d < r, h = a > c, m = Math.max(d, r), p = Math.min(a, c), N = (m - r) / u * 100, ee = (p - m) / u * 100, y = Math.max(ee, ns);
1185
+ return { leftPct: N, widthPct: y, clippedStart: w, clippedEnd: h };
1186
+ }
1187
+ const ls = {
1188
+ ok: "Operational",
1189
+ degraded: "Degraded",
1190
+ down: "Down",
1191
+ unknown: "Unknown"
1192
+ }, is = "This vendor publishes no incident history.", os = "No incidents in this window.";
1193
+ function cs(e) {
1194
+ const s = e.startedAt ?? e.updatedAt, n = [e.title];
1195
+ return e.components !== void 0 && e.components.length > 0 && n.push(`(${e.components.join(", ")})`), s !== void 0 && n.push(
1196
+ e.resolvedAt !== void 0 ? `${s} – ${e.resolvedAt}` : `${s} – ongoing`
1197
+ ), n.join(" ");
1198
+ }
1199
+ function js({
1200
+ window: e,
1201
+ days: s,
1202
+ incidents: n,
1203
+ vendorEmptyLabel: l,
1204
+ nowMs: d = Date.now(),
1205
+ ariaLabel: a
1206
+ }) {
1207
+ const r = s.length, c = r > 0 ? 100 / r : 0, u = n === void 0 ? l ?? is : n.length === 0 ? l ?? os : null;
1208
+ return /* @__PURE__ */ t("div", { className: "w6w-history-timeline", role: "img", "aria-label": a ?? `${r}-day history`, children: /* @__PURE__ */ o("div", { className: "w6w-history-plot", children: [
1209
+ /* @__PURE__ */ t("div", { className: "w6w-history-lane w6w-history-lane-execution", children: s.map((w, h) => /* @__PURE__ */ t(
1210
+ "span",
1211
+ {
1212
+ className: `w6w-history-cell w6w-history-cell-${w.state}`,
1213
+ style: { left: `${h * c}%`, width: `${c}%` },
1214
+ title: w.label ?? `${w.day} — ${ls[w.state]}`
1215
+ },
1216
+ `${w.day}-${h}`
1217
+ )) }),
1218
+ /* @__PURE__ */ t("div", { className: "w6w-history-lane w6w-history-lane-vendor", children: u !== null ? /* @__PURE__ */ t("span", { className: "w6w-history-empty", title: u, children: u }) : n == null ? void 0 : n.map((w, h) => {
1219
+ const m = rs(e, w, d);
1220
+ if (m === null) return null;
1221
+ const p = [
1222
+ m.clippedStart ? "w6w-history-bar-clip-start" : "",
1223
+ m.clippedEnd ? "w6w-history-bar-clip-end" : ""
1224
+ ].filter(Boolean).join(" ");
1225
+ return /* @__PURE__ */ t(
1226
+ "span",
1227
+ {
1228
+ className: `w6w-history-bar w6w-history-bar-${w.state}${p ? ` ${p}` : ""}`,
1229
+ style: { left: `${m.leftPct}%`, width: `${m.widthPct}%` },
1230
+ title: cs(w)
1231
+ },
1232
+ w.id ?? `${w.title}-${h}`
1233
+ );
1234
+ }) }),
1235
+ /* @__PURE__ */ o("div", { className: "w6w-history-axis", children: [
1236
+ /* @__PURE__ */ t("span", { className: "w6w-history-tick w6w-history-tick-start", style: { left: "0%" }, children: e.from }),
1237
+ /* @__PURE__ */ t("span", { className: "w6w-history-tick w6w-history-tick-end", style: { left: "100%" }, children: e.to })
1238
+ ] })
1239
+ ] }) });
1240
+ }
1241
+ function qs({ label: e, children: s, className: n }) {
1242
+ const [l, d] = v(!1), a = Ut();
1243
+ return /* @__PURE__ */ o("span", { className: ["w6w-info-tip", n ?? ""].filter(Boolean).join(" "), children: [
1244
+ /* @__PURE__ */ t(
1245
+ L,
1246
+ {
1247
+ label: e,
1248
+ icon: "info",
1249
+ "aria-expanded": l,
1250
+ "aria-controls": a,
1251
+ onClick: () => d((r) => !r)
1252
+ }
1253
+ ),
1254
+ l && /* @__PURE__ */ t("span", { id: a, className: "w6w-info-tip-body w6w-muted w6w-small", children: s })
1255
+ ] });
1256
+ }
1257
+ function Ks(e) {
1258
+ const { label: s, onClick: n, disabled: l, className: d, ...a } = e;
1259
+ return /* @__PURE__ */ t(
1260
+ L,
1261
+ {
1262
+ label: s,
1263
+ onClick: n,
1264
+ disabled: l,
1265
+ className: d,
1266
+ icon: "edit",
1267
+ "data-testid": a["data-testid"]
1268
+ }
1269
+ );
1270
+ }
1271
+ function Ws(e) {
1272
+ const { label: s, onClick: n, disabled: l, className: d, ...a } = e;
1273
+ return /* @__PURE__ */ t(
1274
+ L,
1275
+ {
1276
+ label: s,
1277
+ onClick: n,
1278
+ disabled: l,
1279
+ className: d,
1280
+ danger: !0,
1281
+ icon: "delete",
1282
+ "data-testid": a["data-testid"]
1283
+ }
1284
+ );
1285
+ }
1286
+ function Vs(e) {
1287
+ const { branch: s, shortSha: n, lastSyncLabel: l, onSyncNow: d, syncing: a, className: r, ...c } = e, [u, w] = v(!1), h = Ft(null);
1288
+ return G(() => {
1289
+ if (!u) return;
1290
+ const m = (N) => {
1291
+ h.current && !h.current.contains(N.target) && w(!1);
1292
+ }, p = (N) => N.key === "Escape" && w(!1);
1293
+ return document.addEventListener("mousedown", m), document.addEventListener("keydown", p), () => {
1294
+ document.removeEventListener("mousedown", m), document.removeEventListener("keydown", p);
1295
+ };
1296
+ }, [u]), /* @__PURE__ */ o(
1297
+ "div",
1298
+ {
1299
+ className: `w6w-repo-sync${r ? ` ${r}` : ""}`,
1300
+ ref: h,
1301
+ "data-testid": c["data-testid"],
1302
+ children: [
1303
+ /* @__PURE__ */ o(
1304
+ "button",
1305
+ {
1306
+ type: "button",
1307
+ className: "w6w-repo-sync-trigger",
1308
+ "aria-haspopup": "menu",
1309
+ "aria-expanded": u,
1310
+ "aria-busy": a,
1311
+ onClick: () => w((m) => !m),
1312
+ children: [
1313
+ /* @__PURE__ */ o("span", { className: "w6w-repo-sync-icon", children: [
1314
+ /* @__PURE__ */ t(ze, { name: "github" }),
1315
+ a && /* @__PURE__ */ t(ze, { name: "sync", size: 10, className: "w6w-repo-sync-spin" })
1316
+ ] }),
1317
+ /* @__PURE__ */ t("span", { className: "w6w-repo-sync-branch", children: s }),
1318
+ n != null && /* @__PURE__ */ t("code", { className: "w6w-repo-sync-sha", children: n })
1319
+ ]
1320
+ }
1321
+ ),
1322
+ u && /* @__PURE__ */ o("div", { className: "w6w-repo-sync-menu", role: "menu", children: [
1323
+ /* @__PURE__ */ o("div", { className: "w6w-repo-sync-detail", children: [
1324
+ /* @__PURE__ */ t("span", { children: s }),
1325
+ n != null && /* @__PURE__ */ t("code", { children: n }),
1326
+ l != null && /* @__PURE__ */ t("span", { children: l })
1327
+ ] }),
1328
+ /* @__PURE__ */ t(
1329
+ "button",
1330
+ {
1331
+ type: "button",
1332
+ role: "menuitem",
1333
+ className: "w6w-repo-sync-item",
1334
+ "data-testid": "repo-sync-now",
1335
+ disabled: a,
1336
+ onClick: d,
1337
+ children: a ? "Syncing…" : "Sync now"
1338
+ }
1339
+ )
1340
+ ] })
1341
+ ]
1342
+ }
1343
+ );
1344
+ }
1345
+ const ds = {
1346
+ pending: "Pending",
1347
+ running: "Running",
1348
+ succeeded: "Succeeded",
1349
+ failed: "Failed",
1350
+ skipped: "Skipped",
1351
+ queued: "Queued",
1352
+ canceled: "Canceled"
1353
+ };
1354
+ function Se({ state: e, label: s, ariaLabel: n }) {
1355
+ const l = s ?? ds[e];
1356
+ return /* @__PURE__ */ o("span", { className: `w6w-step-pill w6w-step-pill-${e}`, "aria-label": n, children: [
1357
+ /* @__PURE__ */ t("span", { className: "w6w-step-pill-dot", "aria-hidden": "true" }),
1358
+ /* @__PURE__ */ t("span", { className: "w6w-step-pill-label", children: l })
1359
+ ] });
1360
+ }
1361
+ const us = "—", he = 1e3, pe = 6e4;
1362
+ function $e(e) {
1363
+ return e == null || !Number.isFinite(e) || e < 0 ? us : e < he ? `${Math.round(e)} ms` : e < pe ? `${(e / he).toFixed(1)} s` : `${Math.floor(e / pe)}m ${Math.round(e % pe / he)}s`;
1364
+ }
1365
+ function X(e) {
1366
+ const s = new Date(e);
1367
+ return Number.isNaN(s.getTime()) ? e : s.toLocaleString(void 0, { dateStyle: "medium", timeStyle: "short" });
1368
+ }
1369
+ const ws = {
1370
+ function: "Function",
1371
+ endpoint: "Endpoint",
1372
+ workflow: "Workflow"
1373
+ };
1374
+ function zs({
1375
+ items: e,
1376
+ selectedId: s = null,
1377
+ onSelect: n,
1378
+ showCallable: l = !1,
1379
+ loading: d = !1,
1380
+ emptyLabel: a,
1381
+ hasPrev: r,
1382
+ hasNext: c,
1383
+ onPrev: u,
1384
+ onNext: w
1385
+ }) {
1386
+ const h = u || w ? /* @__PURE__ */ o("div", { className: "w6w-execution-list-pager", children: [
1387
+ /* @__PURE__ */ t(
1388
+ "button",
1389
+ {
1390
+ type: "button",
1391
+ className: "w6w-btn w6w-btn-ghost",
1392
+ "data-testid": "execution-list-prev",
1393
+ disabled: !r,
1394
+ onClick: u,
1395
+ children: "Previous"
1396
+ }
1397
+ ),
1398
+ /* @__PURE__ */ t(
1399
+ "button",
1400
+ {
1401
+ type: "button",
1402
+ className: "w6w-btn w6w-btn-ghost",
1403
+ "data-testid": "execution-list-next",
1404
+ disabled: !c,
1405
+ onClick: w,
1406
+ children: "Next"
1407
+ }
1408
+ )
1409
+ ] }) : null;
1410
+ let m;
1411
+ return d && e.length === 0 ? m = /* @__PURE__ */ t("p", { "data-testid": "execution-list-loading", children: "Loading…" }) : e.length === 0 ? m = /* @__PURE__ */ t("p", { "data-testid": "execution-list-empty", children: a ?? "No executions yet." }) : m = /* @__PURE__ */ t("ul", { className: "w6w-execution-list-rows", children: e.map((p) => /* @__PURE__ */ t("li", { "data-testid": "execution-row", "data-execution-id": p.id, children: /* @__PURE__ */ t(
1412
+ Ne,
1413
+ {
1414
+ icon: /* @__PURE__ */ t(Se, { state: p.status }),
1415
+ title: l ? p.callableName : X(p.startedAt),
1416
+ subtitle: l ? `${ws[p.kind]} · ${X(p.startedAt)}` : p.id,
1417
+ trailing: $e(p.durationMs),
1418
+ active: p.id === s,
1419
+ onClick: n ? () => n(p.id) : void 0
1420
+ }
1421
+ ) }, p.id)) }), /* @__PURE__ */ o("div", { className: "w6w-execution-list", "data-testid": "execution-list", children: [
1422
+ m,
1423
+ h
1424
+ ] });
1425
+ }
1426
+ function ms({
1427
+ steps: e,
1428
+ emptyLabel: s,
1429
+ onDismiss: n,
1430
+ runError: l,
1431
+ stepErrors: d
1432
+ }) {
1433
+ const a = n ? /* @__PURE__ */ t("div", { className: "w6w-execution-log-head", children: /* @__PURE__ */ t(L, { label: "Dismiss run log", "data-testid": "execution-log-dismiss", onClick: n, children: "×" }) }) : null, r = d ?? [], c = l || r.length > 0 ? /* @__PURE__ */ o("div", { className: "w6w-execution-log-errors w6w-stack", children: [
1434
+ l && /* @__PURE__ */ t(be, { error: l }),
1435
+ r.map((u, w) => /* @__PURE__ */ t(
1436
+ be,
1437
+ {
1438
+ label: u.label ?? u.stepId,
1439
+ error: u.error
1440
+ },
1441
+ `${u.stepId}:${w}`
1442
+ ))
1443
+ ] }) : null;
1444
+ return e.length === 0 ? /* @__PURE__ */ o(k, { children: [
1445
+ a,
1446
+ c,
1447
+ /* @__PURE__ */ t("div", { className: "w6w-execution-log-empty", children: /* @__PURE__ */ t("p", { className: "w6w-muted w6w-small", children: s ?? "No steps have run yet." }) })
1448
+ ] }) : /* @__PURE__ */ o(k, { children: [
1449
+ a,
1450
+ c,
1451
+ /* @__PURE__ */ t("ol", { className: "w6w-execution-log", children: e.map((u) => /* @__PURE__ */ t(hs, { step: u }, u.id)) })
1452
+ ] });
1453
+ }
1454
+ function hs({ step: e }) {
1455
+ const [s, n] = v(!1), l = /* @__PURE__ */ o("div", { className: "w6w-execution-log-row-header", children: [
1456
+ /* @__PURE__ */ t(Se, { state: e.status }),
1457
+ /* @__PURE__ */ t("span", { className: "w6w-execution-log-row-label", children: e.label ?? e.id }),
1458
+ /* @__PURE__ */ t(ps, { startedAt: e.startedAt, finishedAt: e.finishedAt })
1459
+ ] }), d = e.error ? /* @__PURE__ */ t(be, { error: e.error }) : null;
1460
+ return e.input === void 0 && e.output === void 0 && !e.meta ? /* @__PURE__ */ o("li", { className: "w6w-execution-log-row", children: [
1461
+ /* @__PURE__ */ t("div", { className: "w6w-section", children: l }),
1462
+ d
1463
+ ] }) : /* @__PURE__ */ o("li", { className: "w6w-execution-log-row", children: [
1464
+ /* @__PURE__ */ o("details", { className: "w6w-section", open: s, onToggle: (a) => n(a.currentTarget.open), children: [
1465
+ /* @__PURE__ */ t("summary", { className: "w6w-section-summary", children: l }),
1466
+ s && /* @__PURE__ */ o("div", { className: "w6w-execution-log-row-body w6w-section-body w6w-stack", children: [
1467
+ /* @__PURE__ */ t(et, { title: "Input", value: e.input }),
1468
+ /* @__PURE__ */ t(et, { title: "Output", value: e.output }),
1469
+ e.meta && /* @__PURE__ */ o("div", { className: "w6w-execution-log-json w6w-stack", children: [
1470
+ /* @__PURE__ */ t("strong", { className: "w6w-small", children: "Metadata" }),
1471
+ /* @__PURE__ */ t(ke, { code: JSON.stringify(e.meta, null, 2), language: "json" })
1472
+ ] })
1473
+ ] })
1474
+ ] }),
1475
+ d
1476
+ ] });
1477
+ }
1478
+ function be({ error: e, label: s }) {
1479
+ return /* @__PURE__ */ o("div", { className: "w6w-result w6w-error", children: [
1480
+ s !== void 0 && /* @__PURE__ */ t("strong", { className: "w6w-execution-log-error-label", children: s }),
1481
+ e.code && /* @__PURE__ */ t("div", { className: "w6w-small w6w-execution-log-error-code", children: /* @__PURE__ */ t("code", { children: e.code }) }),
1482
+ e.message
1483
+ ] });
1484
+ }
1485
+ function ps({ startedAt: e, finishedAt: s }) {
1486
+ if (e && s) {
1487
+ const n = fs(e, s);
1488
+ return /* @__PURE__ */ o("span", { className: "w6w-execution-log-timing", children: [
1489
+ e,
1490
+ " → ",
1491
+ s,
1492
+ n && /* @__PURE__ */ o("span", { children: [
1493
+ " (",
1494
+ n,
1495
+ ")"
1496
+ ] })
1497
+ ] });
1498
+ }
1499
+ return e ? /* @__PURE__ */ o("span", { className: "w6w-execution-log-timing", children: [
1500
+ "Started ",
1501
+ e
1502
+ ] }) : /* @__PURE__ */ t("span", { className: "w6w-execution-log-timing", children: "—" });
1503
+ }
1504
+ function fs(e, s) {
1505
+ const n = Date.parse(e), l = Date.parse(s);
1506
+ if (!Number.isFinite(n) || !Number.isFinite(l) || l < n) return null;
1507
+ const d = l - n;
1508
+ if (d < 1e3) return `${d}ms`;
1509
+ const a = d / 1e3;
1510
+ if (a < 60) return `${a.toFixed(1)}s`;
1511
+ const r = Math.floor(a / 60), c = Math.round(a % 60);
1512
+ return `${r}m ${c}s`;
1513
+ }
1514
+ function et({ title: e, value: s }) {
1515
+ return /* @__PURE__ */ o("div", { className: "w6w-execution-log-json w6w-stack", children: [
1516
+ /* @__PURE__ */ t("strong", { className: "w6w-small", children: e }),
1517
+ s === void 0 ? /* @__PURE__ */ t("p", { className: "w6w-muted w6w-small", children: "Not available." }) : /* @__PURE__ */ t(ke, { code: JSON.stringify(s, null, 2), language: "json" })
1518
+ ] });
1519
+ }
1520
+ const vs = { status: "", kind: "", from: "", to: "", q: "" }, ys = [
1521
+ { value: "", label: "Any status" },
1522
+ { value: "queued", label: "Queued" },
1523
+ { value: "running", label: "Running" },
1524
+ { value: "succeeded", label: "Succeeded" },
1525
+ { value: "failed", label: "Failed" },
1526
+ { value: "canceled", label: "Canceled" }
1527
+ ], Ns = [
1528
+ { value: "", label: "Any type" },
1529
+ { value: "function", label: "Function" },
1530
+ { value: "endpoint", label: "Endpoint" },
1531
+ { value: "workflow", label: "Workflow" }
1532
+ ];
1533
+ function Gs({
1534
+ value: e,
1535
+ onChange: s,
1536
+ showKind: n = !1,
1537
+ searchPlaceholder: l = "Search by id or name",
1538
+ disabled: d = !1
1539
+ }) {
1540
+ const a = e.status !== "" || e.kind !== "" || e.from !== "" || e.to !== "" || e.q !== "";
1541
+ return /* @__PURE__ */ o("div", { className: "w6w-execution-filters", "data-testid": "execution-filters", children: [
1542
+ /* @__PURE__ */ t(
1543
+ "input",
1544
+ {
1545
+ type: "search",
1546
+ className: "w6w-execution-filters-search",
1547
+ "data-testid": "execution-filter-q",
1548
+ "aria-label": "Search executions",
1549
+ placeholder: l,
1550
+ value: e.q,
1551
+ disabled: d,
1552
+ onChange: (r) => s({ ...e, q: r.target.value })
1553
+ }
1554
+ ),
1555
+ /* @__PURE__ */ t(
1556
+ "select",
1557
+ {
1558
+ className: "w6w-execution-filters-select",
1559
+ "data-testid": "execution-filter-status",
1560
+ "aria-label": "Status",
1561
+ value: e.status,
1562
+ disabled: d,
1563
+ onChange: (r) => s({ ...e, status: r.target.value }),
1564
+ children: ys.map((r) => /* @__PURE__ */ t("option", { value: r.value, children: r.label }, r.value))
1565
+ }
1566
+ ),
1567
+ n && /* @__PURE__ */ t(
1568
+ "select",
1569
+ {
1570
+ className: "w6w-execution-filters-select",
1571
+ "data-testid": "execution-filter-kind",
1572
+ "aria-label": "Type",
1573
+ value: e.kind,
1574
+ disabled: d,
1575
+ onChange: (r) => s({ ...e, kind: r.target.value }),
1576
+ children: Ns.map((r) => /* @__PURE__ */ t("option", { value: r.value, children: r.label }, r.value))
1577
+ }
1578
+ ),
1579
+ /* @__PURE__ */ t(
1580
+ "input",
1581
+ {
1582
+ type: "date",
1583
+ className: "w6w-execution-filters-date",
1584
+ "data-testid": "execution-filter-from",
1585
+ "aria-label": "From date",
1586
+ value: e.from,
1587
+ disabled: d,
1588
+ onChange: (r) => s({ ...e, from: r.target.value })
1589
+ }
1590
+ ),
1591
+ /* @__PURE__ */ t(
1592
+ "input",
1593
+ {
1594
+ type: "date",
1595
+ className: "w6w-execution-filters-date",
1596
+ "data-testid": "execution-filter-to",
1597
+ "aria-label": "To date",
1598
+ value: e.to,
1599
+ disabled: d,
1600
+ onChange: (r) => s({ ...e, to: r.target.value })
1601
+ }
1602
+ ),
1603
+ a && /* @__PURE__ */ t(
1604
+ "button",
1605
+ {
1606
+ type: "button",
1607
+ className: "w6w-btn w6w-btn-ghost w6w-execution-filters-clear",
1608
+ "data-testid": "execution-filter-clear",
1609
+ disabled: d,
1610
+ onClick: () => s({ ...vs }),
1611
+ children: "Clear"
1612
+ }
1613
+ )
1614
+ ] });
1615
+ }
1616
+ const Y = "—";
1617
+ function Qs({ stats: e, label: s }) {
1618
+ const n = [
1619
+ {
1620
+ testid: "execution-stat-total",
1621
+ label: "Executions",
1622
+ value: e ? String(e.total) : Y
1623
+ },
1624
+ {
1625
+ testid: "execution-stat-success-rate",
1626
+ label: "Success rate",
1627
+ value: gs(e == null ? void 0 : e.successRate)
1628
+ },
1629
+ {
1630
+ testid: "execution-stat-failed",
1631
+ label: "Failed",
1632
+ value: e ? String(e.failed) : Y
1633
+ },
1634
+ {
1635
+ testid: "execution-stat-avg-duration",
1636
+ label: "Avg duration",
1637
+ value: e ? $e(e.avgDurationMs) : Y
1638
+ }
1639
+ ];
1640
+ return e && e.inFlight > 0 && n.push({
1641
+ testid: "execution-stat-in-flight",
1642
+ label: "In flight",
1643
+ value: String(e.inFlight)
1644
+ }), /* @__PURE__ */ o("section", { className: "w6w-execution-stats", "data-testid": "execution-stats", children: [
1645
+ s != null && /* @__PURE__ */ t("p", { className: "w6w-execution-stats-label", children: s }),
1646
+ /* @__PURE__ */ t("div", { className: "w6w-execution-stats-cards", children: n.map((l) => /* @__PURE__ */ o("div", { className: "w6w-execution-stat", "data-testid": l.testid, children: [
1647
+ /* @__PURE__ */ t("span", { className: "w6w-execution-stat-value", "data-stat-value": l.value, children: l.value }),
1648
+ /* @__PURE__ */ t("span", { className: "w6w-execution-stat-label", children: l.label })
1649
+ ] }, l.testid)) })
1650
+ ] });
1651
+ }
1652
+ function gs(e) {
1653
+ return e == null || !Number.isFinite(e) ? Y : `${Math.round(e * 100)}%`;
1654
+ }
1655
+ const bs = {
1656
+ function: "Function",
1657
+ endpoint: "Endpoint",
1658
+ workflow: "Workflow"
1659
+ };
1660
+ function ks(e) {
1661
+ return JSON.stringify(e, null, 2) ?? "null";
1662
+ }
1663
+ function Ys({
1664
+ execution: e,
1665
+ loading: s = !1,
1666
+ errorMessage: n,
1667
+ onClose: l,
1668
+ onOpenInEditor: d
1669
+ }) {
1670
+ return /* @__PURE__ */ o("section", { className: "w6w-execution-detail w6w-stack", "data-testid": "execution-detail", children: [
1671
+ n != null && /* @__PURE__ */ t(
1672
+ "p",
1673
+ {
1674
+ role: "alert",
1675
+ className: "w6w-execution-detail-error-message",
1676
+ "data-testid": "execution-detail-error-message",
1677
+ children: n
1678
+ }
1679
+ ),
1680
+ e ? /* @__PURE__ */ t(xs, { execution: e, onClose: l, onOpenInEditor: d }) : s ? /* @__PURE__ */ t("p", { className: "w6w-muted", "data-testid": "execution-detail-loading", children: "Loading…" }) : /* @__PURE__ */ t("p", { className: "w6w-muted", "data-testid": "execution-detail-empty", children: "No execution selected." })
1681
+ ] });
1682
+ }
1683
+ function xs({
1684
+ execution: e,
1685
+ onClose: s,
1686
+ onOpenInEditor: n
1687
+ }) {
1688
+ return /* @__PURE__ */ o(k, { children: [
1689
+ /* @__PURE__ */ o("div", { className: "w6w-execution-detail-head", children: [
1690
+ /* @__PURE__ */ o("div", { className: "w6w-execution-detail-title", children: [
1691
+ /* @__PURE__ */ t("h3", { className: "w6w-execution-detail-name", children: e.callableName }),
1692
+ /* @__PURE__ */ o("div", { className: "w6w-execution-detail-meta", children: [
1693
+ /* @__PURE__ */ t(Se, { state: e.status }),
1694
+ /* @__PURE__ */ t("span", { className: "w6w-execution-detail-kind w6w-muted w6w-small", children: bs[e.kind] })
1695
+ ] })
1696
+ ] }),
1697
+ (n || s) && /* @__PURE__ */ o("div", { className: "w6w-execution-detail-actions", children: [
1698
+ n && /* @__PURE__ */ t(
1699
+ "button",
1700
+ {
1701
+ type: "button",
1702
+ className: "w6w-btn w6w-btn-ghost",
1703
+ "data-testid": "execution-detail-open-editor",
1704
+ onClick: n,
1705
+ children: "Open in visual editor"
1706
+ }
1707
+ ),
1708
+ s && /* @__PURE__ */ t(L, { label: "Close", "data-testid": "execution-detail-close", onClick: s, children: "×" })
1709
+ ] })
1710
+ ] }),
1711
+ /* @__PURE__ */ t("p", { className: "w6w-execution-detail-id-line", children: /* @__PURE__ */ t("code", { className: "w6w-execution-detail-id", "data-testid": "execution-detail-id", children: e.id }) }),
1712
+ /* @__PURE__ */ o("dl", { className: "w6w-execution-detail-timing", children: [
1713
+ /* @__PURE__ */ t(fe, { label: "Started", value: X(e.startedAt) }),
1714
+ /* @__PURE__ */ t(
1715
+ fe,
1716
+ {
1717
+ label: "Finished",
1718
+ value: e.finishedAt ? X(e.finishedAt) : "—"
1719
+ }
1720
+ ),
1721
+ /* @__PURE__ */ t(fe, { label: "Duration", value: $e(e.durationMs) })
1722
+ ] }),
1723
+ e.steps !== void 0 && /* @__PURE__ */ o(
1724
+ "section",
1725
+ {
1726
+ className: "w6w-execution-detail-section w6w-stack",
1727
+ "data-testid": "execution-detail-steps",
1728
+ children: [
1729
+ /* @__PURE__ */ t("strong", { className: "w6w-small", children: "Steps" }),
1730
+ /* @__PURE__ */ t(ms, { steps: e.steps, emptyLabel: "No steps ran." })
1731
+ ]
1732
+ }
1733
+ ),
1734
+ e.input !== void 0 && /* @__PURE__ */ t(ve, { title: "Input", testid: "execution-detail-input", value: e.input }),
1735
+ e.output !== void 0 && /* @__PURE__ */ t(ve, { title: "Output", testid: "execution-detail-output", value: e.output }),
1736
+ e.error != null && /* @__PURE__ */ t(ve, { title: "Error", testid: "execution-detail-error", value: e.error })
1737
+ ] });
1738
+ }
1739
+ function fe({ label: e, value: s }) {
1740
+ return /* @__PURE__ */ o("div", { className: "w6w-execution-detail-timing-item", children: [
1741
+ /* @__PURE__ */ t("dt", { children: e }),
1742
+ /* @__PURE__ */ t("dd", { children: s })
1743
+ ] });
1744
+ }
1745
+ function ve({ title: e, testid: s, value: n }) {
1746
+ return /* @__PURE__ */ o("section", { className: "w6w-execution-detail-section w6w-stack", "data-testid": s, children: [
1747
+ /* @__PURE__ */ t("strong", { className: "w6w-small", children: e }),
1748
+ /* @__PURE__ */ t(ke, { code: ks(n), language: "json" })
1749
+ ] });
1750
+ }
1751
+ export {
1752
+ Ps as ActionTestForm,
1753
+ en as AddConnectionModal,
1754
+ Wt as ApiCallsPanel,
1755
+ ce as ApiError,
1756
+ tn as AppIcon,
1757
+ sn as AppPicker,
1758
+ nn as AuthFieldsForm,
1759
+ ke as CodeBlock,
1760
+ an as CodeEditor,
1761
+ _t as Combobox,
1762
+ Pt as ConfirmModal,
1763
+ qt as Copyable,
1764
+ Us as CopyableText,
1765
+ Ws as DeleteButton,
1766
+ Ks as EditButton,
1767
+ Ys as ExecutionDetail,
1768
+ Gs as ExecutionFilters,
1769
+ zs as ExecutionList,
1770
+ ms as ExecutionLogPanel,
1771
+ Qs as ExecutionStats,
1772
+ rn as ExpressionInput,
1773
+ ln as ExpressionOptionsProvider,
1774
+ Fs as HealthStatusPill,
1775
+ js as HistoryTimeline,
1776
+ ze as Icon,
1777
+ L as IconButton,
1778
+ qs as InfoTip,
1779
+ z as JsonEditor,
1780
+ Ne as ListItem,
1781
+ Ve as Modal,
1782
+ on as NodeConfigForm,
1783
+ Mt as ParamsForm,
1784
+ cn as PropertyEntryForm,
1785
+ Vs as RepoSyncIndicator,
1786
+ dn as RetryPolicyFields,
1787
+ Hs as ServerResourcesBadge,
1788
+ Bs as ServerResourcesCard,
1789
+ Js as ServerResourcesCardSmall,
1790
+ Ds as ServerResourcesRail,
1791
+ un as StepBuilderModal,
1792
+ Se as StepStatusPill,
1793
+ Ls as UptimeStrip,
1794
+ wn as W6WUIProvider,
1795
+ Is as YamlEditor,
1796
+ _s as createW6WApi,
1797
+ Qt as cropText,
1798
+ mn as filterOptions,
1799
+ $e as formatDurationMs,
1800
+ X as formatExecutionTime,
1801
+ xn as iconNames,
1802
+ hn as isExprValue,
1803
+ pn as isSecretValue,
1804
+ fn as isTestRequired,
1805
+ vn as requiredParamsFilled,
1806
+ yn as shouldUseCombobox,
1807
+ Nn as startOAuthPopup,
1808
+ gn as useEnterSubmit,
1809
+ bn as useExpressionOptions,
1810
+ Et as useW6WApi
1811
+ };
1812
+ //# sourceMappingURL=index.mjs.map