@space-lens/cli 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -1,48 +1,4139 @@
1
- #!/usr/bin/env bun
2
- import { n as SORT_MODES, r as normalizeCliConfig } from "./cli-config-AZ8GhaEx.mjs";
1
+ #!/usr/bin/env node
2
+ import { a as formatBytes, c as SORT_MODES, i as createScanViewModel, l as normalizeCliConfig, n as createCleanViewModel, o as getSelectedEntries, r as createInitialTuiState, t as applyTuiAction } from "./assets/model-BICd3EQ5.js";
3
3
  import { Args, Command, Options } from "@effect/cli";
4
4
  import * as NodeContext from "@effect/platform-node/NodeContext";
5
5
  import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
6
6
  import { Effect } from "effect";
7
- //#region src/runtime.ts
8
- function isBunRuntime(runtime = globalThis) {
9
- return runtime.Bun !== void 0;
7
+ import { AnsiCellSurface, FocusManager, FrameClock, StyleTable, StyleTable as StyleTable$1, TerminalDriver, TextInputMachine, TuiRenderer, clampScroll, hitTest, scrollbarThumb, toInputKey } from "@uniview/tui-core";
8
+ import { common, createLowlight } from "lowlight";
9
+ import "marked";
10
+ //#region ../../node_modules/solid-js/dist/solid.js
11
+ var sharedConfig = {
12
+ context: void 0,
13
+ registry: void 0,
14
+ effects: void 0,
15
+ done: false,
16
+ getContextId() {
17
+ return getContextId(this.context.count);
18
+ },
19
+ getNextContextId() {
20
+ return getContextId(this.context.count++);
21
+ }
22
+ };
23
+ function getContextId(count) {
24
+ const num = String(count), len = num.length - 1;
25
+ return sharedConfig.context.id + (len ? String.fromCharCode(96 + len) : "") + num;
26
+ }
27
+ function setHydrateContext(context) {
28
+ sharedConfig.context = context;
29
+ }
30
+ function nextHydrateContext() {
31
+ return {
32
+ ...sharedConfig.context,
33
+ id: sharedConfig.getNextContextId(),
34
+ count: 0
35
+ };
36
+ }
37
+ var equalFn = (a, b) => a === b;
38
+ var $PROXY = Symbol("solid-proxy");
39
+ var SUPPORTS_PROXY = typeof Proxy === "function";
40
+ var $TRACK = Symbol("solid-track");
41
+ var signalOptions = { equals: equalFn };
42
+ var ERROR = null;
43
+ var runEffects = runQueue;
44
+ var STALE = 1;
45
+ var PENDING = 2;
46
+ var UNOWNED = {
47
+ owned: null,
48
+ cleanups: null,
49
+ context: null,
50
+ owner: null
51
+ };
52
+ var Owner = null;
53
+ var Transition = null;
54
+ var Scheduler = null;
55
+ var ExternalSourceConfig = null;
56
+ var Listener = null;
57
+ var Updates = null;
58
+ var Effects = null;
59
+ var ExecCount = 0;
60
+ function createRoot(fn, detachedOwner) {
61
+ const listener = Listener, owner = Owner, unowned = fn.length === 0, current = detachedOwner === void 0 ? owner : detachedOwner, root = unowned ? UNOWNED : {
62
+ owned: null,
63
+ cleanups: null,
64
+ context: current ? current.context : null,
65
+ owner: current
66
+ }, updateFn = unowned ? fn : () => fn(() => untrack(() => cleanNode(root)));
67
+ Owner = root;
68
+ Listener = null;
69
+ try {
70
+ return runUpdates(updateFn, true);
71
+ } finally {
72
+ Listener = listener;
73
+ Owner = owner;
74
+ }
75
+ }
76
+ function createSignal(value, options) {
77
+ options = options ? Object.assign({}, signalOptions, options) : signalOptions;
78
+ const s = {
79
+ value,
80
+ observers: null,
81
+ observerSlots: null,
82
+ comparator: options.equals || void 0
83
+ };
84
+ const setter = (value) => {
85
+ if (typeof value === "function") {
86
+ if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
87
+ else value = value(s.value);
88
+ }
89
+ return writeSignal(s, value);
90
+ };
91
+ return [readSignal.bind(s), setter];
92
+ }
93
+ function createRenderEffect(fn, value, options) {
94
+ const c = createComputation(fn, value, false, STALE);
95
+ if (Scheduler && Transition && Transition.running) Updates.push(c);
96
+ else updateComputation(c);
97
+ }
98
+ function createEffect(fn, value, options) {
99
+ runEffects = runUserEffects;
100
+ const c = createComputation(fn, value, false, STALE), s = SuspenseContext && useContext(SuspenseContext);
101
+ if (s) c.suspense = s;
102
+ if (!options || !options.render) c.user = true;
103
+ Effects ? Effects.push(c) : updateComputation(c);
104
+ }
105
+ function createMemo(fn, value, options) {
106
+ options = options ? Object.assign({}, signalOptions, options) : signalOptions;
107
+ const c = createComputation(fn, value, true, 0);
108
+ c.observers = null;
109
+ c.observerSlots = null;
110
+ c.comparator = options.equals || void 0;
111
+ if (Scheduler && Transition && Transition.running) {
112
+ c.tState = STALE;
113
+ Updates.push(c);
114
+ } else updateComputation(c);
115
+ return readSignal.bind(c);
116
+ }
117
+ function untrack(fn) {
118
+ if (!ExternalSourceConfig && Listener === null) return fn();
119
+ const listener = Listener;
120
+ Listener = null;
121
+ try {
122
+ if (ExternalSourceConfig) return ExternalSourceConfig.untrack(fn);
123
+ return fn();
124
+ } finally {
125
+ Listener = listener;
126
+ }
127
+ }
128
+ function onCleanup(fn) {
129
+ if (Owner === null);
130
+ else if (Owner.cleanups === null) Owner.cleanups = [fn];
131
+ else Owner.cleanups.push(fn);
132
+ return fn;
133
+ }
134
+ function startTransition(fn) {
135
+ if (Transition && Transition.running) {
136
+ fn();
137
+ return Transition.done;
138
+ }
139
+ const l = Listener;
140
+ const o = Owner;
141
+ return Promise.resolve().then(() => {
142
+ Listener = l;
143
+ Owner = o;
144
+ let t;
145
+ if (Scheduler || SuspenseContext) {
146
+ t = Transition || (Transition = {
147
+ sources: /* @__PURE__ */ new Set(),
148
+ effects: [],
149
+ promises: /* @__PURE__ */ new Set(),
150
+ disposed: /* @__PURE__ */ new Set(),
151
+ queue: /* @__PURE__ */ new Set(),
152
+ running: true
153
+ });
154
+ t.done || (t.done = new Promise((res) => t.resolve = res));
155
+ t.running = true;
156
+ }
157
+ runUpdates(fn, false);
158
+ Listener = Owner = null;
159
+ return t ? t.done : void 0;
160
+ });
161
+ }
162
+ var [transPending, setTransPending] = /*@__PURE__*/ createSignal(false);
163
+ function createContext(defaultValue, options) {
164
+ const id = Symbol("context");
165
+ return {
166
+ id,
167
+ Provider: createProvider(id),
168
+ defaultValue
169
+ };
170
+ }
171
+ function useContext(context) {
172
+ let value;
173
+ return Owner && Owner.context && (value = Owner.context[context.id]) !== void 0 ? value : context.defaultValue;
174
+ }
175
+ function children(fn) {
176
+ const children = createMemo(fn);
177
+ const memo = createMemo(() => resolveChildren(children()));
178
+ memo.toArray = () => {
179
+ const c = memo();
180
+ return Array.isArray(c) ? c : c != null ? [c] : [];
181
+ };
182
+ return memo;
183
+ }
184
+ var SuspenseContext;
185
+ function readSignal() {
186
+ const runningTransition = Transition && Transition.running;
187
+ if (this.sources && (runningTransition ? this.tState : this.state)) {
188
+ if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
189
+ else {
190
+ const updates = Updates;
191
+ Updates = null;
192
+ runUpdates(() => lookUpstream(this), false);
193
+ Updates = updates;
194
+ }
195
+ }
196
+ if (Listener) {
197
+ const observers = this.observers;
198
+ if (!observers || observers[observers.length - 1] !== Listener) {
199
+ const sSlot = observers ? observers.length : 0;
200
+ if (!Listener.sources) {
201
+ Listener.sources = [this];
202
+ Listener.sourceSlots = [sSlot];
203
+ } else {
204
+ Listener.sources.push(this);
205
+ Listener.sourceSlots.push(sSlot);
206
+ }
207
+ if (!observers) {
208
+ this.observers = [Listener];
209
+ this.observerSlots = [Listener.sources.length - 1];
210
+ } else {
211
+ observers.push(Listener);
212
+ this.observerSlots.push(Listener.sources.length - 1);
213
+ }
214
+ }
215
+ }
216
+ if (runningTransition && Transition.sources.has(this)) return this.tValue;
217
+ return this.value;
218
+ }
219
+ function writeSignal(node, value, isComp) {
220
+ let current = Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
221
+ if (!node.comparator || !node.comparator(current, value)) {
222
+ if (Transition) {
223
+ const TransitionRunning = Transition.running;
224
+ if (TransitionRunning || !isComp && Transition.sources.has(node)) {
225
+ Transition.sources.add(node);
226
+ node.tValue = value;
227
+ }
228
+ if (!TransitionRunning) node.value = value;
229
+ } else node.value = value;
230
+ if (node.observers && node.observers.length) runUpdates(() => {
231
+ for (let i = 0; i < node.observers.length; i += 1) {
232
+ const o = node.observers[i];
233
+ const TransitionRunning = Transition && Transition.running;
234
+ if (TransitionRunning && Transition.disposed.has(o)) continue;
235
+ if (TransitionRunning ? !o.tState : !o.state) {
236
+ if (o.pure) Updates.push(o);
237
+ else Effects.push(o);
238
+ if (o.observers) markDownstream(o);
239
+ }
240
+ if (!TransitionRunning) o.state = STALE;
241
+ else o.tState = STALE;
242
+ }
243
+ if (Updates.length > 1e6) {
244
+ Updates = [];
245
+ throw new Error();
246
+ }
247
+ }, false);
248
+ }
249
+ return value;
250
+ }
251
+ function updateComputation(node) {
252
+ if (!node.fn) return;
253
+ cleanNode(node);
254
+ const time = ExecCount;
255
+ runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time);
256
+ if (Transition && !Transition.running && Transition.sources.has(node)) queueMicrotask(() => {
257
+ runUpdates(() => {
258
+ Transition && (Transition.running = true);
259
+ Listener = Owner = node;
260
+ runComputation(node, node.tValue, time);
261
+ Listener = Owner = null;
262
+ }, false);
263
+ });
264
+ }
265
+ function runComputation(node, value, time) {
266
+ let nextValue;
267
+ const owner = Owner, listener = Listener;
268
+ Listener = Owner = node;
269
+ try {
270
+ nextValue = node.fn(value);
271
+ } catch (err) {
272
+ if (node.pure) {
273
+ if (Transition && Transition.running) {
274
+ node.tState = STALE;
275
+ node.tOwned && node.tOwned.forEach(cleanNode);
276
+ node.tOwned = void 0;
277
+ } else {
278
+ node.state = STALE;
279
+ node.owned && node.owned.forEach(cleanNode);
280
+ node.owned = null;
281
+ }
282
+ }
283
+ node.updatedAt = time + 1;
284
+ return handleError(err);
285
+ } finally {
286
+ Listener = listener;
287
+ Owner = owner;
288
+ }
289
+ if (!node.updatedAt || node.updatedAt <= time) {
290
+ if (node.updatedAt != null && "observers" in node) writeSignal(node, nextValue, true);
291
+ else if (Transition && Transition.running && node.pure) {
292
+ if (!Transition.sources.has(node)) node.value = nextValue;
293
+ Transition.sources.add(node);
294
+ node.tValue = nextValue;
295
+ } else node.value = nextValue;
296
+ node.updatedAt = time;
297
+ }
298
+ }
299
+ function createComputation(fn, init, pure, state = STALE, options) {
300
+ const c = {
301
+ fn,
302
+ state,
303
+ updatedAt: null,
304
+ owned: null,
305
+ sources: null,
306
+ sourceSlots: null,
307
+ cleanups: null,
308
+ value: init,
309
+ owner: Owner,
310
+ context: Owner ? Owner.context : null,
311
+ pure
312
+ };
313
+ if (Transition && Transition.running) {
314
+ c.state = 0;
315
+ c.tState = state;
316
+ }
317
+ if (Owner === null);
318
+ else if (Owner !== UNOWNED) {
319
+ if (Transition && Transition.running && Owner.pure) {
320
+ if (!Owner.tOwned) Owner.tOwned = [c];
321
+ else Owner.tOwned.push(c);
322
+ } else if (!Owner.owned) Owner.owned = [c];
323
+ else Owner.owned.push(c);
324
+ }
325
+ if (ExternalSourceConfig && c.fn) {
326
+ const sourceFn = c.fn;
327
+ const [track, trigger] = createSignal(void 0, { equals: false });
328
+ const ordinary = ExternalSourceConfig.factory(sourceFn, trigger);
329
+ onCleanup(() => ordinary.dispose());
330
+ let inTransition;
331
+ const triggerInTransition = () => startTransition(trigger).then(() => {
332
+ if (inTransition) {
333
+ inTransition.dispose();
334
+ inTransition = void 0;
335
+ }
336
+ });
337
+ c.fn = (x) => {
338
+ track();
339
+ if (Transition && Transition.running) {
340
+ if (!inTransition) inTransition = ExternalSourceConfig.factory(sourceFn, triggerInTransition);
341
+ return inTransition.track(x);
342
+ }
343
+ return ordinary.track(x);
344
+ };
345
+ }
346
+ return c;
347
+ }
348
+ function runTop(node) {
349
+ const runningTransition = Transition && Transition.running;
350
+ if ((runningTransition ? node.tState : node.state) === 0) return;
351
+ if ((runningTransition ? node.tState : node.state) === PENDING) return lookUpstream(node);
352
+ if (node.suspense && untrack(node.suspense.inFallback)) return node.suspense.effects.push(node);
353
+ const ancestors = [node];
354
+ while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) {
355
+ if (runningTransition && Transition.disposed.has(node)) return;
356
+ if (runningTransition ? node.tState : node.state) ancestors.push(node);
357
+ }
358
+ for (let i = ancestors.length - 1; i >= 0; i--) {
359
+ node = ancestors[i];
360
+ if (runningTransition) {
361
+ let top = node, prev = ancestors[i + 1];
362
+ while ((top = top.owner) && top !== prev) if (Transition.disposed.has(top)) return;
363
+ }
364
+ if ((runningTransition ? node.tState : node.state) === STALE) updateComputation(node);
365
+ else if ((runningTransition ? node.tState : node.state) === PENDING) {
366
+ const updates = Updates;
367
+ Updates = null;
368
+ runUpdates(() => lookUpstream(node, ancestors[0]), false);
369
+ Updates = updates;
370
+ }
371
+ }
372
+ }
373
+ function runUpdates(fn, init) {
374
+ if (Updates) return fn();
375
+ let wait = false;
376
+ if (!init) Updates = [];
377
+ if (Effects) wait = true;
378
+ else Effects = [];
379
+ ExecCount++;
380
+ try {
381
+ const res = fn();
382
+ completeUpdates(wait);
383
+ return res;
384
+ } catch (err) {
385
+ if (!wait) Effects = null;
386
+ Updates = null;
387
+ handleError(err);
388
+ }
389
+ }
390
+ function completeUpdates(wait) {
391
+ if (Updates) {
392
+ if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
393
+ else runQueue(Updates);
394
+ Updates = null;
395
+ }
396
+ if (wait) return;
397
+ let res;
398
+ if (Transition) {
399
+ if (!Transition.promises.size && !Transition.queue.size) {
400
+ const sources = Transition.sources;
401
+ const disposed = Transition.disposed;
402
+ Effects.push.apply(Effects, Transition.effects);
403
+ res = Transition.resolve;
404
+ for (const e of Effects) {
405
+ "tState" in e && (e.state = e.tState);
406
+ delete e.tState;
407
+ }
408
+ Transition = null;
409
+ runUpdates(() => {
410
+ for (const d of disposed) cleanNode(d);
411
+ for (const v of sources) {
412
+ v.value = v.tValue;
413
+ if (v.owned) for (let i = 0, len = v.owned.length; i < len; i++) cleanNode(v.owned[i]);
414
+ if (v.tOwned) v.owned = v.tOwned;
415
+ delete v.tValue;
416
+ delete v.tOwned;
417
+ v.tState = 0;
418
+ }
419
+ setTransPending(false);
420
+ }, false);
421
+ } else if (Transition.running) {
422
+ Transition.running = false;
423
+ Transition.effects.push.apply(Transition.effects, Effects);
424
+ Effects = null;
425
+ setTransPending(true);
426
+ return;
427
+ }
428
+ }
429
+ const e = Effects;
430
+ Effects = null;
431
+ if (e.length) runUpdates(() => runEffects(e), false);
432
+ if (res) res();
433
+ }
434
+ function runQueue(queue) {
435
+ for (let i = 0; i < queue.length; i++) runTop(queue[i]);
436
+ }
437
+ function scheduleQueue(queue) {
438
+ for (let i = 0; i < queue.length; i++) {
439
+ const item = queue[i];
440
+ const tasks = Transition.queue;
441
+ if (!tasks.has(item)) {
442
+ tasks.add(item);
443
+ Scheduler(() => {
444
+ tasks.delete(item);
445
+ runUpdates(() => {
446
+ Transition.running = true;
447
+ runTop(item);
448
+ }, false);
449
+ Transition && (Transition.running = false);
450
+ });
451
+ }
452
+ }
453
+ }
454
+ function runUserEffects(queue) {
455
+ let i, userLength = 0;
456
+ for (i = 0; i < queue.length; i++) {
457
+ const e = queue[i];
458
+ if (!e.user) runTop(e);
459
+ else queue[userLength++] = e;
460
+ }
461
+ if (sharedConfig.context) {
462
+ if (sharedConfig.count) {
463
+ sharedConfig.effects || (sharedConfig.effects = []);
464
+ sharedConfig.effects.push(...queue.slice(0, userLength));
465
+ return;
466
+ }
467
+ setHydrateContext();
468
+ }
469
+ if (sharedConfig.effects && (sharedConfig.done || !sharedConfig.count)) {
470
+ queue = [...sharedConfig.effects, ...queue];
471
+ userLength += sharedConfig.effects.length;
472
+ delete sharedConfig.effects;
473
+ }
474
+ for (i = 0; i < userLength; i++) runTop(queue[i]);
475
+ }
476
+ function lookUpstream(node, ignore) {
477
+ const runningTransition = Transition && Transition.running;
478
+ if (runningTransition) node.tState = 0;
479
+ else node.state = 0;
480
+ for (let i = 0; i < node.sources.length; i += 1) {
481
+ const source = node.sources[i];
482
+ if (source.sources) {
483
+ const state = runningTransition ? source.tState : source.state;
484
+ if (state === STALE) {
485
+ if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount)) runTop(source);
486
+ } else if (state === PENDING) lookUpstream(source, ignore);
487
+ }
488
+ }
489
+ }
490
+ function markDownstream(node) {
491
+ const runningTransition = Transition && Transition.running;
492
+ for (let i = 0; i < node.observers.length; i += 1) {
493
+ const o = node.observers[i];
494
+ if (runningTransition ? !o.tState : !o.state) {
495
+ if (runningTransition) o.tState = PENDING;
496
+ else o.state = PENDING;
497
+ if (o.pure) Updates.push(o);
498
+ else Effects.push(o);
499
+ o.observers && markDownstream(o);
500
+ }
501
+ }
502
+ }
503
+ function cleanNode(node) {
504
+ let i;
505
+ if (node.sources) while (node.sources.length) {
506
+ const source = node.sources.pop(), index = node.sourceSlots.pop(), obs = source.observers;
507
+ if (obs && obs.length) {
508
+ const n = obs.pop(), s = source.observerSlots.pop();
509
+ if (index < obs.length) {
510
+ n.sourceSlots[s] = index;
511
+ obs[index] = n;
512
+ source.observerSlots[index] = s;
513
+ }
514
+ }
515
+ }
516
+ if (node.tOwned) {
517
+ for (i = node.tOwned.length - 1; i >= 0; i--) cleanNode(node.tOwned[i]);
518
+ delete node.tOwned;
519
+ }
520
+ if (Transition && Transition.running && node.pure) reset(node, true);
521
+ else if (node.owned) {
522
+ for (i = node.owned.length - 1; i >= 0; i--) cleanNode(node.owned[i]);
523
+ node.owned = null;
524
+ }
525
+ if (node.cleanups) {
526
+ for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
527
+ node.cleanups = null;
528
+ }
529
+ if (Transition && Transition.running) node.tState = 0;
530
+ else node.state = 0;
531
+ }
532
+ function reset(node, top) {
533
+ if (!top) {
534
+ node.tState = 0;
535
+ Transition.disposed.add(node);
536
+ }
537
+ if (node.owned) for (let i = 0; i < node.owned.length; i++) reset(node.owned[i]);
538
+ }
539
+ function castError(err) {
540
+ if (err instanceof Error) return err;
541
+ return new Error(typeof err === "string" ? err : "Unknown error", { cause: err });
542
+ }
543
+ function runErrors(err, fns, owner) {
544
+ try {
545
+ for (const f of fns) f(err);
546
+ } catch (e) {
547
+ handleError(e, owner && owner.owner || null);
548
+ }
549
+ }
550
+ function handleError(err, owner = Owner) {
551
+ const fns = ERROR && owner && owner.context && owner.context[ERROR];
552
+ const error = castError(err);
553
+ if (!fns) throw error;
554
+ if (Effects) Effects.push({
555
+ fn() {
556
+ runErrors(error, fns, owner);
557
+ },
558
+ state: STALE
559
+ });
560
+ else runErrors(error, fns, owner);
561
+ }
562
+ function resolveChildren(children) {
563
+ if (typeof children === "function" && !children.length) return resolveChildren(children());
564
+ if (Array.isArray(children)) {
565
+ const results = [];
566
+ for (let i = 0; i < children.length; i++) {
567
+ const result = resolveChildren(children[i]);
568
+ if (Array.isArray(result)) {
569
+ if (result.length < 32768) results.push.apply(results, result);
570
+ else for (let j = 0; j < result.length; j++) results.push(result[j]);
571
+ } else results.push(result);
572
+ }
573
+ return results;
574
+ }
575
+ return children;
576
+ }
577
+ function createProvider(id, options) {
578
+ return function provider(props) {
579
+ let res;
580
+ createRenderEffect(() => res = untrack(() => {
581
+ Owner.context = {
582
+ ...Owner.context,
583
+ [id]: props.value
584
+ };
585
+ return children(() => props.children);
586
+ }), void 0);
587
+ return res;
588
+ };
589
+ }
590
+ var FALLBACK = Symbol("fallback");
591
+ function dispose(d) {
592
+ for (let i = 0; i < d.length; i++) d[i]();
593
+ }
594
+ function mapArray(list, mapFn, options = {}) {
595
+ let items = [], mapped = [], disposers = [], len = 0, indexes = mapFn.length > 1 ? [] : null;
596
+ onCleanup(() => dispose(disposers));
597
+ return () => {
598
+ let newItems = list() || [], newLen = newItems.length, i, j;
599
+ newItems[$TRACK];
600
+ return untrack(() => {
601
+ let newIndices, newIndicesNext, temp, tempdisposers, tempIndexes, start, end, newEnd, item;
602
+ if (newLen === 0) {
603
+ if (len !== 0) {
604
+ dispose(disposers);
605
+ disposers = [];
606
+ items = [];
607
+ mapped = [];
608
+ len = 0;
609
+ indexes && (indexes = []);
610
+ }
611
+ if (options.fallback) {
612
+ items = [FALLBACK];
613
+ mapped[0] = createRoot((disposer) => {
614
+ disposers[0] = disposer;
615
+ return options.fallback();
616
+ });
617
+ len = 1;
618
+ }
619
+ } else if (len === 0) {
620
+ mapped = new Array(newLen);
621
+ for (j = 0; j < newLen; j++) {
622
+ items[j] = newItems[j];
623
+ mapped[j] = createRoot(mapper);
624
+ }
625
+ len = newLen;
626
+ } else {
627
+ temp = new Array(newLen);
628
+ tempdisposers = new Array(newLen);
629
+ indexes && (tempIndexes = new Array(newLen));
630
+ for (start = 0, end = Math.min(len, newLen); start < end && items[start] === newItems[start]; start++);
631
+ for (end = len - 1, newEnd = newLen - 1; end >= start && newEnd >= start && items[end] === newItems[newEnd]; end--, newEnd--) {
632
+ temp[newEnd] = mapped[end];
633
+ tempdisposers[newEnd] = disposers[end];
634
+ indexes && (tempIndexes[newEnd] = indexes[end]);
635
+ }
636
+ newIndices = /* @__PURE__ */ new Map();
637
+ newIndicesNext = new Array(newEnd + 1);
638
+ for (j = newEnd; j >= start; j--) {
639
+ item = newItems[j];
640
+ i = newIndices.get(item);
641
+ newIndicesNext[j] = i === void 0 ? -1 : i;
642
+ newIndices.set(item, j);
643
+ }
644
+ for (i = start; i <= end; i++) {
645
+ item = items[i];
646
+ j = newIndices.get(item);
647
+ if (j !== void 0 && j !== -1) {
648
+ temp[j] = mapped[i];
649
+ tempdisposers[j] = disposers[i];
650
+ indexes && (tempIndexes[j] = indexes[i]);
651
+ j = newIndicesNext[j];
652
+ newIndices.set(item, j);
653
+ } else disposers[i]();
654
+ }
655
+ for (j = start; j < newLen; j++) if (j in temp) {
656
+ mapped[j] = temp[j];
657
+ disposers[j] = tempdisposers[j];
658
+ if (indexes) {
659
+ indexes[j] = tempIndexes[j];
660
+ indexes[j](j);
661
+ }
662
+ } else mapped[j] = createRoot(mapper);
663
+ mapped = mapped.slice(0, len = newLen);
664
+ items = newItems.slice(0);
665
+ }
666
+ return mapped;
667
+ });
668
+ function mapper(disposer) {
669
+ disposers[j] = disposer;
670
+ if (indexes) {
671
+ const [s, set] = createSignal(j);
672
+ indexes[j] = set;
673
+ return mapFn(newItems[j], s);
674
+ }
675
+ return mapFn(newItems[j]);
676
+ }
677
+ };
678
+ }
679
+ function indexArray(list, mapFn, options = {}) {
680
+ let items = [], mapped = [], disposers = [], signals = [], len = 0, i;
681
+ onCleanup(() => dispose(disposers));
682
+ return () => {
683
+ const newItems = list() || [], newLen = newItems.length;
684
+ newItems[$TRACK];
685
+ return untrack(() => {
686
+ if (newLen === 0) {
687
+ if (len !== 0) {
688
+ dispose(disposers);
689
+ disposers = [];
690
+ items = [];
691
+ mapped = [];
692
+ len = 0;
693
+ signals = [];
694
+ }
695
+ if (options.fallback) {
696
+ items = [FALLBACK];
697
+ mapped[0] = createRoot((disposer) => {
698
+ disposers[0] = disposer;
699
+ return options.fallback();
700
+ });
701
+ len = 1;
702
+ }
703
+ return mapped;
704
+ }
705
+ if (items[0] === FALLBACK) {
706
+ disposers[0]();
707
+ disposers = [];
708
+ items = [];
709
+ mapped = [];
710
+ len = 0;
711
+ }
712
+ for (i = 0; i < newLen; i++) if (i < items.length && items[i] !== newItems[i]) signals[i](() => newItems[i]);
713
+ else if (i >= items.length) mapped[i] = createRoot(mapper);
714
+ for (; i < items.length; i++) disposers[i]();
715
+ len = signals.length = disposers.length = newLen;
716
+ items = newItems.slice(0);
717
+ return mapped = mapped.slice(0, len);
718
+ });
719
+ function mapper(disposer) {
720
+ disposers[i] = disposer;
721
+ const [s, set] = createSignal(newItems[i]);
722
+ signals[i] = set;
723
+ return mapFn(s, i);
724
+ }
725
+ };
726
+ }
727
+ var hydrationEnabled = false;
728
+ function createComponent(Comp, props) {
729
+ if (hydrationEnabled) {
730
+ if (sharedConfig.context) {
731
+ const c = sharedConfig.context;
732
+ setHydrateContext(nextHydrateContext());
733
+ const r = untrack(() => Comp(props || {}));
734
+ setHydrateContext(c);
735
+ return r;
736
+ }
737
+ }
738
+ return untrack(() => Comp(props || {}));
10
739
  }
