@vscode/component-explorer 0.1.1-2 → 0.1.1-20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/LICENSE +21 -0
  2. package/SECURITY.md +14 -0
  3. package/dist/component-explorer.css +1 -0
  4. package/dist/components/Explorer.d.ts +9 -4
  5. package/dist/components/Explorer.d.ts.map +1 -1
  6. package/dist/components/ExplorerModel.d.ts +45 -3
  7. package/dist/components/ExplorerModel.d.ts.map +1 -1
  8. package/dist/components/FixturePreviewItem.d.ts +1 -1
  9. package/dist/components/FixturePreviewItem.d.ts.map +1 -1
  10. package/dist/components/FixtureScreenshotView.d.ts +12 -0
  11. package/dist/components/FixtureScreenshotView.d.ts.map +1 -0
  12. package/dist/components/LeftSidebar.d.ts.map +1 -1
  13. package/dist/components/PreviewArea.d.ts.map +1 -1
  14. package/dist/components/ReportComparisonRow.d.ts +16 -0
  15. package/dist/components/ReportComparisonRow.d.ts.map +1 -0
  16. package/dist/components/ScreenshotComparisonRow.d.ts +12 -0
  17. package/dist/components/ScreenshotComparisonRow.d.ts.map +1 -0
  18. package/dist/components/SearchInput.d.ts +6 -0
  19. package/dist/components/SearchInput.d.ts.map +1 -0
  20. package/dist/components/TitleBar.d.ts.map +1 -1
  21. package/dist/components/TreeView.d.ts.map +1 -1
  22. package/dist/components/index.d.ts +6 -2
  23. package/dist/components/index.d.ts.map +1 -1
  24. package/dist/components/treeFilter.d.ts +3 -0
  25. package/dist/components/treeFilter.d.ts.map +1 -0
  26. package/dist/components/types.d.ts +1 -0
  27. package/dist/components/types.d.ts.map +1 -1
  28. package/dist/core/CliRuntime.d.ts +50 -0
  29. package/dist/core/CliRuntime.d.ts.map +1 -0
  30. package/dist/core/ComponentRenderer.d.ts +14 -0
  31. package/dist/core/ComponentRenderer.d.ts.map +1 -0
  32. package/dist/core/ErrorInfo.d.ts +29 -0
  33. package/dist/core/ErrorInfo.d.ts.map +1 -0
  34. package/dist/core/FixtureNode.d.ts +4 -1
  35. package/dist/core/FixtureNode.d.ts.map +1 -1
  36. package/dist/core/FixtureRegistry.d.ts +2 -1
  37. package/dist/core/FixtureRegistry.d.ts.map +1 -1
  38. package/dist/core/fixtureApi.d.ts +353 -0
  39. package/dist/core/fixtureApi.d.ts.map +1 -0
  40. package/dist/core/fixtureApiConsumer.d.ts +85 -0
  41. package/dist/core/fixtureApiConsumer.d.ts.map +1 -0
  42. package/dist/core/index.d.ts +7 -6
  43. package/dist/core/index.d.ts.map +1 -1
  44. package/dist/daemon/DaemonConfig.d.ts +19 -0
  45. package/dist/daemon/DaemonConfig.d.ts.map +1 -0
  46. package/dist/daemon/DaemonModel.d.ts +59 -0
  47. package/dist/daemon/DaemonModel.d.ts.map +1 -0
  48. package/dist/daemon/index.d.ts +5 -0
  49. package/dist/daemon/index.d.ts.map +1 -0
  50. package/dist/index-BsQr630j.js +80 -0
  51. package/dist/index-BsQr630j.js.map +1 -0
  52. package/dist/index.d.ts +8 -28
  53. package/dist/index.d.ts.map +1 -1
  54. package/dist/index.js +7 -8693
  55. package/dist/index.js.map +1 -1
  56. package/dist/lib/fixtureFocusTrap.d.ts +2 -0
  57. package/dist/lib/fixtureFocusTrap.d.ts.map +1 -0
  58. package/dist/lib/fixtureSizeCache.d.ts +1 -10
  59. package/dist/lib/fixtureSizeCache.d.ts.map +1 -1
  60. package/dist/lib/queryParamObservable.d.ts +4 -0
  61. package/dist/lib/queryParamObservable.d.ts.map +1 -0
  62. package/dist/report/ReportModel.d.ts +23 -0
  63. package/dist/report/ReportModel.d.ts.map +1 -0
  64. package/dist/report/ScreenshotReport.d.ts +25 -0
  65. package/dist/report/ScreenshotReport.d.ts.map +1 -0
  66. package/dist/report/index.d.ts +3 -0
  67. package/dist/report/index.d.ts.map +1 -0
  68. package/dist/viewer.d.ts +52 -0
  69. package/dist/viewer.d.ts.map +1 -0
  70. package/dist/viewer.js +3903 -0
  71. package/dist/viewer.js.map +1 -0
  72. package/package.json +25 -4
  73. package/dist/core/ComponentDefinition.d.ts +0 -70
  74. package/dist/core/ComponentDefinition.d.ts.map +0 -1
  75. package/dist/core/defineFixture.d.ts +0 -109
  76. package/dist/core/defineFixture.d.ts.map +0 -1
  77. package/dist/index.css +0 -1
