@voltro/devtools 0.1.0

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/index.js ADDED
@@ -0,0 +1,1911 @@
1
+ import { createContext as e, useCallback as t, useContext as n, useEffect as r, useId as i, useMemo as a, useRef as o, useState as s, useSyncExternalStore as c } from "react";
2
+ import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
3
+ import { clearMutations as f, getMutations as p, subscribeMutations as m, useFrameworkRuntimes as h } from "@voltro/client";
4
+ import { getRouteSnapshot as g, getStatuses as _, subscribeRouteSnapshot as ee, subscribeStatuses as v } from "@voltro/web";
5
+ import { addSink as y } from "@voltro/logger";
6
+ //#region src/usePosition.ts
7
+ var b = [
8
+ "topLeft",
9
+ "topMid",
10
+ "topRight",
11
+ "midLeft",
12
+ "midRight",
13
+ "bottomLeft",
14
+ "bottomMid",
15
+ "bottomRight"
16
+ ], x = "voltro:devtools:anchor", te = (e) => {
17
+ if (typeof window > "u") return e;
18
+ try {
19
+ let e = window.localStorage.getItem(x);
20
+ if (e && b.includes(e)) return e;
21
+ } catch {}
22
+ return e;
23
+ }, ne = (e) => {
24
+ if (!(typeof window > "u")) try {
25
+ window.localStorage.setItem(x, e);
26
+ } catch {}
27
+ }, re = (e = "bottomLeft") => {
28
+ let [n, i] = s(() => te(e));
29
+ return r(() => {
30
+ if (typeof window > "u") return;
31
+ let e = (e) => {
32
+ e.key !== x || !e.newValue || b.includes(e.newValue) && i(e.newValue);
33
+ };
34
+ return window.addEventListener("storage", e), () => window.removeEventListener("storage", e);
35
+ }, []), [n, t((e) => {
36
+ i(e), ne(e);
37
+ }, [])];
38
+ }, ie = (e) => {
39
+ switch (e) {
40
+ case "topLeft": return {
41
+ top: 24,
42
+ left: 24
43
+ };
44
+ case "topMid": return {
45
+ top: 24,
46
+ left: "50%",
47
+ transform: "translateX(-50%)"
48
+ };
49
+ case "topRight": return {
50
+ top: 24,
51
+ right: 24
52
+ };
53
+ case "midLeft": return {
54
+ top: "50%",
55
+ left: 24,
56
+ transform: "translateY(-50%)"
57
+ };
58
+ case "midRight": return {
59
+ top: "50%",
60
+ right: 24,
61
+ transform: "translateY(-50%)"
62
+ };
63
+ case "bottomLeft": return {
64
+ bottom: 24,
65
+ left: 24
66
+ };
67
+ case "bottomMid": return {
68
+ bottom: 24,
69
+ left: "50%",
70
+ transform: "translateX(-50%)"
71
+ };
72
+ case "bottomRight": return {
73
+ bottom: 24,
74
+ right: 24
75
+ };
76
+ }
77
+ }, ae = ({ onClick: e, title: t, active: n, children: r, className: i }) => /* @__PURE__ */ u("button", {
78
+ onClick: e,
79
+ title: t,
80
+ className: [
81
+ "vdt:inline-flex vdt:items-center vdt:justify-center",
82
+ "vdt:w-7 vdt:h-7 vdt:rounded-md vdt:transition-colors",
83
+ n ? "vdt:bg-accent vdt:text-accent-foreground" : "vdt:text-foreground-muted hover:vdt:bg-muted hover:vdt:text-foreground",
84
+ i ?? ""
85
+ ].join(" "),
86
+ children: r
87
+ }), oe = ({ children: e, className: t }) => {
88
+ let n = o(null);
89
+ return r(() => {
90
+ let e = n.current;
91
+ if (e === null) return;
92
+ let t = (t) => {
93
+ if (e.scrollWidth <= e.clientWidth) return;
94
+ let n = t.deltaY + t.deltaX;
95
+ n !== 0 && (t.preventDefault(), e.scrollLeft += n);
96
+ };
97
+ return e.addEventListener("wheel", t, { passive: !1 }), () => e.removeEventListener("wheel", t);
98
+ }, []), /* @__PURE__ */ u("div", {
99
+ ref: n,
100
+ role: "tablist",
101
+ className: [
102
+ "vdt-tablist",
103
+ "vdt:flex vdt:items-center vdt:gap-0.5 vdt:border-b vdt:border-border",
104
+ "vdt:px-2 vdt:bg-card",
105
+ "vdt:overflow-x-auto vdt:flex-nowrap",
106
+ t ?? ""
107
+ ].join(" "),
108
+ children: e
109
+ });
110
+ }, S = ({ active: e, onClick: t, badge: n, children: r }) => /* @__PURE__ */ d("button", {
111
+ role: "tab",
112
+ "aria-selected": e,
113
+ onClick: t,
114
+ className: [
115
+ "vdt:relative vdt:flex vdt:items-center vdt:gap-1.5 vdt:px-3 vdt:py-2",
116
+ "vdt:text-xs vdt:font-medium vdt:transition-colors",
117
+ "vdt:border-b-2 vdt:shrink-0 vdt:whitespace-nowrap",
118
+ e ? "vdt:text-foreground vdt:border-accent" : "vdt:text-foreground-muted vdt:border-transparent hover:vdt:text-foreground"
119
+ ].join(" "),
120
+ children: [/* @__PURE__ */ u("span", { children: r }), typeof n == "number" && n > 0 ? /* @__PURE__ */ u("span", {
121
+ className: [
122
+ "vdt:inline-flex vdt:items-center vdt:justify-center",
123
+ "vdt:min-w-4 vdt:h-4 vdt:px-1 vdt:rounded-full",
124
+ "vdt:text-[10px] vdt:font-semibold",
125
+ e ? "vdt:bg-accent vdt:text-accent-foreground" : "vdt:bg-muted vdt:text-foreground-muted"
126
+ ].join(" "),
127
+ children: n
128
+ }) : null]
129
+ }), se = {
130
+ neutral: "vdt:bg-muted vdt:text-foreground-muted vdt:border vdt:border-border",
131
+ success: "vdt:bg-success/15 vdt:text-success vdt:border vdt:border-success/30",
132
+ warning: "vdt:bg-warning/15 vdt:text-warning vdt:border vdt:border-warning/30",
133
+ danger: "vdt:bg-danger/15 vdt:text-danger vdt:border vdt:border-danger/30",
134
+ info: "vdt:bg-info/15 vdt:text-info vdt:border vdt:border-info/30",
135
+ accent: "vdt:bg-accent/15 vdt:text-accent vdt:border vdt:border-accent/30"
136
+ }, C = ({ tone: e = "neutral", children: t, className: n }) => /* @__PURE__ */ u("span", {
137
+ className: [
138
+ "vdt:inline-flex vdt:items-center vdt:gap-1 vdt:px-1.5 vdt:py-0.5",
139
+ "vdt:rounded-sm vdt:text-[10px] vdt:font-medium vdt:uppercase vdt:tracking-wider",
140
+ se[e],
141
+ n ?? ""
142
+ ].join(" "),
143
+ children: t
144
+ }), w = ({ children: e, className: t }) => /* @__PURE__ */ u("div", {
145
+ className: ["vdt:bg-background-elevated vdt:border vdt:border-border vdt:rounded-md", t ?? ""].join(" "),
146
+ children: e
147
+ }), T = ({ children: e, right: t, Icon: n }) => /* @__PURE__ */ d("div", {
148
+ className: "vdt:flex vdt:items-center vdt:justify-between vdt:px-3 vdt:py-2 vdt:border-b vdt:border-border",
149
+ children: [/* @__PURE__ */ d("div", {
150
+ className: "vdt:flex vdt:items-center vdt:gap-1.5",
151
+ children: [n ? /* @__PURE__ */ u(n, { className: "vdt:w-3 vdt:h-3 vdt:text-foreground-muted" }) : null, /* @__PURE__ */ u("span", {
152
+ className: "vdt:text-[10px] vdt:font-semibold vdt:uppercase vdt:tracking-wider vdt:text-foreground-muted",
153
+ children: e
154
+ })]
155
+ }), t ?? null]
156
+ }), E = ({ entries: e }) => /* @__PURE__ */ u("dl", {
157
+ className: "vdt:grid vdt:grid-cols-[auto_1fr] vdt:gap-x-3 vdt:gap-y-1 vdt:px-3 vdt:py-2 vdt:text-xs",
158
+ children: e.map((e) => /* @__PURE__ */ d("div", {
159
+ className: "vdt:contents",
160
+ children: [/* @__PURE__ */ u("dt", {
161
+ className: "vdt:text-foreground-muted vdt:font-medium",
162
+ children: e.key
163
+ }), /* @__PURE__ */ u("dd", {
164
+ className: "vdt:font-mono vdt:text-foreground vdt:break-all",
165
+ children: e.value
166
+ })]
167
+ }, e.key))
168
+ }), D = ({ children: e }) => /* @__PURE__ */ u("div", {
169
+ className: "vdt:flex vdt:items-center vdt:justify-center vdt:py-12 vdt:px-6 vdt:text-center",
170
+ children: /* @__PURE__ */ u("div", {
171
+ className: "vdt:text-xs vdt:text-foreground-subtle vdt:max-w-xs",
172
+ children: e
173
+ })
174
+ }), O = (e) => ({ className: t }) => /* @__PURE__ */ u("svg", {
175
+ viewBox: "0 0 24 24",
176
+ fill: "none",
177
+ stroke: "currentColor",
178
+ strokeWidth: "1.6",
179
+ strokeLinecap: "round",
180
+ strokeLinejoin: "round",
181
+ className: t,
182
+ "aria-hidden": "true",
183
+ children: e
184
+ }), ce = ({ className: e }) => {
185
+ let t = i(), n = `vdtBoltFront-${t}`, r = `vdtBoltBack-${t}`;
186
+ return /* @__PURE__ */ d("svg", {
187
+ viewBox: "0 0 48 48",
188
+ fill: "none",
189
+ className: e,
190
+ "aria-hidden": "true",
191
+ children: [
192
+ /* @__PURE__ */ d("defs", { children: [/* @__PURE__ */ d("linearGradient", {
193
+ id: n,
194
+ x1: "13",
195
+ y1: "5",
196
+ x2: "33",
197
+ y2: "43",
198
+ gradientUnits: "userSpaceOnUse",
199
+ children: [/* @__PURE__ */ u("stop", { stopColor: "#C4A6FF" }), /* @__PURE__ */ u("stop", {
200
+ offset: "1",
201
+ stopColor: "#9D5BFF"
202
+ })]
203
+ }), /* @__PURE__ */ d("linearGradient", {
204
+ id: r,
205
+ x1: "22",
206
+ y1: "5",
207
+ x2: "35",
208
+ y2: "43",
209
+ gradientUnits: "userSpaceOnUse",
210
+ children: [/* @__PURE__ */ u("stop", { stopColor: "#9D5BFF" }), /* @__PURE__ */ u("stop", {
211
+ offset: "1",
212
+ stopColor: "#7C3AED"
213
+ })]
214
+ })] }),
215
+ /* @__PURE__ */ u("path", {
216
+ d: "M28 5 13 27 22 26 20 43Z",
217
+ fill: `url(#${n})`
218
+ }),
219
+ /* @__PURE__ */ u("path", {
220
+ d: "M28 5 20 43 35 21 26 22Z",
221
+ fill: `url(#${r})`
222
+ })
223
+ ]
224
+ });
225
+ }, le = O(/* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u("line", {
226
+ x1: "18",
227
+ y1: "6",
228
+ x2: "6",
229
+ y2: "18"
230
+ }), /* @__PURE__ */ u("line", {
231
+ x1: "6",
232
+ y1: "6",
233
+ x2: "18",
234
+ y2: "18"
235
+ })] })), k = O(/* @__PURE__ */ u("polyline", { points: "22 12 18 12 15 21 9 3 6 12 2 12" })), ue = O(/* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u("circle", {
236
+ cx: "12",
237
+ cy: "12",
238
+ r: "10"
239
+ }), /* @__PURE__ */ u("polygon", { points: "16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76" })] })), de = O(/* @__PURE__ */ d(l, { children: [
240
+ /* @__PURE__ */ u("path", { d: "M12 22 v-5" }),
241
+ /* @__PURE__ */ u("path", { d: "M9 8 V2" }),
242
+ /* @__PURE__ */ u("path", { d: "M15 8 V2" }),
243
+ /* @__PURE__ */ u("path", { d: "M18 8 v4 a6 6 0 0 1 -12 0 V8 z" })
244
+ ] })), fe = O(/* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u("polyline", { points: "17 11 12 6 7 11" }), /* @__PURE__ */ u("polyline", { points: "17 17 12 22 7 17" })] })), pe = O(/* @__PURE__ */ u("polygon", { points: "22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3" })), A = O(/* @__PURE__ */ d(l, { children: [
245
+ /* @__PURE__ */ u("polyline", { points: "3 6 5 6 21 6" }),
246
+ /* @__PURE__ */ u("path", { d: "M19 6 l-1 14 c-.05 1.1 -.96 2 -2 2 H8 c-1.04 0 -1.95 -.9 -2 -2 L5 6" }),
247
+ /* @__PURE__ */ u("path", { d: "M10 11 v6" }),
248
+ /* @__PURE__ */ u("path", { d: "M14 11 v6" })
249
+ ] })), me = O(/* @__PURE__ */ d(l, { children: [
250
+ /* @__PURE__ */ u("path", { d: "M18 16.98 h-5.99 c-1.1 0 -1.95 .94 -2.48 1.9 A4 4 0 0 1 2 17 c0 -1.42 .76 -2.66 1.9 -3.34" }),
251
+ /* @__PURE__ */ u("path", { d: "M6 17 l3.13 -5.78 c.53 -.97 .43 -2.22 -.26 -3.07 A4 4 0 1 1 17 7" }),
252
+ /* @__PURE__ */ u("path", { d: "M16 6.78 a4 4 0 1 1 5 6.31 c-.84 .6 -1.36 1.59 -1.36 2.61" })
253
+ ] })), he = O(/* @__PURE__ */ d(l, { children: [
254
+ /* @__PURE__ */ u("line", {
255
+ x1: "6",
256
+ y1: "3",
257
+ x2: "6",
258
+ y2: "15"
259
+ }),
260
+ /* @__PURE__ */ u("circle", {
261
+ cx: "18",
262
+ cy: "6",
263
+ r: "3"
264
+ }),
265
+ /* @__PURE__ */ u("circle", {
266
+ cx: "6",
267
+ cy: "18",
268
+ r: "3"
269
+ }),
270
+ /* @__PURE__ */ u("path", { d: "M18 9 a9 9 0 0 1 -9 9" })
271
+ ] })), ge = ({ className: e }) => /* @__PURE__ */ d("svg", {
272
+ viewBox: "0 0 24 24",
273
+ fill: "none",
274
+ className: e,
275
+ "aria-hidden": "true",
276
+ children: [/* @__PURE__ */ u("circle", {
277
+ cx: "12",
278
+ cy: "12",
279
+ r: "9",
280
+ stroke: "currentColor",
281
+ strokeOpacity: "0.2",
282
+ strokeWidth: "2.5"
283
+ }), /* @__PURE__ */ u("path", {
284
+ d: "M21 12 a9 9 0 0 0 -9 -9",
285
+ stroke: "currentColor",
286
+ strokeWidth: "2.5",
287
+ strokeLinecap: "round"
288
+ })]
289
+ }), _e = [
290
+ "topLeft",
291
+ "topMid",
292
+ "topRight",
293
+ "midLeft",
294
+ null,
295
+ "midRight",
296
+ "bottomLeft",
297
+ "bottomMid",
298
+ "bottomRight"
299
+ ], ve = ({ anchor: e, onChange: t }) => /* @__PURE__ */ u("div", {
300
+ role: "radiogroup",
301
+ "aria-label": "Devtools position",
302
+ className: "vdt:grid vdt:grid-cols-3 vdt:gap-0.5 vdt:p-1 vdt:bg-muted vdt:rounded-md",
303
+ children: _e.map((n, r) => {
304
+ if (n === null) return /* @__PURE__ */ u("div", {
305
+ "aria-hidden": "true",
306
+ className: "vdt:w-3 vdt:h-3 vdt:rounded-sm vdt:bg-transparent"
307
+ }, r);
308
+ let i = n === e;
309
+ return /* @__PURE__ */ u("button", {
310
+ role: "radio",
311
+ "aria-checked": i,
312
+ "aria-label": n,
313
+ title: n,
314
+ onClick: () => t(n),
315
+ className: ["vdt:w-3 vdt:h-3 vdt:rounded-sm vdt:transition-colors", i ? "vdt:bg-accent" : "vdt:bg-border hover:vdt:bg-border-strong"].join(" ")
316
+ }, n);
317
+ })
318
+ }), ye = 500, j = (e) => {
319
+ let t = "";
320
+ for (let n of e) t += `${n.key}|${n.subscriberCount}|${n.snapshot.revision}|${n.snapshot.pendingPatches}|${n.snapshot.error ? "1" : "0"}|${n.hasFiber ? "1" : "0"}|${n.evicting ? "1" : "0"};`;
321
+ return t;
322
+ }, be = (e) => {
323
+ let [t, n] = s(() => e ? e.peekAll() : []), i = o(j(t));
324
+ return r(() => {
325
+ if (!e) return;
326
+ let t = () => {
327
+ let t = e.peekAll(), r = j(t);
328
+ r !== i.current && (i.current = r, n(t));
329
+ }, r = setInterval(t, ye);
330
+ return t(), () => clearInterval(r);
331
+ }, [e]), t;
332
+ }, xe = {
333
+ shell: {
334
+ brand: "Voltro Devtools",
335
+ brandWord: "Voltro",
336
+ kicker: "Devtools",
337
+ openLabel: "Open Voltro Devtools",
338
+ openTitle: "Open Voltro Devtools (Alt+V)",
339
+ closeTitle: "Close (Alt+V)"
340
+ },
341
+ tabs: {
342
+ subscriptions: "Subs",
343
+ mutations: "Mutations",
344
+ indexes: "Indexes",
345
+ webhooks: "Webhooks",
346
+ traces: "Traces",
347
+ routes: "Routes",
348
+ runtimes: "Runtimes",
349
+ logs: "Logs"
350
+ },
351
+ subscriptions: {
352
+ emptyTitle: "No active subscriptions.",
353
+ emptyHint: "Mount a `useSubscription` hook to see live cache state here."
354
+ },
355
+ indexes: {
356
+ noApis: "No APIs mounted in this app.",
357
+ unreachableTitle: "Couldn't reach any api's `/_voltro/inspect/subscriptions` endpoint.",
358
+ unreachableHint: "Is `voltro dev` running? Inspect endpoints are open in dev mode and gated by `VOLTRO_INSPECT_TOKEN` in production.",
359
+ offline: "offline",
360
+ tables: "Tables",
361
+ subscriptionsSection: "Subscriptions",
362
+ subsBadge: (e) => `${e} subs`,
363
+ live: "live",
364
+ poll: "poll",
365
+ via: "via",
366
+ clients: (e) => e === 1 ? "client" : "clients"
367
+ },
368
+ webhooks: {
369
+ empty: "No api processes connected — webhooks discover from `*.webhook.tsx`.",
370
+ outgoing: (e) => `Outgoing events (${e})`,
371
+ incoming: (e) => `Incoming routes (${e})`,
372
+ targets: (e) => `Active targets (${e})`,
373
+ deliveries: (e) => `Recent deliveries (${e})`,
374
+ signed: "signed",
375
+ unsigned: "unsigned",
376
+ active: "active",
377
+ paused: "paused",
378
+ attempt: (e) => `attempt ${e}`
379
+ },
380
+ mutations: {
381
+ emptyTitle: "No mutations yet.",
382
+ emptyHint: "Calling `mutate(input)` from any `useMutation()` hook will land a row here. Newest-first; capped at 100 entries.",
383
+ clearTitle: "Clear mutation history",
384
+ clear: "Clear",
385
+ recent: (e) => `Recent (${e})`
386
+ },
387
+ logs: {
388
+ filters: "Filters",
389
+ clearTitle: "Clear log history",
390
+ clear: "Clear",
391
+ searchPlaceholder: "Filter messages, scope, fields…",
392
+ emptyNone: "No log records yet.",
393
+ emptyNoMatch: "No records match the current filters.",
394
+ emptyHint: "Every `createLogger().info(...)` / `Effect.log*` call lands here (capped at 500, newest-first).",
395
+ tail: "Tail"
396
+ },
397
+ routes: {
398
+ currentRoute: "Current Route",
399
+ loaderData: "Loader Data",
400
+ collapse: "collapse",
401
+ expand: "expand",
402
+ noLoaderTitle: "No loader data for this route.",
403
+ noLoaderHint: (e) => /* @__PURE__ */ d(l, { children: [
404
+ "Pages with an exported `loader` see their resolved data here. UI-only apps (no ",
405
+ e,
406
+ ") don't surface loader state at all."
407
+ ] })
408
+ },
409
+ runtimes: {
410
+ emptyTitle: "No APIs mounted in this app.",
411
+ emptyHint: "UI-only apps (no `apis` in app.config.ts) don't open any runtimes.",
412
+ live: "live"
413
+ },
414
+ traces: {
415
+ noApi: "No API connected. Traces appear once a `useMutation` / `useSubscription` call runs.",
416
+ noneCaptured: (e) => `${e} — no traces captured yet. Trigger an action.`,
417
+ proxiedTitle: "Traces aren't fetchable from this browser — the API is reached over a proxied socket, so there's no direct inspect origin for this panel.",
418
+ proxiedHint: (e) => /* @__PURE__ */ d(l, { children: [
419
+ "They're still recorded server-side. Use ",
420
+ e,
421
+ " or open the app's",
422
+ " ",
423
+ "Traces page in the cloud dashboard."
424
+ ] }),
425
+ ok: "ok",
426
+ error: "error",
427
+ sub: "sub",
428
+ delivery: (e) => e === 1 ? "delivery" : "deliveries",
429
+ spans: (e) => `${e} spans`
430
+ }
431
+ }, M = e(xe), Se = (e, t) => ({
432
+ shell: {
433
+ ...e.shell,
434
+ ...t.shell
435
+ },
436
+ tabs: {
437
+ ...e.tabs,
438
+ ...t.tabs
439
+ },
440
+ subscriptions: {
441
+ ...e.subscriptions,
442
+ ...t.subscriptions
443
+ },
444
+ indexes: {
445
+ ...e.indexes,
446
+ ...t.indexes
447
+ },
448
+ webhooks: {
449
+ ...e.webhooks,
450
+ ...t.webhooks
451
+ },
452
+ mutations: {
453
+ ...e.mutations,
454
+ ...t.mutations
455
+ },
456
+ logs: {
457
+ ...e.logs,
458
+ ...t.logs
459
+ },
460
+ routes: {
461
+ ...e.routes,
462
+ ...t.routes
463
+ },
464
+ runtimes: {
465
+ ...e.runtimes,
466
+ ...t.runtimes
467
+ },
468
+ traces: {
469
+ ...e.traces,
470
+ ...t.traces
471
+ }
472
+ });
473
+ function Ce(e) {
474
+ let t = n(M), r = a(() => Se(t, e.strings), [t, e.strings]);
475
+ return /* @__PURE__ */ u(M.Provider, {
476
+ value: r,
477
+ children: e.children
478
+ });
479
+ }
480
+ var N = (e) => {
481
+ let t = n(M);
482
+ return a(() => e ? Se(t, e) : t, [t, e]);
483
+ }, we = () => {
484
+ let e = h();
485
+ return e.names.map((t) => ({
486
+ name: t,
487
+ entries: e.get(t).cache.peekAll()
488
+ }));
489
+ }, Te = () => {
490
+ let e = h();
491
+ return be((e.names[0] ? e.get(e.names[0]) : null)?.cache ?? null), we();
492
+ }, Ee = (e) => {
493
+ let { snapshot: t, hasFiber: n, evicting: r } = e;
494
+ return t.error ? "danger" : t.pendingPatches > 0 ? "warning" : t.revision >= 0 ? "success" : r ? "neutral" : n ? "info" : "neutral";
495
+ }, De = ({ tone: e }) => /* @__PURE__ */ u("span", {
496
+ "aria-hidden": "true",
497
+ className: ["vdt:inline-block vdt:w-2 vdt:h-2 vdt:rounded-full", e === "success" ? "vdt:bg-success" : e === "info" ? "vdt:bg-info" : e === "danger" ? "vdt:bg-danger" : e === "warning" ? "vdt:bg-warning" : "vdt:bg-foreground-subtle"].join(" ")
498
+ }), Oe = (e) => {
499
+ try {
500
+ let t = JSON.parse(e);
501
+ if (Array.isArray(t)) {
502
+ let [e, ...n] = t;
503
+ return n.length === 0 || n.length === 1 && (n[0] === void 0 || JSON.stringify(n[0]) === "{}") ? String(e) : `${String(e)}(${n.map((e) => JSON.stringify(e)).join(", ")})`;
504
+ }
505
+ } catch {}
506
+ return e;
507
+ }, ke = ({ entry: e, expanded: t, onToggle: n }) => /* @__PURE__ */ d("div", {
508
+ className: "vdt:border-b last:vdt:border-b-0 vdt:border-border",
509
+ children: [/* @__PURE__ */ d("button", {
510
+ onClick: n,
511
+ className: "vdt:w-full vdt:flex vdt:items-center vdt:gap-2 vdt:px-3 vdt:py-1.5 hover:vdt:bg-muted/40 vdt:transition-colors",
512
+ children: [
513
+ /* @__PURE__ */ u(De, { tone: Ee(e) }),
514
+ /* @__PURE__ */ u("span", {
515
+ className: "vdt:flex-1 vdt:text-xs vdt:font-mono vdt:truncate vdt:text-left vdt:text-foreground",
516
+ children: Oe(e.key)
517
+ }),
518
+ e.snapshot.pendingPatches > 0 ? /* @__PURE__ */ d(C, {
519
+ tone: "warning",
520
+ children: ["+", e.snapshot.pendingPatches]
521
+ }) : null,
522
+ e.subscriberCount > 0 ? /* @__PURE__ */ u(C, {
523
+ tone: "neutral",
524
+ children: e.subscriberCount
525
+ }) : null,
526
+ e.snapshot.revision >= 0 ? /* @__PURE__ */ d("span", {
527
+ className: "vdt:text-[10px] vdt:text-foreground-subtle vdt:font-mono",
528
+ children: ["r", e.snapshot.revision]
529
+ }) : null
530
+ ]
531
+ }), t ? /* @__PURE__ */ d("div", {
532
+ className: "vdt:bg-background/60 vdt:border-t vdt:border-border",
533
+ children: [/* @__PURE__ */ u(E, { entries: [
534
+ {
535
+ key: "tag",
536
+ value: e.tag ?? "—"
537
+ },
538
+ {
539
+ key: "source",
540
+ value: e.source ?? "—"
541
+ },
542
+ {
543
+ key: "subscribers",
544
+ value: String(e.subscriberCount)
545
+ },
546
+ {
547
+ key: "fiber",
548
+ value: e.hasFiber ? "running" : e.evicting ? "evicting" : "idle"
549
+ },
550
+ {
551
+ key: "revision",
552
+ value: e.snapshot.revision >= 0 ? String(e.snapshot.revision) : "—"
553
+ },
554
+ {
555
+ key: "emittedAt",
556
+ value: e.snapshot.emittedAt ? new Date(e.snapshot.emittedAt).toISOString() : "—"
557
+ },
558
+ {
559
+ key: "pendingPatches",
560
+ value: String(e.snapshot.pendingPatches)
561
+ },
562
+ {
563
+ key: "error",
564
+ value: e.snapshot.error ? String(e.snapshot.error) : "—"
565
+ }
566
+ ] }), /* @__PURE__ */ d("details", {
567
+ className: "vdt:px-3 vdt:py-2 vdt:border-t vdt:border-border",
568
+ children: [/* @__PURE__ */ u("summary", {
569
+ className: "vdt:text-[10px] vdt:uppercase vdt:tracking-wider vdt:text-foreground-muted vdt:cursor-pointer",
570
+ children: "Data"
571
+ }), /* @__PURE__ */ u("pre", {
572
+ className: "vdt:mt-2 vdt:text-[11px] vdt:text-foreground vdt:max-h-64 vdt:overflow-auto vdt:font-mono",
573
+ children: (() => {
574
+ try {
575
+ return JSON.stringify(e.snapshot.data, null, 2);
576
+ } catch {
577
+ return String(e.snapshot.data);
578
+ }
579
+ })()
580
+ })]
581
+ })]
582
+ }) : null]
583
+ }), Ae = () => {
584
+ let e = Te(), t = N().subscriptions, [n, r] = s(null);
585
+ return e.reduce((e, t) => e + t.entries.length, 0) === 0 ? /* @__PURE__ */ d(D, { children: [t.emptyTitle, /* @__PURE__ */ u("div", {
586
+ className: "vdt:mt-1 vdt:text-foreground-subtle",
587
+ children: t.emptyHint
588
+ })] }) : /* @__PURE__ */ u("div", {
589
+ className: "vdt:flex vdt:flex-col vdt:gap-3 vdt:p-3",
590
+ children: e.map((e) => e.entries.length === 0 ? null : /* @__PURE__ */ d(w, { children: [/* @__PURE__ */ u(T, {
591
+ Icon: k,
592
+ right: /* @__PURE__ */ u(C, {
593
+ tone: "accent",
594
+ children: e.entries.length
595
+ }),
596
+ children: e.name
597
+ }), e.entries.map((t) => /* @__PURE__ */ u(ke, {
598
+ entry: t,
599
+ expanded: n === `${e.name}:${t.key}`,
600
+ onToggle: () => r((n) => n === `${e.name}:${t.key}` ? null : `${e.name}:${t.key}`)
601
+ }, t.key))] }, e.name))
602
+ });
603
+ }, je = () => Te().reduce((e, t) => e + t.entries.length, 0), Me = (e) => {
604
+ try {
605
+ return JSON.stringify(e, null, 2);
606
+ } catch {
607
+ return String(e);
608
+ }
609
+ }, Ne = () => c(ee, g, g), Pe = () => {
610
+ let [e, t] = s(() => typeof window > "u" ? "/" : window.location.pathname);
611
+ return r(() => {
612
+ if (typeof window > "u") return;
613
+ let e = () => t(window.location.pathname);
614
+ window.addEventListener("popstate", e);
615
+ let n = setInterval(e, 1e3);
616
+ return () => {
617
+ window.removeEventListener("popstate", e), clearInterval(n);
618
+ };
619
+ }, []), e;
620
+ }, Fe = () => {
621
+ let e = Ne(), t = Pe(), n = N().routes, [r, i] = s(!0), a = e.pathname === "/" && Object.keys(e.params).length === 0 && e.loaderData === void 0 && t !== "/" ? t : e.pathname, o = Object.entries(e.params).map(([e, t]) => ({
622
+ key: e,
623
+ value: String(t)
624
+ }));
625
+ return /* @__PURE__ */ d("div", {
626
+ className: "vdt:flex vdt:flex-col vdt:gap-3 vdt:p-3",
627
+ children: [/* @__PURE__ */ d(w, { children: [
628
+ /* @__PURE__ */ u(T, {
629
+ Icon: ue,
630
+ children: n.currentRoute
631
+ }),
632
+ /* @__PURE__ */ u(E, { entries: [{
633
+ key: "pathname",
634
+ value: a
635
+ }, {
636
+ key: "params",
637
+ value: o.length === 0 ? "—" : ""
638
+ }] }),
639
+ o.length > 0 ? /* @__PURE__ */ u("div", {
640
+ className: "vdt:px-3 vdt:pb-3",
641
+ children: /* @__PURE__ */ u(E, { entries: o })
642
+ }) : null
643
+ ] }), /* @__PURE__ */ d(w, { children: [
644
+ /* @__PURE__ */ u(T, {
645
+ Icon: ue,
646
+ children: n.loaderData
647
+ }),
648
+ /* @__PURE__ */ u("button", {
649
+ onClick: () => i((e) => !e),
650
+ className: "vdt:px-3 vdt:py-1.5 vdt:text-[10px] vdt:uppercase vdt:tracking-wider vdt:text-foreground-muted hover:vdt:text-foreground",
651
+ children: r ? n.collapse : n.expand
652
+ }),
653
+ r ? e.loaderData === void 0 ? /* @__PURE__ */ d(D, { children: [n.noLoaderTitle, /* @__PURE__ */ u("div", {
654
+ className: "vdt:mt-1 vdt:text-foreground-subtle",
655
+ children: n.noLoaderHint(/* @__PURE__ */ u("code", { children: "<Router>" }))
656
+ })] }) : /* @__PURE__ */ u("pre", {
657
+ className: "vdt:px-3 vdt:pb-3 vdt:text-[11px] vdt:max-h-80 vdt:overflow-auto vdt:font-mono vdt:text-foreground",
658
+ children: Me(e.loaderData)
659
+ }) : null
660
+ ] })]
661
+ });
662
+ }, Ie = (e) => {
663
+ let t = 0, n = 0, r = 0, i = 0, a = 0;
664
+ for (let o of Object.values(e)) o.kind === "query" && (t += 1), o.kind === "mutation" && (n += 1), o.kind === "action" && (r += 1), o.kind === "stream" && (i += 1), o.kind === "workflow" && (a += 1);
665
+ return {
666
+ queries: t,
667
+ mutations: n,
668
+ actions: r,
669
+ streams: i,
670
+ workflows: a
671
+ };
672
+ }, Le = () => {
673
+ let e = h(), t = N().runtimes, n = e.names;
674
+ return n.length === 0 ? /* @__PURE__ */ d(D, { children: [t.emptyTitle, /* @__PURE__ */ u("div", {
675
+ className: "vdt:mt-1 vdt:text-foreground-subtle",
676
+ children: t.emptyHint
677
+ })] }) : /* @__PURE__ */ u("div", {
678
+ className: "vdt:flex vdt:flex-col vdt:gap-3 vdt:p-3",
679
+ children: n.map((n) => {
680
+ let r = e.get(n), i = Ie(r.descriptors);
681
+ return /* @__PURE__ */ d(w, { children: [/* @__PURE__ */ u(T, {
682
+ Icon: de,
683
+ right: /* @__PURE__ */ u(C, {
684
+ tone: "success",
685
+ children: t.live
686
+ }),
687
+ children: n
688
+ }), /* @__PURE__ */ u(E, { entries: [
689
+ {
690
+ key: "queries",
691
+ value: String(i.queries)
692
+ },
693
+ {
694
+ key: "mutations",
695
+ value: String(i.mutations)
696
+ },
697
+ {
698
+ key: "actions",
699
+ value: String(i.actions)
700
+ },
701
+ {
702
+ key: "streams",
703
+ value: String(i.streams)
704
+ },
705
+ {
706
+ key: "workflows",
707
+ value: String(i.workflows)
708
+ },
709
+ {
710
+ key: "cacheSize",
711
+ value: String(r.cache.size())
712
+ },
713
+ {
714
+ key: "descriptors",
715
+ value: String(Object.keys(r.descriptors).length)
716
+ }
717
+ ] })] }, n);
718
+ })
719
+ });
720
+ }, Re = () => c(m, p, p), ze = (e) => typeof e == "number" ? e < 1 ? "<1ms" : e < 1e3 ? `${Math.round(e)}ms` : `${(e / 1e3).toFixed(1)}s` : "—", P = (e) => {
721
+ try {
722
+ return JSON.stringify(e, null, 2);
723
+ } catch {
724
+ return String(e);
725
+ }
726
+ }, Be = (e) => e === "pending" ? "info" : e === "success" ? "success" : "danger", Ve = ({ tone: e }) => /* @__PURE__ */ u("span", {
727
+ "aria-hidden": "true",
728
+ className: ["vdt:inline-block vdt:w-2 vdt:h-2 vdt:rounded-full", e === "success" ? "vdt:bg-success" : e === "danger" ? "vdt:bg-danger" : "vdt:bg-info"].join(" ")
729
+ }), He = ({ mutation: e, expanded: t, onToggle: n }) => {
730
+ let r = Be(e.status), i = new Date(e.startedAt).toISOString().slice(11, 23);
731
+ return /* @__PURE__ */ d("div", {
732
+ className: "vdt:border-b last:vdt:border-b-0 vdt:border-border",
733
+ children: [/* @__PURE__ */ d("button", {
734
+ onClick: n,
735
+ className: "vdt:w-full vdt:flex vdt:items-center vdt:gap-2 vdt:px-3 vdt:py-1.5 hover:vdt:bg-muted/40 vdt:transition-colors",
736
+ children: [
737
+ /* @__PURE__ */ u(Ve, { tone: r }),
738
+ /* @__PURE__ */ u("span", {
739
+ className: "vdt:text-[10px] vdt:text-foreground-subtle vdt:font-mono vdt:tabular-nums",
740
+ children: i
741
+ }),
742
+ /* @__PURE__ */ d("span", {
743
+ className: "vdt:flex-1 vdt:flex vdt:items-center vdt:gap-1.5 vdt:min-w-0 vdt:text-left",
744
+ children: [/* @__PURE__ */ u(C, {
745
+ tone: "accent",
746
+ children: e.apiName
747
+ }), /* @__PURE__ */ u("span", {
748
+ className: "vdt:text-xs vdt:font-mono vdt:text-foreground vdt:truncate",
749
+ children: e.tag
750
+ })]
751
+ }),
752
+ /* @__PURE__ */ u("span", {
753
+ className: "vdt:text-[10px] vdt:font-mono vdt:text-foreground-muted vdt:tabular-nums",
754
+ children: ze(e.durationMs)
755
+ })
756
+ ]
757
+ }), t ? /* @__PURE__ */ d("div", {
758
+ className: "vdt:bg-background/60 vdt:border-t vdt:border-border",
759
+ children: [
760
+ /* @__PURE__ */ u(E, { entries: [
761
+ {
762
+ key: "id",
763
+ value: e.id
764
+ },
765
+ {
766
+ key: "api",
767
+ value: e.apiName
768
+ },
769
+ {
770
+ key: "tag",
771
+ value: e.tag
772
+ },
773
+ {
774
+ key: "status",
775
+ value: e.status
776
+ },
777
+ {
778
+ key: "startedAt",
779
+ value: new Date(e.startedAt).toISOString()
780
+ },
781
+ {
782
+ key: "settledAt",
783
+ value: e.settledAt ? new Date(e.settledAt).toISOString() : "—"
784
+ },
785
+ {
786
+ key: "duration",
787
+ value: ze(e.durationMs)
788
+ }
789
+ ] }),
790
+ /* @__PURE__ */ d("details", {
791
+ className: "vdt:px-3 vdt:py-2 vdt:border-t vdt:border-border",
792
+ children: [/* @__PURE__ */ u("summary", {
793
+ className: "vdt:text-[10px] vdt:uppercase vdt:tracking-wider vdt:text-foreground-muted vdt:cursor-pointer",
794
+ children: "Input"
795
+ }), /* @__PURE__ */ u("pre", {
796
+ className: "vdt:mt-2 vdt:text-[11px] vdt:max-h-48 vdt:overflow-auto vdt:font-mono vdt:text-foreground",
797
+ children: P(e.input)
798
+ })]
799
+ }),
800
+ e.status === "success" ? /* @__PURE__ */ d("details", {
801
+ className: "vdt:px-3 vdt:py-2 vdt:border-t vdt:border-border",
802
+ children: [/* @__PURE__ */ u("summary", {
803
+ className: "vdt:text-[10px] vdt:uppercase vdt:tracking-wider vdt:text-foreground-muted vdt:cursor-pointer",
804
+ children: "Output"
805
+ }), /* @__PURE__ */ u("pre", {
806
+ className: "vdt:mt-2 vdt:text-[11px] vdt:max-h-48 vdt:overflow-auto vdt:font-mono vdt:text-foreground",
807
+ children: P(e.output)
808
+ })]
809
+ }) : null,
810
+ e.status === "error" ? /* @__PURE__ */ d("details", {
811
+ className: "vdt:px-3 vdt:py-2 vdt:border-t vdt:border-border",
812
+ open: !0,
813
+ children: [/* @__PURE__ */ u("summary", {
814
+ className: "vdt:text-[10px] vdt:uppercase vdt:tracking-wider vdt:text-danger vdt:cursor-pointer",
815
+ children: "Error"
816
+ }), /* @__PURE__ */ u("pre", {
817
+ className: "vdt:mt-2 vdt:text-[11px] vdt:max-h-48 vdt:overflow-auto vdt:font-mono vdt:text-danger",
818
+ children: e.error instanceof Error ? `${e.error.name}: ${e.error.message}\n\n${e.error.stack ?? ""}` : P(e.error)
819
+ })]
820
+ }) : null
821
+ ]
822
+ }) : null]
823
+ });
824
+ }, Ue = () => {
825
+ let e = Re(), t = N().mutations, [n, r] = s(null);
826
+ return e.length === 0 ? /* @__PURE__ */ d(D, { children: [t.emptyTitle, /* @__PURE__ */ u("div", {
827
+ className: "vdt:mt-1 vdt:text-foreground-subtle",
828
+ children: t.emptyHint
829
+ })] }) : /* @__PURE__ */ u("div", {
830
+ className: "vdt:flex vdt:flex-col vdt:gap-3 vdt:p-3",
831
+ children: /* @__PURE__ */ d(w, { children: [/* @__PURE__ */ u(T, {
832
+ Icon: fe,
833
+ right: /* @__PURE__ */ d("button", {
834
+ onClick: () => {
835
+ f(), r(null);
836
+ },
837
+ title: t.clearTitle,
838
+ className: "vdt:inline-flex vdt:items-center vdt:gap-1 vdt:px-1.5 vdt:py-0.5 vdt:rounded-sm vdt:text-[10px] vdt:uppercase vdt:tracking-wider vdt:text-foreground-muted hover:vdt:text-foreground hover:vdt:bg-muted/40 vdt:transition-colors",
839
+ children: [/* @__PURE__ */ u(A, { className: "vdt:w-3 vdt:h-3" }), t.clear]
840
+ }),
841
+ children: t.recent(e.length)
842
+ }), e.map((e) => /* @__PURE__ */ u(He, {
843
+ mutation: e,
844
+ expanded: n === e.id,
845
+ onToggle: () => r(n === e.id ? null : e.id)
846
+ }, e.id))] })
847
+ });
848
+ }, We = () => Re().length, F = 500, I = [], L = /* @__PURE__ */ new Set(), R = [], Ge = () => {
849
+ R = I.slice();
850
+ }, z = () => {
851
+ Ge();
852
+ for (let e of L) try {
853
+ e();
854
+ } catch {}
855
+ };
856
+ y(Ke);
857
+ function Ke(e) {
858
+ I.unshift(e), I.length > F && (I.length = F), z();
859
+ }
860
+ var B = () => R, qe = (e) => (L.add(e), () => {
861
+ L.delete(e);
862
+ }), Je = () => {
863
+ I.length !== 0 && (I.length = 0, z());
864
+ }, V = () => c(qe, B, B), H = [
865
+ "trace",
866
+ "debug",
867
+ "info",
868
+ "warn",
869
+ "error",
870
+ "fatal"
871
+ ], Ye = {
872
+ trace: "vdt:text-foreground-subtle",
873
+ debug: "vdt:text-info",
874
+ info: "vdt:text-foreground",
875
+ warn: "vdt:text-warning",
876
+ error: "vdt:text-danger",
877
+ fatal: "vdt:text-danger vdt:font-bold"
878
+ }, U = {
879
+ trace: "vdt:bg-foreground-subtle",
880
+ debug: "vdt:bg-info",
881
+ info: "vdt:bg-accent",
882
+ warn: "vdt:bg-warning",
883
+ error: "vdt:bg-danger",
884
+ fatal: "vdt:bg-danger"
885
+ }, W = (e) => {
886
+ if (Object.keys(e).length === 0) return "";
887
+ try {
888
+ return JSON.stringify(e, null, 2);
889
+ } catch {
890
+ return String(e);
891
+ }
892
+ }, Xe = (e) => {
893
+ let t = (e) => e < 10 ? `0${e}` : String(e);
894
+ return `${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}.${((e) => e < 100 ? e < 10 ? `00${e}` : `0${e}` : String(e))(e.getMilliseconds())}`;
895
+ }, Ze = ({ record: e, expanded: t, onToggle: n }) => {
896
+ let r = Object.keys(e.fields).length > 0 || e.cause !== void 0 || e.fiberId !== void 0, i = t ? W(e.fields) : "";
897
+ return /* @__PURE__ */ d("div", {
898
+ className: "vdt:border-b last:vdt:border-b-0 vdt:border-border",
899
+ children: [/* @__PURE__ */ d("button", {
900
+ onClick: n,
901
+ disabled: !r,
902
+ className: [
903
+ "vdt:w-full vdt:flex vdt:items-start vdt:gap-2 vdt:px-3 vdt:py-1 vdt:text-left",
904
+ "vdt:transition-colors",
905
+ r ? "hover:vdt:bg-muted/40 vdt:cursor-pointer" : "vdt:cursor-default"
906
+ ].join(" "),
907
+ children: [
908
+ /* @__PURE__ */ u("span", {
909
+ "aria-hidden": "true",
910
+ className: ["vdt:inline-block vdt:w-1 vdt:h-3.5 vdt:rounded-sm vdt:mt-1 vdt:flex-shrink-0", U[e.level]].join(" ")
911
+ }),
912
+ /* @__PURE__ */ u("span", {
913
+ className: "vdt:text-[10px] vdt:font-mono vdt:tabular-nums vdt:text-foreground-subtle vdt:flex-shrink-0 vdt:mt-0.5",
914
+ children: Xe(e.ts)
915
+ }),
916
+ e.scope ? /* @__PURE__ */ u("span", {
917
+ className: "vdt:text-[10px] vdt:font-mono vdt:text-foreground-muted vdt:flex-shrink-0 vdt:mt-0.5 vdt:truncate vdt:max-w-32",
918
+ children: e.scope
919
+ }) : null,
920
+ /* @__PURE__ */ u("span", {
921
+ className: ["vdt:flex-1 vdt:text-xs vdt:break-words", Ye[e.level]].join(" "),
922
+ children: e.message
923
+ })
924
+ ]
925
+ }), t && r ? /* @__PURE__ */ d("div", {
926
+ className: "vdt:bg-background/60 vdt:border-t vdt:border-border vdt:px-3 vdt:py-2 vdt:flex vdt:flex-col vdt:gap-2",
927
+ children: [
928
+ e.fiberId ? /* @__PURE__ */ d("div", {
929
+ className: "vdt:text-[10px] vdt:font-mono vdt:text-foreground-muted",
930
+ children: ["fiber: ", e.fiberId]
931
+ }) : null,
932
+ i ? /* @__PURE__ */ u("pre", {
933
+ className: "vdt:text-[11px] vdt:max-h-48 vdt:overflow-auto vdt:font-mono vdt:text-foreground",
934
+ children: i
935
+ }) : null,
936
+ e.cause === void 0 ? null : /* @__PURE__ */ u("pre", {
937
+ className: "vdt:text-[11px] vdt:max-h-48 vdt:overflow-auto vdt:font-mono vdt:text-danger",
938
+ children: e.cause instanceof Error ? `${e.cause.name}: ${e.cause.message}\n\n${e.cause.stack ?? ""}` : String(e.cause)
939
+ })
940
+ ]
941
+ }) : null]
942
+ });
943
+ }, Qe = () => {
944
+ let e = V(), t = N().logs, [n, r] = s(() => new Set(H)), [i, o] = s(""), [c, l] = s(null), f = (e) => {
945
+ r((t) => {
946
+ let n = new Set(t);
947
+ return n.has(e) ? n.delete(e) : n.add(e), n;
948
+ });
949
+ }, p = a(() => {
950
+ let t = i.trim().toLowerCase();
951
+ return e.filter((e) => n.has(e.level) ? t === "" || [
952
+ e.message,
953
+ e.scope ?? "",
954
+ W(e.fields)
955
+ ].join(" ").toLowerCase().includes(t) : !1);
956
+ }, [
957
+ e,
958
+ n,
959
+ i
960
+ ]);
961
+ return /* @__PURE__ */ d("div", {
962
+ className: "vdt:flex vdt:flex-col vdt:gap-3 vdt:p-3",
963
+ children: [/* @__PURE__ */ d(w, { children: [
964
+ /* @__PURE__ */ u(T, {
965
+ Icon: pe,
966
+ right: /* @__PURE__ */ d("button", {
967
+ onClick: () => {
968
+ Je(), l(null);
969
+ },
970
+ title: t.clearTitle,
971
+ className: "vdt:inline-flex vdt:items-center vdt:gap-1 vdt:px-1.5 vdt:py-0.5 vdt:rounded-sm vdt:text-[10px] vdt:uppercase vdt:tracking-wider vdt:text-foreground-muted hover:vdt:text-foreground hover:vdt:bg-muted/40 vdt:transition-colors",
972
+ children: [/* @__PURE__ */ u(A, { className: "vdt:w-3 vdt:h-3" }), t.clear]
973
+ }),
974
+ children: t.filters
975
+ }),
976
+ /* @__PURE__ */ u("div", {
977
+ className: "vdt:flex vdt:flex-wrap vdt:gap-1.5 vdt:px-3 vdt:py-2 vdt:border-b vdt:border-border",
978
+ children: H.map((e) => {
979
+ let t = n.has(e);
980
+ return /* @__PURE__ */ d("button", {
981
+ onClick: () => f(e),
982
+ "aria-pressed": t,
983
+ className: [
984
+ "vdt:inline-flex vdt:items-center vdt:gap-1 vdt:px-1.5 vdt:py-0.5",
985
+ "vdt:rounded-sm vdt:text-[10px] vdt:font-medium vdt:uppercase vdt:tracking-wider",
986
+ "vdt:border vdt:transition-colors",
987
+ t ? "vdt:bg-muted vdt:text-foreground vdt:border-border-strong" : "vdt:bg-transparent vdt:text-foreground-subtle vdt:border-border hover:vdt:text-foreground-muted"
988
+ ].join(" "),
989
+ children: [/* @__PURE__ */ u("span", {
990
+ "aria-hidden": "true",
991
+ className: [
992
+ "vdt:inline-block vdt:w-1.5 vdt:h-1.5 vdt:rounded-full",
993
+ U[e],
994
+ t ? "" : "vdt:opacity-40"
995
+ ].join(" ")
996
+ }), e]
997
+ }, e);
998
+ })
999
+ }),
1000
+ /* @__PURE__ */ u("div", {
1001
+ className: "vdt:px-3 vdt:py-2",
1002
+ children: /* @__PURE__ */ u("input", {
1003
+ type: "text",
1004
+ value: i,
1005
+ onChange: (e) => o(e.target.value),
1006
+ placeholder: t.searchPlaceholder,
1007
+ className: "vdt:w-full vdt:px-2 vdt:py-1 vdt:text-xs vdt:bg-background vdt:border vdt:border-border vdt:rounded-sm vdt:text-foreground vdt:placeholder:text-foreground-subtle focus:vdt:outline-none focus:vdt:border-accent"
1008
+ })
1009
+ })
1010
+ ] }), p.length === 0 ? /* @__PURE__ */ d(D, { children: [e.length === 0 ? t.emptyNone : t.emptyNoMatch, /* @__PURE__ */ u("div", {
1011
+ className: "vdt:mt-1 vdt:text-foreground-subtle",
1012
+ children: t.emptyHint
1013
+ })] }) : /* @__PURE__ */ d(w, { children: [/* @__PURE__ */ u(T, {
1014
+ right: /* @__PURE__ */ d("span", {
1015
+ className: "vdt:text-[10px] vdt:text-foreground-muted",
1016
+ children: [
1017
+ p.length,
1018
+ " / ",
1019
+ e.length
1020
+ ]
1021
+ }),
1022
+ children: t.tail
1023
+ }), p.map((e, t) => {
1024
+ let n = `${e.ts.getTime()}:${t}`;
1025
+ return /* @__PURE__ */ u(Ze, {
1026
+ record: e,
1027
+ expanded: c === n,
1028
+ onToggle: () => l(c === n ? null : n)
1029
+ }, n);
1030
+ })] })]
1031
+ });
1032
+ }, $e = () => V().length, G = e(null);
1033
+ function et(e) {
1034
+ return /* @__PURE__ */ u(G.Provider, {
1035
+ value: e.token,
1036
+ children: e.children
1037
+ });
1038
+ }
1039
+ var K = () => n(G), q = (e, t) => {
1040
+ let n = { ...t ?? {} };
1041
+ return e !== null && e !== "" && (n.authorization = `Bearer ${e}`), n;
1042
+ }, tt = (e) => {
1043
+ if (e !== void 0 && e !== "") return e;
1044
+ try {
1045
+ let e = {
1046
+ BASE_URL: "/",
1047
+ DEV: !1,
1048
+ MODE: "production",
1049
+ PROD: !0,
1050
+ SSR: !1
1051
+ }.VITE_VOLTRO_INSPECT_TOKEN;
1052
+ if (e !== void 0 && e !== "") return e;
1053
+ } catch {}
1054
+ return null;
1055
+ }, nt = 5e3, rt = async (e, t) => {
1056
+ if (e === "") return null;
1057
+ try {
1058
+ let n = await fetch(`${e}/_voltro/inspect/subscriptions`, { headers: q(t, { accept: "application/json" }) });
1059
+ return n.ok ? await n.json() : null;
1060
+ } catch {
1061
+ return null;
1062
+ }
1063
+ }, it = () => {
1064
+ let e = h(), t = K(), n = e.names, [i, a] = s(() => n.map((e) => ({
1065
+ name: e,
1066
+ response: null,
1067
+ live: !1
1068
+ })));
1069
+ return r(() => {
1070
+ let r = !1, i = (e, t) => {
1071
+ r || a((n) => n.map((n) => n.name === e ? {
1072
+ ...n,
1073
+ ...t
1074
+ } : n));
1075
+ }, o = n.map((n) => {
1076
+ let r = e.get(n).inspectBaseUrl;
1077
+ if (r === "") return { teardown: () => {} };
1078
+ let a = null, o = null, s = () => {
1079
+ o !== null && clearInterval(o), o = null;
1080
+ }, c = () => {
1081
+ if (o !== null) return;
1082
+ let e = async () => {
1083
+ let e = await rt(r, t);
1084
+ e !== null && i(n, {
1085
+ response: e,
1086
+ live: !1
1087
+ });
1088
+ };
1089
+ e(), o = setInterval(() => {
1090
+ e();
1091
+ }, nt);
1092
+ };
1093
+ rt(r, t).then((e) => {
1094
+ e !== null && i(n, { response: e });
1095
+ });
1096
+ try {
1097
+ a = new EventSource(`${r}/_voltro/inspect/stream`), a.addEventListener("subscriptions", (e) => {
1098
+ try {
1099
+ let t = JSON.parse(e.data).payload;
1100
+ t && typeof t == "object" && i(n, {
1101
+ response: t,
1102
+ live: !0
1103
+ });
1104
+ } catch {}
1105
+ }), a.addEventListener("open", () => {
1106
+ i(n, { live: !0 }), s();
1107
+ }), a.addEventListener("error", () => {
1108
+ i(n, { live: !1 }), c();
1109
+ });
1110
+ } catch {
1111
+ c();
1112
+ }
1113
+ return { teardown: () => {
1114
+ a?.close(), s();
1115
+ } };
1116
+ });
1117
+ return () => {
1118
+ r = !0;
1119
+ for (let e of o) e.teardown();
1120
+ };
1121
+ }, [
1122
+ e,
1123
+ n,
1124
+ t
1125
+ ]), i;
1126
+ }, J = (e) => {
1127
+ if (typeof e != "object" || !e) return !1;
1128
+ let t = e;
1129
+ if (Array.isArray(t.and)) return t.and.some(J);
1130
+ if (Array.isArray(t.or)) return t.or.some(J);
1131
+ let n = t.op;
1132
+ return n === "gt" || n === "gte" || n === "lt" || n === "lte";
1133
+ }, Y = (e) => {
1134
+ if (typeof e != "object" || !e) return !1;
1135
+ let t = e;
1136
+ if (Array.isArray(t.and)) return t.and.some(Y);
1137
+ if (Array.isArray(t.or)) return t.or.some(Y);
1138
+ let n = t.op;
1139
+ return n === "eq" || n === "in";
1140
+ }, at = (e) => e.usingIndex !== void 0 && e.usingIndex.fields.every((t) => e.conjunctiveColumns.includes(t)) ? "tuple" : Y(e.predicate) ? "column" : J(e.predicate) ? "range" : "unindexed", ot = (e) => e === "tuple" ? "success" : e === "column" ? "info" : e === "range" ? "neutral" : "warning", st = (e) => e === "tuple" ? "tuple" : e === "column" ? "column" : e === "range" ? "range" : "UNINDEXED", X = (e) => e == null ? "null" : typeof e == "string" ? `'${e}'` : Array.isArray(e) ? `[${e.map(X).join(", ")}]` : String(e), ct = (e) => e.op === "isNull" ? `${e.column} IS NULL` : e.op === "isNotNull" ? `${e.column} IS NOT NULL` : `${e.column} ${e.op} ${X(e.value)}`, Z = (e, t = 0) => {
1141
+ if (typeof e != "object" || !e) return String(e);
1142
+ let n = e;
1143
+ if (Array.isArray(n.and)) return n.and.map((e) => Z(e, t + 1)).join(" AND ");
1144
+ if (Array.isArray(n.or)) {
1145
+ let e = n.or.map((e) => Z(e, t + 1)).join(" OR ");
1146
+ return t > 0 ? `(${e})` : e;
1147
+ }
1148
+ return typeof n.column == "string" && typeof n.op == "string" ? ct(n) : JSON.stringify(e);
1149
+ }, lt = () => {
1150
+ let e = it(), t = N().indexes, n = e.filter((e) => e.response !== null).length;
1151
+ return e.length === 0 ? /* @__PURE__ */ u(D, { children: t.noApis }) : n === 0 ? /* @__PURE__ */ d(D, { children: [t.unreachableTitle, /* @__PURE__ */ u("div", {
1152
+ className: "vdt:mt-1 vdt:text-foreground-subtle",
1153
+ children: t.unreachableHint
1154
+ })] }) : /* @__PURE__ */ u("div", {
1155
+ className: "vdt:flex vdt:flex-col vdt:gap-3 vdt:p-3",
1156
+ children: e.map(({ name: e, response: n, live: r }) => n === null ? /* @__PURE__ */ d(w, { children: [/* @__PURE__ */ u(T, {
1157
+ Icon: k,
1158
+ children: e
1159
+ }), /* @__PURE__ */ u("div", {
1160
+ className: "vdt:text-xs vdt:text-foreground-subtle",
1161
+ children: t.offline
1162
+ })] }, e) : /* @__PURE__ */ u(ut, {
1163
+ apiName: e,
1164
+ response: n,
1165
+ live: r
1166
+ }, e))
1167
+ });
1168
+ }, ut = ({ apiName: e, response: t, live: n }) => {
1169
+ let r = N().indexes, i = [...t.subscriptions].sort((e, t) => t.subscriberCount - e.subscriberCount);
1170
+ return /* @__PURE__ */ d(w, { children: [
1171
+ /* @__PURE__ */ u(T, {
1172
+ Icon: k,
1173
+ right: /* @__PURE__ */ d("div", {
1174
+ className: "vdt:flex vdt:items-center vdt:gap-1",
1175
+ children: [/* @__PURE__ */ u(C, {
1176
+ tone: "info",
1177
+ children: r.subsBadge(t.subscriptions.length)
1178
+ }), /* @__PURE__ */ u(C, {
1179
+ tone: n ? "success" : "neutral",
1180
+ children: n ? r.live : r.poll
1181
+ })]
1182
+ }),
1183
+ children: e
1184
+ }),
1185
+ t.matcherStats.length > 0 && /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u("div", {
1186
+ className: "vdt:text-[11px] vdt:uppercase vdt:tracking-wide vdt:text-foreground-subtle vdt:mt-3 vdt:mb-1",
1187
+ children: r.tables
1188
+ }), /* @__PURE__ */ u("div", {
1189
+ className: "vdt:flex vdt:flex-col vdt:gap-1",
1190
+ children: t.matcherStats.map((e) => /* @__PURE__ */ d("div", {
1191
+ className: "vdt:flex vdt:items-baseline vdt:gap-3 vdt:text-xs",
1192
+ children: [
1193
+ /* @__PURE__ */ u("span", {
1194
+ className: "vdt:font-mono vdt:text-foreground",
1195
+ children: e.tableName
1196
+ }),
1197
+ /* @__PURE__ */ d("span", {
1198
+ className: "vdt:text-foreground-subtle",
1199
+ children: [e.tupleRouted + e.columnBucketed + e.rangeBucketed + e.unindexedFallback, " subs"]
1200
+ }),
1201
+ e.tupleRouted > 0 && /* @__PURE__ */ u(C, {
1202
+ tone: "success",
1203
+ children: `${e.tupleRouted} tuple`
1204
+ }),
1205
+ e.columnBucketed > 0 && /* @__PURE__ */ u(C, {
1206
+ tone: "info",
1207
+ children: `${e.columnBucketed} column`
1208
+ }),
1209
+ e.rangeBucketed > 0 && /* @__PURE__ */ u(C, {
1210
+ tone: "neutral",
1211
+ children: `${e.rangeBucketed} range`
1212
+ }),
1213
+ e.unindexedFallback > 0 && /* @__PURE__ */ u(C, {
1214
+ tone: "warning",
1215
+ children: `${e.unindexedFallback} unindexed`
1216
+ }),
1217
+ e.distinctTupleKeys > 0 && /* @__PURE__ */ d("span", {
1218
+ className: "vdt:text-foreground-subtle",
1219
+ children: [e.distinctTupleKeys, " tuple keys"]
1220
+ })
1221
+ ]
1222
+ }, e.tableName))
1223
+ })] }),
1224
+ i.length > 0 && /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u("div", {
1225
+ className: "vdt:text-[11px] vdt:uppercase vdt:tracking-wide vdt:text-foreground-subtle vdt:mt-3 vdt:mb-1",
1226
+ children: r.subscriptionsSection
1227
+ }), /* @__PURE__ */ u("div", {
1228
+ className: "vdt:flex vdt:flex-col vdt:gap-2",
1229
+ children: i.map((e) => /* @__PURE__ */ u(dt, { sub: e }, e.fingerprint))
1230
+ })] })
1231
+ ] });
1232
+ }, dt = ({ sub: e }) => {
1233
+ let t = N().indexes, n = at(e);
1234
+ return /* @__PURE__ */ d("div", {
1235
+ className: "vdt:flex vdt:flex-col vdt:gap-0.5 vdt:px-2 vdt:py-1 vdt:rounded-sm vdt:bg-muted/40",
1236
+ children: [/* @__PURE__ */ d("div", {
1237
+ className: "vdt:flex vdt:items-baseline vdt:gap-2 vdt:text-xs",
1238
+ children: [
1239
+ /* @__PURE__ */ u("span", {
1240
+ className: "vdt:font-mono vdt:text-foreground",
1241
+ children: e.table
1242
+ }),
1243
+ /* @__PURE__ */ u(C, {
1244
+ tone: ot(n),
1245
+ children: st(n)
1246
+ }),
1247
+ e.usingIndex && /* @__PURE__ */ d("span", {
1248
+ className: "vdt:text-foreground-subtle",
1249
+ children: [
1250
+ t.via,
1251
+ " ",
1252
+ /* @__PURE__ */ u("span", {
1253
+ className: "vdt:font-mono",
1254
+ children: e.usingIndex.name
1255
+ })
1256
+ ]
1257
+ }),
1258
+ /* @__PURE__ */ d("span", {
1259
+ className: "vdt:text-foreground-subtle vdt:ml-auto",
1260
+ children: [
1261
+ e.subscriberCount,
1262
+ " ",
1263
+ t.clients(e.subscriberCount)
1264
+ ]
1265
+ })
1266
+ ]
1267
+ }), /* @__PURE__ */ u("div", {
1268
+ className: "vdt:text-[11px] vdt:font-mono vdt:text-foreground-subtle vdt:break-all",
1269
+ children: Z(e.predicate)
1270
+ })]
1271
+ });
1272
+ }, ft = () => {
1273
+ let e = it(), t = 0;
1274
+ for (let n of e) t += n.response?.subscriptions.length ?? 0;
1275
+ return t;
1276
+ }, pt = (e) => typeof document > "u" ? () => {} : (document.addEventListener("visibilitychange", e), () => document.removeEventListener("visibilitychange", e)), mt = () => typeof document > "u" || !document.hidden, ht = () => !0, Q = () => c(pt, mt, ht), gt = {
1277
+ outgoing: [],
1278
+ incoming: [],
1279
+ targets: [],
1280
+ deliveries: []
1281
+ }, _t = 4e3, vt = async (e, t) => {
1282
+ if (e === "") return null;
1283
+ try {
1284
+ let n = await fetch(`${e}/_voltro/inspect/webhooks`, { headers: q(t, { accept: "application/json" }) });
1285
+ return n.ok ? await n.json() : null;
1286
+ } catch {
1287
+ return null;
1288
+ }
1289
+ }, yt = (e, t = !0) => {
1290
+ let n = Q(), i = K(), a = t && n && e !== "", [o, c] = s(gt);
1291
+ return r(() => {
1292
+ if (!a) return;
1293
+ let t = !1, n = async () => {
1294
+ let n = await vt(e, i);
1295
+ t || n === null || c(n);
1296
+ };
1297
+ n();
1298
+ let r = setInterval(n, _t);
1299
+ return () => {
1300
+ t = !0, clearInterval(r);
1301
+ };
1302
+ }, [
1303
+ e,
1304
+ a,
1305
+ i
1306
+ ]), o;
1307
+ }, bt = {
1308
+ pending: "neutral",
1309
+ inFlight: "info",
1310
+ succeeded: "success",
1311
+ failed: "danger",
1312
+ retryScheduled: "warning"
1313
+ }, xt = (e) => {
1314
+ let t = new Date(e), n = (e) => e < 10 ? `0${e}` : String(e);
1315
+ return `${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`;
1316
+ }, St = (e) => {
1317
+ let t = h(), n = Q(), i = K(), a = t.names.join(","), [o, c] = s(0), l = e && n;
1318
+ return r(() => {
1319
+ if (!l) {
1320
+ c(0);
1321
+ return;
1322
+ }
1323
+ let e = a === "" ? [] : a.split(",").map((e) => t.get(e).inspectBaseUrl).filter((e) => e !== "");
1324
+ if (e.length === 0) {
1325
+ c(0);
1326
+ return;
1327
+ }
1328
+ let n = !1, r = async () => {
1329
+ let t = await Promise.all(e.map((e) => vt(e, i)));
1330
+ n || c(t.reduce((e, t) => e + (t === null ? 0 : t.outgoing.length + t.incoming.length + t.targets.length), 0));
1331
+ };
1332
+ r();
1333
+ let o = setInterval(r, _t);
1334
+ return () => {
1335
+ n = !0, clearInterval(o);
1336
+ };
1337
+ }, [
1338
+ t,
1339
+ a,
1340
+ l,
1341
+ i
1342
+ ]), o;
1343
+ }, Ct = ({ apiName: e, baseUrl: t }) => {
1344
+ let n = yt(t), r = N().webhooks;
1345
+ return n.outgoing.length + n.incoming.length + n.targets.length + n.deliveries.length > 0 ? /* @__PURE__ */ u("div", {
1346
+ className: "vdt:space-y-4",
1347
+ children: /* @__PURE__ */ d(w, { children: [
1348
+ /* @__PURE__ */ d("div", {
1349
+ className: "vdt:flex vdt:items-center vdt:gap-2 vdt:mb-3",
1350
+ children: [/* @__PURE__ */ u(me, { className: "vdt:w-4 vdt:h-4 vdt:text-accent" }), /* @__PURE__ */ u(T, { children: e })]
1351
+ }),
1352
+ n.outgoing.length > 0 ? /* @__PURE__ */ d("div", {
1353
+ className: "vdt:mb-4",
1354
+ children: [/* @__PURE__ */ u("div", {
1355
+ className: "vdt:text-foreground-muted vdt:text-xs vdt:uppercase vdt:tracking-wider vdt:mb-2",
1356
+ children: r.outgoing(n.outgoing.length)
1357
+ }), /* @__PURE__ */ u("div", {
1358
+ className: "vdt:space-y-1",
1359
+ children: n.outgoing.map((e) => /* @__PURE__ */ d("div", {
1360
+ className: "vdt:flex vdt:items-center vdt:gap-2 vdt:text-sm",
1361
+ children: [
1362
+ /* @__PURE__ */ u("code", {
1363
+ className: "vdt:text-foreground vdt:font-mono",
1364
+ children: e.id
1365
+ }),
1366
+ /* @__PURE__ */ d(C, {
1367
+ tone: "neutral",
1368
+ children: ["v", e.version]
1369
+ }),
1370
+ e.description ? /* @__PURE__ */ u("span", {
1371
+ className: "vdt:text-foreground-muted vdt:text-xs vdt:truncate",
1372
+ children: e.description
1373
+ }) : null
1374
+ ]
1375
+ }, e.id))
1376
+ })]
1377
+ }) : null,
1378
+ n.incoming.length > 0 ? /* @__PURE__ */ d("div", {
1379
+ className: "vdt:mb-4",
1380
+ children: [/* @__PURE__ */ u("div", {
1381
+ className: "vdt:text-foreground-muted vdt:text-xs vdt:uppercase vdt:tracking-wider vdt:mb-2",
1382
+ children: r.incoming(n.incoming.length)
1383
+ }), /* @__PURE__ */ u("div", {
1384
+ className: "vdt:space-y-1",
1385
+ children: n.incoming.map((e) => /* @__PURE__ */ d("div", {
1386
+ className: "vdt:flex vdt:items-center vdt:gap-2 vdt:text-sm",
1387
+ children: [
1388
+ /* @__PURE__ */ u("code", {
1389
+ className: "vdt:text-foreground vdt:font-mono",
1390
+ children: e.path
1391
+ }),
1392
+ e.provider ? /* @__PURE__ */ u(C, {
1393
+ tone: "info",
1394
+ children: e.provider
1395
+ }) : null,
1396
+ e.signatureConfigured ? /* @__PURE__ */ u(C, {
1397
+ tone: "success",
1398
+ children: r.signed
1399
+ }) : /* @__PURE__ */ u(C, {
1400
+ tone: "warning",
1401
+ children: r.unsigned
1402
+ })
1403
+ ]
1404
+ }, e.id))
1405
+ })]
1406
+ }) : null,
1407
+ n.targets.length > 0 ? /* @__PURE__ */ d("div", {
1408
+ className: "vdt:mb-4",
1409
+ children: [/* @__PURE__ */ u("div", {
1410
+ className: "vdt:text-foreground-muted vdt:text-xs vdt:uppercase vdt:tracking-wider vdt:mb-2",
1411
+ children: r.targets(n.targets.length)
1412
+ }), /* @__PURE__ */ u("div", {
1413
+ className: "vdt:space-y-1",
1414
+ children: n.targets.map((e) => {
1415
+ let t = n.outgoing.find((t) => t.id === e.event)?.version ?? e.payloadVersion, i = e.payloadVersion === t ? "current" : e.payloadVersion < t ? "behind" : "ahead";
1416
+ return /* @__PURE__ */ d("div", {
1417
+ className: "vdt:flex vdt:items-center vdt:gap-2 vdt:text-sm",
1418
+ children: [
1419
+ /* @__PURE__ */ u("code", {
1420
+ className: "vdt:text-foreground vdt:font-mono",
1421
+ children: e.event
1422
+ }),
1423
+ /* @__PURE__ */ u("span", {
1424
+ className: "vdt:text-foreground-muted",
1425
+ children: "→"
1426
+ }),
1427
+ /* @__PURE__ */ u("span", {
1428
+ className: "vdt:text-foreground vdt:text-xs vdt:truncate vdt:max-w-72",
1429
+ children: e.url
1430
+ }),
1431
+ e.active ? /* @__PURE__ */ u(C, {
1432
+ tone: "success",
1433
+ children: r.active
1434
+ }) : /* @__PURE__ */ u(C, {
1435
+ tone: "warning",
1436
+ children: r.paused
1437
+ }),
1438
+ i === "current" ? /* @__PURE__ */ d(C, {
1439
+ tone: "neutral",
1440
+ children: ["v", e.payloadVersion]
1441
+ }) : i === "behind" ? /* @__PURE__ */ d(C, {
1442
+ tone: "warning",
1443
+ children: [
1444
+ "v",
1445
+ e.payloadVersion,
1446
+ " ← current v",
1447
+ t
1448
+ ]
1449
+ }) : /* @__PURE__ */ d(C, {
1450
+ tone: "danger",
1451
+ children: [
1452
+ "v",
1453
+ e.payloadVersion,
1454
+ " → ahead of v",
1455
+ t
1456
+ ]
1457
+ })
1458
+ ]
1459
+ }, e.id);
1460
+ })
1461
+ })]
1462
+ }) : null,
1463
+ n.deliveries.length > 0 ? /* @__PURE__ */ d("div", { children: [/* @__PURE__ */ u("div", {
1464
+ className: "vdt:text-foreground-muted vdt:text-xs vdt:uppercase vdt:tracking-wider vdt:mb-2",
1465
+ children: r.deliveries(n.deliveries.length)
1466
+ }), /* @__PURE__ */ u("div", {
1467
+ className: "vdt:space-y-0.5 vdt:font-mono vdt:text-xs",
1468
+ children: n.deliveries.map((e) => /* @__PURE__ */ d("div", {
1469
+ className: "vdt:flex vdt:items-center vdt:gap-2",
1470
+ children: [
1471
+ /* @__PURE__ */ u("span", {
1472
+ className: "vdt:text-foreground-subtle",
1473
+ children: xt(e.scheduledAt)
1474
+ }),
1475
+ /* @__PURE__ */ u("span", {
1476
+ className: "vdt:text-foreground vdt:min-w-32 vdt:truncate",
1477
+ children: e.event
1478
+ }),
1479
+ /* @__PURE__ */ u(C, {
1480
+ tone: bt[e.status],
1481
+ children: e.status
1482
+ }),
1483
+ e.responseStatus === null ? null : /* @__PURE__ */ u("span", {
1484
+ className: "vdt:text-foreground-muted",
1485
+ children: e.responseStatus
1486
+ }),
1487
+ e.latencyMs === null ? null : /* @__PURE__ */ d("span", {
1488
+ className: "vdt:text-foreground-subtle",
1489
+ children: [e.latencyMs, "ms"]
1490
+ }),
1491
+ /* @__PURE__ */ u("span", {
1492
+ className: "vdt:text-foreground-subtle",
1493
+ children: r.attempt(e.attempt)
1494
+ }),
1495
+ e.errorMessage ? /* @__PURE__ */ u("span", {
1496
+ className: "vdt:text-danger vdt:truncate vdt:max-w-64",
1497
+ children: e.errorMessage
1498
+ }) : null
1499
+ ]
1500
+ }, e.id))
1501
+ })] }) : null
1502
+ ] })
1503
+ }) : null;
1504
+ }, wt = () => {
1505
+ let e = h(), t = N().webhooks;
1506
+ return e.names.length === 0 ? /* @__PURE__ */ u(D, { children: t.empty }) : /* @__PURE__ */ u("div", {
1507
+ className: "vdt:space-y-4 vdt:p-3",
1508
+ children: e.names.map((t) => /* @__PURE__ */ u(Ct, {
1509
+ apiName: t,
1510
+ baseUrl: e.get(t).inspectBaseUrl
1511
+ }, t))
1512
+ });
1513
+ }, Tt = { traces: [] }, Et = 4e3, Dt = async (e, t) => {
1514
+ if (e === "") return null;
1515
+ try {
1516
+ let n = await fetch(`${e}/_voltro/inspect/traces`, { headers: q(t, { accept: "application/json" }) });
1517
+ return n.ok ? await n.json() : null;
1518
+ } catch {
1519
+ return null;
1520
+ }
1521
+ }, Ot = (e, t = !0) => {
1522
+ let n = Q(), i = K(), a = t && n && e !== "", [o, c] = s(Tt);
1523
+ return r(() => {
1524
+ if (!a) return;
1525
+ let t = !1, n = async () => {
1526
+ let n = await Dt(e, i);
1527
+ t || n === null || c(n);
1528
+ };
1529
+ n();
1530
+ let r = setInterval(n, Et);
1531
+ return () => {
1532
+ t = !0, clearInterval(r);
1533
+ };
1534
+ }, [
1535
+ e,
1536
+ a,
1537
+ i
1538
+ ]), o;
1539
+ }, kt = (e) => {
1540
+ let t = h(), n = Q(), i = K(), a = t.names.join(","), [o, c] = s(0), l = e && n;
1541
+ return r(() => {
1542
+ if (!l) {
1543
+ c(0);
1544
+ return;
1545
+ }
1546
+ let e = a === "" ? [] : a.split(",").map((e) => t.get(e).inspectBaseUrl).filter((e) => e !== "");
1547
+ if (e.length === 0) {
1548
+ c(0);
1549
+ return;
1550
+ }
1551
+ let n = !1, r = async () => {
1552
+ let t = await Promise.all(e.map((e) => Dt(e, i)));
1553
+ n || c(t.reduce((e, t) => e + (t === null ? 0 : t.traces.filter((e) => e.hasError).length), 0));
1554
+ };
1555
+ r();
1556
+ let o = setInterval(r, Et);
1557
+ return () => {
1558
+ n = !0, clearInterval(o);
1559
+ };
1560
+ }, [
1561
+ t,
1562
+ a,
1563
+ l,
1564
+ i
1565
+ ]), o;
1566
+ }, $ = (e) => e < 1 ? "<1ms" : e < 1e3 ? `${Math.round(e)}ms` : `${(e / 1e3).toFixed(2)}s`, At = (e) => {
1567
+ let t = new Date(e), n = (e) => e < 10 ? `0${e}` : String(e);
1568
+ return `${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`;
1569
+ }, jt = (e) => {
1570
+ let t = new Map(e.map((e) => [e.spanId, e])), n = /* @__PURE__ */ new Map(), r = (e, i) => {
1571
+ if (n.has(e.spanId)) return n.get(e.spanId);
1572
+ if (i > 64 || e.parentSpanId === null) return n.set(e.spanId, 0), 0;
1573
+ let a = t.get(e.parentSpanId), o = a ? r(a, i + 1) + 1 : 0;
1574
+ return n.set(e.spanId, o), o;
1575
+ };
1576
+ for (let t of e) r(t, 0);
1577
+ return n;
1578
+ }, Mt = ({ trace: e }) => {
1579
+ let [t, n] = s(e.hasError), r = N().traces, i = jt(e.spans), a = e.startMs, o = e.durationMs > 0 ? e.durationMs : 1;
1580
+ return /* @__PURE__ */ d("div", {
1581
+ className: "vdt:border vdt:border-border vdt:rounded-md vdt:overflow-hidden",
1582
+ children: [/* @__PURE__ */ d("button", {
1583
+ onClick: () => n((e) => !e),
1584
+ className: "vdt:w-full vdt:flex vdt:items-center vdt:gap-2 vdt:px-3 vdt:py-2 vdt:text-left vdt:text-sm hover:vdt:bg-background-elevated",
1585
+ children: [
1586
+ /* @__PURE__ */ u("span", {
1587
+ className: "vdt:text-foreground-muted vdt:text-xs",
1588
+ children: t ? "▾" : "▸"
1589
+ }),
1590
+ /* @__PURE__ */ u("code", {
1591
+ className: "vdt:font-mono vdt:text-foreground vdt:truncate vdt:max-w-64",
1592
+ children: e.rootName
1593
+ }),
1594
+ e.hasError ? /* @__PURE__ */ u(C, {
1595
+ tone: "danger",
1596
+ children: r.error
1597
+ }) : /* @__PURE__ */ u(C, {
1598
+ tone: "success",
1599
+ children: r.ok
1600
+ }),
1601
+ e.kind === "subscription" ? /* @__PURE__ */ u(C, {
1602
+ tone: "info",
1603
+ children: r.sub
1604
+ }) : null,
1605
+ e.kind === "subscription" ? /* @__PURE__ */ d("span", {
1606
+ className: "vdt:text-foreground-muted vdt:text-xs vdt:ml-auto",
1607
+ children: [
1608
+ e.deliveryCount ?? 0,
1609
+ " ",
1610
+ r.delivery(e.deliveryCount ?? 0),
1611
+ e.lastDeliveryMs === void 0 ? null : /* @__PURE__ */ d(l, { children: [" · last ", /* @__PURE__ */ u("span", {
1612
+ className: "vdt:text-foreground vdt:tabular-nums",
1613
+ children: $(e.lastDeliveryMs)
1614
+ })] })
1615
+ ]
1616
+ }) : /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u("span", {
1617
+ className: "vdt:text-foreground-muted vdt:text-xs vdt:ml-auto",
1618
+ children: r.spans(e.spanCount)
1619
+ }), /* @__PURE__ */ u("span", {
1620
+ className: "vdt:text-foreground vdt:text-xs vdt:tabular-nums",
1621
+ children: $(e.durationMs)
1622
+ })] }),
1623
+ /* @__PURE__ */ u("span", {
1624
+ className: "vdt:text-foreground-subtle vdt:text-xs",
1625
+ children: At(e.startMs)
1626
+ })
1627
+ ]
1628
+ }), t ? /* @__PURE__ */ d("div", {
1629
+ className: "vdt:px-3 vdt:py-2 vdt:space-y-1 vdt:border-t vdt:border-border vdt:bg-background",
1630
+ children: [
1631
+ /* @__PURE__ */ d("div", {
1632
+ className: "vdt:text-foreground-subtle vdt:text-[10px] vdt:font-mono vdt:mb-1",
1633
+ children: ["trace ", e.traceId]
1634
+ }),
1635
+ e.spans.map((e) => {
1636
+ let t = i.get(e.spanId) ?? 0, n = Math.max(0, Math.min(100, (e.startMs - a) / o * 100)), r = Math.max(1.5, Math.min(100 - n, e.durationMs / o * 100)), s = e.status === "error";
1637
+ return /* @__PURE__ */ d("div", {
1638
+ className: "vdt:flex vdt:items-center vdt:gap-2 vdt:text-xs",
1639
+ children: [
1640
+ /* @__PURE__ */ d("div", {
1641
+ className: "vdt:flex vdt:items-center vdt:gap-1 vdt:w-56 vdt:shrink-0",
1642
+ style: { paddingLeft: t * 12 },
1643
+ children: [/* @__PURE__ */ u("span", {
1644
+ className: s ? "vdt:text-danger" : "vdt:text-foreground-muted",
1645
+ children: s ? "✗" : "·"
1646
+ }), /* @__PURE__ */ u("code", {
1647
+ className: `vdt:font-mono vdt:truncate ${s ? "vdt:text-danger" : "vdt:text-foreground"}`,
1648
+ children: e.name
1649
+ })]
1650
+ }),
1651
+ /* @__PURE__ */ u("div", {
1652
+ className: "vdt:relative vdt:flex-1 vdt:h-3 vdt:bg-background-elevated vdt:rounded-sm vdt:overflow-hidden",
1653
+ children: /* @__PURE__ */ u("div", {
1654
+ className: `vdt:absolute vdt:top-0 vdt:h-full vdt:rounded-sm ${s ? "vdt:bg-danger" : "vdt:bg-accent"}`,
1655
+ style: {
1656
+ left: `${n}%`,
1657
+ width: `${r}%`
1658
+ }
1659
+ })
1660
+ }),
1661
+ /* @__PURE__ */ u("span", {
1662
+ className: "vdt:text-foreground vdt:tabular-nums vdt:w-14 vdt:text-right vdt:shrink-0",
1663
+ children: $(e.durationMs)
1664
+ })
1665
+ ]
1666
+ }, e.spanId);
1667
+ }),
1668
+ e.spans.filter((e) => e.status === "error" && e.statusMessage).map((e) => /* @__PURE__ */ d("div", {
1669
+ className: "vdt:text-danger vdt:text-xs vdt:font-mono vdt:pl-2 vdt:pt-1",
1670
+ children: [
1671
+ e.name,
1672
+ ": ",
1673
+ e.statusMessage
1674
+ ]
1675
+ }, `${e.spanId}-msg`))
1676
+ ]
1677
+ }) : null]
1678
+ });
1679
+ }, Nt = ({ apiName: e, baseUrl: t }) => {
1680
+ let n = Ot(t), r = N().traces;
1681
+ return n.traces.length === 0 ? /* @__PURE__ */ u("div", {
1682
+ className: "vdt:text-foreground-muted vdt:text-sm vdt:px-1",
1683
+ children: r.noneCaptured(e)
1684
+ }) : /* @__PURE__ */ d(w, { children: [/* @__PURE__ */ d("div", {
1685
+ className: "vdt:flex vdt:items-center vdt:gap-2 vdt:mb-3",
1686
+ children: [
1687
+ /* @__PURE__ */ u(he, { className: "vdt:w-4 vdt:h-4 vdt:text-accent" }),
1688
+ /* @__PURE__ */ u(T, { children: e }),
1689
+ /* @__PURE__ */ u(C, {
1690
+ tone: "neutral",
1691
+ children: n.traces.length
1692
+ })
1693
+ ]
1694
+ }), /* @__PURE__ */ u("div", {
1695
+ className: "vdt:space-y-2",
1696
+ children: n.traces.map((e) => /* @__PURE__ */ u(Mt, { trace: e }, e.traceId))
1697
+ })] });
1698
+ }, Pt = () => {
1699
+ let e = h(), t = N().traces, n = e.names, r = n.map((t) => ({
1700
+ name: t,
1701
+ handle: e.get(t)
1702
+ })).filter((e) => e.handle !== null && e.handle.inspectBaseUrl !== "");
1703
+ return n.length === 0 ? /* @__PURE__ */ u("div", {
1704
+ className: "vdt:text-foreground-muted vdt:text-sm vdt:p-4",
1705
+ children: t.noApi
1706
+ }) : r.length === 0 ? /* @__PURE__ */ d("div", {
1707
+ className: "vdt:text-foreground-muted vdt:text-sm vdt:p-4 vdt:space-y-2",
1708
+ children: [/* @__PURE__ */ u("p", { children: t.proxiedTitle }), /* @__PURE__ */ u("p", { children: t.proxiedHint(/* @__PURE__ */ u("code", {
1709
+ className: "vdt:text-foreground",
1710
+ children: "voltro logs --trace <id>"
1711
+ })) })]
1712
+ }) : /* @__PURE__ */ u("div", {
1713
+ className: "vdt:space-y-4",
1714
+ children: r.map(({ name: e, handle: t }) => /* @__PURE__ */ u(Nt, {
1715
+ apiName: e,
1716
+ baseUrl: t.inspectBaseUrl
1717
+ }, e))
1718
+ });
1719
+ }, Ft = () => c(v, _, _), It = "voltro:devtools:open", Lt = (e) => {
1720
+ if (typeof window > "u") return e;
1721
+ try {
1722
+ let t = window.localStorage.getItem(It);
1723
+ return t === null ? e : t === "1";
1724
+ } catch {
1725
+ return e;
1726
+ }
1727
+ }, Rt = (e) => {
1728
+ if (!(typeof window > "u")) try {
1729
+ window.localStorage.setItem(It, e ? "1" : "0");
1730
+ } catch {}
1731
+ }, zt = ({ initialIsOpen: e = !1, initialAnchor: t = "bottomLeft", strings: n, inspectToken: r } = {}) => /* @__PURE__ */ u(et, {
1732
+ token: tt(r),
1733
+ children: /* @__PURE__ */ u(Ce, {
1734
+ strings: n ?? {},
1735
+ children: /* @__PURE__ */ u(Bt, {
1736
+ initialIsOpen: e,
1737
+ initialAnchor: t
1738
+ })
1739
+ })
1740
+ }), Bt = ({ initialIsOpen: e, initialAnchor: t }) => {
1741
+ let n = N().shell, [i, a] = re(t), [o, c] = s(() => Lt(e)), [l, f] = s("subscriptions"), p = je(), m = We(), h = $e(), g = ft(), _ = St(o), ee = kt(o), v = Ft(), y = v.length > 0 ? v[v.length - 1] : null, b = y !== null;
1742
+ return r(() => {
1743
+ Rt(o);
1744
+ }, [o]), r(() => {
1745
+ if (typeof window > "u") return;
1746
+ let e = (e) => {
1747
+ e.altKey && (e.key === "v" || e.key === "V") && (e.preventDefault(), c((e) => !e));
1748
+ };
1749
+ return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
1750
+ }, []), /* @__PURE__ */ u("div", {
1751
+ className: "vdt-host",
1752
+ style: ie(i),
1753
+ children: /* @__PURE__ */ u("div", {
1754
+ className: "vdt-scope",
1755
+ children: /* @__PURE__ */ d("div", {
1756
+ className: "vdt-surface vdt-pulse vdt-anim-pop",
1757
+ "data-open": o ? "true" : "false",
1758
+ "data-busy": b ? "true" : "false",
1759
+ "data-kind": y?.kind ?? "idle",
1760
+ role: o ? "dialog" : void 0,
1761
+ "aria-label": o ? n.brand : void 0,
1762
+ children: [/* @__PURE__ */ u(Ht, {
1763
+ open: o,
1764
+ busy: b,
1765
+ label: y?.label ?? "",
1766
+ kind: y?.kind ?? "idle",
1767
+ onOpen: () => c(!0)
1768
+ }), /* @__PURE__ */ u(Ut, {
1769
+ open: o,
1770
+ anchor: i,
1771
+ onAnchor: a,
1772
+ onClose: () => c(!1),
1773
+ tab: l,
1774
+ onTab: f,
1775
+ subsCount: p,
1776
+ mutationsCount: m,
1777
+ logsCount: h,
1778
+ indexesCount: g,
1779
+ webhooksCount: _,
1780
+ tracesCount: ee
1781
+ })]
1782
+ })
1783
+ })
1784
+ });
1785
+ }, Vt = (e) => e === "compiling" || e === "loading" || e === "reconnecting", Ht = ({ open: e, busy: t, label: n, kind: r, onOpen: i }) => {
1786
+ let a = N().shell, o = Vt(r), s = o ? n.replace(/[…\.\s]+$/, "") : n;
1787
+ return /* @__PURE__ */ d("button", {
1788
+ type: "button",
1789
+ className: "vdt-fab-layer",
1790
+ onClick: i,
1791
+ tabIndex: e ? -1 : 0,
1792
+ "aria-hidden": e ? "true" : "false",
1793
+ title: e ? void 0 : a.openTitle,
1794
+ "aria-label": e ? void 0 : a.openLabel,
1795
+ children: [t ? /* @__PURE__ */ u(ge, { className: "vdt:w-5 vdt:h-5 vdt-spinner" }) : /* @__PURE__ */ u(ce, { className: "vdt:w-6 vdt:h-6" }), /* @__PURE__ */ d("span", {
1796
+ className: "vdt-fab-label",
1797
+ children: [s, o ? /* @__PURE__ */ d("span", {
1798
+ className: "vdt-dots",
1799
+ "aria-hidden": "true",
1800
+ children: [
1801
+ /* @__PURE__ */ u("span", {}),
1802
+ /* @__PURE__ */ u("span", {}),
1803
+ /* @__PURE__ */ u("span", {})
1804
+ ]
1805
+ }) : null]
1806
+ })]
1807
+ });
1808
+ }, Ut = ({ open: e, anchor: t, onAnchor: n, onClose: r, tab: i, onTab: a, subsCount: o, mutationsCount: s, logsCount: c, indexesCount: l, webhooksCount: f, tracesCount: p }) => {
1809
+ let m = N().tabs;
1810
+ return /* @__PURE__ */ d("div", {
1811
+ className: "vdt-panel-layer",
1812
+ "aria-hidden": e ? "false" : "true",
1813
+ children: [
1814
+ /* @__PURE__ */ u(Wt, {
1815
+ anchor: t,
1816
+ onAnchor: n,
1817
+ onClose: r
1818
+ }),
1819
+ /* @__PURE__ */ d(oe, { children: [
1820
+ /* @__PURE__ */ u(S, {
1821
+ active: i === "subscriptions",
1822
+ onClick: () => a("subscriptions"),
1823
+ badge: o,
1824
+ children: m.subscriptions
1825
+ }),
1826
+ /* @__PURE__ */ u(S, {
1827
+ active: i === "mutations",
1828
+ onClick: () => a("mutations"),
1829
+ badge: s,
1830
+ children: m.mutations
1831
+ }),
1832
+ /* @__PURE__ */ u(S, {
1833
+ active: i === "indexes",
1834
+ onClick: () => a("indexes"),
1835
+ badge: l,
1836
+ children: m.indexes
1837
+ }),
1838
+ /* @__PURE__ */ u(S, {
1839
+ active: i === "webhooks",
1840
+ onClick: () => a("webhooks"),
1841
+ badge: f,
1842
+ children: m.webhooks
1843
+ }),
1844
+ /* @__PURE__ */ u(S, {
1845
+ active: i === "traces",
1846
+ onClick: () => a("traces"),
1847
+ badge: p,
1848
+ children: m.traces
1849
+ }),
1850
+ /* @__PURE__ */ u(S, {
1851
+ active: i === "routes",
1852
+ onClick: () => a("routes"),
1853
+ children: m.routes
1854
+ }),
1855
+ /* @__PURE__ */ u(S, {
1856
+ active: i === "runtimes",
1857
+ onClick: () => a("runtimes"),
1858
+ children: m.runtimes
1859
+ }),
1860
+ /* @__PURE__ */ u(S, {
1861
+ active: i === "logs",
1862
+ onClick: () => a("logs"),
1863
+ badge: c,
1864
+ children: m.logs
1865
+ })
1866
+ ] }),
1867
+ /* @__PURE__ */ d("div", {
1868
+ className: "vdt:flex-1 vdt:overflow-auto vdt:bg-background",
1869
+ children: [
1870
+ e && i === "subscriptions" ? /* @__PURE__ */ u(Ae, {}) : null,
1871
+ e && i === "mutations" ? /* @__PURE__ */ u(Ue, {}) : null,
1872
+ e && i === "indexes" ? /* @__PURE__ */ u(lt, {}) : null,
1873
+ e && i === "webhooks" ? /* @__PURE__ */ u(wt, {}) : null,
1874
+ e && i === "traces" ? /* @__PURE__ */ u(Pt, {}) : null,
1875
+ e && i === "routes" ? /* @__PURE__ */ u(Fe, {}) : null,
1876
+ e && i === "runtimes" ? /* @__PURE__ */ u(Le, {}) : null,
1877
+ e && i === "logs" ? /* @__PURE__ */ u(Qe, {}) : null
1878
+ ]
1879
+ })
1880
+ ]
1881
+ });
1882
+ }, Wt = ({ anchor: e, onAnchor: t, onClose: n }) => {
1883
+ let r = N().shell;
1884
+ return /* @__PURE__ */ d("div", {
1885
+ className: "vdt:flex vdt:items-center vdt:gap-2 vdt:px-3 vdt:py-2 vdt:border-b vdt:border-border vdt:bg-background-elevated",
1886
+ children: [
1887
+ /* @__PURE__ */ u(ce, { className: "vdt:w-4 vdt:h-4 vdt:text-accent" }),
1888
+ /* @__PURE__ */ d("div", {
1889
+ className: "vdt:flex-1 vdt:flex vdt:items-center vdt:gap-1.5",
1890
+ children: [/* @__PURE__ */ u("span", {
1891
+ className: "vdt:text-xs vdt:font-semibold vdt:text-foreground",
1892
+ children: r.brandWord
1893
+ }), /* @__PURE__ */ u("span", {
1894
+ className: "vdt:text-[10px] vdt:uppercase vdt:tracking-wider vdt:text-foreground-muted",
1895
+ children: r.kicker
1896
+ })]
1897
+ }),
1898
+ /* @__PURE__ */ u(ve, {
1899
+ anchor: e,
1900
+ onChange: t
1901
+ }),
1902
+ /* @__PURE__ */ u(ae, {
1903
+ onClick: n,
1904
+ title: r.closeTitle,
1905
+ children: /* @__PURE__ */ u(le, { className: "vdt:w-4 vdt:h-4" })
1906
+ })
1907
+ ]
1908
+ });
1909
+ };
1910
+ //#endregion
1911
+ export { Ce as DevtoolsStringsProvider, zt as VoltroDevtools, xe as defaultDevtoolsStrings, N as useDevtoolsStrings };