11
- function assertSupportedRuntime(runtime = globalThis) {
12
- if (!isBunRuntime(runtime)) throw new Error("OpenTUI currently requires Bun. Run this CLI with `bun` or `yarn tui`.");
740
+ function trueFn() {
741
+ return true;
742
+ }
743
+ var propTraps = {
744
+ get(_, property, receiver) {
745
+ if (property === $PROXY) return receiver;
746
+ return _.get(property);
747
+ },
748
+ has(_, property) {
749
+ if (property === $PROXY) return true;
750
+ return _.has(property);
751
+ },
752
+ set: trueFn,
753
+ deleteProperty: trueFn,
754
+ getOwnPropertyDescriptor(_, property) {
755
+ return {
756
+ configurable: true,
757
+ enumerable: true,
758
+ get() {
759
+ return _.get(property);
760
+ },
761
+ set: trueFn,
762
+ deleteProperty: trueFn
763
+ };
764
+ },
765
+ ownKeys(_) {
766
+ return _.keys();
767
+ }
768
+ };
769
+ function resolveSource(s) {
770
+ return !(s = typeof s === "function" ? s() : s) ? {} : s;
771
+ }
772
+ function resolveSources() {
773
+ for (let i = 0, length = this.length; i < length; ++i) {
774
+ const v = this[i]();
775
+ if (v !== void 0) return v;
776
+ }
777
+ }
778
+ function mergeProps(...sources) {
779
+ let proxy = false;
780
+ for (let i = 0; i < sources.length; i++) {
781
+ const s = sources[i];
782
+ proxy = proxy || !!s && $PROXY in s;
783
+ sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
784
+ }
785
+ if (SUPPORTS_PROXY && proxy) return new Proxy({
786
+ get(property) {
787
+ for (let i = sources.length - 1; i >= 0; i--) {
788
+ const v = resolveSource(sources[i])[property];
789
+ if (v !== void 0) return v;
790
+ }
791
+ },
792
+ has(property) {
793
+ for (let i = sources.length - 1; i >= 0; i--) if (property in resolveSource(sources[i])) return true;
794
+ return false;
795
+ },
796
+ keys() {
797
+ const keys = [];
798
+ for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
799
+ return [...new Set(keys)];
800
+ }
801
+ }, propTraps);
802
+ const sourcesMap = {};
803
+ const defined = Object.create(null);
804
+ for (let i = sources.length - 1; i >= 0; i--) {
805
+ const source = sources[i];
806
+ if (!source) continue;
807
+ const sourceKeys = Object.getOwnPropertyNames(source);
808
+ for (let i = sourceKeys.length - 1; i >= 0; i--) {
809
+ const key = sourceKeys[i];
810
+ if (key === "__proto__" || key === "constructor") continue;
811
+ const desc = Object.getOwnPropertyDescriptor(source, key);
812
+ if (!defined[key]) defined[key] = desc.get ? {
813
+ enumerable: true,
814
+ configurable: true,
815
+ get: resolveSources.bind(sourcesMap[key] = [desc.get.bind(source)])
816
+ } : desc.value !== void 0 ? desc : void 0;
817
+ else {
818
+ const sources = sourcesMap[key];
819
+ if (sources) {
820
+ if (desc.get) sources.push(desc.get.bind(source));
821
+ else if (desc.value !== void 0) sources.push(() => desc.value);
822
+ }
823
+ }
824
+ }
825
+ }
826
+ const target = {};
827
+ const definedKeys = Object.keys(defined);
828
+ for (let i = definedKeys.length - 1; i >= 0; i--) {
829
+ const key = definedKeys[i], desc = defined[key];
830
+ if (desc && desc.get) Object.defineProperty(target, key, desc);
831
+ else target[key] = desc ? desc.value : void 0;
832
+ }
833
+ return target;
834
+ }
835
+ function splitProps(props, ...keys) {
836
+ const len = keys.length;
837
+ if (SUPPORTS_PROXY && $PROXY in props) {
838
+ const blocked = len > 1 ? keys.flat() : keys[0];
839
+ const res = keys.map((k) => {
840
+ return new Proxy({
841
+ get(property) {
842
+ return k.includes(property) ? props[property] : void 0;
843
+ },
844
+ has(property) {
845
+ return k.includes(property) && property in props;
846
+ },
847
+ keys() {
848
+ return k.filter((property) => property in props);
849
+ }
850
+ }, propTraps);
851
+ });
852
+ res.push(new Proxy({
853
+ get(property) {
854
+ return blocked.includes(property) ? void 0 : props[property];
855
+ },
856
+ has(property) {
857
+ return blocked.includes(property) ? false : property in props;
858
+ },
859
+ keys() {
860
+ return Object.keys(props).filter((k) => !blocked.includes(k));
861
+ }
862
+ }, propTraps));
863
+ return res;
864
+ }
865
+ const objects = [];
866
+ for (let i = 0; i <= len; i++) objects[i] = {};
867
+ for (const propName of Object.getOwnPropertyNames(props)) {
868
+ let keyIndex = len;
869
+ for (let i = 0; i < keys.length; i++) if (keys[i].includes(propName)) {
870
+ keyIndex = i;
871
+ break;
872
+ }
873
+ const desc = Object.getOwnPropertyDescriptor(props, propName);
874
+ !desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable ? objects[keyIndex][propName] = desc.value : Object.defineProperty(objects[keyIndex], propName, desc);
875
+ }
876
+ return objects;
877
+ }
878
+ var narrowedError = (name) => `Stale read from <${name}>.`;
879
+ function For(props) {
880
+ const fallback = "fallback" in props && { fallback: () => props.fallback };
881
+ return createMemo(mapArray(() => props.each, props.children, fallback || void 0));
882
+ }
883
+ function Index(props) {
884
+ const fallback = "fallback" in props && { fallback: () => props.fallback };
885
+ return createMemo(indexArray(() => props.each, props.children, fallback || void 0));
886
+ }
887
+ function Show(props) {
888
+ const keyed = props.keyed;
889
+ const conditionValue = createMemo(() => props.when, void 0, void 0);
890
+ const condition = keyed ? conditionValue : createMemo(conditionValue, void 0, { equals: (a, b) => !a === !b });
891
+ return createMemo(() => {
892
+ const c = condition();
893
+ if (c) {
894
+ const child = props.children;
895
+ return typeof child === "function" && child.length > 0 ? untrack(() => child(keyed ? c : () => {
896
+ if (!untrack(condition)) throw narrowedError("Show");
897
+ return conditionValue();
898
+ })) : child;
899
+ }
900
+ return props.fallback;
901
+ }, void 0, void 0);
13
902
  }
14
903
  //#endregion
15
- //#region src/cli-program.ts
16
- const APP_VERSION = "0.2.0";
17
- const commandConfig = {
18
- paths: Args.text({ name: "path" }).pipe(Args.atLeast(0), Args.withDescription("Directory to scan. Repeat by passing multiple paths.")),
19
- presets: Options.text("preset").pipe(Options.withAlias("p"), Options.repeated, Options.withDescription("Cleanup preset to include: node, rust, gitignored. Can be repeated or comma-separated.")),
20
- ignoreHidden: Options.boolean("ignore-hidden").pipe(Options.withDescription("Skip hidden paths while scanning.")),
21
- sort: Options.choice("sort", SORT_MODES).pipe(Options.withDefault("size"), Options.withDescription("Sort cleanup candidates by size or path."))
904
+ //#region ../../node_modules/@uniview/tui-solid/dist/dist-bXJeAA2t.mjs
905
+ /**
906
+ * Reserved node type for text content (protocol v3).
907
+ * Text nodes carry their content in `text` and have no props/children.
908
+ */
909
+ var TEXT_NODE_TYPE = "#text";
910
+ /**
911
+ * Read the text content of a child, whether it uses the v3 explicit text
912
+ * node form or the legacy bare-string form.
913
+ */
914
+ function textContent(node) {
915
+ if (typeof node === "string") return node;
916
+ if (node.type === "#text") return node.text ?? "";
917
+ return null;
918
+ }
919
+ /**
920
+ * Runtime form of {@link EventPropName} — the DOM-style events, not every
921
+ * handler prop. See that type before using this as a filter.
922
+ */
923
+ var EVENT_PROPS = [
924
+ "onClick",
925
+ "onChange",
926
+ "onInput",
927
+ "onSubmit",
928
+ "onFocus",
929
+ "onBlur",
930
+ "onKeyDown",
931
+ "onKeyUp",
932
+ "onMouseEnter",
933
+ "onMouseLeave",
934
+ "onWheel"
935
+ ];
936
+ /**
937
+ * Check if a prop name is a handler ID prop
938
+ * e.g., '_onClickHandlerId' -> true
939
+ */
940
+ function isHandlerIdProp(propName) {
941
+ return propName.startsWith("_") && propName.endsWith("HandlerId");
942
+ }
943
+ /**
944
+ * Extract the event name from a handler ID prop name
945
+ * e.g., '_onClickHandlerId' -> 'onClick'
946
+ *
947
+ * Returns null for a handler id prop outside {@link EVENT_PROPS} — meaning "not
948
+ * a DOM event I can auto-wire", NOT "dead prop". `_onActionHandlerId` lands
949
+ * here and is still bound by name on the AppKit and Svelte hosts, so a caller
950
+ * filtering on this must pass the unrecognized ones through rather than drop
951
+ * them (see host-svelte's ComponentRenderer).
952
+ */
953
+ var HANDLER_ID_PREFIX_LENGTH = 1;
954
+ function extractEventName(handlerIdProp) {
955
+ if (!isHandlerIdProp(handlerIdProp)) return null;
956
+ const eventName = handlerIdProp.slice(HANDLER_ID_PREFIX_LENGTH, -9);
957
+ if (EVENT_PROPS.includes(eventName)) return eventName;
958
+ return null;
959
+ }
960
+ /**
961
+ * The Tailwind color palette, as flat `<family>-<shade>` tokens.
962
+ *
963
+ * These are plain design tokens, not a Tailwind dependency: the resolver looks
964
+ * class names up in `Theme.colors`, and this is what seeds the default theme so
965
+ * that `bg-emerald-500` / `text-zinc-400` resolve to a concrete color instead of
966
+ * being silently dropped.
967
+ *
968
+ * Values are literal hex. A native host receives the color the plugin author
969
+ * asked for, exactly — semantic, appearance-adaptive colors are a separate
970
+ * concern, expressed by the theme's semantic tokens (`foreground`, `border`, …).
971
+ *
972
+ * These are GENERATED from `tailwindcss/theme.css`, not typed by hand. Tailwind
973
+ * v4 defines its palette in oklch and re-tuned nearly every shade from v3, so a
974
+ * palette written from memory is a palette from the wrong major version: the
975
+ * first draft of this file had 185 of 242 tokens wrong, and `bg-emerald-500`
976
+ * rendered a different green natively than it did in a browser — from the same
977
+ * class name, which is the one thing this project cannot get wrong.
978
+ *
979
+ * `pnpm --filter @uniview/style gen:palette` regenerates; `palette.test.ts`
980
+ * fails if this file and the installed Tailwind ever disagree.
981
+ */
982
+ var FAMILIES = {
983
+ red: [
984
+ "#fef2f2",
985
+ "#ffe2e2",
986
+ "#ffc9c9",
987
+ "#ffa2a2",
988
+ "#ff6467",
989
+ "#fb2c36",
990
+ "#e7000b",
991
+ "#c10007",
992
+ "#9f0712",
993
+ "#82181a",
994
+ "#460809"
995
+ ],
996
+ orange: [
997
+ "#fff7ed",
998
+ "#ffedd4",
999
+ "#ffd6a7",
1000
+ "#ffb86a",
1001
+ "#ff8904",
1002
+ "#ff6900",
1003
+ "#f54900",
1004
+ "#ca3500",
1005
+ "#9f2d00",
1006
+ "#7e2a0c",
1007
+ "#441306"
1008
+ ],
1009
+ amber: [
1010
+ "#fffbeb",
1011
+ "#fef3c6",
1012
+ "#fee685",
1013
+ "#ffd230",
1014
+ "#ffb900",
1015
+ "#fe9a00",
1016
+ "#e17100",
1017
+ "#bb4d00",
1018
+ "#973c00",
1019
+ "#7b3306",
1020
+ "#461901"
1021
+ ],
1022
+ yellow: [
1023
+ "#fefce8",
1024
+ "#fef9c2",
1025
+ "#fff085",
1026
+ "#ffdf20",
1027
+ "#fdc700",
1028
+ "#f0b100",
1029
+ "#d08700",
1030
+ "#a65f00",
1031
+ "#894b00",
1032
+ "#733e0a",
1033
+ "#432004"
1034
+ ],
1035
+ lime: [
1036
+ "#f7fee7",
1037
+ "#ecfcca",
1038
+ "#d8f999",
1039
+ "#bbf451",
1040
+ "#9ae600",
1041
+ "#7ccf00",
1042
+ "#5ea500",
1043
+ "#497d00",
1044
+ "#3c6300",
1045
+ "#35530e",
1046
+ "#192e03"
1047
+ ],
1048
+ green: [
1049
+ "#f0fdf4",
1050
+ "#dcfce7",
1051
+ "#b9f8cf",
1052
+ "#7bf1a8",
1053
+ "#05df72",
1054
+ "#00c950",
1055
+ "#00a63e",
1056
+ "#008236",
1057
+ "#016630",
1058
+ "#0d542b",
1059
+ "#032e15"
1060
+ ],
1061
+ emerald: [
1062
+ "#ecfdf5",
1063
+ "#d0fae5",
1064
+ "#a4f4cf",
1065
+ "#5ee9b5",
1066
+ "#00d492",
1067
+ "#00bc7d",
1068
+ "#009966",
1069
+ "#007a55",
1070
+ "#006045",
1071
+ "#004f3b",
1072
+ "#002c22"
1073
+ ],
1074
+ teal: [
1075
+ "#f0fdfa",
1076
+ "#cbfbf1",
1077
+ "#96f7e4",
1078
+ "#46ecd5",
1079
+ "#00d5be",
1080
+ "#00bba7",
1081
+ "#009689",
1082
+ "#00786f",
1083
+ "#005f5a",
1084
+ "#0b4f4a",
1085
+ "#022f2e"
1086
+ ],
1087
+ cyan: [
1088
+ "#ecfeff",
1089
+ "#cefafe",
1090
+ "#a2f4fd",
1091
+ "#53eafd",
1092
+ "#00d3f2",
1093
+ "#00b8db",
1094
+ "#0092b8",
1095
+ "#007595",
1096
+ "#005f78",
1097
+ "#104e64",
1098
+ "#053345"
1099
+ ],
1100
+ sky: [
1101
+ "#f0f9ff",
1102
+ "#dff2fe",
1103
+ "#b8e6fe",
1104
+ "#74d4ff",
1105
+ "#00bcff",
1106
+ "#00a6f4",
1107
+ "#0084d1",
1108
+ "#0069a8",
1109
+ "#00598a",
1110
+ "#024a70",
1111
+ "#052f4a"
1112
+ ],
1113
+ blue: [
1114
+ "#eff6ff",
1115
+ "#dbeafe",
1116
+ "#bedbff",
1117
+ "#8ec5ff",
1118
+ "#51a2ff",
1119
+ "#2b7fff",
1120
+ "#155dfc",
1121
+ "#1447e6",
1122
+ "#193cb8",
1123
+ "#1c398e",
1124
+ "#162456"
1125
+ ],
1126
+ indigo: [
1127
+ "#eef2ff",
1128
+ "#e0e7ff",
1129
+ "#c6d2ff",
1130
+ "#a3b3ff",
1131
+ "#7c86ff",
1132
+ "#615fff",
1133
+ "#4f39f6",
1134
+ "#432dd7",
1135
+ "#372aac",
1136
+ "#312c85",
1137
+ "#1e1a4d"
1138
+ ],
1139
+ violet: [
1140
+ "#f5f3ff",
1141
+ "#ede9fe",
1142
+ "#ddd6ff",
1143
+ "#c4b4ff",
1144
+ "#a684ff",
1145
+ "#8e51ff",
1146
+ "#7f22fe",
1147
+ "#7008e7",
1148
+ "#5d0ec0",
1149
+ "#4d179a",
1150
+ "#2f0d68"
1151
+ ],
1152
+ purple: [
1153
+ "#faf5ff",
1154
+ "#f3e8ff",
1155
+ "#e9d4ff",
1156
+ "#dab2ff",
1157
+ "#c27aff",
1158
+ "#ad46ff",
1159
+ "#9810fa",
1160
+ "#8200db",
1161
+ "#6e11b0",
1162
+ "#59168b",
1163
+ "#3c0366"
1164
+ ],
1165
+ fuchsia: [
1166
+ "#fdf4ff",
1167
+ "#fae8ff",
1168
+ "#f6cfff",
1169
+ "#f4a8ff",
1170
+ "#ed6aff",
1171
+ "#e12afb",
1172
+ "#c800de",
1173
+ "#a800b7",
1174
+ "#8a0194",
1175
+ "#721378",
1176
+ "#4b004f"
1177
+ ],
1178
+ pink: [
1179
+ "#fdf2f8",
1180
+ "#fce7f3",
1181
+ "#fccee8",
1182
+ "#fda5d5",
1183
+ "#fb64b6",
1184
+ "#f6339a",
1185
+ "#e60076",
1186
+ "#c6005c",
1187
+ "#a3004c",
1188
+ "#861043",
1189
+ "#510424"
1190
+ ],
1191
+ rose: [
1192
+ "#fff1f2",
1193
+ "#ffe4e6",
1194
+ "#ffccd3",
1195
+ "#ffa1ad",
1196
+ "#ff637e",
1197
+ "#ff2056",
1198
+ "#ec003f",
1199
+ "#c70036",
1200
+ "#a50036",
1201
+ "#8b0836",
1202
+ "#4d0218"
1203
+ ],
1204
+ slate: [
1205
+ "#f8fafc",
1206
+ "#f1f5f9",
1207
+ "#e2e8f0",
1208
+ "#cad5e2",
1209
+ "#90a1b9",
1210
+ "#62748e",
1211
+ "#45556c",
1212
+ "#314158",
1213
+ "#1d293d",
1214
+ "#0f172b",
1215
+ "#020618"
1216
+ ],
1217
+ gray: [
1218
+ "#f9fafb",
1219
+ "#f3f4f6",
1220
+ "#e5e7eb",
1221
+ "#d1d5dc",
1222
+ "#99a1af",
1223
+ "#6a7282",
1224
+ "#4a5565",
1225
+ "#364153",
1226
+ "#1e2939",
1227
+ "#101828",
1228
+ "#030712"
1229
+ ],
1230
+ zinc: [
1231
+ "#fafafa",
1232
+ "#f4f4f5",
1233
+ "#e4e4e7",
1234
+ "#d4d4d8",
1235
+ "#9f9fa9",
1236
+ "#71717b",
1237
+ "#52525c",
1238
+ "#3f3f46",
1239
+ "#27272a",
1240
+ "#18181b",
1241
+ "#09090b"
1242
+ ],
1243
+ neutral: [
1244
+ "#fafafa",
1245
+ "#f5f5f5",
1246
+ "#e5e5e5",
1247
+ "#d4d4d4",
1248
+ "#a1a1a1",
1249
+ "#737373",
1250
+ "#525252",
1251
+ "#404040",
1252
+ "#262626",
1253
+ "#171717",
1254
+ "#0a0a0a"
1255
+ ],
1256
+ stone: [
1257
+ "#fafaf9",
1258
+ "#f5f5f4",
1259
+ "#e7e5e4",
1260
+ "#d6d3d1",
1261
+ "#a6a09b",
1262
+ "#79716b",
1263
+ "#57534d",
1264
+ "#44403b",
1265
+ "#292524",
1266
+ "#1c1917",
1267
+ "#0c0a09"
1268
+ ]
1269
+ };
1270
+ var SHADES = [
1271
+ 50,
1272
+ 100,
1273
+ 200,
1274
+ 300,
1275
+ 400,
1276
+ 500,
1277
+ 600,
1278
+ 700,
1279
+ 800,
1280
+ 900,
1281
+ 950
1282
+ ];
1283
+ function buildPalette() {
1284
+ const palette = {
1285
+ white: "#ffffff",
1286
+ black: "#000000",
1287
+ transparent: "transparent"
1288
+ };
1289
+ for (const [family, hexes] of Object.entries(FAMILIES)) SHADES.forEach((shade, i) => {
1290
+ palette[`${family}-${shade}`] = hexes[i];
1291
+ });
1292
+ return palette;
1293
+ }
1294
+ /** `{ "zinc-400": "#9f9fa9", "emerald-500": "#00bc7d", ... }` */
1295
+ var tailwindPalette = buildPalette();
1296
+ /**
1297
+ * The semantic vocabulary — shadcn's token names, mapped onto colors the OS owns.
1298
+ * Every one of these has a native counterpart the host resolves per view; the hex
1299
+ * here is what a web host (or a TS-resolving theme) uses.
1300
+ */
1301
+ var SEMANTIC_COLORS = {
1302
+ background: "#ffffff",
1303
+ foreground: "#111111",
1304
+ primary: "#0a84ff",
1305
+ "primary-foreground": "#ffffff",
1306
+ accent: "#0a84ff",
1307
+ "accent-foreground": "#ffffff",
1308
+ secondary: "#5856d6",
1309
+ muted: "#f2f2f7",
1310
+ "muted-foreground": "#6b7280",
1311
+ border: "#d1d5db",
1312
+ card: "#ffffff",
1313
+ destructive: "#ff3b30"
1314
+ };
1315
+ var defaultTheme = {
1316
+ colors: {
1317
+ ...tailwindPalette,
1318
+ ...SEMANTIC_COLORS
1319
+ },
1320
+ nativeTokens: new Set(Object.keys(SEMANTIC_COLORS)),
1321
+ spacing: (n) => n * 4,
1322
+ radii: {
1323
+ none: 0,
1324
+ sm: 4,
1325
+ md: 6,
1326
+ lg: 8,
1327
+ xl: 12,
1328
+ "2xl": 16,
1329
+ "3xl": 24,
1330
+ full: 9999,
1331
+ default: 6
1332
+ },
1333
+ fontSizes: {
1334
+ xs: 11,
1335
+ sm: 12,
1336
+ base: 13,
1337
+ lg: 15,
1338
+ xl: 18,
1339
+ "2xl": 22,
1340
+ "3xl": 28,
1341
+ "4xl": 34
1342
+ },
1343
+ shadows: {
1344
+ none: {
1345
+ offsetX: 0,
1346
+ offsetY: 0,
1347
+ radius: 0,
1348
+ color: "transparent"
1349
+ },
1350
+ sm: {
1351
+ offsetX: 0,
1352
+ offsetY: 1,
1353
+ radius: 2,
1354
+ color: "#0000000d"
1355
+ },
1356
+ default: {
1357
+ offsetX: 0,
1358
+ offsetY: 1,
1359
+ radius: 3,
1360
+ color: "#0000001a"
1361
+ },
1362
+ md: {
1363
+ offsetX: 0,
1364
+ offsetY: 4,
1365
+ radius: 6,
1366
+ color: "#0000001a"
1367
+ },
1368
+ lg: {
1369
+ offsetX: 0,
1370
+ offsetY: 10,
1371
+ radius: 15,
1372
+ color: "#0000001a"
1373
+ },
1374
+ xl: {
1375
+ offsetX: 0,
1376
+ offsetY: 20,
1377
+ radius: 25,
1378
+ color: "#0000001a"
1379
+ },
1380
+ "2xl": {
1381
+ offsetX: 0,
1382
+ offsetY: 25,
1383
+ radius: 50,
1384
+ color: "#00000040"
1385
+ }
1386
+ },
1387
+ leadings: {
1388
+ none: 1,
1389
+ tight: 1.25,
1390
+ snug: 1.375,
1391
+ normal: 1.5,
1392
+ relaxed: 1.625,
1393
+ loose: 2
1394
+ },
1395
+ sizes: {
1396
+ xs: 320,
1397
+ sm: 384,
1398
+ md: 448,
1399
+ lg: 512,
1400
+ xl: 576,
1401
+ "2xl": 672,
1402
+ "3xl": 768,
1403
+ "4xl": 896,
1404
+ "5xl": 1024,
1405
+ "6xl": 1152,
1406
+ "7xl": 1280
1407
+ }
22
1408
  };
23
- const spaceLensTuiCommand = Command.make("spacelens", commandConfig, (rawConfig) => Effect.gen(function* () {
1409
+ ({ ...defaultTheme });
1410
+ ({ ...defaultTheme }), { ...defaultTheme.colors };
1411
+ /**
1412
+ * The Tailwind-subset resolver. Runs plugin-side: a native host receives the
1413
+ * finished `ResolvedStyle` and never parses a class name.
1414
+ *
1415
+ * Two places where this deliberately follows *CSS* semantics rather than a
1416
+ * naive token mapping, because plugins are authored against CSS:
1417
+ *
1418
+ * - `flex` sets `flexDirection: "row"`. CSS's `display:flex` defaults to row,
1419
+ * but a flex engine (Yoga) defaults to column, so treating `flex` as a no-op
1420
+ * would silently stack every `<div className="flex gap-2">` vertically.
1421
+ * - `space-y-N` / `space-x-N` become `gap`. Tailwind implements them as margins
1422
+ * on the children; on a flex engine `gap` is the equivalent, and every native
1423
+ * container is a flex box. (The axis distinction is lost — a `space-y` on a
1424
+ * row will space it horizontally.)
1425
+ */
1426
+ /** Classes with a fixed mapping (no argument). */
1427
+ var STATIC_CLASSES = {
1428
+ flex: { flexDirection: "row" },
1429
+ "flex-row": { flexDirection: "row" },
1430
+ "flex-col": { flexDirection: "column" },
1431
+ "flex-row-reverse": { flexDirection: "row-reverse" },
1432
+ "flex-col-reverse": { flexDirection: "column-reverse" },
1433
+ "flex-wrap": { flexWrap: "wrap" },
1434
+ "flex-nowrap": { flexWrap: "nowrap" },
1435
+ "flex-1": {
1436
+ flexGrow: 1,
1437
+ flexShrink: 1,
1438
+ flexBasis: 0
1439
+ },
1440
+ "flex-auto": {
1441
+ flexGrow: 1,
1442
+ flexShrink: 1,
1443
+ flexBasis: "auto"
1444
+ },
1445
+ "flex-none": {
1446
+ flexGrow: 0,
1447
+ flexShrink: 0
1448
+ },
1449
+ grow: { flexGrow: 1 },
1450
+ "grow-0": { flexGrow: 0 },
1451
+ shrink: { flexShrink: 1 },
1452
+ "shrink-0": { flexShrink: 0 },
1453
+ "items-start": { alignItems: "flex-start" },
1454
+ "items-center": { alignItems: "center" },
1455
+ "items-end": { alignItems: "flex-end" },
1456
+ "items-stretch": { alignItems: "stretch" },
1457
+ "items-baseline": { alignItems: "baseline" },
1458
+ "justify-start": { justifyContent: "flex-start" },
1459
+ "justify-center": { justifyContent: "center" },
1460
+ "justify-end": { justifyContent: "flex-end" },
1461
+ "justify-between": { justifyContent: "space-between" },
1462
+ "justify-around": { justifyContent: "space-around" },
1463
+ "justify-evenly": { justifyContent: "space-evenly" },
1464
+ "self-auto": { alignSelf: "auto" },
1465
+ "self-start": { alignSelf: "flex-start" },
1466
+ "self-center": { alignSelf: "center" },
1467
+ "self-end": { alignSelf: "flex-end" },
1468
+ "self-stretch": { alignSelf: "stretch" },
1469
+ relative: { position: "relative" },
1470
+ absolute: { position: "absolute" },
1471
+ hidden: { display: "none" },
1472
+ block: { display: "flex" },
1473
+ "overflow-visible": { overflow: "visible" },
1474
+ "overflow-hidden": { overflow: "hidden" },
1475
+ "overflow-scroll": { overflow: "scroll" },
1476
+ "overflow-auto": { overflow: "scroll" },
1477
+ border: { borderWidth: 1 },
1478
+ "border-0": { borderWidth: 0 },
1479
+ "font-normal": { fontWeight: "normal" },
1480
+ "font-medium": { fontWeight: "medium" },
1481
+ "font-semibold": { fontWeight: "semibold" },
1482
+ "font-bold": { fontWeight: "bold" },
1483
+ italic: { fontStyle: "italic" },
1484
+ "not-italic": { fontStyle: "normal" },
1485
+ underline: { textDecoration: "underline" },
1486
+ "line-through": { textDecoration: "line-through" },
1487
+ "no-underline": { textDecoration: "none" },
1488
+ truncate: { maxLines: 1 },
1489
+ "text-left": { textAlign: "left" },
1490
+ "text-center": { textAlign: "center" },
1491
+ "text-right": { textAlign: "right" }
1492
+ };
1493
+ /**
1494
+ * Rules whose argument is a length on the spacing scale. The argument is matched
1495
+ * loosely (`(.+)`) and handed to `spacingValue`, so an arbitrary value
1496
+ * (`p-[13px]`) works everywhere a step (`p-4`) does, without a second rule table.
1497
+ */
1498
+ var EDGE_RULES = [
1499
+ [/^gap-(.+)$/, (v) => ({ gap: v })],
1500
+ [/^space-[xy]-(.+)$/, (v) => ({ gap: v })],
1501
+ [/^p-(.+)$/, (v) => ({
1502
+ paddingTop: v,
1503
+ paddingRight: v,
1504
+ paddingBottom: v,
1505
+ paddingLeft: v
1506
+ })],
1507
+ [/^px-(.+)$/, (v) => ({
1508
+ paddingLeft: v,
1509
+ paddingRight: v
1510
+ })],
1511
+ [/^py-(.+)$/, (v) => ({
1512
+ paddingTop: v,
1513
+ paddingBottom: v
1514
+ })],
1515
+ [/^pt-(.+)$/, (v) => ({ paddingTop: v })],
1516
+ [/^pr-(.+)$/, (v) => ({ paddingRight: v })],
1517
+ [/^pb-(.+)$/, (v) => ({ paddingBottom: v })],
1518
+ [/^pl-(.+)$/, (v) => ({ paddingLeft: v })],
1519
+ [/^m-(.+)$/, (v) => ({
1520
+ marginTop: v,
1521
+ marginRight: v,
1522
+ marginBottom: v,
1523
+ marginLeft: v
1524
+ })],
1525
+ [/^mx-(.+)$/, (v) => ({
1526
+ marginLeft: v,
1527
+ marginRight: v
1528
+ })],
1529
+ [/^my-(.+)$/, (v) => ({
1530
+ marginTop: v,
1531
+ marginBottom: v
1532
+ })],
1533
+ [/^mt-(.+)$/, (v) => ({ marginTop: v })],
1534
+ [/^mr-(.+)$/, (v) => ({ marginRight: v })],
1535
+ [/^mb-(.+)$/, (v) => ({ marginBottom: v })],
1536
+ [/^ml-(.+)$/, (v) => ({ marginLeft: v })],
1537
+ [/^inset-x-(.+)$/, (v) => ({
1538
+ left: v,
1539
+ right: v
1540
+ })],
1541
+ [/^inset-y-(.+)$/, (v) => ({
1542
+ top: v,
1543
+ bottom: v
1544
+ })],
1545
+ [/^inset-(.+)$/, (v) => ({
1546
+ top: v,
1547
+ right: v,
1548
+ bottom: v,
1549
+ left: v
1550
+ })],
1551
+ [/^top-(.+)$/, (v) => ({ top: v })],
1552
+ [/^right-(.+)$/, (v) => ({ right: v })],
1553
+ [/^bottom-(.+)$/, (v) => ({ bottom: v })],
1554
+ [/^left-(.+)$/, (v) => ({ left: v })]
1555
+ ];
1556
+ /** Rules that a leading `-` may negate (`-mt-2`, `-inset-1`). Lengths only. */
1557
+ var NEGATABLE = /^(m[xytrbl]?|inset(-[xy])?|top|right|bottom|left|z)-/;
1558
+ var AUTO_MARGINS = {
1559
+ "m-auto": {
1560
+ marginTop: "auto",
1561
+ marginRight: "auto",
1562
+ marginBottom: "auto",
1563
+ marginLeft: "auto"
1564
+ },
1565
+ "mx-auto": {
1566
+ marginLeft: "auto",
1567
+ marginRight: "auto"
1568
+ },
1569
+ "my-auto": {
1570
+ marginTop: "auto",
1571
+ marginBottom: "auto"
1572
+ },
1573
+ "mt-auto": { marginTop: "auto" },
1574
+ "mr-auto": { marginRight: "auto" },
1575
+ "mb-auto": { marginBottom: "auto" },
1576
+ "ml-auto": { marginLeft: "auto" }
1577
+ };
1578
+ var SIZE_RULES = [
1579
+ [/^w-(.+)$/, (d) => ({ width: d })],
1580
+ [/^h-(.+)$/, (d) => ({ height: d })],
1581
+ [/^min-w-(.+)$/, (d) => ({ minWidth: d })],
1582
+ [/^min-h-(.+)$/, (d) => ({ minHeight: d })],
1583
+ [/^max-w-(.+)$/, (d) => ({ maxWidth: d })],
1584
+ [/^max-h-(.+)$/, (d) => ({ maxHeight: d })]
1585
+ ];
1586
+ /**
1587
+ * The contents of an arbitrary value: `[13px]` → `"13px"`. Tailwind's escape
1588
+ * hatch, and the answer to every "the scale doesn't have the number I need".
1589
+ */
1590
+ function arbitrary(token) {
1591
+ return token.startsWith("[") && token.endsWith("]") ? token.slice(1, -1).replace(/_/g, " ") : void 0;
1592
+ }
1593
+ /** A length in points: a spacing step (`4` → 16), or an arbitrary `[13px]`. */
1594
+ function spacingValue(token, theme) {
1595
+ const raw = arbitrary(token);
1596
+ if (raw !== void 0) {
1597
+ const n = Number.parseFloat(raw);
1598
+ return Number.isNaN(n) ? void 0 : n;
1599
+ }
1600
+ if (token === "px") return 1;
1601
+ return /^\d+(\.\d+)?$/.test(token) ? theme.spacing(Number(token)) : void 0;
1602
+ }
1603
+ /**
1604
+ * A sizing argument: `full`, `auto`, `screen`, a named size (`md` → the theme's
1605
+ * size scale), a fraction (`1/2` → `"50%"`), an arbitrary `[137px]` / `[50%]`,
1606
+ * or a spacing step (`10` → 40px).
1607
+ */
1608
+ function parseDimension(token, theme) {
1609
+ if (token === "full") return "100%";
1610
+ if (token === "auto") return "auto";
1611
+ const raw = arbitrary(token);
1612
+ if (raw !== void 0) {
1613
+ if (raw.endsWith("%")) {
1614
+ const pct = Number.parseFloat(raw);
1615
+ return Number.isNaN(pct) ? void 0 : `${pct}%`;
1616
+ }
1617
+ const n = Number.parseFloat(raw);
1618
+ return Number.isNaN(n) ? void 0 : n;
1619
+ }
1620
+ if (token in theme.sizes) return theme.sizes[token];
1621
+ const fraction = token.match(/^(\d+)\/(\d+)$/);
1622
+ if (fraction) {
1623
+ const pct = Number(fraction[1]) / Number(fraction[2]) * 100;
1624
+ return `${Number(pct.toFixed(4))}%`;
1625
+ }
1626
+ return spacingValue(token, theme);
1627
+ }
1628
+ /** `0` → `"00"`, `255` → `"ff"`. */
1629
+ function alphaByte(fraction) {
1630
+ return Math.round(Math.max(0, Math.min(1, fraction)) * 255).toString(16).padStart(2, "0");
1631
+ }
1632
+ /**
1633
+ * A color argument, with Tailwind's optional `/N` alpha suffix.
1634
+ *
1635
+ * A token in `theme.nativeTokens` keeps its NAME (`card`, `card/50`): the native
1636
+ * host owns what it looks like, so that it can keep looking right when the
1637
+ * appearance changes. Everything else resolves to a literal, and its alpha folds
1638
+ * into an 8-digit `#rrggbbaa` — the form native color parsers already take, so no
1639
+ * host needs an `rgba()` parser.
1640
+ */
1641
+ function parseColor(token, theme) {
1642
+ const literal = arbitrary(token);
1643
+ if (literal !== void 0) return literal;
1644
+ const slash = token.lastIndexOf("/");
1645
+ const name = slash === -1 ? token : token.slice(0, slash);
1646
+ if (theme.nativeTokens.has(name)) return token;
1647
+ const base = theme.colors[name];
1648
+ if (base === void 0) return void 0;
1649
+ if (slash === -1) return base;
1650
+ const percent = Number(token.slice(slash + 1));
1651
+ if (Number.isNaN(percent)) return void 0;
1652
+ if (!/^#[0-9a-f]{6}$/i.test(base)) return base;
1653
+ return base + alphaByte(percent / 100);
1654
+ }
1655
+ /** Resolve one class token to a partial style, or null when unrecognized. */
1656
+ function matchToken(token, theme) {
1657
+ if (token.startsWith("-") && NEGATABLE.test(token.slice(1))) {
1658
+ const positive = matchToken(token.slice(1), theme);
1659
+ if (!positive) return null;
1660
+ return Object.fromEntries(Object.entries(positive).map(([key, value]) => [key, typeof value === "number" ? -value : value]));
1661
+ }
1662
+ const staticMatch = STATIC_CLASSES[token] ?? AUTO_MARGINS[token];
1663
+ if (staticMatch) return staticMatch;
1664
+ for (const [pattern, build] of EDGE_RULES) {
1665
+ const m = token.match(pattern);
1666
+ if (!m) continue;
1667
+ const value = spacingValue(m[1], theme);
1668
+ return value === void 0 ? null : build(value);
1669
+ }
1670
+ for (const [pattern, build] of SIZE_RULES) {
1671
+ const m = token.match(pattern);
1672
+ if (!m) continue;
1673
+ const dimension = parseDimension(m[1], theme);
1674
+ return dimension === void 0 ? null : build(dimension);
1675
+ }
1676
+ let m;
1677
+ if (m = token.match(/^rounded(?:-(.+))?$/)) {
1678
+ const key = m[1] ?? "default";
1679
+ if (key in theme.radii) return { borderRadius: theme.radii[key] };
1680
+ const value = spacingValue(key, theme) ?? Number(key);
1681
+ return Number.isNaN(value) ? null : { borderRadius: value };
1682
+ }
1683
+ if (m = token.match(/^shadow(?:-(.+))?$/)) {
1684
+ const key = m[1] ?? "default";
1685
+ if (key in theme.shadows) return { shadow: theme.shadows[key] };
1686
+ const color = parseColor(key, theme);
1687
+ return color === void 0 ? null : { shadowColor: color };
1688
+ }
1689
+ if (m = token.match(/^z-(\d+)$/)) return { zIndex: Number(m[1]) };
1690
+ if (m = token.match(/^aspect-(.+)$/)) {
1691
+ const key = m[1];
1692
+ if (key === "square") return { aspectRatio: 1 };
1693
+ if (key === "video") return { aspectRatio: 16 / 9 };
1694
+ const raw = arbitrary(key) ?? key;
1695
+ const ratio = raw.match(/^(\d+(?:\.\d+)?)\/(\d+(?:\.\d+)?)$/);
1696
+ if (ratio) return { aspectRatio: Number(ratio[1]) / Number(ratio[2]) };
1697
+ const n = Number.parseFloat(raw);
1698
+ return Number.isNaN(n) ? null : { aspectRatio: n };
1699
+ }
1700
+ if (m = token.match(/^leading-(.+)$/)) {
1701
+ const key = m[1];
1702
+ if (key in theme.leadings) return { lineHeightMultiple: theme.leadings[key] };
1703
+ const value = spacingValue(key, theme);
1704
+ return value === void 0 ? null : { lineHeight: value };
1705
+ }
1706
+ if (m = token.match(/^line-clamp-(\d+)$/)) return { maxLines: Number(m[1]) };
1707
+ if (m = token.match(/^border-(\d+)$/)) return { borderWidth: Number(m[1]) };
1708
+ if (m = token.match(/^opacity-(\d+(?:\.\d+)?)$/)) return { opacity: Number(m[1]) / 100 };
1709
+ if (m = token.match(/^bg-(.+)$/)) {
1710
+ const color = parseColor(m[1], theme);
1711
+ return color === void 0 ? null : { backgroundColor: color };
1712
+ }
1713
+ if (m = token.match(/^border-(.+)$/)) {
1714
+ const color = parseColor(m[1], theme);
1715
+ return color === void 0 ? null : { borderColor: color };
1716
+ }
1717
+ if (m = token.match(/^text-(.+)$/)) {
1718
+ const key = m[1];
1719
+ if (key in theme.fontSizes) return { fontSize: theme.fontSizes[key] };
1720
+ const size = arbitrary(key);
1721
+ if (size !== void 0 && /^[\d.]/.test(size)) return { fontSize: Number.parseFloat(size) };
1722
+ const color = parseColor(key, theme);
1723
+ return color === void 0 ? null : { color };
1724
+ }
1725
+ return null;
1726
+ }
1727
+ var GRADIENT_DIRECTIONS = /* @__PURE__ */ new Set([
1728
+ "to-t",
1729
+ "to-tr",
1730
+ "to-r",
1731
+ "to-br",
1732
+ "to-b",
1733
+ "to-bl",
1734
+ "to-l",
1735
+ "to-tl"
1736
+ ]);
1737
+ /**
1738
+ * `bg-linear-to-br from-sky-500 via-indigo-400 to-violet-600` (v4), or the same
1739
+ * with v3's `bg-gradient-to-br`.
1740
+ *
1741
+ * A gradient is the one thing in Tailwind that a *single* token cannot express:
1742
+ * the direction and each stop arrive as separate classes and have to be gathered.
1743
+ * So it gets a pass of its own rather than being bent into the per-token table.
1744
+ *
1745
+ * `to-` is deliberately matched only here. Everywhere else in Tailwind a bare
1746
+ * `to-…` means nothing, so there is no ambiguity to resolve.
1747
+ */
1748
+ function gradient(tokens, theme) {
1749
+ let direction;
1750
+ let from;
1751
+ let to;
1752
+ const via = [];
1753
+ for (const token of tokens) {
1754
+ const arrow = token.match(/^bg-(?:linear|gradient)-(to-[a-z]{1,2})$/);
1755
+ if (arrow && GRADIENT_DIRECTIONS.has(arrow[1])) {
1756
+ direction = arrow[1];
1757
+ continue;
1758
+ }
1759
+ const stop = token.match(/^(from|via|to)-(.+)$/);
1760
+ if (!stop) continue;
1761
+ const color = parseColor(stop[2], theme);
1762
+ if (color === void 0) continue;
1763
+ if (stop[1] === "from") from = color;
1764
+ else if (stop[1] === "to") to = color;
1765
+ else via.push(color);
1766
+ }
1767
+ if (direction === void 0 || from === void 0 || to === void 0) return void 0;
1768
+ return {
1769
+ direction,
1770
+ colors: [
1771
+ from,
1772
+ ...via,
1773
+ to
1774
+ ]
1775
+ };
1776
+ }
1777
+ /**
1778
+ * Class strings are static literals re-serialized on every render, so the parse
1779
+ * is memoized per theme. Cached results are frozen: callers spread, never write.
1780
+ */
1781
+ var cache = /* @__PURE__ */ new WeakMap();
1782
+ /**
1783
+ * Resolve a Tailwind-subset class string into a `ResolvedStyle`. Unknown tokens
1784
+ * are ignored; later tokens override earlier ones.
1785
+ */
1786
+ function resolveClassName(className, theme = defaultTheme) {
1787
+ let themeCache = cache.get(theme);
1788
+ if (!themeCache) {
1789
+ themeCache = /* @__PURE__ */ new Map();
1790
+ cache.set(theme, themeCache);
1791
+ }
1792
+ const hit = themeCache.get(className);
1793
+ if (hit) return hit;
1794
+ const tokens = className.trim().split(/\s+/).filter(Boolean);
1795
+ const out = {};
1796
+ const variants = {};
1797
+ const base = [];
1798
+ for (const token of tokens) {
1799
+ const split = splitVariants(token);
1800
+ if (split === null) continue;
1801
+ const [conditions, rest] = split;
1802
+ if (conditions.length === 0) {
1803
+ base.push(rest);
1804
+ const partial = matchToken(rest, theme);
1805
+ if (partial) Object.assign(out, partial);
1806
+ continue;
1807
+ }
1808
+ const partial = matchToken(rest, theme);
1809
+ if (!partial) continue;
1810
+ const key = conditions.join(":");
1811
+ variants[key] = {
1812
+ ...variants[key],
1813
+ ...partial
1814
+ };
1815
+ }
1816
+ const fill = gradient(base, theme);
1817
+ if (fill) out.backgroundGradient = fill;
1818
+ if (Object.keys(variants).length > 0) out.variants = variants;
1819
+ const frozen = Object.freeze(out);
1820
+ themeCache.set(className, frozen);
1821
+ return frozen;
1822
+ }
1823
+ /** The conditions a variant prefix may name. Anything else is not a variant. */
1824
+ var VARIANTS = /* @__PURE__ */ new Set([
1825
+ "dark",
1826
+ "light",
1827
+ "hover",
1828
+ "focus",
1829
+ "active",
1830
+ "disabled"
1831
+ ]);
1832
+ /**
1833
+ * `dark:hover:bg-zinc-800` → `[["dark", "hover"], "bg-zinc-800"]`.
1834
+ *
1835
+ * Returns `null` for a prefix that isn't a variant we can honour. Dropping the
1836
+ * whole token is deliberate: strip an unknown `md:` and it would silently become
1837
+ * an *unconditional* style, which is worse than it not working.
1838
+ */
1839
+ function splitVariants(token) {
1840
+ const bracket = token.indexOf("[");
1841
+ const count = (bracket === -1 ? token : token.slice(0, bracket)).split(":").length - 1;
1842
+ if (count === 0) return [[], token];
1843
+ const conditions = token.split(":", count);
1844
+ const rest = token.slice(conditions.reduce((n, c) => n + c.length + 1, 0));
1845
+ return conditions.every((c) => VARIANTS.has(c)) ? [conditions, rest] : null;
1846
+ }
1847
+ /**
1848
+ * Expand the padding/margin shorthands in a style object into the four explicit
1849
+ * edges. Precedence, low → high: all-sides, then horizontal/vertical, then edge.
1850
+ */
1851
+ function normalizeStyleInput(style) {
1852
+ const { padding, paddingHorizontal, paddingVertical, margin, marginHorizontal, marginVertical, ...rest } = style;
1853
+ const out = { ...rest };
1854
+ const edges = [
1855
+ [
1856
+ "paddingTop",
1857
+ out.paddingTop,
1858
+ paddingVertical,
1859
+ padding
1860
+ ],
1861
+ [
1862
+ "paddingBottom",
1863
+ out.paddingBottom,
1864
+ paddingVertical,
1865
+ padding
1866
+ ],
1867
+ [
1868
+ "paddingLeft",
1869
+ out.paddingLeft,
1870
+ paddingHorizontal,
1871
+ padding
1872
+ ],
1873
+ [
1874
+ "paddingRight",
1875
+ out.paddingRight,
1876
+ paddingHorizontal,
1877
+ padding
1878
+ ],
1879
+ [
1880
+ "marginTop",
1881
+ out.marginTop,
1882
+ marginVertical,
1883
+ margin
1884
+ ],
1885
+ [
1886
+ "marginBottom",
1887
+ out.marginBottom,
1888
+ marginVertical,
1889
+ margin
1890
+ ],
1891
+ [
1892
+ "marginLeft",
1893
+ out.marginLeft,
1894
+ marginHorizontal,
1895
+ margin
1896
+ ],
1897
+ [
1898
+ "marginRight",
1899
+ out.marginRight,
1900
+ marginHorizontal,
1901
+ margin
1902
+ ]
1903
+ ];
1904
+ for (const [key, edge, axis, all] of edges) {
1905
+ const value = edge ?? axis ?? all;
1906
+ if (value !== void 0) Object.assign(out, { [key]: value });
1907
+ }
1908
+ return out;
1909
+ }
1910
+ /**
1911
+ * Resolve `className` + `style` into one `ResolvedStyle`. The style object wins
1912
+ * over the class string on any field they both set.
1913
+ */
1914
+ function resolveStyle(input, theme = defaultTheme) {
1915
+ const fromClass = input.className ? resolveClassName(input.className, theme) : {};
1916
+ const fromStyle = input.style ? normalizeStyleInput(input.style) : {};
1917
+ return {
1918
+ ...fromClass,
1919
+ ...fromStyle
1920
+ };
1921
+ }
1922
+ /**
1923
+ * Resolve a node's `className` + `style` into the Style IR object that travels on
1924
+ * the wire as `_style`, or `null` when the node has no styling.
1925
+ *
1926
+ * This is what every renderer's serializer emits so that a native host — which
1927
+ * has no CSS engine and never parses `className` — still gets the resolved
1928
+ * layout and visual style. It lives here, in `@uniview/style`, precisely so that
1929
+ * a *new* renderer (React, Solid, and whatever comes next) does not re-implement
1930
+ * it and drift: the whole point of the framework-agnostic contract is that the IR
1931
+ * is produced identically no matter which plugin-side framework authored the
1932
+ * tree. (The Solid renderer once forwarded `className` untouched, so Solid
1933
+ * plugins rendered natively lost every Tailwind-derived style — this exists so
1934
+ * that can't recur.)
1935
+ *
1936
+ * `undefined` fields are dropped so the object is JSON-clean; the result is a
1937
+ * plain `ResolvedStyle`, which is already JSON-safe, and callers hand it across
1938
+ * the boundary as-is.
1939
+ */
1940
+ function resolveStyleIR(props, theme = defaultTheme) {
1941
+ const input = {};
1942
+ if (typeof props.className === "string") input.className = props.className;
1943
+ if (typeof props.style === "object" && props.style !== null && !Array.isArray(props.style)) input.style = props.style;
1944
+ if (input.className === void 0 && input.style === void 0) return null;
1945
+ const resolved = {};
1946
+ for (const [key, value] of Object.entries(resolveStyle(input, theme))) if (value !== void 0) Object.assign(resolved, { [key]: value });
1947
+ return Object.keys(resolved).length > 0 ? resolved : null;
1948
+ }
1949
+ var idCounter = 0;
1950
+ function generateId(prefix = "node") {
1951
+ return `${prefix}-${++idCounter}`;
1952
+ }
1953
+ function resetIdCounter() {
1954
+ idCounter = 0;
1955
+ }
1956
+ var memo$1 = (fn) => createMemo(() => fn());
1957
+ function createRenderer({ createElement, createTextNode, createSlotNode, isTextNode, replaceText, insertNode, removeNode, setProperty, getParentNode, getFirstChild, getNextSibling }) {
1958
+ function insert(parent, accessor, marker, initial) {
1959
+ if (marker !== void 0 && !initial) initial = [];
1960
+ if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
1961
+ createRenderEffect((current) => insertExpression(parent, accessor(), current, marker), initial);
1962
+ }
1963
+ function insertExpression(parent, value, current, marker, unwrapArray) {
1964
+ while (typeof current === "function") current = current();
1965
+ if (value === current) return current;
1966
+ const t = typeof value, multi = marker !== void 0;
1967
+ if (t === "string" || t === "number") {
1968
+ if (t === "number") value = value.toString();
1969
+ if (multi) {
1970
+ let node = current[0];
1971
+ if (node && isTextNode(node)) replaceText(node, value);
1972
+ else node = createTextNode(value);
1973
+ current = cleanChildren(parent, current, marker, node);
1974
+ } else if (current !== "" && typeof current === "string") replaceText(getFirstChild(parent), current = value);
1975
+ else {
1976
+ cleanChildren(parent, current, marker, createTextNode(value));
1977
+ current = value;
1978
+ }
1979
+ } else if (value == null || t === "boolean") current = cleanChildren(parent, current, marker);
1980
+ else if (t === "function") {
1981
+ createRenderEffect(() => {
1982
+ let v = value();
1983
+ while (typeof v === "function") v = v();
1984
+ current = insertExpression(parent, v, current, marker);
1985
+ });
1986
+ return () => current;
1987
+ } else if (Array.isArray(value)) {
1988
+ const array = [];
1989
+ if (normalizeIncomingArray(array, value, unwrapArray)) {
1990
+ createRenderEffect(() => current = insertExpression(parent, array, current, marker, true));
1991
+ return () => current;
1992
+ }
1993
+ if (array.length === 0) {
1994
+ const replacement = cleanChildren(parent, current, marker);
1995
+ if (multi) return current = replacement;
1996
+ } else if (Array.isArray(current)) if (current.length === 0) appendNodes(parent, array, marker);
1997
+ else reconcileArrays(parent, current, array);
1998
+ else if (current == null || current === "") appendNodes(parent, array);
1999
+ else reconcileArrays(parent, multi && current || [getFirstChild(parent)], array);
2000
+ current = array;
2001
+ } else {
2002
+ if (Array.isArray(current)) {
2003
+ if (multi) return current = cleanChildren(parent, current, marker, value);
2004
+ cleanChildren(parent, current, null, value);
2005
+ } else if (current == null || current === "" || !getFirstChild(parent)) insertNode(parent, value);
2006
+ else replaceNode(parent, value, getFirstChild(parent));
2007
+ current = value;
2008
+ }
2009
+ return current;
2010
+ }
2011
+ function normalizeIncomingArray(normalized, array, unwrap) {
2012
+ let dynamic = false;
2013
+ for (let i = 0, len = array.length; i < len; i++) {
2014
+ let item = array[i], t;
2015
+ if (item == null || item === true || item === false);
2016
+ else if (Array.isArray(item)) dynamic = normalizeIncomingArray(normalized, item) || dynamic;
2017
+ else if ((t = typeof item) === "string" || t === "number") normalized.push(createTextNode(item));
2018
+ else if (t === "function") if (unwrap) {
2019
+ while (typeof item === "function") item = item();
2020
+ dynamic = normalizeIncomingArray(normalized, Array.isArray(item) ? item : [item]) || dynamic;
2021
+ } else {
2022
+ normalized.push(item);
2023
+ dynamic = true;
2024
+ }
2025
+ else normalized.push(item);
2026
+ }
2027
+ return dynamic;
2028
+ }
2029
+ function reconcileArrays(parentNode, a, b) {
2030
+ let bLength = b.length, aEnd = a.length, bEnd = bLength, aStart = 0, bStart = 0, after = getNextSibling(a[aEnd - 1]), map = null;
2031
+ while (aStart < aEnd || bStart < bEnd) {
2032
+ if (a[aStart] === b[bStart]) {
2033
+ aStart++;
2034
+ bStart++;
2035
+ continue;
2036
+ }
2037
+ while (a[aEnd - 1] === b[bEnd - 1]) {
2038
+ aEnd--;
2039
+ bEnd--;
2040
+ }
2041
+ if (aEnd === aStart) {
2042
+ const node = bEnd < bLength ? bStart ? getNextSibling(b[bStart - 1]) : b[bEnd - bStart] : after;
2043
+ while (bStart < bEnd) insertNode(parentNode, b[bStart++], node);
2044
+ } else if (bEnd === bStart) while (aStart < aEnd) {
2045
+ if (!map || !map.has(a[aStart])) removeNode(parentNode, a[aStart]);
2046
+ aStart++;
2047
+ }
2048
+ else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
2049
+ const node = getNextSibling(a[--aEnd]);
2050
+ insertNode(parentNode, b[bStart++], getNextSibling(a[aStart++]));
2051
+ insertNode(parentNode, b[--bEnd], node);
2052
+ a[aEnd] = b[bEnd];
2053
+ } else {
2054
+ if (!map) {
2055
+ map = /* @__PURE__ */ new Map();
2056
+ let i = bStart;
2057
+ while (i < bEnd) map.set(b[i], i++);
2058
+ }
2059
+ const index = map.get(a[aStart]);
2060
+ if (index != null) if (bStart < index && index < bEnd) {
2061
+ let i = aStart, sequence = 1, t;
2062
+ while (++i < aEnd && i < bEnd) {
2063
+ if ((t = map.get(a[i])) == null || t !== index + sequence) break;
2064
+ sequence++;
2065
+ }
2066
+ if (sequence > index - bStart) {
2067
+ const node = a[aStart];
2068
+ while (bStart < index) insertNode(parentNode, b[bStart++], node);
2069
+ } else replaceNode(parentNode, b[bStart++], a[aStart++]);
2070
+ } else aStart++;
2071
+ else removeNode(parentNode, a[aStart++]);
2072
+ }
2073
+ }
2074
+ }
2075
+ function cleanChildren(parent, current, marker, replacement) {
2076
+ if (marker === void 0) {
2077
+ let removed;
2078
+ while (removed = getFirstChild(parent)) removeNode(parent, removed);
2079
+ replacement && insertNode(parent, replacement);
2080
+ return replacement;
2081
+ }
2082
+ const node = replacement || createSlotNode();
2083
+ if (current.length) {
2084
+ let inserted = false;
2085
+ for (let i = current.length - 1; i >= 0; i--) {
2086
+ const el = current[i];
2087
+ if (node !== el) {
2088
+ const isParent = getParentNode(el) === parent;
2089
+ if (!inserted && !i) isParent ? replaceNode(parent, node, el) : insertNode(parent, node, marker);
2090
+ else isParent && removeNode(parent, el);
2091
+ } else inserted = true;
2092
+ }
2093
+ } else insertNode(parent, node, marker);
2094
+ return [node];
2095
+ }
2096
+ function appendNodes(parent, array, marker) {
2097
+ for (let i = 0, len = array.length; i < len; i++) insertNode(parent, array[i], marker);
2098
+ }
2099
+ function replaceNode(parent, newNode, oldNode) {
2100
+ insertNode(parent, newNode, oldNode);
2101
+ removeNode(parent, oldNode);
2102
+ }
2103
+ function spreadExpression(node, props, prevProps = {}, skipChildren) {
2104
+ props || (props = {});
2105
+ if (!skipChildren) createRenderEffect(() => prevProps.children = insertExpression(node, props.children, prevProps.children));
2106
+ createRenderEffect(() => props.ref && props.ref(node));
2107
+ createRenderEffect(() => {
2108
+ for (const prop in props) {
2109
+ if (prop === "children" || prop === "ref") continue;
2110
+ const value = props[prop];
2111
+ if (value === prevProps[prop]) continue;
2112
+ setProperty(node, prop, value, prevProps[prop]);
2113
+ prevProps[prop] = value;
2114
+ }
2115
+ });
2116
+ return prevProps;
2117
+ }
2118
+ return {
2119
+ render(code, element) {
2120
+ let disposer;
2121
+ createRoot((dispose) => {
2122
+ disposer = dispose;
2123
+ insert(element, code());
2124
+ });
2125
+ return disposer;
2126
+ },
2127
+ insert,
2128
+ spread(node, accessor, skipChildren) {
2129
+ if (typeof accessor === "function") createRenderEffect((current) => spreadExpression(node, accessor(), current, skipChildren));
2130
+ else spreadExpression(node, accessor, void 0, skipChildren);
2131
+ },
2132
+ createElement,
2133
+ createTextNode,
2134
+ insertNode,
2135
+ setProp(node, name, value, prev) {
2136
+ setProperty(node, name, value, prev);
2137
+ return value;
2138
+ },
2139
+ mergeProps,
2140
+ effect: createRenderEffect,
2141
+ memo: memo$1,
2142
+ createComponent,
2143
+ use(fn, element, arg) {
2144
+ return untrack(() => fn(element, arg));
2145
+ }
2146
+ };
2147
+ }
2148
+ var updateCallback = null;
2149
+ var mutationUpdateCallback = null;
2150
+ var mutationCollector = null;
2151
+ var rootNode = null;
2152
+ var scheduled = false;
2153
+ var warnedMultipleRoots = false;
2154
+ function scheduleUpdate() {
2155
+ if (scheduled) return;
2156
+ scheduled = true;
2157
+ queueMicrotask(() => {
2158
+ scheduled = false;
2159
+ if (!warnedMultipleRoots && rootNode) {
2160
+ if (rootNode.children.filter((c) => c._type !== "slot").length > 1) {
2161
+ warnedMultipleRoots = true;
2162
+ console.error("[uniview] plugin root must be a single element — wrap top-level siblings in one parent element (only the first is rendered)");
2163
+ }
2164
+ }
2165
+ if (mutationCollector && mutationUpdateCallback) {
2166
+ const mutations = mutationCollector.flushCommit();
2167
+ if (mutations.length > 0) mutationUpdateCallback(mutations);
2168
+ }
2169
+ if (updateCallback && rootNode) updateCallback(rootNode);
2170
+ });
2171
+ }
2172
+ function setUpdateCallback(cb) {
2173
+ updateCallback = cb;
2174
+ }
2175
+ function setMutationUpdateCallback(cb) {
2176
+ mutationUpdateCallback = cb;
2177
+ }
2178
+ function setMutationCollector(collector) {
2179
+ mutationCollector = collector;
2180
+ }
2181
+ function getRootNode() {
2182
+ return rootNode;
2183
+ }
2184
+ function setRootNode(node) {
2185
+ rootNode = node;
2186
+ warnedMultipleRoots = false;
2187
+ }
2188
+ function _createElement(tagName) {
2189
+ return {
2190
+ _type: "element",
2191
+ id: generateId(tagName),
2192
+ type: tagName,
2193
+ props: {},
2194
+ children: [],
2195
+ parent: null
2196
+ };
2197
+ }
2198
+ function _createTextNode(value) {
2199
+ return {
2200
+ _type: "text",
2201
+ id: generateId("text"),
2202
+ value: String(value),
2203
+ parent: null
2204
+ };
2205
+ }
2206
+ function _createSlotNode() {
2207
+ return {
2208
+ _type: "slot",
2209
+ id: generateId("slot"),
2210
+ parent: null
2211
+ };
2212
+ }
2213
+ function _isTextNode(node) {
2214
+ return node._type === "text";
2215
+ }
2216
+ function _replaceText(textNode, value) {
2217
+ textNode.value = value;
2218
+ mutationCollector?.collectSetText(textNode);
2219
+ scheduleUpdate();
2220
+ }
2221
+ /**
2222
+ * Remove a node from its current parent's children array (if attached).
2223
+ * Solid's universal renderer reuses insertNode to MOVE existing nodes
2224
+ * (keyed list reorders); DOM insertBefore auto-detaches, an array-based
2225
+ * children model must do it explicitly or reorders duplicate the node.
2226
+ */
2227
+ function _detachFromParent(node) {
2228
+ const prevParent = node.parent;
2229
+ if (!prevParent) return;
2230
+ const index = prevParent.children.indexOf(node);
2231
+ if (index !== -1) prevParent.children.splice(index, 1);
2232
+ }
2233
+ /**
2234
+ * Emit a setRoot mutation seeding the host from the container's real root
2235
+ * element. Solid mounts the plugin into a synthetic container (`rootNode`,
2236
+ * id "root") the host never sees; appendChild/removeChild against that
2237
+ * container referenced the internal "root" id, so incremental hosts could
2238
+ * never seed their tree and the runtime had to resend the whole tree every
2239
+ * flush. Addressing container-level changes as setRoot fixes that — every
2240
+ * later mutation then references real node ids.
2241
+ */
2242
+ function _syncContainerRoot() {
2243
+ if (!mutationCollector || !rootNode) return;
2244
+ const root = rootNode.children.find((c) => c._type !== "slot") ?? null;
2245
+ mutationCollector.collectSetRoot(root ?? null);
2246
+ }
2247
+ function _insertNode(parent, node, anchor) {
2248
+ _detachFromParent(node);
2249
+ node.parent = parent;
2250
+ const isContainerInsert = parent === rootNode;
2251
+ if (anchor) {
2252
+ const anchorIndex = parent.children.indexOf(anchor);
2253
+ if (anchorIndex !== -1) {
2254
+ parent.children.splice(anchorIndex, 0, node);
2255
+ if (!isContainerInsert) mutationCollector?.collectInsertBefore(parent, node, anchor);
2256
+ } else {
2257
+ parent.children.push(node);
2258
+ if (!isContainerInsert) mutationCollector?.collectAppendChild(parent, node);
2259
+ }
2260
+ } else {
2261
+ parent.children.push(node);
2262
+ if (!isContainerInsert) mutationCollector?.collectAppendChild(parent, node);
2263
+ }
2264
+ if (isContainerInsert) _syncContainerRoot();
2265
+ scheduleUpdate();
2266
+ }
2267
+ function _removeNode(parent, node) {
2268
+ const index = parent.children.indexOf(node);
2269
+ const wasContainerChild = parent === rootNode;
2270
+ if (index !== -1) {
2271
+ parent.children.splice(index, 1);
2272
+ if (wasContainerChild) {
2273
+ mutationCollector?.cleanupHandlers(node);
2274
+ _syncContainerRoot();
2275
+ } else mutationCollector?.collectRemoveChild(parent, node);
2276
+ }
2277
+ node.parent = null;
2278
+ scheduleUpdate();
2279
+ }
2280
+ function _setProperty(node, name, value, _prev) {
2281
+ if (value === void 0) delete node.props[name];
2282
+ else node.props[name] = value;
2283
+ mutationCollector?.collectSetProps(node);
2284
+ scheduleUpdate();
2285
+ }
2286
+ function _getParentNode(childNode) {
2287
+ return childNode.parent ?? void 0;
2288
+ }
2289
+ function _getFirstChild(node) {
2290
+ return node.children[0];
2291
+ }
2292
+ function _getNextSibling(node) {
2293
+ const parent = node.parent;
2294
+ if (!parent) return void 0;
2295
+ const index = parent.children.indexOf(node);
2296
+ if (index === -1 || index >= parent.children.length - 1) return void 0;
2297
+ return parent.children[index + 1];
2298
+ }
2299
+ var { render, effect, memo, createComponent: createComponent$1, createElement, createTextNode, insertNode, insert, spread, setProp, mergeProps: mergeProps$1, use } = createRenderer({
2300
+ createElement: _createElement,
2301
+ createTextNode: _createTextNode,
2302
+ createSlotNode: _createSlotNode,
2303
+ isTextNode: _isTextNode,
2304
+ replaceText: _replaceText,
2305
+ insertNode: _insertNode,
2306
+ removeNode: _removeNode,
2307
+ setProperty: _setProperty,
2308
+ getParentNode: _getParentNode,
2309
+ getFirstChild: _getFirstChild,
2310
+ getNextSibling: _getNextSibling
2311
+ });
2312
+ /**
2313
+ * Registry mapping stable handler ids to plugin-side functions.
2314
+ *
2315
+ * Handler ids are deterministic — `${nodeId}:${propName}` — so re-serializing
2316
+ * a node OVERWRITES its entries instead of growing the registry, and an
2317
+ * event RPC that arrives after a re-render executes that node's latest
2318
+ * handler (correct semantics) instead of a stale or wrong one. The previous
2319
+ * counter-based ids were reset by clear() on every full update, so a late
2320
+ * event could execute a DIFFERENT node's handler that reused the id.
2321
+ *
2322
+ * Ownership is tracked per node: `syncNode` replaces a node's full handler
2323
+ * set (dropping props that disappeared), `releaseNode` frees everything a
2324
+ * removed node owned. Full-tree serialization brackets its walk with
2325
+ * `beginSweep`/`endSweep` to release nodes that are no longer in the tree.
2326
+ */
2327
+ var HandlerRegistry = class {
2328
+ handlers = /* @__PURE__ */ new Map();
2329
+ nodeHandlers = /* @__PURE__ */ new Map();
2330
+ sweepSeen = null;
2331
+ /**
2332
+ * Replace the handler set owned by a node. Ids present before but not in
2333
+ * `next` are released; ids in `next` are (re-)registered in place.
2334
+ */
2335
+ syncNode(nodeId, next) {
2336
+ this.sweepSeen?.add(nodeId);
2337
+ const prev = this.nodeHandlers.get(nodeId);
2338
+ if (prev) {
2339
+ for (const id of prev) if (!next.has(id)) this.handlers.delete(id);
2340
+ }
2341
+ if (next.size === 0) {
2342
+ this.nodeHandlers.delete(nodeId);
2343
+ return;
2344
+ }
2345
+ const ids = /* @__PURE__ */ new Set();
2346
+ for (const [id, handler] of next) {
2347
+ this.handlers.set(id, handler);
2348
+ ids.add(id);
2349
+ }
2350
+ this.nodeHandlers.set(nodeId, ids);
2351
+ }
2352
+ /** Release every handler owned by a node (e.g. on removeChild). */
2353
+ releaseNode(nodeId) {
2354
+ const ids = this.nodeHandlers.get(nodeId);
2355
+ if (!ids) return;
2356
+ for (const id of ids) this.handlers.delete(id);
2357
+ this.nodeHandlers.delete(nodeId);
2358
+ }
2359
+ /**
2360
+ * Start tracking which nodes a full-tree serialization touches.
2361
+ * Nodes not seen by the matching `endSweep` are released — they left
2362
+ * the tree without an explicit removeChild (full update mode).
2363
+ */
2364
+ beginSweep() {
2365
+ this.sweepSeen = /* @__PURE__ */ new Set();
2366
+ }
2367
+ endSweep() {
2368
+ const seen = this.sweepSeen;
2369
+ this.sweepSeen = null;
2370
+ if (!seen) return;
2371
+ for (const nodeId of [...this.nodeHandlers.keys()]) if (!seen.has(nodeId)) this.releaseNode(nodeId);
2372
+ }
2373
+ async execute(handlerId, ...args) {
2374
+ const handler = this.handlers.get(handlerId);
2375
+ if (!handler) {
2376
+ console.warn(`[uniview] executeHandler: no handler registered for "${handlerId}" (node unmounted or event arrived after removal)`);
2377
+ return;
2378
+ }
2379
+ const result = handler(...args);
2380
+ if (result instanceof Promise) return await result;
2381
+ return result;
2382
+ }
2383
+ has(handlerId) {
2384
+ return this.handlers.has(handlerId);
2385
+ }
2386
+ clear() {
2387
+ this.handlers.clear();
2388
+ this.nodeHandlers.clear();
2389
+ this.sweepSeen = null;
2390
+ }
2391
+ get size() {
2392
+ return this.handlers.size;
2393
+ }
2394
+ };
2395
+ /**
2396
+ * The Style IR travels as a derived `_style` prop, alongside the untouched
2397
+ * `className` / `style` the author wrote. A native host has no CSS engine and
2398
+ * reads `_style`; web hosts ignore it and render `className` themselves.
2399
+ *
2400
+ * This is resolved by the shared `@uniview/style` helper — the SAME one the React
2401
+ * renderer uses — on purpose: a Solid plugin rendered through the native bridge
2402
+ * must produce the identical IR a React plugin would, or the framework-agnostic
2403
+ * contract is a lie. (It was: this serializer used to forward `className`
2404
+ * untouched, so every Solid plugin lost its Tailwind styling on the native side.)
2405
+ */
2406
+ var STYLE_IR_PROP = "_style";
2407
+ /**
2408
+ * Serialize props for a node, converting event handlers to handler IDs
2409
+ * and filtering out non-serializable values.
2410
+ *
2411
+ * Any `on[A-Z]*` function prop becomes a handler id (matching the react
2412
+ * renderer — custom app-level handlers like onSearchTextChange included,
2413
+ * not just the DOM event whitelist). Do not narrow this to `EVENT_PROPS`:
2414
+ * that list is only the DOM-style subset hosts auto-wire to real input events,
2415
+ * NOT the closed set of handler props a host may bind. AppKit binds
2416
+ * `_onSelectHandlerId` for menu items and `_onActionHandlerId` /
2417
+ * `_onSearchTextChangeHandlerId` / `_onSelectionChangeHandlerId` for the
2418
+ * Raycast-style surfaces, and the Svelte host passes unrecognized handler id
2419
+ * props through for registered components to relay. `extractEventName`
2420
+ * returning null means "not a DOM event", not "nobody binds it".
2421
+ *
2422
+ * Handler ids are deterministic (`${nodeId}:${propName}`) and the node's full
2423
+ * handler set is synced into the registry in one shot, so repeated
2424
+ * serialization never grows it.
2425
+ *
2426
+ * This is shared between full-tree serialization and mutation-based updates.
2427
+ */
2428
+ var warnedNestedFunctionProps = /* @__PURE__ */ new Set();
2429
+ function serializeProps(props, registry, nodeId) {
2430
+ const serializedProps = {};
2431
+ const handlers = /* @__PURE__ */ new Map();
2432
+ for (const [key, value] of Object.entries(props)) {
2433
+ if (key === "children" || key === "key" || key === "ref") continue;
2434
+ if (typeof value === "function") {
2435
+ if (/^on[A-Z]/.test(key)) {
2436
+ const handlerId = `${nodeId}:${key}`;
2437
+ handlers.set(handlerId, value);
2438
+ serializedProps[`_${key}HandlerId`] = handlerId;
2439
+ }
2440
+ continue;
2441
+ } else if (value === void 0) continue;
2442
+ else if (value === null) serializedProps[key] = null;
2443
+ else try {
2444
+ let hasNestedFunction = false;
2445
+ JSON.stringify(value, (_k, v) => {
2446
+ if (typeof v === "function") {
2447
+ hasNestedFunction = true;
2448
+ return;
2449
+ }
2450
+ return v;
2451
+ });
2452
+ if (hasNestedFunction && !warnedNestedFunctionProps.has(key)) {
2453
+ warnedNestedFunctionProps.add(key);
2454
+ console.warn(`[uniview] prop "${key}" contains nested function(s) that will NOT become event handlers — only top-level on[A-Z]* function props are converted to handler ids. Pass callbacks as top-level props or model the data as child elements.`);
2455
+ }
2456
+ serializedProps[key] = value;
2457
+ } catch {
2458
+ continue;
2459
+ }
2460
+ }
2461
+ const ir = resolveStyleIR(props);
2462
+ if (ir !== null) serializedProps[STYLE_IR_PROP] = ir;
2463
+ registry.syncNode(nodeId, handlers);
2464
+ return serializedProps;
2465
+ }
2466
+ function isTextNode$1(node) {
2467
+ return node._type === "text";
2468
+ }
2469
+ function isSlotNode$1(node) {
2470
+ return node._type === "slot";
2471
+ }
2472
+ function isElementNode$1(node) {
2473
+ return node._type === "element";
2474
+ }
2475
+ /**
2476
+ * Serialize a full tree from the root. Brackets the walk with a registry
2477
+ * sweep so handlers owned by nodes that left the tree are released —
2478
+ * without this, full update mode leaks handlers for every removed node.
2479
+ */
2480
+ function serializeTree(node, registry) {
2481
+ registry.beginSweep();
2482
+ try {
2483
+ return serializeNode(node, registry);
2484
+ } finally {
2485
+ registry.endSweep();
2486
+ }
2487
+ }
2488
+ function serializeNode(node, registry) {
2489
+ if (node == null) return null;
2490
+ if (isTextNode$1(node)) return {
2491
+ id: node.id,
2492
+ type: TEXT_NODE_TYPE,
2493
+ props: {},
2494
+ children: [],
2495
+ text: node.value
2496
+ };
2497
+ if (isSlotNode$1(node)) return null;
2498
+ if (!isElementNode$1(node)) return null;
2499
+ const serializedChildren = [];
2500
+ for (const child of node.children) {
2501
+ const serializedChild = serializeNode(child, registry);
2502
+ if (serializedChild !== null) serializedChildren.push(serializedChild);
2503
+ }
2504
+ return {
2505
+ type: node.type,
2506
+ props: serializeProps(node.props, registry, node.id),
2507
+ children: serializedChildren,
2508
+ id: node.id
2509
+ };
2510
+ }
2511
+ //#endregion
2512
+ //#region ../../node_modules/@uniview/tui-solid/dist/index.mjs
2513
+ function isElement(child) {
2514
+ return typeof child !== "string";
2515
+ }
2516
+ /**
2517
+ * Applies protocol {@link Mutation}s to a UINode tree, maintaining an id index
2518
+ * and parent map so mutations address nodes in O(1). Moves (append/insert of an
2519
+ * already-present node) detach the node from its old parent first, per the
2520
+ * protocol contract.
2521
+ */
2522
+ var MutableTree = class {
2523
+ root = null;
2524
+ nodes = /* @__PURE__ */ new Map();
2525
+ parentOf = /* @__PURE__ */ new Map();
2526
+ getRoot() {
2527
+ return this.root;
2528
+ }
2529
+ getNode(id) {
2530
+ return this.nodes.get(id);
2531
+ }
2532
+ /** The id of a node's parent, or undefined for the root/unknown nodes. */
2533
+ parentId(id) {
2534
+ return this.parentOf.get(id);
2535
+ }
2536
+ applyBatch(mutations) {
2537
+ for (const mutation of mutations) this.apply(mutation);
2538
+ }
2539
+ apply(mutation) {
2540
+ switch (mutation.type) {
2541
+ case "setRoot":
2542
+ if (this.root) this.unindex(this.root);
2543
+ this.root = mutation.node;
2544
+ if (mutation.node) this.index(mutation.node, null);
2545
+ return;
2546
+ case "appendChild": {
2547
+ const parent = this.nodes.get(mutation.parentId);
2548
+ if (!parent) return;
2549
+ this.ensureDetached(mutation.node.id);
2550
+ parent.children.push(mutation.node);
2551
+ this.index(mutation.node, parent.id);
2552
+ return;
2553
+ }
2554
+ case "insertBefore": {
2555
+ const parent = this.nodes.get(mutation.parentId);
2556
+ if (!parent) return;
2557
+ this.ensureDetached(mutation.node.id);
2558
+ const at = parent.children.findIndex((c) => isElement(c) && c.id === mutation.beforeId);
2559
+ parent.children.splice(at < 0 ? parent.children.length : at, 0, mutation.node);
2560
+ this.index(mutation.node, parent.id);
2561
+ return;
2562
+ }
2563
+ case "removeChild": {
2564
+ const parent = this.nodes.get(mutation.parentId);
2565
+ if (!parent) return;
2566
+ const at = parent.children.findIndex((c) => isElement(c) && c.id === mutation.nodeId);
2567
+ if (at < 0) return;
2568
+ const [removed] = parent.children.splice(at, 1);
2569
+ if (removed && isElement(removed)) this.unindex(removed);
2570
+ return;
2571
+ }
2572
+ case "setText": {
2573
+ const node = this.nodes.get(mutation.nodeId);
2574
+ if (node) node.text = mutation.text;
2575
+ return;
2576
+ }
2577
+ case "setProps": {
2578
+ const node = this.nodes.get(mutation.nodeId);
2579
+ if (node) node.props = mutation.props;
2580
+ return;
2581
+ }
2582
+ }
2583
+ }
2584
+ index(node, parentId) {
2585
+ this.nodes.set(node.id, node);
2586
+ if (parentId !== null) this.parentOf.set(node.id, parentId);
2587
+ else this.parentOf.delete(node.id);
2588
+ for (const child of node.children) if (isElement(child)) this.index(child, node.id);
2589
+ }
2590
+ unindex(node) {
2591
+ this.nodes.delete(node.id);
2592
+ this.parentOf.delete(node.id);
2593
+ for (const child of node.children) if (isElement(child)) this.unindex(child);
2594
+ }
2595
+ /** Detach an existing node from its parent and drop its old index entries. */
2596
+ ensureDetached(id) {
2597
+ const existing = this.nodes.get(id);
2598
+ if (!existing) return;
2599
+ const parentId = this.parentOf.get(id);
2600
+ const parent = parentId !== void 0 ? this.nodes.get(parentId) : void 0;
2601
+ if (parent) {
2602
+ const at = parent.children.findIndex((c) => isElement(c) && c.id === id);
2603
+ if (at >= 0) parent.children.splice(at, 1);
2604
+ }
2605
+ this.unindex(existing);
2606
+ }
2607
+ };
2608
+ /** Element types treated as inline text (their text children are flattened). */
2609
+ var TEXT_TYPES$1 = /* @__PURE__ */ new Set([
2610
+ "text",
2611
+ "span",
2612
+ "p",
2613
+ "strong",
2614
+ "em",
2615
+ "code",
2616
+ "label"
2617
+ ]);
2618
+ /** Layout props copied straight through to {@link TuiStyle}. */
2619
+ var STYLE_KEYS = [
2620
+ "display",
2621
+ "position",
2622
+ "top",
2623
+ "right",
2624
+ "bottom",
2625
+ "left",
2626
+ "flexDirection",
2627
+ "flexGrow",
2628
+ "flexShrink",
2629
+ "flexBasis",
2630
+ "justifyContent",
2631
+ "alignItems",
2632
+ "alignSelf",
2633
+ "width",
2634
+ "height",
2635
+ "minWidth",
2636
+ "maxWidth",
2637
+ "minHeight",
2638
+ "maxHeight",
2639
+ "margin",
2640
+ "padding",
2641
+ "gap",
2642
+ "rowGap",
2643
+ "columnGap",
2644
+ "border",
2645
+ "overflow",
2646
+ "zIndex"
2647
+ ];
2648
+ var TEXT_STYLE_FLAGS = [
2649
+ "bold",
2650
+ "dim",
2651
+ "italic",
2652
+ "underline",
2653
+ "strikethrough",
2654
+ "inverse",
2655
+ "blink",
2656
+ "hidden"
2657
+ ];
2658
+ function propsToStyle(props) {
2659
+ const style = {};
2660
+ for (const key of STYLE_KEYS) {
2661
+ const value = props[key];
2662
+ if (value !== void 0) style[key] = value;
2663
+ }
2664
+ return style;
2665
+ }
2666
+ /** Accept a color prop as a named/CSS string or an `{ r, g, b }` triple. */
2667
+ function asColor(value) {
2668
+ if (typeof value === "string") return value;
2669
+ if (value !== null && typeof value === "object" && !Array.isArray(value)) {
2670
+ const o = value;
2671
+ if (typeof o.r === "number" && typeof o.g === "number" && typeof o.b === "number") return {
2672
+ r: o.r,
2673
+ g: o.g,
2674
+ b: o.b
2675
+ };
2676
+ }
2677
+ }
2678
+ function asAlign(value) {
2679
+ return value === "left" || value === "center" || value === "right" ? value : void 0;
2680
+ }
2681
+ function propsToTextStyle(props) {
2682
+ const style = {};
2683
+ const fg = asColor(props.color);
2684
+ const bg = asColor(props.backgroundColor);
2685
+ if (fg !== void 0) style.fg = fg;
2686
+ if (bg !== void 0) style.bg = bg;
2687
+ for (const flag of TEXT_STYLE_FLAGS) if (props[flag] === true) style[flag] = true;
2688
+ return style;
2689
+ }
2690
+ /** Coerce a JSON `spans` prop into {@link StyledSpan}s, dropping malformed entries. */
2691
+ function parseSpans(value) {
2692
+ if (!Array.isArray(value)) return [];
2693
+ const spans = [];
2694
+ for (const item of value) {
2695
+ if (item === null || typeof item !== "object" || Array.isArray(item)) continue;
2696
+ const record = item;
2697
+ if (typeof record.text !== "string") continue;
2698
+ const span = { text: record.text };
2699
+ const style = record.style;
2700
+ if (style !== null && typeof style === "object" && !Array.isArray(style)) span.style = style;
2701
+ spans.push(span);
2702
+ }
2703
+ return spans;
2704
+ }
2705
+ /**
2706
+ * Flatten a text-type node's children into one string. `textContent` only
2707
+ * handles the two leaf shapes (a bare string, or an explicit text node); a
2708
+ * nested UINode (e.g. `<text><strong>OK</strong></text>`) falls through and
2709
+ * must be descended into recursively, or its text silently disappears from
2710
+ * the visual render while `semantics.ts`'s `collectText` (which already
2711
+ * recurses) still finds it — a query/render mismatch, not just missing text.
2712
+ */
2713
+ function joinText(node) {
2714
+ let text = "";
2715
+ for (const child of node.children) {
2716
+ if (typeof child === "string") {
2717
+ text += child;
2718
+ continue;
2719
+ }
2720
+ const content = textContent(child);
2721
+ text += content !== null ? content : joinText(child);
2722
+ }
2723
+ return text;
2724
+ }
2725
+ /**
2726
+ * Convert a protocol {@link UINode} (or bare string child) into a
2727
+ * {@link RenderNode} for @uniview/tui-core. Text elements flatten their text
2728
+ * children; box elements recurse. The node id is preserved so painted cells map
2729
+ * back to plugin nodes for hit-testing and event dispatch.
2730
+ *
2731
+ * `focusedId` resolves the text-field caret host-side (the plan's principle 3:
2732
+ * focus is local, never streamed to the plugin). A `<text caret>` cell renders
2733
+ * as an inverse, terminal-blinking block **only** while its enclosing textbox
2734
+ * is the focused node, and as a plain cell otherwise — so exactly one caret
2735
+ * blinks, on the field the user is actually editing.
2736
+ */
2737
+ function uinodeToRenderNode(node, focusedId = null) {
2738
+ return convert(node, focusedId, false);
2739
+ }
2740
+ function convert(node, focusedId, inFocused) {
2741
+ if (typeof node === "string") return {
2742
+ type: "text",
2743
+ text: node
2744
+ };
2745
+ if (node.type === "#text") return {
2746
+ type: "text",
2747
+ text: node.text ?? ""
2748
+ };
2749
+ const style = propsToStyle(node.props);
2750
+ if (node.type === "richtext") {
2751
+ const rendered = {
2752
+ type: "richtext",
2753
+ id: node.id,
2754
+ style,
2755
+ spans: parseSpans(node.props.spans)
2756
+ };
2757
+ if (typeof node.props.selectable === "boolean") rendered.selectable = node.props.selectable;
2758
+ const bg = asColor(node.props.backgroundColor);
2759
+ if (bg !== void 0) rendered.background = bg;
2760
+ return rendered;
2761
+ }
2762
+ if (TEXT_TYPES$1.has(node.type)) {
2763
+ const textStyle = propsToTextStyle(node.props);
2764
+ if (node.props.caret === true && inFocused) {
2765
+ textStyle.inverse = true;
2766
+ textStyle.blink = true;
2767
+ }
2768
+ const rendered = {
2769
+ type: "text",
2770
+ id: node.id,
2771
+ text: joinText(node),
2772
+ textStyle,
2773
+ style
2774
+ };
2775
+ if (typeof node.props.selectable === "boolean") rendered.selectable = node.props.selectable;
2776
+ return rendered;
2777
+ }
2778
+ const childInFocused = inFocused || focusedId !== null && node.id === focusedId;
2779
+ const rendered = {
2780
+ type: node.type,
2781
+ id: node.id,
2782
+ style,
2783
+ children: node.children.map((child) => convert(child, focusedId, childInFocused)).filter((c) => c !== null)
2784
+ };
2785
+ const bg = asColor(node.props.backgroundColor);
2786
+ if (bg !== void 0) rendered.background = bg;
2787
+ if (typeof node.props.title === "string") rendered.title = node.props.title;
2788
+ const titleAlign = asAlign(node.props.titleAlign);
2789
+ if (titleAlign) rendered.titleAlign = titleAlign;
2790
+ if (typeof node.props.footer === "string") rendered.footer = node.props.footer;
2791
+ const footerAlign = asAlign(node.props.footerAlign);
2792
+ if (footerAlign) rendered.footerAlign = footerAlign;
2793
+ const borderColor = asColor(node.props.borderColor);
2794
+ if (borderColor !== void 0) rendered.borderStyle = { fg: borderColor };
2795
+ return rendered;
2796
+ }
2797
+ /**
2798
+ * Walk a UINode tree and collect the handler ids attached to each node, keyed
2799
+ * by node id, so the host can dispatch events without re-parsing props.
2800
+ */
2801
+ function extractHandlers(root) {
2802
+ const handlers = /* @__PURE__ */ new Map();
2803
+ if (!root) return handlers;
2804
+ const visit = (node) => {
2805
+ let entry;
2806
+ for (const [key, value] of Object.entries(node.props)) {
2807
+ if (!isHandlerIdProp(key) || typeof value !== "string") continue;
2808
+ const event = extractEventName(key);
2809
+ if (!event || !EVENT_PROPS.includes(event)) continue;
2810
+ (entry ??= {})[event] = value;
2811
+ }
2812
+ if (entry) handlers.set(node.id, entry);
2813
+ for (const child of node.children) if (typeof child !== "string") visit(child);
2814
+ };
2815
+ visit(root);
2816
+ return handlers;
2817
+ }
2818
+ var TEXT_TYPES = /* @__PURE__ */ new Set([
2819
+ "#text",
2820
+ "text",
2821
+ "span",
2822
+ "p",
2823
+ "strong",
2824
+ "em",
2825
+ "code",
2826
+ "label"
2827
+ ]);
2828
+ var TEXTBOX_TYPES = /* @__PURE__ */ new Set([
2829
+ "input",
2830
+ "textarea",
2831
+ "textbox"
2832
+ ]);
2833
+ function hasClickHandler(node) {
2834
+ return Object.keys(node.props).some((key) => isHandlerIdProp(key) && key.includes("onClick"));
2835
+ }
2836
+ function inferRole(node) {
2837
+ const explicit = node.props.role;
2838
+ if (typeof explicit === "string") return explicit;
2839
+ if (node.type === "checkbox" || node.type === "switch") return "checkbox";
2840
+ if (node.type === "tab") return "tab";
2841
+ if (TEXTBOX_TYPES.has(node.type)) return "textbox";
2842
+ if (node.type === "button" || hasClickHandler(node)) return "button";
2843
+ if (TEXT_TYPES.has(node.type)) return "text";
2844
+ return "group";
2845
+ }
2846
+ /** Flattened text content of a node's subtree. */
2847
+ function collectText(node) {
2848
+ if (node.type === "#text") return node.text ?? "";
2849
+ let out = "";
2850
+ for (const child of node.children) {
2851
+ const direct = textContent(child);
2852
+ out += direct !== null ? direct : typeof child === "string" ? child : collectText(child);
2853
+ }
2854
+ return out;
2855
+ }
2856
+ function accessibleName(node, text) {
2857
+ const candidates = [
2858
+ node.props["aria-label"],
2859
+ node.props.name,
2860
+ node.props.label
2861
+ ];
2862
+ for (const value of candidates) if (typeof value === "string" && value.length > 0) return value;
2863
+ return text.length > 0 ? text : void 0;
2864
+ }
2865
+ /** Derive the semantic (accessibility) tree from a UINode tree. */
2866
+ function buildSemanticTree(node) {
2867
+ if (!node) return null;
2868
+ const role = inferRole(node);
2869
+ const text = collectText(node);
2870
+ const semantic = {
2871
+ id: node.id,
2872
+ role,
2873
+ children: node.children.filter((c) => typeof c !== "string" && c.type !== "#text").map((c) => buildSemanticTree(c)).filter((c) => c !== null)
2874
+ };
2875
+ if (role === "text") semantic.text = text;
2876
+ else {
2877
+ const name = accessibleName(node, role === "group" ? "" : text);
2878
+ if (name !== void 0) semantic.name = name;
2879
+ }
2880
+ if (role === "textbox" && typeof node.props.value === "string") semantic.value = node.props.value;
2881
+ if (node.props.disabled === true) semantic.disabled = true;
2882
+ if (node.props.checked === true) semantic.checked = true;
2883
+ if (node.props.selected === true) semantic.selected = true;
2884
+ return semantic;
2885
+ }
2886
+ function matches(value, matcher) {
2887
+ if (value === void 0) return false;
2888
+ return typeof matcher === "string" ? value === matcher : matcher.test(value);
2889
+ }
2890
+ function* walk$1(node) {
2891
+ if (!node) return;
2892
+ yield node;
2893
+ for (const child of node.children) yield* walk$1(child);
2894
+ }
2895
+ /** First node matching `role` (and optional accessible name). */
2896
+ function queryByRole(tree, role, query = {}) {
2897
+ for (const node of walk$1(tree)) {
2898
+ if (node.role !== role) continue;
2899
+ if (query.name !== void 0 && !matches(node.name, query.name)) continue;
2900
+ return node;
2901
+ }
2902
+ return null;
2903
+ }
2904
+ /** First node whose text or name matches. */
2905
+ function queryByText(tree, matcher) {
2906
+ for (const node of walk$1(tree)) if (matches(node.text, matcher) || matches(node.name, matcher)) return node;
2907
+ return null;
2908
+ }
2909
+ /** Node with the given id. */
2910
+ function queryById(tree, id) {
2911
+ for (const node of walk$1(tree)) if (node.id === id) return node;
2912
+ return null;
2913
+ }
2914
+ /**
2915
+ * A terminal host for the Uniview protocol. It consumes `setRoot` and mutation
2916
+ * batches into a {@link MutableTree}, converts the tree to a tui-core render
2917
+ * tree, drives a {@link TuiRenderer}, and dispatches input back to plugin
2918
+ * handlers by id — the plan's "TUI becomes a Uniview host".
2919
+ */
2920
+ var TuiHost = class {
2921
+ renderer;
2922
+ tree = new MutableTree();
2923
+ onInvokeHandler;
2924
+ handlers = /* @__PURE__ */ new Map();
2925
+ invocations = [];
2926
+ committed;
2927
+ staticCounts = /* @__PURE__ */ new Map();
2928
+ focusedId = null;
2929
+ lifecycle = "active";
2930
+ /** Whether host mutations and event dispatch remain available. */
2931
+ get isActive() {
2932
+ if (this.lifecycle === "active" && !this.renderer.isActive) this.lifecycle = "destroying";
2933
+ return this.lifecycle === "active";
2934
+ }
2935
+ constructor(options) {
2936
+ this.onInvokeHandler = options.onInvokeHandler;
2937
+ this.committed = options.committed;
2938
+ this.renderer = new TuiRenderer({
2939
+ surface: options.surface,
2940
+ size: options.size,
2941
+ styles: options.styles ?? new StyleTable(),
2942
+ schedule: options.schedule,
2943
+ layoutEngine: options.layoutEngine,
2944
+ selection: options.selection
2945
+ });
2946
+ }
2947
+ /** Replace the whole tree and render. */
2948
+ setRoot(node) {
2949
+ this.assertActive("set a root");
2950
+ this.tree.apply({
2951
+ type: "setRoot",
2952
+ node
2953
+ });
2954
+ this.render();
2955
+ }
2956
+ /** Apply a mutation batch and render. */
2957
+ applyBatch(mutations) {
2958
+ this.assertActive("apply mutations");
2959
+ this.tree.applyBatch(mutations);
2960
+ this.render();
2961
+ }
2962
+ /** Convert the current tree and paint a frame. */
2963
+ render() {
2964
+ this.assertActive("render");
2965
+ try {
2966
+ const root = this.tree.getRoot();
2967
+ this.handlers = extractHandlers(root);
2968
+ this.flushStatic(root);
2969
+ this.renderer.setRoot(root ? uinodeToRenderNode(root, this.focusedId) : null);
2970
+ this.renderer.flush();
2971
+ } catch (error) {
2972
+ if (!this.renderer.isActive) this.lifecycle = "destroying";
2973
+ throw error;
2974
+ }
2975
+ }
2976
+ /**
2977
+ * Record which node currently holds focus and repaint if it changed. The
2978
+ * {@link InputRouter} calls this after every focus move so the text-field
2979
+ * caret (resolved in {@link uinodeToRenderNode}) tracks focus without a
2980
+ * plugin re-render — focus stays host-local (the plan's principle 3).
2981
+ */
2982
+ setFocusedId(id) {
2983
+ this.assertActive("set focus");
2984
+ if (id === this.focusedId) return;
2985
+ this.focusedId = id;
2986
+ this.render();
2987
+ }
2988
+ /** Imperatively append finalized lines to the committed-output channel (direct mode). */
2989
+ commitStatic(lines) {
2990
+ this.assertActive("commit static output");
2991
+ this.committed?.commit(lines);
2992
+ }
2993
+ /**
2994
+ * Commit the `staticLines` of every `role="log"` node, deduped per node id —
2995
+ * only lines beyond that node's high-water mark are written, so appending
2996
+ * items re-commits only the new ones and a plain re-render writes nothing.
2997
+ */
2998
+ flushStatic(root) {
2999
+ const committed = this.committed;
3000
+ if (!committed || !root) return;
3001
+ const visit = (node) => {
3002
+ const lines = node.props.staticLines;
3003
+ if (Array.isArray(lines)) {
3004
+ const already = this.staticCounts.get(node.id) ?? 0;
3005
+ if (lines.length > already) {
3006
+ const fresh = [];
3007
+ for (let i = already; i < lines.length; i += 1) {
3008
+ const value = lines[i];
3009
+ if (typeof value === "string") fresh.push([{ text: value }]);
3010
+ }
3011
+ committed.commit(fresh);
3012
+ this.staticCounts.set(node.id, lines.length);
3013
+ }
3014
+ }
3015
+ for (const child of node.children) if (typeof child !== "string") visit(child);
3016
+ };
3017
+ visit(root);
3018
+ }
3019
+ /** Node ids (in tree order) that have a handler for `event`. */
3020
+ eventTargets(event) {
3021
+ const ids = [];
3022
+ for (const [id, map] of this.handlers) if (map[event] !== void 0) ids.push(id);
3023
+ return ids;
3024
+ }
3025
+ /** True when `nodeId`'s UINode carries `disabled: true`. */
3026
+ isDisabled(nodeId) {
3027
+ return this.tree.getNode(nodeId)?.props.disabled === true;
3028
+ }
3029
+ /**
3030
+ * Focusable nodes in tree order — those that can be clicked or that edit
3031
+ * text. `textbox` is true when the node accepts text input (has onChange).
3032
+ * Disabled nodes are excluded, matching how HTML `disabled` removes an
3033
+ * element from the tab order rather than merely styling it.
3034
+ */
3035
+ focusableTargets() {
3036
+ const targets = [];
3037
+ for (const [id, map] of this.handlers) {
3038
+ if (this.isDisabled(id)) continue;
3039
+ const textbox = map.onChange !== void 0;
3040
+ if (map.onClick !== void 0 || map.onKeyDown !== void 0 || textbox) {
3041
+ const autoFocus = this.tree.getNode(id)?.props.autoFocus === true;
3042
+ targets.push({
3043
+ id,
3044
+ textbox,
3045
+ autoFocus
3046
+ });
3047
+ }
3048
+ }
3049
+ return targets;
3050
+ }
3051
+ /** The plugin node id owning the cell at `(x, y)`, or null. */
3052
+ nodeAt(x, y) {
3053
+ const frame = this.renderer.currentFrame;
3054
+ if (!frame) return null;
3055
+ return hitTest(frame, this.renderer.owners, x, y);
3056
+ }
3057
+ /**
3058
+ * Fire an event on a node; returns whether a handler was invoked. A disabled
3059
+ * node never fires — this is the single choke point every input path
3060
+ * (click, key, automation) routes through, so gating here is what actually
3061
+ * makes `disabled` mean something rather than a prop `semantics.ts` reports
3062
+ * but nothing enforces.
3063
+ */
3064
+ fireEvent(nodeId, event, payload) {
3065
+ this.assertActive("dispatch an event");
3066
+ if (this.isDisabled(nodeId)) return false;
3067
+ const handlerId = this.handlers.get(nodeId)?.[event];
3068
+ if (handlerId === void 0) return false;
3069
+ this.invocations.push({
3070
+ id: handlerId,
3071
+ payload
3072
+ });
3073
+ this.onInvokeHandler?.(handlerId, payload);
3074
+ return true;
3075
+ }
3076
+ /** The handler ids invoked so far (a command trace for automation). */
3077
+ commands() {
3078
+ return this.invocations;
3079
+ }
3080
+ /** Clear the recorded command trace. */
3081
+ resetCommands() {
3082
+ this.assertActive("reset commands");
3083
+ this.invocations.length = 0;
3084
+ }
3085
+ /**
3086
+ * The nearest node at or above `startId` that has a handler for any of
3087
+ * `events` — used to resolve hover/wheel targets by bubbling from the node
3088
+ * under the pointer. Returns null when none is found.
3089
+ */
3090
+ nearestTarget(startId, events) {
3091
+ let id = startId;
3092
+ while (id) {
3093
+ const map = this.handlers.get(id);
3094
+ if (map && events.some((e) => map[e] !== void 0)) return id;
3095
+ id = this.tree.parentId(id);
3096
+ }
3097
+ return null;
3098
+ }
3099
+ /**
3100
+ * The nearest node at or above `startId` that can take focus. A pointer hit
3101
+ * usually lands on a leaf (the label inside a row), which is not focusable
3102
+ * itself — focusing it would be a silent no-op, leaving focus stranded on
3103
+ * whatever was focused before.
3104
+ */
3105
+ nearestFocusable(startId) {
3106
+ const focusable = new Set(this.focusableTargets().map((t) => t.id));
3107
+ let id = startId;
3108
+ while (id) {
3109
+ if (focusable.has(id)) return id;
3110
+ id = this.tree.parentId(id);
3111
+ }
3112
+ return null;
3113
+ }
3114
+ /**
3115
+ * Fire an event starting at `startId` and bubbling up ancestors until a
3116
+ * handler runs (like DOM bubbling). Returns whether any handler was invoked.
3117
+ */
3118
+ fireEventBubbling(startId, event, payload) {
3119
+ this.assertActive("dispatch a bubbling event");
3120
+ let id = startId;
3121
+ while (id) {
3122
+ if (this.fireEvent(id, event, payload)) return true;
3123
+ id = this.tree.parentId(id);
3124
+ }
3125
+ return false;
3126
+ }
3127
+ /** The accessibility tree derived from the current UINode tree. */
3128
+ semanticTree() {
3129
+ return buildSemanticTree(this.tree.getRoot());
3130
+ }
3131
+ queryByRole(role, query) {
3132
+ return queryByRole(this.semanticTree(), role, query);
3133
+ }
3134
+ queryByText(matcher) {
3135
+ return queryByText(this.semanticTree(), matcher);
3136
+ }
3137
+ queryById(id) {
3138
+ return queryById(this.semanticTree(), id);
3139
+ }
3140
+ /**
3141
+ * Resolve a semantic target (by role+name or id) and activate it — the
3142
+ * automation `act` primitive that drives by semantics, not coordinates.
3143
+ * Returns whether a matching control's handler ran.
3144
+ */
3145
+ activate(target) {
3146
+ this.assertActive("activate a target");
3147
+ const node = "id" in target ? this.queryById(target.id) : this.queryByRole(target.role, { name: target.name });
3148
+ if (!node) return false;
3149
+ return this.fireEvent(node.id, "onClick");
3150
+ }
3151
+ destroy() {
3152
+ if (this.lifecycle === "destroyed") return;
3153
+ this.lifecycle = "destroying";
3154
+ this.renderer.destroy();
3155
+ this.lifecycle = "destroyed";
3156
+ }
3157
+ assertActive(action) {
3158
+ if (!this.isActive) throw new Error(`Cannot ${action} after TUI host teardown has started`);
3159
+ }
3160
+ };
3161
+ var HOVER_EVENTS = ["onMouseEnter", "onMouseLeave"];
3162
+ var WHEEL_EVENTS = ["onWheel"];
3163
+ var KEY_EVENTS = ["onKeyDown"];
3164
+ var TEXT_EDITING_KEYS = /* @__PURE__ */ new Set([
3165
+ "ArrowLeft",
3166
+ "ArrowRight",
3167
+ "Home",
3168
+ "End",
3169
+ "Backspace",
3170
+ "Delete",
3171
+ "Enter"
3172
+ ]);
3173
+ function isTextEditingEvent(event) {
3174
+ return event.type === "text" || event.type === "paste" || event.type === "key" && TEXT_EDITING_KEYS.has(event.key);
3175
+ }
3176
+ /**
3177
+ * Routes normalized input to the right control for a {@link TuiHost}: keeps a
3178
+ * host-local {@link TextInputMachine} per text field, dispatches editing keys
3179
+ * to the focused field (firing onChange/onSubmit), and Tab/Enter/Space/click to
3180
+ * buttons. Field state lives in the host, not the plugin — the plan's
3181
+ * "local default actions" with optimistic controlled reconciliation (§5.4).
3182
+ */
3183
+ var InputRouter = class {
3184
+ host;
3185
+ focus = new FocusManager();
3186
+ fields = /* @__PURE__ */ new Map();
3187
+ hoveredId = null;
3188
+ autoFocused = false;
3189
+ inputSubscribers = /* @__PURE__ */ new Set();
3190
+ constructor(host) {
3191
+ this.host = host;
3192
+ }
3193
+ /**
3194
+ * Subscribe to global input — key/text events the focused control did not
3195
+ * consume, plus every paste. This is the host-side seam useInput/usePaste
3196
+ * build on: high-frequency keys resolve here, never one RPC round trip per
3197
+ * event (the plan's principle 3). Returns an unsubscribe function.
3198
+ */
3199
+ subscribeInput(listener) {
3200
+ this.assertActive("subscribe to input");
3201
+ this.inputSubscribers.add(listener);
3202
+ return () => this.inputSubscribers.delete(listener);
3203
+ }
3204
+ emitGlobal(event) {
3205
+ for (const listener of this.inputSubscribers) {
3206
+ if (!this.host.isActive) return;
3207
+ listener(event);
3208
+ }
3209
+ }
3210
+ /** Refresh the focusable set after a render; prunes fields for removed nodes. */
3211
+ onRender() {
3212
+ this.assertActive("refresh input state");
3213
+ const targets = this.host.focusableTargets();
3214
+ this.focus.setFocusables(targets.map((t) => ({ id: t.id })));
3215
+ const live = new Set(targets.map((t) => t.id));
3216
+ for (const id of [...this.fields.keys()]) if (!live.has(id)) this.fields.delete(id);
3217
+ if (this.hoveredId && this.host.nearestTarget(this.hoveredId, HOVER_EVENTS) !== this.hoveredId) this.hoveredId = null;
3218
+ if (!this.autoFocused && this.focus.focused === null) {
3219
+ const auto = targets.find((t) => t.autoFocus);
3220
+ if (auto) {
3221
+ this.autoFocused = true;
3222
+ this.focus.focus(auto.id, "programmatic");
3223
+ }
3224
+ }
3225
+ this.syncFocus();
3226
+ }
3227
+ /** Mirror the current focus into the host so the caret repaints where focus went. */
3228
+ syncFocus() {
3229
+ this.host.setFocusedId(this.focus.focused);
3230
+ }
3231
+ /** Update hover: leave the previous target, enter the new one under (x, y). */
3232
+ updateHover(x, y) {
3233
+ const target = this.host.nearestTarget(this.host.nodeAt(x, y), HOVER_EVENTS);
3234
+ if (target === this.hoveredId) return target !== null;
3235
+ if (this.hoveredId) this.host.fireEvent(this.hoveredId, "onMouseLeave", {
3236
+ x,
3237
+ y
3238
+ });
3239
+ this.hoveredId = target;
3240
+ if (target) this.host.fireEvent(target, "onMouseEnter", {
3241
+ x,
3242
+ y
3243
+ });
3244
+ return true;
3245
+ }
3246
+ get focusedId() {
3247
+ return this.focus.focused;
3248
+ }
3249
+ /** Release local pointer/keyboard focus so application-level navigation can take over. */
3250
+ clearFocus() {
3251
+ this.assertActive("clear focus");
3252
+ this.focus.focus(null, "programmatic");
3253
+ this.syncFocus();
3254
+ }
3255
+ isTextbox(id) {
3256
+ return this.host.focusableTargets().some((t) => t.id === id && t.textbox);
3257
+ }
3258
+ hasKeyHandler(id) {
3259
+ return this.host.eventTargets("onKeyDown").includes(id);
3260
+ }
3261
+ fieldFor(id) {
3262
+ const committed = this.host.queryById(id)?.value ?? "";
3263
+ let field = this.fields.get(id);
3264
+ if (!field) {
3265
+ field = {
3266
+ machine: new TextInputMachine({
3267
+ value: committed,
3268
+ cursor: committed.length
3269
+ }),
3270
+ lastSent: committed,
3271
+ lastObserved: committed
3272
+ };
3273
+ this.fields.set(id, field);
3274
+ } else if (committed !== field.lastObserved) {
3275
+ field.lastObserved = committed;
3276
+ if (committed !== field.lastSent) {
3277
+ field.machine.setValue(committed);
3278
+ field.lastSent = committed;
3279
+ }
3280
+ }
3281
+ return field;
3282
+ }
3283
+ /**
3284
+ * Route one event and report whether a local control consumed it.
3285
+ *
3286
+ * `false` means the event reached the global input layer. Direct terminal
3287
+ * clients can use that signal to apply their own hotkeys without stealing
3288
+ * Enter/Space from a focused button, row, or tab.
3289
+ */
3290
+ dispatch(event) {
3291
+ this.assertActive("dispatch input");
3292
+ if (this.host.renderer.handleSelectionInput(event).consumed) return true;
3293
+ if (event.type === "mouse") {
3294
+ if (event.action === "move" || event.action === "drag") return this.updateHover(event.x, event.y);
3295
+ if (event.action === "wheel") {
3296
+ const target = this.host.nearestTarget(this.host.nodeAt(event.x, event.y), WHEEL_EVENTS);
3297
+ if (target) this.host.fireEvent(target, "onWheel", {
3298
+ deltaY: event.deltaY ?? 0,
3299
+ x: event.x,
3300
+ y: event.y
3301
+ });
3302
+ return target !== null;
3303
+ }
3304
+ if (event.action === "up" && event.button === "left") {
3305
+ const id = this.host.nodeAt(event.x, event.y);
3306
+ let consumed = false;
3307
+ if (id) {
3308
+ const focusTarget = this.host.nearestFocusable(id);
3309
+ if (focusTarget) {
3310
+ this.focus.focus(focusTarget, "pointer");
3311
+ this.syncFocus();
3312
+ consumed = true;
3313
+ }
3314
+ if (!this.isTextbox(id)) consumed = this.host.fireEventBubbling(id, "onClick", {
3315
+ x: event.x,
3316
+ y: event.y
3317
+ }) || consumed;
3318
+ }
3319
+ return consumed;
3320
+ }
3321
+ return false;
3322
+ }
3323
+ if (event.type === "key" && event.key === "Tab") {
3324
+ const focused = this.focus.move(event.shift ? "previous" : "next");
3325
+ this.syncFocus();
3326
+ if (focused !== null) return true;
3327
+ this.emitGlobal(event);
3328
+ return false;
3329
+ }
3330
+ const focused = this.focus.focused;
3331
+ if (focused && this.isTextbox(focused)) {
3332
+ const field = this.fieldFor(focused);
3333
+ const before = field.machine.value;
3334
+ const effects = field.machine.handle(event);
3335
+ for (const effect of effects) if (effect.type === "change") {
3336
+ if (effect.value !== before) {
3337
+ field.lastSent = effect.value;
3338
+ this.host.fireEvent(focused, "onChange", effect.value);
3339
+ }
3340
+ } else this.host.fireEvent(focused, "onSubmit", effect.value);
3341
+ if (effects.length > 0 || isTextEditingEvent(event)) return true;
3342
+ }
3343
+ if (event.type === "key" && focused && this.hasKeyHandler(focused)) {
3344
+ this.fireKey(focused, event);
3345
+ return true;
3346
+ }
3347
+ if (event.type === "key" && event.key === "Enter" && focused) {
3348
+ if (this.host.fireEvent(focused, "onClick")) return true;
3349
+ }
3350
+ if (event.type === "text" && event.text === " " && focused) {
3351
+ if (this.host.fireEvent(focused, "onClick")) return true;
3352
+ }
3353
+ if (event.type === "key" && focused) {
3354
+ const target = this.host.nearestTarget(focused, KEY_EVENTS);
3355
+ if (target) {
3356
+ this.fireKey(target, event);
3357
+ return true;
3358
+ }
3359
+ }
3360
+ if (event.type === "key" || event.type === "text" || event.type === "paste") this.emitGlobal(event);
3361
+ return false;
3362
+ }
3363
+ fireKey(id, event) {
3364
+ this.host.fireEvent(id, "onKeyDown", {
3365
+ key: event.key,
3366
+ ctrl: event.ctrl,
3367
+ alt: event.alt,
3368
+ shift: event.shift,
3369
+ meta: event.meta
3370
+ });
3371
+ }
3372
+ assertActive(action) {
3373
+ if (!this.host.isActive) throw new Error(`Cannot ${action} after TUI host teardown has started`);
3374
+ }
3375
+ };
3376
+ /** Provides the host {@link InputRouter} to `useInput`/`usePaste`. */
3377
+ var TuiRuntimeContext = createContext();
3378
+ /**
3379
+ * Subscribe to global keyboard input (keys/text the focused control did not
3380
+ * consume). Same signature and mapping as `@uniview/tui-react`'s `useInput`, so
3381
+ * a plugin reads identically in either binding. Resolved host-side — no per-event
3382
+ * RPC. A no-op outside a Tui root.
3383
+ */
3384
+ function useInput(handler, opts = {}) {
3385
+ const router = useContext(TuiRuntimeContext);
3386
+ createEffect(() => {
3387
+ if (!router || opts.isActive === false) return;
3388
+ onCleanup(router.subscribeInput((event) => {
3389
+ if (event.type !== "key" && event.type !== "text") return;
3390
+ const { input, key } = toInputKey(event);
3391
+ handler(input, key);
3392
+ }));
3393
+ });
3394
+ }
3395
+ function devFlag() {
3396
+ return typeof process !== "undefined" && process.env?.TUI_DEVTOOLS === "1";
3397
+ }
3398
+ /**
3399
+ * Connect the plugin to Solid DevTools when a dev flag is set. The devtools
3400
+ * package is *dynamically imported behind the flag* (a variable specifier, so
3401
+ * it need not be installed for production builds/type-checks) and any failure
3402
+ * — including the package being absent — is swallowed: devtools is best-effort.
3403
+ */
3404
+ async function connectSolidDevTools(opts = {}) {
3405
+ if (!(opts.enabled ?? devFlag())) return;
3406
+ const connect = opts.connect ?? (async () => {
3407
+ await import("solid-devtools");
3408
+ });
3409
+ try {
3410
+ await connect();
3411
+ } catch (error) {
3412
+ console.warn("[tui-solid] devtools connection failed:", error);
3413
+ }
3414
+ }
3415
+ createLowlight(common);
3416
+ /**
3417
+ * First-class JSX components for the Uniview TUI host primitives, so Solid
3418
+ * plugins author terminal UI in real JSX (ink-style), e.g.
3419
+ *
3420
+ * ```tsx
3421
+ * <Box flexDirection="column" padding={1} border="rounded">
3422
+ * <Text color="cyan" bold>Hello</Text>
3423
+ * </Box>
3424
+ * ```
3425
+ *
3426
+ * They are thin, typed wrappers over the `box` / `text` / `richtext`
3427
+ * primitives the Solid renderer renders — capitalized because Solid's
3428
+ * lowercase JSX intrinsics are typed only by a catch-all
3429
+ * `[tag: string]: unknown` (zero safety). Mirrors
3430
+ * `@uniview/tui-react`'s `primitives.ts` convention.
3431
+ */
3432
+ /** Attributes shared by every TUI element: layout ({@link TuiStyle}) + handlers + semantics. */
3433
+ /** Props for {@link Box}. */
3434
+ /** Props for {@link Text}. */
3435
+ /** Props for {@link RichText}. */
3436
+ /**
3437
+ * A flexbox container (`box` primitive).
3438
+ *
3439
+ * NOTE: props are spread, never destructured — destructuring would read each
3440
+ * prop eagerly and break Solid's fine-grained (getter-based) reactivity.
3441
+ */
3442
+ function Box(props) {
3443
+ return (() => {
3444
+ var _el$ = createElement("box");
3445
+ spread(_el$, props, false);
3446
+ return _el$;
3447
+ })();
3448
+ }
3449
+ /**
3450
+ * Styled text (`text` primitive). Children are strings/numbers.
3451
+ *
3452
+ * Built via the low-level renderer primitives instead of literal
3453
+ * `<text {...props} />` JSX: solid-js's own JSX typings declare a `text` SVG
3454
+ * intrinsic (`JSX.IntrinsicElements["text"]: TextSVGAttributes<SVGTextElement>`)
3455
+ * whose `onChange` expects a DOM `Event`, which is structurally incompatible
3456
+ * with {@link TuiEventHandlers.onChange}'s `(value: string) => void`.
3457
+ * TypeScript requires every partial declaration merged into
3458
+ * `JSX.IntrinsicElements` to agree on a property's type, so that collision
3459
+ * can't be resolved by widening `"text"`'s declared prop type — the only tag
3460
+ * among box/text/richtext that collides with a real DOM/SVG element name.
3461
+ * This mirrors exactly how `@uniview/tui-react` avoids the same class of
3462
+ * problem: it builds the element via `createElement("text", props)` instead
3463
+ * of raw `<text>` JSX. `spread` reads `props` through its getters inside a
3464
+ * reactive effect (the same mechanism the compiler emits for `{...props}`),
3465
+ * so this preserves Solid's fine-grained reactivity exactly like the JSX form.
3466
+ */
3467
+ function Text(props) {
3468
+ const node = createElement("text");
3469
+ spread(node, props, false);
3470
+ return node;
3471
+ }
3472
+ /**
3473
+ * A vertical scrollbar: a 1-cell-wide column of `height` rows with a thumb sized
3474
+ * and positioned by {@link scrollbarThumb}. Reusable on its own or inside
3475
+ * {@link ScrollView}.
3476
+ */
3477
+ function Scrollbar(props) {
3478
+ const geometry = createMemo(() => scrollbarThumb(props.total, props.height, props.value));
3479
+ return (() => {
3480
+ var _el$ = createElement("box");
3481
+ setProp(_el$, "flexDirection", "column");
3482
+ setProp(_el$, "width", 1);
3483
+ insert(_el$, createComponent$1(Index, {
3484
+ get each() {
3485
+ return Array.from({ length: props.height });
3486
+ },
3487
+ children: (_, i) => {
3488
+ const on = createMemo(() => i >= geometry().start && i < geometry().start + geometry().thumb);
3489
+ return createComponent$1(Text, {
3490
+ get color() {
3491
+ return memo(() => !!on())() ? props.thumbColor ?? "white" : props.trackColor ?? "gray";
3492
+ },
3493
+ get dim() {
3494
+ return !on();
3495
+ },
3496
+ get children() {
3497
+ return on() ? "█" : "│";
3498
+ }
3499
+ });
3500
+ }
3501
+ }));
3502
+ return _el$;
3503
+ })();
3504
+ }
3505
+ /** A bordered, titled, focusable panel — the lazygit window primitive. */
3506
+ /**
3507
+ * Solid port of `@uniview/tui-react`'s `Panel` — stateless, a pure prop→element
3508
+ * mapping onto the `box` primitive (whose `title`/`footer`/`borderColor` props
3509
+ * are interpreted by `@uniview/host-tui`'s converter).
3510
+ *
3511
+ * NOTE: props are read through {@link splitProps} + getters, never destructured
3512
+ * — destructuring would snapshot each prop eagerly and break Solid's
3513
+ * fine-grained reactivity (a `focused` signal would stop repainting the border).
3514
+ */
3515
+ function Panel(props) {
3516
+ const [, rest] = splitProps(props, [
3517
+ "title",
3518
+ "titleAlign",
3519
+ "footer",
3520
+ "footerAlign",
3521
+ "focused",
3522
+ "focusedColor",
3523
+ "borderColor",
3524
+ "border",
3525
+ "children"
3526
+ ]);
3527
+ const border = () => props.border ?? "rounded";
3528
+ const resolvedBorderColor = () => props.focused ? props.focusedColor ?? "green" : props.borderColor;
3529
+ return (() => {
3530
+ var _el$ = createElement("box");
3531
+ spread(_el$, mergeProps$1(rest, {
3532
+ get border() {
3533
+ return border();
3534
+ },
3535
+ get title() {
3536
+ return props.title;
3537
+ },
3538
+ get titleAlign() {
3539
+ return props.titleAlign;
3540
+ },
3541
+ get footer() {
3542
+ return props.footer;
3543
+ },
3544
+ get footerAlign() {
3545
+ return props.footerAlign;
3546
+ },
3547
+ get borderColor() {
3548
+ return resolvedBorderColor();
3549
+ }
3550
+ }), true);
3551
+ insert(_el$, () => props.children);
3552
+ return _el$;
3553
+ })();
3554
+ }
3555
+ var activeSolidRootOwner = null;
3556
+ var pendingSolidSessionCleanup = null;
3557
+ var retryingPendingSolidSessionCleanup = false;
3558
+ function retryPendingSolidSessionCleanup(nextOwner) {
3559
+ const pending = pendingSolidSessionCleanup;
3560
+ if (!pending || pending.owner === nextOwner) return;
3561
+ if (retryingPendingSolidSessionCleanup) throw new Error("TUI Solid root cleanup is already in progress");
3562
+ retryingPendingSolidSessionCleanup = true;
3563
+ try {
3564
+ pending.driver.stop();
3565
+ if (pendingSolidSessionCleanup === pending) pendingSolidSessionCleanup = null;
3566
+ } finally {
3567
+ retryingPendingSolidSessionCleanup = false;
3568
+ }
3569
+ }
3570
+ function reserveSolidRootOwnership(owner) {
3571
+ retryPendingSolidSessionCleanup(owner);
3572
+ if (activeSolidRootOwner && activeSolidRootOwner !== owner) throw new Error("Cannot render because another TUI Solid root is active; destroy it before rendering this root");
3573
+ activeSolidRootOwner = owner;
3574
+ }
3575
+ function releaseSolidRootOwnership(owner) {
3576
+ if (activeSolidRootOwner === owner) activeSolidRootOwner = null;
3577
+ }
3578
+ /**
3579
+ * Render a Solid plugin to a terminal {@link CellSurface}. Solid's fine-grained
3580
+ * reactivity commits synchronously; each update serializes to UINode and feeds
3581
+ * a {@link TuiHost}, and input routes back exactly as in the React adapter.
3582
+ * Together with @uniview/tui-react this proves the framework-agnostic host.
3583
+ *
3584
+ * Note: solid-renderer uses a single module-global root, so one Solid root may
3585
+ * be active per process at a time.
3586
+ */
3587
+ function createTuiSolidRootInternal(options, owner) {
3588
+ const registry = new HandlerRegistry();
3589
+ const host = new TuiHost({
3590
+ surface: options.surface,
3591
+ size: options.size,
3592
+ styles: options.styles,
3593
+ committed: options.committed,
3594
+ layoutEngine: options.layoutEngine,
3595
+ selection: options.selection,
3596
+ onInvokeHandler: (handlerId, payload) => {
3597
+ registry.execute(handlerId, payload);
3598
+ }
3599
+ });
3600
+ const router = new InputRouter(host);
3601
+ const clock = options.clock ?? new FrameClock({
3602
+ now: () => performance.now(),
3603
+ requestFrame: (frame) => {
3604
+ setTimeout(frame, 16);
3605
+ },
3606
+ diagnostics: host.renderer.diagnostics
3607
+ });
3608
+ if (options.devtools) connectSolidDevTools({ enabled: true });
3609
+ const ownsGlobals = () => activeSolidRootOwner === owner;
3610
+ const sync = () => {
3611
+ const appRoot = getRootNode()?.children[0] ?? null;
3612
+ const tree = appRoot ? serializeTree(appRoot, registry) : null;
3613
+ host.setRoot(tree && typeof tree !== "string" ? tree : null);
3614
+ router.onRender();
3615
+ };
3616
+ let dispose = null;
3617
+ let teardownStarted = false;
3618
+ let globalsInstalled = false;
3619
+ let hostDestroyed = false;
3620
+ const reserveOwnership = () => {
3621
+ reserveSolidRootOwnership(owner);
3622
+ };
3623
+ const releaseOwnership = () => {
3624
+ if (!ownsGlobals()) return;
3625
+ if (globalsInstalled) {
3626
+ setUpdateCallback(null);
3627
+ setMutationUpdateCallback(null);
3628
+ setMutationCollector(null);
3629
+ setRootNode(null);
3630
+ }
3631
+ globalsInstalled = false;
3632
+ releaseSolidRootOwnership(owner);
3633
+ };
3634
+ const installGlobals = () => {
3635
+ reserveOwnership();
3636
+ if (globalsInstalled) return;
3637
+ globalsInstalled = true;
3638
+ try {
3639
+ setRootNode(null);
3640
+ setMutationUpdateCallback(null);
3641
+ setMutationCollector(null);
3642
+ setUpdateCallback(sync);
3643
+ } catch (error) {
3644
+ releaseOwnership();
3645
+ throw error;
3646
+ }
3647
+ };
3648
+ const disposeMount = () => {
3649
+ const activeDispose = dispose;
3650
+ try {
3651
+ activeDispose?.();
3652
+ if (dispose === activeDispose) dispose = null;
3653
+ } finally {
3654
+ registry.clear();
3655
+ if (ownsGlobals() && globalsInstalled) setRootNode(null);
3656
+ }
3657
+ };
3658
+ return {
3659
+ host,
3660
+ clock,
3661
+ render(App) {
3662
+ if (hostDestroyed && !ownsGlobals()) throw new Error("Cannot render into a destroyed TUI Solid root");
3663
+ if (teardownStarted) throw new Error("Cannot render after TUI Solid root teardown has started");
3664
+ installGlobals();
3665
+ disposeMount();
3666
+ resetIdCounter();
3667
+ const container = {
3668
+ _type: "element",
3669
+ id: "__root",
3670
+ type: "div",
3671
+ props: {},
3672
+ children: [],
3673
+ parent: null
3674
+ };
3675
+ setRootNode(container);
3676
+ try {
3677
+ dispose = render(() => createComponent$1(TuiRuntimeContext.Provider, {
3678
+ value: router,
3679
+ get children() {
3680
+ return App();
3681
+ }
3682
+ }), container);
3683
+ } catch (error) {
3684
+ try {
3685
+ disposeMount();
3686
+ } catch {}
3687
+ if (dispose === null) try {
3688
+ releaseOwnership();
3689
+ } catch {}
3690
+ try {
3691
+ host.setRoot(null);
3692
+ router.onRender();
3693
+ } catch {}
3694
+ throw error;
3695
+ }
3696
+ sync();
3697
+ },
3698
+ dispatchInput(event) {
3699
+ if (teardownStarted) throw new Error("Cannot dispatch input after TUI Solid root teardown has started");
3700
+ router.dispatch(event);
3701
+ },
3702
+ dispatchInputWithResult(event) {
3703
+ if (teardownStarted) throw new Error("Cannot dispatch input after TUI Solid root teardown has started");
3704
+ return router.dispatch(event);
3705
+ },
3706
+ clearFocus() {
3707
+ if (teardownStarted) throw new Error("Cannot clear focus after TUI Solid root teardown has started");
3708
+ router.clearFocus();
3709
+ },
3710
+ destroy() {
3711
+ if (hostDestroyed && dispose === null && !ownsGlobals()) return;
3712
+ teardownStarted = true;
3713
+ let firstError;
3714
+ let hasError = false;
3715
+ const attempt = (cleanup, complete) => {
3716
+ try {
3717
+ cleanup();
3718
+ complete?.();
3719
+ } catch (error) {
3720
+ if (!hasError) {
3721
+ firstError = error;
3722
+ hasError = true;
3723
+ }
3724
+ }
3725
+ };
3726
+ if (dispose !== null) attempt(disposeMount);
3727
+ if (dispose === null && ownsGlobals()) attempt(releaseOwnership);
3728
+ if (!hostDestroyed) attempt(() => host.destroy(), () => {
3729
+ hostDestroyed = true;
3730
+ });
3731
+ if (hasError) throw firstError;
3732
+ }
3733
+ };
3734
+ }
3735
+ function createTuiSolidRoot(options) {
3736
+ return createTuiSolidRootInternal(options, {});
3737
+ }
3738
+ //#endregion
3739
+ //#region src/ui.tsx
3740
+ function runTui(options) {
3741
+ return new Promise((resolve) => {
3742
+ const styles = new StyleTable$1();
3743
+ const surface = new AnsiCellSurface({
3744
+ write: (chunk) => process.stdout.write(chunk),
3745
+ styles
3746
+ });
3747
+ const initialSize = {
3748
+ width: process.stdout.columns ?? 80,
3749
+ height: process.stdout.rows ?? 24
3750
+ };
3751
+ const [terminalSize, setTerminalSize] = createSignal(initialSize);
3752
+ const root = createTuiSolidRoot({
3753
+ surface,
3754
+ styles,
3755
+ size: initialSize
3756
+ });
3757
+ let stopped = false;
3758
+ let driverStarted = false;
3759
+ const quit = () => {
3760
+ if (stopped) return;
3761
+ stopped = true;
3762
+ root.destroy();
3763
+ if (driverStarted) driver.stop();
3764
+ resolve();
3765
+ };
3766
+ const driver = new TerminalDriver({
3767
+ input: process.stdin,
3768
+ output: process.stdout,
3769
+ screen: "alternate",
3770
+ mouse: "click",
3771
+ onEvent: (event) => {
3772
+ if (event.type === "resize") {
3773
+ setTerminalSize({
3774
+ width: event.width,
3775
+ height: event.height
3776
+ });
3777
+ root.host.renderer.resize({
3778
+ width: event.width,
3779
+ height: event.height
3780
+ });
3781
+ } else root.dispatchInput(event);
3782
+ }
3783
+ });
3784
+ try {
3785
+ driver.start();
3786
+ driverStarted = true;
3787
+ root.render(() => createComponent$1(SpaceLensApp, {
3788
+ options,
3789
+ terminalHeight: () => terminalSize().height,
3790
+ onQuit: quit
3791
+ }));
3792
+ process.stdin.on?.("end", quit);
3793
+ } catch (error) {
3794
+ try {
3795
+ root.destroy();
3796
+ } finally {
3797
+ if (driverStarted) driver.stop();
3798
+ }
3799
+ throw error;
3800
+ }
3801
+ });
3802
+ }
3803
+ function SpaceLensApp(props) {
3804
+ const state = createInitialTuiState();
3805
+ const [data, setData] = createSignal(props.options.initialData);
3806
+ const [executing, setExecuting] = createSignal(false);
3807
+ const [revision, setRevision] = createSignal(0);
3808
+ const touch = () => setRevision((value) => value + 1);
3809
+ const act = (action) => {
3810
+ applyTuiAction(state, action);
3811
+ touch();
3812
+ };
3813
+ const scan = createMemo(() => {
3814
+ revision();
3815
+ return createScanViewModel(data().scanTrees, state);
3816
+ });
3817
+ const clean = createMemo(() => {
3818
+ revision();
3819
+ return createCleanViewModel(data().plan, {
3820
+ sort: props.options.sort,
3821
+ state
3822
+ });
3823
+ });
3824
+ const selected = createMemo(() => {
3825
+ revision();
3826
+ return getSelectedEntries(state, data().plan.entries);
3827
+ });
3828
+ const viewportHeight = () => listViewportHeight(props.terminalHeight(), clean().errors.length);
3829
+ const activeRows = () => state.mode === "scan" ? scan().rows : clean().rows;
3830
+ const activeMode = () => {
3831
+ revision();
3832
+ return state.mode;
3833
+ };
3834
+ const status = () => {
3835
+ revision();
3836
+ return state.status;
3837
+ };
3838
+ const confirmExecute = () => {
3839
+ revision();
3840
+ return state.confirmExecute;
3841
+ };
3842
+ const move = (delta) => {
3843
+ act({
3844
+ type: "move",
3845
+ delta,
3846
+ rowCount: activeRows().length
3847
+ });
3848
+ };
3849
+ const toggleCurrent = () => {
3850
+ if (activeMode() !== "clean") return;
3851
+ const row = clean().rows[clean().cursor];
3852
+ if (row) act({
3853
+ type: "toggle-selected",
3854
+ path: row.path
3855
+ });
3856
+ };
3857
+ const executeSelected = () => {
3858
+ const entries = selected();
3859
+ if (entries.length === 0) {
3860
+ act({
3861
+ type: "set-status",
3862
+ status: "Nothing selected."
3863
+ });
3864
+ return;
3865
+ }
3866
+ setExecuting(true);
3867
+ act({
3868
+ type: "set-status",
3869
+ status: `Removing ${entries.length} selected paths...`
3870
+ });
3871
+ try {
3872
+ const outcome = props.options.executeEntries(entries);
3873
+ setData(props.options.refreshData());
3874
+ act({ type: "clear-selection" });
3875
+ act({
3876
+ type: "set-status",
3877
+ status: removalStatus(outcome)
3878
+ });
3879
+ } catch (error) {
3880
+ act({
3881
+ type: "set-status",
3882
+ status: `Delete failed: ${error instanceof Error ? error.message : String(error)}`
3883
+ });
3884
+ } finally {
3885
+ setExecuting(false);
3886
+ }
3887
+ };
3888
+ useInput((input, key) => {
3889
+ if (executing()) return;
3890
+ if (key.ctrl) return props.onQuit();
3891
+ if (key.tab) return act({ type: "switch-mode" });
3892
+ if (key.return) return confirmExecute() ? executeSelected() : void 0;
3893
+ if (key.escape) return act({ type: "cancel-execute" });
3894
+ if (input === "q") return props.onQuit();
3895
+ if (input === "j" || key.downArrow) return move(1);
3896
+ if (input === "k" || key.upArrow) return move(-1);
3897
+ if (key.pageDown) return move(viewportHeight());
3898
+ if (key.pageUp) return move(-viewportHeight());
3899
+ if (input === " ") return toggleCurrent();
3900
+ if (input === "a" && activeMode() === "clean") return act({
3901
+ type: "toggle-all",
3902
+ paths: clean().rows.map((row) => row.path)
3903
+ });
3904
+ if (input === "x" && activeMode() === "clean") return act({ type: "request-execute" });
3905
+ });
3906
+ return createComponent$1(Box, {
3907
+ flexDirection: "column",
3908
+ gap: 1,
3909
+ padding: 1,
3910
+ width: "100%",
3911
+ height: "100%",
3912
+ get children() {
3913
+ return [
3914
+ createComponent$1(Text, {
3915
+ color: "cyan",
3916
+ get children() {
3917
+ return [
3918
+ "Space Lens | ",
3919
+ memo(() => activeMode() === "scan" ? "SCAN" : "CLEAN"),
3920
+ " | tab switch | j/k move | q quit"
3921
+ ];
3922
+ }
3923
+ }),
3924
+ createComponent$1(Text, {
3925
+ color: "white",
3926
+ get children() {
3927
+ return memo(() => activeMode() === "scan")() ? `${scan().summary} | tree view` : `${clean().summary} | space select | a all | x delete`;
3928
+ }
3929
+ }),
3930
+ createComponent$1(Text, {
3931
+ get color() {
3932
+ return confirmExecute() ? "red" : "gray";
3933
+ },
3934
+ get children() {
3935
+ return statusLine(selected(), confirmExecute(), executing(), status());
3936
+ }
3937
+ }),
3938
+ createComponent$1(Show, {
3939
+ get when() {
3940
+ return activeMode() === "scan";
3941
+ },
3942
+ get fallback() {
3943
+ return createComponent$1(ListPanel, {
3944
+ get title() {
3945
+ return memo(() => selected().length > 0)() ? `cleanup candidates (${selected().length} selected)` : "cleanup candidates";
3946
+ },
3947
+ get rows() {
3948
+ return clean().rows;
3949
+ },
3950
+ get cursor() {
3951
+ return clean().cursor;
3952
+ },
3953
+ get height() {
3954
+ return viewportHeight();
3955
+ },
3956
+ get danger() {
3957
+ return confirmExecute();
3958
+ },
3959
+ empty: "No cleanup candidates found.",
3960
+ renderRow: (row) => createComponent$1(Text, {
3961
+ get color() {
3962
+ return memo(() => !!row.active)() ? "cyan" : colorForPreset(row.preset);
3963
+ },
3964
+ get children() {
3965
+ return `${row.active ? ">" : " "} ${row.selected ? "[x]" : "[ ]"} ${row.sizeLabel.padEnd(24)} ${row.preset.padEnd(10)} ${row.path} ${row.reason}`;
3966
+ }
3967
+ })
3968
+ });
3969
+ },
3970
+ get children() {
3971
+ return createComponent$1(ListPanel, {
3972
+ title: "scan tree",
3973
+ get rows() {
3974
+ return scan().rows;
3975
+ },
3976
+ get cursor() {
3977
+ return scan().cursor;
3978
+ },
3979
+ get height() {
3980
+ return viewportHeight();
3981
+ },
3982
+ empty: "No scan results.",
3983
+ renderRow: (row) => createComponent$1(Text, {
3984
+ get color() {
3985
+ return memo(() => !!row.active)() ? "cyan" : row.ignored ? "yellow" : "white";
3986
+ },
3987
+ get children() {
3988
+ return `${row.active ? ">" : " "} ${row.sizeLabel.padEnd(24)} ${row.label}`;
3989
+ }
3990
+ })
3991
+ });
3992
+ }
3993
+ }),
3994
+ createComponent$1(For, {
3995
+ get each() {
3996
+ return clean().errors;
3997
+ },
3998
+ children: (error) => createComponent$1(Text, {
3999
+ color: "yellow",
4000
+ get children() {
4001
+ return ["Warnings: ", error];
4002
+ }
4003
+ })
4004
+ })
4005
+ ];
4006
+ }
4007
+ });
4008
+ }
4009
+ function ListPanel(props) {
4010
+ const [scrollTop, setScrollTop] = createSignal(0);
4011
+ const maxScroll = () => Math.max(0, props.rows.length - props.height);
4012
+ const visible = () => props.rows.slice(scrollTop(), scrollTop() + props.height);
4013
+ createEffect(() => {
4014
+ const cursor = props.cursor;
4015
+ const height = props.height;
4016
+ const max = maxScroll();
4017
+ setScrollTop((top) => {
4018
+ if (cursor < top) return cursor;
4019
+ if (cursor >= top + height) return Math.min(max, cursor - height + 1);
4020
+ return Math.min(top, max);
4021
+ });
4022
+ });
4023
+ const onWheel = (event) => {
4024
+ setScrollTop((top) => clampScroll(top + event.deltaY * 3, props.rows.length, props.height));
4025
+ };
4026
+ const footer = () => props.rows.length > props.height ? `${Math.min(scrollTop() + props.height, props.rows.length)} / ${props.rows.length}` : void 0;
4027
+ return createComponent$1(Panel, {
4028
+ get title() {
4029
+ return props.title;
4030
+ },
4031
+ get footer() {
4032
+ return footer();
4033
+ },
4034
+ get borderColor() {
4035
+ return props.danger ? "red" : "gray";
4036
+ },
4037
+ flexGrow: 1,
4038
+ flexShrink: 1,
4039
+ minHeight: 0,
4040
+ overflow: "hidden",
4041
+ onWheel,
4042
+ get children() {
4043
+ return createComponent$1(Box, {
4044
+ flexDirection: "row",
4045
+ flexGrow: 1,
4046
+ flexShrink: 1,
4047
+ minWidth: 0,
4048
+ get height() {
4049
+ return props.height;
4050
+ },
4051
+ get children() {
4052
+ return [createComponent$1(Box, {
4053
+ flexDirection: "column",
4054
+ flexGrow: 1,
4055
+ flexShrink: 1,
4056
+ minWidth: 0,
4057
+ get height() {
4058
+ return props.height;
4059
+ },
4060
+ get children() {
4061
+ return createComponent$1(Show, {
4062
+ get when() {
4063
+ return props.rows.length > 0;
4064
+ },
4065
+ get fallback() {
4066
+ return createComponent$1(Text, {
4067
+ color: "gray",
4068
+ get children() {
4069
+ return props.empty;
4070
+ }
4071
+ });
4072
+ },
4073
+ get children() {
4074
+ return createComponent$1(For, {
4075
+ get each() {
4076
+ return visible();
4077
+ },
4078
+ children: (row, index) => props.renderRow(row, scrollTop() + index())
4079
+ });
4080
+ }
4081
+ });
4082
+ }
4083
+ }), createComponent$1(Scrollbar, {
4084
+ get total() {
4085
+ return props.rows.length;
4086
+ },
4087
+ get height() {
4088
+ return props.height;
4089
+ },
4090
+ get value() {
4091
+ return scrollTop();
4092
+ }
4093
+ })];
4094
+ }
4095
+ });
4096
+ }
4097
+ });
4098
+ }
4099
+ function listViewportHeight(terminalHeight, warningCount) {
4100
+ return Math.max(1, terminalHeight - 12 - warningCount * 2);
4101
+ }
4102
+ function statusLine(selected, confirm, executing, status) {
4103
+ if (executing) return status;
4104
+ if (confirm) return `Confirm delete ${selected.length} paths (${formatBytes(selected.reduce((total, entry) => total + entry.size, 0))}): enter execute, esc cancel.`;
4105
+ return status || "Scan mode shows disk tree. Clean mode selects cleanup candidates.";
4106
+ }
4107
+ function removalStatus(outcome) {
4108
+ return `Removed ${outcome.removed.length} paths, ${formatBytes(outcome.bytesRemoved)}.${outcome.errors.length > 0 ? ` ${outcome.errors.length} errors.` : ""}`;
4109
+ }
4110
+ function colorForPreset(preset) {
4111
+ return preset === "node" ? "green" : preset === "rust" ? "red" : preset === "gitignored" ? "yellow" : "white";
4112
+ }
4113
+ //#endregion
4114
+ //#region src/cli-program.ts
4115
+ var APP_VERSION = "0.2.3";
4116
+ var command = Command.make("spacelens", {
4117
+ paths: Args.text({ name: "path" }).pipe(Args.atLeast(0), Args.withDescription("Directory to scan.")),
4118
+ presets: Options.text("preset").pipe(Options.withAlias("p"), Options.repeated, Options.withDescription("Cleanup preset: node, rust, gitignored.")),
4119
+ ignoreHidden: Options.boolean("ignore-hidden").pipe(Options.withDescription("Skip hidden paths.")),
4120
+ sort: Options.choice("sort", SORT_MODES).pipe(Options.withDefault("size"), Options.withDescription("Sort by size or path."))
4121
+ }, (rawConfig) => Effect.gen(function* () {
24
4122
  yield* runTuiProgram(yield* Effect.try({
25
4123
  try: () => normalizeCliConfig(rawConfig),
26
4124
  catch: toError
27
4125
  }));
28
- }).pipe(Effect.catchAll(reportCliError))).pipe(Command.withDescription("OpenTUI scanner and cleanup picker for Space Lens."));
29
- const cli = Command.run(spaceLensTuiCommand, {
4126
+ }).pipe(Effect.catchAll(reportCliError))).pipe(Command.withDescription("Space Lens scanner and cleanup picker."));
4127
+ var cli = Command.run(command, {
30
4128
  name: "Space Lens TUI",
31
4129
  version: APP_VERSION
32
4130
  });
33
- function makeCliEffect(argv) {
34
- return cli(argv).pipe(Effect.provide(NodeContext.layer));
35
- }
36
4131
  function runCli(argv = process.argv) {
37
- NodeRuntime.runMain(makeCliEffect(argv));
4132
+ NodeRuntime.runMain(cli(argv).pipe(Effect.provide(NodeContext.layer)));
38
4133
  }
39
- const runTuiProgram = Effect.fn("runTuiProgram")((options) => Effect.gen(function* () {
40
- yield* Effect.try({
41
- try: () => assertSupportedRuntime(),
42
- catch: toError
43
- });
44
- const [{ executeCleanupEntries, loadSpaceLensData }, { runTui }] = yield* Effect.tryPromise({
45
- try: () => Promise.all([import("./scanner-BwSuW3ks.mjs"), import("./ui-BKn7TAnJ.mjs")]),
4134
+ var runTuiProgram = Effect.fn("runTuiProgram")((options) => Effect.gen(function* () {
4135
+ const [{ executeCleanupEntries, loadSpaceLensData }] = yield* Effect.tryPromise({
4136
+ try: () => Promise.all([import("./assets/scanner-CZbLKIYe.js")]),
46
4137
  catch: toError
47
4138
  });
48
4139
  const initialData = yield* Effect.try({