@vscode/component-explorer 0.1.1-0 → 0.1.1-10

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