batchkit-devtools 0.3.7 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1138 @@
1
+ import { delegateEvents as ne, template as _, style as o, insert as m, createComponent as z, effect as I, memo as N, setAttribute as X, setStyleProperty as ge, addEventListener as De, className as _e, use as Le, render as je } from "solid-js/web";
2
+ import { createRoot as Me, createSignal as F, createMemo as ke, For as ae, Show as L, onMount as Ne } from "solid-js";
3
+ import { __setDevtoolsHook as Fe } from "batchkit";
4
+ let Ue = 0;
5
+ function Ke(n) {
6
+ if (!n) return;
7
+ const e = n.split(`
8
+ `);
9
+ for (const r of e)
10
+ if (r.includes("batch") && !r.includes("batchkit") && !r.includes("node_modules")) {
11
+ const s = r.match(/at\s+.*?\s+\(?(.*?:\d+:\d+)\)?$/);
12
+ if (s) return s[1];
13
+ }
14
+ for (const r of e.slice(2))
15
+ if (!r.includes("batchkit") && !r.includes("node_modules")) {
16
+ const s = r.match(/at\s+.*?\s+\(?(.*?:\d+:\d+)\)?$/);
17
+ if (s) return s[1];
18
+ }
19
+ }
20
+ function He() {
21
+ const [n, e] = F({
22
+ batchers: /* @__PURE__ */ new Map(),
23
+ events: [],
24
+ batches: /* @__PURE__ */ new Map(),
25
+ selectedBatcher: null,
26
+ isOpen: !1,
27
+ config: {}
28
+ }), r = /* @__PURE__ */ new Set();
29
+ function s() {
30
+ const u = n();
31
+ for (const h of r)
32
+ h(u);
33
+ }
34
+ function t(u) {
35
+ e((h) => {
36
+ const l = new Map(h.batchers);
37
+ return l.set(u.name, u), { ...h, batchers: l };
38
+ }), s();
39
+ }
40
+ function i(u, h) {
41
+ const l = { ...h, batcherName: u };
42
+ e((w) => {
43
+ const p = [...w.events, l], v = new Map(w.batches);
44
+ if (l.type === "schedule") {
45
+ const S = {
46
+ batchId: l.batchId,
47
+ batcherName: u,
48
+ keys: [],
49
+ status: "scheduled",
50
+ scheduledAt: l.timestamp
51
+ };
52
+ v.set(l.batchId, S);
53
+ }
54
+ if (l.type === "dispatch") {
55
+ const S = v.get(l.batchId);
56
+ S && v.set(l.batchId, {
57
+ ...S,
58
+ keys: l.keys,
59
+ status: "dispatching",
60
+ dispatchedAt: l.timestamp
61
+ });
62
+ }
63
+ if (l.type === "resolve") {
64
+ const S = v.get(l.batchId);
65
+ S && v.set(l.batchId, {
66
+ ...S,
67
+ status: "resolved",
68
+ completedAt: l.timestamp,
69
+ duration: l.duration
70
+ });
71
+ }
72
+ if (l.type === "error") {
73
+ const S = v.get(l.batchId);
74
+ S && v.set(l.batchId, {
75
+ ...S,
76
+ status: "error",
77
+ completedAt: l.timestamp,
78
+ error: l.error
79
+ });
80
+ }
81
+ if (l.type === "abort") {
82
+ const S = v.get(l.batchId);
83
+ S && v.set(l.batchId, {
84
+ ...S,
85
+ status: "aborted",
86
+ completedAt: l.timestamp
87
+ });
88
+ }
89
+ return { ...w, events: p, batches: v };
90
+ }), s();
91
+ }
92
+ function d(u) {
93
+ return r.add(u), u(n()), () => r.delete(u);
94
+ }
95
+ function f() {
96
+ return n();
97
+ }
98
+ function c() {
99
+ e((u) => ({
100
+ ...u,
101
+ events: [],
102
+ batches: /* @__PURE__ */ new Map()
103
+ })), s();
104
+ }
105
+ function g() {
106
+ e((u) => ({ ...u, isOpen: !0 })), s();
107
+ }
108
+ function y() {
109
+ e((u) => ({ ...u, isOpen: !1 })), s();
110
+ }
111
+ function x() {
112
+ e((u) => ({ ...u, isOpen: !u.isOpen })), s();
113
+ }
114
+ return Fe({
115
+ onBatcherCreated({ fn: u, name: h, stack: l }) {
116
+ const w = !h, p = h ?? `unnamed-${++Ue}`, v = u.toString().slice(0, 500), S = Ke(l);
117
+ return t({
118
+ name: p,
119
+ registeredAt: performance.now(),
120
+ isUnnamed: w,
121
+ fnSource: v,
122
+ location: S
123
+ }), (T) => {
124
+ i(p, T);
125
+ };
126
+ }
127
+ }), {
128
+ subscribe: d,
129
+ getStore: f,
130
+ clear: c,
131
+ open: g,
132
+ close: y,
133
+ toggle: x,
134
+ _setStore: e,
135
+ _store: n
136
+ };
137
+ }
138
+ let B = null;
139
+ function Pe() {
140
+ if (typeof window > "u")
141
+ throw new Error("DevTools can only be used in browser environment");
142
+ return B || (B = Me(() => He())), B;
143
+ }
144
+ function Z() {
145
+ if (!B)
146
+ throw new Error(
147
+ "DevTools registry not initialized. Call initRegistry() first."
148
+ );
149
+ return B;
150
+ }
151
+ function Ce() {
152
+ const n = Z();
153
+ if (n._store)
154
+ return n._store;
155
+ const [e, r] = F(n.getStore());
156
+ return n.subscribe(r), e;
157
+ }
158
+ function Xe(n) {
159
+ var e;
160
+ B && ((e = B._setStore) == null || e.call(B, (r) => ({
161
+ ...r,
162
+ selectedBatcher: n
163
+ })));
164
+ }
165
+ function Ge(n) {
166
+ var e;
167
+ B && ((e = B._setStore) == null || e.call(B, (r) => ({
168
+ ...r,
169
+ config: { ...r.config, ...n }
170
+ })));
171
+ }
172
+ var We = /* @__PURE__ */ _("<div>"), Ye = /* @__PURE__ */ _("<div><div></div><div><span> gets</span><span> batches"), qe = /* @__PURE__ */ _("<div><div style=font-size:11px;color:#78716c;margin-bottom:4px>No batchers yet</div><div style=font-size:11px;color:#57534e>Call batch() to see it here");
173
+ const Ze = {
174
+ flex: "1",
175
+ "overflow-y": "auto"
176
+ }, ze = {
177
+ padding: "8px 12px",
178
+ cursor: "pointer",
179
+ "border-bottom": "1px solid #292524",
180
+ "border-left": "2px solid transparent"
181
+ }, Je = {
182
+ ...ze,
183
+ background: "#1c1917",
184
+ "border-left-color": "#a8a29e"
185
+ }, Te = {
186
+ "font-size": "13px",
187
+ color: "#d6d3d1",
188
+ "margin-bottom": "2px"
189
+ }, Qe = {
190
+ ...Te,
191
+ color: "#78716c",
192
+ "font-style": "italic"
193
+ }, Ve = {
194
+ "font-size": "11px",
195
+ color: "#78716c"
196
+ }, he = {
197
+ display: "inline-flex",
198
+ "align-items": "center",
199
+ gap: "4px",
200
+ "margin-right": "8px"
201
+ }, et = {
202
+ display: "flex",
203
+ "flex-direction": "column",
204
+ "align-items": "center",
205
+ "justify-content": "center",
206
+ height: "100%",
207
+ color: "#57534e",
208
+ "text-align": "center",
209
+ padding: "24px 12px"
210
+ }, tt = (n) => {
211
+ const e = ke(() => Array.from(n.batchers.values())), r = (t) => {
212
+ const i = n.events.filter((c) => c.batcherName === t), d = i.filter((c) => c.type === "get").length, f = i.filter((c) => c.type === "resolve").length;
213
+ return {
214
+ gets: d,
215
+ batches: f
216
+ };
217
+ }, s = (t) => {
218
+ n.selectedBatcher === t ? n.onSelect(null) : n.onSelect(t);
219
+ };
220
+ return (() => {
221
+ var t = We();
222
+ return o(t, Ze), m(t, z(ae, {
223
+ get each() {
224
+ return e();
225
+ },
226
+ children: (i) => {
227
+ const d = () => r(i.name), f = () => n.selectedBatcher === i.name;
228
+ return (() => {
229
+ var c = Ye(), g = c.firstChild, y = g.nextSibling, x = y.firstChild, k = x.firstChild, u = x.nextSibling, h = u.firstChild;
230
+ return c.$$click = () => s(i.name), m(g, () => i.name), o(y, Ve), m(x, () => d().gets, k), m(u, () => d().batches, h), I((l) => {
231
+ var w = f() ? Je : ze, p = i.isUnnamed ? Qe : Te, v = he, S = he;
232
+ return l.e = o(c, w, l.e), l.t = o(g, p, l.t), l.a = o(x, v, l.a), l.o = o(u, S, l.o), l;
233
+ }, {
234
+ e: void 0,
235
+ t: void 0,
236
+ a: void 0,
237
+ o: void 0
238
+ }), c;
239
+ })();
240
+ }
241
+ }), null), m(t, (() => {
242
+ var i = N(() => e().length === 0);
243
+ return () => i() && (() => {
244
+ var d = qe(), f = d.firstChild;
245
+ return f.nextSibling, o(d, et), d;
246
+ })();
247
+ })(), null), t;
248
+ })();
249
+ };
250
+ ne(["click"]);
251
+ var nt = /* @__PURE__ */ _("<div>"), rt = /* @__PURE__ */ _("<div><div style=font-size:11px;color:#78716c;margin-bottom:4px>No batches yet</div><div style=font-size:11px;color:#57534e>Batches appear as requests are processed"), ot = /* @__PURE__ */ _("<div><div></div><div></div><div></div><div>");
252
+ const it = {
253
+ display: "flex",
254
+ "flex-direction": "column",
255
+ gap: "1px"
256
+ }, st = {
257
+ display: "flex",
258
+ "align-items": "center",
259
+ gap: "12px",
260
+ padding: "6px 8px",
261
+ background: "#1c1917",
262
+ "font-size": "11px"
263
+ }, lt = {
264
+ "font-size": "11px",
265
+ color: "#78716c",
266
+ "min-width": "80px"
267
+ }, P = {
268
+ padding: "2px 6px",
269
+ "font-size": "10px",
270
+ "font-weight": "500",
271
+ "text-transform": "uppercase",
272
+ "letter-spacing": "0.3px"
273
+ }, ct = {
274
+ scheduled: {
275
+ ...P,
276
+ background: "#422006",
277
+ color: "#fbbf24"
278
+ },
279
+ dispatching: {
280
+ ...P,
281
+ background: "#1e3a5f",
282
+ color: "#60a5fa"
283
+ },
284
+ resolved: {
285
+ ...P,
286
+ background: "#14532d",
287
+ color: "#4ade80"
288
+ },
289
+ error: {
290
+ ...P,
291
+ background: "#450a0a",
292
+ color: "#f87171"
293
+ },
294
+ aborted: {
295
+ ...P,
296
+ background: "#292524",
297
+ color: "#a8a29e"
298
+ }
299
+ }, at = {
300
+ flex: "1",
301
+ "font-size": "11px",
302
+ color: "#a8a29e",
303
+ "white-space": "nowrap",
304
+ overflow: "hidden",
305
+ "text-overflow": "ellipsis"
306
+ }, dt = {
307
+ "font-size": "11px",
308
+ color: "#57534e",
309
+ "min-width": "50px",
310
+ "text-align": "right"
311
+ }, ut = {
312
+ display: "flex",
313
+ "flex-direction": "column",
314
+ "align-items": "center",
315
+ "justify-content": "center",
316
+ height: "100%",
317
+ color: "#57534e",
318
+ "text-align": "center",
319
+ padding: "32px"
320
+ }, ft = (n) => {
321
+ const e = (t) => t === void 0 ? "-" : t < 1 ? "<1ms" : t < 1e3 ? `${Math.round(t)}ms` : `${(t / 1e3).toFixed(2)}s`, r = (t) => {
322
+ if (t.length === 0) return "-";
323
+ const i = t.slice(0, 3).map((d) => String(d)).join(", ");
324
+ return t.length > 3 ? `${i} +${t.length - 3}` : i;
325
+ }, s = () => [...n.batches].sort((t, i) => i.scheduledAt - t.scheduledAt);
326
+ return (() => {
327
+ var t = nt();
328
+ return o(t, it), m(t, z(L, {
329
+ get when() {
330
+ return s().length > 0;
331
+ },
332
+ get fallback() {
333
+ return (() => {
334
+ var i = rt(), d = i.firstChild;
335
+ return d.nextSibling, o(i, ut), i;
336
+ })();
337
+ },
338
+ get children() {
339
+ return z(ae, {
340
+ get each() {
341
+ return s();
342
+ },
343
+ children: (i) => (() => {
344
+ var d = ot(), f = d.firstChild, c = f.nextSibling, g = c.nextSibling, y = g.nextSibling;
345
+ return o(d, st), o(f, lt), m(f, () => i.batchId), m(c, () => i.status), o(g, at), m(g, () => r(i.keys)), o(y, dt), m(y, () => e(i.duration)), I((x) => {
346
+ var k = ct[i.status] || P, u = i.keys.map(String).join(", ");
347
+ return x.e = o(c, k, x.e), u !== x.t && X(g, "title", x.t = u), x;
348
+ }, {
349
+ e: void 0,
350
+ t: void 0
351
+ }), d;
352
+ })()
353
+ });
354
+ }
355
+ })), t;
356
+ })();
357
+ };
358
+ var vt = /* @__PURE__ */ _("<div>"), gt = /* @__PURE__ */ _("<div><div style=font-size:11px;color:#78716c;margin-bottom:4px>No events</div><div style=font-size:11px;color:#57534e>Events appear as batchers process requests"), ht = /* @__PURE__ */ _("<div><span></span><span></span><span>");
359
+ const mt = {
360
+ display: "flex",
361
+ "flex-direction": "column",
362
+ gap: "1px",
363
+ "font-size": "11px"
364
+ }, pt = {
365
+ display: "flex",
366
+ gap: "12px",
367
+ padding: "4px 8px",
368
+ background: "#1c1917"
369
+ }, bt = {
370
+ color: "#57534e",
371
+ "min-width": "60px"
372
+ }, xt = {
373
+ "min-width": "60px",
374
+ "font-weight": "500"
375
+ }, yt = {
376
+ get: "#60a5fa",
377
+ dedup: "#c084fc",
378
+ schedule: "#fbbf24",
379
+ dispatch: "#22d3ee",
380
+ resolve: "#4ade80",
381
+ error: "#f87171",
382
+ abort: "#a8a29e"
383
+ }, St = {
384
+ color: "#78716c",
385
+ flex: "1",
386
+ "white-space": "nowrap",
387
+ overflow: "hidden",
388
+ "text-overflow": "ellipsis"
389
+ }, $t = {
390
+ display: "flex",
391
+ "flex-direction": "column",
392
+ "align-items": "center",
393
+ "justify-content": "center",
394
+ height: "100%",
395
+ color: "#57534e",
396
+ "text-align": "center",
397
+ padding: "32px"
398
+ }, wt = (n) => {
399
+ const e = (t) => (t / 1e3).toFixed(3) + "s", r = (t) => {
400
+ switch (t.type) {
401
+ case "get":
402
+ return `key: ${String(t.key)}`;
403
+ case "dedup":
404
+ return `key: ${String(t.key)} (dedup)`;
405
+ case "schedule":
406
+ return `batch: ${t.batchId}, size: ${t.size}`;
407
+ case "dispatch":
408
+ return `batch: ${t.batchId}, keys: [${t.keys.map(String).join(", ")}]`;
409
+ case "resolve":
410
+ return `batch: ${t.batchId}, ${t.duration.toFixed(1)}ms`;
411
+ case "error":
412
+ return `batch: ${t.batchId}, ${t.error.message}`;
413
+ case "abort":
414
+ return `batch: ${t.batchId}`;
415
+ default:
416
+ return "";
417
+ }
418
+ }, s = () => [...n.events].reverse();
419
+ return (() => {
420
+ var t = vt();
421
+ return o(t, mt), m(t, z(L, {
422
+ get when() {
423
+ return s().length > 0;
424
+ },
425
+ get fallback() {
426
+ return (() => {
427
+ var i = gt(), d = i.firstChild;
428
+ return d.nextSibling, o(i, $t), i;
429
+ })();
430
+ },
431
+ get children() {
432
+ return z(ae, {
433
+ get each() {
434
+ return s();
435
+ },
436
+ children: (i) => (() => {
437
+ var d = ht(), f = d.firstChild, c = f.nextSibling, g = c.nextSibling;
438
+ return o(d, pt), o(f, bt), m(f, () => e(i.timestamp)), m(c, () => i.type), o(g, St), m(g, () => r(i)), I((y) => o(c, {
439
+ ...xt,
440
+ color: yt[i.type]
441
+ }, y)), d;
442
+ })()
443
+ });
444
+ }
445
+ })), t;
446
+ })();
447
+ };
448
+ var _t = /* @__PURE__ */ _("<div><div><div>Gets</div><div></div></div><div><div>Batches</div><div></div></div><div><div>Deduped</div><div><span>(<!>%)</span></div></div><div><div>Avg Size</div><div></div></div><div><div>Avg Time</div><div><span>ms</span></div></div><div><div>Err / Abort</div><div><span></span><span style=color:#57534e> / </span><span>");
449
+ const kt = {
450
+ display: "grid",
451
+ "grid-template-columns": "repeat(auto-fit, minmax(120px, 1fr))",
452
+ gap: "1px",
453
+ background: "#292524"
454
+ }, U = {
455
+ padding: "12px",
456
+ background: "#1c1917"
457
+ }, K = {
458
+ "font-size": "11px",
459
+ "text-transform": "uppercase",
460
+ "letter-spacing": "0.5px",
461
+ color: "#78716c",
462
+ "margin-bottom": "4px"
463
+ }, H = {
464
+ "font-size": "20px",
465
+ "font-weight": "500",
466
+ color: "#f5f5f4"
467
+ }, me = {
468
+ "font-size": "11px",
469
+ color: "#57534e",
470
+ "margin-left": "2px"
471
+ }, Ct = (n) => {
472
+ const e = ke(() => {
473
+ const r = n.events, s = n.batches, t = r.filter((u) => u.type === "get").length, i = r.filter((u) => u.type === "dedup").length, d = s.filter((u) => u.status === "resolved"), f = d.length, c = f > 0 ? d.reduce((u, h) => u + h.keys.length, 0) / f : 0, g = f > 0 ? d.reduce((u, h) => u + (h.duration || 0), 0) / f : 0, y = s.filter((u) => u.status === "error").length, x = s.filter((u) => u.status === "aborted").length, k = t > 0 ? i / t * 100 : 0;
474
+ return {
475
+ totalGets: t,
476
+ totalBatches: f,
477
+ dedupedKeys: i,
478
+ avgBatchSize: c,
479
+ avgDuration: g,
480
+ errors: y,
481
+ aborts: x,
482
+ dedupRate: k
483
+ };
484
+ });
485
+ return (() => {
486
+ var r = _t(), s = r.firstChild, t = s.firstChild, i = t.nextSibling, d = s.nextSibling, f = d.firstChild, c = f.nextSibling, g = d.nextSibling, y = g.firstChild, x = y.nextSibling, k = x.firstChild, u = k.firstChild, h = u.nextSibling;
487
+ h.nextSibling;
488
+ var l = g.nextSibling, w = l.firstChild, p = w.nextSibling, v = l.nextSibling, S = v.firstChild, T = S.nextSibling, Q = T.firstChild, $ = v.nextSibling, C = $.firstChild, A = C.nextSibling, E = A.firstChild, O = E.nextSibling, R = O.nextSibling;
489
+ return o(r, kt), m(i, () => e().totalGets), m(c, () => e().totalBatches), m(x, () => e().dedupedKeys, k), m(k, () => e().dedupRate.toFixed(0), h), m(p, () => e().avgBatchSize.toFixed(1)), m(T, () => e().avgDuration.toFixed(0), Q), m(E, () => e().errors), m(R, () => e().aborts), I((a) => {
490
+ var G = U, D = K, j = H, W = U, Y = K, q = H, V = U, M = K, b = H, ee = me, re = U, oe = K, ie = H, se = U, le = K, ce = H, Ee = me, Ae = U, Oe = K, Re = H, fe = e().errors > 0 ? "#f87171" : "#f5f5f4", ve = e().aborts > 0 ? "#fbbf24" : "#f5f5f4";
491
+ return a.e = o(s, G, a.e), a.t = o(t, D, a.t), a.a = o(i, j, a.a), a.o = o(d, W, a.o), a.i = o(f, Y, a.i), a.n = o(c, q, a.n), a.s = o(g, V, a.s), a.h = o(y, M, a.h), a.r = o(x, b, a.r), a.d = o(k, ee, a.d), a.l = o(l, re, a.l), a.u = o(w, oe, a.u), a.c = o(p, ie, a.c), a.w = o(v, se, a.w), a.m = o(S, le, a.m), a.f = o(T, ce, a.f), a.y = o(Q, Ee, a.y), a.g = o($, Ae, a.g), a.p = o(C, Oe, a.p), a.b = o(A, Re, a.b), fe !== a.T && ge(E, "color", a.T = fe), ve !== a.A && ge(R, "color", a.A = ve), a;
492
+ }, {
493
+ e: void 0,
494
+ t: void 0,
495
+ a: void 0,
496
+ o: void 0,
497
+ i: void 0,
498
+ n: void 0,
499
+ s: void 0,
500
+ h: void 0,
501
+ r: void 0,
502
+ d: void 0,
503
+ l: void 0,
504
+ u: void 0,
505
+ c: void 0,
506
+ w: void 0,
507
+ m: void 0,
508
+ f: void 0,
509
+ y: void 0,
510
+ g: void 0,
511
+ p: void 0,
512
+ b: void 0,
513
+ T: void 0,
514
+ A: void 0
515
+ }), r;
516
+ })();
517
+ };
518
+ var pe = /* @__PURE__ */ _("<div>"), zt = /* @__PURE__ */ _("<div><div style=font-size:11px;color:#78716c;margin-bottom:4px>No batcher selected</div><div style=font-size:11px;color:#57534e>Click a batcher to see its trace info"), Tt = /* @__PURE__ */ _("<div><div>Function</div><div>"), Bt = /* @__PURE__ */ _('<div style="height:auto;padding:24px 0"><div style=font-size:11px;color:#57534e>No trace metadata available'), It = /* @__PURE__ */ _("<span style=color:#78716c;font-weight:normal;font-style:italic> (unnamed)"), Et = /* @__PURE__ */ _("<div><div>Location"), At = /* @__PURE__ */ _("<div>Set projectRoot to enable click-to-open"), Ot = /* @__PURE__ */ _("<div><div style=display:flex;align-items:center;justify-content:space-between;gap:8px><span style=overflow:hidden;text-overflow:ellipsis;white-space:nowrap></span><button>"), Rt = /* @__PURE__ */ _("<a><span style=overflow:hidden;text-overflow:ellipsis;white-space:nowrap></span><span style=color:#57534e;flex-shrink:0>↗ Open");
519
+ function Be(n) {
520
+ let e = n;
521
+ const r = n.match(/^https?:\/\/[^/]+(.*)$/);
522
+ r && (e = r[1]), e = e.split("?")[0];
523
+ const s = e.match(/^(.+?):(\d+)(?::(\d+))?$/);
524
+ return s ? {
525
+ path: s[1],
526
+ line: parseInt(s[2], 10),
527
+ column: s[3] ? parseInt(s[3], 10) : void 0
528
+ } : {
529
+ path: e
530
+ };
531
+ }
532
+ function Dt(n, e) {
533
+ if (!e.projectRoot) return null;
534
+ const r = Be(n);
535
+ if (!r) return null;
536
+ let {
537
+ path: s,
538
+ line: t,
539
+ column: i
540
+ } = r;
541
+ s.startsWith("/") && !s.startsWith("//") ? s = e.projectRoot + s : s.startsWith("/") || (s = e.projectRoot + "/" + s);
542
+ const d = e.editor ?? "vscode", c = {
543
+ vscode: "vscode://file",
544
+ cursor: "cursor://file",
545
+ webstorm: "webstorm://open?file=",
546
+ idea: "idea://open?file="
547
+ }[d];
548
+ if (!c) return null;
549
+ if (d === "webstorm" || d === "idea") {
550
+ let y = `${c}${encodeURIComponent(s)}`;
551
+ return t !== void 0 && (y += `&line=${t}`, i !== void 0 && (y += `&column=${i}`)), y;
552
+ }
553
+ let g = `${c}${s}`;
554
+ return t !== void 0 && (g += `:${t}`, i !== void 0 && (g += `:${i}`)), g;
555
+ }
556
+ function Lt(n) {
557
+ const e = Be(n);
558
+ if (!e) return n;
559
+ let r = e.path;
560
+ const s = r.split("/").filter(Boolean);
561
+ return s.length > 3 && (r = ".../" + s.slice(-3).join("/")), e.line !== void 0 && (r += `:${e.line}`, e.column !== void 0 && (r += `:${e.column}`)), r;
562
+ }
563
+ const jt = {
564
+ padding: "12px",
565
+ height: "100%",
566
+ "overflow-y": "auto"
567
+ }, be = {
568
+ display: "flex",
569
+ "flex-direction": "column",
570
+ "align-items": "center",
571
+ "justify-content": "center",
572
+ height: "100%",
573
+ color: "#57534e",
574
+ "text-align": "center"
575
+ }, xe = {
576
+ "margin-bottom": "16px"
577
+ }, ye = {
578
+ color: "#78716c",
579
+ "margin-bottom": "6px",
580
+ "font-size": "10px",
581
+ "text-transform": "uppercase",
582
+ "letter-spacing": "0.5px"
583
+ }, de = {
584
+ background: "#1c1917",
585
+ padding: "8px 10px",
586
+ "font-size": "11px",
587
+ color: "#d6d3d1",
588
+ border: "1px solid #292524"
589
+ }, Mt = {
590
+ ...de,
591
+ display: "flex",
592
+ "align-items": "center",
593
+ "justify-content": "space-between",
594
+ gap: "8px",
595
+ color: "#93c5fd",
596
+ "text-decoration": "none",
597
+ cursor: "pointer"
598
+ }, Nt = {
599
+ padding: "2px 6px",
600
+ background: "#292524",
601
+ border: "1px solid #44403c",
602
+ color: "#78716c",
603
+ "font-size": "10px",
604
+ cursor: "pointer",
605
+ "flex-shrink": "0"
606
+ }, Ft = {
607
+ "font-size": "10px",
608
+ color: "#57534e",
609
+ "margin-top": "6px",
610
+ "font-style": "italic"
611
+ }, Ut = {
612
+ ...de,
613
+ "white-space": "pre-wrap",
614
+ "word-break": "break-all",
615
+ "max-height": "300px",
616
+ "overflow-y": "auto",
617
+ "font-family": "ui-monospace, monospace"
618
+ }, Kt = {
619
+ "font-size": "14px",
620
+ "font-weight": "600",
621
+ color: "#f5f5f4",
622
+ "margin-bottom": "16px"
623
+ }, Ht = (n) => {
624
+ const e = Ce(), r = () => e().config, [s, t] = F(!1), i = async (d) => {
625
+ try {
626
+ await navigator.clipboard.writeText(d), t(!0), setTimeout(() => t(!1), 1500);
627
+ } catch {
628
+ const f = document.createElement("textarea");
629
+ f.value = d, document.body.appendChild(f), f.select(), document.execCommand("copy"), document.body.removeChild(f), t(!0), setTimeout(() => t(!1), 1500);
630
+ }
631
+ };
632
+ return (() => {
633
+ var d = pe();
634
+ return o(d, jt), m(d, z(L, {
635
+ get when() {
636
+ return n.batcher;
637
+ },
638
+ get fallback() {
639
+ return (() => {
640
+ var f = zt(), c = f.firstChild;
641
+ return c.nextSibling, I((g) => o(f, be, g)), f;
642
+ })();
643
+ },
644
+ children: (f) => [(() => {
645
+ var c = pe();
646
+ return o(c, Kt), m(c, () => f().name, null), m(c, (() => {
647
+ var g = N(() => !!f().isUnnamed);
648
+ return () => g() && It();
649
+ })(), null), c;
650
+ })(), z(L, {
651
+ get when() {
652
+ return f().location;
653
+ },
654
+ children: (c) => {
655
+ const g = () => Dt(c(), r()), y = () => Lt(c()), x = () => !!r().projectRoot;
656
+ return (() => {
657
+ var k = Et(), u = k.firstChild;
658
+ return m(k, z(L, {
659
+ get when() {
660
+ return g();
661
+ },
662
+ get fallback() {
663
+ return (() => {
664
+ var h = Ot(), l = h.firstChild, w = l.firstChild, p = w.nextSibling;
665
+ return m(w, y), p.$$mouseup = (v) => {
666
+ v.currentTarget.style.background = "#44403c";
667
+ }, p.$$mousedown = (v) => {
668
+ v.currentTarget.style.background = "#57534e";
669
+ }, p.$$mouseout = (v) => {
670
+ v.currentTarget.style.background = "#292524", v.currentTarget.style.color = "#78716c";
671
+ }, p.$$mouseover = (v) => {
672
+ v.currentTarget.style.background = "#44403c", v.currentTarget.style.color = "#a8a29e";
673
+ }, p.$$click = () => i(c()), o(p, Nt), m(p, () => s() ? "✓" : "Copy"), m(h, z(L, {
674
+ get when() {
675
+ return !x();
676
+ },
677
+ get children() {
678
+ var v = At();
679
+ return o(v, Ft), v;
680
+ }
681
+ }), null), I((v) => {
682
+ var S = {
683
+ ...de
684
+ }, T = c();
685
+ return v.e = o(l, S, v.e), T !== v.t && X(l, "title", v.t = T), v;
686
+ }, {
687
+ e: void 0,
688
+ t: void 0
689
+ }), h;
690
+ })();
691
+ },
692
+ children: (h) => (() => {
693
+ var l = Rt(), w = l.firstChild;
694
+ return w.nextSibling, l.$$mouseout = (p) => {
695
+ p.currentTarget.style.textDecoration = "none";
696
+ }, l.$$mouseover = (p) => {
697
+ p.currentTarget.style.textDecoration = "underline";
698
+ }, m(w, y), I((p) => {
699
+ var v = h(), S = Mt, T = `Open in ${r().editor ?? "vscode"}`;
700
+ return v !== p.e && X(l, "href", p.e = v), p.t = o(l, S, p.t), T !== p.a && X(l, "title", p.a = T), p;
701
+ }, {
702
+ e: void 0,
703
+ t: void 0,
704
+ a: void 0
705
+ }), l;
706
+ })()
707
+ }), null), I((h) => {
708
+ var l = xe, w = ye;
709
+ return h.e = o(k, l, h.e), h.t = o(u, w, h.t), h;
710
+ }, {
711
+ e: void 0,
712
+ t: void 0
713
+ }), k;
714
+ })();
715
+ }
716
+ }), z(L, {
717
+ get when() {
718
+ return f().fnSource;
719
+ },
720
+ get children() {
721
+ var c = Tt(), g = c.firstChild, y = g.nextSibling;
722
+ return m(y, () => f().fnSource), I((x) => {
723
+ var k = xe, u = ye, h = Ut;
724
+ return x.e = o(c, k, x.e), x.t = o(g, u, x.t), x.a = o(y, h, x.a), x;
725
+ }, {
726
+ e: void 0,
727
+ t: void 0,
728
+ a: void 0
729
+ }), c;
730
+ }
731
+ }), z(L, {
732
+ get when() {
733
+ return N(() => !f().location)() && !f().fnSource;
734
+ },
735
+ get children() {
736
+ var c = Bt();
737
+ return c.firstChild, I((g) => o(c, {
738
+ ...be
739
+ }, g)), c;
740
+ }
741
+ })]
742
+ })), d;
743
+ })();
744
+ };
745
+ ne(["click", "mouseover", "mouseout", "mousedown", "mouseup"]);
746
+ var Pt = /* @__PURE__ */ _("<button>");
747
+ const Ie = {
748
+ position: "fixed",
749
+ bottom: "16px",
750
+ right: "16px",
751
+ width: "40px",
752
+ height: "40px",
753
+ border: "1px solid #44403c",
754
+ background: "#1c1917",
755
+ color: "#a8a29e",
756
+ cursor: "pointer",
757
+ display: "flex",
758
+ "align-items": "center",
759
+ "justify-content": "center",
760
+ "z-index": "99999",
761
+ "font-family": "ui-monospace, monospace"
762
+ }, Xt = {
763
+ ...Ie,
764
+ background: "#292524",
765
+ color: "#f5f5f4",
766
+ "border-color": "#57534e"
767
+ }, Gt = {
768
+ background: "#44403c"
769
+ }, Wt = (n) => {
770
+ const [e, r] = F(!1), s = () => ({
771
+ ...n.isOpen ? Xt : Ie,
772
+ ...e() ? Gt : {},
773
+ ...n.style
774
+ });
775
+ return (() => {
776
+ var t = Pt();
777
+ return t.addEventListener("mouseleave", () => r(!1)), t.$$mouseup = () => r(!1), t.$$mousedown = () => r(!0), De(t, "click", n.onClick, !0), m(t, () => n.isOpen ? "[×]" : "[=]"), I((i) => {
778
+ var d = n.class, f = s(), c = n.isOpen ? "Close BatchKit DevTools" : "Open BatchKit DevTools", g = n.isOpen ? "Close BatchKit DevTools" : "Open BatchKit DevTools";
779
+ return d !== i.e && _e(t, i.e = d), i.t = o(t, f, i.t), c !== i.a && X(t, "title", i.a = c), g !== i.o && X(t, "aria-label", i.o = g), i;
780
+ }, {
781
+ e: void 0,
782
+ t: void 0,
783
+ a: void 0,
784
+ o: void 0
785
+ }), t;
786
+ })();
787
+ };
788
+ ne(["click", "mousedown", "mouseup"]);
789
+ var Yt = /* @__PURE__ */ _("<div><div></div><div><div><span style=color:#78716c>[=]</span>Devtools</div><button>Clear</button></div><div><div><div>Batchers</div></div><div><div><button>Timeline</button><button>Events</button><button>Stats</button><button>Trace</button></div><div>");
790
+ const ue = "__batchkit_devtools_", qt = 650, Zt = 350, Se = 200, $e = 1200, Jt = "0.2s";
791
+ function Qt(n) {
792
+ try {
793
+ const e = localStorage.getItem(ue + n);
794
+ return e === null ? void 0 : e === "true";
795
+ } catch {
796
+ return;
797
+ }
798
+ }
799
+ function Vt(n) {
800
+ try {
801
+ const e = localStorage.getItem(ue + n);
802
+ if (e === null) return;
803
+ const r = parseInt(e, 10);
804
+ return isNaN(r) ? void 0 : r;
805
+ } catch {
806
+ return;
807
+ }
808
+ }
809
+ function we(n, e) {
810
+ try {
811
+ localStorage.setItem(ue + n, String(e));
812
+ } catch {
813
+ }
814
+ }
815
+ function en(n, e, r) {
816
+ const s = {
817
+ position: "fixed",
818
+ background: "#0c0a09",
819
+ "border-color": "#44403c",
820
+ "border-style": "solid",
821
+ "border-width": "0",
822
+ display: "flex",
823
+ "flex-direction": "column",
824
+ overflow: "visible",
825
+ "z-index": "99998",
826
+ "font-family": "ui-monospace, monospace",
827
+ color: "#d6d3d1",
828
+ transition: r ? "none" : `transform ${Jt} ease-out`,
829
+ "box-shadow": "0 0 10px 0 rgba(0, 0, 0, 0.1)"
830
+ };
831
+ switch (n) {
832
+ case "right":
833
+ return {
834
+ ...s,
835
+ top: "0",
836
+ right: "0",
837
+ width: `${e}px`,
838
+ height: "100vh",
839
+ "border-left-width": "1px"
840
+ };
841
+ case "left":
842
+ return {
843
+ ...s,
844
+ top: "0",
845
+ left: "0",
846
+ width: `${e}px`,
847
+ height: "100vh",
848
+ "border-right-width": "1px"
849
+ };
850
+ case "bottom":
851
+ return {
852
+ ...s,
853
+ bottom: "0",
854
+ left: "0",
855
+ right: "0",
856
+ width: "100%",
857
+ height: `${e}px`,
858
+ "border-top-width": "1px"
859
+ };
860
+ }
861
+ }
862
+ function tn(n) {
863
+ const e = {
864
+ position: "absolute",
865
+ background: "transparent",
866
+ "z-index": "99999"
867
+ };
868
+ switch (n) {
869
+ case "right":
870
+ return {
871
+ ...e,
872
+ left: "-3px",
873
+ top: "0",
874
+ bottom: "0",
875
+ width: "6px",
876
+ cursor: "ew-resize"
877
+ };
878
+ case "left":
879
+ return {
880
+ ...e,
881
+ right: "-3px",
882
+ top: "0",
883
+ bottom: "0",
884
+ width: "6px",
885
+ cursor: "ew-resize"
886
+ };
887
+ case "bottom":
888
+ return {
889
+ ...e,
890
+ top: "-3px",
891
+ left: "0",
892
+ right: "0",
893
+ height: "6px",
894
+ cursor: "ns-resize"
895
+ };
896
+ }
897
+ }
898
+ function nn(n, e) {
899
+ if (e) return "translate(0, 0)";
900
+ switch (n) {
901
+ case "right":
902
+ return "translateX(100%)";
903
+ case "left":
904
+ return "translateX(-100%)";
905
+ case "bottom":
906
+ return "translateY(100%)";
907
+ }
908
+ }
909
+ const rn = {
910
+ display: "flex",
911
+ "align-items": "center",
912
+ "justify-content": "space-between",
913
+ padding: "8px 12px",
914
+ background: "#1c1917",
915
+ "border-bottom": "1px solid #44403c",
916
+ "flex-shrink": "0",
917
+ "user-select": "none"
918
+ }, on = {
919
+ "font-size": "11px",
920
+ "font-weight": "500",
921
+ color: "#a8a29e",
922
+ display: "flex",
923
+ "align-items": "center",
924
+ gap: "8px",
925
+ "text-transform": "uppercase",
926
+ "letter-spacing": "0.5px"
927
+ }, sn = {
928
+ padding: "4px 8px",
929
+ border: "1px solid #44403c",
930
+ background: "#1c1917",
931
+ color: "#78716c",
932
+ "font-size": "11px",
933
+ "font-family": "ui-monospace, monospace",
934
+ cursor: "pointer"
935
+ };
936
+ function ln(n, e, r = "#44403c") {
937
+ n.addEventListener("mousedown", () => {
938
+ n.style.background = r;
939
+ }), n.addEventListener("mouseup", () => {
940
+ n.style.background = e;
941
+ }), n.addEventListener("mouseleave", () => {
942
+ n.style.background = e;
943
+ });
944
+ }
945
+ const cn = {
946
+ display: "flex",
947
+ flex: "1",
948
+ "min-height": "0",
949
+ overflow: "hidden"
950
+ }, an = {
951
+ width: "160px",
952
+ "border-right": "1px solid #44403c",
953
+ display: "flex",
954
+ "flex-direction": "column",
955
+ background: "#0c0a09",
956
+ "flex-shrink": "0",
957
+ "user-select": "none"
958
+ }, dn = {
959
+ padding: "8px 12px",
960
+ "font-size": "11px",
961
+ "font-weight": "500",
962
+ "text-transform": "uppercase",
963
+ "letter-spacing": "0.5px",
964
+ color: "#78716c",
965
+ "border-bottom": "1px solid #292524"
966
+ }, un = {
967
+ flex: "1",
968
+ display: "flex",
969
+ "flex-direction": "column",
970
+ "min-width": "0"
971
+ }, fn = {
972
+ display: "flex",
973
+ "border-bottom": "1px solid #44403c",
974
+ background: "#1c1917",
975
+ "flex-shrink": "0",
976
+ "user-select": "none"
977
+ }, J = {
978
+ padding: "8px 12px",
979
+ "font-size": "11px",
980
+ "font-weight": "500",
981
+ color: "#78716c",
982
+ cursor: "pointer",
983
+ "border-bottom": "1px solid transparent",
984
+ "margin-bottom": "-1px",
985
+ background: "transparent",
986
+ border: "none",
987
+ "font-family": "ui-monospace, monospace"
988
+ }, te = {
989
+ ...J,
990
+ color: "#f5f5f4",
991
+ "border-bottom": "1px solid #f5f5f4"
992
+ }, vn = {
993
+ flex: "1",
994
+ overflow: "auto",
995
+ padding: "12px",
996
+ background: "#0c0a09"
997
+ }, gn = (n) => {
998
+ const e = Ce(), [r, s] = F("timeline"), [t, i] = F(!1), d = () => n.position ?? "right", f = () => d() === "bottom", c = () => f() ? Zt : qt, [g, y] = F(c());
999
+ Ne(() => {
1000
+ const $ = Qt("isOpen");
1001
+ $ !== void 0 ? $ && Z().open() : n.defaultOpen && Z().open();
1002
+ const C = Vt("panelSize");
1003
+ C && C >= Se && C <= $e && y(C);
1004
+ });
1005
+ const x = () => {
1006
+ Z().toggle(), we("isOpen", e().isOpen);
1007
+ }, k = ($) => {
1008
+ $.preventDefault(), i(!0);
1009
+ const C = f() ? $.clientY : $.clientX, A = g(), E = d(), O = (a) => {
1010
+ const G = f() ? a.clientY : a.clientX;
1011
+ let D = C - G;
1012
+ E === "left" && (D = -D);
1013
+ const j = Math.min($e, Math.max(Se, A + D));
1014
+ y(j);
1015
+ }, R = () => {
1016
+ i(!1), document.removeEventListener("mousemove", O), document.removeEventListener("mouseup", R), document.body.style.cursor = "", document.body.style.userSelect = "", we("panelSize", g());
1017
+ };
1018
+ document.addEventListener("mousemove", O), document.addEventListener("mouseup", R), document.body.style.cursor = f() ? "ns-resize" : "ew-resize", document.body.style.userSelect = "none";
1019
+ }, u = () => {
1020
+ Z().clear();
1021
+ }, h = () => e().selectedBatcher, l = () => e().batchers, w = () => e().events, p = () => e().batches, v = () => {
1022
+ const $ = h();
1023
+ return $ ? l().get($) ?? null : null;
1024
+ }, S = () => {
1025
+ const $ = h();
1026
+ return $ ? w().filter((C) => C.batcherName === $) : w();
1027
+ }, T = () => {
1028
+ const $ = h();
1029
+ return $ ? Array.from(p().values()).filter((C) => C.batcherName === $) : Array.from(p().values());
1030
+ }, Q = () => ({
1031
+ ...en(d(), g(), t()),
1032
+ transform: nn(d(), e().isOpen),
1033
+ ...n.panelStyle
1034
+ });
1035
+ return [z(Wt, {
1036
+ get isOpen() {
1037
+ return e().isOpen;
1038
+ },
1039
+ onClick: x,
1040
+ get style() {
1041
+ return n.buttonStyle;
1042
+ },
1043
+ get class() {
1044
+ return n.buttonClass;
1045
+ }
1046
+ }), (() => {
1047
+ var $ = Yt(), C = $.firstChild, A = C.nextSibling, E = A.firstChild;
1048
+ E.firstChild;
1049
+ var O = E.nextSibling, R = A.nextSibling, a = R.firstChild, G = a.firstChild, D = a.nextSibling, j = D.firstChild, W = j.firstChild, Y = W.nextSibling, q = Y.nextSibling, V = q.nextSibling, M = j.nextSibling;
1050
+ return C.$$mouseout = (b) => {
1051
+ t() || (b.currentTarget.style.background = "transparent");
1052
+ }, C.$$mouseover = (b) => {
1053
+ t() || (b.currentTarget.style.background = "#44403c");
1054
+ }, C.$$mousedown = k, o(A, rn), o(E, on), Le((b) => ln(b, "#1c1917"), O), O.$$click = u, o(O, sn), o(R, cn), o(a, an), o(G, dn), m(a, z(tt, {
1055
+ get batchers() {
1056
+ return l();
1057
+ },
1058
+ get events() {
1059
+ return w();
1060
+ },
1061
+ get selectedBatcher() {
1062
+ return h();
1063
+ },
1064
+ onSelect: Xe
1065
+ }), null), o(D, un), o(j, fn), W.$$click = () => s("timeline"), Y.$$click = () => s("events"), q.$$click = () => s("stats"), V.$$click = () => s("trace"), o(M, vn), m(M, (() => {
1066
+ var b = N(() => r() === "timeline");
1067
+ return () => b() && z(ft, {
1068
+ get batches() {
1069
+ return T();
1070
+ }
1071
+ });
1072
+ })(), null), m(M, (() => {
1073
+ var b = N(() => r() === "events");
1074
+ return () => b() && z(wt, {
1075
+ get events() {
1076
+ return S();
1077
+ }
1078
+ });
1079
+ })(), null), m(M, (() => {
1080
+ var b = N(() => r() === "stats");
1081
+ return () => b() && z(Ct, {
1082
+ get events() {
1083
+ return S();
1084
+ },
1085
+ get batches() {
1086
+ return T();
1087
+ }
1088
+ });
1089
+ })(), null), m(M, (() => {
1090
+ var b = N(() => r() === "trace");
1091
+ return () => b() && z(Ht, {
1092
+ get batcher() {
1093
+ return v();
1094
+ }
1095
+ });
1096
+ })(), null), I((b) => {
1097
+ var ee = n.panelClass, re = Q(), oe = {
1098
+ ...tn(d()),
1099
+ background: t() ? "#44403c" : "transparent"
1100
+ }, ie = r() === "timeline" ? te : J, se = r() === "events" ? te : J, le = r() === "stats" ? te : J, ce = r() === "trace" ? te : J;
1101
+ return ee !== b.e && _e($, b.e = ee), b.t = o($, re, b.t), b.a = o(C, oe, b.a), b.o = o(W, ie, b.o), b.i = o(Y, se, b.i), b.n = o(q, le, b.n), b.s = o(V, ce, b.s), b;
1102
+ }, {
1103
+ e: void 0,
1104
+ t: void 0,
1105
+ a: void 0,
1106
+ o: void 0,
1107
+ i: void 0,
1108
+ n: void 0,
1109
+ s: void 0
1110
+ }), $;
1111
+ })()];
1112
+ };
1113
+ ne(["mousedown", "mouseover", "mouseout", "click"]);
1114
+ function bn(n, e) {
1115
+ if (typeof window > "u")
1116
+ return () => {
1117
+ };
1118
+ Pe(), (e != null && e.projectRoot || e != null && e.editor) && Ge({
1119
+ projectRoot: e.projectRoot,
1120
+ editor: e.editor
1121
+ });
1122
+ const r = {
1123
+ position: e == null ? void 0 : e.position,
1124
+ defaultOpen: e == null ? void 0 : e.defaultOpen,
1125
+ buttonStyle: e == null ? void 0 : e.buttonStyle,
1126
+ buttonClass: e == null ? void 0 : e.buttonClass,
1127
+ panelStyle: e == null ? void 0 : e.panelStyle,
1128
+ panelClass: e == null ? void 0 : e.panelClass
1129
+ };
1130
+ return je(() => gn(r), n);
1131
+ }
1132
+ export {
1133
+ Ge as c,
1134
+ Z as g,
1135
+ Pe as i,
1136
+ bn as m,
1137
+ Ce as u
1138
+ };