package/dist/viewer.js ADDED
@@ -0,0 +1,3903 @@
1
+ var Vt = Object.defineProperty;
2
+ var Mt = (r, e, t) => e in r ? Vt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var l = (r, e, t) => Mt(r, typeof e != "symbol" ? e + "" : e, t);
4
+ import { f as Re, a as Te, s as ke } from "./index-BsQr630j.js";
5
+ import { b as as, d as ds, c as cs, e as ls, g as hs } from "./index-BsQr630j.js";
6
+ import { createRoot as Ft } from "react-dom/client";
7
+ import { createContext as Ye, useReducer as Et, useState as Dt, useContext as Bt, useEffect as Ie, createElement as At } from "react";
8
+ import { jsx as a, jsxs as g, Fragment as me } from "react/jsx-runtime";
9
+ import { unstable_batchedUpdates as et } from "react-dom";
10
+ function ve(r) {
11
+ return typeof r == "object" && r !== null && ke in r && r[ke] === !0 && "_options" in r && typeof r._options == "object";
12
+ }
13
+ function be(r) {
14
+ return typeof r == "object" && r !== null && Re in r && r[Re] === !0 && "_entries" in r && typeof r._entries == "object";
15
+ }
16
+ function _e(r) {
17
+ return typeof r == "object" && r !== null && Te in r && r[Te] === !0 && "_variants" in r && typeof r._variants == "object";
18
+ }
19
+ function Xn(r) {
20
+ return ve(r) ? { success: !0, data: r } : be(r) ? { success: !0, data: r } : _e(r) ? { success: !0, data: r } : { success: !1, error: "Value is not a valid fixture export (missing brand symbol or _options/_entries/_variants)" };
21
+ }
22
+ function Yn(r) {
23
+ return ve(r) ? { success: !0, data: r } : { success: !1, error: "Value is not a SingleFixtureExport" };
24
+ }
25
+ function es(r) {
26
+ return be(r) ? { success: !0, data: r } : { success: !1, error: "Value is not a FixtureGroupExport" };
27
+ }
28
+ function ts(r) {
29
+ return _e(r) ? { success: !0, data: r } : { success: !1, error: "Value is not a FixtureVariantsExport" };
30
+ }
31
+ function Oe(r, e, t) {
32
+ const n = r._options;
33
+ return {
34
+ id: e,
35
+ name: t,
36
+ description: n.description,
37
+ isolation: n.isolation ?? "shadow-dom",
38
+ displayMode: n.displayMode ?? { type: "component" },
39
+ styles: n.styles,
40
+ background: n.background ?? "light",
41
+ labels: n.labels ?? [],
42
+ properties: n.properties ?? [],
43
+ render: n.render
44
+ };
45
+ }
46
+ function rs(r) {
47
+ return typeof r == "object" && r !== null && "render" in r && typeof r.render == "function" && "id" in r && "name" in r;
48
+ }
49
+ const $t = {
50
+ mobile: { width: 390, height: 844 },
51
+ tablet: { width: 768, height: 1024 },
52
+ desktop: { width: 1440, height: 900 }
53
+ };
54
+ function zt(r) {
55
+ return typeof r == "string" ? { name: r, ...$t[r] } : r;
56
+ }
57
+ function Lt(r) {
58
+ const e = {};
59
+ for (const t of r)
60
+ e[t.name] = t.defaultValue;
61
+ return e;
62
+ }
63
+ function Ne(r) {
64
+ if (r.startsWith("/"))
65
+ throw new Error(`Fixture path cannot start with '/': ${r}`);
66
+ if (r.includes("//"))
67
+ throw new Error(`Fixture path cannot contain empty segments: ${r}`);
68
+ if (r === "")
69
+ throw new Error("Fixture path cannot be empty (use undefined for default)");
70
+ }
71
+ function Ht(r, e) {
72
+ const t = jt(r);
73
+ if (e === void 0)
74
+ return [t];
75
+ if (e.endsWith("/")) {
76
+ const n = e.slice(0, -1);
77
+ if (n)
78
+ return Ne(n), [...n.split("/"), t];
79
+ throw new Error(`Fixture path cannot be just '/': ${e}`);
80
+ } else
81
+ return Ne(e), e.split("/");
82
+ }
83
+ function ie(r) {
84
+ const e = {
85
+ id: "",
86
+ name: "Components",
87
+ type: "folder",
88
+ children: [],
89
+ labels: []
90
+ };
91
+ for (const [t, n] of r) {
92
+ const s = "_path" in n ? n._path : void 0, o = Ht(t, s);
93
+ tt(e, o, n);
94
+ }
95
+ return e;
96
+ }
97
+ function jt(r) {
98
+ return (r.split("/").pop() ?? r).replace(/\.fixture\.(tsx?|jsx?)$/, "");
99
+ }
100
+ function tt(r, e, t, n = []) {
101
+ var c, u;
102
+ let s = r;
103
+ const o = [...n];
104
+ for (let h = 0; h < e.length - 1; h++) {
105
+ const p = e[h];
106
+ o.push(p);
107
+ const m = o.join("/");
108
+ let b = (c = s.children) == null ? void 0 : c.find(
109
+ (S) => S.type === "folder" && S.name === p
110
+ );
111
+ b || (b = {
112
+ id: m,
113
+ name: p,
114
+ type: "folder",
115
+ children: [],
116
+ labels: []
117
+ }, s.children || (s.children = []), s.children.push(b)), s = b;
118
+ }
119
+ const i = e[e.length - 1];
120
+ o.push(i);
121
+ const d = o.join("/");
122
+ if (ve(t)) {
123
+ const h = Oe(t, d, i), p = {
124
+ id: d,
125
+ name: i,
126
+ type: "component",
127
+ component: h,
128
+ labels: [...h.labels]
129
+ };
130
+ s.children || (s.children = []), s.children.push(p);
131
+ } else if (be(t)) {
132
+ let h = (u = s.children) == null ? void 0 : u.find(
133
+ (p) => p.type === "folder" && p.name === i
134
+ );
135
+ h || (h = {
136
+ id: d,
137
+ name: i,
138
+ type: "folder",
139
+ children: [],
140
+ labels: [...t._labels ?? []]
141
+ }, s.children || (s.children = []), s.children.push(h));
142
+ for (const [p, m] of Object.entries(t._entries))
143
+ tt(h, [p], m, o);
144
+ } else if (_e(t)) {
145
+ const h = {
146
+ id: d,
147
+ name: i,
148
+ type: "variants",
149
+ children: [],
150
+ labels: [...t._labels ?? []]
151
+ };
152
+ s.children || (s.children = []), s.children.push(h);
153
+ for (const [p, m] of Object.entries(t._variants)) {
154
+ const b = [...o, p].join("/"), S = {
155
+ id: b,
156
+ name: p,
157
+ type: "component",
158
+ component: Oe(m, b, p),
159
+ labels: [...m._options.labels ?? []]
160
+ };
161
+ h.children.push(S);
162
+ }
163
+ }
164
+ }
165
+ function Ve(r, e) {
166
+ if (e.length === 0)
167
+ return r;
168
+ let t = r;
169
+ for (const n of e) {
170
+ if (!t || !t.children)
171
+ return;
172
+ t = t.children.find((s) => s.name === n);
173
+ }
174
+ return t;
175
+ }
176
+ function Ut(r) {
177
+ if (r.type === "component" && r.component)
178
+ return [r.component];
179
+ const e = [];
180
+ for (const t of r.children ?? [])
181
+ e.push(...Ut(t));
182
+ return e;
183
+ }
184
+ let L;
185
+ function Pt(r) {
186
+ L ? L instanceof Me ? L.loggers.push(r) : L = new Me([L, r]) : L = r;
187
+ }
188
+ function y() {
189
+ return L;
190
+ }
191
+ let ae;
192
+ function Wt(r) {
193
+ ae = r;
194
+ }
195
+ function Gt(r) {
196
+ ae && ae(r);
197
+ }
198
+ class Me {
199
+ constructor(e) {
200
+ this.loggers = e;
201
+ }
202
+ handleObservableCreated(e, t) {
203
+ for (const n of this.loggers)
204
+ n.handleObservableCreated(e, t);
205
+ }
206
+ handleOnListenerCountChanged(e, t) {
207
+ for (const n of this.loggers)
208
+ n.handleOnListenerCountChanged(e, t);
209
+ }
210
+ handleObservableUpdated(e, t) {
211
+ for (const n of this.loggers)
212
+ n.handleObservableUpdated(e, t);
213
+ }
214
+ handleAutorunCreated(e, t) {
215
+ for (const n of this.loggers)
216
+ n.handleAutorunCreated(e, t);
217
+ }
218
+ handleAutorunDisposed(e) {
219
+ for (const t of this.loggers)
220
+ t.handleAutorunDisposed(e);
221
+ }
222
+ handleAutorunDependencyChanged(e, t, n) {
223
+ for (const s of this.loggers)
224
+ s.handleAutorunDependencyChanged(e, t, n);
225
+ }
226
+ handleAutorunStarted(e) {
227
+ for (const t of this.loggers)
228
+ t.handleAutorunStarted(e);
229
+ }
230
+ handleAutorunFinished(e) {
231
+ for (const t of this.loggers)
232
+ t.handleAutorunFinished(e);
233
+ }
234
+ handleDerivedDependencyChanged(e, t, n) {
235
+ for (const s of this.loggers)
236
+ s.handleDerivedDependencyChanged(e, t, n);
237
+ }
238
+ handleDerivedCleared(e) {
239
+ for (const t of this.loggers)
240
+ t.handleDerivedCleared(e);
241
+ }
242
+ handleBeginTransaction(e) {
243
+ for (const t of this.loggers)
244
+ t.handleBeginTransaction(e);
245
+ }
246
+ handleEndTransaction(e) {
247
+ for (const t of this.loggers)
248
+ t.handleEndTransaction(e);
249
+ }
250
+ }
251
+ var V;
252
+ (function(r) {
253
+ let e = !1;
254
+ function t() {
255
+ e = !0;
256
+ }
257
+ r.enable = t;
258
+ function n() {
259
+ return s(1);
260
+ }
261
+ r.ofCaller = n;
262
+ function s(o) {
263
+ if (!e)
264
+ return;
265
+ const i = Error, d = i.stackTraceLimit;
266
+ i.stackTraceLimit = 3;
267
+ const c = new Error().stack;
268
+ return i.stackTraceLimit = d, ye.fromStack(c, o + 1);
269
+ }
270
+ r.ofNthCaller = s;
271
+ })(V || (V = {}));
272
+ class ye {
273
+ static fromStack(e, t) {
274
+ const n = e.split(`
275
+ `), s = qt(n[t + 1]);
276
+ if (s)
277
+ return new ye(s.fileName, s.line, s.column, s.id);
278
+ }
279
+ constructor(e, t, n, s) {
280
+ this.fileName = e, this.line = t, this.column = n, this.id = s;
281
+ }
282
+ }
283
+ function qt(r) {
284
+ if (!r)
285
+ return;
286
+ const e = r.match(/\((.*):(\d+):(\d+)\)/);
287
+ if (e)
288
+ return {
289
+ fileName: e[1],
290
+ line: parseInt(e[2]),
291
+ column: parseInt(e[3]),
292
+ id: r
293
+ };
294
+ const t = r.match(/at ([^\(\)]*):(\d+):(\d+)/);
295
+ if (t)
296
+ return {
297
+ fileName: t[1],
298
+ line: parseInt(t[2]),
299
+ column: parseInt(t[3]),
300
+ id: r
301
+ };
302
+ }
303
+ class D {
304
+ constructor(e, t, n) {
305
+ this.owner = e, this.debugNameSource = t, this.referenceFn = n;
306
+ }
307
+ getDebugName(e) {
308
+ return Kt(e, this);
309
+ }
310
+ }
311
+ const Fe = /* @__PURE__ */ new Map(), de = /* @__PURE__ */ new WeakMap();
312
+ function Kt(r, e) {
313
+ const t = de.get(r);
314
+ if (t)
315
+ return t;
316
+ const n = Jt(r, e);
317
+ if (n) {
318
+ let s = Fe.get(n) ?? 0;
319
+ s++, Fe.set(n, s);
320
+ const o = s === 1 ? n : `${n}#${s}`;
321
+ return de.set(r, o), o;
322
+ }
323
+ }
324
+ function Jt(r, e) {
325
+ const t = de.get(r);
326
+ if (t)
327
+ return t;
328
+ const n = e.owner ? Zt(e.owner) + "." : "";
329
+ let s;
330
+ const o = e.debugNameSource;
331
+ if (o !== void 0)
332
+ if (typeof o == "function") {
333
+ if (s = o(), s !== void 0)
334
+ return n + s;
335
+ } else
336
+ return n + o;
337
+ const i = e.referenceFn;
338
+ if (i !== void 0 && (s = xe(i), s !== void 0))
339
+ return n + s;
340
+ if (e.owner !== void 0) {
341
+ const d = Qt(e.owner, r);
342
+ if (d !== void 0)
343
+ return n + d;
344
+ }
345
+ }
346
+ function Qt(r, e) {
347
+ for (const t in r)
348
+ if (r[t] === e)
349
+ return t;
350
+ }
351
+ const Ee = /* @__PURE__ */ new Map(), De = /* @__PURE__ */ new WeakMap();
352
+ function Zt(r) {
353
+ const e = De.get(r);
354
+ if (e)
355
+ return e;
356
+ const t = rt(r) ?? "Object";
357
+ let n = Ee.get(t) ?? 0;
358
+ n++, Ee.set(t, n);
359
+ const s = n === 1 ? t : `${t}#${n}`;
360
+ return De.set(r, s), s;
361
+ }
362
+ function rt(r) {
363
+ const e = r.constructor;
364
+ if (e)
365
+ return e.name === "Object" ? void 0 : e.name;
366
+ }
367
+ function xe(r) {
368
+ const e = r.toString(), n = /\/\*\*\s*@description\s*([^*]*)\*\//.exec(e), s = n ? n[1] : void 0;
369
+ return s == null ? void 0 : s.trim();
370
+ }
371
+ let ce;
372
+ function Xt(r) {
373
+ ce = r;
374
+ }
375
+ let nt;
376
+ function Yt(r) {
377
+ nt = r;
378
+ }
379
+ let st;
380
+ function er(r) {
381
+ st = r;
382
+ }
383
+ let ot;
384
+ function tr(r) {
385
+ ot = r;
386
+ }
387
+ class rr {
388
+ get TChange() {
389
+ return null;
390
+ }
391
+ reportChanges() {
392
+ this.get();
393
+ }
394
+ /** @sealed */
395
+ read(e) {
396
+ return e ? e.readObservable(this) : this.get();
397
+ }
398
+ map(e, t, n = V.ofCaller()) {
399
+ const s = t === void 0 ? void 0 : e, o = t === void 0 ? e : t;
400
+ return ce({
401
+ owner: s,
402
+ debugName: () => {
403
+ const i = xe(o);
404
+ if (i !== void 0)
405
+ return i;
406
+ const c = /^\s*\(?\s*([a-zA-Z_$][a-zA-Z_$0-9]*)\s*\)?\s*=>\s*\1(?:\??)\.([a-zA-Z_$][a-zA-Z_$0-9]*)\s*$/.exec(o.toString());
407
+ if (c)
408
+ return `${this.debugName}.${c[2]}`;
409
+ if (!s)
410
+ return `${this.debugName} (mapped)`;
411
+ },
412
+ debugReferenceFn: o
413
+ }, (i) => o(this.read(i), i), n);
414
+ }
415
+ /**
416
+ * @sealed
417
+ * Converts an observable of an observable value into a direct observable of the value.
418
+ */
419
+ flatten() {
420
+ return ce({
421
+ owner: void 0,
422
+ debugName: () => `${this.debugName} (flattened)`
423
+ }, (e) => this.read(e).read(e));
424
+ }
425
+ recomputeInitiallyAndOnChange(e, t) {
426
+ return e.add(nt(this, t)), this;
427
+ }
428
+ /**
429
+ * Ensures that this observable is observed. This keeps the cache alive.
430
+ * However, in case of deriveds, it does not force eager evaluation (only when the value is read/get).
431
+ * Use `recomputeInitiallyAndOnChange` for eager evaluation.
432
+ */
433
+ keepObserved(e) {
434
+ return e.add(st(this)), this;
435
+ }
436
+ get debugValue() {
437
+ return this.get();
438
+ }
439
+ debugGetDependencyGraph() {
440
+ return ot(this);
441
+ }
442
+ }
443
+ class Se extends rr {
444
+ constructor(e) {
445
+ var t;
446
+ super(), this._observers = /* @__PURE__ */ new Set(), (t = y()) == null || t.handleObservableCreated(this, e);
447
+ }
448
+ addObserver(e) {
449
+ var n;
450
+ const t = this._observers.size;
451
+ this._observers.add(e), t === 0 && this.onFirstObserverAdded(), t !== this._observers.size && ((n = y()) == null || n.handleOnListenerCountChanged(this, this._observers.size));
452
+ }
453
+ removeObserver(e) {
454
+ var n;
455
+ const t = this._observers.delete(e);
456
+ t && this._observers.size === 0 && this.onLastObserverRemoved(), t && ((n = y()) == null || n.handleOnListenerCountChanged(this, this._observers.size));
457
+ }
458
+ onFirstObserverAdded() {
459
+ }
460
+ onLastObserverRemoved() {
461
+ }
462
+ log() {
463
+ var t;
464
+ const e = !!y();
465
+ return Gt(this), e || (t = y()) == null || t.handleObservableCreated(this, V.ofCaller()), this;
466
+ }
467
+ debugGetObservers() {
468
+ return this._observers;
469
+ }
470
+ }
471
+ function it(r) {
472
+ return {
473
+ dispose: r
474
+ };
475
+ }
476
+ class j extends Error {
477
+ constructor(e) {
478
+ super(e || "An unexpected bug occurred."), Object.setPrototypeOf(this, j.prototype);
479
+ }
480
+ }
481
+ function re(r) {
482
+ throw r;
483
+ }
484
+ function nr(r) {
485
+ console.error("Unexpected error:", r);
486
+ }
487
+ const X = (r, e) => r === e;
488
+ class Y {
489
+ constructor() {
490
+ this.disposables = [], this._isDisposed = !1;
491
+ }
492
+ get isDisposed() {
493
+ return this._isDisposed;
494
+ }
495
+ dispose() {
496
+ this.clear(), this._isDisposed = !0;
497
+ }
498
+ add(e) {
499
+ return e && this.disposables.push(e), e;
500
+ }
501
+ remove(e) {
502
+ if (!e)
503
+ return e;
504
+ const t = this.disposables.indexOf(e);
505
+ return t !== -1 && this.disposables.splice(t, 1), e;
506
+ }
507
+ clear() {
508
+ for (const e of this.disposables)
509
+ e.dispose();
510
+ this.disposables = [];
511
+ }
512
+ leakItems() {
513
+ this.disposables = [];
514
+ }
515
+ }
516
+ function sr(r) {
517
+ switch (r) {
518
+ case 0:
519
+ return "initial";
520
+ case 1:
521
+ return "dependenciesMightHaveChanged";
522
+ case 2:
523
+ return "stale";
524
+ case 3:
525
+ return "upToDate";
526
+ default:
527
+ return "<unknown>";
528
+ }
529
+ }
530
+ class U extends Se {
531
+ get debugName() {
532
+ return this._debugNameData.getDebugName(this) ?? "(anonymous)";
533
+ }
534
+ constructor(e, t, n, s = void 0, o, i) {
535
+ var d;
536
+ super(i), this._debugNameData = e, this._computeFn = t, this._changeTracker = n, this._handleLastObserverRemoved = s, this._equalityComparator = o, this._state = 0, this._value = void 0, this._updateCount = 0, this._dependencies = /* @__PURE__ */ new Set(), this._dependenciesToBeRemoved = /* @__PURE__ */ new Set(), this._changeSummary = void 0, this._isUpdating = !1, this._isComputing = !1, this._didReportChange = !1, this._isInBeforeUpdate = !1, this._isReaderValid = !1, this._store = void 0, this._delayedStore = void 0, this._removedObserverToCallEndUpdateOn = null, this._changeSummary = (d = this._changeTracker) == null ? void 0 : d.createChangeSummary(void 0);
537
+ }
538
+ onLastObserverRemoved() {
539
+ var e, t;
540
+ this._state = 0, this._value = void 0, (e = y()) == null || e.handleDerivedCleared(this);
541
+ for (const n of this._dependencies)
542
+ n.removeObserver(this);
543
+ this._dependencies.clear(), this._store !== void 0 && (this._store.dispose(), this._store = void 0), this._delayedStore !== void 0 && (this._delayedStore.dispose(), this._delayedStore = void 0), (t = this._handleLastObserverRemoved) == null || t.call(this);
544
+ }
545
+ get() {
546
+ var t, n;
547
+ if (this._isComputing, this._observers.size === 0) {
548
+ let s;
549
+ try {
550
+ this._isReaderValid = !0;
551
+ let o;
552
+ this._changeTracker && (o = this._changeTracker.createChangeSummary(void 0), (n = (t = this._changeTracker).beforeUpdate) == null || n.call(t, this, o)), s = this._computeFn(this, o);
553
+ } finally {
554
+ this._isReaderValid = !1;
555
+ }
556
+ return this.onLastObserverRemoved(), s;
557
+ } else {
558
+ do {
559
+ if (this._state === 1) {
560
+ for (const s of this._dependencies)
561
+ if (s.reportChanges(), this._state === 2)
562
+ break;
563
+ }
564
+ this._state === 1 && (this._state = 3), this._state !== 3 && this._recompute();
565
+ } while (this._state !== 3);
566
+ return this._value;
567
+ }
568
+ }
569
+ _recompute() {
570
+ var n, s, o, i;
571
+ let e = !1;
572
+ this._isComputing = !0, this._didReportChange = !1;
573
+ const t = this._dependenciesToBeRemoved;
574
+ this._dependenciesToBeRemoved = this._dependencies, this._dependencies = t;
575
+ try {
576
+ const d = this._changeSummary;
577
+ this._isReaderValid = !0, this._changeTracker && (this._isInBeforeUpdate = !0, (s = (n = this._changeTracker).beforeUpdate) == null || s.call(n, this, d), this._isInBeforeUpdate = !1, this._changeSummary = (o = this._changeTracker) == null ? void 0 : o.createChangeSummary(d));
578
+ const c = this._state !== 0, u = this._value;
579
+ this._state = 3;
580
+ const h = this._delayedStore;
581
+ h !== void 0 && (this._delayedStore = void 0);
582
+ try {
583
+ this._store !== void 0 && (this._store.dispose(), this._store = void 0), this._value = this._computeFn(this, d);
584
+ } finally {
585
+ this._isReaderValid = !1;
586
+ for (const p of this._dependenciesToBeRemoved)
587
+ p.removeObserver(this);
588
+ this._dependenciesToBeRemoved.clear(), h !== void 0 && h.dispose();
589
+ }
590
+ e = this._didReportChange || c && !this._equalityComparator(u, this._value), (i = y()) == null || i.handleObservableUpdated(this, {
591
+ oldValue: u,
592
+ newValue: this._value,
593
+ change: void 0,
594
+ didChange: e,
595
+ hadValue: c
596
+ });
597
+ } catch (d) {
598
+ re(d);
599
+ }
600
+ if (this._isComputing = !1, !this._didReportChange && e)
601
+ for (const d of this._observers)
602
+ d.handleChange(this, void 0);
603
+ else
604
+ this._didReportChange = !1;
605
+ }
606
+ toString() {
607
+ return `LazyDerived<${this.debugName}>`;
608
+ }
609
+ // IObserver Implementation
610
+ beginUpdate(e) {
611
+ if (this._isUpdating)
612
+ throw new j("Cyclic deriveds are not supported yet!");
613
+ this._updateCount++, this._isUpdating = !0;
614
+ try {
615
+ const t = this._updateCount === 1;
616
+ if (this._state === 3 && (this._state = 1, !t))
617
+ for (const n of this._observers)
618
+ n.handlePossibleChange(this);
619
+ if (t)
620
+ for (const n of this._observers)
621
+ n.beginUpdate(this);
622
+ } finally {
623
+ this._isUpdating = !1;
624
+ }
625
+ }
626
+ endUpdate(e) {
627
+ if (this._updateCount--, this._updateCount === 0) {
628
+ const t = [...this._observers];
629
+ for (const n of t)
630
+ n.endUpdate(this);
631
+ if (this._removedObserverToCallEndUpdateOn) {
632
+ const n = [...this._removedObserverToCallEndUpdateOn];
633
+ this._removedObserverToCallEndUpdateOn = null;
634
+ for (const s of n)
635
+ s.endUpdate(this);
636
+ }
637
+ }
638
+ }
639
+ handlePossibleChange(e) {
640
+ if (this._state === 3 && this._dependencies.has(e) && !this._dependenciesToBeRemoved.has(e)) {
641
+ this._state = 1;
642
+ for (const t of this._observers)
643
+ t.handlePossibleChange(this);
644
+ }
645
+ }
646
+ handleChange(e, t) {
647
+ var n;
648
+ if (this._dependencies.has(e) && !this._dependenciesToBeRemoved.has(e) || this._isInBeforeUpdate) {
649
+ (n = y()) == null || n.handleDerivedDependencyChanged(this, e, t);
650
+ let s = !1;
651
+ try {
652
+ s = this._changeTracker ? this._changeTracker.handleChange({
653
+ changedObservable: e,
654
+ change: t,
655
+ didChange: (i) => i === e
656
+ }, this._changeSummary) : !0;
657
+ } catch (i) {
658
+ re(i);
659
+ }
660
+ const o = this._state === 3;
661
+ if (s && (this._state === 1 || o) && (this._state = 2, o))
662
+ for (const i of this._observers)
663
+ i.handlePossibleChange(this);
664
+ }
665
+ }
666
+ // IReader Implementation
667
+ _ensureReaderValid() {
668
+ if (!this._isReaderValid)
669
+ throw new j("The reader object cannot be used outside its compute function!");
670
+ }
671
+ readObservable(e) {
672
+ this._ensureReaderValid(), e.addObserver(this);
673
+ const t = e.get();
674
+ return this._dependencies.add(e), this._dependenciesToBeRemoved.delete(e), t;
675
+ }
676
+ reportChange(e) {
677
+ this._ensureReaderValid(), this._didReportChange = !0;
678
+ for (const t of this._observers)
679
+ t.handleChange(this, e);
680
+ }
681
+ get store() {
682
+ return this._ensureReaderValid(), this._store === void 0 && (this._store = new Y()), this._store;
683
+ }
684
+ get delayedStore() {
685
+ return this._ensureReaderValid(), this._delayedStore === void 0 && (this._delayedStore = new Y()), this._delayedStore;
686
+ }
687
+ addObserver(e) {
688
+ const t = !this._observers.has(e) && this._updateCount > 0;
689
+ super.addObserver(e), t && (this._removedObserverToCallEndUpdateOn && this._removedObserverToCallEndUpdateOn.has(e) ? this._removedObserverToCallEndUpdateOn.delete(e) : e.beginUpdate(this));
690
+ }
691
+ removeObserver(e) {
692
+ this._observers.has(e) && this._updateCount > 0 && (this._removedObserverToCallEndUpdateOn || (this._removedObserverToCallEndUpdateOn = /* @__PURE__ */ new Set()), this._removedObserverToCallEndUpdateOn.add(e)), super.removeObserver(e);
693
+ }
694
+ debugGetState() {
695
+ return {
696
+ state: this._state,
697
+ stateStr: sr(this._state),
698
+ updateCount: this._updateCount,
699
+ isComputing: this._isComputing,
700
+ dependencies: this._dependencies,
701
+ value: this._value
702
+ };
703
+ }
704
+ debugSetValue(e) {
705
+ this._value = e;
706
+ }
707
+ debugRecompute() {
708
+ this._isComputing ? this._state = 2 : this._recompute();
709
+ }
710
+ setValue(e, t, n) {
711
+ this._value = e;
712
+ const s = this._observers;
713
+ t.updateObserver(this, this);
714
+ for (const o of s)
715
+ o.handleChange(this, n);
716
+ }
717
+ }
718
+ function O(r, e, t = V.ofCaller()) {
719
+ return e !== void 0 ? new U(new D(r, void 0, e), e, void 0, void 0, X, t) : new U(new D(void 0, void 0, r), r, void 0, void 0, X, t);
720
+ }
721
+ function or(r, e, t = V.ofCaller()) {
722
+ return new U(new D(r.owner, r.debugName, r.debugReferenceFn), e, void 0, r.onLastObserverRemoved, r.equalsFn ?? X, t);
723
+ }
724
+ Xt(or);
725
+ function ir(r, e, t = V.ofCaller()) {
726
+ let n, s;
727
+ n = r, s = void 0;
728
+ let o;
729
+ return new U(new D(s, void 0, n), (i) => {
730
+ o ? o.clear() : o = new Y();
731
+ const d = n(i);
732
+ return d && o.add(d), d;
733
+ }, void 0, () => {
734
+ o && (o.dispose(), o = void 0);
735
+ }, X, t);
736
+ }
737
+ function ar(r) {
738
+ switch (r) {
739
+ case 1:
740
+ return "dependenciesMightHaveChanged";
741
+ case 2:
742
+ return "stale";
743
+ case 3:
744
+ return "upToDate";
745
+ default:
746
+ return "<unknown>";
747
+ }
748
+ }
749
+ class at {
750
+ get debugName() {
751
+ return this._debugNameData.getDebugName(this) ?? "(anonymous)";
752
+ }
753
+ constructor(e, t, n, s) {
754
+ var o, i;
755
+ this._debugNameData = e, this._runFn = t, this._changeTracker = n, this._state = 2, this._updateCount = 0, this._disposed = !1, this._dependencies = /* @__PURE__ */ new Set(), this._dependenciesToBeRemoved = /* @__PURE__ */ new Set(), this._isRunning = !1, this._store = void 0, this._delayedStore = void 0, this._changeSummary = (o = this._changeTracker) == null ? void 0 : o.createChangeSummary(void 0), (i = y()) == null || i.handleAutorunCreated(this, s), this._run();
756
+ }
757
+ dispose() {
758
+ var e;
759
+ if (!this._disposed) {
760
+ this._disposed = !0;
761
+ for (const t of this._dependencies)
762
+ t.removeObserver(this);
763
+ this._dependencies.clear(), this._store !== void 0 && this._store.dispose(), this._delayedStore !== void 0 && this._delayedStore.dispose(), (e = y()) == null || e.handleAutorunDisposed(this);
764
+ }
765
+ }
766
+ _run() {
767
+ var t, n, s, o;
768
+ const e = this._dependenciesToBeRemoved;
769
+ this._dependenciesToBeRemoved = this._dependencies, this._dependencies = e, this._state = 3;
770
+ try {
771
+ if (!this._disposed) {
772
+ (t = y()) == null || t.handleAutorunStarted(this);
773
+ const i = this._changeSummary, d = this._delayedStore;
774
+ d !== void 0 && (this._delayedStore = void 0);
775
+ try {
776
+ this._isRunning = !0, this._changeTracker && ((s = (n = this._changeTracker).beforeUpdate) == null || s.call(n, this, i), this._changeSummary = this._changeTracker.createChangeSummary(i)), this._store !== void 0 && (this._store.dispose(), this._store = void 0), this._runFn(this, i);
777
+ } catch (c) {
778
+ re(c);
779
+ } finally {
780
+ this._isRunning = !1, d !== void 0 && d.dispose();
781
+ }
782
+ }
783
+ } finally {
784
+ this._disposed || (o = y()) == null || o.handleAutorunFinished(this);
785
+ for (const i of this._dependenciesToBeRemoved)
786
+ i.removeObserver(this);
787
+ this._dependenciesToBeRemoved.clear();
788
+ }
789
+ }
790
+ toString() {
791
+ return `Autorun<${this.debugName}>`;
792
+ }
793
+ // IObserver implementation
794
+ beginUpdate(e) {
795
+ this._state === 3 && (this._state = 1), this._updateCount++;
796
+ }
797
+ endUpdate(e) {
798
+ try {
799
+ if (this._updateCount === 1)
800
+ do {
801
+ if (this._state === 1) {
802
+ this._state = 3;
803
+ for (const t of this._dependencies)
804
+ if (t.reportChanges(), this._state === 2)
805
+ break;
806
+ }
807
+ this._state !== 3 && this._run();
808
+ } while (this._state !== 3);
809
+ } finally {
810
+ this._updateCount--;
811
+ }
812
+ }
813
+ handlePossibleChange(e) {
814
+ this._state === 3 && this._isDependency(e) && (this._state = 1);
815
+ }
816
+ handleChange(e, t) {
817
+ var n;
818
+ if (this._isDependency(e)) {
819
+ (n = y()) == null || n.handleAutorunDependencyChanged(this, e, t);
820
+ try {
821
+ (this._changeTracker ? this._changeTracker.handleChange({
822
+ changedObservable: e,
823
+ change: t,
824
+ didChange: (o) => o === e
825
+ }, this._changeSummary) : !0) && (this._state = 2);
826
+ } catch (s) {
827
+ re(s);
828
+ }
829
+ }
830
+ }
831
+ _isDependency(e) {
832
+ return this._dependencies.has(e) && !this._dependenciesToBeRemoved.has(e);
833
+ }
834
+ // IReader implementation
835
+ _ensureNoRunning() {
836
+ if (!this._isRunning)
837
+ throw new j("The reader object cannot be used outside its compute function!");
838
+ }
839
+ readObservable(e) {
840
+ if (this._ensureNoRunning(), this._disposed)
841
+ return e.get();
842
+ e.addObserver(this);
843
+ const t = e.get();
844
+ return this._dependencies.add(e), this._dependenciesToBeRemoved.delete(e), t;
845
+ }
846
+ get store() {
847
+ if (this._ensureNoRunning(), this._disposed)
848
+ throw new j("Cannot access store after dispose");
849
+ return this._store === void 0 && (this._store = new Y()), this._store;
850
+ }
851
+ get delayedStore() {
852
+ if (this._ensureNoRunning(), this._disposed)
853
+ throw new j("Cannot access store after dispose");
854
+ return this._delayedStore === void 0 && (this._delayedStore = new Y()), this._delayedStore;
855
+ }
856
+ debugGetState() {
857
+ return {
858
+ isRunning: this._isRunning,
859
+ updateCount: this._updateCount,
860
+ dependencies: this._dependencies,
861
+ state: this._state,
862
+ stateStr: ar(this._state)
863
+ };
864
+ }
865
+ debugRerun() {
866
+ this._isRunning ? this._state = 2 : this._run();
867
+ }
868
+ }
869
+ function dt(r, e = V.ofCaller()) {
870
+ return new at(new D(void 0, void 0, r), r, void 0, e);
871
+ }
872
+ function Be(r) {
873
+ const e = new Error("BugIndicatingErrorRecovery: " + r);
874
+ nr(e), console.error("recovered from an error that indicates a bug", e);
875
+ }
876
+ function ct(r, e) {
877
+ const t = new lt(r, e);
878
+ try {
879
+ r(t);
880
+ } finally {
881
+ t.finish();
882
+ }
883
+ }
884
+ function dr(r, e, t) {
885
+ r ? e(r) : ct(e, t);
886
+ }
887
+ class lt {
888
+ constructor(e, t) {
889
+ var n;
890
+ this._fn = e, this._getDebugName = t, this._updatingObservers = [], (n = y()) == null || n.handleBeginTransaction(this);
891
+ }
892
+ getDebugName() {
893
+ return this._getDebugName ? this._getDebugName() : xe(this._fn);
894
+ }
895
+ updateObserver(e, t) {
896
+ if (!this._updatingObservers) {
897
+ Be("Transaction already finished!"), ct((n) => {
898
+ n.updateObserver(e, t);
899
+ });
900
+ return;
901
+ }
902
+ this._updatingObservers.push({ observer: e, observable: t }), e.beginUpdate(t);
903
+ }
904
+ finish() {
905
+ var t;
906
+ const e = this._updatingObservers;
907
+ if (!e) {
908
+ Be("transaction.finish() has already been called!");
909
+ return;
910
+ }
911
+ for (let n = 0; n < e.length; n++) {
912
+ const { observer: s, observable: o } = e[n];
913
+ s.endUpdate(o);
914
+ }
915
+ this._updatingObservers = null, (t = y()) == null || t.handleEndTransaction(this);
916
+ }
917
+ debugGetUpdatingObservers() {
918
+ return this._updatingObservers;
919
+ }
920
+ }
921
+ function x(r, e, t = V.ofCaller()) {
922
+ let n;
923
+ return typeof r == "string" ? n = new D(void 0, r, void 0) : n = new D(r, void 0, void 0), new ht(n, e, X, t);
924
+ }
925
+ class ht extends Se {
926
+ get debugName() {
927
+ return this._debugNameData.getDebugName(this) ?? "ObservableValue";
928
+ }
929
+ constructor(e, t, n, s) {
930
+ var o;
931
+ super(s), this._debugNameData = e, this._equalityComparator = n, this._value = t, (o = y()) == null || o.handleObservableUpdated(this, { hadValue: !1, newValue: t, change: void 0, didChange: !0, oldValue: void 0 });
932
+ }
933
+ get() {
934
+ return this._value;
935
+ }
936
+ set(e, t, n) {
937
+ var o;
938
+ if (n === void 0 && this._equalityComparator(this._value, e))
939
+ return;
940
+ let s;
941
+ t || (t = s = new lt(() => {
942
+ }, () => `Setting ${this.debugName}`));
943
+ try {
944
+ const i = this._value;
945
+ this._setValue(e), (o = y()) == null || o.handleObservableUpdated(this, { oldValue: i, newValue: e, change: n, didChange: !0, hadValue: !0 });
946
+ for (const d of this._observers)
947
+ t.updateObserver(d, this), d.handleChange(this, n);
948
+ } finally {
949
+ s && s.finish();
950
+ }
951
+ }
952
+ toString() {
953
+ return `${this.debugName}: ${this._value}`;
954
+ }
955
+ _setValue(e) {
956
+ this._value = e;
957
+ }
958
+ debugGetState() {
959
+ return {
960
+ value: this._value
961
+ };
962
+ }
963
+ debugSetValue(e) {
964
+ this._value = e;
965
+ }
966
+ }
967
+ function Ae(...r) {
968
+ let e, t, n, s;
969
+ return r.length === 2 ? [t, n] = r : [e, t, n, s] = r, new H(new D(e, void 0, n), t, n, () => H.globalTransaction, X, s ?? V.ofCaller());
970
+ }
971
+ class H extends Se {
972
+ constructor(e, t, n, s, o, i) {
973
+ super(i), this._debugNameData = e, this.event = t, this._getValue = n, this._getTransaction = s, this._equalityComparator = o, this._hasValue = !1, this.handleEvent = (d) => {
974
+ var m;
975
+ const c = this._getValue(d), u = this._value, h = !this._hasValue || !this._equalityComparator(u, c);
976
+ let p = !1;
977
+ h && (this._value = c, this._hasValue && (p = !0, dr(this._getTransaction(), (b) => {
978
+ var S;
979
+ (S = y()) == null || S.handleObservableUpdated(this, { oldValue: u, newValue: c, change: void 0, didChange: h, hadValue: this._hasValue });
980
+ for (const C of this._observers)
981
+ b.updateObserver(C, this), C.handleChange(this, void 0);
982
+ }, () => {
983
+ const b = this.getDebugName();
984
+ return "Event fired" + (b ? `: ${b}` : "");
985
+ })), this._hasValue = !0), p || (m = y()) == null || m.handleObservableUpdated(this, { oldValue: u, newValue: c, change: void 0, didChange: h, hadValue: this._hasValue });
986
+ };
987
+ }
988
+ getDebugName() {
989
+ return this._debugNameData.getDebugName(this);
990
+ }
991
+ get debugName() {
992
+ const e = this.getDebugName();
993
+ return "From Event" + (e ? `: ${e}` : "");
994
+ }
995
+ onFirstObserverAdded() {
996
+ this._subscription = this.event(this.handleEvent);
997
+ }
998
+ onLastObserverRemoved() {
999
+ this._subscription.dispose(), this._subscription = void 0, this._hasValue = !1, this._value = void 0;
1000
+ }
1001
+ get() {
1002
+ return this._subscription ? (this._hasValue || this.handleEvent(void 0), this._value) : this._getValue(void 0);
1003
+ }
1004
+ debugSetValue(e) {
1005
+ this._value = e;
1006
+ }
1007
+ debugGetState() {
1008
+ return { value: this._value, hasValue: this._hasValue };
1009
+ }
1010
+ }
1011
+ (function(r) {
1012
+ r.Observer = H;
1013
+ function e(t, n) {
1014
+ let s = !1;
1015
+ H.globalTransaction === void 0 && (H.globalTransaction = t, s = !0);
1016
+ try {
1017
+ n();
1018
+ } finally {
1019
+ s && (H.globalTransaction = void 0);
1020
+ }
1021
+ }
1022
+ r.batchEventsGlobally = e;
1023
+ })(Ae || (Ae = {}));
1024
+ function cr(r) {
1025
+ const e = new ut(!1, void 0);
1026
+ return r.addObserver(e), it(() => {
1027
+ r.removeObserver(e);
1028
+ });
1029
+ }
1030
+ er(cr);
1031
+ function lr(r, e) {
1032
+ const t = new ut(!0, e);
1033
+ r.addObserver(t);
1034
+ try {
1035
+ t.beginUpdate(r);
1036
+ } finally {
1037
+ t.endUpdate(r);
1038
+ }
1039
+ return it(() => {
1040
+ r.removeObserver(t);
1041
+ });
1042
+ }
1043
+ Yt(lr);
1044
+ class ut {
1045
+ constructor(e, t) {
1046
+ this._forceRecompute = e, this._handleValue = t, this._counter = 0;
1047
+ }
1048
+ beginUpdate(e) {
1049
+ this._counter++;
1050
+ }
1051
+ endUpdate(e) {
1052
+ this._counter === 1 && this._forceRecompute && (this._handleValue ? this._handleValue(e.get()) : e.reportChanges()), this._counter--;
1053
+ }
1054
+ handlePossibleChange(e) {
1055
+ }
1056
+ handleChange(e, t) {
1057
+ }
1058
+ }
1059
+ let ee;
1060
+ function hr(r) {
1061
+ ee || (ee = new ur(), Pt(ee)), ee.addFilteredObj(r);
1062
+ }
1063
+ class ur {
1064
+ constructor() {
1065
+ this.indentation = 0, this.changedObservablesSets = /* @__PURE__ */ new WeakMap();
1066
+ }
1067
+ addFilteredObj(e) {
1068
+ this._filteredObjects || (this._filteredObjects = /* @__PURE__ */ new Set()), this._filteredObjects.add(e);
1069
+ }
1070
+ _isIncluded(e) {
1071
+ var t;
1072
+ return ((t = this._filteredObjects) == null ? void 0 : t.has(e)) ?? !0;
1073
+ }
1074
+ textToConsoleArgs(e) {
1075
+ return pr([
1076
+ P(vr("| ", this.indentation)),
1077
+ e
1078
+ ]);
1079
+ }
1080
+ formatInfo(e) {
1081
+ return e.hadValue ? e.didChange ? [
1082
+ P(" "),
1083
+ T(Z(e.oldValue, 70), {
1084
+ color: "red",
1085
+ strikeThrough: !0
1086
+ }),
1087
+ P(" "),
1088
+ T(Z(e.newValue, 60), {
1089
+ color: "green"
1090
+ })
1091
+ ] : [P(" (unchanged)")] : [
1092
+ P(" "),
1093
+ T(Z(e.newValue, 60), {
1094
+ color: "green"
1095
+ }),
1096
+ P(" (initial)")
1097
+ ];
1098
+ }
1099
+ handleObservableCreated(e) {
1100
+ if (e instanceof U) {
1101
+ const t = e;
1102
+ this.changedObservablesSets.set(t, /* @__PURE__ */ new Set());
1103
+ }
1104
+ }
1105
+ handleOnListenerCountChanged(e, t) {
1106
+ }
1107
+ handleObservableUpdated(e, t) {
1108
+ if (this._isIncluded(e)) {
1109
+ if (e instanceof U) {
1110
+ this._handleDerivedRecomputed(e, t);
1111
+ return;
1112
+ }
1113
+ console.log(...this.textToConsoleArgs([
1114
+ W("observable value changed"),
1115
+ T(e.debugName, { color: "BlueViolet" }),
1116
+ ...this.formatInfo(t)
1117
+ ]));
1118
+ }
1119
+ }
1120
+ formatChanges(e) {
1121
+ if (e.size !== 0)
1122
+ return T(" (changed deps: " + [...e].map((t) => t.debugName).join(", ") + ")", { color: "gray" });
1123
+ }
1124
+ handleDerivedDependencyChanged(e, t, n) {
1125
+ var s;
1126
+ this._isIncluded(e) && ((s = this.changedObservablesSets.get(e)) == null || s.add(t));
1127
+ }
1128
+ _handleDerivedRecomputed(e, t) {
1129
+ if (!this._isIncluded(e))
1130
+ return;
1131
+ const n = this.changedObservablesSets.get(e);
1132
+ n && (console.log(...this.textToConsoleArgs([
1133
+ W("derived recomputed"),
1134
+ T(e.debugName, { color: "BlueViolet" }),
1135
+ ...this.formatInfo(t),
1136
+ this.formatChanges(n),
1137
+ { data: [{ fn: e._debugNameData.referenceFn ?? e._computeFn }] }
1138
+ ])), n.clear());
1139
+ }
1140
+ handleDerivedCleared(e) {
1141
+ this._isIncluded(e) && console.log(...this.textToConsoleArgs([
1142
+ W("derived cleared"),
1143
+ T(e.debugName, { color: "BlueViolet" })
1144
+ ]));
1145
+ }
1146
+ handleFromEventObservableTriggered(e, t) {
1147
+ this._isIncluded(e) && console.log(...this.textToConsoleArgs([
1148
+ W("observable from event triggered"),
1149
+ T(e.debugName, { color: "BlueViolet" }),
1150
+ ...this.formatInfo(t),
1151
+ { data: [{ fn: e._getValue }] }
1152
+ ]));
1153
+ }
1154
+ handleAutorunCreated(e) {
1155
+ this._isIncluded(e) && this.changedObservablesSets.set(e, /* @__PURE__ */ new Set());
1156
+ }
1157
+ handleAutorunDisposed(e) {
1158
+ }
1159
+ handleAutorunDependencyChanged(e, t, n) {
1160
+ this._isIncluded(e) && this.changedObservablesSets.get(e).add(t);
1161
+ }
1162
+ handleAutorunStarted(e) {
1163
+ const t = this.changedObservablesSets.get(e);
1164
+ t && (this._isIncluded(e) && console.log(...this.textToConsoleArgs([
1165
+ W("autorun"),
1166
+ T(e.debugName, { color: "BlueViolet" }),
1167
+ this.formatChanges(t),
1168
+ { data: [{ fn: e._debugNameData.referenceFn ?? e._runFn }] }
1169
+ ])), t.clear(), this.indentation++);
1170
+ }
1171
+ handleAutorunFinished(e) {
1172
+ this.indentation--;
1173
+ }
1174
+ handleBeginTransaction(e) {
1175
+ let t = e.getDebugName();
1176
+ t === void 0 && (t = ""), this._isIncluded(e) && console.log(...this.textToConsoleArgs([
1177
+ W("transaction"),
1178
+ T(t, { color: "BlueViolet" }),
1179
+ { data: [{ fn: e._fn }] }
1180
+ ])), this.indentation++;
1181
+ }
1182
+ handleEndTransaction() {
1183
+ this.indentation--;
1184
+ }
1185
+ }
1186
+ function pr(r) {
1187
+ const e = new Array(), t = [];
1188
+ let n = "";
1189
+ function s(i) {
1190
+ if ("length" in i)
1191
+ for (const d of i)
1192
+ d && s(d);
1193
+ else "text" in i ? (n += `%c${i.text}`, e.push(i.style), i.data && t.push(...i.data)) : "data" in i && t.push(...i.data);
1194
+ }
1195
+ s(r);
1196
+ const o = [n, ...e];
1197
+ return o.push(...t), o;
1198
+ }
1199
+ function P(r) {
1200
+ return T(r, { color: "black" });
1201
+ }
1202
+ function W(r) {
1203
+ return T(br(`${r}: `, 10), { color: "black", bold: !0 });
1204
+ }
1205
+ function T(r, e = {
1206
+ color: "black"
1207
+ }) {
1208
+ function t(s) {
1209
+ return Object.entries(s).reduce((o, [i, d]) => `${o}${i}:${d};`, "");
1210
+ }
1211
+ const n = {
1212
+ color: e.color
1213
+ };
1214
+ return e.strikeThrough && (n["text-decoration"] = "line-through"), e.bold && (n["font-weight"] = "bold"), {
1215
+ text: r,
1216
+ style: t(n)
1217
+ };
1218
+ }
1219
+ function Z(r, e) {
1220
+ try {
1221
+ return fr(r, e);
1222
+ } catch {
1223
+ return "[[???]]";
1224
+ }
1225
+ }
1226
+ function fr(r, e) {
1227
+ switch (typeof r) {
1228
+ case "number":
1229
+ return "" + r;
1230
+ case "string":
1231
+ return r.length + 2 <= e ? `"${r}"` : `"${r.substr(0, e - 7)}"+...`;
1232
+ case "boolean":
1233
+ return r ? "true" : "false";
1234
+ case "undefined":
1235
+ return "undefined";
1236
+ case "object":
1237
+ return r === null ? "null" : Array.isArray(r) ? gr(r, e) : mr(r, e);
1238
+ case "symbol":
1239
+ return r.toString();
1240
+ case "function":
1241
+ return `[[Function${r.name ? " " + r.name : ""}]]`;
1242
+ default:
1243
+ return "" + r;
1244
+ }
1245
+ }
1246
+ function gr(r, e) {
1247
+ let t = "[ ", n = !0;
1248
+ for (const s of r) {
1249
+ if (n || (t += ", "), t.length - 5 > e) {
1250
+ t += "...";
1251
+ break;
1252
+ }
1253
+ n = !1, t += `${Z(s, e - t.length)}`;
1254
+ }
1255
+ return t += " ]", t;
1256
+ }
1257
+ function mr(r, e) {
1258
+ try {
1259
+ if (typeof r.toString == "function" && r.toString !== Object.prototype.toString) {
1260
+ const i = r.toString();
1261
+ return i.length <= e ? i : i.substring(0, e - 3) + "...";
1262
+ }
1263
+ } catch {
1264
+ return "[[Object]]";
1265
+ }
1266
+ const t = rt(r);
1267
+ let n = t ? t + "(" : "{ ", s = !0, o;
1268
+ try {
1269
+ o = Object.entries(r);
1270
+ } catch {
1271
+ return t ? `${t}(...)` : "[[Object]]";
1272
+ }
1273
+ for (const [i, d] of o) {
1274
+ if (s || (n += ", "), n.length - 5 > e) {
1275
+ n += "...";
1276
+ break;
1277
+ }
1278
+ s = !1, n += `${i}: ${Z(d, e - n.length)}`;
1279
+ }
1280
+ return n += t ? ")" : " }", n;
1281
+ }
1282
+ function vr(r, e) {
1283
+ let t = "";
1284
+ for (let n = 1; n <= e; n++)
1285
+ t += r;
1286
+ return t;
1287
+ }
1288
+ function br(r, e) {
1289
+ for (; r.length < e; )
1290
+ r += " ";
1291
+ return r;
1292
+ }
1293
+ function _r(r, e) {
1294
+ const t = (e == null ? void 0 : e.debugNamePostProcessor) ?? ((o) => o), n = I.from(r, t);
1295
+ return n ? pt(n, 0, /* @__PURE__ */ new Set()).trim() : "";
1296
+ }
1297
+ function pt(r, e, t) {
1298
+ const n = " ".repeat(e), s = [];
1299
+ if (t.has(r.sourceObj))
1300
+ return s.push(`${n}* ${r.type} ${r.name} (already listed)`), s.join(`
1301
+ `);
1302
+ if (t.add(r.sourceObj), s.push(`${n}* ${r.type} ${r.name}:`), s.push(`${n} value: ${Z(r.value, 50)}`), s.push(`${n} state: ${r.state}`), r.dependencies.length > 0) {
1303
+ s.push(`${n} dependencies:`);
1304
+ for (const i of r.dependencies)
1305
+ s.push(pt(i, e + 1, t));
1306
+ }
1307
+ return s.join(`
1308
+ `);
1309
+ }
1310
+ class I {
1311
+ static from(e, t) {
1312
+ if (e instanceof at) {
1313
+ const n = e.debugGetState();
1314
+ return new I(e, t(e.debugName), "autorun", void 0, n.stateStr, Array.from(n.dependencies).map((s) => I.from(s, t) || I.unknown(s)));
1315
+ } else if (e instanceof U) {
1316
+ const n = e.debugGetState();
1317
+ return new I(e, t(e.debugName), "derived", n.value, n.stateStr, Array.from(n.dependencies).map((s) => I.from(s, t) || I.unknown(s)));
1318
+ } else if (e instanceof ht) {
1319
+ const n = e.debugGetState();
1320
+ return new I(e, t(e.debugName), "observableValue", n.value, "upToDate", []);
1321
+ } else if (e instanceof H) {
1322
+ const n = e.debugGetState();
1323
+ return new I(e, t(e.debugName), "fromEvent", n.value, n.hasValue ? "upToDate" : "initial", []);
1324
+ }
1325
+ }
1326
+ static unknown(e) {
1327
+ return new I(e, "(unknown)", "unknown", void 0, "unknown", []);
1328
+ }
1329
+ constructor(e, t, n, s, o, i) {
1330
+ this.sourceObj = e, this.name = t, this.type = n, this.value = s, this.state = o, this.dependencies = i;
1331
+ }
1332
+ }
1333
+ tr(_r);
1334
+ Wt(hr);
1335
+ class yr {
1336
+ constructor() {
1337
+ l(this, "_fixtures", x(this, /* @__PURE__ */ new Map()));
1338
+ /** Observable root of the fixture tree */
1339
+ l(this, "root", O(this, (e) => {
1340
+ const t = this._fixtures.read(e);
1341
+ return ie(t);
1342
+ }));
1343
+ }
1344
+ /**
1345
+ * Registers a fixture file.
1346
+ * @param path The file path (e.g., 'components/Button.fixture.tsx')
1347
+ * @param fixtureExport The exported fixture object
1348
+ */
1349
+ register(e, t) {
1350
+ const n = new Map(this._fixtures.get());
1351
+ n.set(e, t), this._fixtures.set(n, void 0);
1352
+ }
1353
+ /**
1354
+ * Unregisters a fixture file.
1355
+ * @param path The file path to remove
1356
+ */
1357
+ unregister(e) {
1358
+ const t = new Map(this._fixtures.get());
1359
+ t.delete(e) && this._fixtures.set(t, void 0);
1360
+ }
1361
+ /**
1362
+ * Clears all registered fixtures.
1363
+ */
1364
+ clear() {
1365
+ this._fixtures.set(/* @__PURE__ */ new Map(), void 0);
1366
+ }
1367
+ /**
1368
+ * Gets a node by path.
1369
+ */
1370
+ getNode(e, t) {
1371
+ const n = this.root.read(e);
1372
+ return Ve(n, t);
1373
+ }
1374
+ /**
1375
+ * Gets a component by path (non-reactive, for use in preview iframe).
1376
+ * @param path Array of path segments (e.g., ['Button', 'Primary'])
1377
+ */
1378
+ getComponentByPath(e) {
1379
+ const t = this._fixtures.get(), n = ie(t), s = Ve(n, e);
1380
+ return s == null ? void 0 : s.component;
1381
+ }
1382
+ }
1383
+ class ft {
1384
+ constructor(e, t) {
1385
+ l(this, "renderTarget");
1386
+ l(this, "shadowRoot");
1387
+ l(this, "_abortController", new AbortController());
1388
+ l(this, "_rawResult");
1389
+ l(this, "_resolvedResult");
1390
+ if (this.component = t, t.isolation === "shadow-dom") {
1391
+ let s;
1392
+ if (e.shadowRoot) {
1393
+ for (s = e.shadowRoot; s.firstChild; )
1394
+ s.removeChild(s.firstChild);
1395
+ s.adoptedStyleSheets = [];
1396
+ } else
1397
+ s = e.attachShadow({ mode: "open" });
1398
+ if (t.styles)
1399
+ for (const o of t.styles)
1400
+ if (o.type === "css") {
1401
+ const i = document.createElement("style");
1402
+ i.textContent = o.content, s.appendChild(i);
1403
+ } else if (o.type === "url") {
1404
+ const i = document.createElement("link");
1405
+ i.rel = "stylesheet", i.href = o.href, s.appendChild(i);
1406
+ } else o.type === "adopted" && (s.adoptedStyleSheets = [
1407
+ ...s.adoptedStyleSheets,
1408
+ o.sheet
1409
+ ]);
1410
+ this.renderTarget = document.createElement("div"), s.appendChild(this.renderTarget), this.shadowRoot = s;
1411
+ } else
1412
+ this.renderTarget = document.createElement("div"), e.appendChild(this.renderTarget), this.shadowRoot = null;
1413
+ const n = Lt(t.properties);
1414
+ this._rawResult = t.render(this.renderTarget, {
1415
+ props: n,
1416
+ signal: this._abortController.signal
1417
+ }), this._rawResult instanceof Promise ? this._rawResult.then((s) => {
1418
+ var o;
1419
+ this._abortController.signal.aborted ? (o = s == null ? void 0 : s.dispose) == null || o.call(s) : this._resolvedResult = s ?? void 0;
1420
+ }).catch(() => {
1421
+ }) : this._resolvedResult = this._rawResult ?? void 0;
1422
+ }
1423
+ get result() {
1424
+ return this._rawResult;
1425
+ }
1426
+ dispose() {
1427
+ var e, t;
1428
+ this._abortController.abort(), (t = (e = this._resolvedResult) == null ? void 0 : e.dispose) == null || t.call(e), this._resolvedResult = void 0;
1429
+ }
1430
+ }
1431
+ class ns {
1432
+ constructor(e, t) {
1433
+ l(this, "sessionId", Math.random().toString(36).slice(2));
1434
+ l(this, "_updateVersion", 0);
1435
+ l(this, "_root");
1436
+ l(this, "_fixtureModules");
1437
+ l(this, "_currentRendering");
1438
+ l(this, "_currentContainer");
1439
+ this._containerElement = e, this._fixtureModules = t, this._root = this._buildRegistry(), this._installGlobalApi();
1440
+ const n = this._flattenFixtures(this._root).length;
1441
+ console.log("[cli] CLI entry initialized, sessionId:", this.sessionId, "version:", this._updateVersion, "fixtures:", n);
1442
+ }
1443
+ get updateVersion() {
1444
+ return this._updateVersion;
1445
+ }
1446
+ updateFixtures(e) {
1447
+ this._fixtureModules = e, this._root = this._buildRegistry(), this._updateVersion++;
1448
+ const t = this._flattenFixtures(this._root).length;
1449
+ console.log("[cli] Registry rebuilt, version:", this._updateVersion, "fixtures:", t);
1450
+ }
1451
+ bumpVersion() {
1452
+ this._updateVersion++, console.log("[cli] Version bumped:", this._updateVersion);
1453
+ }
1454
+ listFixtures() {
1455
+ return this._flattenFixtures(this._root);
1456
+ }
1457
+ async renderFixture(e) {
1458
+ const t = this._findFixtureNode(this._root, e);
1459
+ if (!t || !t.component)
1460
+ throw new Error("Fixture not found: " + e);
1461
+ this._currentRendering && (this._currentRendering.dispose(), this._currentRendering = void 0), this._currentContainer && (this._currentContainer.remove(), this._currentContainer = void 0);
1462
+ const n = document.createElement("div");
1463
+ n.style.display = "inline-block", this._containerElement.appendChild(n), this._currentContainer = n;
1464
+ const s = t.component, o = [], i = console.error, d = console.warn;
1465
+ console.error = (...h) => {
1466
+ o.push({ kind: "console", level: "error", message: h.map(String).join(" ") }), i.apply(console, h);
1467
+ }, console.warn = (...h) => {
1468
+ o.push({ kind: "console", level: "warn", message: h.map(String).join(" ") }), d.apply(console, h);
1469
+ };
1470
+ const c = (h) => {
1471
+ var p;
1472
+ o.push({ kind: "exception", message: h.message, stack: (p = h.error) == null ? void 0 : p.stack });
1473
+ }, u = (h) => {
1474
+ const p = h.reason, m = p instanceof Error ? p.message : String(p), b = p instanceof Error ? p.stack : void 0;
1475
+ o.push({ kind: "exception", message: m, stack: b });
1476
+ };
1477
+ window.addEventListener("error", c), window.addEventListener("unhandledrejection", u);
1478
+ try {
1479
+ const h = new ft(n, s);
1480
+ this._currentRendering = h;
1481
+ const p = 3e3;
1482
+ let m;
1483
+ const b = h.result;
1484
+ if (b instanceof Promise) {
1485
+ const S = new Promise((_) => setTimeout(() => _("timeout"), p)), C = await Promise.race([b.then((_) => ({ resolved: _ })), S]);
1486
+ C === "timeout" ? (h.dispose(), o.push({ kind: "exception", message: `Fixture render() timed out after ${p}ms` })) : m = C.resolved ?? void 0;
1487
+ } else
1488
+ m = b ?? void 0;
1489
+ if (m != null && m.ready) {
1490
+ const S = new Promise((_) => setTimeout(() => _("timeout"), p));
1491
+ await Promise.race([m.ready.then(() => "done"), S]) === "timeout" && (h.dispose(), o.push({ kind: "exception", message: `Fixture ready promise timed out after ${p}ms` }));
1492
+ }
1493
+ } catch (h) {
1494
+ const p = h instanceof Error ? h : new Error(String(h));
1495
+ o.push({ kind: "exception", message: p.message, stack: p.stack });
1496
+ } finally {
1497
+ console.error = i, console.warn = d;
1498
+ }
1499
+ return await new Promise((h) => requestAnimationFrame(() => requestAnimationFrame(() => h()))), window.removeEventListener("error", c), window.removeEventListener("unhandledrejection", u), { errors: o };
1500
+ }
1501
+ _buildRegistry() {
1502
+ const e = /* @__PURE__ */ new Map();
1503
+ for (const [t, n] of Object.entries(this._fixtureModules)) {
1504
+ const s = n.default;
1505
+ s && typeof s == "object" && e.set(t, s);
1506
+ }
1507
+ return ie(e);
1508
+ }
1509
+ _flattenFixtures(e, t = [], n = []) {
1510
+ var i;
1511
+ const s = n.length > 0 && e.labels.length > 0 ? [.../* @__PURE__ */ new Set([...n, ...e.labels])] : e.labels.length > 0 ? [...e.labels] : [...n], o = [];
1512
+ e.type === "component" && o.push({ fixtureId: e.id, fixtureName: e.name, groupPath: t, background: ((i = e.component) == null ? void 0 : i.background) ?? "light", labels: s });
1513
+ for (const d of e.children ?? []) {
1514
+ const c = e.id ? [...t, e.name] : t;
1515
+ o.push(...this._flattenFixtures(d, c, s));
1516
+ }
1517
+ return o;
1518
+ }
1519
+ _findFixtureNode(e, t) {
1520
+ if (e.id === t) return e;
1521
+ for (const n of e.children ?? []) {
1522
+ const s = this._findFixtureNode(n, t);
1523
+ if (s) return s;
1524
+ }
1525
+ }
1526
+ _installGlobalApi() {
1527
+ window.__componentExplorerCli__ = {
1528
+ sessionId: this.sessionId,
1529
+ get updateVersion() {
1530
+ return 0;
1531
+ },
1532
+ listFixtures: () => this.listFixtures(),
1533
+ renderFixture: (e) => this.renderFixture(e)
1534
+ }, Object.defineProperty(window.__componentExplorerCli__, "updateVersion", {
1535
+ get: () => this._updateVersion
1536
+ });
1537
+ }
1538
+ }
1539
+ class xr {
1540
+ constructor(e) {
1541
+ this._run = e, this._changes = [], this._map = /* @__PURE__ */ new Map(), this._updateCounter = 0;
1542
+ }
1543
+ addDependency(e, t) {
1544
+ return this._map.set(e, t), e.addObserver(this), {
1545
+ dispose: () => {
1546
+ this._map.delete(e), e.removeObserver(this);
1547
+ }
1548
+ };
1549
+ }
1550
+ beginUpdate(e) {
1551
+ this._updateCounter++, this._changes.push(this._map.get(e));
1552
+ }
1553
+ endUpdate(e) {
1554
+ if (this._updateCounter--, this._updateCounter === 0 && this._changes.length > 0) {
1555
+ const t = this._changes;
1556
+ this._changes = [], this._run(t);
1557
+ }
1558
+ }
1559
+ handlePossibleChange(e) {
1560
+ this._changes.push(this._map.get(e));
1561
+ }
1562
+ handleChange(e, t) {
1563
+ }
1564
+ }
1565
+ function f() {
1566
+ return le.instance;
1567
+ }
1568
+ function Sr() {
1569
+ return he.instance;
1570
+ }
1571
+ function wr() {
1572
+ return ue.instance;
1573
+ }
1574
+ f.const = Sr;
1575
+ f.obs = wr;
1576
+ class le {
1577
+ create(e) {
1578
+ const t = O((n) => e(n));
1579
+ return { read: (n) => t };
1580
+ }
1581
+ }
1582
+ le.instance = new le();
1583
+ class he {
1584
+ create(e) {
1585
+ const t = O((n) => e(n));
1586
+ return { read: (n) => t.read(n) };
1587
+ }
1588
+ }
1589
+ he.instance = new he();
1590
+ class ue {
1591
+ create(e) {
1592
+ const t = O((n) => {
1593
+ const s = e(n);
1594
+ return Cr(s) ? s.read(n) : s;
1595
+ });
1596
+ return { read: (n) => t };
1597
+ }
1598
+ }
1599
+ ue.instance = new ue();
1600
+ function Cr(r) {
1601
+ return typeof r == "object" && r !== null && "read" in r;
1602
+ }
1603
+ function J(r, e) {
1604
+ return Object.fromEntries(Object.entries(r).map(([t, n]) => [t, e(n, t)]));
1605
+ }
1606
+ const se = Symbol("ViewModelContext");
1607
+ class Rr {
1608
+ constructor(e) {
1609
+ this._store = new Y(), this.props = e;
1610
+ }
1611
+ dispose() {
1612
+ this._store.dispose();
1613
+ }
1614
+ }
1615
+ function Tr(r) {
1616
+ return r[se] || (r[se] = Ye(void 0)), r[se];
1617
+ }
1618
+ function B(r = {}) {
1619
+ var e;
1620
+ return e = class extends Rr {
1621
+ }, e._props = r, e;
1622
+ }
1623
+ let pe = 0;
1624
+ const kr = new xr((r) => {
1625
+ for (const e of r)
1626
+ e.rendered = !1;
1627
+ if (pe > 0) {
1628
+ const e = r.find((t) => t.isRendering);
1629
+ e.itemsToRender = r;
1630
+ } else
1631
+ et(() => {
1632
+ for (const e of r)
1633
+ e.rendered || e.forceUpdate();
1634
+ });
1635
+ });
1636
+ let Ir = 0;
1637
+ class Or {
1638
+ constructor(e, t) {
1639
+ this.debugName = e, this.renderFactory = t, this._obsProps = void 0, this.forceUpdate = void 0, this._render = void 0, this._disposable = void 0, this.contextValues = /* @__PURE__ */ new Map(), this.cleanupEffect = () => () => {
1640
+ var n;
1641
+ (n = this._disposable) == null || n.dispose();
1642
+ }, this.itemsToRender = [], this.handleAfterRender = () => {
1643
+ et(() => {
1644
+ for (const n of this.itemsToRender)
1645
+ n.rendered || n.forceUpdate();
1646
+ }), this.itemsToRender = [];
1647
+ }, this.rendering = void 0, this.isRendering = !1, this.rendered = !1;
1648
+ }
1649
+ toString() {
1650
+ return this.debugName;
1651
+ }
1652
+ updateProps(e) {
1653
+ this._obsProps ? this._obsProps.set(e, void 0) : (this._obsProps = x(this, e), this._render = this.renderFactory(this._obsProps, () => this.contextValues), this.rendering = O(this, this._render), this._disposable = kr.addDependency(this.rendering, this));
1654
+ }
1655
+ }
1656
+ function we(r, e, t) {
1657
+ const n = (i) => i + 1, s = () => new Or(r + ++Ir, e), o = function(i) {
1658
+ const d = Et(n, 0)[1], c = Dt(s)[0];
1659
+ for (const u of t ?? [])
1660
+ c.contextValues.set(u, Bt(u));
1661
+ if (Ie(c.cleanupEffect, []), Ie(c.handleAfterRender), c.isRendering)
1662
+ throw new Error("Component is already rendering");
1663
+ c.isRendering = !0, pe++;
1664
+ try {
1665
+ c.forceUpdate = d, c.updateProps(i);
1666
+ const u = c.rendering.get();
1667
+ return c.rendered = !0, u;
1668
+ } finally {
1669
+ c.isRendering = !1, pe--;
1670
+ }
1671
+ };
1672
+ return o.displayName = r, o;
1673
+ }
1674
+ we("ObsView", (r) => (e) => r.read(e).children(e));
1675
+ function k(r, e) {
1676
+ return we("view", (t) => {
1677
+ const n = J(r, (s, o) => s.create((i) => t.read(i)[o], void 0));
1678
+ return (s) => {
1679
+ const o = J(n, (i) => i.read(s));
1680
+ return e(s, o);
1681
+ };
1682
+ });
1683
+ }
1684
+ function Nr(r) {
1685
+ const e = [];
1686
+ for (const t of Object.values(r)) {
1687
+ const n = t._requiredContext;
1688
+ n && !e.includes(n) && e.push(n);
1689
+ }
1690
+ return e;
1691
+ }
1692
+ function A(r, e, t) {
1693
+ const n = typeof e == "function" ? {} : e, s = typeof e == "function" ? e : t, o = "_props" in r ? r._props : {}, i = Nr({ ...o, ...n }), d = Tr(r), c = [...i, d];
1694
+ return we("viewWithModel", (u, h) => {
1695
+ const p = h(), m = p.get(d), b = "_props" in r ? J(r._props, (_, M) => _.create((F) => u.read(F)[M], p.get(_._requiredContext))) : {}, S = m ? { read: () => m, dispose: () => {
1696
+ } } : ir((_) => {
1697
+ const M = J(b, (F) => F.read(_));
1698
+ return new r(M);
1699
+ }), C = J(n, (_, M) => _.create((F) => u.read(F)[M], p.get(_._requiredContext)));
1700
+ return (_) => {
1701
+ const M = S.read(_), F = J(C, (Nt) => Nt.read(_));
1702
+ return s(_, M, F);
1703
+ };
1704
+ }, c.length > 0 ? c : void 0);
1705
+ }
1706
+ k({ value: f.obs() }, (r, e) => e.value.read(r));
1707
+ Ye(null);
1708
+ function gt(r) {
1709
+ var e;
1710
+ return {
1711
+ id: r.id,
1712
+ name: r.name,
1713
+ type: r.type,
1714
+ children: (e = r.children) == null ? void 0 : e.map(gt),
1715
+ component: r.component,
1716
+ labels: r.labels
1717
+ };
1718
+ }
1719
+ function Vr(r, e) {
1720
+ if (r.name.toLowerCase().includes(e)) return !0;
1721
+ for (const t of r.labels)
1722
+ if (t.toLowerCase().includes(e)) return !0;
1723
+ return !1;
1724
+ }
1725
+ function Mr(r, e) {
1726
+ if (!e) return r;
1727
+ const t = e.toLowerCase();
1728
+ return mt(r, t);
1729
+ }
1730
+ function mt(r, e) {
1731
+ const t = Vr(r, e);
1732
+ if (!r.children || r.children.length === 0)
1733
+ return t ? r : void 0;
1734
+ if (t) return r;
1735
+ const n = [];
1736
+ for (const s of r.children) {
1737
+ const o = mt(s, e);
1738
+ o && n.push(o);
1739
+ }
1740
+ if (n.length !== 0)
1741
+ return {
1742
+ ...r,
1743
+ children: n
1744
+ };
1745
+ }
1746
+ function te(r, e) {
1747
+ const {
1748
+ storageKey: t,
1749
+ defaultValue: n,
1750
+ serialize: s = JSON.stringify,
1751
+ deserialize: o = JSON.parse
1752
+ } = e;
1753
+ let i = n;
1754
+ try {
1755
+ const u = localStorage.getItem(t);
1756
+ u !== null && (i = o(u));
1757
+ } catch {
1758
+ }
1759
+ const d = x(r, i), c = d.set.bind(d);
1760
+ return d.set = (u, h) => {
1761
+ try {
1762
+ localStorage.setItem(t, s(u));
1763
+ } catch {
1764
+ }
1765
+ c(u, h);
1766
+ }, d;
1767
+ }
1768
+ function $e(r, e) {
1769
+ const n = new URLSearchParams(location.search).get(e) || void 0, s = x(r, n);
1770
+ window.addEventListener("popstate", () => {
1771
+ const i = new URLSearchParams(location.search);
1772
+ s.set(i.get(e) || void 0, void 0);
1773
+ });
1774
+ const o = s.set.bind(s);
1775
+ return s.set = (i, d) => {
1776
+ const c = new URLSearchParams(location.search);
1777
+ i ? c.set(e, i) : c.delete(e);
1778
+ const u = c.toString(), h = location.pathname + (u ? "?" + u : "") + location.hash;
1779
+ history.replaceState(history.state, "", h), o(i, d);
1780
+ }, s;
1781
+ }
1782
+ function vt(r, e) {
1783
+ const t = new URLSearchParams(location.search);
1784
+ return t.set(r, e), location.pathname + "?" + t.toString();
1785
+ }
1786
+ class Fr extends B({
1787
+ registry: f.const(),
1788
+ daemonModel: f.const(),
1789
+ reportModel: f.const()
1790
+ }) {
1791
+ constructor() {
1792
+ super(...arguments);
1793
+ l(this, "leftSidebarVisible", te(this, {
1794
+ storageKey: "component-explorer:leftSidebarVisible",
1795
+ defaultValue: !0
1796
+ }));
1797
+ l(this, "rightSidebarVisible", te(this, {
1798
+ storageKey: "component-explorer:rightSidebarVisible",
1799
+ defaultValue: !1
1800
+ }));
1801
+ l(this, "isDarkTheme", te(this, {
1802
+ storageKey: "component-explorer:isDarkTheme",
1803
+ defaultValue: !0
1804
+ }));
1805
+ l(this, "selectedNodeId", $e(this, "component"));
1806
+ l(this, "expandedNodeIds", x(this, this._initialExpandedNodes()));
1807
+ l(this, "viewMode", te(this, {
1808
+ storageKey: "component-explorer:viewMode",
1809
+ defaultValue: "session"
1810
+ }));
1811
+ l(this, "searchQuery", $e(this, "search"));
1812
+ /** The explorer's tree derived from the registry or report */
1813
+ l(this, "tree", O(this, (t) => {
1814
+ const n = this.props.reportModel;
1815
+ if (n)
1816
+ return n.buildTree(t);
1817
+ const s = this.props.registry.root.read(t);
1818
+ return gt(s);
1819
+ }));
1820
+ l(this, "filteredTree", O(this, (t) => {
1821
+ const n = this.tree.read(t), s = this.searchQuery.read(t);
1822
+ return Mr(n, s) ?? { ...n, children: [] };
1823
+ }));
1824
+ l(this, "selectedNode", O(this, (t) => {
1825
+ const n = this.selectedNodeId.read(t);
1826
+ if (n === void 0) return;
1827
+ const s = this.filteredTree.read(t);
1828
+ return s.id === n ? s : this._findNode(s.children ?? [], n);
1829
+ }));
1830
+ /** List of preview rows to render based on current selection and view mode */
1831
+ l(this, "selectedFixtures", O(this, (t) => {
1832
+ const n = this.selectedNode.read(t);
1833
+ return n ? this.isReportMode ? (this.props.reportModel.state.read(t), this._collectReportRows(n, n.name)) : this.viewMode.read(t) === "diff" && this.daemonAvailable && this.daemon.sessions.read(t).length > 1 ? this._collectDiffRows(n, n.name) : this._collectPreviewRows(n, n.name) : [];
1834
+ }));
1835
+ l(this, "setViewMode", (t) => {
1836
+ this.viewMode.set(t, void 0);
1837
+ });
1838
+ l(this, "navigateToSession", (t) => {
1839
+ const n = this.props.daemonModel;
1840
+ if (!n) return;
1841
+ const s = n.getSessionExplorerUrl(t);
1842
+ s && (window.location.href = s);
1843
+ });
1844
+ l(this, "toggleLeftSidebar", () => {
1845
+ this.leftSidebarVisible.set(!this.leftSidebarVisible.get(), void 0);
1846
+ });
1847
+ l(this, "toggleRightSidebar", () => {
1848
+ this.rightSidebarVisible.set(!this.rightSidebarVisible.get(), void 0);
1849
+ });
1850
+ l(this, "toggleTheme", () => {
1851
+ this.isDarkTheme.set(!this.isDarkTheme.get(), void 0);
1852
+ });
1853
+ l(this, "selectNode", (t) => {
1854
+ this.selectedNodeId.set(t, void 0);
1855
+ });
1856
+ l(this, "toggleNodeExpanded", (t) => {
1857
+ const n = this.expandedNodeIds.get(), s = new Set(n);
1858
+ s.has(t) ? s.delete(t) : s.add(t), this.expandedNodeIds.set(s, void 0);
1859
+ });
1860
+ }
1861
+ get daemonAvailable() {
1862
+ return this.props.daemonModel !== void 0;
1863
+ }
1864
+ get daemon() {
1865
+ return this.props.daemonModel;
1866
+ }
1867
+ get reportModel() {
1868
+ return this.props.reportModel;
1869
+ }
1870
+ get isReportMode() {
1871
+ return this.props.reportModel !== void 0;
1872
+ }
1873
+ isNodeExpanded(t, n) {
1874
+ return this.searchQuery.read(n) ? !0 : this.expandedNodeIds.read(n).has(t);
1875
+ }
1876
+ _initialExpandedNodes() {
1877
+ const t = this.selectedNodeId.get();
1878
+ if (!t) return /* @__PURE__ */ new Set([""]);
1879
+ const n = t.split("/"), s = /* @__PURE__ */ new Set([""]);
1880
+ for (let o = 1; o <= n.length; o++)
1881
+ s.add(n.slice(0, o).join("/"));
1882
+ return s;
1883
+ }
1884
+ _findNode(t, n) {
1885
+ for (const s of t) {
1886
+ if (s.id === n) return s;
1887
+ if (s.children) {
1888
+ const o = this._findNode(s.children, n);
1889
+ if (o) return o;
1890
+ }
1891
+ }
1892
+ }
1893
+ _collectPreviewRows(t, n) {
1894
+ if (t.type === "component" && t.component)
1895
+ return [{
1896
+ type: "single",
1897
+ fixture: {
1898
+ id: t.id,
1899
+ name: t.name,
1900
+ path: n,
1901
+ component: t.component
1902
+ }
1903
+ }];
1904
+ if (t.type === "variants") {
1905
+ const o = [];
1906
+ for (const i of t.children ?? [])
1907
+ i.type === "component" && i.component && o.push({
1908
+ id: i.id,
1909
+ name: i.name,
1910
+ path: `${n} / ${i.name}`,
1911
+ component: i.component
1912
+ });
1913
+ return o.length > 0 ? [{
1914
+ type: "variants",
1915
+ id: t.id,
1916
+ name: t.name,
1917
+ path: n,
1918
+ fixtures: o
1919
+ }] : [];
1920
+ }
1921
+ const s = [];
1922
+ for (const o of t.children ?? []) {
1923
+ const i = n ? `${n} / ${o.name}` : o.name;
1924
+ s.push(...this._collectPreviewRows(o, i));
1925
+ }
1926
+ return s;
1927
+ }
1928
+ /**
1929
+ * In diff mode: fixtures become screenshot comparison items showing current vs baseline.
1930
+ * Variants become comparison groups.
1931
+ */
1932
+ _collectDiffRows(t, n) {
1933
+ if (t.type === "component")
1934
+ return [{
1935
+ type: "screenshot-comparison",
1936
+ id: t.id,
1937
+ name: t.name,
1938
+ path: n,
1939
+ items: [{
1940
+ fixtureId: t.id,
1941
+ name: t.name,
1942
+ path: n
1943
+ }]
1944
+ }];
1945
+ if (t.type === "variants") {
1946
+ const o = [];
1947
+ for (const i of t.children ?? [])
1948
+ i.type === "component" && o.push({
1949
+ fixtureId: i.id,
1950
+ name: i.name,
1951
+ path: `${n} / ${i.name}`
1952
+ });
1953
+ return o.length > 0 ? [{
1954
+ type: "screenshot-comparison",
1955
+ id: t.id,
1956
+ name: t.name,
1957
+ path: n,
1958
+ items: o
1959
+ }] : [];
1960
+ }
1961
+ const s = [];
1962
+ for (const o of t.children ?? []) {
1963
+ const i = n ? `${n} / ${o.name}` : o.name;
1964
+ s.push(...this._collectDiffRows(o, i));
1965
+ }
1966
+ return s;
1967
+ }
1968
+ _collectReportRows(t, n) {
1969
+ const s = this.props.reportModel.state.get();
1970
+ if (s.status !== "ready") return [];
1971
+ const o = s.report.fixtures;
1972
+ if (t.type === "component") {
1973
+ const d = o[t.id];
1974
+ return d ? [{
1975
+ type: "report-comparison",
1976
+ id: t.id,
1977
+ name: t.name,
1978
+ path: n,
1979
+ items: [{
1980
+ fixtureId: t.id,
1981
+ name: t.name,
1982
+ path: n,
1983
+ entry: d
1984
+ }]
1985
+ }] : [];
1986
+ }
1987
+ const i = [];
1988
+ for (const d of t.children ?? []) {
1989
+ const c = n ? `${n} / ${d.name}` : d.name;
1990
+ i.push(...this._collectReportRows(d, c));
1991
+ }
1992
+ return i;
1993
+ }
1994
+ }
1995
+ const v = {
1996
+ container: {
1997
+ display: "flex",
1998
+ flexDirection: "row",
1999
+ height: "100%",
2000
+ width: "100%",
2001
+ fontFamily: "var(--vscode-font-family)",
2002
+ fontSize: "var(--vscode-font-size)",
2003
+ color: "var(--vscode-foreground)",
2004
+ backgroundColor: "var(--vscode-editor-background)"
2005
+ },
2006
+ centerArea: {
2007
+ display: "flex",
2008
+ flexDirection: "column",
2009
+ flex: 1,
2010
+ overflow: "hidden"
2011
+ },
2012
+ titleBar: {
2013
+ display: "flex",
2014
+ alignItems: "center",
2015
+ justifyContent: "space-between",
2016
+ height: "35px",
2017
+ minHeight: "35px",
2018
+ padding: "0 10px",
2019
+ backgroundColor: "var(--vscode-titleBar-activeBackground)",
2020
+ color: "var(--vscode-titleBar-activeForeground)",
2021
+ borderBottom: "1px solid var(--vscode-titleBar-border, var(--vscode-panel-border))"
2022
+ },
2023
+ titleBarSection: {
2024
+ display: "flex",
2025
+ alignItems: "center",
2026
+ gap: "2px"
2027
+ },
2028
+ titleBarCenter: {
2029
+ display: "flex",
2030
+ alignItems: "center",
2031
+ gap: "4px",
2032
+ fontSize: "13px",
2033
+ fontWeight: 400
2034
+ },
2035
+ titleBarButton: {
2036
+ display: "flex",
2037
+ alignItems: "center",
2038
+ justifyContent: "center",
2039
+ width: "28px",
2040
+ height: "28px",
2041
+ border: "none",
2042
+ background: "transparent",
2043
+ color: "var(--vscode-titleBar-activeForeground)",
2044
+ cursor: "pointer",
2045
+ borderRadius: "4px"
2046
+ },
2047
+ titleBarButtonHover: {
2048
+ backgroundColor: "var(--vscode-toolbar-hoverBackground)"
2049
+ },
2050
+ titleBarButtonActive: {
2051
+ backgroundColor: "var(--vscode-toolbar-activeBackground)",
2052
+ color: "var(--vscode-focusBorder)"
2053
+ },
2054
+ sidebar: {
2055
+ display: "flex",
2056
+ flexDirection: "column",
2057
+ width: "260px",
2058
+ minWidth: "200px",
2059
+ backgroundColor: "var(--vscode-sideBar-background)",
2060
+ borderRight: "1px solid var(--vscode-titleBar-border, var(--vscode-panel-border))"
2061
+ },
2062
+ sidebarRight: {
2063
+ borderRight: "none",
2064
+ borderLeft: "1px solid var(--vscode-titleBar-border, var(--vscode-panel-border))"
2065
+ },
2066
+ sidebarHeader: {
2067
+ display: "flex",
2068
+ alignItems: "center",
2069
+ height: "35px",
2070
+ minHeight: "35px",
2071
+ padding: "0 12px",
2072
+ fontSize: "11px",
2073
+ fontWeight: 700,
2074
+ textTransform: "uppercase",
2075
+ letterSpacing: "0.04em",
2076
+ color: "var(--vscode-titleBar-activeForeground)",
2077
+ backgroundColor: "var(--vscode-titleBar-activeBackground)",
2078
+ borderBottom: "1px solid var(--vscode-titleBar-border, var(--vscode-panel-border))"
2079
+ },
2080
+ sidebarContent: {
2081
+ flex: 1,
2082
+ overflow: "auto",
2083
+ padding: "4px 0"
2084
+ },
2085
+ treeItem: {
2086
+ display: "flex",
2087
+ alignItems: "center",
2088
+ height: "22px",
2089
+ paddingRight: "8px",
2090
+ cursor: "pointer",
2091
+ userSelect: "none"
2092
+ },
2093
+ treeItemSelected: {
2094
+ backgroundColor: "var(--vscode-list-activeSelectionBackground)",
2095
+ color: "var(--vscode-list-activeSelectionForeground)"
2096
+ },
2097
+ treeItemHover: {
2098
+ backgroundColor: "var(--vscode-list-hoverBackground)"
2099
+ },
2100
+ treeItemChevron: {
2101
+ display: "flex",
2102
+ alignItems: "center",
2103
+ justifyContent: "center",
2104
+ width: "16px",
2105
+ height: "16px",
2106
+ color: "var(--vscode-foreground)",
2107
+ opacity: 0.8,
2108
+ cursor: "pointer"
2109
+ },
2110
+ treeItemChevronPlaceholder: {
2111
+ width: "16px"
2112
+ },
2113
+ treeItemIcon: {
2114
+ display: "flex",
2115
+ alignItems: "center",
2116
+ justifyContent: "center",
2117
+ width: "16px",
2118
+ height: "16px",
2119
+ marginRight: "4px"
2120
+ },
2121
+ treeItemLabel: {
2122
+ flex: 1,
2123
+ overflow: "hidden",
2124
+ textOverflow: "ellipsis",
2125
+ whiteSpace: "nowrap",
2126
+ fontSize: "13px"
2127
+ },
2128
+ treeItemCount: {
2129
+ marginLeft: "8px",
2130
+ fontSize: "11px",
2131
+ color: "var(--vscode-descriptionForeground)"
2132
+ },
2133
+ mainContent: {
2134
+ flex: 1,
2135
+ display: "flex",
2136
+ alignItems: "center",
2137
+ justifyContent: "center",
2138
+ backgroundColor: "var(--vscode-editor-background)",
2139
+ color: "var(--vscode-descriptionForeground)",
2140
+ fontSize: "14px"
2141
+ },
2142
+ propertiesPanel: {
2143
+ padding: "12px"
2144
+ },
2145
+ propertyRow: {
2146
+ marginBottom: "12px"
2147
+ },
2148
+ propertyLabel: {
2149
+ fontSize: "12px",
2150
+ color: "var(--vscode-foreground)",
2151
+ marginBottom: "4px"
2152
+ },
2153
+ propertyDescription: {
2154
+ fontSize: "11px",
2155
+ color: "var(--vscode-descriptionForeground)",
2156
+ marginTop: "2px"
2157
+ },
2158
+ propertyInput: {
2159
+ width: "100%",
2160
+ height: "26px",
2161
+ padding: "0 8px",
2162
+ fontSize: "13px",
2163
+ color: "var(--vscode-input-foreground)",
2164
+ backgroundColor: "var(--vscode-input-background)",
2165
+ border: "1px solid var(--vscode-input-border, transparent)",
2166
+ borderRadius: "2px",
2167
+ outline: "none",
2168
+ boxSizing: "border-box"
2169
+ },
2170
+ propertySelect: {
2171
+ width: "100%",
2172
+ height: "26px",
2173
+ padding: "0 8px",
2174
+ fontSize: "13px",
2175
+ color: "var(--vscode-dropdown-foreground)",
2176
+ backgroundColor: "var(--vscode-dropdown-background)",
2177
+ border: "1px solid var(--vscode-dropdown-border)",
2178
+ borderRadius: "2px",
2179
+ outline: "none",
2180
+ boxSizing: "border-box",
2181
+ cursor: "pointer"
2182
+ }
2183
+ };
2184
+ function Ce(...r) {
2185
+ return Object.assign({}, ...r.filter(Boolean));
2186
+ }
2187
+ class Er extends B({
2188
+ active: f()
2189
+ }) {
2190
+ constructor() {
2191
+ super(...arguments);
2192
+ l(this, "isHovered", x(this, !1));
2193
+ l(this, "setHovered", (t) => {
2194
+ this.isHovered.set(t, void 0);
2195
+ });
2196
+ }
2197
+ get active() {
2198
+ return this.props.active;
2199
+ }
2200
+ }
2201
+ const oe = A(
2202
+ Er,
2203
+ {
2204
+ onClick: f.const(),
2205
+ title: f.const(),
2206
+ children: f.const()
2207
+ },
2208
+ (r, e, t) => {
2209
+ const n = e.isHovered.read(r), s = e.active.read(r), o = Ce(
2210
+ v.titleBarButton,
2211
+ n && !s && v.titleBarButtonHover,
2212
+ s && v.titleBarButtonActive
2213
+ );
2214
+ return /* @__PURE__ */ a(
2215
+ "button",
2216
+ {
2217
+ style: o,
2218
+ onClick: t.onClick,
2219
+ title: t.title,
2220
+ onMouseEnter: () => e.setHovered(!0),
2221
+ onMouseLeave: () => e.setHovered(!1),
2222
+ children: t.children
2223
+ }
2224
+ );
2225
+ }
2226
+ ), Dr = ({ style: r }) => /* @__PURE__ */ a("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", style: r, children: /* @__PURE__ */ a("path", { d: "M5.7 13.7L5 13l4.6-4.6L5 3.7l.7-.7 5.3 5.4-5.3 5.3z" }) }), Br = ({ style: r }) => /* @__PURE__ */ a("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", style: r, children: /* @__PURE__ */ a("path", { d: "M11 5.5L6 10.5L5.3 9.8L9.6 5.5L5.3 1.2L6 0.5L11 5.5z", transform: "rotate(90 8 5.5)" }) }), Ar = ({ style: r }) => /* @__PURE__ */ a("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", style: r, children: /* @__PURE__ */ a("path", { d: "M14.5 2H9l-.35.15-.65.64-.65-.64L7 2H1.5l-.5.5v10l.5.5H7l.35-.15.65-.64.65.64.35.15h5.5l.5-.5v-10l-.5-.5zm-7 10H2V3h5v.86L5.85 5l1.15 1.14V10l-1.15-1.14L7 7.72V12zm6 0H8V7.72l1.15 1.14L8 10V6.14L9.15 5 8 3.86V3h5v9z" }) }), $r = ({ style: r }) => /* @__PURE__ */ a("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", style: r, children: /* @__PURE__ */ a("path", { d: "M14.5 3H7.71l-.85-.85L6.5 2h-5l-.5.5v11l.5.5h13l.5-.5v-10l-.5-.5zm-.5 10H2V6h12v7zm0-8H2V3h4.29l.85.85.36.15H14v1z" }) }), zr = () => /* @__PURE__ */ a("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ a("path", { d: "M2 2v12h12V2H2zm11 11H6V3h7v10zM3 3h2v10H3V3z" }) }), Lr = () => /* @__PURE__ */ a("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ a("path", { d: "M2 2v12h12V2H2zm6 11V3h5v10H8zM3 3h4v10H3V3z" }) }), Hr = () => /* @__PURE__ */ a("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ a("path", { d: "M8 11a3 3 0 1 1 0-6 3 3 0 0 1 0 6zm0 1a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM8 0a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 0zm0 13a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 13zm8-5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2a.5.5 0 0 1 .5.5zM3 8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2A.5.5 0 0 1 3 8zm10.657-5.657a.5.5 0 0 1 0 .707l-1.414 1.415a.5.5 0 1 1-.707-.708l1.414-1.414a.5.5 0 0 1 .707 0zm-9.193 9.193a.5.5 0 0 1 0 .707L3.05 13.657a.5.5 0 0 1-.707-.707l1.414-1.414a.5.5 0 0 1 .707 0zm9.193 2.121a.5.5 0 0 1-.707 0l-1.414-1.414a.5.5 0 0 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .707zM4.464 4.465a.5.5 0 0 1-.707 0L2.343 3.05a.5.5 0 1 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .708z" }) }), jr = () => /* @__PURE__ */ a("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ a("path", { d: "M6 .278a.768.768 0 0 1 .08.858 7.208 7.208 0 0 0-.878 3.46c0 4.021 3.278 7.277 7.318 7.277.527 0 1.04-.055 1.533-.16a.787.787 0 0 1 .81.316.733.733 0 0 1-.031.893A8.349 8.349 0 0 1 8.344 16C3.734 16 0 12.286 0 7.71 0 4.266 2.114 1.312 5.124.06A.752.752 0 0 1 6 .278z" }) }), Ur = k(
2227
+ { model: f.const() },
2228
+ (r, e) => {
2229
+ var d, c;
2230
+ const t = e.model, n = t.viewMode.read(r), s = ((d = t.daemon) == null ? void 0 : d.sessions.read(r)) ?? [], o = (c = t.daemon) == null ? void 0 : c.sessionName, i = s.filter((u) => u.name !== o);
2231
+ return s.length <= 1 ? null : /* @__PURE__ */ g("div", { style: Q.container, children: [
2232
+ /* @__PURE__ */ g("div", { style: Q.segmentedControl, children: [
2233
+ /* @__PURE__ */ a(ze, { label: "Live", mode: "session", active: n === "session", onClick: () => t.setViewMode("session") }),
2234
+ /* @__PURE__ */ a(ze, { label: "Diff", mode: "diff", active: n === "diff", onClick: () => t.setViewMode("diff") })
2235
+ ] }),
2236
+ i.length > 0 && /* @__PURE__ */ a("div", { style: Q.sessionLinks, children: i.map((u) => /* @__PURE__ */ g(
2237
+ "button",
2238
+ {
2239
+ style: Q.sessionLink,
2240
+ onClick: () => t.navigateToSession(u.name),
2241
+ title: `Switch to ${u.name} session`,
2242
+ children: [
2243
+ "→ ",
2244
+ u.name
2245
+ ]
2246
+ },
2247
+ u.name
2248
+ )) })
2249
+ ] });
2250
+ }
2251
+ );
2252
+ function ze({ label: r, mode: e, active: t, onClick: n }) {
2253
+ return /* @__PURE__ */ a(
2254
+ "button",
2255
+ {
2256
+ style: t ? Q.segmentActive : Q.segment,
2257
+ onClick: n,
2258
+ children: r
2259
+ }
2260
+ );
2261
+ }
2262
+ const Pr = k(
2263
+ {
2264
+ model: f.const()
2265
+ },
2266
+ (r, e) => {
2267
+ const t = e.model, n = t.leftSidebarVisible.read(r), s = t.rightSidebarVisible.read(r), o = t.isDarkTheme.read(r), i = t.selectedNode.read(r);
2268
+ return /* @__PURE__ */ g("div", { style: v.titleBar, children: [
2269
+ /* @__PURE__ */ a("div", { style: v.titleBarSection, children: /* @__PURE__ */ a(
2270
+ oe,
2271
+ {
2272
+ active: n,
2273
+ onClick: t.toggleLeftSidebar,
2274
+ title: "Toggle left sidebar",
2275
+ children: /* @__PURE__ */ a(zr, {})
2276
+ }
2277
+ ) }),
2278
+ /* @__PURE__ */ g("div", { style: v.titleBarCenter, children: [
2279
+ t.isReportMode ? /* @__PURE__ */ a("span", { style: { fontSize: 12, color: "var(--vscode-descriptionForeground)" }, children: "Screenshot Report" }) : t.daemonAvailable ? /* @__PURE__ */ a(Ur, { model: t }) : null,
2280
+ i ? /* @__PURE__ */ g(me, { children: [
2281
+ /* @__PURE__ */ a("span", { style: { color: "var(--vscode-textLink-foreground)" }, children: "<" }),
2282
+ /* @__PURE__ */ a("span", { children: i.name }),
2283
+ /* @__PURE__ */ a("span", { style: { color: "var(--vscode-textLink-foreground)" }, children: "/>" })
2284
+ ] }) : /* @__PURE__ */ a("span", { style: { color: "var(--vscode-descriptionForeground)" }, children: "No component selected" })
2285
+ ] }),
2286
+ /* @__PURE__ */ g("div", { style: v.titleBarSection, children: [
2287
+ /* @__PURE__ */ a(
2288
+ oe,
2289
+ {
2290
+ active: !1,
2291
+ onClick: t.toggleTheme,
2292
+ title: o ? "Switch to light theme" : "Switch to dark theme",
2293
+ children: o ? /* @__PURE__ */ a(Hr, {}) : /* @__PURE__ */ a(jr, {})
2294
+ }
2295
+ ),
2296
+ /* @__PURE__ */ a(
2297
+ oe,
2298
+ {
2299
+ active: s,
2300
+ onClick: t.toggleRightSidebar,
2301
+ title: "Toggle right sidebar",
2302
+ children: /* @__PURE__ */ a(Lr, {})
2303
+ }
2304
+ )
2305
+ ] })
2306
+ ] });
2307
+ }
2308
+ ), Q = {
2309
+ container: {
2310
+ display: "flex",
2311
+ alignItems: "center",
2312
+ gap: 8,
2313
+ marginRight: 12
2314
+ },
2315
+ segmentedControl: {
2316
+ display: "flex",
2317
+ borderRadius: 4,
2318
+ overflow: "hidden",
2319
+ border: "1px solid var(--vscode-panel-border)"
2320
+ },
2321
+ segment: {
2322
+ padding: "2px 10px",
2323
+ fontSize: 11,
2324
+ fontWeight: 500,
2325
+ border: "none",
2326
+ background: "transparent",
2327
+ color: "var(--vscode-descriptionForeground)",
2328
+ cursor: "pointer"
2329
+ },
2330
+ segmentActive: {
2331
+ padding: "2px 10px",
2332
+ fontSize: 11,
2333
+ fontWeight: 500,
2334
+ border: "none",
2335
+ background: "var(--vscode-button-background)",
2336
+ color: "var(--vscode-button-foreground)",
2337
+ cursor: "pointer"
2338
+ },
2339
+ sessionLinks: {
2340
+ display: "flex",
2341
+ gap: 4
2342
+ },
2343
+ sessionLink: {
2344
+ padding: "2px 8px",
2345
+ fontSize: 11,
2346
+ border: "1px solid var(--vscode-panel-border)",
2347
+ borderRadius: 4,
2348
+ background: "transparent",
2349
+ color: "var(--vscode-textLink-foreground)",
2350
+ cursor: "pointer"
2351
+ }
2352
+ }, Wr = {
2353
+ display: "flex",
2354
+ gap: "3px",
2355
+ marginLeft: "6px",
2356
+ overflow: "hidden",
2357
+ flexShrink: 1,
2358
+ minWidth: 0
2359
+ }, Gr = {
2360
+ fontSize: "10px",
2361
+ lineHeight: "14px",
2362
+ padding: "0 4px",
2363
+ borderRadius: "2px",
2364
+ backgroundColor: "var(--vscode-badge-background)",
2365
+ color: "var(--vscode-badge-foreground)",
2366
+ whiteSpace: "nowrap",
2367
+ overflow: "hidden",
2368
+ textOverflow: "ellipsis",
2369
+ maxWidth: "60px",
2370
+ cursor: "pointer"
2371
+ }, bt = k(
2372
+ {
2373
+ model: f.const(),
2374
+ nodes: f.const(),
2375
+ depth: f.const()
2376
+ },
2377
+ (r, e) => /* @__PURE__ */ a(me, { children: e.nodes.map((t) => /* @__PURE__ */ a(Kr, { model: e.model, node: t, depth: e.depth }, t.id)) })
2378
+ );
2379
+ class qr extends B({
2380
+ model: f.const(),
2381
+ node: f.const(),
2382
+ depth: f.const()
2383
+ }) {
2384
+ constructor() {
2385
+ super(...arguments);
2386
+ l(this, "isHovered", x(this, !1));
2387
+ l(this, "setHovered", (t) => {
2388
+ this.isHovered.set(t, void 0);
2389
+ });
2390
+ l(this, "handleClick", () => {
2391
+ this.props.model.selectNode(this.props.node.id);
2392
+ });
2393
+ l(this, "handleDoubleClick", () => {
2394
+ this._hasChildren && this.props.model.toggleNodeExpanded(this.props.node.id);
2395
+ });
2396
+ l(this, "handleChevronClick", (t) => {
2397
+ t.stopPropagation(), this.props.model.toggleNodeExpanded(this.props.node.id);
2398
+ });
2399
+ }
2400
+ // Expose props for render function
2401
+ get explorerModel() {
2402
+ return this.props.model;
2403
+ }
2404
+ get treeNode() {
2405
+ return this.props.node;
2406
+ }
2407
+ get treeDepth() {
2408
+ return this.props.depth;
2409
+ }
2410
+ get _hasChildren() {
2411
+ return !!(this.props.node.children && this.props.node.children.length > 0);
2412
+ }
2413
+ }
2414
+ const Kr = A(qr, {}, (r, e) => {
2415
+ const t = e.explorerModel, n = e.treeNode, s = e.treeDepth, o = !!(n.children && n.children.length > 0), i = o ? t.isNodeExpanded(n.id, r) : !1, c = t.selectedNodeId.read(r) === n.id, u = e.isHovered.read(r), h = Ce(
2416
+ v.treeItem,
2417
+ { paddingLeft: `${8 + s * 12}px` },
2418
+ c && v.treeItemSelected,
2419
+ !c && u && v.treeItemHover
2420
+ );
2421
+ return /* @__PURE__ */ g(me, { children: [
2422
+ /* @__PURE__ */ g(
2423
+ "div",
2424
+ {
2425
+ style: h,
2426
+ onClick: e.handleClick,
2427
+ onDoubleClick: e.handleDoubleClick,
2428
+ onMouseEnter: () => e.setHovered(!0),
2429
+ onMouseLeave: () => e.setHovered(!1),
2430
+ children: [
2431
+ o ? /* @__PURE__ */ a("div", { style: v.treeItemChevron, onClick: e.handleChevronClick, children: i ? /* @__PURE__ */ a(Br, {}) : /* @__PURE__ */ a(Dr, {}) }) : /* @__PURE__ */ a("div", { style: v.treeItemChevronPlaceholder }),
2432
+ /* @__PURE__ */ a("div", { style: v.treeItemIcon, children: n.type === "folder" ? /* @__PURE__ */ a($r, { style: { color: "var(--vscode-symbolIcon-folderForeground)" } }) : /* @__PURE__ */ a(Ar, { style: { color: "#deb45b" } }) }),
2433
+ /* @__PURE__ */ a("span", { style: v.treeItemLabel, children: n.name }),
2434
+ n.labels.some((p) => !p.startsWith(".")) && /* @__PURE__ */ a("span", { style: Wr, children: n.labels.filter((p) => !p.startsWith(".")).map((p) => /* @__PURE__ */ a(
2435
+ "span",
2436
+ {
2437
+ style: Gr,
2438
+ onClick: (m) => {
2439
+ m.stopPropagation(), t.searchQuery.set(p, void 0);
2440
+ },
2441
+ title: p,
2442
+ children: p
2443
+ },
2444
+ p
2445
+ )) }),
2446
+ o && /* @__PURE__ */ a("span", { style: v.treeItemCount, children: n.children.length })
2447
+ ]
2448
+ }
2449
+ ),
2450
+ o && i && /* @__PURE__ */ a(bt, { model: t, nodes: n.children, depth: s + 1 })
2451
+ ] });
2452
+ }), Jr = {
2453
+ padding: "4px 8px",
2454
+ borderBottom: "1px solid var(--vscode-panel-border)"
2455
+ }, Qr = {
2456
+ width: "100%",
2457
+ height: "24px",
2458
+ padding: "0 22px 0 6px",
2459
+ fontSize: "12px",
2460
+ color: "var(--vscode-input-foreground)",
2461
+ backgroundColor: "var(--vscode-input-background)",
2462
+ border: "1px solid var(--vscode-input-border, transparent)",
2463
+ borderRadius: "2px",
2464
+ outline: "none",
2465
+ boxSizing: "border-box"
2466
+ }, Zr = {
2467
+ position: "relative"
2468
+ }, Xr = {
2469
+ position: "absolute",
2470
+ right: "2px",
2471
+ top: "50%",
2472
+ transform: "translateY(-50%)",
2473
+ display: "flex",
2474
+ alignItems: "center",
2475
+ justifyContent: "center",
2476
+ width: "18px",
2477
+ height: "18px",
2478
+ border: "none",
2479
+ background: "transparent",
2480
+ color: "var(--vscode-input-foreground)",
2481
+ cursor: "pointer",
2482
+ borderRadius: "2px",
2483
+ fontSize: "14px",
2484
+ opacity: 0.7
2485
+ }, Yr = k(
2486
+ {
2487
+ model: f.const()
2488
+ },
2489
+ (r, e) => {
2490
+ const t = e.model.searchQuery.read(r);
2491
+ return /* @__PURE__ */ a("div", { style: Jr, children: /* @__PURE__ */ g("div", { style: Zr, children: [
2492
+ /* @__PURE__ */ a(
2493
+ "input",
2494
+ {
2495
+ type: "text",
2496
+ placeholder: "Filter (name or label)",
2497
+ style: Qr,
2498
+ value: t ?? "",
2499
+ onChange: (n) => e.model.searchQuery.set(n.target.value || void 0, void 0),
2500
+ onFocus: (n) => n.target.style.borderColor = "var(--vscode-focusBorder)",
2501
+ onBlur: (n) => n.target.style.borderColor = "var(--vscode-input-border, transparent)"
2502
+ }
2503
+ ),
2504
+ t && /* @__PURE__ */ a(
2505
+ "button",
2506
+ {
2507
+ style: Xr,
2508
+ onClick: () => e.model.searchQuery.set(void 0, void 0),
2509
+ title: "Clear filter",
2510
+ children: "×"
2511
+ }
2512
+ )
2513
+ ] }) });
2514
+ }
2515
+ ), en = k(
2516
+ {
2517
+ model: f.const()
2518
+ },
2519
+ (r, e) => {
2520
+ const t = e.model.filteredTree.read(r);
2521
+ return /* @__PURE__ */ g("div", { style: v.sidebar, children: [
2522
+ /* @__PURE__ */ a("div", { style: v.sidebarHeader, children: "Explorer" }),
2523
+ /* @__PURE__ */ a(Yr, { model: e.model }),
2524
+ /* @__PURE__ */ a("div", { style: v.sidebarContent, children: /* @__PURE__ */ a(bt, { model: e.model, nodes: [t], depth: 0 }) })
2525
+ ] });
2526
+ }
2527
+ );
2528
+ class tn extends B({}) {
2529
+ constructor() {
2530
+ super(...arguments);
2531
+ l(this, "checked", x(this, !1));
2532
+ l(this, "toggle", () => {
2533
+ this.checked.set(!this.checked.get(), void 0);
2534
+ });
2535
+ }
2536
+ }
2537
+ const rn = A(tn, {}, (r, e) => {
2538
+ const t = e.checked.read(r), n = {
2539
+ position: "relative",
2540
+ width: "36px",
2541
+ height: "18px",
2542
+ backgroundColor: t ? "var(--vscode-button-background)" : "var(--vscode-input-background)",
2543
+ borderRadius: "9px",
2544
+ cursor: "pointer",
2545
+ transition: "background-color 0.2s",
2546
+ border: "1px solid var(--vscode-input-border, transparent)"
2547
+ }, s = {
2548
+ position: "absolute",
2549
+ top: "2px",
2550
+ left: t ? "18px" : "2px",
2551
+ width: "12px",
2552
+ height: "12px",
2553
+ backgroundColor: "var(--vscode-foreground)",
2554
+ borderRadius: "50%",
2555
+ transition: "left 0.2s"
2556
+ };
2557
+ return /* @__PURE__ */ a("div", { style: n, onClick: e.toggle, children: /* @__PURE__ */ a("div", { style: s }) });
2558
+ }), nn = k(
2559
+ {
2560
+ node: f.const()
2561
+ },
2562
+ (r, e) => e.node.type !== "component" ? /* @__PURE__ */ a("div", { style: { padding: "12px", color: "var(--vscode-descriptionForeground)", fontSize: "12px" }, children: "Select a component (not a folder) to view its properties" }) : /* @__PURE__ */ g("div", { style: v.propertiesPanel, children: [
2563
+ /* @__PURE__ */ g("div", { style: v.propertyRow, children: [
2564
+ /* @__PURE__ */ g("div", { style: v.propertyLabel, children: [
2565
+ "children",
2566
+ /* @__PURE__ */ a("span", { style: { color: "var(--vscode-descriptionForeground)" }, children: " : string" })
2567
+ ] }),
2568
+ /* @__PURE__ */ a(
2569
+ "input",
2570
+ {
2571
+ type: "text",
2572
+ style: v.propertyInput,
2573
+ defaultValue: "Click me",
2574
+ placeholder: "Enter text..."
2575
+ }
2576
+ ),
2577
+ /* @__PURE__ */ a("div", { style: v.propertyDescription, children: "Button text content" })
2578
+ ] }),
2579
+ /* @__PURE__ */ g("div", { style: v.propertyRow, children: [
2580
+ /* @__PURE__ */ g("div", { style: v.propertyLabel, children: [
2581
+ "variant",
2582
+ /* @__PURE__ */ a("span", { style: { color: "var(--vscode-descriptionForeground)" }, children: " : select" })
2583
+ ] }),
2584
+ /* @__PURE__ */ g("select", { style: v.propertySelect, defaultValue: "default", children: [
2585
+ /* @__PURE__ */ a("option", { value: "default", children: "default" }),
2586
+ /* @__PURE__ */ a("option", { value: "primary", children: "primary" }),
2587
+ /* @__PURE__ */ a("option", { value: "secondary", children: "secondary" }),
2588
+ /* @__PURE__ */ a("option", { value: "destructive", children: "destructive" })
2589
+ ] }),
2590
+ /* @__PURE__ */ a("div", { style: v.propertyDescription, children: "Visual style variant" })
2591
+ ] }),
2592
+ /* @__PURE__ */ g("div", { style: v.propertyRow, children: [
2593
+ /* @__PURE__ */ g("div", { style: v.propertyLabel, children: [
2594
+ "size",
2595
+ /* @__PURE__ */ a("span", { style: { color: "var(--vscode-descriptionForeground)" }, children: " : select" })
2596
+ ] }),
2597
+ /* @__PURE__ */ g("select", { style: v.propertySelect, defaultValue: "default", children: [
2598
+ /* @__PURE__ */ a("option", { value: "sm", children: "sm" }),
2599
+ /* @__PURE__ */ a("option", { value: "default", children: "default" }),
2600
+ /* @__PURE__ */ a("option", { value: "lg", children: "lg" })
2601
+ ] }),
2602
+ /* @__PURE__ */ a("div", { style: v.propertyDescription, children: "Button size" })
2603
+ ] }),
2604
+ /* @__PURE__ */ g("div", { style: v.propertyRow, children: [
2605
+ /* @__PURE__ */ g("div", { style: v.propertyLabel, children: [
2606
+ "disabled",
2607
+ /* @__PURE__ */ a("span", { style: { color: "var(--vscode-descriptionForeground)" }, children: " : boolean" })
2608
+ ] }),
2609
+ /* @__PURE__ */ a(rn, {}),
2610
+ /* @__PURE__ */ a("div", { style: v.propertyDescription, children: "Disable the button" })
2611
+ ] })
2612
+ ] })
2613
+ ), sn = k(
2614
+ {
2615
+ selectedNode: f.const()
2616
+ },
2617
+ (r, e) => /* @__PURE__ */ g("div", { style: Ce(v.sidebar, v.sidebarRight), children: [
2618
+ /* @__PURE__ */ g("div", { style: v.sidebarHeader, children: [
2619
+ /* @__PURE__ */ a("span", { style: { marginRight: "6px", color: "var(--vscode-textLink-foreground)" }, children: "</>" }),
2620
+ "Props"
2621
+ ] }),
2622
+ /* @__PURE__ */ a("div", { style: v.sidebarContent, children: e.selectedNode ? /* @__PURE__ */ a(nn, { node: e.selectedNode }) : /* @__PURE__ */ a("div", { style: { padding: "12px", color: "var(--vscode-descriptionForeground)", fontSize: "12px" }, children: "Select a component to view its properties" }) })
2623
+ ] })
2624
+ ), _t = /* @__PURE__ */ new WeakSet(), Le = HTMLElement.prototype.focus;
2625
+ HTMLElement.prototype.focus = function(r) {
2626
+ const e = this.getRootNode();
2627
+ e instanceof ShadowRoot && _t.has(e) && !(r != null && r.preventScroll) ? Le.call(this, { ...r, preventScroll: !0 }) : Le.call(this, r);
2628
+ };
2629
+ function on(r) {
2630
+ _t.add(r);
2631
+ }
2632
+ class an extends B({
2633
+ fixture: f.const(),
2634
+ compact: f.const(),
2635
+ onSelect: f.const()
2636
+ }) {
2637
+ constructor() {
2638
+ super(...arguments);
2639
+ l(this, "_containerRef", null);
2640
+ l(this, "_rendering", null);
2641
+ l(this, "_resizeObserver", null);
2642
+ l(this, "measuredWidth", x(this, void 0));
2643
+ l(this, "measuredHeight", x(this, void 0));
2644
+ l(this, "setContainerRef", (t) => {
2645
+ if (t === this._containerRef || (this._cleanup(), this._containerRef = t, !t)) return;
2646
+ const n = new ft(t, this.fixture.component);
2647
+ this._rendering = n, n.shadowRoot && on(n.shadowRoot);
2648
+ const s = n.renderTarget;
2649
+ this._resizeObserver = new ResizeObserver((o) => {
2650
+ for (const i of o) {
2651
+ const { width: d, height: c } = i.contentRect;
2652
+ c > 0 && (this.measuredWidth.set(Math.round(d), void 0), this.measuredHeight.set(Math.round(c), void 0));
2653
+ }
2654
+ }), this._resizeObserver.observe(s);
2655
+ });
2656
+ }
2657
+ get fixture() {
2658
+ return this.props.fixture;
2659
+ }
2660
+ get compact() {
2661
+ return this.props.compact ?? !1;
2662
+ }
2663
+ get onSelect() {
2664
+ return this.props.onSelect;
2665
+ }
2666
+ _cleanup() {
2667
+ var t, n;
2668
+ (t = this._rendering) == null || t.dispose(), this._rendering = null, (n = this._resizeObserver) == null || n.disconnect(), this._resizeObserver = null;
2669
+ }
2670
+ dispose() {
2671
+ this._cleanup();
2672
+ }
2673
+ }
2674
+ const yt = A(
2675
+ an,
2676
+ {},
2677
+ (r, e) => {
2678
+ const t = e.fixture, n = t.component, s = n.displayMode, o = e.measuredWidth.read(r), i = e.measuredHeight.read(r), d = e.compact;
2679
+ let c;
2680
+ if (s.type === "page") {
2681
+ const m = s.viewports[0], b = zt(m);
2682
+ c = {
2683
+ width: b.width,
2684
+ height: b.height,
2685
+ overflow: "auto"
2686
+ };
2687
+ } else
2688
+ c = {
2689
+ display: "inline-block"
2690
+ };
2691
+ const u = o && i ? `${o} × ${i}` : "", h = d ? q.wrapperCompact : q.wrapper, p = d ? q.nameCompact : q.name;
2692
+ return /* @__PURE__ */ g("div", { style: h, children: [
2693
+ /* @__PURE__ */ g("div", { style: q.labelRow, children: [
2694
+ d && /* @__PURE__ */ a(
2695
+ "a",
2696
+ {
2697
+ href: vt("component", t.id),
2698
+ style: { ...p, textDecoration: "none", color: "inherit" },
2699
+ onClick: (m) => {
2700
+ e.onSelect && (m.preventDefault(), e.onSelect(t.id));
2701
+ },
2702
+ children: t.name
2703
+ }
2704
+ ),
2705
+ !d && u && /* @__PURE__ */ a("span", { style: q.dimensions, children: u })
2706
+ ] }),
2707
+ /* @__PURE__ */ a("div", { style: hn(n.background), children: /* @__PURE__ */ a("div", { ref: e.setContainerRef, style: c }) })
2708
+ ] });
2709
+ }
2710
+ ), G = 8;
2711
+ function xt(r, e) {
2712
+ return `
2713
+ linear-gradient(45deg, ${e} 25%, transparent 25%),
2714
+ linear-gradient(-45deg, ${e} 25%, transparent 25%),
2715
+ linear-gradient(45deg, transparent 75%, ${e} 75%),
2716
+ linear-gradient(-45deg, transparent 75%, ${e} 75%)
2717
+ `;
2718
+ }
2719
+ const dn = {
2720
+ backgroundColor: "#ffffff",
2721
+ backgroundImage: xt("#ffffff", "#e5e5e5")
2722
+ }, cn = {
2723
+ backgroundColor: "#1e1e1e",
2724
+ backgroundImage: xt("#1e1e1e", "#2d2d2d")
2725
+ }, ln = {
2726
+ display: "inline-block",
2727
+ padding: "12px",
2728
+ borderRadius: "4px",
2729
+ backgroundSize: `${G * 2}px ${G * 2}px`,
2730
+ backgroundPosition: `0 0, 0 ${G}px, ${G}px -${G}px, -${G}px 0`,
2731
+ boxShadow: "0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08)",
2732
+ overflow: "hidden",
2733
+ position: "relative"
2734
+ };
2735
+ function hn(r) {
2736
+ const e = r === "dark" ? cn : dn;
2737
+ return {
2738
+ ...ln,
2739
+ backgroundColor: e.backgroundColor,
2740
+ backgroundImage: e.backgroundImage
2741
+ };
2742
+ }
2743
+ const q = {
2744
+ wrapper: {
2745
+ marginBottom: "32px"
2746
+ },
2747
+ wrapperCompact: {
2748
+ marginBottom: "0"
2749
+ },
2750
+ labelRow: {
2751
+ display: "flex",
2752
+ alignItems: "baseline",
2753
+ gap: "8px",
2754
+ marginBottom: "8px"
2755
+ },
2756
+ name: {
2757
+ fontSize: "12px",
2758
+ fontWeight: 500,
2759
+ color: "var(--vscode-foreground)"
2760
+ },
2761
+ nameCompact: {
2762
+ fontSize: "11px",
2763
+ fontWeight: 500,
2764
+ color: "var(--vscode-descriptionForeground)"
2765
+ },
2766
+ dimensions: {
2767
+ fontSize: "11px",
2768
+ color: "var(--vscode-descriptionForeground)",
2769
+ fontFamily: "var(--vscode-editor-font-family, monospace)"
2770
+ }
2771
+ };
2772
+ class un extends B({
2773
+ fixtureId: f.const(),
2774
+ sessionName: f.const(),
2775
+ daemon: f.const()
2776
+ }) {
2777
+ constructor(t) {
2778
+ super(t);
2779
+ l(this, "screenshot", x(this, { status: "idle" }));
2780
+ l(this, "_fetchVersion", 0);
2781
+ this._store.add(dt((n) => {
2782
+ this.props.daemon.sourceTreeIds.read(n).get(this.props.sessionName) && this._fetchScreenshot();
2783
+ }));
2784
+ }
2785
+ get fixtureId() {
2786
+ return this.props.fixtureId;
2787
+ }
2788
+ async _fetchScreenshot() {
2789
+ const t = ++this._fetchVersion;
2790
+ this.screenshot.set({ status: "loading" }, void 0);
2791
+ try {
2792
+ const n = await this.props.daemon.getScreenshot(this.props.sessionName, this.props.fixtureId);
2793
+ t === this._fetchVersion && this.screenshot.set({ status: "ready", data: n }, void 0);
2794
+ } catch (n) {
2795
+ t === this._fetchVersion && this.screenshot.set({ status: "error", message: String(n) }, void 0);
2796
+ }
2797
+ }
2798
+ }
2799
+ const He = A(
2800
+ un,
2801
+ {},
2802
+ (r, e) => {
2803
+ const t = e.screenshot.read(r);
2804
+ if (t.status === "idle" || t.status === "loading")
2805
+ return /* @__PURE__ */ a("div", { style: $.placeholder, children: /* @__PURE__ */ a("div", { style: $.shimmer }) });
2806
+ if (t.status === "error")
2807
+ return /* @__PURE__ */ a("div", { style: $.error, children: /* @__PURE__ */ a("span", { style: $.errorText, children: "Screenshot failed" }) });
2808
+ const { data: n } = t;
2809
+ return n.image ? /* @__PURE__ */ a(
2810
+ "img",
2811
+ {
2812
+ src: `data:image/png;base64,${n.image}`,
2813
+ style: $.image,
2814
+ alt: `Screenshot of ${e.fixtureId}`
2815
+ }
2816
+ ) : /* @__PURE__ */ a("div", { style: $.placeholder, children: /* @__PURE__ */ a("span", { style: $.hashText, children: n.hash.slice(0, 12) }) });
2817
+ }
2818
+ ), $ = {
2819
+ placeholder: {
2820
+ minHeight: 80,
2821
+ display: "flex",
2822
+ alignItems: "center",
2823
+ justifyContent: "center",
2824
+ backgroundColor: "var(--vscode-editor-background)",
2825
+ border: "1px solid var(--vscode-panel-border)",
2826
+ borderRadius: 4,
2827
+ overflow: "hidden"
2828
+ },
2829
+ shimmer: {
2830
+ width: "100%",
2831
+ height: 80,
2832
+ background: "linear-gradient(90deg, var(--vscode-editor-background) 25%, var(--vscode-list-hoverBackground) 50%, var(--vscode-editor-background) 75%)",
2833
+ backgroundSize: "200% 100%",
2834
+ animation: "shimmer 1.5s infinite"
2835
+ },
2836
+ error: {
2837
+ minHeight: 80,
2838
+ display: "flex",
2839
+ alignItems: "center",
2840
+ justifyContent: "center",
2841
+ backgroundColor: "var(--vscode-inputValidation-errorBackground)",
2842
+ border: "1px solid var(--vscode-inputValidation-errorBorder)",
2843
+ borderRadius: 4
2844
+ },
2845
+ errorText: {
2846
+ fontSize: 12,
2847
+ color: "var(--vscode-errorForeground)"
2848
+ },
2849
+ hashText: {
2850
+ fontSize: 11,
2851
+ color: "var(--vscode-descriptionForeground)",
2852
+ fontFamily: "var(--vscode-editor-font-family, monospace)"
2853
+ },
2854
+ image: {
2855
+ maxWidth: "100%",
2856
+ display: "block",
2857
+ borderRadius: 4,
2858
+ border: "1px solid var(--vscode-panel-border)"
2859
+ }
2860
+ };
2861
+ class pn extends B({
2862
+ fixtureId: f.const(),
2863
+ daemon: f.const(),
2864
+ baselineSession: f.const(),
2865
+ currentSession: f.const()
2866
+ }) {
2867
+ constructor(t) {
2868
+ super(t);
2869
+ l(this, "comparisonStatus", x(this, { status: "loading" }));
2870
+ this._store.add(dt((n) => {
2871
+ const s = this.props.daemon.sourceTreeIds.read(n), o = s.get(this.props.baselineSession), i = s.get(this.props.currentSession);
2872
+ o && i && this._fetchComparison();
2873
+ }));
2874
+ }
2875
+ get fixtureId() {
2876
+ return this.props.fixtureId;
2877
+ }
2878
+ get daemon() {
2879
+ return this.props.daemon;
2880
+ }
2881
+ get baselineSession() {
2882
+ return this.props.baselineSession;
2883
+ }
2884
+ get currentSession() {
2885
+ return this.props.currentSession;
2886
+ }
2887
+ async _fetchComparison() {
2888
+ this.comparisonStatus.set({ status: "loading" }, void 0);
2889
+ try {
2890
+ const t = await this.props.daemon.compare(
2891
+ this.props.fixtureId,
2892
+ this.props.baselineSession,
2893
+ this.props.currentSession
2894
+ );
2895
+ this.comparisonStatus.set({ status: "ready", match: t.match }, void 0);
2896
+ } catch (t) {
2897
+ this.comparisonStatus.set({ status: "error", message: String(t) }, void 0);
2898
+ }
2899
+ }
2900
+ }
2901
+ const fn = A(
2902
+ pn,
2903
+ {},
2904
+ (r, e) => {
2905
+ const t = e.comparisonStatus.read(r), n = t.status === "loading" ? /* @__PURE__ */ a("span", { style: R.badgeLoading, children: "comparing..." }) : t.status === "error" ? /* @__PURE__ */ a("span", { style: R.badgeError, children: "error" }) : t.match ? /* @__PURE__ */ a("span", { style: R.badgeMatch, children: "✓ match" }) : /* @__PURE__ */ a("span", { style: R.badgeChanged, children: "● changed" });
2906
+ return /* @__PURE__ */ g("div", { style: R.fixtureRow, children: [
2907
+ /* @__PURE__ */ g("div", { style: R.fixtureLabel, children: [
2908
+ /* @__PURE__ */ a("span", { style: R.fixtureName, children: e.fixtureId }),
2909
+ n
2910
+ ] }),
2911
+ /* @__PURE__ */ g("div", { style: R.sideBySide, children: [
2912
+ /* @__PURE__ */ g("div", { style: R.screenshotColumn, children: [
2913
+ /* @__PURE__ */ a("span", { style: R.columnLabel, children: "Current" }),
2914
+ /* @__PURE__ */ a(
2915
+ He,
2916
+ {
2917
+ fixtureId: e.fixtureId,
2918
+ sessionName: e.currentSession,
2919
+ daemon: e.daemon
2920
+ }
2921
+ )
2922
+ ] }),
2923
+ /* @__PURE__ */ g("div", { style: R.screenshotColumn, children: [
2924
+ /* @__PURE__ */ a("span", { style: R.columnLabel, children: "Baseline" }),
2925
+ /* @__PURE__ */ a(
2926
+ He,
2927
+ {
2928
+ fixtureId: e.fixtureId,
2929
+ sessionName: e.baselineSession,
2930
+ daemon: e.daemon
2931
+ }
2932
+ )
2933
+ ] })
2934
+ ] })
2935
+ ] });
2936
+ }
2937
+ ), gn = k(
2938
+ {
2939
+ name: f.const(),
2940
+ path: f.const(),
2941
+ items: f.const(),
2942
+ daemon: f.const(),
2943
+ baselineSession: f.const(),
2944
+ currentSession: f.const()
2945
+ },
2946
+ (r, e) => /* @__PURE__ */ a("div", { style: R.groupContent, children: e.items.map((t) => /* @__PURE__ */ a(
2947
+ fn,
2948
+ {
2949
+ fixtureId: t.fixtureId,
2950
+ daemon: e.daemon,
2951
+ baselineSession: e.baselineSession,
2952
+ currentSession: e.currentSession
2953
+ },
2954
+ t.fixtureId
2955
+ )) })
2956
+ ), R = {
2957
+ groupContent: {
2958
+ display: "flex",
2959
+ flexDirection: "column",
2960
+ gap: 24
2961
+ },
2962
+ fixtureRow: {
2963
+ display: "flex",
2964
+ flexDirection: "column",
2965
+ gap: 8
2966
+ },
2967
+ fixtureLabel: {
2968
+ display: "flex",
2969
+ alignItems: "center",
2970
+ gap: 8
2971
+ },
2972
+ fixtureName: {
2973
+ fontSize: 12,
2974
+ fontWeight: 500,
2975
+ color: "var(--vscode-foreground)"
2976
+ },
2977
+ sideBySide: {
2978
+ display: "flex",
2979
+ flexDirection: "row",
2980
+ gap: 16
2981
+ },
2982
+ screenshotColumn: {
2983
+ flex: 1,
2984
+ display: "flex",
2985
+ flexDirection: "column",
2986
+ gap: 4,
2987
+ minWidth: 0
2988
+ },
2989
+ columnLabel: {
2990
+ fontSize: 11,
2991
+ fontWeight: 500,
2992
+ color: "var(--vscode-descriptionForeground)",
2993
+ textTransform: "uppercase",
2994
+ letterSpacing: "0.05em"
2995
+ },
2996
+ badgeMatch: {
2997
+ fontSize: 11,
2998
+ color: "var(--vscode-testing-iconPassed)",
2999
+ fontWeight: 500
3000
+ },
3001
+ badgeChanged: {
3002
+ fontSize: 11,
3003
+ color: "var(--vscode-testing-iconFailed)",
3004
+ fontWeight: 500
3005
+ },
3006
+ badgeLoading: {
3007
+ fontSize: 11,
3008
+ color: "var(--vscode-descriptionForeground)",
3009
+ fontStyle: "italic"
3010
+ },
3011
+ badgeError: {
3012
+ fontSize: 11,
3013
+ color: "var(--vscode-errorForeground)",
3014
+ fontWeight: 500
3015
+ }
3016
+ }, K = 8;
3017
+ function St(r, e) {
3018
+ return `
3019
+ linear-gradient(45deg, ${e} 25%, transparent 25%),
3020
+ linear-gradient(-45deg, ${e} 25%, transparent 25%),
3021
+ linear-gradient(45deg, transparent 75%, ${e} 75%),
3022
+ linear-gradient(-45deg, transparent 75%, ${e} 75%)
3023
+ `;
3024
+ }
3025
+ const mn = {
3026
+ backgroundColor: "#ffffff",
3027
+ backgroundImage: St("#ffffff", "#e5e5e5")
3028
+ }, vn = {
3029
+ backgroundColor: "#1e1e1e",
3030
+ backgroundImage: St("#1e1e1e", "#2d2d2d")
3031
+ }, bn = {
3032
+ display: "inline-block",
3033
+ padding: "12px",
3034
+ borderRadius: "4px",
3035
+ backgroundSize: `${K * 2}px ${K * 2}px`,
3036
+ backgroundPosition: `0 0, 0 ${K}px, ${K}px -${K}px, -${K}px 0`,
3037
+ boxShadow: "0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08)"
3038
+ };
3039
+ function _n(r) {
3040
+ const e = r === "dark" ? vn : mn;
3041
+ return {
3042
+ ...bn,
3043
+ backgroundColor: e.backgroundColor,
3044
+ backgroundImage: e.backgroundImage
3045
+ };
3046
+ }
3047
+ function je({ src: r, alt: e, background: t }) {
3048
+ return /* @__PURE__ */ a("div", { style: _n(t), children: /* @__PURE__ */ a("img", { src: r, alt: e, style: w.image }) });
3049
+ }
3050
+ const yn = k(
3051
+ {
3052
+ item: f.const(),
3053
+ reportModel: f.const()
3054
+ },
3055
+ (r, e) => {
3056
+ const { item: t, reportModel: n } = e, { entry: s } = t, o = s.background ?? "light", i = s.status === "unchanged" ? /* @__PURE__ */ a("span", { style: w.badgeMatch, children: "✓ match" }) : s.status === "changed" ? /* @__PURE__ */ a("span", { style: w.badgeChanged, children: "● changed" }) : /* @__PURE__ */ a("span", { style: w.badgeAdded, children: "+ added" }), d = s.baselineScreenshot || s.currentScreenshot;
3057
+ return /* @__PURE__ */ g("div", { style: w.fixtureRow, children: [
3058
+ /* @__PURE__ */ g("div", { style: w.fixtureLabel, children: [
3059
+ /* @__PURE__ */ a("span", { style: w.fixtureName, children: t.fixtureId }),
3060
+ i
3061
+ ] }),
3062
+ d && /* @__PURE__ */ g("div", { style: w.sideBySide, children: [
3063
+ s.baselineScreenshot && /* @__PURE__ */ g("div", { style: w.screenshotColumn, children: [
3064
+ /* @__PURE__ */ a("span", { style: w.columnLabel, children: "Baseline" }),
3065
+ /* @__PURE__ */ a(
3066
+ je,
3067
+ {
3068
+ src: n.resolveScreenshotUrl(s.baselineScreenshot),
3069
+ alt: `Baseline screenshot of ${t.fixtureId}`,
3070
+ background: o
3071
+ }
3072
+ )
3073
+ ] }),
3074
+ s.currentScreenshot && /* @__PURE__ */ g("div", { style: w.screenshotColumn, children: [
3075
+ /* @__PURE__ */ a("span", { style: w.columnLabel, children: "Current" }),
3076
+ /* @__PURE__ */ a(
3077
+ je,
3078
+ {
3079
+ src: n.resolveScreenshotUrl(s.currentScreenshot),
3080
+ alt: `Current screenshot of ${t.fixtureId}`,
3081
+ background: o
3082
+ }
3083
+ )
3084
+ ] })
3085
+ ] }),
3086
+ !d && s.status === "unchanged" && /* @__PURE__ */ a("div", { style: w.hashRow, children: /* @__PURE__ */ g("span", { style: w.hashText, children: [
3087
+ "hash: ",
3088
+ s.targetHash
3089
+ ] }) })
3090
+ ] });
3091
+ }
3092
+ ), xn = k(
3093
+ {
3094
+ name: f.const(),
3095
+ path: f.const(),
3096
+ items: f.const(),
3097
+ reportModel: f.const()
3098
+ },
3099
+ (r, e) => /* @__PURE__ */ a("div", { style: w.groupContent, children: e.items.map((t) => /* @__PURE__ */ a(
3100
+ yn,
3101
+ {
3102
+ item: t,
3103
+ reportModel: e.reportModel
3104
+ },
3105
+ t.fixtureId
3106
+ )) })
3107
+ ), w = {
3108
+ groupContent: {
3109
+ display: "flex",
3110
+ flexDirection: "column",
3111
+ gap: 24
3112
+ },
3113
+ fixtureRow: {
3114
+ display: "flex",
3115
+ flexDirection: "column",
3116
+ gap: 8
3117
+ },
3118
+ fixtureLabel: {
3119
+ display: "flex",
3120
+ alignItems: "center",
3121
+ gap: 8
3122
+ },
3123
+ fixtureName: {
3124
+ fontSize: 12,
3125
+ fontWeight: 500,
3126
+ color: "var(--vscode-foreground)"
3127
+ },
3128
+ sideBySide: {
3129
+ display: "flex",
3130
+ flexDirection: "row",
3131
+ gap: 16
3132
+ },
3133
+ screenshotColumn: {
3134
+ display: "flex",
3135
+ flexDirection: "column",
3136
+ gap: 4
3137
+ },
3138
+ columnLabel: {
3139
+ fontSize: 11,
3140
+ fontWeight: 500,
3141
+ color: "var(--vscode-descriptionForeground)",
3142
+ textTransform: "uppercase",
3143
+ letterSpacing: "0.05em"
3144
+ },
3145
+ image: {
3146
+ display: "block"
3147
+ },
3148
+ hashRow: {
3149
+ padding: "8px 0"
3150
+ },
3151
+ hashText: {
3152
+ fontSize: 11,
3153
+ color: "var(--vscode-descriptionForeground)",
3154
+ fontFamily: "monospace"
3155
+ },
3156
+ badgeMatch: {
3157
+ fontSize: 11,
3158
+ color: "var(--vscode-testing-iconPassed)",
3159
+ fontWeight: 500
3160
+ },
3161
+ badgeChanged: {
3162
+ fontSize: 11,
3163
+ color: "var(--vscode-testing-iconFailed)",
3164
+ fontWeight: 500
3165
+ },
3166
+ badgeAdded: {
3167
+ fontSize: 11,
3168
+ color: "var(--vscode-testing-iconQueued)",
3169
+ fontWeight: 500
3170
+ }
3171
+ }, wt = "component-explorer:fixtureHeights", Ue = 500;
3172
+ let N = null;
3173
+ function Ct() {
3174
+ if (N !== null) return N;
3175
+ try {
3176
+ const r = localStorage.getItem(wt);
3177
+ if (r)
3178
+ return N = JSON.parse(r), N;
3179
+ } catch {
3180
+ }
3181
+ return N = {}, N;
3182
+ }
3183
+ function Sn() {
3184
+ if (N !== null)
3185
+ try {
3186
+ const r = Object.entries(N);
3187
+ r.length > Ue && (N = Object.fromEntries(r.slice(-Ue))), localStorage.setItem(wt, JSON.stringify(N));
3188
+ } catch {
3189
+ }
3190
+ }
3191
+ function wn(r, e) {
3192
+ const t = Ct();
3193
+ t[r] = e, Sn();
3194
+ }
3195
+ function Cn() {
3196
+ return new Map(Object.entries(Ct()));
3197
+ }
3198
+ const Rn = 280, Tn = 32, ne = 32, Pe = 400;
3199
+ let Rt = 0;
3200
+ function z(r, e) {
3201
+ const t = ++Rt, n = performance.now().toFixed(1);
3202
+ console.log(
3203
+ `%c[scroll #${t} @${n}ms] ${r}`,
3204
+ "color: #3b82f6; font-weight: bold",
3205
+ e
3206
+ );
3207
+ }
3208
+ function We(r, e) {
3209
+ const t = ++Rt, n = performance.now().toFixed(1);
3210
+ console.warn(
3211
+ `[scroll #${t} @${n}ms] ${r}`,
3212
+ e
3213
+ );
3214
+ }
3215
+ const Tt = "component-explorer:scrollAnchors", Ge = 100;
3216
+ function kt() {
3217
+ try {
3218
+ const r = localStorage.getItem(Tt);
3219
+ if (r) return JSON.parse(r);
3220
+ } catch {
3221
+ }
3222
+ return {};
3223
+ }
3224
+ function kn(r, e) {
3225
+ try {
3226
+ const t = kt();
3227
+ t[r] = e;
3228
+ const n = Object.entries(t), s = n.length > Ge ? Object.fromEntries(n.slice(-Ge)) : t;
3229
+ localStorage.setItem(Tt, JSON.stringify(s));
3230
+ } catch {
3231
+ }
3232
+ }
3233
+ function In(r) {
3234
+ return kt()[r];
3235
+ }
3236
+ function It(r) {
3237
+ return r.type === "single" ? r.fixture.id : r.id;
3238
+ }
3239
+ function On(r, e) {
3240
+ const t = new Array(r.length);
3241
+ let n = ne;
3242
+ for (let s = 0; s < r.length; s++) {
3243
+ const o = e.get(It(r[s])) ?? Rn;
3244
+ t[s] = { top: n, height: o }, n += o + Tn;
3245
+ }
3246
+ return t;
3247
+ }
3248
+ function fe(r) {
3249
+ if (r.length === 0) return 0;
3250
+ const e = r[r.length - 1];
3251
+ return e.top + e.height + ne;
3252
+ }
3253
+ function Ot(r, e) {
3254
+ let t = 0, n = r.length;
3255
+ for (; t < n; ) {
3256
+ const s = t + n >> 1;
3257
+ r[s].top + r[s].height < e ? t = s + 1 : n = s;
3258
+ }
3259
+ return t;
3260
+ }
3261
+ function Nn(r, e, t) {
3262
+ if (r.length === 0) return { start: 0, end: 0 };
3263
+ const n = Ot(r, e - Pe);
3264
+ let s = n;
3265
+ const o = e + t + Pe;
3266
+ for (; s < r.length && r[s].top < o; )
3267
+ s++;
3268
+ return { start: n, end: s };
3269
+ }
3270
+ function qe(r, e) {
3271
+ if (r.length === 0) return;
3272
+ const t = Ot(r, e), n = Math.min(t, r.length - 1);
3273
+ return {
3274
+ rowIndex: n,
3275
+ offsetFromViewport: r[n].top - e
3276
+ };
3277
+ }
3278
+ function Ke(r, e) {
3279
+ return e.rowIndex >= r.length ? 0 : r[e.rowIndex].top - e.offsetFromViewport;
3280
+ }
3281
+ function Je(r) {
3282
+ return r.type === "single" ? r.fixture.path : r.path;
3283
+ }
3284
+ function Qe(r) {
3285
+ return r.split(" / ").slice(1);
3286
+ }
3287
+ function Vn(r, e, t) {
3288
+ const n = t.split("/"), s = n.length - r.length;
3289
+ for (let o = 0; o < r.length; o++)
3290
+ if (!e || o >= e.length || r[o] !== e[o])
3291
+ return r.slice(o).map((i, d) => ({
3292
+ depth: o + d,
3293
+ name: i,
3294
+ nodeId: n.slice(0, s + o + d + 1).join("/")
3295
+ }));
3296
+ return [];
3297
+ }
3298
+ const Ze = ["h1", "h2", "h3", "h4"];
3299
+ function Mn(r) {
3300
+ return Ze[Math.min(r, Ze.length - 1)];
3301
+ }
3302
+ const Xe = ["22px", "15px", "13px", "12px"];
3303
+ function Fn(r) {
3304
+ return {
3305
+ fontSize: Xe[Math.min(r, Xe.length - 1)],
3306
+ fontWeight: r <= 1 ? 600 : 500,
3307
+ color: "var(--vscode-foreground)",
3308
+ margin: 0,
3309
+ marginBottom: r === 0 ? "8px" : "4px",
3310
+ paddingBottom: r === 0 ? "6px" : void 0,
3311
+ borderBottom: r === 0 ? "1px solid var(--vscode-widget-border, var(--vscode-panel-border, rgba(128,128,128,0.35)))" : void 0
3312
+ };
3313
+ }
3314
+ class En extends B({
3315
+ model: f.const()
3316
+ }) {
3317
+ constructor() {
3318
+ super(...arguments);
3319
+ l(this, "_rowHeights", x(this, Cn()));
3320
+ l(this, "_scrollTop", x(this, 0));
3321
+ l(this, "_viewportHeight", x(this, 0));
3322
+ l(this, "_scrollContainerRef", null);
3323
+ l(this, "_resizeObserver", null);
3324
+ l(this, "_viewportResizeObserver", null);
3325
+ l(this, "_currentNodeId");
3326
+ l(this, "_scrollSaveTimeout", null);
3327
+ l(this, "_suppressScrollHandler", !1);
3328
+ l(this, "layout", O(this, (t) => {
3329
+ const n = this.explorerModel.selectedFixtures.read(t), s = this._rowHeights.read(t);
3330
+ return On(n, s);
3331
+ }));
3332
+ l(this, "visibleRowRange", O(this, (t) => {
3333
+ const n = this.layout.read(t), s = this._scrollTop.read(t), o = this._viewportHeight.read(t);
3334
+ return Nn(n, s, o);
3335
+ }));
3336
+ l(this, "setScrollContainerRef", (t) => {
3337
+ var n;
3338
+ this._scrollContainerRef && this._scrollContainerRef.removeEventListener("scroll", this._handleScroll), (n = this._viewportResizeObserver) == null || n.disconnect(), this._scrollContainerRef = t, t && (t.addEventListener("scroll", this._handleScroll, { passive: !0 }), this._viewportHeight.set(t.clientHeight, void 0), z("setScrollContainerRef", { clientHeight: t.clientHeight, scrollTop: t.scrollTop }), this._viewportResizeObserver = new ResizeObserver(([s]) => {
3339
+ const o = Math.round(s.contentRect.height), i = this._viewportHeight.get();
3340
+ o !== i && z("viewportResize", { prev: i, new: o }), this._viewportHeight.set(o, void 0);
3341
+ }), this._viewportResizeObserver.observe(t), this._restoreScrollPosition());
3342
+ });
3343
+ l(this, "_handleScroll", () => {
3344
+ if (!this._scrollContainerRef) return;
3345
+ const t = this._scrollTop.get(), n = this._scrollContainerRef.scrollTop, s = n - t;
3346
+ if (this._scrollTop.set(n, void 0), Math.abs(s) > 200 && We("handleScroll:LARGE_JUMP", {
3347
+ prevObsScrollTop: t,
3348
+ newScrollTop: n,
3349
+ delta: s,
3350
+ suppressed: this._suppressScrollHandler,
3351
+ stack: new Error().stack
3352
+ }), this._suppressScrollHandler || !this._currentNodeId) {
3353
+ this._suppressScrollHandler && z("handleScroll:suppressed", { newScrollTop: n, delta: s });
3354
+ return;
3355
+ }
3356
+ this._scrollSaveTimeout && clearTimeout(this._scrollSaveTimeout), this._scrollSaveTimeout = setTimeout(() => {
3357
+ if (!this._currentNodeId) return;
3358
+ const o = this.layout.get(), i = qe(o, this._scrollTop.get());
3359
+ i && kn(this._currentNodeId, i);
3360
+ }, 150);
3361
+ });
3362
+ l(this, "observeRowElement", (t, n) => {
3363
+ t && (this._resizeObserver || (this._resizeObserver = new ResizeObserver((s) => {
3364
+ const o = this._rowHeights.get();
3365
+ let i;
3366
+ const d = [];
3367
+ for (const c of s) {
3368
+ const u = c.target.getAttribute("data-row-id");
3369
+ if (!u) continue;
3370
+ const h = Math.round(c.contentRect.height);
3371
+ h > 0 && o.get(u) !== h && (d.push({ rid: u, oldH: o.get(u), newH: h }), i || (i = new Map(o)), i.set(u, h), wn(u, h));
3372
+ }
3373
+ if (i) {
3374
+ const c = this.layout.get(), u = this._scrollTop.get(), h = qe(c, u);
3375
+ this._rowHeights.set(i, void 0);
3376
+ const p = this.layout.get();
3377
+ if (h && this._scrollContainerRef) {
3378
+ const m = Ke(p, h), b = m - u;
3379
+ Math.abs(b) > 2 && z("resizeObserver:reAnchor", {
3380
+ changedRows: d,
3381
+ anchor: h,
3382
+ scrollTopBefore: u,
3383
+ newScrollTop: m,
3384
+ delta: b,
3385
+ oldTotalHeight: fe(c),
3386
+ newTotalHeight: fe(p)
3387
+ }), Math.abs(b) > 200 && We("resizeObserver:LARGE_REANCHOR", {
3388
+ changedRows: d,
3389
+ anchor: h,
3390
+ scrollTopBefore: u,
3391
+ newScrollTop: m,
3392
+ delta: b
3393
+ }), this._suppressScrollHandler = !0, this._scrollContainerRef.scrollTop = m, this._scrollTop.set(m, void 0), requestAnimationFrame(() => {
3394
+ this._suppressScrollHandler = !1;
3395
+ });
3396
+ }
3397
+ }
3398
+ })), t.setAttribute("data-row-id", n), this._resizeObserver.observe(t));
3399
+ });
3400
+ }
3401
+ get explorerModel() {
3402
+ return this.props.model;
3403
+ }
3404
+ get currentSessionName() {
3405
+ var s, o;
3406
+ const t = this.explorerModel.daemon;
3407
+ if (!t) return "current";
3408
+ const n = t.sessions.get();
3409
+ return ((s = n.find((i) => i.sourceKind === "current")) == null ? void 0 : s.name) ?? ((o = n[0]) == null ? void 0 : o.name) ?? "current";
3410
+ }
3411
+ get baselineSessionName() {
3412
+ var s, o;
3413
+ const t = this.explorerModel.daemon;
3414
+ if (!t) return "baseline";
3415
+ const n = t.sessions.get();
3416
+ return ((s = n.find((i) => i.sourceKind === "worktree")) == null ? void 0 : s.name) ?? ((o = n[1]) == null ? void 0 : o.name) ?? "baseline";
3417
+ }
3418
+ updateForSelection(t) {
3419
+ this._currentNodeId !== t && (z("updateForSelection", { prev: this._currentNodeId, new: t }), this._currentNodeId = t, this._restoreScrollPosition());
3420
+ }
3421
+ _restoreScrollPosition() {
3422
+ if (!this._scrollContainerRef || !this._currentNodeId) return;
3423
+ const t = In(this._currentNodeId);
3424
+ if (!t) {
3425
+ z("restoreScroll:noAnchor", { nodeId: this._currentNodeId });
3426
+ return;
3427
+ }
3428
+ const n = this.layout.get(), s = Ke(n, t), o = this._scrollContainerRef.scrollTop;
3429
+ z("restoreScroll", {
3430
+ nodeId: this._currentNodeId,
3431
+ anchor: t,
3432
+ prevScrollTop: o,
3433
+ targetScrollTop: s,
3434
+ delta: s - o,
3435
+ layoutLength: n.length
3436
+ }), this._suppressScrollHandler = !0, this._scrollContainerRef.scrollTop = s, this._scrollTop.set(s, void 0), requestAnimationFrame(() => {
3437
+ this._suppressScrollHandler = !1;
3438
+ });
3439
+ }
3440
+ dispose() {
3441
+ var t, n;
3442
+ (t = this._resizeObserver) == null || t.disconnect(), (n = this._viewportResizeObserver) == null || n.disconnect(), this._scrollContainerRef && this._scrollContainerRef.removeEventListener("scroll", this._handleScroll), this._scrollSaveTimeout && clearTimeout(this._scrollSaveTimeout);
3443
+ }
3444
+ }
3445
+ const Dn = A(
3446
+ En,
3447
+ {},
3448
+ (r, e) => {
3449
+ const t = e.explorerModel.selectedFixtures.read(r), n = e.explorerModel.selectedNodeId.read(r), s = e.layout.read(r), { start: o, end: i } = e.visibleRowRange.read(r);
3450
+ if (e.updateForSelection(n), t.length === 0) {
3451
+ const c = e.explorerModel.reportModel;
3452
+ if (c) {
3453
+ const u = c.state.read(r);
3454
+ if (u.status === "loading")
3455
+ return /* @__PURE__ */ a("div", { style: E.emptyState, children: /* @__PURE__ */ a("span", { style: E.emptyText, children: "Loading report..." }) });
3456
+ if (u.status === "error")
3457
+ return /* @__PURE__ */ a("div", { style: E.emptyState, children: /* @__PURE__ */ g("span", { style: { ...E.emptyText, color: "var(--vscode-errorForeground)" }, children: [
3458
+ "Failed to load report: ",
3459
+ u.message
3460
+ ] }) });
3461
+ }
3462
+ return /* @__PURE__ */ a("div", { style: E.emptyState, children: /* @__PURE__ */ a("span", { style: E.emptyText, children: "Select a component or folder to preview" }) });
3463
+ }
3464
+ const d = fe(s);
3465
+ return /* @__PURE__ */ a("div", { ref: e.setScrollContainerRef, style: E.scrollContainer, children: /* @__PURE__ */ a("div", { style: { position: "relative", height: d }, children: t.slice(o, i).map((c, u) => {
3466
+ const h = o + u, { top: p } = s[h], m = It(c), b = Qe(Je(c)), S = h > 0 ? Qe(Je(t[h - 1])) : void 0, C = Vn(b, S, m);
3467
+ return /* @__PURE__ */ g(
3468
+ "div",
3469
+ {
3470
+ ref: (_) => e.observeRowElement(_, m),
3471
+ style: { position: "absolute", top: p, left: ne, right: ne },
3472
+ children: [
3473
+ C.map((_) => {
3474
+ const M = Mn(_.depth);
3475
+ return /* @__PURE__ */ a(M, { style: Fn(_.depth), children: /* @__PURE__ */ a(
3476
+ "a",
3477
+ {
3478
+ href: vt("component", _.nodeId),
3479
+ style: E.headingLink,
3480
+ onClick: (F) => {
3481
+ F.preventDefault(), e.explorerModel.selectNode(_.nodeId);
3482
+ },
3483
+ children: _.name
3484
+ }
3485
+ ) }, _.depth);
3486
+ }),
3487
+ c.type === "single" ? /* @__PURE__ */ a(yt, { fixture: c.fixture, compact: !1 }) : c.type === "variants" ? /* @__PURE__ */ a(Bn, { row: c, onSelect: e.explorerModel.selectNode }) : c.type === "screenshot-comparison" && e.explorerModel.daemon ? /* @__PURE__ */ a(
3488
+ gn,
3489
+ {
3490
+ name: c.name,
3491
+ path: c.path,
3492
+ items: c.items,
3493
+ daemon: e.explorerModel.daemon,
3494
+ baselineSession: e.baselineSessionName,
3495
+ currentSession: e.currentSessionName
3496
+ }
3497
+ ) : c.type === "report-comparison" && e.explorerModel.reportModel ? /* @__PURE__ */ a(
3498
+ xn,
3499
+ {
3500
+ name: c.name,
3501
+ path: c.path,
3502
+ items: c.items,
3503
+ reportModel: e.explorerModel.reportModel
3504
+ }
3505
+ ) : null
3506
+ ]
3507
+ },
3508
+ m
3509
+ );
3510
+ }) }) });
3511
+ }
3512
+ ), Bn = k(
3513
+ {
3514
+ row: f.const(),
3515
+ onSelect: f.const()
3516
+ },
3517
+ (r, e) => {
3518
+ const t = e.row;
3519
+ return /* @__PURE__ */ a("div", { style: E.variantsContent, children: t.fixtures.map((n) => /* @__PURE__ */ a(yt, { fixture: n, compact: !0, onSelect: e.onSelect }, n.id)) });
3520
+ }
3521
+ ), E = {
3522
+ scrollContainer: {
3523
+ flex: 1,
3524
+ overflow: "auto",
3525
+ backgroundColor: "var(--vscode-editor-background)"
3526
+ },
3527
+ emptyState: {
3528
+ flex: 1,
3529
+ display: "flex",
3530
+ alignItems: "center",
3531
+ justifyContent: "center",
3532
+ backgroundColor: "var(--vscode-editor-background)"
3533
+ },
3534
+ emptyText: {
3535
+ color: "var(--vscode-descriptionForeground)",
3536
+ fontSize: "14px"
3537
+ },
3538
+ variantsContent: {
3539
+ display: "flex",
3540
+ flexDirection: "row",
3541
+ flexWrap: "wrap",
3542
+ gap: "16px"
3543
+ },
3544
+ headingLink: {
3545
+ textDecoration: "none",
3546
+ color: "inherit"
3547
+ }
3548
+ }, An = A(
3549
+ Fr,
3550
+ { daemonModel: f.const(), reportModel: f.const() },
3551
+ (r, e) => {
3552
+ const t = e.leftSidebarVisible.read(r), n = e.rightSidebarVisible.read(r), s = e.isDarkTheme.read(r), o = e.selectedNode.read(r);
3553
+ return /* @__PURE__ */ g("div", { className: s ? "vscode-theme default-dark-plus" : "vscode-theme default-light-plus", style: v.container, children: [
3554
+ t && /* @__PURE__ */ a(en, { model: e }),
3555
+ /* @__PURE__ */ g("div", { style: v.centerArea, children: [
3556
+ /* @__PURE__ */ a(Pr, { model: e }),
3557
+ /* @__PURE__ */ a(Dn, { model: e })
3558
+ ] }),
3559
+ n && /* @__PURE__ */ a(sn, { selectedNode: o })
3560
+ ] });
3561
+ }
3562
+ );
3563
+ var $n = class ge {
3564
+ constructor(e) {
3565
+ this.iterator = e;
3566
+ }
3567
+ static fromIterable(e) {
3568
+ return new ge(e[Symbol.asyncIterator]());
3569
+ }
3570
+ static fromFn(e) {
3571
+ return new ge(e());
3572
+ }
3573
+ [Symbol.asyncIterator]() {
3574
+ return this.iterator;
3575
+ }
3576
+ }, zn = class extends Error {
3577
+ constructor(r, e, t) {
3578
+ super(t), this.statusCode = r, this.method = e, this.name = "ApiError";
3579
+ }
3580
+ }, Ln = class {
3581
+ constructor(r) {
3582
+ l(this, "methods", this._createProxy(""));
3583
+ this._request = r;
3584
+ }
3585
+ _createProxy(r) {
3586
+ return new Proxy(() => {
3587
+ }, {
3588
+ apply: async (e, t, n) => await this._request(r, n[0]),
3589
+ get: (e, t) => {
3590
+ if (typeof t != "symbol" && !(t === "then" || t === "catch" || t === "finally" || t === "toString" || t === "valueOf" || t === "toJSON" || t === "name" || t === "length" || t === "prototype" || t === "constructor" || t === "caller" || t === "arguments"))
3591
+ return this._createProxy(`${r}${r ? "/" : ""}${t}`);
3592
+ }
3593
+ });
3594
+ }
3595
+ };
3596
+ function Hn(r, e) {
3597
+ return new Ln(async (t, n) => {
3598
+ var d;
3599
+ const s = await fetch(`${r}/${t}`, {
3600
+ method: "POST",
3601
+ headers: {
3602
+ "Content-Type": "application/json",
3603
+ ...(d = e == null ? void 0 : e.getHeaders) == null ? void 0 : d.call(e)
3604
+ },
3605
+ body: JSON.stringify(n)
3606
+ });
3607
+ if (s.status !== 200) {
3608
+ const c = await s.json().catch(() => null);
3609
+ let u;
3610
+ throw c && typeof c == "object" && "errorMessage" in c ? u = `${c.errorMessage}` : u = `Error calling API method ${t}: ${JSON.stringify(c)} (Status: ${s.status}, Status Text: ${s.statusText})`, new zn(s.status, t, u);
3611
+ }
3612
+ const o = s.headers.get("Content-Type");
3613
+ return o != null && o.startsWith("application/jsonl") ? $n.fromFn(async function* () {
3614
+ var m;
3615
+ const c = (m = s.body) == null ? void 0 : m.getReader();
3616
+ if (!c)
3617
+ return;
3618
+ let u = "";
3619
+ const h = new TextDecoder("utf-8");
3620
+ for (; ; ) {
3621
+ const { done: b, value: S } = await c.read();
3622
+ if (b)
3623
+ break;
3624
+ u += h.decode(S, { stream: !0 });
3625
+ let C;
3626
+ for (; (C = u.indexOf(`
3627
+ `)) >= 0; ) {
3628
+ const _ = u.slice(0, C).trim();
3629
+ u = u.slice(C + 1), _.length > 0 && (yield JSON.parse(_));
3630
+ }
3631
+ }
3632
+ const p = u.trim();
3633
+ p.length > 0 && (yield JSON.parse(p));
3634
+ }) : await s.json();
3635
+ });
3636
+ }
3637
+ class jn {
3638
+ constructor(e) {
3639
+ l(this, "_sourceTreeIds", x(this, /* @__PURE__ */ new Map()));
3640
+ l(this, "_sessions", x(this, []));
3641
+ l(this, "_screenshotCache", /* @__PURE__ */ new Map());
3642
+ l(this, "_client");
3643
+ l(this, "_eventStreamAbort", null);
3644
+ l(this, "sessionName");
3645
+ /** Observable map of sessionName → current sourceTreeId */
3646
+ l(this, "sourceTreeIds", this._sourceTreeIds);
3647
+ /** Observable list of sessions from the daemon */
3648
+ l(this, "sessions", this._sessions);
3649
+ this.config = e, this.sessionName = e.sessionName, this._client = Hn("/__explorer/daemon-api");
3650
+ }
3651
+ /**
3652
+ * Initializes the model: fetches initial session info and starts listening to events.
3653
+ * Call this once after construction.
3654
+ */
3655
+ async initialize() {
3656
+ await this._fetchSessionInfos(), this._startEventStream();
3657
+ }
3658
+ /**
3659
+ * Get a screenshot for a fixture in a session, using cache when available.
3660
+ * Cache is keyed on sessionName + fixtureId and invalidated when sourceTreeId changes.
3661
+ */
3662
+ async getScreenshot(e, t) {
3663
+ const n = this._sourceTreeIds.get().get(e);
3664
+ if (!n)
3665
+ throw new Error(`No sourceTreeId known for session '${e}'`);
3666
+ const s = `${e}:${t}`, o = this._screenshotCache.get(s);
3667
+ if (o && o.sourceTreeId === n)
3668
+ return o.data;
3669
+ const i = await this._client.methods.screenshots.take({
3670
+ fixtureId: t,
3671
+ sessionName: e,
3672
+ sourceTreeId: n,
3673
+ includeImage: !0
3674
+ });
3675
+ return this._screenshotCache.set(s, { sourceTreeId: n, data: i }), i;
3676
+ }
3677
+ /**
3678
+ * Compare a fixture across two sessions. Returns match status and hashes (no images).
3679
+ */
3680
+ async compare(e, t, n) {
3681
+ const s = this._sourceTreeIds.get().get(t), o = this._sourceTreeIds.get().get(n);
3682
+ if (!s || !o)
3683
+ throw new Error("Missing sourceTreeId for sessions");
3684
+ return this._client.methods.screenshots.compare({
3685
+ fixtureId: e,
3686
+ baselineSessionName: t,
3687
+ baselineSourceTreeId: s,
3688
+ currentSessionName: n,
3689
+ currentSourceTreeId: o,
3690
+ includeImages: !1
3691
+ });
3692
+ }
3693
+ /**
3694
+ * List fixtures from a session.
3695
+ */
3696
+ async listFixtures(e) {
3697
+ const t = this._sourceTreeIds.get().get(e);
3698
+ if (!t)
3699
+ throw new Error(`No sourceTreeId known for session '${e}'`);
3700
+ return this._client.methods.fixtures.list({ sessionName: e, sourceTreeId: t });
3701
+ }
3702
+ /**
3703
+ * Get the explorer URL for a different session (for session switching via full navigation).
3704
+ */
3705
+ getSessionExplorerUrl(e) {
3706
+ const t = this._sessions.get().find((n) => n.name === e);
3707
+ if (t)
3708
+ return t.serverUrl + "/___explorer";
3709
+ }
3710
+ dispose() {
3711
+ var e;
3712
+ (e = this._eventStreamAbort) == null || e.abort(), this._eventStreamAbort = null;
3713
+ }
3714
+ // ---------------------------------------------------------------------------
3715
+ // Private
3716
+ // ---------------------------------------------------------------------------
3717
+ async _fetchSessionInfos() {
3718
+ const e = await this._client.methods.sessions(), t = /* @__PURE__ */ new Map(), n = [];
3719
+ for (const s of e)
3720
+ t.set(s.name, s.sourceTreeId), n.push({ name: s.name, serverUrl: s.serverUrl, sourceKind: s.sourceKind });
3721
+ this._sourceTreeIds.set(t, void 0), this._sessions.set(n, void 0);
3722
+ }
3723
+ async _startEventStream() {
3724
+ this._eventStreamAbort = new AbortController();
3725
+ const e = this._eventStreamAbort.signal;
3726
+ try {
3727
+ const t = await this._client.methods.events();
3728
+ for await (const n of t) {
3729
+ if (e.aborted) break;
3730
+ this._handleEvent(n);
3731
+ }
3732
+ } catch (t) {
3733
+ e.aborted || (console.error("[DaemonModel] Event stream error:", t), setTimeout(() => {
3734
+ e.aborted || this._startEventStream();
3735
+ }, 2e3));
3736
+ }
3737
+ }
3738
+ _handleEvent(e) {
3739
+ if (e.type === "source-change") {
3740
+ const t = new Map(this._sourceTreeIds.get());
3741
+ t.set(e.sessionName, e.sourceTreeId), this._sourceTreeIds.set(t, void 0);
3742
+ for (const n of this._screenshotCache.keys())
3743
+ n.startsWith(`${e.sessionName}:`) && this._screenshotCache.delete(n);
3744
+ }
3745
+ }
3746
+ }
3747
+ function Un() {
3748
+ return window.__EXPLORER_DAEMON__;
3749
+ }
3750
+ class Pn {
3751
+ constructor(e) {
3752
+ l(this, "state", x(this, { status: "loading" }));
3753
+ l(this, "_baseUrl");
3754
+ this.reportUrl = e;
3755
+ const t = e.lastIndexOf("/");
3756
+ this._baseUrl = t >= 0 ? e.slice(0, t + 1) : "", this._fetch();
3757
+ }
3758
+ resolveScreenshotUrl(e) {
3759
+ return this._baseUrl + e;
3760
+ }
3761
+ buildTree(e) {
3762
+ const t = this.state.read(e);
3763
+ return t.status !== "ready" ? { id: "", name: "Report", type: "folder", children: [], labels: [] } : Wn(t.report.fixtures);
3764
+ }
3765
+ async _fetch() {
3766
+ this.state.set({ status: "loading" }, void 0);
3767
+ try {
3768
+ const e = await fetch(this.reportUrl);
3769
+ if (!e.ok)
3770
+ throw new Error(`HTTP ${e.status}: ${e.statusText}`);
3771
+ const t = await e.json();
3772
+ this.state.set({ status: "ready", report: t }, void 0);
3773
+ } catch (e) {
3774
+ this.state.set({ status: "error", message: String(e) }, void 0);
3775
+ }
3776
+ }
3777
+ }
3778
+ function Wn(r) {
3779
+ const e = { id: "", name: "Components", type: "folder", children: [], labels: [] };
3780
+ for (const [t, n] of Object.entries(r)) {
3781
+ const s = t.split("/");
3782
+ let o = e;
3783
+ for (let i = 0; i < s.length; i++) {
3784
+ const d = s[i], c = i === s.length - 1, u = s.slice(0, i + 1).join("/");
3785
+ if (c)
3786
+ o.children.push({
3787
+ id: u,
3788
+ name: d,
3789
+ type: "component",
3790
+ reportEntry: n,
3791
+ labels: []
3792
+ });
3793
+ else {
3794
+ let h = o.children.find((p) => p.type === "folder" && p.name === d);
3795
+ h || (h = { id: u, name: d, type: "folder", children: [], labels: [] }, o.children.push(h)), o = h;
3796
+ }
3797
+ }
3798
+ }
3799
+ return e;
3800
+ }
3801
+ class ss {
3802
+ constructor(e, t) {
3803
+ l(this, "_root");
3804
+ l(this, "_registry", new yr());
3805
+ l(this, "_daemonModel");
3806
+ l(this, "_reportModel");
3807
+ this._populateRegistry(t), this._reportModel = this._initializeReportModel(), this._daemonModel = this._reportModel ? void 0 : this._initializeDaemonModel(), this._root = Ft(e), this._root.render(At(An, {
3808
+ registry: this._registry,
3809
+ daemonModel: this._daemonModel,
3810
+ reportModel: this._reportModel
3811
+ }));
3812
+ }
3813
+ _initializeReportModel() {
3814
+ const t = new URLSearchParams(location.search).get("report");
3815
+ if (t)
3816
+ return new Pn(t);
3817
+ }
3818
+ _initializeDaemonModel() {
3819
+ const e = Un();
3820
+ if (!e)
3821
+ return;
3822
+ const t = new jn(e);
3823
+ return t.initialize().catch((n) => {
3824
+ console.error("[ExplorerApp] Failed to initialize DaemonModel:", n);
3825
+ }), t;
3826
+ }
3827
+ _populateRegistry(e) {
3828
+ this._registry.clear();
3829
+ for (const [t, n] of Object.entries(e)) {
3830
+ const s = n.default;
3831
+ s && typeof s == "object" && this._registry.register(t, s);
3832
+ }
3833
+ }
3834
+ /**
3835
+ * Updates the fixtures. The UI will update automatically since the registry is observable.
3836
+ */
3837
+ updateFixtures(e) {
3838
+ this._populateRegistry(e);
3839
+ }
3840
+ /**
3841
+ * No-op for ExplorerApp (only meaningful for CliRuntime).
3842
+ * Present so the plugin's HMR wiring can call it polymorphically.
3843
+ */
3844
+ bumpVersion() {
3845
+ }
3846
+ /**
3847
+ * Unmounts the explorer and cleans up resources.
3848
+ */
3849
+ dispose() {
3850
+ var e;
3851
+ (e = this._daemonModel) == null || e.dispose(), this._root.unmount();
3852
+ }
3853
+ }
3854
+ export {
3855
+ Br as ChevronDownIcon,
3856
+ Dr as ChevronRightIcon,
3857
+ ns as CliRuntime,
3858
+ Ar as ComponentIcon,
3859
+ jn as DaemonModel,
3860
+ An as Explorer,
3861
+ ss as ExplorerApp,
3862
+ Fr as ExplorerModel,
3863
+ yr as FixtureRegistry,
3864
+ $r as FolderIcon,
3865
+ en as LeftSidebar,
3866
+ jr as MoonIcon,
3867
+ zr as PanelLeftIcon,
3868
+ Lr as PanelRightIcon,
3869
+ Pn as ReportModel,
3870
+ sn as RightSidebar,
3871
+ Hr as SunIcon,
3872
+ Pr as TitleBar,
3873
+ oe as TitleBarButton,
3874
+ Kr as TreeItem,
3875
+ bt as TreeView,
3876
+ $t as VIEWPORT_SIZES,
3877
+ as as asyncRender,
3878
+ Ut as collectComponents,
3879
+ Oe as createComponentDefinition,
3880
+ ie as createFixtureTree,
3881
+ ds as defineFixture,
3882
+ cs as defineFixtureGroup,
3883
+ ls as defineFixtureVariants,
3884
+ Ve as findNodeByPath,
3885
+ Re as fixtureGroupBrand,
3886
+ Te as fixtureVariantsBrand,
3887
+ Lt as getDefaultPropertyValues,
3888
+ rs as isComponentDefinition,
3889
+ be as isFixtureGroup,
3890
+ _e as isFixtureVariants,
3891
+ ve as isSingleFixture,
3892
+ Ce as mergeStyles,
3893
+ Xn as parseFixtureExport,
3894
+ es as parseFixtureGroup,
3895
+ ts as parseFixtureVariants,
3896
+ Yn as parseSingleFixture,
3897
+ zt as resolveViewport,
3898
+ ke as singleFixtureBrand,
3899
+ v as styles,
3900
+ hs as syncRender,
3901
+ gt as toExplorerTree
3902
+ };
3903
+ //# sourceMappingURL=viewer.js.map