@isoloop/devtools 0.0.0-stage → 0.1.0-next.10

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.
package/dist/panel.js ADDED
@@ -0,0 +1,3120 @@
1
+ /** Topics under this prefix belong to the kernel (ADR 0002). */
2
+ const SYSTEM_TOPIC_PREFIX = "isoloop.";
3
+ function isSystemTopic(topic) {
4
+ return topic.startsWith(SYSTEM_TOPIC_PREFIX);
5
+ }
6
+ Object.freeze([
7
+ "mcp",
8
+ "webmcp",
9
+ "builder"
10
+ ]);
11
+ /** Wraps a hand-written check as a Standard Schema that passes valid values through unchanged. */
12
+ function systemSchema(check) {
13
+ return { "~standard": {
14
+ version: 1,
15
+ vendor: "isoloop",
16
+ validate: (value) => {
17
+ const issues = check(value, []);
18
+ return issues.length === 0 ? { value } : { issues };
19
+ }
20
+ } };
21
+ }
22
+ /** Defines a system topic. The name must start with `isoloop.`. */
23
+ function systemTopic(name, def) {
24
+ if (!isSystemTopic(name)) throw new Error(`system topic names start with isoloop.: ${name}`);
25
+ return Object.freeze({
26
+ ...def,
27
+ name
28
+ });
29
+ }
30
+ const isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
31
+ const issue = (path, message) => [{
32
+ message,
33
+ path
34
+ }];
35
+ /** Small building blocks for hand-written checks. */
36
+ const checks = {
37
+ string: (v, path) => typeof v === "string" ? [] : issue(path, "expected a string"),
38
+ optionalString: (v, path) => v === void 0 || typeof v === "string" ? [] : issue(path, "expected a string or nothing"),
39
+ object: (fields) => (v, path) => {
40
+ if (!isObject(v)) return issue(path, "expected an object");
41
+ return Object.entries(fields).flatMap(([k, check]) => check(v[k], [...path, k]));
42
+ },
43
+ any: () => []
44
+ };
45
+ const stringOrNull = (v, path) => v === null || typeof v === "string" ? [] : [{
46
+ message: "expected a string or null",
47
+ path
48
+ }];
49
+ systemTopic("isoloop.route.v1", {
50
+ schema: systemSchema(checks.object({
51
+ href: checks.string,
52
+ pathname: checks.string,
53
+ path: stringOrNull,
54
+ search: checks.string,
55
+ hash: checks.string,
56
+ state: checks.any
57
+ })),
58
+ retention: { kind: "compacted" }
59
+ });
60
+ /** `"0.4.2"` → `"0.4"`. Anything that isn't `major.minor[.patch…]` gives `undefined`. */
61
+ function majorMinor(version) {
62
+ const m = /^(\d+)\.(\d+)(?:[.+-].*)?$/.exec(version);
63
+ return m ? `${Number(m[1])}.${Number(m[2])}` : void 0;
64
+ }
65
+ // ../runtime/dist/index.js
66
+ /**
67
+ * This build's stamp: `major.minor` of the package version, inlined when tsdown bundles it.
68
+ *
69
+ * @internal
70
+ */
71
+ const REQUIRES = majorMinor("0.1.0-next.10") ?? "0.0";
72
+ // ../../node_modules/.pnpm/preact@11.1.1/node_modules/preact/dist/preact.mjs
73
+ var n;
74
+ var t$1;
75
+ var i$1;
76
+ var u$2;
77
+ var f$2;
78
+ var e$1;
79
+ var o$2;
80
+ var l$1;
81
+ var c$1;
82
+ var a$2;
83
+ var s$1;
84
+ var h$1 = Symbol.for("pv");
85
+ var p$1 = {};
86
+ var v$1 = [];
87
+ var y$1 = /^m(i|n|o|s|text|space)$/;
88
+ var w$1 = Array.isArray;
89
+ var d$1 = v$1.slice;
90
+ var _$1 = Object.assign;
91
+ function g$1(n) {
92
+ n && n.parentNode && n.remove();
93
+ }
94
+ function k$1(n, t, r) {
95
+ var i, u, f, e = {}, o = arguments.length;
96
+ for (f in t) "key" == f ? i = t[f] : "ref" == f && "function" != typeof n ? u = t[f] : e[f] = t[f];
97
+ return o > 2 && (e.children = o > 3 ? d$1.call(arguments, 2) : r), m$1(n, e, i, u, null);
98
+ }
99
+ function m$1(r, i, u, f, e) {
100
+ var o = {
101
+ type: r,
102
+ props: i,
103
+ key: u,
104
+ ref: f,
105
+ __k: null,
106
+ __: null,
107
+ __b: 0,
108
+ __e: null,
109
+ __c: null,
110
+ constructor: h$1,
111
+ __v: e || ++t$1,
112
+ __i: -1,
113
+ __u: 0
114
+ };
115
+ return !e && n.vnode && n.vnode(o), o;
116
+ }
117
+ function M(n) {
118
+ return n.children;
119
+ }
120
+ function x(n, t) {
121
+ this.props = n, this.context = t, this.__g = 0;
122
+ }
123
+ function S(n, t) {
124
+ if (null == t) return n.__ && S(n.__, n.__i + 1);
125
+ for (var r; t < n.__k.length; t++) if ((r = n.__k[t]) && r.__e) return r.__e;
126
+ return "function" != typeof n.type || n.props.__P ? null : S(n);
127
+ }
128
+ function C$1(n) {
129
+ if ((n = n.__) && n.__c && !n.props.__P) return n.__e = null, n.__k.some(function(t) {
130
+ return t && (n.__e = t.__e);
131
+ }), C$1(n);
132
+ }
133
+ function j$1(t) {
134
+ (8 & t.__g || (t.__g |= 8, i$1.push(t), f$2++)) && u$2 == n.debounceRendering || ((u$2 = n.debounceRendering) || queueMicrotask)(L);
135
+ }
136
+ function L() {
137
+ var t, r, o, l, c, a, s, p, v;
138
+ try {
139
+ for (r = 1; i$1.length;) i$1.length > r && i$1.sort(e$1), t = i$1.shift(), r = i$1.length, 8 & t.__g && (l = void 0, c = void 0, a = (c = (o = t).__v).__e, s = [], p = [], (v = o.__P) && ((l = _$1({ constructor: h$1 }, c)).__v = c.__v + 1, n.vnode && n.vnode(l), V(v, l, c, o.__n, v.namespaceURI, 32 & c.__u ? [a] : null, s, a || S(c), 32 & c.__u, p), l.__v = c.__v, l.__.__k[l.__i] = l, D$1(s, l, p), c.__ = c.__e = null, l.__e != a && C$1(l)));
140
+ } finally {
141
+ (f$2 = i$1.length) && (u$2 || queueMicrotask)(L);
142
+ }
143
+ }
144
+ function H(n, t, r, i, u, f, e, o, l, c, a) {
145
+ var s, h, y, w, d, _, g = i.__k || v$1, k = t.length;
146
+ for (l = I(r, t, g, l, k), s = 0; s < k; s++) null != (y = r.__k[s]) && (h = ~y.__i && g[y.__i] || p$1, y.__i = s, _ = V(n, y, h, u, f, e, o, l, c, a), w = y.__e, (h.ref != y.ref || 8 & h.__u) && (h.ref && F(h.ref, null, y, h), y.ref && a.push(y.ref, y.__c || w, y)), d = d || w, 4 & y.__u ? (l = q(y, l, n, !h.__v), h.__e && (h.__e = null)) : "function" == typeof y.type && void 0 !== _ ? l = _ : w && (l = w.nextSibling), y.__u &= -21);
147
+ return r.__e = d, l;
148
+ }
149
+ function I(n, t, r, i, u) {
150
+ var f, e, o, l, c, a, s, p, v, y = r.length, d = y, _ = 0, g = 0, k = n.__k = Array(u);
151
+ for (f = 0; f < u; f++) null != (e = t[f]) && "boolean" != typeof e && "function" != typeof e ? ("object" != typeof e || e.constructor === String ? e = k[f] = m$1(null, e) : w$1(e) ? e = k[f] = m$1(M, { children: e }) : e.constructor === h$1 && e.__b ? e = k[f] = m$1(e.type, e.props, e.key, e.ref, e.__v) : k[f] = e, l = f + _, e.__ = n, e.__b = n.__b + 1, o = null, ~(c = e.__i = O(e, r, l, d)) && (d--, (o = r[c]) && (o.__u |= 2)), o && o.__v ? (e.__u |= 16, c == l - 1 ? _-- : c == l + 1 ? _++ : c != l && (c > l ? _-- : _++, g = 1)) : (~c || (u > y ? _-- : u < y && _++), "function" != typeof e.type && (e.__u |= 4))) : k[f] = null;
152
+ if (g) {
153
+ for (a = [], s = [], f = 0; f < u; f++) if ((e = k[f]) && 16 & e.__u) {
154
+ for (_ = 0, p = a.length; _ < p;) a[v = _ + p >> 1] < e.__i ? _ = v + 1 : p = v;
155
+ a[_] = e.__i, s[f] = _ + 1;
156
+ }
157
+ for (_ = a.length; f--;) s[f] && (s[f] == _ ? _-- : k[f].__u |= 4);
158
+ }
159
+ if (d) for (f = 0; f < y; f++) !(o = r[f]) || 2 & o.__u || (o.__e == i && (i = S(o)), G$1(o, o));
160
+ return i;
161
+ }
162
+ function q(n, t, r, i) {
163
+ var u, f, e, o;
164
+ if ("function" == typeof n.type) {
165
+ if (n.props.__P) return t;
166
+ if (u = n.__k) for (f = 0; f < u.length; f++) u[f] && (u[f].__ = n, t = q(u[f], t, r, !1));
167
+ return t;
168
+ }
169
+ for (t && !t.parentNode && (t = S(n)) && !t.parentNode && (t = null), e = n.__e, o = t; o && 8 == o.nodeType;) o = o.nextSibling;
170
+ for (e != o && (!i && r.moveBefore && e.parentNode ? r.moveBefore(e, t) : r.insertBefore(e, t || null)), t = e; (t = t && t.nextSibling) && 8 == t.nodeType && !t.data.startsWith("$s"););
171
+ return t;
172
+ }
173
+ function O(n, t, r, i) {
174
+ var u, f = n.key, e = n.type, o = t[r], l = o && !(2 & o.__u);
175
+ if (null === o && null == f || l && f == o.key && e == o.type) return r;
176
+ if (i > (l ? 1 : 0)) {
177
+ for (u = r - 1; u >= 0; u--) if ((o = t[u]) && !(2 & o.__u) && f == o.key && e == o.type) return u;
178
+ for (u = r + 1; u < t.length; u++) if ((o = t[u]) && !(2 & o.__u) && f == o.key && e == o.type) return u;
179
+ }
180
+ return -1;
181
+ }
182
+ function P(n, t, r) {
183
+ r ??= "", "-" == t[0] ? n.setProperty(t, r) : n[t] = r;
184
+ }
185
+ function T$1(n, t, r, i, u) {
186
+ var f, e;
187
+ if ("style" == t) if ("string" == typeof r) n.style.cssText = r;
188
+ else {
189
+ if ("string" == typeof i && (n.style.cssText = i = ""), i) for (t in i) r && t in r || P(n.style, t);
190
+ if (r) for (t in r) i && r[t] == i[t] || P(n.style, t, r[t]);
191
+ }
192
+ else if ("o" == t[0] && "n" == t[1]) (n.__e || (n.__e = {}))[t] = r, r && i || (e = a$2[t] || (a$2[t] = N(t)), (n.__a || (n.__a = {}))[t] = c$1, f = t != (t = t.replace(l$1, "$1")), (t = t.slice(2))[0] < "a" && (t = t.toLowerCase()), r ? n.addEventListener(t, e, f) : n.removeEventListener(t, e, f));
193
+ else {
194
+ if ("http://www.w3.org/2000/svg" == u) t = t.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
195
+ else if ("width" != t && "height" != t && "href" != t && "list" != t && "form" != t && "tabIndex" != t && "download" != t && "rowSpan" != t && "colSpan" != t && "role" != t && "popover" != t && t in n) try {
196
+ n[t] = null == r ? "" : r;
197
+ return;
198
+ } catch (n) {}
199
+ if ("function" == typeof r) return;
200
+ null == r || !1 === r && "-" != t[4] ? n.removeAttribute(t) : n.setAttribute(t, "popover" == t && 1 == r ? "" : r);
201
+ }
202
+ }
203
+ function N(t) {
204
+ return function(r) {
205
+ var i = this.__e;
206
+ if (i) {
207
+ if (i = i[t], null == r[o$2]) r[o$2] = c$1++;
208
+ else if (r[o$2] < this.__a[t]) return;
209
+ return i(n.event ? n.event(r) : r);
210
+ }
211
+ };
212
+ }
213
+ function V(t, r, i, u, f, e, o, l, c, a) {
214
+ var s, p, y, d, k, b, m, $, C, j, L, I, q, A, O, P, T, N, V = r.type;
215
+ if (r.constructor !== h$1) return null;
216
+ 128 & i.__u && (c = 32 & i.__u, s = i.__c.__z) && (r.__u |= c, p = e = [], 8 == s.nodeType ? l = z$1(s, e) : e.push(s), l = e[0] || l), (s = n.__b) && s(r);
217
+ n: if ("function" == typeof V) {
218
+ y = o.length;
219
+ try {
220
+ if ($ = r.props, C = (s = V.prototype) && s.render, j = (s = V.contextType) && u[s.__c], L = s ? j ? j.props.value : s.__ : u, (d = i.__c) ? (r.__c = d, 2 & d.__g && (d.__g |= 1)) : (C ? r.__c = d = new V($, L) : (r.__c = d = new x($, L), d.constructor = V, d.render = J), j && j.sub(d), d.state || (d.state = {}), d.__n = u, d.__g |= 8, d.__h = [], d.__k = []), C && (d.__s || (d.__s = d.state), V.getDerivedStateFromProps && (d.__s == d.state && (d.__s = _$1({}, d.__s)), _$1(d.__s, V.getDerivedStateFromProps($, d.__s)))), k = d.props, b = d.state, d.__v = r, i.__c) {
221
+ if ($ !== k && C && !V.getDerivedStateFromProps && d.componentWillReceiveProps && d.componentWillReceiveProps($, L), r.__v == i.__v && !(8 & d.__g) || !(4 & d.__g) && d.shouldComponentUpdate && !1 === d.shouldComponentUpdate($, d.__s, L)) {
222
+ r.__v != i.__v && (d.props = $, d.state = d.__s, d.__g &= -9), r.__e = i.__e, r.__k = i.__k, r.__k.some(function(n) {
223
+ n && (n.__ = r);
224
+ }), v$1.push.apply(d.__h, d.__k), d.__k = [], d.__h.length && o.push(d), l = S(i);
225
+ break n;
226
+ }
227
+ d.componentWillUpdate && d.componentWillUpdate($, d.__s, L), C && d.componentDidUpdate && d.__h.push(function() {
228
+ d.componentDidUpdate(k, b, m);
229
+ });
230
+ } else C && !V.getDerivedStateFromProps && d.componentWillMount && d.componentWillMount(), C && d.componentDidMount && d.__h.push(d.componentDidMount);
231
+ if (d.context = L, d.props = $, d.__P = t, d.__g &= -5, I = n.__r, q = 0, C) d.state = d.__s, d.__g &= -9, I && I(r), s = d.render(d.props, d.state, d.context), v$1.push.apply(d.__h, d.__k), d.__k = [];
232
+ else do
233
+ d.__g &= -9, I && I(r), s = d.render(d.props, d.state, d.context), d.state = d.__s;
234
+ while (8 & d.__g && ++q < 25);
235
+ d.state = d.__s, d.getChildContext && (u = _$1({}, u, d.getChildContext())), C && i.__c && d.getSnapshotBeforeUpdate && (m = d.getSnapshotBeforeUpdate(k, b)), A = s && s.type === M && null == s.key ? s.props.children : s, $.__P && (s = l, f = (t = $.__P).namespaceURI, c = e = null, i.props && i.props.__P != t && (i.__k.some(function(n) {
236
+ n && G$1(n, n);
237
+ }), i.__k = null), l = i.__k ? S(i, 0) : null), l = H(t, w$1(A) ? A : [A], r, i, u, f, e, o, l, c, a), $.__P && (r.__e = null, l = s), r.__u &= -161, p && p.some(g$1), d.__h.length && o.push(d), 1 & d.__g && (d.__g &= -4);
238
+ } catch (t) {
239
+ if (o.length = y, r.__v = null, c || e) if (t.then) {
240
+ if (O = 0, r.__u |= 128 | c, e) {
241
+ for (~(T = e.indexOf(l || void 0)) || (T = e.length); (N = e[T - 1]) && 8 == N.nodeType;) T--;
242
+ for (; T < e.length; T++) if (N = e[T]) {
243
+ if (e[T] = null, 8 == N.nodeType) {
244
+ if (N.data.startsWith("$s")) O++ || (P = N);
245
+ else if (O && N.data.startsWith("/$s") && !--O) break;
246
+ } else if (!O) break;
247
+ }
248
+ }
249
+ if (!P) {
250
+ for (; l && 8 == l.nodeType && l.nextSibling;) l = l.nextSibling;
251
+ P = l;
252
+ }
253
+ (s = z$1(P = r.__c.__z || (r.__c.__z = P))) ? (r.__e = P, l = s) : r.__e = l, l = l && l.nextSibling;
254
+ } else e && e.some(g$1);
255
+ else r.__e = i.__e;
256
+ r.__k || (r.__k = i.__k || []), t.then || B$1(r), n.__e(t, r, i);
257
+ }
258
+ } else l = r.__e = E$1(i.__e, r, i, u, f, e, o, c, a, t);
259
+ return (s = n.diffed) && s(r), l;
260
+ }
261
+ function z$1(n, t) {
262
+ if (n && 8 == n.nodeType && n.data.startsWith("$s")) for (var r = 1; n = n.nextSibling;) {
263
+ if (8 == n.nodeType) {
264
+ if (n.data.startsWith("$s")) r++;
265
+ else if (n.data.startsWith("/$s") && !--r) return n;
266
+ }
267
+ t && t.push(n);
268
+ }
269
+ }
270
+ function B$1(n) {
271
+ n && (n.__c && (n.__c.__g |= 4), n.__k && n.__k.some(B$1));
272
+ }
273
+ function D$1(t, r, i) {
274
+ for (var u = 0; u < i.length;) F(i[u++], i[u++], i[u++]);
275
+ n.__c && n.__c(r, t), t.some(function(r) {
276
+ try {
277
+ t = r.__h, r.__h = [], t.some(function(n) {
278
+ n.call(r);
279
+ });
280
+ } catch (t) {
281
+ n.__e(t, r.__v);
282
+ }
283
+ });
284
+ }
285
+ function E$1(t, r, i, u, f, e, o, l, c, a) {
286
+ var s, h, v, _, k, b, m, $, M, x = i.props || p$1, C = r.props, j = r.type;
287
+ if ("svg" == j ? f = "http://www.w3.org/2000/svg" : "math" == j ? f = "http://www.w3.org/1998/Math/MathML" : f || (f = "http://www.w3.org/1999/xhtml"), e) {
288
+ for (s = 0; s < e.length; s++) if ((k = e[s]) && (j ? k.localName == j : 3 == k.nodeType)) {
289
+ t = k, e[s] = null;
290
+ break;
291
+ }
292
+ }
293
+ if (!t) {
294
+ if ($ = a.ownerDocument || document, !j) return $.createTextNode(C);
295
+ t = $.createElementNS(f, j, C.is && C), l && (n.__m && n.__m(r, e), l = !1), e = null;
296
+ }
297
+ if (j) {
298
+ if (a = "template" == j && t.content || t, e = "textarea" == j && null != C.defaultValue ? null : e && d$1.call(a.childNodes), !l && e) for (x = {}, s = 0; s < t.attributes.length; s++) x[(k = t.attributes[s]).name] = k.value;
299
+ for (s in x) k = x[s], "dangerouslySetInnerHTML" == s ? v = k : "children" == s || s in C || "value" == s && "defaultValue" in C || "checked" == s && "defaultChecked" in C || T$1(t, s, null, k, f);
300
+ for (s in M = 1 & i.__u, C) k = C[s], "children" == s ? _ = k : "dangerouslySetInnerHTML" == s ? h = k : "value" == s ? b = k : "checked" == s ? m = k : l && "function" != typeof k || !(x[s] !== k || M && null != k) || T$1(t, s, k, x[s], f);
301
+ h ? (l || v && (h.__html == v.__html || h.__html == t.innerHTML) || (t.innerHTML = h.__html), r.__k = []) : (v && (t.textContent = ""), ("foreignObject" == j || "http://www.w3.org/1998/Math/MathML" == f && y$1.test(j)) && (f = "http://www.w3.org/1999/xhtml"), H(a, w$1(_) ? _ : [_], r, i, u, f, e, o, e ? e[0] : i.__k && S(i, 0), l, c), e && e.some(g$1)), l && "textarea" != j || (s = "value", "progress" == j && null == b ? t.removeAttribute(s) : null == b || b === t[s] && ("progress" != j || b) || T$1(t, s, b, x[s], f), s = "checked", null != m && m != t[s] && T$1(t, s, m, x[s], f));
302
+ } else x === C || l && t.data == C || (t.data = C);
303
+ return t;
304
+ }
305
+ function F(t, r, i, u) {
306
+ try {
307
+ "function" == typeof t ? r ? r.__x = t(r) || 1 : u && (u = u.__c || u.__e) && (r = u.__x) && (u.__x = null, "function" == typeof r ? r() : t(null)) : t.current = r;
308
+ } catch (t) {
309
+ n.__e(t, i);
310
+ }
311
+ }
312
+ function G$1(t, r, i) {
313
+ var u, f, e, o;
314
+ if (n.unmount && n.unmount(t), !(u = t.ref) || u.current && u.current != t.__e || F(u, null, r, t), u = t.__c) {
315
+ if (u.componentWillUnmount) try {
316
+ u.componentWillUnmount();
317
+ } catch (t) {
318
+ n.__e(t, r);
319
+ }
320
+ u.__P = u.__n = null;
321
+ }
322
+ if (u = t.__k) for (o = 0; o < u.length; o++) u[o] && G$1(u[o], r, "function" != typeof t.type || i && !t.props.__P);
323
+ !i && (u = t.__c) && (u = u.__z) && (f = z$1(u, e = [])) && (u == t.__e && e.some(g$1), g$1(f), g$1(u)), (u = t.__e) && (i || g$1(u), u.__e && (u.__e = null)), t.__e = t.__c = t.__ = null;
324
+ }
325
+ function J(n, t, r) {
326
+ return this.constructor(n, r);
327
+ }
328
+ function K(t, r) {
329
+ var i, u, f, e;
330
+ n.__ && n.__(t, r), 9 == r.nodeType && (r = r.documentElement), u = (i = t && 32 & t.__u) ? null : r.__k, r.__k = m$1(M, { children: [t] }), f = [], e = [], V(r, r.__k, u || p$1, p$1, r.namespaceURI, u ? null : r.firstChild ? d$1.call(r.childNodes) : null, f, u ? u.__e : r.firstChild, i, e), D$1(f, r.__k, e), r.__k.props.children = null;
331
+ }
332
+ function R(n) {
333
+ function t(n) {
334
+ var r, i;
335
+ return this.getChildContext || (r = /* @__PURE__ */ new Set(), (i = {})[t.__c] = this, this.getChildContext = function() {
336
+ return i;
337
+ }, this.shouldComponentUpdate = function(n) {
338
+ this.props.value != n.value && r.forEach(function(n) {
339
+ n.__g |= 4, j$1(n);
340
+ });
341
+ }, this.sub = function(n) {
342
+ r.add(n);
343
+ var t = n.componentWillUnmount;
344
+ n.componentWillUnmount = function() {
345
+ r.delete(n), t && t.call(n);
346
+ };
347
+ }), n.children;
348
+ }
349
+ return t.__c = "__cC" + s$1++, t.__ = n, t.Provider = (t.Consumer = function(n, t) {
350
+ return n.children(t);
351
+ }).contextType = t, t;
352
+ }
353
+ n = { __e: function(n, t, r, i) {
354
+ for (var u, e, o; t = t.__;) if ((u = t.__c) && !(1 & u.__g)) {
355
+ u.__g |= 4;
356
+ try {
357
+ if ((o = (e = u.constructor) && e.getDerivedStateFromError) && u.setState(e.getDerivedStateFromError(n)), u.componentDidCatch && (u.componentDidCatch(n, i || {}), o = 1), o && 8 & u.__g) return void (u.__g |= 2);
358
+ } catch (t) {
359
+ n = t;
360
+ }
361
+ }
362
+ throw f$2 = 0, n;
363
+ } }, t$1 = 0, x.prototype.setState = function(n, t) {
364
+ var r = this.__s;
365
+ r && r != this.state || (r = this.__s = _$1({}, this.state)), "function" == typeof n && (n = n(_$1({}, r), this.props)), n && (_$1(r, n), this.__v && (t && this.__k.push(t), j$1(this)));
366
+ }, x.prototype.forceUpdate = function(n) {
367
+ this.__v && (this.__g |= 4, n && this.__h.push(n), j$1(this));
368
+ }, x.prototype.render = M, i$1 = [], f$2 = 0, e$1 = function(n, t) {
369
+ return n.__v.__b - t.__v.__b;
370
+ }, o$2 = Symbol(), l$1 = /(PointerCapture)$|Capture$/i, c$1 = 0, a$2 = {}, s$1 = 0;
371
+ // ../../node_modules/.pnpm/preact@11.1.1/node_modules/preact/hooks/dist/hooks.mjs
372
+ var t;
373
+ var r;
374
+ var u$1;
375
+ var i;
376
+ var o$1 = Object.is;
377
+ var f$1 = 0;
378
+ var c = [];
379
+ var e = [];
380
+ var a$1 = n;
381
+ var v = a$1.__b;
382
+ var l = a$1.__r;
383
+ var m = a$1.diffed;
384
+ var h = a$1.__c;
385
+ var s = a$1.unmount;
386
+ var p = a$1.__;
387
+ function y(n, t) {
388
+ a$1.__h && a$1.__h(r, n, f$1 || t), f$1 = 0;
389
+ var u = r.__H || (r.__H = {
390
+ __: [],
391
+ __h: []
392
+ });
393
+ return n >= u.__.length && u.__.push({}), u.__[n];
394
+ }
395
+ function d(n) {
396
+ return f$1 = 1, _(G, n);
397
+ }
398
+ function _(n, u, i) {
399
+ var f = y(t++, 2);
400
+ if (f.t = n, !f.__c && (f.__ = [i ? i(u) : G(void 0, u), function(n) {
401
+ var t = f.__N ? f.__N[0] : f.__[0], r = f.t(t, n);
402
+ o$1(t, r) || (f.__N = [r, f.__[1]], f.__c.setState({}));
403
+ }], f.__c = r, !r.__f)) {
404
+ r.__f = !0;
405
+ var c = r.shouldComponentUpdate;
406
+ r.shouldComponentUpdate = function(n, t, r) {
407
+ var u = this.__H;
408
+ if (!u) return !0;
409
+ var i = !1, f = this.props != n;
410
+ if (u.__.some(function(n) {
411
+ n.__N && (i = !0, o$1(n.__[0], n.__N[0]) || (f = !0));
412
+ }), c) {
413
+ var e = c.call(this, n, t, r);
414
+ return i ? e || f : e;
415
+ }
416
+ return !i || f;
417
+ };
418
+ }
419
+ return f.__;
420
+ }
421
+ function A(n, u) {
422
+ var i = y(t++, 3);
423
+ !a$1.__s && E(i.__H, u) && (i.__P = !0, i.__ = n, i.u = u, r.__H.__h.push(i));
424
+ }
425
+ function T(n) {
426
+ return f$1 = 5, w(function() {
427
+ return { current: n };
428
+ }, []);
429
+ }
430
+ function w(n, r) {
431
+ var u = y(t++, 7);
432
+ return E(u.__H, r) && (u.__ = n(), u.__H = r), u.__;
433
+ }
434
+ function j(n) {
435
+ var u = r.context[n.__c], i = y(t++, 9);
436
+ return i.c = n, u ? (i.__ ?? (i.__ = !0, u.sub(r)), u.props.value) : n.__;
437
+ }
438
+ function g() {
439
+ var n;
440
+ do {
441
+ for (; n = e.shift();) try {
442
+ C(n);
443
+ } catch (t) {
444
+ a$1.__e(t, { __: (n = n.__P) && n.__v });
445
+ }
446
+ for (; n = c.shift();) {
447
+ var t = n.__H;
448
+ if (n.__P && t) try {
449
+ t.__h.some(C), t.__h.some(D), t.__h = [];
450
+ } catch (r) {
451
+ t.__h = [], a$1.__e(r, n.__v);
452
+ }
453
+ }
454
+ } while (e.length);
455
+ }
456
+ a$1.__b = function(n) {
457
+ r = null, v && v(n);
458
+ }, a$1.__ = function(n, t) {
459
+ n && t.__k && t.__k.__m && (n.__m = t.__k.__m), p && p(n, t);
460
+ }, a$1.__r = function(n) {
461
+ l && l(n), t = 0;
462
+ var i = (r = n.__c).__H;
463
+ i && (u$1 == r ? r.__h = [] : (i.__h.some(C), i.__h.some(D), t = 0), i.__h = [], i.__.some(function(n) {
464
+ n.__N && (n.__ = n.__N), n.u = n.__N = void 0;
465
+ })), u$1 = r;
466
+ }, a$1.diffed = function(n) {
467
+ m && m(n);
468
+ var t = n.__c;
469
+ t && t.__H && (t.__H.__h.length && B(c.push(t)), t.__H.__.some(function(n) {
470
+ n.u && (n.__H = n.u);
471
+ })), u$1 = r = null;
472
+ }, a$1.__c = function(n, t) {
473
+ t.some(function(n) {
474
+ try {
475
+ n.__h.some(C), n.__h = n.__h.filter(function(n) {
476
+ return !n.__ || D(n);
477
+ });
478
+ } catch (t) {
479
+ n.__h = [function() {
480
+ throw t;
481
+ }];
482
+ }
483
+ }), h && h(n, t);
484
+ }, a$1.unmount = function(n) {
485
+ s && s(n);
486
+ var t, r, u = n.__c;
487
+ u && u.__H && (u.__H.__.some(function(u) {
488
+ try {
489
+ if (u.__P && u.__c) {
490
+ if (void 0 === r) {
491
+ for (r = n.__; r && (!r.__c || !r.__c.__P);) r = r.__;
492
+ r = r && r.__c;
493
+ }
494
+ u.__P = r, B(e.push(u));
495
+ } else C(u);
496
+ } catch (n) {
497
+ t = n;
498
+ }
499
+ }), u.__H = void 0, t && a$1.__e(t, u.__v));
500
+ };
501
+ var k = "function" == typeof requestAnimationFrame;
502
+ function z(n) {
503
+ var t, r = function() {
504
+ clearTimeout(u), k && cancelAnimationFrame(t), setTimeout(n);
505
+ }, u = setTimeout(r, 35);
506
+ k && (t = requestAnimationFrame(r));
507
+ }
508
+ function B(n) {
509
+ 1 != n && i == a$1.requestAnimationFrame || ((i = a$1.requestAnimationFrame) || z)(g);
510
+ }
511
+ function C(n) {
512
+ var t = r, u = n.__c;
513
+ "function" == typeof u && (n.__c = void 0, u()), r = t;
514
+ }
515
+ function D(n) {
516
+ var t = r;
517
+ n.__c = n.__(), r = t;
518
+ }
519
+ function E(n, t) {
520
+ return !n || n.length != t.length || t.some(function(t, r) {
521
+ return !o$1(t, n[r]);
522
+ });
523
+ }
524
+ function G(n, t) {
525
+ return "function" == typeof t ? t(n) : t;
526
+ }
527
+ // ../preact/dist/index.js
528
+ const IsolateCtx = R(null);
529
+ /**
530
+ * The isolate's context, as `start(ctx)` gets it: `ctx.bus`, `ctx.host`, `ctx.config` and
531
+ * the rest.
532
+ *
533
+ * @returns The context of the isolate this component runs in.
534
+ * @throws `Error` outside a component that `defineIsolate` rendered.
535
+ */
536
+ function useIsolate() {
537
+ const ctx = j(IsolateCtx);
538
+ if (!ctx) throw new Error("useIsolate: not inside a component rendered by defineIsolate()");
539
+ return ctx;
540
+ }
541
+ /**
542
+ * Catches a render error at the isolate's root and reports it as this
543
+ * isolate's own (`ctx.reportError`), so in a pool it crashes only this member
544
+ * (ADR 0015, decision 8). Under a runtime without `reportError` (ADR 0012) the
545
+ * error is rethrown, as before.
546
+ */
547
+ var Boundary = class extends x {
548
+ state = { failed: false };
549
+ static getDerivedStateFromError() {
550
+ return { failed: true };
551
+ }
552
+ componentDidCatch(error) {
553
+ const { ctx } = this.props;
554
+ if (typeof ctx.reportError === "function") ctx.reportError(error);
555
+ else queueMicrotask(() => {
556
+ throw error;
557
+ });
558
+ }
559
+ render() {
560
+ return this.state.failed ? null : this.props.children;
561
+ }
562
+ };
563
+ /** The runtime's internal hook on a context (ADR 0017), by its `Symbol.for` key. */
564
+ const BUSY = Symbol.for("isoloop.busy");
565
+ /** Set on `options` once its render batches are bound, by any copy of this adapter. */
566
+ const BOUND = Symbol.for("isoloop.preact.batches");
567
+ /** Preact 10's default: a resolved promise's callback. */
568
+ const defer = (cb) => {
569
+ Promise.resolve().then(cb);
570
+ };
571
+ /**
572
+ * Preact renders a batch in a promise callback, which the runtime can't see.
573
+ * Through `options.debounceRendering` (public), each batch runs as the code
574
+ * that scheduled it, so the members whose roots it changes share its time
575
+ * (ADR 0017). The batch is still scheduled as Preact schedules it by default,
576
+ * or by a `debounceRendering` already set.
577
+ */
578
+ function bindBatches(ctx) {
579
+ if (Reflect.get(n, BOUND) === true) return;
580
+ const hook = Reflect.get(ctx, BUSY);
581
+ const bind = typeof hook === "object" && hook !== null ? Reflect.get(hook, "bind") : void 0;
582
+ if (typeof bind !== "function") return;
583
+ const prev = Reflect.get(n, "debounceRendering");
584
+ const schedule = (cb) => {
585
+ if (typeof prev === "function") Reflect.apply(prev, void 0, [cb]);
586
+ else defer(cb);
587
+ };
588
+ n.debounceRendering = (cb) => {
589
+ const bound = Reflect.apply(bind, hook, [cb]);
590
+ schedule(typeof bound === "function" ? () => {
591
+ Reflect.apply(bound, void 0, []);
592
+ } : cb);
593
+ };
594
+ Reflect.set(n, BOUND, true);
595
+ }
596
+ /**
597
+ * Makes `Component` an isolate: the module's default export, which renders it into the
598
+ * isolate's surface (with Preact) and unmounts it on shutdown, so effects clean up and
599
+ * subscriptions end. Every hook in this package works inside it.
600
+ *
601
+ * A render error is caught at the root and reported as this isolate's own crash, so in
602
+ * a pool it fails only this member. The isolate needs a surface: started headless, it
603
+ * throws an `Error` at start.
604
+ *
605
+ * @param Component - The root component. It gets {@link IsolateProps}.
606
+ * @returns The isolate definition, stamped with the runtime version it was built against.
607
+ * @example
608
+ * ```tsx
609
+ * import { defineIsolate, usePublish, useTopic } from '@isoloop/preact';
610
+ * import { count } from './topics';
611
+ *
612
+ * function Counter() {
613
+ * const n = useTopic(count, { from: 'earliest' }) ?? 0;
614
+ * const publish = usePublish(count);
615
+ * return <button onClick={() => void publish(n + 1)}>Count: {n}</button>;
616
+ * }
617
+ *
618
+ * export default defineIsolate(Counter);
619
+ * ```
620
+ */
621
+ function defineIsolate(Component) {
622
+ return {
623
+ requires: REQUIRES,
624
+ start(ctx) {
625
+ const container = ctx.root;
626
+ if (!(container instanceof Element)) throw new Error(`defineIsolate (Preact): "${ctx.id}" is headless; Preact needs a surface`);
627
+ bindBatches(ctx);
628
+ K(k$1(IsolateCtx.Provider, { value: ctx }, k$1(Boundary, { ctx }, k$1(Component, { config: ctx.config }))), container);
629
+ ctx.onShutdown(() => {
630
+ K(null, container);
631
+ });
632
+ }
633
+ };
634
+ }
635
+ /** `snap` with one feed message applied. Pure. */
636
+ function applyMessage(snap, m) {
637
+ switch (m.t) {
638
+ case "snapshot": return m.p;
639
+ case "event": {
640
+ const events = [...snap.events, m.p].slice(-200);
641
+ return {
642
+ ...snap,
643
+ at: Math.max(snap.at, m.p.at),
644
+ events
645
+ };
646
+ }
647
+ case "beats": {
648
+ const byId = new Map(m.p.beats.map((b) => [b.id, b]));
649
+ const isolates = snap.isolates.map((i) => {
650
+ const b = byId.get(i.id);
651
+ if (!b) return i;
652
+ const next = {
653
+ ...i,
654
+ lagMs: b.lagMs,
655
+ lastBeatAt: b.at
656
+ };
657
+ if (b.busyMs !== void 0) next.busyMs = b.busyMs;
658
+ return next;
659
+ });
660
+ return {
661
+ ...snap,
662
+ at: Math.max(snap.at, m.p.at),
663
+ isolates
664
+ };
665
+ }
666
+ case "metrics": return {
667
+ ...snap,
668
+ bus: {
669
+ ...snap.bus,
670
+ metrics: m.p
671
+ }
672
+ };
673
+ case "memory": {
674
+ const byId = new Map(m.p.isolates.map((x) => [x.id, x.memory]));
675
+ const isolates = snap.isolates.map((i) => {
676
+ const memory = byId.get(i.id);
677
+ return memory ? {
678
+ ...i,
679
+ memory
680
+ } : i;
681
+ });
682
+ return {
683
+ ...snap,
684
+ at: Math.max(snap.at, m.p.at),
685
+ isolates
686
+ };
687
+ }
688
+ default: return snap;
689
+ }
690
+ }
691
+ /**
692
+ * The feed as state: `undefined` until the first snapshot arrives (and for
693
+ * good without an inspector).
694
+ */
695
+ function useFeed(inspector) {
696
+ const [snap, setSnap] = d(void 0);
697
+ A(() => {
698
+ if (!inspector) return void 0;
699
+ let alive = true;
700
+ let timer;
701
+ const refresh = () => {
702
+ timer = void 0;
703
+ inspector.snapshot().then((s) => {
704
+ if (alive) setSnap(s);
705
+ }, () => {});
706
+ };
707
+ const off = inspector.on((m) => {
708
+ setSnap((s) => s ? applyMessage(s, m) : s);
709
+ if (m.t === "event" && timer === void 0) timer = setTimeout(refresh, 100);
710
+ });
711
+ refresh();
712
+ return () => {
713
+ alive = false;
714
+ off();
715
+ if (timer !== void 0) clearTimeout(timer);
716
+ };
717
+ }, [inspector]);
718
+ return snap;
719
+ }
720
+ const UNWELL = /* @__PURE__ */ new Set([
721
+ "restarting",
722
+ "crashed",
723
+ "blocked"
724
+ ]);
725
+ function healthOf(snap) {
726
+ if (!snap) return "ok";
727
+ if (snap.isolates.some((i) => i.state === "failed")) return "failed";
728
+ return snap.isolates.some((i) => UNWELL.has(i.state)) ? "unwell" : "ok";
729
+ }
730
+ // src/persist.ts
731
+ const isMode = (v) => v === "normal" || v === "wide" || v === "max";
732
+ const DB = "isoloop-devtools";
733
+ const STORE = "settings";
734
+ /** The kernel events of each page session, and the sessions themselves (`event-store.ts`). */
735
+ const EVENTS_STORE = "events";
736
+ const SESSIONS_STORE = "sessions";
737
+ const KEY = "panel";
738
+ const POSITIONS$1 = /* @__PURE__ */ new Set([
739
+ "bottom-right",
740
+ "bottom-left",
741
+ "top-right",
742
+ "top-left"
743
+ ]);
744
+ const isPosition = (v) => typeof v === "string" && POSITIONS$1.has(v);
745
+ /** The stored fields that are well formed; anything else is dropped. */
746
+ function parseUi(v) {
747
+ if (typeof v !== "object" || v === null) return {};
748
+ const out = {};
749
+ const open = Reflect.get(v, "open");
750
+ const width = Reflect.get(v, "width");
751
+ const height = Reflect.get(v, "height");
752
+ const position = Reflect.get(v, "position");
753
+ if (typeof open === "boolean") out.open = open;
754
+ if (typeof width === "number" && Number.isFinite(width)) out.width = width;
755
+ if (typeof height === "number" && Number.isFinite(height)) out.height = height;
756
+ if (isPosition(position)) out.position = position;
757
+ const mode = Reflect.get(v, "mode");
758
+ if (isMode(mode)) out.mode = mode;
759
+ return out;
760
+ }
761
+ /** Settles with a request's result; rejects on its error. */
762
+ const settle = (req) => new Promise((resolve, reject) => {
763
+ req.addEventListener("success", () => {
764
+ resolve(req.result);
765
+ });
766
+ req.addEventListener("error", () => {
767
+ reject(req.error ?? /* @__PURE__ */ new Error("IndexedDB request failed"));
768
+ });
769
+ });
770
+ function openDb() {
771
+ const req = indexedDB.open(DB, 2);
772
+ req.addEventListener("upgradeneeded", () => {
773
+ const d = req.result;
774
+ if (!d.objectStoreNames.contains(STORE)) d.createObjectStore(STORE);
775
+ if (!d.objectStoreNames.contains("events")) d.createObjectStore(EVENTS_STORE, {
776
+ keyPath: "id",
777
+ autoIncrement: true
778
+ }).createIndex("session", "session");
779
+ if (!d.objectStoreNames.contains("sessions")) d.createObjectStore(SESSIONS_STORE, { keyPath: "id" });
780
+ });
781
+ const opened = settle(req).then((d) => {
782
+ d.addEventListener("versionchange", () => {
783
+ d.close();
784
+ db = void 0;
785
+ });
786
+ return d;
787
+ });
788
+ return Promise.race([opened, new Promise((_resolve, reject) => {
789
+ req.addEventListener("blocked", () => {
790
+ reject(/* @__PURE__ */ new Error("indexedDB.open blocked"));
791
+ });
792
+ })]);
793
+ }
794
+ /** The open connection, shared; reset when the database is closed from under it. */
795
+ let db;
796
+ const database = () => {
797
+ db ??= openDb();
798
+ return db;
799
+ };
800
+ /** The stored settings, or `{}` when there are none or storage isn't there. */
801
+ async function loadUi() {
802
+ try {
803
+ const d = await database();
804
+ return parseUi(await settle(d.transaction(STORE, "readonly").objectStore(STORE).get(KEY)));
805
+ } catch {
806
+ return {};
807
+ }
808
+ }
809
+ /** Stores the settings; failures are ignored. Resolves once written (or not). */
810
+ async function saveUi(s) {
811
+ try {
812
+ const tx = (await database()).transaction(STORE, "readwrite");
813
+ tx.objectStore(STORE).put({ ...s }, KEY);
814
+ await new Promise((resolve) => {
815
+ for (const type of [
816
+ "complete",
817
+ "error",
818
+ "abort"
819
+ ]) tx.addEventListener(type, () => {
820
+ resolve();
821
+ });
822
+ });
823
+ } catch {}
824
+ }
825
+ const UNWELL_STATES = /* @__PURE__ */ new Set([
826
+ "restarting",
827
+ "crashed",
828
+ "blocked"
829
+ ]);
830
+ /** `ok` below `warn`, `unwell` below `bad`, `failed` from `bad` up. */
831
+ const by = (value, warn, bad) => value < warn ? "ok" : value < bad ? "unwell" : "failed";
832
+ const max = (xs) => xs.reduce((a, b) => Math.max(a, b), 0);
833
+ const unknown = (id, label) => ({
834
+ id,
835
+ label,
836
+ level: "unknown"
837
+ });
838
+ /** The ring's checks, always `RING_SLOTS` of them: grey ones while there's no data. */
839
+ function checksOf(snap) {
840
+ if (!snap) return Array.from({ length: 12 }, (_, i) => unknown(`c${i}`, "No data yet"));
841
+ const { isolates, pools, bus } = snap;
842
+ const m = bus.metrics;
843
+ const surfaces = isolates.flatMap((i) => i.surface ? [i.surface] : []);
844
+ const memory = isolates.flatMap((i) => i.memory ? [i.memory.bytes] : []);
845
+ const rejected = m ? Object.values(m.rejected).reduce((n, v) => n + (v ?? 0), 0) : 0;
846
+ const storage = m?.storage;
847
+ return [
848
+ {
849
+ id: "isolates",
850
+ label: "Isolates",
851
+ level: isolates.some((i) => i.state === "failed") ? "failed" : isolates.some((i) => UNWELL_STATES.has(i.state)) ? "unwell" : "ok"
852
+ },
853
+ {
854
+ id: "restarts",
855
+ label: "Restarts",
856
+ level: by(max(isolates.map((i) => i.restarts)), 1, 3)
857
+ },
858
+ {
859
+ id: "lag",
860
+ label: "Heartbeat lag",
861
+ level: by(max(isolates.map((i) => i.lagMs)), 100, 500)
862
+ },
863
+ {
864
+ id: "holds",
865
+ label: "Held isolates",
866
+ level: by(max(isolates.flatMap((i) => (i.holds ?? []).map((h) => h.ageMs))), 1, 1e3)
867
+ },
868
+ {
869
+ id: "errors",
870
+ label: "Isolate errors",
871
+ level: isolates.some((i) => i.error !== void 0) ? "unwell" : "ok"
872
+ },
873
+ {
874
+ id: "frames",
875
+ label: "Dropped or rejected updates",
876
+ level: surfaces.some((s) => s.dropped + s.rejected > 0) ? "unwell" : "ok"
877
+ },
878
+ {
879
+ id: "bus",
880
+ label: "Bus",
881
+ level: bus.state === "running" ? "ok" : bus.state === "failed" ? "failed" : bus.state === "starting" || bus.state === "loading" ? "unknown" : "unwell"
882
+ },
883
+ m ? {
884
+ id: "rejected",
885
+ label: "Rejected publishes",
886
+ level: by(rejected, 1, 100)
887
+ } : unknown("rejected", "Rejected publishes"),
888
+ m ? {
889
+ id: "consumers",
890
+ label: "Consumer lag",
891
+ level: by(max(m.subscriptions.map((s) => s.lag)), 100, 1e3)
892
+ } : unknown("consumers", "Consumer lag"),
893
+ storage ? {
894
+ id: "storage",
895
+ label: "Storage",
896
+ level: by(storage.usage / Math.max(1, storage.quota), .7, .9)
897
+ } : unknown("storage", "Storage"),
898
+ {
899
+ id: "pools",
900
+ label: "Pools",
901
+ level: pools.some((p) => !p.running) ? "unwell" : "ok"
902
+ },
903
+ memory.length > 0 ? {
904
+ id: "memory",
905
+ label: "Memory",
906
+ level: "ok"
907
+ } : unknown("memory", "Memory")
908
+ ];
909
+ }
910
+ const levelOf = (state) => state === "failed" ? "failed" : UNWELL_STATES.has(state) ? "unwell" : state === "loading" || state === "starting" ? "unknown" : "ok";
911
+ const RANK = {
912
+ failed: 3,
913
+ unwell: 2,
914
+ ok: 1,
915
+ unknown: 0
916
+ };
917
+ /**
918
+ * The ring: the isolates in the order they were spawned, shared out over
919
+ * `RING_SLOTS` arcs (a few to an arc when there are many, one isolate over
920
+ * several arcs when there are few), each arc the worst state among its own.
921
+ * A crash lights the arc its isolate is in, so where on the ring tells you
922
+ * roughly which one.
923
+ */
924
+ function arcsOf(snap) {
925
+ const list = snap?.isolates ?? [];
926
+ const n = list.length;
927
+ return Array.from({ length: 12 }, (_, i) => {
928
+ if (n === 0) return {
929
+ id: `a${i}`,
930
+ label: "No isolates yet",
931
+ level: "unknown"
932
+ };
933
+ const from = Math.floor(i * n / 12);
934
+ const to = Math.max(from + 1, Math.floor((i + 1) * n / 12));
935
+ const members = list.slice(from, to);
936
+ let level = "unknown";
937
+ const bad = [];
938
+ for (const m of members) {
939
+ const l = levelOf(m.state);
940
+ if (RANK[l] > RANK[level]) level = l;
941
+ if (l === "failed" || l === "unwell") bad.push(`${m.id} ${m.state}`);
942
+ }
943
+ const first = members[0]?.id ?? "";
944
+ const last = members.at(-1)?.id ?? "";
945
+ const range = first === last ? first : `${first} … ${last}`;
946
+ return {
947
+ id: `a${i}`,
948
+ label: bad.length > 0 ? `${range}: ${bad.join(", ")}` : range,
949
+ level
950
+ };
951
+ });
952
+ }
953
+ /** A line for the button's label: how many isolates need attention, and which other checks do. */
954
+ function summaryOf(arcs, checks) {
955
+ const bad = arcs.filter((a) => a.level === "failed").length;
956
+ const warn = arcs.filter((a) => a.level === "unwell").length;
957
+ const other = checks.filter((c) => c.id !== "isolates" && (c.level === "failed" || c.level === "unwell"));
958
+ const parts = [
959
+ bad > 0 ? `${bad} of 12 ring sections failed` : "",
960
+ warn > 0 ? `${warn} of 12 ring sections need attention` : "",
961
+ other.length > 0 ? `Also: ${other.map((c) => c.label).join(", ")}` : ""
962
+ ].filter(Boolean);
963
+ return parts.length > 0 ? parts.join(". ") : "All checks pass";
964
+ }
965
+ /** The SVG path of arc `i` of `RING_SLOTS` on a circle. Neighbours overlap a hair so no seam shows. */
966
+ function arcPath(i, cx, cy, r) {
967
+ const step = 30;
968
+ const gap = -.8;
969
+ const a0 = (-90 + i * step + gap / 2) * Math.PI / 180;
970
+ const a1 = (-90 + (i + 1) * step - gap / 2) * Math.PI / 180;
971
+ const p = (a) => `${(cx + r * Math.cos(a)).toFixed(2)} ${(cy + r * Math.sin(a)).toFixed(2)}`;
972
+ return `M${p(a0)}A${r} ${r} 0 0 1 ${p(a1)}`;
973
+ }
974
+ /**
975
+ * The pie slice of arc `i` on a circle of radius `r` about (`cx`, `cy`), at the
976
+ * same angles as `arcPath`: the logo filled with these puts each colour on the
977
+ * same side of the button as its arc in the ring.
978
+ */
979
+ function wedgePath(i, cx, cy, r) {
980
+ const step = 30;
981
+ const over = .8;
982
+ const a0 = (-90 + i * step - over / 2) * Math.PI / 180;
983
+ const a1 = (-90 + (i + 1) * step + over / 2) * Math.PI / 180;
984
+ const p = (a) => `${(cx + r * Math.cos(a)).toFixed(2)} ${(cy + r * Math.sin(a)).toFixed(2)}`;
985
+ return `M${cx} ${cy}L${p(a0)}A${r} ${r} 0 0 1 ${p(a1)}Z`;
986
+ }
987
+ // src/event-level.ts
988
+ const str = (v) => typeof v === "string" ? v : "";
989
+ /** How serious an event is, in the ring's terms: failed is red, a crash or a stall amber. */
990
+ function levelOfEvent(e) {
991
+ switch (e.event) {
992
+ case "isolate:failed":
993
+ case "bus:failed": return "bad";
994
+ case "isolate:crash":
995
+ case "isolate:error":
996
+ case "bus:crash":
997
+ case "bus:recovered":
998
+ case "bus:quota":
999
+ case "bus:durability_degraded":
1000
+ case "workers:budget":
1001
+ case "agents:unmatched": return "warn";
1002
+ case "isolate:ready":
1003
+ case "bus:ready": return "good";
1004
+ case "isolate:state": {
1005
+ const state = str(e.data["state"]);
1006
+ if (state === "failed") return "bad";
1007
+ if (state === "running") return "good";
1008
+ return [
1009
+ "blocked",
1010
+ "restarting",
1011
+ "crashed"
1012
+ ].includes(state) ? "warn" : "info";
1013
+ }
1014
+ default: return "info";
1015
+ }
1016
+ }
1017
+ /** What the event is about: its isolate, or the bus. */
1018
+ const subjectOf = (e) => {
1019
+ const id = str(e.data["id"]);
1020
+ if (id) return id;
1021
+ return e.event.startsWith("bus:") ? "bus" : "";
1022
+ };
1023
+ const show = (v) => typeof v === "string" || typeof v === "number" || typeof v === "boolean" ? String(v) : JSON.stringify(v);
1024
+ /** One line of what happened. */
1025
+ function detailOf(e) {
1026
+ const d = e.data;
1027
+ if (e.event === "isolate:state") return `${str(d["prev"])} → ${str(d["state"])}`;
1028
+ if (e.event === "isolate:crash" || e.event === "isolate:failed" || e.event === "bus:crash") return [str(d["reason"]), str(d["message"])].filter(Boolean).join(": ");
1029
+ if (e.event === "isolate:error") return str(d["message"]);
1030
+ return Object.entries(d).filter(([k]) => k !== "id").map(([k, v]) => `${k}=${show(v)}`).join(" ");
1031
+ }
1032
+ // src/event-store.ts
1033
+ const PER_SESSION = 6e3;
1034
+ /** How long events wait to be written together. Problems are written at once. */
1035
+ const FLUSH_MS = 250;
1036
+ const isSession = (v) => typeof v === "object" && v !== null && typeof Reflect.get(v, "id") === "string" && typeof Reflect.get(v, "started") === "number";
1037
+ const isRow = (v) => typeof v === "object" && v !== null && typeof Reflect.get(v, "at") === "number" && typeof Reflect.get(v, "event") === "string" && typeof Reflect.get(v, "wall") === "number" && ["number", "undefined"].includes(typeof Reflect.get(v, "n")) && typeof Reflect.get(v, "data") === "object";
1038
+ const keyOf = (e) => `${e.at} ${e.event} ${JSON.stringify(e.data)}`;
1039
+ const done = (tx) => new Promise((resolve) => {
1040
+ for (const type of [
1041
+ "complete",
1042
+ "error",
1043
+ "abort"
1044
+ ]) tx.addEventListener(type, () => {
1045
+ resolve();
1046
+ });
1047
+ });
1048
+ function createRecorder() {
1049
+ const session = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
1050
+ const started = Date.now();
1051
+ /** This session's events, oldest first. */
1052
+ let mem = [];
1053
+ const seen = /* @__PURE__ */ new Set();
1054
+ let pending = [];
1055
+ let timer;
1056
+ let written = 0;
1057
+ let seq = 0;
1058
+ let acked = 0;
1059
+ let ready;
1060
+ /** Opens storage, notes this session and drops the sessions beyond the last few before it. */
1061
+ const open = () => {
1062
+ ready ??= (async () => {
1063
+ try {
1064
+ const tx = (await database()).transaction([SESSIONS_STORE, EVENTS_STORE], "readwrite");
1065
+ const sessions = tx.objectStore(SESSIONS_STORE);
1066
+ sessions.put({
1067
+ id: session,
1068
+ started
1069
+ });
1070
+ const old = (await settle(sessions.getAll())).filter(isSession).toSorted((a, b) => b.started - a.started).slice(4);
1071
+ const events = tx.objectStore(EVENTS_STORE).index("session");
1072
+ for (const s of old) {
1073
+ sessions.delete(s.id);
1074
+ const cursor = events.openKeyCursor(IDBKeyRange.only(s.id));
1075
+ cursor.addEventListener("success", () => {
1076
+ const c = cursor.result;
1077
+ if (!c) return;
1078
+ tx.objectStore(EVENTS_STORE).delete(c.primaryKey);
1079
+ c.continue();
1080
+ });
1081
+ }
1082
+ await done(tx);
1083
+ return true;
1084
+ } catch {
1085
+ return false;
1086
+ }
1087
+ })();
1088
+ return ready;
1089
+ };
1090
+ const flush = async () => {
1091
+ timer = void 0;
1092
+ const batch = pending;
1093
+ pending = [];
1094
+ if (batch.length === 0 || !await open()) return;
1095
+ try {
1096
+ const tx = (await database()).transaction(EVENTS_STORE, "readwrite");
1097
+ const store = tx.objectStore(EVENTS_STORE);
1098
+ for (const e of batch) store.add({
1099
+ ...e,
1100
+ session
1101
+ });
1102
+ written += batch.length;
1103
+ if (written > 6e3) {
1104
+ let drop = written - PER_SESSION;
1105
+ written = PER_SESSION;
1106
+ const cursor = store.index("session").openKeyCursor(IDBKeyRange.only(session));
1107
+ cursor.addEventListener("success", () => {
1108
+ const c = cursor.result;
1109
+ if (!c || drop <= 0) return;
1110
+ drop -= 1;
1111
+ store.delete(c.primaryKey);
1112
+ c.continue();
1113
+ });
1114
+ }
1115
+ await done(tx);
1116
+ } catch {}
1117
+ };
1118
+ const schedule = (urgent) => {
1119
+ if (urgent) {
1120
+ if (timer !== void 0) clearTimeout(timer);
1121
+ flush();
1122
+ } else timer ??= setTimeout(() => void flush(), FLUSH_MS);
1123
+ };
1124
+ /** Records events not seen yet; the same event arriving twice (live and in a snapshot) counts once. */
1125
+ const add = (events, wall = Date.now()) => {
1126
+ let urgent = false;
1127
+ let changed = false;
1128
+ for (const e of events) {
1129
+ const k = keyOf(e);
1130
+ if (seen.has(k)) continue;
1131
+ seen.add(k);
1132
+ const stored = {
1133
+ ...e,
1134
+ wall,
1135
+ n: ++seq
1136
+ };
1137
+ mem.push(stored);
1138
+ pending.push(stored);
1139
+ changed = true;
1140
+ const l = levelOfEvent(e);
1141
+ if (l === "bad" || l === "warn") urgent = true;
1142
+ }
1143
+ if (!changed) return;
1144
+ mem = mem.toSorted((a, b) => a.at - b.at);
1145
+ if (mem.length > 6e3) mem = mem.slice(mem.length - PER_SESSION);
1146
+ schedule(urgent);
1147
+ };
1148
+ return {
1149
+ session,
1150
+ started,
1151
+ add,
1152
+ /** This session's events, oldest first. */
1153
+ events: () => mem,
1154
+ isNew: (e) => (e.n ?? 0) > acked,
1155
+ unacknowledged: () => mem.filter((e) => {
1156
+ const l = levelOfEvent(e);
1157
+ return (l === "bad" || l === "warn") && (e.n ?? 0) > acked;
1158
+ }).length,
1159
+ acknowledge() {
1160
+ acked = seq;
1161
+ },
1162
+ /**
1163
+ * Starts recording from `inspector`: every event as it comes, and the ring
1164
+ * it already holds (what happened before the panel connected).
1165
+ */
1166
+ start(inspector) {
1167
+ const off = inspector.on((m) => {
1168
+ if (m.t === "event") add([m.p]);
1169
+ });
1170
+ inspector.snapshot().then((s) => {
1171
+ const now = Date.now();
1172
+ for (const e of s.events) add([e], now - Math.max(0, s.at - e.at));
1173
+ }, () => void 0);
1174
+ return off;
1175
+ },
1176
+ /** This and the earlier sessions kept in storage, newest first. */
1177
+ async sessions() {
1178
+ if (!await open()) return [];
1179
+ try {
1180
+ const tx = (await database()).transaction([SESSIONS_STORE, EVENTS_STORE], "readonly");
1181
+ const all = (await settle(tx.objectStore(SESSIONS_STORE).getAll())).filter(isSession);
1182
+ const index = tx.objectStore(EVENTS_STORE).index("session");
1183
+ return await Promise.all(all.toSorted((a, b) => b.started - a.started).map(async (s) => ({
1184
+ id: s.id,
1185
+ started: s.started,
1186
+ count: await settle(index.count(IDBKeyRange.only(s.id)))
1187
+ })));
1188
+ } catch {
1189
+ return [];
1190
+ }
1191
+ },
1192
+ /** One stored session's events, oldest first. */
1193
+ async load(id) {
1194
+ try {
1195
+ const d = await database();
1196
+ return (await settle(d.transaction(EVENTS_STORE, "readonly").objectStore(EVENTS_STORE).index("session").getAll(IDBKeyRange.only(id)))).filter(isRow).map(({ session: _s, id: _i, ...e }) => e);
1197
+ } catch {
1198
+ return [];
1199
+ }
1200
+ },
1201
+ /** Forgets everything stored, this session's and the earlier ones. */
1202
+ async clear() {
1203
+ mem = [];
1204
+ pending = [];
1205
+ seen.clear();
1206
+ written = 0;
1207
+ acked = seq;
1208
+ try {
1209
+ const tx = (await database()).transaction([SESSIONS_STORE, EVENTS_STORE], "readwrite");
1210
+ tx.objectStore(EVENTS_STORE).clear();
1211
+ tx.objectStore(SESSIONS_STORE).clear();
1212
+ tx.objectStore(SESSIONS_STORE).put({
1213
+ id: session,
1214
+ started
1215
+ });
1216
+ await done(tx);
1217
+ } catch {}
1218
+ }
1219
+ };
1220
+ }
1221
+ // ../../node_modules/.pnpm/preact@11.1.1/node_modules/preact/jsx-runtime/dist/jsxRuntime.mjs
1222
+ var f = Symbol.for("pv");
1223
+ var o = 0;
1224
+ Array.isArray;
1225
+ function a(t, e, n$1, u, a, i) {
1226
+ e || (e = {});
1227
+ var c, l, p = e;
1228
+ if ("ref" in p && "function" != typeof t) for (l in p = {}, e) "ref" == l ? c = e[l] : p[l] = e[l];
1229
+ var s = {
1230
+ type: t,
1231
+ props: p,
1232
+ key: n$1,
1233
+ ref: c,
1234
+ __k: null,
1235
+ __: null,
1236
+ __b: 0,
1237
+ __e: null,
1238
+ __c: null,
1239
+ constructor: f,
1240
+ __v: --o,
1241
+ __i: -1,
1242
+ __u: 0
1243
+ };
1244
+ return (a || i) && (s.__source = a, s.__self = i), n.vnode && n.vnode(s), s;
1245
+ }
1246
+ // src/bus-view.tsx
1247
+ const rate = (n) => n >= 10 ? String(Math.round(n)) : n.toFixed(1);
1248
+ const bytes = (n) => n >= 1048576 ? `${(n / 1048576).toFixed(1)} MB` : n >= 1024 ? `${(n / 1024).toFixed(1)} KB` : `${Math.round(n)} B`;
1249
+ function Topics(props) {
1250
+ const { topics } = props.metrics;
1251
+ if (topics.length === 0) return /* @__PURE__ */ a("p", {
1252
+ class: "dt-muted",
1253
+ children: "No topics."
1254
+ });
1255
+ return /* @__PURE__ */ a("table", {
1256
+ class: "dt-table",
1257
+ "data-view": "topics",
1258
+ children: [/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: [
1259
+ /* @__PURE__ */ a("th", { children: "Topic" }),
1260
+ /* @__PURE__ */ a("th", {
1261
+ class: "dt-num",
1262
+ children: "Records/s"
1263
+ }),
1264
+ /* @__PURE__ */ a("th", {
1265
+ class: "dt-num",
1266
+ children: "Bytes/s"
1267
+ }),
1268
+ /* @__PURE__ */ a("th", {
1269
+ class: "dt-num",
1270
+ title: "The next offset to be written",
1271
+ children: "Head"
1272
+ }),
1273
+ /* @__PURE__ */ a("th", {
1274
+ class: "dt-num",
1275
+ title: "Records the topic still holds",
1276
+ children: "Retained"
1277
+ })
1278
+ ] }) }), /* @__PURE__ */ a("tbody", { children: topics.map((t) => /* @__PURE__ */ a("tr", {
1279
+ "data-topic": t.topic,
1280
+ children: [
1281
+ /* @__PURE__ */ a("td", { children: /* @__PURE__ */ a("code", { children: t.topic }) }),
1282
+ /* @__PURE__ */ a("td", {
1283
+ class: "dt-num",
1284
+ children: rate(t.recordsPerSec)
1285
+ }),
1286
+ /* @__PURE__ */ a("td", {
1287
+ class: "dt-num",
1288
+ children: bytes(t.bytesPerSec)
1289
+ }),
1290
+ /* @__PURE__ */ a("td", {
1291
+ class: "dt-num",
1292
+ "data-head": t.head,
1293
+ children: t.head
1294
+ }),
1295
+ /* @__PURE__ */ a("td", {
1296
+ class: "dt-num",
1297
+ "data-retained": t.retained,
1298
+ children: t.retained
1299
+ })
1300
+ ]
1301
+ }, t.topic)) })]
1302
+ });
1303
+ }
1304
+ function Subscriptions(props) {
1305
+ const { subscriptions } = props.metrics;
1306
+ if (subscriptions.length === 0) return /* @__PURE__ */ a("p", {
1307
+ class: "dt-muted",
1308
+ children: "No subscriptions."
1309
+ });
1310
+ return /* @__PURE__ */ a("table", {
1311
+ class: "dt-table",
1312
+ "data-view": "subscriptions",
1313
+ children: [/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: [
1314
+ /* @__PURE__ */ a("th", { children: "Consumer" }),
1315
+ /* @__PURE__ */ a("th", { children: "Topic" }),
1316
+ /* @__PURE__ */ a("th", {
1317
+ class: "dt-num",
1318
+ title: "Head minus the consumer's cursor",
1319
+ children: "Lag"
1320
+ }),
1321
+ /* @__PURE__ */ a("th", {
1322
+ class: "dt-num",
1323
+ title: "Records that may still be delivered before its next commit",
1324
+ children: "Credit"
1325
+ })
1326
+ ] }) }), /* @__PURE__ */ a("tbody", { children: subscriptions.map((s) => /* @__PURE__ */ a("tr", {
1327
+ "data-consumer": s.consumer,
1328
+ "data-subscription": s.topic,
1329
+ children: [
1330
+ /* @__PURE__ */ a("td", { children: /* @__PURE__ */ a("code", { children: s.consumer }) }),
1331
+ /* @__PURE__ */ a("td", { children: /* @__PURE__ */ a("code", { children: s.topic }) }),
1332
+ /* @__PURE__ */ a("td", {
1333
+ class: "dt-num",
1334
+ "data-lag": s.lag,
1335
+ children: s.lag
1336
+ }),
1337
+ /* @__PURE__ */ a("td", {
1338
+ class: "dt-num",
1339
+ "data-credit": s.credit,
1340
+ children: s.credit
1341
+ })
1342
+ ]
1343
+ }, `${s.consumer} ${s.topic}`)) })]
1344
+ });
1345
+ }
1346
+ function Rejected(props) {
1347
+ const entries = Object.entries(props.metrics.rejected).filter((e) => typeof e[1] === "number" && e[1] > 0);
1348
+ if (entries.length === 0) return /* @__PURE__ */ a("p", {
1349
+ class: "dt-muted",
1350
+ children: "None."
1351
+ });
1352
+ return /* @__PURE__ */ a("ul", {
1353
+ style: "margin:0;padding:0;list-style:none;",
1354
+ "data-view": "rejected",
1355
+ children: entries.map(([code, n]) => /* @__PURE__ */ a("li", {
1356
+ "data-rejected": code,
1357
+ children: [
1358
+ /* @__PURE__ */ a("code", { children: code }),
1359
+ " ",
1360
+ n
1361
+ ]
1362
+ }, code))
1363
+ });
1364
+ }
1365
+ function BusView(props) {
1366
+ const { bus, sub } = props;
1367
+ const m = bus.metrics;
1368
+ return /* @__PURE__ */ a("div", {
1369
+ class: "dt-view",
1370
+ "data-view": "bus",
1371
+ children: [/* @__PURE__ */ a("p", {
1372
+ class: "dt-muted",
1373
+ style: "margin:0 0 4px;",
1374
+ "data-bus-state": bus.state,
1375
+ children: [
1376
+ "Bus ",
1377
+ /* @__PURE__ */ a("span", {
1378
+ class: `dt-state-${bus.state}`,
1379
+ children: bus.state
1380
+ }),
1381
+ " · ",
1382
+ bus.restarts,
1383
+ " restarts",
1384
+ m?.storage ? ` · storage ${bytes(m.storage.usage)} of ${bytes(m.storage.quota)}` : ""
1385
+ ]
1386
+ }), m ? /* @__PURE__ */ a(M, { children: [
1387
+ sub === "topics" ? /* @__PURE__ */ a(Topics, { metrics: m }) : null,
1388
+ sub === "subscriptions" ? /* @__PURE__ */ a(Subscriptions, { metrics: m }) : null,
1389
+ sub === "rejected" ? /* @__PURE__ */ a(M, { children: [/* @__PURE__ */ a("p", {
1390
+ class: "dt-muted",
1391
+ style: "margin:0 0 4px;",
1392
+ children: "Publishes rejected since the bus worker started."
1393
+ }), /* @__PURE__ */ a(Rejected, { metrics: m })] }) : null
1394
+ ] }) : /* @__PURE__ */ a("p", {
1395
+ class: "dt-muted",
1396
+ children: bus.state === "none" ? "No bus: the kernel has no contracts." : "Waiting for bus metrics…"
1397
+ })]
1398
+ });
1399
+ }
1400
+ // src/format.ts
1401
+ const pad$2 = (n) => " ".repeat(n);
1402
+ /**
1403
+ * The text indented like JSON, one member or element to a line. The values are
1404
+ * JSON-like, not always JSON (`Float32Array(50)`, or a preview cut short), so
1405
+ * this walks the text instead of parsing it: strings and anything in
1406
+ * parentheses stay whole, and a cut-off ending is left as it is.
1407
+ */
1408
+ function pretty(text) {
1409
+ let out = "";
1410
+ let depth = 0;
1411
+ let parens = 0;
1412
+ let fresh = false;
1413
+ for (let i = 0; i < text.length; i++) {
1414
+ const c = text.charAt(i);
1415
+ const wasFresh = fresh;
1416
+ fresh = false;
1417
+ if (c === "\"") {
1418
+ let j = i + 1;
1419
+ while (j < text.length && text.charAt(j) !== "\"") j += text.charAt(j) === "\\" ? 2 : 1;
1420
+ out += text.slice(i, j + 1);
1421
+ i = j;
1422
+ } else if (parens > 0 || c === "(") {
1423
+ if (c === "(") parens++;
1424
+ else if (c === ")") parens--;
1425
+ out += c;
1426
+ } else if (c === "{" || c === "[") {
1427
+ const close = c === "{" ? "}" : "]";
1428
+ if (text.charAt(i + 1) === close) {
1429
+ out += c + close;
1430
+ i++;
1431
+ } else {
1432
+ depth++;
1433
+ out += `${c}\n${pad$2(depth)}`;
1434
+ fresh = true;
1435
+ }
1436
+ } else if (c === "}" || c === "]") {
1437
+ depth = Math.max(0, depth - 1);
1438
+ out += `\n${pad$2(depth)}${c}`;
1439
+ } else if (c === ",") {
1440
+ out += `,\n${pad$2(depth)}`;
1441
+ fresh = true;
1442
+ } else if (c === ":") {
1443
+ out += ": ";
1444
+ fresh = true;
1445
+ } else if (!(wasFresh && /\s/.test(c))) out += c;
1446
+ }
1447
+ return out;
1448
+ }
1449
+ const TOKEN = /("(?:\\.|[^"\\])*")(\s*:)?|\b(?:true|false|null)\b|(?<![\w$.])-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(?![\w$])/g;
1450
+ /** Splits JSON-like text into parts to colour: keys, strings, numbers, true/false/null. */
1451
+ function highlight(text) {
1452
+ const parts = [];
1453
+ let last = 0;
1454
+ for (const m of text.matchAll(TOKEN)) {
1455
+ const at = m.index;
1456
+ if (at > last) parts.push({ text: text.slice(last, at) });
1457
+ if (m[1] !== void 0) {
1458
+ if (m[2] === void 0) parts.push({
1459
+ text: m[1],
1460
+ kind: "string"
1461
+ });
1462
+ else {
1463
+ parts.push({
1464
+ text: m[1],
1465
+ kind: "key"
1466
+ });
1467
+ parts.push({ text: m[2] });
1468
+ }
1469
+ } else parts.push({
1470
+ text: m[0],
1471
+ kind: /^[-\d]/.test(m[0]) ? "number" : "literal"
1472
+ });
1473
+ last = at + m[0].length;
1474
+ }
1475
+ if (last < text.length) parts.push({ text: text.slice(last) });
1476
+ return parts;
1477
+ }
1478
+ /** What a record is besides its value, as indented JSON (for the Record panel's Copy). */
1479
+ function recordJson(r) {
1480
+ return JSON.stringify({
1481
+ topic: r.topic,
1482
+ offset: r.offset,
1483
+ ...r.key === void 0 ? {} : { key: r.key },
1484
+ time: new Date(r.ts).toISOString(),
1485
+ ts: r.ts,
1486
+ producer: r.producer,
1487
+ bytes: r.bytes,
1488
+ truncated: r.truncated,
1489
+ ...r.req === void 0 ? {} : { req: r.req }
1490
+ }, null, 2);
1491
+ }
1492
+ // src/events-view.tsx
1493
+ const pad$1 = (n, w = 2) => String(n).padStart(w, "0");
1494
+ /** Time since the page started, as the host's clock has it: m:ss.mmm. */
1495
+ const since = (at) => {
1496
+ const total = Math.max(0, Math.round(at));
1497
+ return `${Math.floor(total / 6e4)}:${pad$1(Math.floor(total / 1e3) % 60)}.${pad$1(total % 1e3, 3)}`;
1498
+ };
1499
+ /** Newest first, each with a key that stays the same while newer events arrive. */
1500
+ function rowsOf(events) {
1501
+ const seen = /* @__PURE__ */ new Map();
1502
+ const oldestFirst = events.map((e) => {
1503
+ const subject = subjectOf(e);
1504
+ const base = `${e.at} ${e.event} ${subject}`;
1505
+ const n = (seen.get(base) ?? 0) + 1;
1506
+ seen.set(base, n);
1507
+ return {
1508
+ key: `${base} ${n}`,
1509
+ e,
1510
+ level: levelOfEvent(e),
1511
+ subject,
1512
+ detail: detailOf(e)
1513
+ };
1514
+ });
1515
+ const rows = [];
1516
+ for (let i = oldestFirst.length - 1; i >= 0; i--) {
1517
+ const r = oldestFirst[i];
1518
+ if (r) rows.push(r);
1519
+ }
1520
+ return rows;
1521
+ }
1522
+ const isProblem = (l) => l === "bad" || l === "warn";
1523
+ const MARK$1 = {
1524
+ bad: "●",
1525
+ warn: "●",
1526
+ good: "●",
1527
+ info: "○"
1528
+ };
1529
+ const PAGE = 500;
1530
+ const when = (ms) => new Date(ms).toLocaleString(void 0, {
1531
+ dateStyle: "short",
1532
+ timeStyle: "medium"
1533
+ });
1534
+ function EventsView(props) {
1535
+ const { recorder } = props;
1536
+ const [filter, setFilter] = d("");
1537
+ const [problems, setProblems] = d(false);
1538
+ const [open, setOpen] = d(/* @__PURE__ */ new Set());
1539
+ const [copied, setCopied] = d(void 0);
1540
+ const [limit, setLimit] = d(PAGE);
1541
+ const [sessions, setSessions] = d([]);
1542
+ const [session, setSession] = d(recorder.session);
1543
+ const [earlier, setEarlier] = d(void 0);
1544
+ const current = session === recorder.session;
1545
+ const refreshSessions = () => {
1546
+ recorder.sessions().then(setSessions);
1547
+ };
1548
+ A(refreshSessions, []);
1549
+ A(() => {
1550
+ let alive = true;
1551
+ setEarlier(void 0);
1552
+ if (!current) recorder.load(session).then((rows) => {
1553
+ if (alive) setEarlier(rows);
1554
+ });
1555
+ return () => {
1556
+ alive = false;
1557
+ };
1558
+ }, [session]);
1559
+ const events = current ? recorder.events() : earlier ?? [];
1560
+ const q = filter.trim().toLowerCase();
1561
+ const all = rowsOf(events);
1562
+ const matching = all.filter((r) => (!problems || r.level === "bad" || r.level === "warn") && (q === "" || `${r.e.event} ${r.subject} ${r.detail}`.toLowerCase().includes(q)));
1563
+ const rows = matching.slice(0, limit);
1564
+ const others = sessions.filter((s) => s.id !== recorder.session);
1565
+ const unseen = recorder.unacknowledged();
1566
+ return /* @__PURE__ */ a("div", {
1567
+ class: "dt-view dt-log",
1568
+ "data-view": "events",
1569
+ children: [
1570
+ /* @__PURE__ */ a("form", {
1571
+ class: "dt-log-bar",
1572
+ onSubmit: (e) => {
1573
+ e.preventDefault();
1574
+ },
1575
+ children: [
1576
+ /* @__PURE__ */ a("input", {
1577
+ type: "text",
1578
+ "aria-label": "Filter the events",
1579
+ placeholder: "Filter, e.g. feed-T1 or crash",
1580
+ value: filter,
1581
+ "data-events-filter": "",
1582
+ onInput: (e) => {
1583
+ setFilter(e.currentTarget.value);
1584
+ setLimit(PAGE);
1585
+ }
1586
+ }),
1587
+ /* @__PURE__ */ a("button", {
1588
+ type: "button",
1589
+ "data-events-problems": "",
1590
+ "aria-pressed": problems ? "true" : "false",
1591
+ onClick: () => {
1592
+ setProblems(!problems);
1593
+ setLimit(PAGE);
1594
+ },
1595
+ children: "Problems only"
1596
+ }),
1597
+ others.length > 0 ? /* @__PURE__ */ a("select", {
1598
+ "aria-label": "Session",
1599
+ "data-events-session": "",
1600
+ value: session,
1601
+ onChange: (e) => {
1602
+ setSession(e.currentTarget.value);
1603
+ setLimit(PAGE);
1604
+ setOpen(/* @__PURE__ */ new Set());
1605
+ },
1606
+ children: [/* @__PURE__ */ a("option", {
1607
+ value: recorder.session,
1608
+ children: "This session"
1609
+ }), others.map((s) => /* @__PURE__ */ a("option", {
1610
+ value: s.id,
1611
+ children: [
1612
+ when(s.started),
1613
+ " · ",
1614
+ s.count,
1615
+ " events"
1616
+ ]
1617
+ }, s.id))]
1618
+ }) : null,
1619
+ /* @__PURE__ */ a("button", {
1620
+ type: "button",
1621
+ "data-events-ack": "",
1622
+ disabled: unseen === 0,
1623
+ title: "Mark the problems listed as seen, which clears the count on the tab",
1624
+ onClick: () => {
1625
+ recorder.acknowledge();
1626
+ props.onAck();
1627
+ },
1628
+ children: ["Acknowledge", unseen > 0 ? ` (${unseen})` : ""]
1629
+ }),
1630
+ /* @__PURE__ */ a("button", {
1631
+ type: "button",
1632
+ "data-events-clear": "",
1633
+ title: `Forget the stored events of every session. Kept in this browser (IndexedDB): this session and the last 3 before it, up to ${PER_SESSION} events each.`,
1634
+ onClick: () => {
1635
+ recorder.clear().then(() => {
1636
+ setSession(recorder.session);
1637
+ setOpen(/* @__PURE__ */ new Set());
1638
+ refreshSessions();
1639
+ props.onAck();
1640
+ });
1641
+ },
1642
+ children: "Clear"
1643
+ })
1644
+ ]
1645
+ }),
1646
+ /* @__PURE__ */ a("p", {
1647
+ class: "dt-muted",
1648
+ style: "margin:4px 0;",
1649
+ children: [
1650
+ matching.length === all.length ? `${all.length} events` : `${matching.length} of ${all.length} events`,
1651
+ " · newest first · ",
1652
+ current ? "this page session" : `session from ${when(sessions.find((s) => s.id === session)?.started ?? 0)}`,
1653
+ current && all.length >= 6e3 ? ` · the oldest are dropped past ${PER_SESSION}` : ""
1654
+ ]
1655
+ }),
1656
+ /* @__PURE__ */ a("div", {
1657
+ class: "dt-log-rows",
1658
+ children: rows.length === 0 ? /* @__PURE__ */ a("p", {
1659
+ class: "dt-muted",
1660
+ children: !current && earlier === void 0 ? "Loading…" : all.length === 0 ? "No events yet." : "No events match."
1661
+ }) : /* @__PURE__ */ a(M, { children: [/* @__PURE__ */ a("table", {
1662
+ class: "dt-table",
1663
+ "data-events-table": "",
1664
+ children: [/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: [
1665
+ /* @__PURE__ */ a("th", {
1666
+ class: "dt-c-chev",
1667
+ children: /* @__PURE__ */ a("span", {
1668
+ class: "dt-sr",
1669
+ children: "Details"
1670
+ })
1671
+ }),
1672
+ /* @__PURE__ */ a("th", {
1673
+ class: "dt-c-time",
1674
+ children: "Since start"
1675
+ }),
1676
+ /* @__PURE__ */ a("th", { children: "Event" }),
1677
+ /* @__PURE__ */ a("th", { children: "Isolate" }),
1678
+ /* @__PURE__ */ a("th", { children: "What happened" })
1679
+ ] }) }), /* @__PURE__ */ a("tbody", { children: rows.map((r) => {
1680
+ const isOpen = open.has(r.key);
1681
+ const text = JSON.stringify(r.e.data, null, 2);
1682
+ return /* @__PURE__ */ a(M, { children: [/* @__PURE__ */ a("tr", {
1683
+ class: `dt-log-row dt-ev-${r.level}${current && isProblem(r.level) && recorder.isNew(r.e) ? " dt-ev-new" : ""}`,
1684
+ "data-event": r.e.event,
1685
+ "data-level": r.level,
1686
+ "aria-expanded": isOpen ? "true" : "false",
1687
+ onClick: () => {
1688
+ const next = new Set(open);
1689
+ if (isOpen) next.delete(r.key);
1690
+ else next.add(r.key);
1691
+ setOpen(next);
1692
+ },
1693
+ children: [
1694
+ /* @__PURE__ */ a("td", {
1695
+ class: "dt-c-chev",
1696
+ children: /* @__PURE__ */ a("button", {
1697
+ type: "button",
1698
+ class: "dt-chev",
1699
+ "aria-expanded": isOpen ? "true" : "false",
1700
+ "aria-label": isOpen ? "Hide the event" : "Show the event",
1701
+ children: isOpen ? "▾" : "▸"
1702
+ })
1703
+ }),
1704
+ /* @__PURE__ */ a("td", {
1705
+ class: "dt-c-time",
1706
+ title: when(r.e.wall),
1707
+ children: since(r.e.at)
1708
+ }),
1709
+ /* @__PURE__ */ a("td", { children: [
1710
+ /* @__PURE__ */ a("span", {
1711
+ class: "dt-ev-dot",
1712
+ "aria-hidden": "true",
1713
+ children: MARK$1[r.level]
1714
+ }),
1715
+ " ",
1716
+ /* @__PURE__ */ a("code", { children: r.e.event })
1717
+ ] }),
1718
+ /* @__PURE__ */ a("td", { children: r.subject }),
1719
+ /* @__PURE__ */ a("td", {
1720
+ class: "dt-vclip",
1721
+ children: r.detail
1722
+ })
1723
+ ]
1724
+ }), isOpen ? /* @__PURE__ */ a("tr", {
1725
+ class: "dt-log-detail",
1726
+ "data-event-detail": "",
1727
+ children: /* @__PURE__ */ a("td", {
1728
+ colSpan: 5,
1729
+ children: /* @__PURE__ */ a("div", {
1730
+ class: "dt-detail",
1731
+ children: /* @__PURE__ */ a("div", {
1732
+ class: "dt-detail-part dt-detail-value",
1733
+ children: [/* @__PURE__ */ a("div", {
1734
+ class: "dt-detail-bar",
1735
+ children: [/* @__PURE__ */ a("strong", {
1736
+ class: "dt-detail-h",
1737
+ children: "Data"
1738
+ }), /* @__PURE__ */ a("button", {
1739
+ type: "button",
1740
+ "data-isoloop-copy": text,
1741
+ "data-log-copy": "event",
1742
+ onClick: () => {
1743
+ setCopied(r.key);
1744
+ setTimeout(() => {
1745
+ setCopied((c) => c === r.key ? void 0 : c);
1746
+ }, 1500);
1747
+ },
1748
+ children: copied === r.key ? "Copied" : "Copy"
1749
+ })]
1750
+ }), /* @__PURE__ */ a("pre", {
1751
+ class: "dt-json",
1752
+ children: highlight(text).map((part, i) => /* @__PURE__ */ a("span", {
1753
+ class: part.kind ? `dt-j-${part.kind}` : void 0,
1754
+ children: part.text
1755
+ }, i))
1756
+ })]
1757
+ })
1758
+ })
1759
+ })
1760
+ }) : null] }, r.key);
1761
+ }) })]
1762
+ }), matching.length > rows.length ? /* @__PURE__ */ a("p", {
1763
+ style: "margin:6px 0;",
1764
+ children: /* @__PURE__ */ a("button", {
1765
+ type: "button",
1766
+ class: "dt-more",
1767
+ "data-events-older": "",
1768
+ onClick: () => {
1769
+ setLimit(limit + PAGE);
1770
+ },
1771
+ children: [
1772
+ "Load older (",
1773
+ matching.length - rows.length,
1774
+ " more)"
1775
+ ]
1776
+ })
1777
+ }) : null] })
1778
+ })
1779
+ ]
1780
+ });
1781
+ }
1782
+ // src/record-detail.tsx
1783
+ const ITEMS = [{
1784
+ id: "value",
1785
+ label: "Value"
1786
+ }, {
1787
+ id: "record",
1788
+ label: "Record"
1789
+ }];
1790
+ function Value(props) {
1791
+ return /* @__PURE__ */ a("pre", {
1792
+ class: "dt-json",
1793
+ children: highlight(props.text).map((part, i) => /* @__PURE__ */ a("span", {
1794
+ class: part.kind ? `dt-j-${part.kind}` : void 0,
1795
+ children: part.text
1796
+ }, i))
1797
+ });
1798
+ }
1799
+ const dim = (v) => /* @__PURE__ */ a("span", {
1800
+ class: "dt-dim",
1801
+ children: v
1802
+ });
1803
+ function Fields(props) {
1804
+ const { r } = props;
1805
+ return /* @__PURE__ */ a(M, { children: [/* @__PURE__ */ a("dl", {
1806
+ class: "dt-rec",
1807
+ children: [
1808
+ [
1809
+ "Time",
1810
+ "mono",
1811
+ new Date(r.ts).toISOString()
1812
+ ],
1813
+ [
1814
+ "Topic",
1815
+ "topic",
1816
+ r.topic
1817
+ ],
1818
+ [
1819
+ "Offset",
1820
+ "num",
1821
+ String(r.offset)
1822
+ ],
1823
+ [
1824
+ "Key",
1825
+ r.key === void 0 ? "" : "str",
1826
+ r.key ?? dim("–")
1827
+ ],
1828
+ [
1829
+ "Producer",
1830
+ "",
1831
+ r.producer
1832
+ ],
1833
+ [
1834
+ "Size",
1835
+ "num",
1836
+ `${r.bytes} B`
1837
+ ],
1838
+ [
1839
+ "Request",
1840
+ "",
1841
+ r.req ? `${r.req.from} · ${r.req.id}${r.req.via ? ` · via ${r.req.via}` : ""}` : dim("–")
1842
+ ]
1843
+ ].map(([k, kind, v]) => /* @__PURE__ */ a("div", {
1844
+ class: "dt-rec-row",
1845
+ children: [/* @__PURE__ */ a("dt", { children: k }), /* @__PURE__ */ a("dd", {
1846
+ class: kind ? `dt-rec-${kind}` : void 0,
1847
+ children: v
1848
+ })]
1849
+ }, k))
1850
+ }), r.truncated ? /* @__PURE__ */ a("p", {
1851
+ class: "dt-rec-note",
1852
+ children: "The value is cut to a 2 KB preview."
1853
+ }) : null] });
1854
+ }
1855
+ function RecordDetail(props) {
1856
+ const { r } = props;
1857
+ const [copied, setCopied] = d(void 0);
1858
+ const value = pretty(r.preview);
1859
+ const record = recordJson(r);
1860
+ const copy = (p) => /* @__PURE__ */ a("button", {
1861
+ type: "button",
1862
+ "data-isoloop-copy": p === "value" ? value : record,
1863
+ "data-log-copy": p,
1864
+ onClick: () => {
1865
+ setCopied(p);
1866
+ setTimeout(() => {
1867
+ setCopied((c) => c === p ? void 0 : c);
1868
+ }, 1500);
1869
+ },
1870
+ children: copied === p ? "Copied" : "Copy"
1871
+ });
1872
+ return /* @__PURE__ */ a("div", {
1873
+ class: "dt-detail dt-detail-cols",
1874
+ children: ITEMS.map((it) => /* @__PURE__ */ a("section", {
1875
+ class: `dt-detail-part dt-detail-${it.id}`,
1876
+ children: [/* @__PURE__ */ a("div", {
1877
+ class: "dt-detail-bar",
1878
+ children: [/* @__PURE__ */ a("strong", {
1879
+ class: "dt-detail-h",
1880
+ children: it.label
1881
+ }), copy(it.id)]
1882
+ }), it.id === "value" ? /* @__PURE__ */ a(Value, { text: value }) : /* @__PURE__ */ a(Fields, { r })]
1883
+ }, it.id))
1884
+ });
1885
+ }
1886
+ /** Splits the filter into tap patterns: `*` (every topic) when empty. */
1887
+ const patternsOf = (filter) => {
1888
+ const p = filter.split(/[\s,]+/).map((s) => s.trim()).filter((s) => s.length > 0);
1889
+ return p.length > 0 ? p : ["*"];
1890
+ };
1891
+ const pad = (n, w = 2) => String(n).padStart(w, "0");
1892
+ const time = (ts) => {
1893
+ const d = new Date(ts);
1894
+ return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds(), 3)}`;
1895
+ };
1896
+ /** The row's one-line value is coloured once, from its first characters (the cell clips the rest). */
1897
+ const GLANCE = 240;
1898
+ function MessagesView() {
1899
+ const inspector = useIsolate().inspector;
1900
+ const [filter, setFilter] = d("");
1901
+ const [applied, setApplied] = d(["*"]);
1902
+ const [paused, setPaused] = d(false);
1903
+ const [entries, setEntries] = d([]);
1904
+ const [skipped, setSkipped] = d(0);
1905
+ const [open, setOpen] = d(/* @__PURE__ */ new Set());
1906
+ A(() => {
1907
+ if (!inspector || paused) return void 0;
1908
+ let n = 0;
1909
+ const onSkipped = (count) => {
1910
+ setSkipped((x) => x + count);
1911
+ };
1912
+ return inspector.tap({
1913
+ topics: applied,
1914
+ maxPerSec: 50,
1915
+ onSkipped
1916
+ }, (r) => {
1917
+ n += 1;
1918
+ const entry = {
1919
+ ...r,
1920
+ n,
1921
+ glance: highlight(r.preview.slice(0, GLANCE))
1922
+ };
1923
+ setEntries((prev) => [entry, ...prev].slice(0, 200));
1924
+ });
1925
+ }, [
1926
+ inspector,
1927
+ applied,
1928
+ paused
1929
+ ]);
1930
+ return /* @__PURE__ */ a("div", {
1931
+ class: "dt-view dt-log",
1932
+ "data-view": "messages",
1933
+ children: [
1934
+ /* @__PURE__ */ a("form", {
1935
+ class: "dt-log-bar",
1936
+ onSubmit: (e) => {
1937
+ e.preventDefault();
1938
+ setApplied(patternsOf(filter));
1939
+ },
1940
+ children: [
1941
+ /* @__PURE__ */ a("input", {
1942
+ type: "text",
1943
+ "aria-label": "Topics to log, as patterns (empty for every topic)",
1944
+ placeholder: "Topics, e.g. orders.* (empty: all)",
1945
+ value: filter,
1946
+ "data-log-filter": "",
1947
+ onInput: (e) => {
1948
+ setFilter(e.currentTarget.value);
1949
+ }
1950
+ }),
1951
+ /* @__PURE__ */ a("button", {
1952
+ type: "submit",
1953
+ "data-log-apply": "",
1954
+ children: "Apply"
1955
+ }),
1956
+ /* @__PURE__ */ a("button", {
1957
+ type: "button",
1958
+ "data-log-pause": "",
1959
+ "aria-pressed": paused ? "true" : "false",
1960
+ onClick: () => {
1961
+ setPaused((p) => !p);
1962
+ },
1963
+ children: paused ? "Resume" : "Pause"
1964
+ }),
1965
+ /* @__PURE__ */ a("button", {
1966
+ type: "button",
1967
+ "data-log-clear": "",
1968
+ onClick: () => {
1969
+ setEntries([]);
1970
+ },
1971
+ children: "Clear"
1972
+ })
1973
+ ]
1974
+ }),
1975
+ /* @__PURE__ */ a("p", {
1976
+ class: "dt-muted",
1977
+ style: "margin:4px 0;",
1978
+ children: [
1979
+ paused ? "Paused" : `Tapping ${applied.join(", ")}`,
1980
+ " · newest first ·",
1981
+ " ",
1982
+ /* @__PURE__ */ a("span", {
1983
+ "data-log-skipped": skipped,
1984
+ children: [
1985
+ 50,
1986
+ "/s cap · ",
1987
+ skipped,
1988
+ " skipped"
1989
+ ]
1990
+ })
1991
+ ]
1992
+ }),
1993
+ /* @__PURE__ */ a("div", {
1994
+ class: "dt-log-rows",
1995
+ children: entries.length === 0 ? /* @__PURE__ */ a("p", {
1996
+ class: "dt-muted",
1997
+ children: "No records yet."
1998
+ }) : /* @__PURE__ */ a("table", {
1999
+ class: "dt-table",
2000
+ "data-log-table": "",
2001
+ children: [/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: [
2002
+ /* @__PURE__ */ a("th", {
2003
+ class: "dt-c-chev",
2004
+ children: /* @__PURE__ */ a("span", {
2005
+ class: "dt-sr",
2006
+ children: "Details"
2007
+ })
2008
+ }),
2009
+ /* @__PURE__ */ a("th", {
2010
+ class: "dt-c-time",
2011
+ children: "Time"
2012
+ }),
2013
+ /* @__PURE__ */ a("th", { children: "Topic" }),
2014
+ /* @__PURE__ */ a("th", {
2015
+ class: "dt-num dt-c-offset",
2016
+ children: "Offset"
2017
+ }),
2018
+ /* @__PURE__ */ a("th", {
2019
+ class: "dt-c-key",
2020
+ children: "Key"
2021
+ }),
2022
+ /* @__PURE__ */ a("th", { children: "Producer" }),
2023
+ /* @__PURE__ */ a("th", {
2024
+ class: "dt-num dt-c-size",
2025
+ children: "Size"
2026
+ }),
2027
+ /* @__PURE__ */ a("th", { children: "Value" })
2028
+ ] }) }), /* @__PURE__ */ a("tbody", { children: entries.map((r) => {
2029
+ const id = `${r.topic} ${r.offset} ${r.n}`;
2030
+ const isOpen = open.has(id);
2031
+ return /* @__PURE__ */ a(M, { children: [/* @__PURE__ */ a("tr", {
2032
+ class: "dt-log-row",
2033
+ "data-log-topic": r.topic,
2034
+ "data-offset": r.offset,
2035
+ "aria-expanded": isOpen ? "true" : "false",
2036
+ onClick: () => {
2037
+ const next = new Set(open);
2038
+ if (isOpen) next.delete(id);
2039
+ else next.add(id);
2040
+ setOpen(next);
2041
+ },
2042
+ children: [
2043
+ /* @__PURE__ */ a("td", {
2044
+ class: "dt-c-chev",
2045
+ children: /* @__PURE__ */ a("button", {
2046
+ type: "button",
2047
+ class: "dt-chev",
2048
+ "aria-expanded": isOpen ? "true" : "false",
2049
+ "aria-label": isOpen ? "Hide the record" : "Show the record",
2050
+ children: isOpen ? "▾" : "▸"
2051
+ })
2052
+ }),
2053
+ /* @__PURE__ */ a("td", {
2054
+ class: "dt-c-time",
2055
+ children: time(r.ts)
2056
+ }),
2057
+ /* @__PURE__ */ a("td", {
2058
+ class: "dt-col-topic",
2059
+ children: /* @__PURE__ */ a("code", { children: r.topic })
2060
+ }),
2061
+ /* @__PURE__ */ a("td", {
2062
+ class: "dt-num dt-c-offset dt-col-num",
2063
+ children: r.offset
2064
+ }),
2065
+ /* @__PURE__ */ a("td", {
2066
+ class: "dt-c-key dt-col-str",
2067
+ title: r.key ?? "",
2068
+ children: r.key ?? ""
2069
+ }),
2070
+ /* @__PURE__ */ a("td", { children: r.producer }),
2071
+ /* @__PURE__ */ a("td", {
2072
+ class: "dt-num dt-c-size",
2073
+ children: [r.bytes, " B"]
2074
+ }),
2075
+ /* @__PURE__ */ a("td", {
2076
+ class: "dt-vclip",
2077
+ children: /* @__PURE__ */ a("code", { children: r.glance.map((part, i) => /* @__PURE__ */ a("span", {
2078
+ class: part.kind ? `dt-j-${part.kind}` : void 0,
2079
+ children: part.text
2080
+ }, i)) })
2081
+ })
2082
+ ]
2083
+ }), isOpen ? /* @__PURE__ */ a("tr", {
2084
+ class: "dt-log-detail",
2085
+ "data-log-detail": "",
2086
+ children: /* @__PURE__ */ a("td", {
2087
+ colSpan: 8,
2088
+ children: /* @__PURE__ */ a(RecordDetail, { r })
2089
+ })
2090
+ }) : null] }, id);
2091
+ }) })]
2092
+ })
2093
+ })
2094
+ ]
2095
+ });
2096
+ }
2097
+ // src/subtabs.tsx
2098
+ const subId = (group, id) => `dt-sub-${group}-${id}`;
2099
+ const subPanelId = (group) => `dt-subpanel-${group}`;
2100
+ function SubTabs(props) {
2101
+ const ctx = useIsolate();
2102
+ const buttons = T({});
2103
+ const { items, value } = props;
2104
+ const onKey = (e) => {
2105
+ const step = e.key === "ArrowRight" ? 1 : e.key === "ArrowLeft" ? -1 : 0;
2106
+ if (step === 0) return;
2107
+ const i = items.findIndex((t) => t.id === value);
2108
+ const next = items[(i + step + items.length) % items.length];
2109
+ if (!next) return;
2110
+ props.onChange(next.id);
2111
+ const el = buttons.current[next.id];
2112
+ if (el !== void 0) ctx.host.focus(el).catch(() => void 0);
2113
+ };
2114
+ return /* @__PURE__ */ a("div", {
2115
+ class: "dt-subtabs",
2116
+ role: "tablist",
2117
+ "aria-label": props.label,
2118
+ onKeyDown: onKey,
2119
+ children: items.map((t) => /* @__PURE__ */ a("button", {
2120
+ ref: (el) => {
2121
+ buttons.current[t.id] = el ?? void 0;
2122
+ },
2123
+ id: subId(props.group, t.id),
2124
+ type: "button",
2125
+ role: "tab",
2126
+ "data-subtab": t.id,
2127
+ "aria-selected": value === t.id ? "true" : "false",
2128
+ "aria-controls": subPanelId(props.group),
2129
+ tabindex: value === t.id ? 0 : -1,
2130
+ class: "dt-subtab",
2131
+ onClick: () => {
2132
+ props.onChange(t.id);
2133
+ },
2134
+ children: [t.label, t.count === void 0 ? null : /* @__PURE__ */ a("span", {
2135
+ class: "dt-subcount",
2136
+ children: t.count
2137
+ })]
2138
+ }, t.id))
2139
+ });
2140
+ }
2141
+ // src/views.tsx
2142
+ /** How long the block control busy-loops an isolate's worker. */
2143
+ const BLOCK_MS = 2e3;
2144
+ const CSS = `
2145
+ .dt-root { display: flex; flex-direction: column; flex: 1; min-height: 0; }
2146
+ .dt-nav { background: #0b1220; }
2147
+ .dt-scroll { flex: 1; min-height: 0; overflow: auto; }
2148
+ /* The log keeps its toolbar in place and scrolls only its rows. */
2149
+ .dt-scroll-fill { display: flex; flex-direction: column; overflow: hidden; }
2150
+ .dt-tabs { display: flex; gap: 2px; padding: 4px 12px 0; border-bottom: 1px solid #374151; }
2151
+ .dt-subtabs { display: flex; gap: 4px; padding: 4px 12px; background: #0f1a2e;
2152
+ border-bottom: 1px solid #1f2937; }
2153
+ .dt-subtab { background: none; border: 1px solid transparent; border-radius: 999px; color: #8b95a7;
2154
+ font: inherit; font-size: 11px; padding: 1px 9px; cursor: pointer; }
2155
+ .dt-subtab:hover { color: #e5e7eb; }
2156
+ .dt-subtab[aria-selected="true"] { background: #1e293b; border-color: #334155; color: #e5e7eb; }
2157
+ .dt-subtab:focus-visible { outline: 2px solid #60a5fa; outline-offset: 1px; }
2158
+ .dt-subcount { margin-left: 5px; color: #64748b; font-variant-numeric: tabular-nums; }
2159
+ .dt-subtab[aria-selected="true"] .dt-subcount { color: #93c5fd; }
2160
+ .dt-tab { background: none; border: 0; border-bottom: 2px solid transparent; color: #9ca3af;
2161
+ font: inherit; padding: 4px 8px; cursor: pointer; }
2162
+ .dt-tab[aria-selected="true"] { color: #e5e7eb; border-bottom-color: #60a5fa; }
2163
+ .dt-view { padding: 6px 12px; }
2164
+ .dt-muted { color: #9ca3af; }
2165
+ .dt-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
2166
+ .dt-table th { text-align: left; font-weight: 600; color: #9ca3af; padding: 2px 12px 4px 0;
2167
+ white-space: nowrap; }
2168
+ .dt-table td { padding: 3px 12px 3px 0; border-top: 1px solid #1f2937; vertical-align: top;
2169
+ white-space: nowrap; }
2170
+ .dt-table th { position: sticky; top: 0; z-index: 1; background: #111827; box-shadow: 0 1px 0 #374151; }
2171
+ .dt-table td.dt-num, .dt-table th.dt-num { text-align: right; }
2172
+ .dt-chips { display: flex; flex-wrap: wrap; gap: 3px; }
2173
+ .dt-chip { background: #1f2937; border: 1px solid #374151; border-radius: 4px; padding: 0 5px;
2174
+ font-size: 11px; color: #d1d5db; }
2175
+ .dt-more { background: none; border: 1px dashed #4b5563; border-radius: 4px; color: #93c5fd;
2176
+ font: inherit; font-size: 11px; padding: 0 5px; cursor: pointer; }
2177
+ .dt-more:focus-visible { outline: 2px solid #60a5fa; outline-offset: 1px; }
2178
+ .dt-pool-note { margin-top: 3px; font-size: 11px; }
2179
+ .dt-badge { display: inline-block; margin-left: 4px; padding: 0 4px; border-radius: 3px;
2180
+ background: #1e3a8a; color: #bfdbfe; font-size: 10px; }
2181
+ /* The Events tab's count of problems: amber, like the ring's arcs. */
2182
+ .dt-badge-warn { background: #f59e0b; color: #111827; font-weight: 600; }
2183
+ .dt-pool { display: block; color: #9ca3af; font-size: 11px; }
2184
+ .dt-state-running { color: #86efac; }
2185
+ .dt-state-blocked, .dt-state-crashed, .dt-state-restarting { color: #fcd34d; }
2186
+ .dt-state-failed { color: #fca5a5; }
2187
+ .dt-actions { display: flex; justify-content: center; gap: 4px; }
2188
+ .dt-table th.dt-center { text-align: center; }
2189
+ .dt-actions button { background: #1f2937; color: #e5e7eb; border: 1px solid #374151;
2190
+ border-radius: 4px; font: inherit; font-size: 11px; padding: 1px 6px; cursor: pointer; }
2191
+ .dt-actions button:focus-visible, .dt-tab:focus-visible { outline: 2px solid #60a5fa;
2192
+ outline-offset: 1px; }
2193
+ .dt-status { margin: 6px 0 0; color: #fca5a5; }
2194
+ .dt-h { margin: 10px 0 4px; font-size: 12px; color: #9ca3af; }
2195
+ .dt-warning { color: #fcd34d; }
2196
+ .dt-state-none { color: #9ca3af; }
2197
+ .dt-log { display: flex; flex-direction: column; flex: 1; min-height: 0; }
2198
+ .dt-log-rows { flex: 1; min-height: 0; overflow: auto; container-type: inline-size; }
2199
+ /* The detail keeps the width you can see, so a wide table doesn't push its panels out of view. */
2200
+ .dt-detail { position: sticky; left: 0; width: calc(100cqw - 16px); box-sizing: border-box; }
2201
+ .dt-log-bar { display: flex; flex-wrap: wrap; align-items: stretch; gap: 4px; }
2202
+ .dt-log-bar input { flex: 1 1 9em; min-width: 9em; box-sizing: border-box; background: #0b1220; color: #e5e7eb;
2203
+ border: 1px solid #374151; border-radius: 4px; font: inherit; padding: 2px 6px; }
2204
+ .dt-log-bar button { white-space: nowrap; box-sizing: border-box; background: #1f2937; color: #e5e7eb; border: 1px solid #374151;
2205
+ border-radius: 4px; font: inherit; font-size: 11px; padding: 1px 8px; cursor: pointer; }
2206
+ .dt-log-bar select { box-sizing: border-box; background: #1f2937; color: #e5e7eb; border: 1px solid #374151;
2207
+ border-radius: 4px; font: inherit; font-size: 11px; padding: 1px 4px; max-width: 14em; }
2208
+ .dt-log-bar input:focus-visible, .dt-log-bar select:focus-visible, .dt-log-bar button:focus-visible { outline: 2px solid #60a5fa;
2209
+ outline-offset: 1px; }
2210
+ .dt-table td.dt-value { white-space: normal; word-break: break-all; max-width: 40ch; }
2211
+ /* The log's columns with a known width keep it; the value takes the rest, on one line. */
2212
+ .dt-table .dt-c-time { width: 12ch; min-width: 12ch; }
2213
+ .dt-table .dt-c-offset { width: 7ch; min-width: 7ch; }
2214
+ .dt-table .dt-c-size { width: 9ch; min-width: 9ch; }
2215
+ .dt-table .dt-c-key { width: 12ch; min-width: 12ch; max-width: 12ch; overflow: hidden;
2216
+ text-overflow: ellipsis; }
2217
+ .dt-table td.dt-vclip { width: 100%; max-width: 0; overflow: hidden; text-overflow: ellipsis; }
2218
+ .dt-table .dt-c-chev { width: 18px; min-width: 18px; padding-right: 0; }
2219
+ .dt-chev { background: none; border: 0; color: #6b7280; font: inherit; font-size: 11px;
2220
+ padding: 0; width: 16px; cursor: pointer; }
2221
+ .dt-log-row:hover .dt-chev, .dt-log-row[aria-expanded="true"] .dt-chev { color: #e5e7eb; }
2222
+ .dt-chev:focus-visible { outline: 2px solid #60a5fa; outline-offset: 1px; }
2223
+ .dt-sr { position: absolute; width: 1px; height: 1px; overflow: hidden;
2224
+ clip: rect(0 0 0 0); white-space: nowrap; }
2225
+ .dt-log-row { cursor: pointer; }
2226
+ .dt-ev-new td:first-child { box-shadow: inset 3px 0 0 #f59e0b; }
2227
+ .dt-log-bar button:disabled { opacity: 0.45; cursor: default; }
2228
+ .dt-ev-bad .dt-ev-dot { color: #ef4444; }
2229
+ .dt-ev-warn .dt-ev-dot { color: #f59e0b; }
2230
+ .dt-ev-good .dt-ev-dot { color: #22c55e; }
2231
+ .dt-ev-info .dt-ev-dot { color: #64748b; }
2232
+ .dt-ev-bad td.dt-vclip { color: #fca5a5; }
2233
+ .dt-ev-warn td.dt-vclip { color: #fcd34d; }
2234
+ .dt-log-row:hover { background: #172033; }
2235
+ .dt-log-row[aria-expanded="true"] { background: #172033; }
2236
+ .dt-table tr.dt-log-detail td { white-space: normal; background: #0b1220; padding: 6px 8px; }
2237
+ .dt-detail-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
2238
+ .dt-detail-bar .dt-subtabs { background: none; border: 0; padding: 0; }
2239
+ .dt-detail-bar button[data-log-copy] { background: #1f2937; color: #e5e7eb; border: 1px solid #374151;
2240
+ border-radius: 4px; font: inherit; font-size: 11px; padding: 1px 8px; cursor: pointer; }
2241
+ .dt-detail-bar button[data-log-copy]:focus-visible { outline: 2px solid #60a5fa; outline-offset: 1px; }
2242
+ .dt-detail-h { color: #9ca3af; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
2243
+ .dt-detail-cols { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; }
2244
+ .dt-detail-part { box-sizing: border-box; min-width: 0; background: #0f1a2e; border: 1px solid #1f2937;
2245
+ border-left-width: 3px; border-radius: 6px; padding: 6px 10px 8px; }
2246
+ .dt-detail-value { flex: 1 1 260px; border-left-color: #4ade80; }
2247
+ /* The record is as wide as its content, up to 30% of what you can see. */
2248
+ .dt-detail-record { flex: 0 1 auto; width: max-content; max-width: 30%; min-width: 200px;
2249
+ border-left-color: #60a5fa; }
2250
+ .dt-rec { margin: 0; }
2251
+ .dt-rec-row { display: grid; grid-template-columns: 4.5em 1fr; gap: 0 12px; padding: 3px 0;
2252
+ border-top: 1px solid #1c2a40; }
2253
+ .dt-rec-row:first-child { border-top: 0; }
2254
+ .dt-rec dt { color: #8b95a7; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
2255
+ padding-top: 1px; }
2256
+ .dt-rec dd { margin: 0; color: #e5e7eb; word-break: break-word; }
2257
+ .dt-rec-mono, .dt-rec-topic, .dt-rec-num, .dt-rec-str { font: 11px/1.5 ui-monospace, SFMono-Regular,
2258
+ Menlo, monospace; }
2259
+ .dt-rec-topic, .dt-col-topic { color: #93c5fd; }
2260
+ .dt-rec-num, .dt-col-num { color: #fcd34d; }
2261
+ .dt-rec-str, .dt-col-str { color: #86efac; }
2262
+ .dt-dim { color: #64748b; }
2263
+ .dt-rec-note { margin: 4px 0 0; color: #9ca3af; font-size: 11px; }
2264
+ .dt-json { margin: 0; max-height: 240px; overflow: auto; white-space: pre-wrap;
2265
+ word-break: break-word; font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
2266
+ color: #d1d5db; }
2267
+ .dt-j-key { color: #93c5fd; }
2268
+ .dt-j-string { color: #86efac; }
2269
+ .dt-j-number { color: #fcd34d; }
2270
+ .dt-j-literal { color: #c4b5fd; }
2271
+ `;
2272
+ const ms = (n) => n === void 0 ? "–" : `${Math.round(n)} ms`;
2273
+ const mb = (bytes) => `${(bytes / 1048576).toFixed(1)} MB`;
2274
+ /** A memory figure, its age against the feed's latest time, and what it covers. */
2275
+ function Memory(props) {
2276
+ const { memory } = props;
2277
+ if (!memory) return /* @__PURE__ */ a("span", {
2278
+ class: "dt-muted",
2279
+ title: "Measured only in Chromium on a cross-origin isolated page (ADR 0020, decision 4)",
2280
+ children: "–"
2281
+ });
2282
+ const age = Math.max(0, Math.round((props.now - memory.at) / 1e3));
2283
+ return /* @__PURE__ */ a("span", {
2284
+ "data-memory": memory.bytes,
2285
+ title: `Chromium, cross-origin isolated. Measured ${age} s ago${memory.shared ? "; the whole pool worker, shared by its members" : ""}.`,
2286
+ children: [
2287
+ mb(memory.bytes),
2288
+ memory.shared ? " (pool)" : "",
2289
+ /* @__PURE__ */ a("span", {
2290
+ class: "dt-muted",
2291
+ children: [
2292
+ " · ",
2293
+ age,
2294
+ " s"
2295
+ ]
2296
+ })
2297
+ ]
2298
+ });
2299
+ }
2300
+ function Controls(props) {
2301
+ const act = (name, run) => () => {
2302
+ props.onError(void 0);
2303
+ run().catch((e) => {
2304
+ props.onError(`${name} ${props.id}: ${e instanceof Error ? e.message : String(e)}`);
2305
+ });
2306
+ };
2307
+ const { id, inspector } = props;
2308
+ return /* @__PURE__ */ a("span", {
2309
+ class: "dt-actions",
2310
+ children: [
2311
+ /* @__PURE__ */ a("button", {
2312
+ type: "button",
2313
+ "data-control": "restart",
2314
+ "aria-label": `Restart ${id}`,
2315
+ title: `Restart ${id}`,
2316
+ onClick: act("restart", () => inspector.restart(id)),
2317
+ children: "Restart"
2318
+ }),
2319
+ /* @__PURE__ */ a("button", {
2320
+ type: "button",
2321
+ "data-control": "kill",
2322
+ "aria-label": `Kill ${id}`,
2323
+ title: `End ${id}'s worker as a crash; the supervisor restarts it. In a pool, every member restarts.`,
2324
+ onClick: act("kill", () => inspector.kill(id)),
2325
+ children: "Kill"
2326
+ }),
2327
+ /* @__PURE__ */ a("button", {
2328
+ type: "button",
2329
+ "data-control": "block",
2330
+ "aria-label": `Block ${id} for ${BLOCK_MS / 1e3} s`,
2331
+ title: `Busy-loop ${id}'s worker for ${BLOCK_MS / 1e3} s`,
2332
+ onClick: act("block", () => inspector.block(id, BLOCK_MS)),
2333
+ children: [
2334
+ "Block ",
2335
+ BLOCK_MS / 1e3,
2336
+ " s"
2337
+ ]
2338
+ })
2339
+ ]
2340
+ });
2341
+ }
2342
+ function IsolateRow(props) {
2343
+ const i = props.isolate;
2344
+ return /* @__PURE__ */ a("tr", {
2345
+ "data-isolate": i.id,
2346
+ "data-state": i.state,
2347
+ children: [
2348
+ /* @__PURE__ */ a("td", { children: [
2349
+ /* @__PURE__ */ a("code", { children: i.id }),
2350
+ props.self ? /* @__PURE__ */ a("span", {
2351
+ class: "dt-badge",
2352
+ "data-devtools-self": "",
2353
+ children: "devtools"
2354
+ }) : null,
2355
+ i.pool === void 0 ? null : /* @__PURE__ */ a("span", {
2356
+ class: "dt-pool",
2357
+ children: ["pool ", i.pool]
2358
+ })
2359
+ ] }),
2360
+ /* @__PURE__ */ a("td", {
2361
+ class: `dt-state-${i.state}`,
2362
+ title: i.error ?? i.reason ?? "",
2363
+ children: i.state
2364
+ }),
2365
+ /* @__PURE__ */ a("td", {
2366
+ class: "dt-num",
2367
+ "data-lag": i.lagMs,
2368
+ children: ms(i.lagMs)
2369
+ }),
2370
+ /* @__PURE__ */ a("td", {
2371
+ class: "dt-num",
2372
+ title: "Busy time from its last beat (ADR 0017)",
2373
+ children: ms(i.busyMs)
2374
+ }),
2375
+ /* @__PURE__ */ a("td", {
2376
+ class: "dt-num",
2377
+ children: /* @__PURE__ */ a(Memory, {
2378
+ memory: i.memory,
2379
+ now: props.now
2380
+ })
2381
+ }),
2382
+ /* @__PURE__ */ a("td", {
2383
+ class: "dt-num",
2384
+ "data-restarts": i.restarts,
2385
+ children: i.restarts
2386
+ }),
2387
+ /* @__PURE__ */ a("td", {
2388
+ class: "dt-num",
2389
+ title: "Patch batches waiting for the compositor",
2390
+ children: i.surface ? i.surface.queued : "–"
2391
+ }),
2392
+ /* @__PURE__ */ a("td", { children: props.inspector ? /* @__PURE__ */ a(Controls, {
2393
+ id: i.id,
2394
+ inspector: props.inspector,
2395
+ onError: props.onError
2396
+ }) : null })
2397
+ ]
2398
+ });
2399
+ }
2400
+ /** How many members a pool row lists before "+N more". */
2401
+ const POOL_PREVIEW = 8;
2402
+ function PoolRow(props) {
2403
+ const { pool: p } = props;
2404
+ const [all, setAll] = d(false);
2405
+ const shown = all ? p.members : p.members.slice(0, POOL_PREVIEW);
2406
+ const rest = p.members.length - shown.length;
2407
+ return /* @__PURE__ */ a("tr", {
2408
+ "data-pool": p.name,
2409
+ children: [
2410
+ /* @__PURE__ */ a("td", { children: /* @__PURE__ */ a("code", { children: p.name }) }),
2411
+ /* @__PURE__ */ a("td", {
2412
+ class: p.running ? "dt-state-running" : "dt-state-failed",
2413
+ children: p.running ? "running" : "stopped"
2414
+ }),
2415
+ /* @__PURE__ */ a("td", {
2416
+ class: "dt-num",
2417
+ children: p.members.length
2418
+ }),
2419
+ /* @__PURE__ */ a("td", {
2420
+ style: "white-space:normal;",
2421
+ children: [/* @__PURE__ */ a("div", {
2422
+ class: "dt-chips",
2423
+ children: [shown.map((m) => /* @__PURE__ */ a("span", {
2424
+ class: "dt-chip",
2425
+ children: m
2426
+ }, m)), p.members.length > POOL_PREVIEW ? /* @__PURE__ */ a("button", {
2427
+ type: "button",
2428
+ class: "dt-more",
2429
+ "data-pool-more": p.name,
2430
+ "aria-expanded": all ? "true" : "false",
2431
+ onClick: () => {
2432
+ setAll(!all);
2433
+ },
2434
+ children: all ? "Show fewer" : `+${rest} more`
2435
+ }) : null]
2436
+ }), p.warning === void 0 ? null : /* @__PURE__ */ a("div", {
2437
+ class: "dt-pool-note dt-warning",
2438
+ children: ["⚠ ", p.warning]
2439
+ })]
2440
+ })
2441
+ ]
2442
+ });
2443
+ }
2444
+ function PoolsTable(props) {
2445
+ return /* @__PURE__ */ a("table", {
2446
+ class: "dt-table",
2447
+ "data-view": "pools",
2448
+ children: [/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: [
2449
+ /* @__PURE__ */ a("th", { children: "Pool" }),
2450
+ /* @__PURE__ */ a("th", { children: "Worker" }),
2451
+ /* @__PURE__ */ a("th", {
2452
+ class: "dt-num",
2453
+ children: "Isolates"
2454
+ }),
2455
+ /* @__PURE__ */ a("th", { children: "Members" })
2456
+ ] }) }), /* @__PURE__ */ a("tbody", { children: props.snap.pools.map((p) => /* @__PURE__ */ a(PoolRow, { pool: p }, p.name)) })]
2457
+ });
2458
+ }
2459
+ function IsolatesView(props) {
2460
+ const ctx = useIsolate();
2461
+ const [error, setError] = d(void 0);
2462
+ const { snap, sub } = props;
2463
+ if (sub === "pools") return /* @__PURE__ */ a("div", {
2464
+ class: "dt-view",
2465
+ "data-view": "isolates",
2466
+ children: /* @__PURE__ */ a(PoolsTable, { snap })
2467
+ });
2468
+ return /* @__PURE__ */ a("div", {
2469
+ class: "dt-view",
2470
+ "data-view": "isolates",
2471
+ children: [
2472
+ /* @__PURE__ */ a("p", {
2473
+ "data-isoloop-devtools-summary": "",
2474
+ class: "dt-muted",
2475
+ style: "margin:0 0 4px;",
2476
+ children: [
2477
+ snap.isolates.length,
2478
+ " isolates · bus ",
2479
+ snap.bus.state
2480
+ ]
2481
+ }),
2482
+ /* @__PURE__ */ a("table", {
2483
+ class: "dt-table",
2484
+ children: [/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: [
2485
+ /* @__PURE__ */ a("th", { children: "Isolate" }),
2486
+ /* @__PURE__ */ a("th", { children: "State" }),
2487
+ /* @__PURE__ */ a("th", {
2488
+ class: "dt-num",
2489
+ children: "Lag"
2490
+ }),
2491
+ /* @__PURE__ */ a("th", {
2492
+ class: "dt-num",
2493
+ children: "Busy"
2494
+ }),
2495
+ /* @__PURE__ */ a("th", {
2496
+ class: "dt-num",
2497
+ children: "Memory"
2498
+ }),
2499
+ /* @__PURE__ */ a("th", {
2500
+ class: "dt-num",
2501
+ children: "Restarts"
2502
+ }),
2503
+ /* @__PURE__ */ a("th", {
2504
+ class: "dt-num",
2505
+ children: "Queue"
2506
+ }),
2507
+ /* @__PURE__ */ a("th", {
2508
+ class: "dt-center",
2509
+ children: "Actions"
2510
+ })
2511
+ ] }) }), /* @__PURE__ */ a("tbody", { children: snap.isolates.map((i) => /* @__PURE__ */ a(IsolateRow, {
2512
+ isolate: i,
2513
+ self: i.id === ctx.id,
2514
+ now: snap.at,
2515
+ inspector: ctx.inspector,
2516
+ onError: setError
2517
+ }, i.id)) })]
2518
+ }),
2519
+ error === void 0 ? null : /* @__PURE__ */ a("p", {
2520
+ class: "dt-status",
2521
+ role: "status",
2522
+ "data-isoloop-devtools-status": "",
2523
+ children: error
2524
+ })
2525
+ ]
2526
+ });
2527
+ }
2528
+ const TABS = [
2529
+ {
2530
+ id: "isolates",
2531
+ label: "Isolates"
2532
+ },
2533
+ {
2534
+ id: "bus",
2535
+ label: "Bus"
2536
+ },
2537
+ {
2538
+ id: "events",
2539
+ label: "Events"
2540
+ },
2541
+ {
2542
+ id: "messages",
2543
+ label: "Messages"
2544
+ }
2545
+ ];
2546
+ const tabId = (t) => `dt-tab-${t}`;
2547
+ const panelId = (t) => `dt-panel-${t}`;
2548
+ function Body(props) {
2549
+ const ctx = useIsolate();
2550
+ const [tab, setTab] = d("isolates");
2551
+ const [isoSub, setIsoSub] = d("isolates");
2552
+ const [busSub, setBusSub] = d("topics");
2553
+ A(() => {
2554
+ ctx.styles(CSS);
2555
+ }, []);
2556
+ const { snap } = props;
2557
+ const [, setAcks] = d(0);
2558
+ const eventProblems = props.recorder.unacknowledged();
2559
+ const buttons = T({});
2560
+ const onKey = (e) => {
2561
+ const step = e.key === "ArrowRight" ? 1 : e.key === "ArrowLeft" ? -1 : 0;
2562
+ if (step === 0) return;
2563
+ const i = TABS.findIndex((t) => t.id === tab);
2564
+ const next = TABS[(i + step + TABS.length) % TABS.length];
2565
+ if (!next) return;
2566
+ setTab(next.id);
2567
+ const el = buttons.current[next.id];
2568
+ if (el !== void 0) ctx.host.focus(el).catch(() => void 0);
2569
+ };
2570
+ let view;
2571
+ let subBar = null;
2572
+ let subGroup = "";
2573
+ let subValue = "";
2574
+ if (!snap) view = /* @__PURE__ */ a("p", {
2575
+ class: "dt-view dt-muted",
2576
+ children: "Waiting for the inspection feed…"
2577
+ });
2578
+ else if (tab === "bus") {
2579
+ const m = snap.bus.metrics;
2580
+ const items = m ? [
2581
+ {
2582
+ id: "topics",
2583
+ label: "Topics",
2584
+ count: m.topics.length
2585
+ },
2586
+ {
2587
+ id: "subscriptions",
2588
+ label: "Subscriptions",
2589
+ count: m.subscriptions.length
2590
+ },
2591
+ {
2592
+ id: "rejected",
2593
+ label: "Rejected",
2594
+ count: Object.values(m.rejected).reduce((n, v) => n + (typeof v === "number" ? v : 0), 0)
2595
+ }
2596
+ ] : [];
2597
+ subGroup = "bus";
2598
+ subValue = busSub;
2599
+ if (items.length > 0) subBar = /* @__PURE__ */ a(SubTabs, {
2600
+ group: "bus",
2601
+ label: "Bus views",
2602
+ items,
2603
+ value: busSub,
2604
+ onChange: setBusSub
2605
+ });
2606
+ view = /* @__PURE__ */ a(BusView, {
2607
+ bus: snap.bus,
2608
+ sub: busSub
2609
+ });
2610
+ } else if (tab === "events") view = /* @__PURE__ */ a(EventsView, {
2611
+ recorder: props.recorder,
2612
+ onAck: () => {
2613
+ setAcks((n) => n + 1);
2614
+ }
2615
+ });
2616
+ else if (tab === "messages") view = /* @__PURE__ */ a(MessagesView, {});
2617
+ else {
2618
+ const hasPools = snap.pools.length > 0;
2619
+ const sub = hasPools ? isoSub : "isolates";
2620
+ const items = [{
2621
+ id: "isolates",
2622
+ label: "Isolates",
2623
+ count: snap.isolates.length
2624
+ }, ...hasPools ? [{
2625
+ id: "pools",
2626
+ label: "Pools",
2627
+ count: snap.pools.length
2628
+ }] : []];
2629
+ subGroup = "isolates";
2630
+ subValue = sub;
2631
+ if (hasPools) subBar = /* @__PURE__ */ a(SubTabs, {
2632
+ group: "isolates",
2633
+ label: "Isolates views",
2634
+ items,
2635
+ value: sub,
2636
+ onChange: setIsoSub
2637
+ });
2638
+ view = /* @__PURE__ */ a(IsolatesView, {
2639
+ snap,
2640
+ sub
2641
+ });
2642
+ }
2643
+ return /* @__PURE__ */ a("div", {
2644
+ class: "dt-root",
2645
+ children: [/* @__PURE__ */ a("div", {
2646
+ class: "dt-nav",
2647
+ children: [/* @__PURE__ */ a("div", {
2648
+ class: "dt-tabs",
2649
+ role: "tablist",
2650
+ "aria-label": "Devtools views",
2651
+ onKeyDown: onKey,
2652
+ children: TABS.map((t) => /* @__PURE__ */ a("button", {
2653
+ ref: (el) => {
2654
+ buttons.current[t.id] = el ?? void 0;
2655
+ },
2656
+ id: tabId(t.id),
2657
+ type: "button",
2658
+ role: "tab",
2659
+ "data-tab": t.id,
2660
+ "aria-selected": tab === t.id ? "true" : "false",
2661
+ "aria-controls": panelId(t.id),
2662
+ tabindex: tab === t.id ? 0 : -1,
2663
+ class: "dt-tab",
2664
+ onClick: () => {
2665
+ setTab(t.id);
2666
+ },
2667
+ children: [t.label, t.id === "events" && eventProblems > 0 ? /* @__PURE__ */ a("span", {
2668
+ class: "dt-badge dt-badge-warn",
2669
+ title: "Problem events you haven't acknowledged",
2670
+ children: eventProblems > 99 ? "99+" : eventProblems
2671
+ }) : null]
2672
+ }, t.id))
2673
+ }), subBar]
2674
+ }), /* @__PURE__ */ a("div", {
2675
+ class: tab === "messages" || tab === "events" ? "dt-scroll dt-scroll-fill" : "dt-scroll",
2676
+ role: "tabpanel",
2677
+ id: subBar ? subPanelId(subGroup) : panelId(tab),
2678
+ "aria-labelledby": subBar ? subId(subGroup, subValue) : tabId(tab),
2679
+ children: view
2680
+ })]
2681
+ });
2682
+ }
2683
+ // src/panel.tsx
2684
+ const POSITIONS = [
2685
+ "bottom-right",
2686
+ "bottom-left",
2687
+ "top-left",
2688
+ "top-right"
2689
+ ];
2690
+ const MIN_WIDTH = 280;
2691
+ const MIN_HEIGHT = 160;
2692
+ const GAP = 12;
2693
+ /** The open panel docks flush to the viewport edges, so it can be dragged to the very edge. */
2694
+ const DOCK_GAP = 0;
2695
+ /** Isoloop one-colour mark (logo exploration 6-cube v108), traced to a path. */
2696
+ const MARK = "M33.9 79.4L31.7 79.4L28.4 79.2L26.3 78.8L23.5 78.1L19.9 76.6L17.1 75.0L15.2 73.7L12.5 71.4L10.6 69.3L9.1 67.3L7.7 65.0L6.6 62.1L5.9 59.7L5.4 56.7L5.2 53.3L0.1 53.2L5.4 43.7L6.0 40.3L6.9 36.7L7.9 33.8L9.2 30.7L11.1 27.0L13.9 22.9L15.5 20.8L17.6 18.4L19.9 16.2L24.2 12.7L26.7 11.0L30.5 8.9L33.9 7.4L38.6 5.7L42.9 4.8L47.5 4.3L51.6 4.2L55.2 4.5L59.2 5.2L63.8 6.5L67.3 7.9L71.6 10.1L75.4 12.5L77.7 14.3L80.1 16.5L83.3 19.8L84.9 21.8L87.1 25.0L89.7 29.6L90.9 32.3L92.3 36.0L93.1 38.8L93.8 42.0L94.3 45.9L99.7 46.1L94.4 55.9L93.2 60.7L91.6 65.4L91.6 65.5L91.1 64.8L80.0 46.2L86.0 46.1L85.9 43.7L85.5 41.3L84.8 38.3L84.2 36.4L83.4 34.2L82.0 31.0L80.2 27.8L79.0 26.1L77.7 24.4L75.7 22.1L72.1 18.8L68.7 16.3L66.4 15.0L64.2 13.9L59.9 12.3L56.3 11.5L53.7 11.1L51.6 10.9L48.7 10.9L46.3 11.0L41.5 11.9L37.6 13.1L33.7 14.7L30.7 16.3L26.5 19.4L23.9 21.7L20.8 25.1L18.3 28.5L16.5 31.8L15.5 34.2L14.4 37.6L13.8 40.1L13.5 43.5L13.7 44.0L19.3 53.1L19.2 53.2L13.5 53.3L13.1 53.4L13.3 55.3L14.1 58.4L15.3 61.4L16.6 63.6L18.4 65.9L21.0 68.3L23.7 70.0L25.9 71.0L27.2 71.4L30.2 71.9L32.1 72.1L34.7 71.9L36.7 71.7L38.9 71.1L41.0 70.5L42.6 69.8L44.5 68.7L46.1 67.6L46.9 66.9L48.5 65.0L49.4 63.2L50.0 61.4L50.2 59.5L50.3 51.2L77.6 35.1L77.7 36.5L77.8 65.2L77.7 65.4L72.0 68.8L71.4 69.1L71.3 69.0L71.1 65.9L70.4 62.0L70.3 47.3L70.1 47.2L57.1 54.8L57.0 62.0L56.9 63.3L56.5 65.2L55.7 67.4L54.6 69.5L53.1 71.4L51.8 72.6L49.8 74.2L47.6 75.6L45.7 76.6L43.0 77.7L38.4 78.9ZM32.8 39.5L30.1 38.1L23.1 33.9L24.4 33.1L49.9 18.0L69.9 29.5L69.1 30.0L62.6 33.8L50.1 26.5L42.6 30.6L38.9 33.0L37.5 34.1L35.2 36.3ZM30.2 60.9L30.0 60.9L30.0 51.5L30.2 49.0L30.6 46.7L31.1 45.0L31.8 43.2L32.9 41.0L35.1 37.9L36.9 35.9L38.5 34.5L42.3 31.9L49.5 27.8L49.7 30.0L49.7 35.2L49.6 41.0L44.9 38.4L43.4 39.6L41.6 41.4L39.8 43.7L38.6 45.9L37.8 48.4L37.5 50.7L37.5 52.6L41.1 54.7L41.2 54.9ZM50.6 40.8L50.6 27.9L61.5 34.4L60.5 35.0ZM49.7 50.4L40.3 45.0L40.5 44.4L41.8 42.7L43.7 40.6L44.9 39.6L45.0 39.5L45.8 39.9L49.9 42.3L70.9 30.1L77.5 33.9ZM33.6 71.1L31.4 71.1L22.3 65.5L22.4 34.7L32.2 40.3L31.0 42.7L30.2 44.8L29.5 47.4L29.2 48.9L29.0 51.4L29.1 61.8L39.0 67.7L41.4 69.2L40.1 69.8L37.4 70.6L35.1 71.0ZM42.9 68.5L42.6 68.6L42.5 68.2L42.6 54.6L38.4 52.0L38.6 49.0L39.0 47.6L39.7 45.8L49.3 51.4L49.3 59.7L49.0 61.4L48.6 62.7L47.7 64.6L46.8 65.6L45.2 67.2ZM69.4 61.3L58.5 55.0L69.3 48.7L69.4 48.8L69.4 48.9L69.5 58.3L69.5 61.2ZM41.6 68.0L41.4 68.0L40.4 67.4L30.9 61.9L30.8 61.7L41.6 55.8ZM56.1 69.2L55.9 69.3L55.8 69.2L56.7 67.6L57.3 65.8L57.9 63.2L58.0 60.9L58.0 56.0L58.1 55.9L58.6 56.2L68.6 62.0L68.6 62.1ZM52.8 95.6L46.0 95.6L43.1 95.3L39.3 94.7L35.8 93.7L33.2 92.7L31.2 91.8L27.6 89.9L24.4 87.7L22.2 86.0L19.3 83.3L17.5 81.4L15.6 79.1L13.5 76.1L11.3 72.6L10.2 70.5L10.3 70.5L12.2 72.4L14.3 74.1L18.5 77.0L22.6 78.7L25.0 79.4L28.2 80.0L31.8 82.6L35.8 84.6L38.6 85.7L42.4 86.6L46.4 87.0L49.3 86.9L51.8 86.4L53.9 85.5L55.9 84.2L58.2 82.0L59.4 80.3L60.3 78.7L61.5 75.3L61.9 72.9L62.0 71.4L61.9 69.0L61.6 67.3L69.5 62.7L69.8 64.0L70.3 67.6L70.4 70.4L70.2 73.0L69.8 75.6L69.3 77.6L68.4 80.1L67.2 82.2L64.8 85.6L62.7 87.7L60.4 89.6L58.1 91.1L56.3 92.1L53.2 93.4L49.7 94.5L50.3 94.5L51.7 94.4L54.4 93.7L57.7 92.3L60.3 90.9L62.9 88.9L64.5 87.4L66.2 85.5L67.8 83.2L68.8 81.4L72.0 78.9L75.4 75.7L78.1 72.4L81.1 68.0L83.6 63.1L84.7 60.3L85.6 57.5L91.1 66.7L89.0 71.1L87.1 74.2L84.5 77.9L82.4 80.5L78.8 84.2L75.5 86.9L72.0 89.3L69.1 91.0L64.8 92.9L60.7 94.2L56.2 95.2ZM50.6 81.7L50.6 74.8L52.9 72.9L54.7 71.0L60.7 67.7L61.0 69.5L61.1 71.6L60.9 73.9L60.5 75.4ZM49.7 82.3L49.4 82.3L45.6 80.1L43.2 78.6L46.9 77.0L49.7 75.5Z";
2697
+ const font = "font:12px/1.4 ui-sans-serif,system-ui,sans-serif;";
2698
+ const configStatus = (config) => {
2699
+ const v = typeof config === "object" && config !== null ? Reflect.get(config, "healthStatus") : void 0;
2700
+ return v === "radar" || v === "off" ? v : "ring";
2701
+ };
2702
+ const configPosition = (config) => {
2703
+ const p = typeof config === "object" && config !== null ? Reflect.get(config, "position") : void 0;
2704
+ return POSITIONS.find((x) => x === p) ?? "bottom-right";
2705
+ };
2706
+ /**
2707
+ * CSS placing a box in `position`'s corner of the viewport. Fixed, not
2708
+ * absolute: the compositor's own element in the surface has no height.
2709
+ */
2710
+ const corner = (position, gap = GAP) => {
2711
+ const [v, h] = position.split("-");
2712
+ return `position:fixed;${v}:${gap}px;${h}:${gap}px;`;
2713
+ };
2714
+ /**
2715
+ * The panel's size. Stretched or maximized, it is pinned to both edges instead
2716
+ * of given the viewport's width: `100vw` counts the page's scrollbar, so the
2717
+ * panel would run a few pixels past the window.
2718
+ */
2719
+ const OPPOSITE = {
2720
+ left: "right",
2721
+ right: "left",
2722
+ top: "bottom",
2723
+ bottom: "top"
2724
+ };
2725
+ const fill = (ui) => {
2726
+ const [v, h] = ui.position.split("-");
2727
+ return `${ui.mode !== "normal" ? `${OPPOSITE[h ?? ""] ?? "left"}:0;` : ""}${ui.mode === "max" ? `${OPPOSITE[v ?? ""] ?? "top"}:0;` : ""}${ui.mode === "normal" ? `width:${ui.width}px;` : "width:auto;"}${ui.mode === "max" ? "height:auto;" : `height:${ui.height}px;`}max-width:100%;max-height:100%;`;
2728
+ };
2729
+ /** The closed button: a round tile of 70px, the mark inside at 58px. */
2730
+ const FAB_SIZE = 70;
2731
+ const FAB_MARK = 46;
2732
+ /** The ring's thickness: it sits on the button's outer edge, with nothing outside it. */
2733
+ const RING_WIDTH = 4;
2734
+ /** Seconds for the wave to go once around the ring. */
2735
+ const RING_PERIOD = 2.4;
2736
+ /**
2737
+ * The wave: every arc brightens and dims on the same clock, each a step behind
2738
+ * the last (the delays are set per arc), so brightness runs round the ring. The
2739
+ * colour is animated, not the opacity, so where two arcs overlap by a hair no
2740
+ * seam shows. A failing arc pulses faster; a grey one sits still. Reduced
2741
+ * motion: no motion.
2742
+ */
2743
+ const RING_CSS = `
2744
+ @keyframes dt-flow-ok { 0%, 100% { stroke: #15803d; } 50% { stroke: #22c55e; } }
2745
+ @keyframes dt-flow-unwell { 0%, 100% { stroke: #a16207; } 50% { stroke: #f59e0b; } }
2746
+ @keyframes dt-alarm { 0%, 100% { stroke: #ef4444; } 50% { stroke: #7f1d1d; } }
2747
+ @keyframes dt-fill-ok { 0%, 100% { fill: #15803d; } 50% { fill: #4ade80; } }
2748
+ @keyframes dt-fill-unwell { 0%, 100% { fill: #a16207; } 50% { fill: #fbbf24; } }
2749
+ @keyframes dt-fill-alarm { 0%, 100% { fill: #ef4444; } 50% { fill: #7f1d1d; } }
2750
+ .dt-ring path[data-level="ok"] { animation: dt-flow-ok ${RING_PERIOD}s ease-in-out infinite; }
2751
+ .dt-ring path[data-level="unwell"] { animation: dt-flow-unwell ${RING_PERIOD}s ease-in-out infinite; }
2752
+ .dt-ring path[data-level="failed"] { animation: dt-alarm 0.9s ease-in-out infinite; }
2753
+ .dt-mark path[data-level="ok"] { animation: dt-fill-ok ${RING_PERIOD}s ease-in-out infinite; }
2754
+ .dt-mark path[data-level="unwell"] { animation: dt-fill-unwell ${RING_PERIOD}s ease-in-out infinite; }
2755
+ .dt-mark path[data-level="failed"] { animation: dt-fill-alarm 0.9s ease-in-out infinite; }
2756
+ @media (prefers-reduced-motion: reduce) {
2757
+ .dt-ring path, .dt-mark path { animation: none; }
2758
+ }
2759
+ `;
2760
+ const LEVEL_COLOR = {
2761
+ ok: "#22c55e",
2762
+ unwell: "#f59e0b",
2763
+ failed: "#ef4444",
2764
+ unknown: "#334155"
2765
+ };
2766
+ const STEP = {
2767
+ "bottom-left": {
2768
+ horizontal: "bottom-right",
2769
+ vertical: "top-left"
2770
+ },
2771
+ "bottom-right": {
2772
+ horizontal: "bottom-left",
2773
+ vertical: "top-right"
2774
+ },
2775
+ "top-left": {
2776
+ horizontal: "top-right",
2777
+ vertical: "bottom-left"
2778
+ },
2779
+ "top-right": {
2780
+ horizontal: "top-left",
2781
+ vertical: "bottom-right"
2782
+ }
2783
+ };
2784
+ /** The corner one step across (`horizontal`) or up or down (`vertical`) from `position`. */
2785
+ const stepPosition = (position, axis) => STEP[position][axis];
2786
+ const ARROW = 24;
2787
+ const ARROW_GAP = 4;
2788
+ /** Chevron paths on the 14 px icon grid. */
2789
+ const CHEVRON = {
2790
+ left: "M8.5 3 4.5 7l4 4",
2791
+ right: "M5.5 3l4 4-4 4",
2792
+ up: "M3 8.5l4-4 4 4",
2793
+ down: "M3 5.5l4 4 4-4"
2794
+ };
2795
+ const arrowStyle = `position:absolute;width:${ARROW}px;height:${ARROW}px;padding:0;border-radius:${ARROW / 2}px;display:flex;align-items:center;justify-content:center;border:1px solid #374151;background:#111827;color:#e5e7eb;cursor:pointer;box-shadow:0 2px 6px rgb(0 0 0 / 0.5);`;
2796
+ function Fab(props) {
2797
+ const [hover, setHover] = d(false);
2798
+ const [v, h] = props.position.split("-");
2799
+ const toH = stepPosition(props.position, "horizontal");
2800
+ const toV = stepPosition(props.position, "vertical");
2801
+ const chevH = h === "left" ? CHEVRON.right : CHEVRON.left;
2802
+ const chevV = v === "top" ? CHEVRON.down : CHEVRON.up;
2803
+ const mid = 23;
2804
+ const offH = h === "left" ? 74 : -28;
2805
+ const offV = v === "top" ? 74 : -28;
2806
+ const bridgeH = h === "left" ? FAB_SIZE : -4;
2807
+ const bridgeV = v === "top" ? FAB_SIZE : -4;
2808
+ return /* @__PURE__ */ a(M, { children: [hover ? /* @__PURE__ */ a("div", {
2809
+ "data-isoloop-devtools-fab-away": "",
2810
+ onPointerMove: () => {
2811
+ setHover(false);
2812
+ },
2813
+ onPointerDown: () => {
2814
+ setHover(false);
2815
+ },
2816
+ style: "position:fixed;inset:0;pointer-events:auto;z-index:0;"
2817
+ }) : null, /* @__PURE__ */ a("div", {
2818
+ "data-isoloop-devtools-fab": "",
2819
+ onPointerMove: () => {
2820
+ if (!hover) setHover(true);
2821
+ },
2822
+ style: `${corner(props.position)}pointer-events:auto;z-index:1;width:${FAB_SIZE}px;height:${FAB_SIZE}px;`,
2823
+ children: [/* @__PURE__ */ a("button", {
2824
+ type: "button",
2825
+ "data-isoloop-devtools-toggle": "",
2826
+ "data-health": props.health,
2827
+ "aria-label": `Open Isoloop devtools (Alt+Shift+D)${props.summary ? `. ${props.summary}` : ""}`,
2828
+ title: `Isoloop devtools (Alt+Shift+D)${props.summary ? `\n${props.summary}` : ""}`,
2829
+ onClick: props.onOpen,
2830
+ style: `position:absolute;inset:0;display:flex;align-items:center;justify-content:center;border-radius:${FAB_SIZE / 2}px;border:0;background:#111827;box-shadow:0 0 0 3px rgb(0 0 0 / 0.35),0 4px 14px rgb(0 0 0 / 0.7);color:#e5e7eb;cursor:pointer;padding:0;overflow:hidden;${font}`,
2831
+ children: [/* @__PURE__ */ a("svg", {
2832
+ class: "dt-ring",
2833
+ width: FAB_SIZE,
2834
+ height: FAB_SIZE,
2835
+ viewBox: `0 0 ${FAB_SIZE} ${FAB_SIZE}`,
2836
+ "aria-hidden": "true",
2837
+ style: "position:absolute;inset:0;",
2838
+ children: props.status === "off" ? /* @__PURE__ */ a("circle", {
2839
+ cx: FAB_SIZE / 2,
2840
+ cy: FAB_SIZE / 2,
2841
+ r: FAB_SIZE / 2 - RING_WIDTH / 2,
2842
+ fill: "none",
2843
+ stroke: "#f8fafc",
2844
+ "stroke-width": RING_WIDTH
2845
+ }) : props.arcs.map((c, i) => /* @__PURE__ */ a("path", {
2846
+ "data-level": c.level,
2847
+ d: arcPath(i, FAB_SIZE / 2, FAB_SIZE / 2, FAB_SIZE / 2 - RING_WIDTH / 2),
2848
+ stroke: LEVEL_COLOR[c.level],
2849
+ "stroke-width": RING_WIDTH,
2850
+ "stroke-linecap": "butt",
2851
+ fill: "none",
2852
+ style: `animation-delay:-${(i / 12 * RING_PERIOD).toFixed(2)}s;`,
2853
+ children: /* @__PURE__ */ a("title", { children: c.label })
2854
+ }, c.id))
2855
+ }), props.status === "radar" ? /* @__PURE__ */ a("svg", {
2856
+ class: "dt-mark",
2857
+ width: FAB_MARK,
2858
+ height: FAB_MARK,
2859
+ viewBox: "0 0 100 100",
2860
+ "aria-hidden": "true",
2861
+ children: [/* @__PURE__ */ a("defs", { children: /* @__PURE__ */ a("clipPath", {
2862
+ id: "dt-mark-clip",
2863
+ children: /* @__PURE__ */ a("path", {
2864
+ d: MARK,
2865
+ "clip-rule": "evenodd"
2866
+ })
2867
+ }) }), /* @__PURE__ */ a("g", {
2868
+ "clip-path": "url(#dt-mark-clip)",
2869
+ children: props.arcs.map((c, i) => /* @__PURE__ */ a("path", {
2870
+ "data-level": c.level,
2871
+ d: wedgePath(i, 50, 50, 75),
2872
+ fill: LEVEL_COLOR[c.level],
2873
+ style: `animation-delay:-${(i / 12 * RING_PERIOD).toFixed(2)}s;`
2874
+ }, c.id))
2875
+ })]
2876
+ }) : /* @__PURE__ */ a("svg", {
2877
+ width: FAB_MARK,
2878
+ height: FAB_MARK,
2879
+ viewBox: "0 0 100 100",
2880
+ "aria-hidden": "true",
2881
+ children: /* @__PURE__ */ a("path", {
2882
+ d: MARK,
2883
+ fill: "#fff",
2884
+ "fill-rule": "evenodd"
2885
+ })
2886
+ })]
2887
+ }), hover ? /* @__PURE__ */ a(M, { children: [
2888
+ /* @__PURE__ */ a("span", { style: `position:absolute;left:${bridgeH}px;top:${mid}px;width:${ARROW_GAP}px;height:${ARROW}px;` }),
2889
+ /* @__PURE__ */ a("span", { style: `position:absolute;top:${bridgeV}px;left:${mid}px;width:${ARROW}px;height:${ARROW_GAP}px;` }),
2890
+ /* @__PURE__ */ a("button", {
2891
+ type: "button",
2892
+ "data-isoloop-devtools-move": "horizontal",
2893
+ "aria-label": `Move the button ${h === "left" ? "right" : "left"}`,
2894
+ title: `Move ${h === "left" ? "right" : "left"}`,
2895
+ onClick: () => {
2896
+ props.onMove(toH);
2897
+ },
2898
+ style: `${arrowStyle}top:${mid}px;left:${offH}px;`,
2899
+ children: /* @__PURE__ */ a(Icon, { d: chevH })
2900
+ }),
2901
+ /* @__PURE__ */ a("button", {
2902
+ type: "button",
2903
+ "data-isoloop-devtools-move": "vertical",
2904
+ "aria-label": `Move the button ${v === "top" ? "down" : "up"}`,
2905
+ title: `Move ${v === "top" ? "down" : "up"}`,
2906
+ onClick: () => {
2907
+ props.onMove(toV);
2908
+ },
2909
+ style: `${arrowStyle}top:${offV}px;left:${mid}px;`,
2910
+ children: /* @__PURE__ */ a(Icon, { d: chevV })
2911
+ })
2912
+ ] }) : null]
2913
+ })] });
2914
+ }
2915
+ /** A toolbar button: the same 26 px square, its icon centered. */
2916
+ const tool = (active) => `display:inline-flex;align-items:center;justify-content:center;width:26px;height:26px;box-sizing:border-box;background:${active ? "#374151" : "none"};border:0;border-radius:4px;color:inherit;cursor:pointer;padding:0;`;
2917
+ const Icon = (props) => /* @__PURE__ */ a("svg", {
2918
+ width: "14",
2919
+ height: "14",
2920
+ viewBox: "0 0 14 14",
2921
+ "aria-hidden": "true",
2922
+ style: "display:block;",
2923
+ children: /* @__PURE__ */ a("path", {
2924
+ d: props.d,
2925
+ fill: "none",
2926
+ stroke: "currentColor",
2927
+ "stroke-width": "1.5",
2928
+ "stroke-linecap": "round",
2929
+ "stroke-linejoin": "round"
2930
+ })
2931
+ });
2932
+ function Dock(props) {
2933
+ const { ui } = props;
2934
+ const [v, h] = ui.position.split("-");
2935
+ const [drag, setDrag] = d(void 0);
2936
+ const sx = h === "right" ? 1 : -1;
2937
+ const sy = v === "bottom" ? 1 : -1;
2938
+ const sizeAt = (d, x, y) => [d.axis === "y" ? d.width : Math.max(280, Math.round(d.width + (d.x - x) * sx)), d.axis === "x" ? d.height : Math.max(160, Math.round(d.height + (d.y - y) * sy))];
2939
+ const handleV = v === "bottom" ? "top" : "bottom";
2940
+ const handleH = h === "right" ? "left" : "right";
2941
+ const cornerCursor = sx === sy ? "nwse-resize" : "nesw-resize";
2942
+ const cursor = drag?.axis === "x" ? "ew-resize" : drag?.axis === "y" ? "ns-resize" : cornerCursor;
2943
+ const start = (axis, e) => {
2944
+ setDrag({
2945
+ x: e.clientX,
2946
+ y: e.clientY,
2947
+ width: ui.width,
2948
+ height: ui.height,
2949
+ axis
2950
+ });
2951
+ };
2952
+ return /* @__PURE__ */ a("div", {
2953
+ "data-isoloop-devtools-panel": "",
2954
+ role: "dialog",
2955
+ "aria-label": "Isoloop devtools",
2956
+ onKeyDown: (e) => {
2957
+ if (e.key === "Escape") props.onClose();
2958
+ },
2959
+ style: `${corner(ui.position, DOCK_GAP)}${fill(ui)}pointer-events:auto;box-sizing:border-box;display:flex;flex-direction:column;border:1px solid #374151;border-radius:8px;background:#111827;color:#e5e7eb;box-shadow:0 4px 16px rgb(0 0 0 / 0.35);overflow:hidden;${font}`,
2960
+ children: [
2961
+ /* @__PURE__ */ a("div", {
2962
+ style: "display:flex;align-items:center;gap:4px;padding:6px 12px;border-bottom:1px solid #374151;",
2963
+ children: [
2964
+ /* @__PURE__ */ a("strong", {
2965
+ style: "flex:1;",
2966
+ children: "Isoloop devtools"
2967
+ }),
2968
+ /* @__PURE__ */ a("button", {
2969
+ type: "button",
2970
+ "data-isoloop-devtools-stretch": "",
2971
+ "aria-label": "Stretch across the window's width",
2972
+ "aria-pressed": ui.mode === "wide",
2973
+ title: ui.mode === "wide" ? "Restore width" : "Stretch across the width",
2974
+ onClick: () => {
2975
+ props.onMode(ui.mode === "wide" ? "normal" : "wide");
2976
+ },
2977
+ style: tool(ui.mode === "wide"),
2978
+ children: /* @__PURE__ */ a(Icon, { d: "M1.5 7h11M4 4.5 1.5 7 4 9.5M10 4.5 12.5 7 10 9.5" })
2979
+ }),
2980
+ /* @__PURE__ */ a("button", {
2981
+ type: "button",
2982
+ "data-isoloop-devtools-maximize": "",
2983
+ "aria-label": "Fill the window",
2984
+ "aria-pressed": ui.mode === "max",
2985
+ title: ui.mode === "max" ? "Restore size" : "Fill the window",
2986
+ onClick: () => {
2987
+ props.onMode(ui.mode === "max" ? "normal" : "max");
2988
+ },
2989
+ style: tool(ui.mode === "max"),
2990
+ children: /* @__PURE__ */ a(Icon, { d: "M2.5 2.5h9v9h-9z" })
2991
+ }),
2992
+ /* @__PURE__ */ a("button", {
2993
+ type: "button",
2994
+ "data-isoloop-devtools-toggle": "",
2995
+ "aria-label": "Close Isoloop devtools (Alt+Shift+D)",
2996
+ title: "Close (Alt+Shift+D)",
2997
+ onClick: props.onClose,
2998
+ style: tool(false),
2999
+ children: /* @__PURE__ */ a(Icon, { d: "M3 3l8 8M11 3l-8 8" })
3000
+ })
3001
+ ]
3002
+ }),
3003
+ /* @__PURE__ */ a("div", {
3004
+ style: "flex:1;min-height:0;display:flex;flex-direction:column;",
3005
+ children: /* @__PURE__ */ a(Body, {
3006
+ snap: props.snap,
3007
+ recorder: props.recorder
3008
+ })
3009
+ }),
3010
+ ui.mode === "max" ? null : /* @__PURE__ */ a("div", {
3011
+ "data-isoloop-devtools-resize-y": "",
3012
+ "aria-hidden": "true",
3013
+ onPointerDown: (e) => {
3014
+ start("y", e);
3015
+ },
3016
+ style: `position:absolute;${handleV}:0;left:0;right:0;height:5px;cursor:ns-resize;`
3017
+ }),
3018
+ ui.mode === "normal" ? /* @__PURE__ */ a(M, { children: [/* @__PURE__ */ a("div", {
3019
+ "data-isoloop-devtools-resize-x": "",
3020
+ "aria-hidden": "true",
3021
+ onPointerDown: (e) => {
3022
+ start("x", e);
3023
+ },
3024
+ style: `position:absolute;${handleH}:0;top:0;bottom:0;width:5px;cursor:ew-resize;`
3025
+ }), /* @__PURE__ */ a("div", {
3026
+ "data-isoloop-devtools-resize": "",
3027
+ "aria-hidden": "true",
3028
+ onPointerDown: (e) => {
3029
+ start("both", e);
3030
+ },
3031
+ style: `position:absolute;${handleV}:0;${handleH}:0;width:14px;height:14px;cursor:${cornerCursor};`
3032
+ })] }) : null,
3033
+ drag ? /* @__PURE__ */ a("div", {
3034
+ "data-isoloop-devtools-drag": "",
3035
+ onPointerMove: (e) => {
3036
+ const [w, ht] = sizeAt(drag, e.clientX, e.clientY);
3037
+ props.onResize(w, ht, false);
3038
+ },
3039
+ onPointerUp: (e) => {
3040
+ const [w, ht] = sizeAt(drag, e.clientX, e.clientY);
3041
+ setDrag(void 0);
3042
+ props.onResize(w, ht, true);
3043
+ },
3044
+ style: `position:fixed;inset:0;pointer-events:auto;cursor:${cursor};`
3045
+ }) : null
3046
+ ]
3047
+ });
3048
+ }
3049
+ function Panel({ config }) {
3050
+ const ctx = useIsolate();
3051
+ const status = configStatus(config);
3052
+ A(() => {
3053
+ ctx.styles(RING_CSS);
3054
+ }, []);
3055
+ const snap = useFeed(ctx.inspector);
3056
+ const [recorder] = d(createRecorder);
3057
+ A(() => ctx.inspector ? recorder.start(ctx.inspector) : void 0, [ctx.inspector]);
3058
+ const [ui, setUi] = d(void 0);
3059
+ const latest = T(void 0);
3060
+ latest.current = ui;
3061
+ A(() => {
3062
+ let alive = true;
3063
+ loadUi().then((stored) => {
3064
+ if (!alive) return;
3065
+ setUi({
3066
+ open: false,
3067
+ width: 420,
3068
+ height: 320,
3069
+ position: configPosition(config),
3070
+ mode: "normal",
3071
+ ...stored
3072
+ });
3073
+ });
3074
+ return () => {
3075
+ alive = false;
3076
+ };
3077
+ }, []);
3078
+ if (!ui) return null;
3079
+ const update = (patch, persist = true) => {
3080
+ const next = {
3081
+ ...latest.current ?? ui,
3082
+ ...patch
3083
+ };
3084
+ latest.current = next;
3085
+ setUi(next);
3086
+ if (persist) saveUi(next);
3087
+ };
3088
+ if (!ui.open) return /* @__PURE__ */ a(Fab, {
3089
+ position: ui.position,
3090
+ health: healthOf(snap),
3091
+ arcs: status === "off" ? [] : arcsOf(snap),
3092
+ summary: status === "off" ? "" : summaryOf(arcsOf(snap), checksOf(snap)),
3093
+ status,
3094
+ onOpen: () => {
3095
+ update({ open: true });
3096
+ },
3097
+ onMove: (position) => {
3098
+ update({ position });
3099
+ }
3100
+ });
3101
+ return /* @__PURE__ */ a(Dock, {
3102
+ ui,
3103
+ snap,
3104
+ recorder,
3105
+ onClose: () => {
3106
+ update({ open: false });
3107
+ },
3108
+ onMode: (mode) => {
3109
+ update({ mode });
3110
+ },
3111
+ onResize: (width, height, done) => {
3112
+ update({
3113
+ width,
3114
+ height
3115
+ }, done);
3116
+ }
3117
+ });
3118
+ }
3119
+ const panel = defineIsolate(Panel);
3120
+ export { MIN_HEIGHT, MIN_WIDTH, panel as default, stepPosition };