@zeus-js/zeus 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2216 @@
1
+ /**
2
+ * zeus v0.0.2
3
+ * (c) 2026 baicie
4
+ * Released under the MIT License.
5
+ **/
6
+ var Zeus = (function(exports) {
7
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
+ //#region packages/shared/src/makeMap.ts
9
+ /**
10
+ * Make a map and return a function for checking if a key
11
+ * is in that map.
12
+ * IMPORTANT: all calls of this function must be prefixed with
13
+ * \/\*#\_\_PURE\_\_\*\/
14
+ * So that rollup can tree-shake them if necessary.
15
+ */
16
+ /*@__NO_SIDE_EFFECTS__*/
17
+ function makeMap(str) {
18
+ const map = Object.create(null);
19
+ for (const key of str.split(",")) map[key] = 1;
20
+ return (val) => val in map;
21
+ }
22
+ //#endregion
23
+ //#region packages/shared/src/general.ts
24
+ const EMPTY_OBJ = Object.freeze({});
25
+ Object.freeze([]);
26
+ const NOOP = () => {};
27
+ const extend = Object.assign;
28
+ const remove = (arr, el) => {
29
+ const i = arr.indexOf(el);
30
+ if (i > -1) arr.splice(i, 1);
31
+ };
32
+ const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
33
+ const hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
34
+ const isArray = Array.isArray;
35
+ const isMap = (val) => toTypeString(val) === "[object Map]";
36
+ const isSet = (val) => toTypeString(val) === "[object Set]";
37
+ const isFunction = (val) => typeof val === "function";
38
+ const isString = (val) => typeof val === "string";
39
+ const isSymbol = (val) => typeof val === "symbol";
40
+ const isObject = (val) => val !== null && typeof val === "object";
41
+ const objectToString = Object.prototype.toString;
42
+ const toTypeString = (value) => objectToString.call(value);
43
+ const toRawType = (value) => {
44
+ return toTypeString(value).slice(8, -1);
45
+ };
46
+ const isPlainObject$1 = (val) => toTypeString(val) === "[object Object]";
47
+ const isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
48
+ const cacheStringFunction = (fn) => {
49
+ const cache = Object.create(null);
50
+ return ((str) => {
51
+ return cache[str] || (cache[str] = fn(str));
52
+ });
53
+ };
54
+ /**
55
+ * @private
56
+ */
57
+ const capitalize = cacheStringFunction((str) => {
58
+ return str.charAt(0).toUpperCase() + str.slice(1);
59
+ });
60
+ const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
61
+ //#endregion
62
+ //#region packages/signal/src/warning.ts
63
+ function warn(msg, ...args) {
64
+ console.warn(`[Zeus warn] ${msg}`, ...args);
65
+ }
66
+ //#endregion
67
+ //#region packages/signal/src/effectScope.ts
68
+ let activeEffectScope;
69
+ var EffectScope = class {
70
+ constructor(detached = false) {
71
+ this.detached = detached;
72
+ this._active = true;
73
+ this._on = 0;
74
+ this.effects = [];
75
+ this.cleanups = [];
76
+ this._isPaused = false;
77
+ this._warnOnRun = true;
78
+ this.__v_skip = true;
79
+ if (!detached && activeEffectScope) if (activeEffectScope.active) {
80
+ this.parent = activeEffectScope;
81
+ this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
82
+ } else {
83
+ this._active = false;
84
+ this._warnOnRun = false;
85
+ }
86
+ }
87
+ get active() {
88
+ return this._active;
89
+ }
90
+ pause() {
91
+ if (this._active) {
92
+ this._isPaused = true;
93
+ let i, l;
94
+ if (this.scopes) for (i = 0, l = this.scopes.length; i < l; i++) this.scopes[i].pause();
95
+ for (i = 0, l = this.effects.length; i < l; i++) this.effects[i].pause();
96
+ }
97
+ }
98
+ /**
99
+ * Resumes the effect scope, including all child scopes and effects.
100
+ */
101
+ resume() {
102
+ if (this._active) {
103
+ if (this._isPaused) {
104
+ this._isPaused = false;
105
+ let i, l;
106
+ if (this.scopes) for (i = 0, l = this.scopes.length; i < l; i++) this.scopes[i].resume();
107
+ for (i = 0, l = this.effects.length; i < l; i++) this.effects[i].resume();
108
+ }
109
+ }
110
+ }
111
+ run(fn) {
112
+ if (this._active) {
113
+ const currentEffectScope = activeEffectScope;
114
+ try {
115
+ activeEffectScope = this;
116
+ return fn();
117
+ } finally {
118
+ activeEffectScope = currentEffectScope;
119
+ }
120
+ } else if (this._warnOnRun) warn(`cannot run an inactive effect scope.`);
121
+ }
122
+ /**
123
+ * This should only be called on non-detached scopes
124
+ * @internal
125
+ */
126
+ on() {
127
+ if (++this._on === 1) {
128
+ this.prevScope = activeEffectScope;
129
+ activeEffectScope = this;
130
+ }
131
+ }
132
+ /**
133
+ * This should only be called on non-detached scopes
134
+ * @internal
135
+ */
136
+ off() {
137
+ if (this._on > 0 && --this._on === 0) {
138
+ if (activeEffectScope === this) activeEffectScope = this.prevScope;
139
+ else {
140
+ let current = activeEffectScope;
141
+ while (current) {
142
+ if (current.prevScope === this) {
143
+ current.prevScope = this.prevScope;
144
+ break;
145
+ }
146
+ current = current.prevScope;
147
+ }
148
+ }
149
+ this.prevScope = void 0;
150
+ }
151
+ }
152
+ stop(fromParent) {
153
+ if (this._active) {
154
+ this._active = false;
155
+ let i, l;
156
+ for (i = 0, l = this.effects.length; i < l; i++) this.effects[i].stop();
157
+ this.effects.length = 0;
158
+ for (i = 0, l = this.cleanups.length; i < l; i++) this.cleanups[i]();
159
+ this.cleanups.length = 0;
160
+ if (this.scopes) {
161
+ for (i = 0, l = this.scopes.length; i < l; i++) this.scopes[i].stop(true);
162
+ this.scopes.length = 0;
163
+ }
164
+ if (!this.detached && this.parent && !fromParent) {
165
+ const last = this.parent.scopes.pop();
166
+ if (last && last !== this) {
167
+ this.parent.scopes[this.index] = last;
168
+ last.index = this.index;
169
+ }
170
+ }
171
+ this.parent = void 0;
172
+ }
173
+ }
174
+ };
175
+ /**
176
+ * Creates an effect scope object which can capture the reactive effects (i.e.
177
+ * computed and watchers) created within it so that these effects can be
178
+ * disposed together. For detailed use cases of this API, please consult its
179
+ * corresponding {@link https://github.com/vuejs/rfcs/blob/master/active-rfcs/0041-reactivity-effect-scope.md | RFC}.
180
+ *
181
+ * @param detached - Can be used to create a "detached" effect scope.
182
+ * @see {@link https://vuejs.org/api/reactivity-advanced.html#effectscope}
183
+ */
184
+ function effectScope(detached) {
185
+ return new EffectScope(detached);
186
+ }
187
+ /**
188
+ * Returns the current active effect scope if there is one.
189
+ *
190
+ * @see {@link https://vuejs.org/api/reactivity-advanced.html#getcurrentscope}
191
+ */
192
+ function getCurrentScope() {
193
+ return activeEffectScope;
194
+ }
195
+ /**
196
+ * Registers a dispose callback on the current active effect scope. The
197
+ * callback will be invoked when the associated effect scope is stopped.
198
+ *
199
+ * @param fn - The callback function to attach to the scope's cleanup.
200
+ * @see {@link https://vuejs.org/api/reactivity-advanced.html#onscopedispose}
201
+ */
202
+ function onScopeDispose(fn, failSilently = false) {
203
+ if (activeEffectScope) activeEffectScope.cleanups.push(fn);
204
+ else if (!failSilently) warn("onScopeDispose() is called when there is no active effect scope to be associated with.");
205
+ }
206
+ //#endregion
207
+ //#region packages/signal/src/effect.ts
208
+ let activeSub;
209
+ const pausedQueueEffects = /* @__PURE__ */ new WeakSet();
210
+ var ReactiveEffect = class {
211
+ constructor(fn) {
212
+ this.fn = fn;
213
+ this.deps = void 0;
214
+ this.depsTail = void 0;
215
+ this.flags = 5;
216
+ this.next = void 0;
217
+ this.cleanup = void 0;
218
+ this.scheduler = void 0;
219
+ if (activeEffectScope) if (activeEffectScope.active) activeEffectScope.effects.push(this);
220
+ else this.flags &= -2;
221
+ }
222
+ pause() {
223
+ this.flags |= 64;
224
+ }
225
+ resume() {
226
+ if (this.flags & 64) {
227
+ this.flags &= -65;
228
+ if (pausedQueueEffects.has(this)) {
229
+ pausedQueueEffects.delete(this);
230
+ this.trigger();
231
+ }
232
+ }
233
+ }
234
+ /**
235
+ * @internal
236
+ */
237
+ notify() {
238
+ if (this.flags & 2 && !(this.flags & 32)) return;
239
+ if (!(this.flags & 8)) queueSubscriber(this);
240
+ }
241
+ run() {
242
+ if (!(this.flags & 1)) return this.fn();
243
+ this.flags |= 2;
244
+ cleanupEffect(this);
245
+ prepareDeps(this);
246
+ const prevEffect = activeSub;
247
+ const prevShouldTrack = shouldTrack;
248
+ activeSub = this;
249
+ shouldTrack = true;
250
+ try {
251
+ return this.fn();
252
+ } finally {
253
+ if (activeSub !== this) warn("Active effect was not restored correctly - this is likely a Vue internal bug.");
254
+ cleanupDeps(this);
255
+ activeSub = prevEffect;
256
+ shouldTrack = prevShouldTrack;
257
+ this.flags &= -3;
258
+ }
259
+ }
260
+ stop() {
261
+ if (this.flags & 1) {
262
+ for (let link = this.deps; link; link = link.nextDep) removeSub(link);
263
+ this.deps = this.depsTail = void 0;
264
+ cleanupEffect(this);
265
+ this.onStop && this.onStop();
266
+ this.flags &= -2;
267
+ }
268
+ }
269
+ trigger() {
270
+ if (this.flags & 64) pausedQueueEffects.add(this);
271
+ else if (this.scheduler) this.scheduler();
272
+ else this.runIfDirty();
273
+ }
274
+ /**
275
+ * @internal
276
+ */
277
+ runIfDirty() {
278
+ if (isDirty(this)) this.run();
279
+ }
280
+ get dirty() {
281
+ return isDirty(this);
282
+ }
283
+ };
284
+ /**
285
+ * For debugging
286
+ */
287
+ let batchDepth = 0;
288
+ let batchedSub;
289
+ let batchedComputed;
290
+ /**
291
+ * @internal
292
+ */
293
+ function queueSubscriber(sub, isComputed = false) {
294
+ sub.flags |= 8;
295
+ if (isComputed) {
296
+ sub.next = batchedComputed;
297
+ batchedComputed = sub;
298
+ return;
299
+ }
300
+ sub.next = batchedSub;
301
+ batchedSub = sub;
302
+ }
303
+ /**
304
+ * @internal
305
+ */
306
+ function startBatch() {
307
+ batchDepth++;
308
+ }
309
+ /**
310
+ * Run batched effects when all batches have ended
311
+ * @internal
312
+ */
313
+ function endBatch() {
314
+ if (--batchDepth > 0) return;
315
+ if (batchedComputed) {
316
+ let e = batchedComputed;
317
+ batchedComputed = void 0;
318
+ while (e) {
319
+ const next = e.next;
320
+ e.next = void 0;
321
+ e.flags &= -9;
322
+ e = next;
323
+ }
324
+ }
325
+ let error;
326
+ while (batchedSub) {
327
+ let e = batchedSub;
328
+ batchedSub = void 0;
329
+ while (e) {
330
+ const next = e.next;
331
+ e.next = void 0;
332
+ e.flags &= -9;
333
+ if (e.flags & 1) try {
334
+ e.trigger();
335
+ } catch (err) {
336
+ if (!error) error = err;
337
+ }
338
+ e = next;
339
+ }
340
+ }
341
+ if (error) throw error;
342
+ }
343
+ function prepareDeps(sub) {
344
+ for (let link = sub.deps; link; link = link.nextDep) {
345
+ link.version = -1;
346
+ link.prevActiveLink = link.dep.activeLink;
347
+ link.dep.activeLink = link;
348
+ }
349
+ }
350
+ function cleanupDeps(sub) {
351
+ let head;
352
+ let tail = sub.depsTail;
353
+ let link = tail;
354
+ while (link) {
355
+ const prev = link.prevDep;
356
+ if (link.version === -1) {
357
+ if (link === tail) tail = prev;
358
+ removeSub(link);
359
+ removeDep(link);
360
+ } else head = link;
361
+ link.dep.activeLink = link.prevActiveLink;
362
+ link.prevActiveLink = void 0;
363
+ link = prev;
364
+ }
365
+ sub.deps = head;
366
+ sub.depsTail = tail;
367
+ }
368
+ function isDirty(sub) {
369
+ for (let link = sub.deps; link; link = link.nextDep) if (link.dep.version !== link.version || link.dep.computed && (refreshComputed(link.dep.computed) || link.dep.version !== link.version)) return true;
370
+ if (sub._dirty) return true;
371
+ return false;
372
+ }
373
+ /**
374
+ * Returning false indicates the refresh failed
375
+ * @internal
376
+ */
377
+ function refreshComputed(computed) {
378
+ if (computed.flags & 4 && !(computed.flags & 16)) return;
379
+ computed.flags &= -17;
380
+ if (computed.globalVersion === globalVersion) return;
381
+ computed.globalVersion = globalVersion;
382
+ if (!computed.isSSR && computed.flags & 128 && (!computed.deps && !computed._dirty || !isDirty(computed))) return;
383
+ computed.flags |= 2;
384
+ const dep = computed.dep;
385
+ const prevSub = activeSub;
386
+ const prevShouldTrack = shouldTrack;
387
+ activeSub = computed;
388
+ shouldTrack = true;
389
+ try {
390
+ prepareDeps(computed);
391
+ const value = computed.fn(computed._value);
392
+ if (dep.version === 0 || hasChanged(value, computed._value)) {
393
+ computed.flags |= 128;
394
+ computed._value = value;
395
+ dep.version++;
396
+ }
397
+ } catch (err) {
398
+ dep.version++;
399
+ throw err;
400
+ } finally {
401
+ activeSub = prevSub;
402
+ shouldTrack = prevShouldTrack;
403
+ cleanupDeps(computed);
404
+ computed.flags &= -3;
405
+ }
406
+ }
407
+ function removeSub(link, soft = false) {
408
+ const { dep, prevSub, nextSub } = link;
409
+ if (prevSub) {
410
+ prevSub.nextSub = nextSub;
411
+ link.prevSub = void 0;
412
+ }
413
+ if (nextSub) {
414
+ nextSub.prevSub = prevSub;
415
+ link.nextSub = void 0;
416
+ }
417
+ if (dep.subsHead === link) dep.subsHead = nextSub;
418
+ if (dep.subs === link) {
419
+ dep.subs = prevSub;
420
+ if (!prevSub && dep.computed) {
421
+ dep.computed.flags &= -5;
422
+ for (let l = dep.computed.deps; l; l = l.nextDep) removeSub(l, true);
423
+ }
424
+ }
425
+ if (!soft && !--dep.sc && dep.map) dep.map.delete(dep.key);
426
+ }
427
+ function removeDep(link) {
428
+ const { prevDep, nextDep } = link;
429
+ if (prevDep) {
430
+ prevDep.nextDep = nextDep;
431
+ link.prevDep = void 0;
432
+ }
433
+ if (nextDep) {
434
+ nextDep.prevDep = prevDep;
435
+ link.nextDep = void 0;
436
+ }
437
+ }
438
+ function effect(fn, options) {
439
+ if (fn.effect instanceof ReactiveEffect) fn = fn.effect.fn;
440
+ const e = new ReactiveEffect(fn);
441
+ if (options) extend(e, options);
442
+ try {
443
+ e.run();
444
+ } catch (err) {
445
+ e.stop();
446
+ throw err;
447
+ }
448
+ const runner = e.run.bind(e);
449
+ runner.effect = e;
450
+ return runner;
451
+ }
452
+ /**
453
+ * @internal
454
+ */
455
+ let shouldTrack = true;
456
+ const trackStack = [];
457
+ /**
458
+ * Temporarily pauses tracking.
459
+ */
460
+ function pauseTracking() {
461
+ trackStack.push(shouldTrack);
462
+ shouldTrack = false;
463
+ }
464
+ /**
465
+ * Resets the previous global effect tracking state.
466
+ */
467
+ function resetTracking() {
468
+ const last = trackStack.pop();
469
+ shouldTrack = last === void 0 ? true : last;
470
+ }
471
+ /**
472
+ * Registers a cleanup function for the current active effect.
473
+ * The cleanup function is called right before the next effect run, or when the
474
+ * effect is stopped.
475
+ *
476
+ * Throws a warning if there is no current active effect. The warning can be
477
+ * suppressed by passing `true` to the second argument.
478
+ *
479
+ * @param fn - the cleanup function to be registered
480
+ * @param failSilently - if `true`, will not throw warning when called without
481
+ * an active effect.
482
+ */
483
+ function onEffectCleanup(fn, failSilently = false) {
484
+ if (activeSub instanceof ReactiveEffect) activeSub.cleanup = fn;
485
+ else if (!failSilently) warn("onEffectCleanup() was called when there was no active effect to associate with.");
486
+ }
487
+ function cleanupEffect(e) {
488
+ const { cleanup } = e;
489
+ e.cleanup = void 0;
490
+ if (cleanup) {
491
+ const prevSub = activeSub;
492
+ activeSub = void 0;
493
+ try {
494
+ cleanup();
495
+ } finally {
496
+ activeSub = prevSub;
497
+ }
498
+ }
499
+ }
500
+ /**
501
+ * Batches reactive updates synchronously within the given function.
502
+ * All updates triggered inside `fn` are deferred until the function completes,
503
+ * then flushed together in a single batch.
504
+ */
505
+ function batch(fn) {
506
+ startBatch();
507
+ try {
508
+ return fn();
509
+ } finally {
510
+ endBatch();
511
+ }
512
+ }
513
+ /**
514
+ * Executes the given function without tracking reactive dependencies.
515
+ * Any reactive reads inside `fn` will not trigger effect re-runs.
516
+ */
517
+ function untrack(fn) {
518
+ pauseTracking();
519
+ try {
520
+ return fn();
521
+ } finally {
522
+ resetTracking();
523
+ }
524
+ }
525
+ /**
526
+ * Returns the currently executing reactive effect, if any.
527
+ */
528
+ function getCurrentEffect() {
529
+ return activeSub instanceof ReactiveEffect ? activeSub : void 0;
530
+ }
531
+ //#endregion
532
+ //#region packages/signal/src/dep.ts
533
+ /**
534
+ * Incremented every time a reactive change happens
535
+ * This is used to give computed a fast path to avoid re-compute when nothing
536
+ * has changed.
537
+ */
538
+ let globalVersion = 0;
539
+ /**
540
+ * Represents a link between a source (Dep) and a subscriber (Effect or Computed).
541
+ * Deps and subs have a many-to-many relationship - each link between a
542
+ * dep and a sub is represented by a Link instance.
543
+ *
544
+ * A Link is also a node in two doubly-linked lists - one for the associated
545
+ * sub to track all its deps, and one for the associated dep to track all its
546
+ * subs.
547
+ *
548
+ * @internal
549
+ */
550
+ var Link = class {
551
+ constructor(sub, dep) {
552
+ this.sub = sub;
553
+ this.dep = dep;
554
+ this.version = dep.version;
555
+ this.nextDep = this.prevDep = this.nextSub = this.prevSub = this.prevActiveLink = void 0;
556
+ }
557
+ };
558
+ /**
559
+ * @internal
560
+ */
561
+ var Dep = class {
562
+ constructor(computed) {
563
+ this.computed = computed;
564
+ this.version = 0;
565
+ this.activeLink = void 0;
566
+ this.subs = void 0;
567
+ this.map = void 0;
568
+ this.key = void 0;
569
+ this.sc = 0;
570
+ this.__v_skip = true;
571
+ this.subsHead = void 0;
572
+ }
573
+ track(debugInfo) {
574
+ if (!activeSub || !shouldTrack || activeSub === this.computed) return;
575
+ let link = this.activeLink;
576
+ if (link === void 0 || link.sub !== activeSub) {
577
+ link = this.activeLink = new Link(activeSub, this);
578
+ if (!activeSub.deps) activeSub.deps = activeSub.depsTail = link;
579
+ else {
580
+ link.prevDep = activeSub.depsTail;
581
+ activeSub.depsTail.nextDep = link;
582
+ activeSub.depsTail = link;
583
+ }
584
+ addSub(link);
585
+ } else if (link.version === -1) {
586
+ link.version = this.version;
587
+ if (link.nextDep) {
588
+ const next = link.nextDep;
589
+ next.prevDep = link.prevDep;
590
+ if (link.prevDep) link.prevDep.nextDep = next;
591
+ link.prevDep = activeSub.depsTail;
592
+ link.nextDep = void 0;
593
+ activeSub.depsTail.nextDep = link;
594
+ activeSub.depsTail = link;
595
+ if (activeSub.deps === link) activeSub.deps = next;
596
+ }
597
+ }
598
+ if (activeSub.onTrack) activeSub.onTrack(extend({ effect: activeSub }, debugInfo));
599
+ return link;
600
+ }
601
+ trigger(debugInfo) {
602
+ this.version++;
603
+ globalVersion++;
604
+ this.notify(debugInfo);
605
+ }
606
+ notify(debugInfo) {
607
+ startBatch();
608
+ try {
609
+ for (let head = this.subsHead; head; head = head.nextSub) if (head.sub.onTrigger && !(head.sub.flags & 8)) head.sub.onTrigger(extend({ effect: head.sub }, debugInfo));
610
+ for (let link = this.subs; link; link = link.prevSub) if (link.sub.notify()) link.sub.dep.notify();
611
+ } finally {
612
+ endBatch();
613
+ }
614
+ }
615
+ };
616
+ function addSub(link) {
617
+ link.dep.sc++;
618
+ if (link.sub.flags & 4) {
619
+ const computed = link.dep.computed;
620
+ if (computed && !link.dep.subs) {
621
+ computed.flags |= 20;
622
+ for (let l = computed.deps; l; l = l.nextDep) addSub(l);
623
+ }
624
+ const currentTail = link.dep.subs;
625
+ if (currentTail !== link) {
626
+ link.prevSub = currentTail;
627
+ if (currentTail) currentTail.nextSub = link;
628
+ }
629
+ if (link.dep.subsHead === void 0) link.dep.subsHead = link;
630
+ link.dep.subs = link;
631
+ }
632
+ }
633
+ const targetMap = /* @__PURE__ */ new WeakMap();
634
+ const ITERATE_KEY = Symbol("Object iterate");
635
+ const MAP_KEY_ITERATE_KEY = Symbol("Map keys iterate");
636
+ const ARRAY_ITERATE_KEY = Symbol("Array iterate");
637
+ /**
638
+ * Tracks access to a reactive property.
639
+ *
640
+ * This will check which effect is running at the moment and record it as dep
641
+ * which records all effects that depend on the reactive property.
642
+ *
643
+ * @param target - Object holding the reactive property.
644
+ * @param type - Defines the type of access to the reactive property.
645
+ * @param key - Identifier of the reactive property to track.
646
+ */
647
+ function track(target, type, key) {
648
+ if (shouldTrack && activeSub) {
649
+ let depsMap = targetMap.get(target);
650
+ if (!depsMap) targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
651
+ let dep = depsMap.get(key);
652
+ if (!dep) {
653
+ depsMap.set(key, dep = new Dep());
654
+ dep.map = depsMap;
655
+ dep.key = key;
656
+ }
657
+ dep.track({
658
+ target,
659
+ type,
660
+ key
661
+ });
662
+ }
663
+ }
664
+ /**
665
+ * Finds all deps associated with the target (or a specific property) and
666
+ * triggers the effects stored within.
667
+ *
668
+ * @param target - The reactive object.
669
+ * @param type - Defines the type of the operation that needs to trigger effects.
670
+ * @param key - Can be used to target a specific reactive property in the target object.
671
+ */
672
+ function trigger(target, type, key, newValue, oldValue, oldTarget) {
673
+ const depsMap = targetMap.get(target);
674
+ if (!depsMap) {
675
+ globalVersion++;
676
+ return;
677
+ }
678
+ const run = (dep) => {
679
+ if (dep) dep.trigger({
680
+ target,
681
+ type,
682
+ key,
683
+ newValue,
684
+ oldValue,
685
+ oldTarget
686
+ });
687
+ };
688
+ startBatch();
689
+ if (type === "clear") depsMap.forEach(run);
690
+ else {
691
+ const targetIsArray = isArray(target);
692
+ const isArrayIndex = targetIsArray && isIntegerKey(key);
693
+ if (targetIsArray && key === "length") {
694
+ const newLength = Number(newValue);
695
+ depsMap.forEach((dep, key) => {
696
+ if (key === "length" || key === ARRAY_ITERATE_KEY || !isSymbol(key) && key >= newLength) run(dep);
697
+ });
698
+ } else {
699
+ if (key !== void 0 || depsMap.has(void 0)) run(depsMap.get(key));
700
+ if (isArrayIndex) run(depsMap.get(ARRAY_ITERATE_KEY));
701
+ switch (type) {
702
+ case "add":
703
+ if (!targetIsArray) {
704
+ run(depsMap.get(ITERATE_KEY));
705
+ if (isMap(target)) run(depsMap.get(MAP_KEY_ITERATE_KEY));
706
+ } else if (isArrayIndex) run(depsMap.get("length"));
707
+ break;
708
+ case "delete":
709
+ if (!targetIsArray) {
710
+ run(depsMap.get(ITERATE_KEY));
711
+ if (isMap(target)) run(depsMap.get(MAP_KEY_ITERATE_KEY));
712
+ }
713
+ break;
714
+ case "set":
715
+ if (isMap(target)) run(depsMap.get(ITERATE_KEY));
716
+ break;
717
+ }
718
+ }
719
+ }
720
+ endBatch();
721
+ }
722
+ //#endregion
723
+ //#region packages/signal/src/arrayInstrumentations.ts
724
+ /**
725
+ * Track array iteration and return:
726
+ * - if input is reactive: a cloned raw array with reactive values
727
+ * - if input is non-reactive or shallowReactive: the original raw array
728
+ */
729
+ function reactiveReadArray(array) {
730
+ const raw = /* @__PURE__ */ toRaw(array);
731
+ if (raw === array) return raw;
732
+ track(raw, "iterate", ARRAY_ITERATE_KEY);
733
+ return /* @__PURE__ */ isShallow(array) ? raw : raw.map(toReactive);
734
+ }
735
+ /**
736
+ * Track array iteration and return raw array
737
+ */
738
+ function shallowReadArray(arr) {
739
+ track(arr = /* @__PURE__ */ toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
740
+ return arr;
741
+ }
742
+ function toWrapped(target, item) {
743
+ if (/* @__PURE__ */ isReadonly(target)) return /* @__PURE__ */ isReactive(target) ? toReadonly(toReactive(item)) : toReadonly(item);
744
+ return toReactive(item);
745
+ }
746
+ const arrayInstrumentations = {
747
+ __proto__: null,
748
+ [Symbol.iterator]() {
749
+ return iterator(this, Symbol.iterator, (item) => toWrapped(this, item));
750
+ },
751
+ concat(...args) {
752
+ return reactiveReadArray(this).concat(...args.map((x) => isArray(x) ? reactiveReadArray(x) : x));
753
+ },
754
+ entries() {
755
+ return iterator(this, "entries", (value) => {
756
+ value[1] = toWrapped(this, value[1]);
757
+ return value;
758
+ });
759
+ },
760
+ every(fn, thisArg) {
761
+ return apply(this, "every", fn, thisArg, void 0, arguments);
762
+ },
763
+ filter(fn, thisArg) {
764
+ return apply(this, "filter", fn, thisArg, (v) => v.map((item) => toWrapped(this, item)), arguments);
765
+ },
766
+ find(fn, thisArg) {
767
+ return apply(this, "find", fn, thisArg, (item) => toWrapped(this, item), arguments);
768
+ },
769
+ findIndex(fn, thisArg) {
770
+ return apply(this, "findIndex", fn, thisArg, void 0, arguments);
771
+ },
772
+ findLast(fn, thisArg) {
773
+ return apply(this, "findLast", fn, thisArg, (item) => toWrapped(this, item), arguments);
774
+ },
775
+ findLastIndex(fn, thisArg) {
776
+ return apply(this, "findLastIndex", fn, thisArg, void 0, arguments);
777
+ },
778
+ forEach(fn, thisArg) {
779
+ return apply(this, "forEach", fn, thisArg, void 0, arguments);
780
+ },
781
+ includes(...args) {
782
+ return searchProxy(this, "includes", args);
783
+ },
784
+ indexOf(...args) {
785
+ return searchProxy(this, "indexOf", args);
786
+ },
787
+ join(separator) {
788
+ return reactiveReadArray(this).join(separator);
789
+ },
790
+ lastIndexOf(...args) {
791
+ return searchProxy(this, "lastIndexOf", args);
792
+ },
793
+ map(fn, thisArg) {
794
+ return apply(this, "map", fn, thisArg, void 0, arguments);
795
+ },
796
+ pop() {
797
+ return noTracking(this, "pop");
798
+ },
799
+ push(...args) {
800
+ return noTracking(this, "push", args);
801
+ },
802
+ reduce(fn, ...args) {
803
+ return reduce(this, "reduce", fn, args);
804
+ },
805
+ reduceRight(fn, ...args) {
806
+ return reduce(this, "reduceRight", fn, args);
807
+ },
808
+ shift() {
809
+ return noTracking(this, "shift");
810
+ },
811
+ some(fn, thisArg) {
812
+ return apply(this, "some", fn, thisArg, void 0, arguments);
813
+ },
814
+ splice(...args) {
815
+ return noTracking(this, "splice", args);
816
+ },
817
+ toReversed() {
818
+ return reactiveReadArray(this).toReversed();
819
+ },
820
+ toSorted(comparer) {
821
+ return reactiveReadArray(this).toSorted(comparer);
822
+ },
823
+ toSpliced(...args) {
824
+ return reactiveReadArray(this).toSpliced(...args);
825
+ },
826
+ unshift(...args) {
827
+ return noTracking(this, "unshift", args);
828
+ },
829
+ values() {
830
+ return iterator(this, "values", (item) => toWrapped(this, item));
831
+ }
832
+ };
833
+ function iterator(self, method, wrapValue) {
834
+ const arr = shallowReadArray(self);
835
+ const iter = arr[method]();
836
+ if (arr !== self && !/* @__PURE__ */ isShallow(self)) {
837
+ iter._next = iter.next;
838
+ iter.next = () => {
839
+ const result = iter._next();
840
+ if (!result.done) result.value = wrapValue(result.value);
841
+ return result;
842
+ };
843
+ }
844
+ return iter;
845
+ }
846
+ const arrayProto = Array.prototype;
847
+ function apply(self, method, fn, thisArg, wrappedRetFn, args) {
848
+ const arr = shallowReadArray(self);
849
+ const needsWrap = arr !== self && !/* @__PURE__ */ isShallow(self);
850
+ const methodFn = arr[method];
851
+ if (methodFn !== arrayProto[method]) {
852
+ const result = methodFn.apply(self, args);
853
+ return needsWrap ? toReactive(result) : result;
854
+ }
855
+ let wrappedFn = fn;
856
+ if (arr !== self) {
857
+ if (needsWrap) wrappedFn = function(item, index) {
858
+ return fn.call(this, toWrapped(self, item), index, self);
859
+ };
860
+ else if (fn.length > 2) wrappedFn = function(item, index) {
861
+ return fn.call(this, item, index, self);
862
+ };
863
+ }
864
+ const result = methodFn.call(arr, wrappedFn, thisArg);
865
+ return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
866
+ }
867
+ function reduce(self, method, fn, args) {
868
+ const arr = shallowReadArray(self);
869
+ const needsWrap = arr !== self && !/* @__PURE__ */ isShallow(self);
870
+ let wrappedFn = fn;
871
+ let wrapInitialAccumulator = false;
872
+ if (arr !== self) {
873
+ if (needsWrap) {
874
+ wrapInitialAccumulator = args.length === 0;
875
+ wrappedFn = function(acc, item, index) {
876
+ if (wrapInitialAccumulator) {
877
+ wrapInitialAccumulator = false;
878
+ acc = toWrapped(self, acc);
879
+ }
880
+ return fn.call(this, acc, toWrapped(self, item), index, self);
881
+ };
882
+ } else if (fn.length > 3) wrappedFn = function(acc, item, index) {
883
+ return fn.call(this, acc, item, index, self);
884
+ };
885
+ }
886
+ const result = arr[method](wrappedFn, ...args);
887
+ return wrapInitialAccumulator ? toWrapped(self, result) : result;
888
+ }
889
+ function searchProxy(self, method, args) {
890
+ const arr = /* @__PURE__ */ toRaw(self);
891
+ track(arr, "iterate", ARRAY_ITERATE_KEY);
892
+ const res = arr[method](...args);
893
+ if ((res === -1 || res === false) && /* @__PURE__ */ isProxy(args[0])) {
894
+ args[0] = /* @__PURE__ */ toRaw(args[0]);
895
+ return arr[method](...args);
896
+ }
897
+ return res;
898
+ }
899
+ function noTracking(self, method, args = []) {
900
+ pauseTracking();
901
+ startBatch();
902
+ const res = (/* @__PURE__ */ toRaw(self))[method].apply(self, args);
903
+ endBatch();
904
+ resetTracking();
905
+ return res;
906
+ }
907
+ //#endregion
908
+ //#region packages/signal/src/ref.ts
909
+ let _ReactiveFlags$IS_REF, _ReactiveFlags$IS_SHA;
910
+ /*@__NO_SIDE_EFFECTS__*/
911
+ function isRef(r) {
912
+ return r ? r["__v_isRef"] === true : false;
913
+ }
914
+ /*@__NO_SIDE_EFFECTS__*/
915
+ function ref(value) {
916
+ return createRef(value, false);
917
+ }
918
+ function createRef(rawValue, shallow) {
919
+ if (/* @__PURE__ */ isRef(rawValue)) return rawValue;
920
+ return new RefImpl(rawValue, shallow);
921
+ }
922
+ _ReactiveFlags$IS_REF = "__v_isRef";
923
+ _ReactiveFlags$IS_SHA = "__v_isShallow";
924
+ /**
925
+ * @internal
926
+ */
927
+ var RefImpl = class {
928
+ constructor(value, isShallow) {
929
+ this.dep = new Dep();
930
+ this[_ReactiveFlags$IS_REF] = true;
931
+ this[_ReactiveFlags$IS_SHA] = false;
932
+ this._rawValue = isShallow ? value : /* @__PURE__ */ toRaw(value);
933
+ this._value = isShallow ? value : toReactive(value);
934
+ this["__v_isShallow"] = isShallow;
935
+ }
936
+ get value() {
937
+ this.dep.track({
938
+ target: this,
939
+ type: "get",
940
+ key: "value"
941
+ });
942
+ return this._value;
943
+ }
944
+ set value(newValue) {
945
+ const oldValue = this._rawValue;
946
+ const useDirectValue = this["__v_isShallow"] || /* @__PURE__ */ isShallow(newValue) || /* @__PURE__ */ isReadonly(newValue);
947
+ newValue = useDirectValue ? newValue : /* @__PURE__ */ toRaw(newValue);
948
+ if (hasChanged(newValue, oldValue)) {
949
+ this._rawValue = newValue;
950
+ this._value = useDirectValue ? newValue : toReactive(newValue);
951
+ this.dep.trigger({
952
+ target: this,
953
+ type: "set",
954
+ key: "value",
955
+ newValue,
956
+ oldValue
957
+ });
958
+ }
959
+ }
960
+ };
961
+ //#endregion
962
+ //#region packages/signal/src/baseHandlers.ts
963
+ const isNonTrackableKeys = /*@__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
964
+ const builtInSymbols = new Set(/*@__PURE__*/ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol));
965
+ function hasOwnProperty(key) {
966
+ if (!isSymbol(key)) key = String(key);
967
+ const obj = /* @__PURE__ */ toRaw(this);
968
+ track(obj, "has", key);
969
+ return obj.hasOwnProperty(key);
970
+ }
971
+ var BaseReactiveHandler = class {
972
+ constructor(_isReadonly = false, _isShallow = false) {
973
+ this._isReadonly = _isReadonly;
974
+ this._isShallow = _isShallow;
975
+ }
976
+ get(target, key, receiver) {
977
+ if (key === "__v_skip") return target["__v_skip"];
978
+ const isReadonly = this._isReadonly, isShallow = this._isShallow;
979
+ if (key === "__v_isReactive") return !isReadonly;
980
+ else if (key === "__v_isReadonly") return isReadonly;
981
+ else if (key === "__v_isShallow") return isShallow;
982
+ else if (key === "__v_raw") {
983
+ if (receiver === (isReadonly ? isShallow ? shallowReadonlyMap : readonlyMap : isShallow ? shallowReactiveMap : reactiveMap).get(target) || Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) return target;
984
+ return;
985
+ }
986
+ const targetIsArray = isArray(target);
987
+ if (!isReadonly) {
988
+ let fn;
989
+ if (targetIsArray && (fn = arrayInstrumentations[key])) return fn;
990
+ if (key === "hasOwnProperty") return hasOwnProperty;
991
+ }
992
+ const res = Reflect.get(target, key, /* @__PURE__ */ isRef(target) ? target : receiver);
993
+ if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) return res;
994
+ if (!isReadonly) track(target, "get", key);
995
+ if (isShallow) return res;
996
+ if (/* @__PURE__ */ isRef(res)) {
997
+ const value = targetIsArray && isIntegerKey(key) ? res : res.value;
998
+ return isReadonly && isObject(value) ? /* @__PURE__ */ readonly(value) : value;
999
+ }
1000
+ if (isObject(res)) return isReadonly ? /* @__PURE__ */ readonly(res) : /* @__PURE__ */ reactive(res);
1001
+ return res;
1002
+ }
1003
+ };
1004
+ var MutableReactiveHandler = class extends BaseReactiveHandler {
1005
+ constructor(isShallow = false) {
1006
+ super(false, isShallow);
1007
+ }
1008
+ set(target, key, value, receiver) {
1009
+ let oldValue = target[key];
1010
+ const isArrayWithIntegerKey = isArray(target) && isIntegerKey(key);
1011
+ if (!this._isShallow) {
1012
+ const isOldValueReadonly = /* @__PURE__ */ isReadonly(oldValue);
1013
+ if (!/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value)) {
1014
+ oldValue = /* @__PURE__ */ toRaw(oldValue);
1015
+ value = /* @__PURE__ */ toRaw(value);
1016
+ }
1017
+ if (!isArrayWithIntegerKey && /* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value)) if (isOldValueReadonly) {
1018
+ warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target[key]);
1019
+ return true;
1020
+ } else {
1021
+ oldValue.value = value;
1022
+ return true;
1023
+ }
1024
+ }
1025
+ const hadKey = isArrayWithIntegerKey ? Number(key) < target.length : hasOwn(target, key);
1026
+ const result = Reflect.set(target, key, value, /* @__PURE__ */ isRef(target) ? target : receiver);
1027
+ if (target === /* @__PURE__ */ toRaw(receiver)) {
1028
+ if (!hadKey) trigger(target, "add", key, value);
1029
+ else if (hasChanged(value, oldValue)) trigger(target, "set", key, value, oldValue);
1030
+ }
1031
+ return result;
1032
+ }
1033
+ deleteProperty(target, key) {
1034
+ const hadKey = hasOwn(target, key);
1035
+ const oldValue = target[key];
1036
+ const result = Reflect.deleteProperty(target, key);
1037
+ if (result && hadKey) trigger(target, "delete", key, void 0, oldValue);
1038
+ return result;
1039
+ }
1040
+ has(target, key) {
1041
+ const result = Reflect.has(target, key);
1042
+ if (!isSymbol(key) || !builtInSymbols.has(key)) track(target, "has", key);
1043
+ return result;
1044
+ }
1045
+ ownKeys(target) {
1046
+ track(target, "iterate", isArray(target) ? "length" : ITERATE_KEY);
1047
+ return Reflect.ownKeys(target);
1048
+ }
1049
+ };
1050
+ var ReadonlyReactiveHandler = class extends BaseReactiveHandler {
1051
+ constructor(isShallow = false) {
1052
+ super(true, isShallow);
1053
+ }
1054
+ set(target, key) {
1055
+ warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
1056
+ return true;
1057
+ }
1058
+ deleteProperty(target, key) {
1059
+ warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
1060
+ return true;
1061
+ }
1062
+ };
1063
+ const mutableHandlers = /*@__PURE__*/ new MutableReactiveHandler();
1064
+ const readonlyHandlers = /*@__PURE__*/ new ReadonlyReactiveHandler();
1065
+ //#endregion
1066
+ //#region packages/signal/src/collectionHandlers.ts
1067
+ const toShallow = (value) => value;
1068
+ const getProto = (v) => Reflect.getPrototypeOf(v);
1069
+ function createIterableMethod(method, isReadonly, isShallow) {
1070
+ return function(...args) {
1071
+ const target = this["__v_raw"];
1072
+ const rawTarget = /* @__PURE__ */ toRaw(target);
1073
+ const targetIsMap = isMap(rawTarget);
1074
+ const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
1075
+ const isKeyOnly = method === "keys" && targetIsMap;
1076
+ const innerIterator = target[method](...args);
1077
+ const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
1078
+ !isReadonly && track(rawTarget, "iterate", isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
1079
+ return extend(Object.create(innerIterator), { next() {
1080
+ const { value, done } = innerIterator.next();
1081
+ return done ? {
1082
+ value,
1083
+ done
1084
+ } : {
1085
+ value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
1086
+ done
1087
+ };
1088
+ } });
1089
+ };
1090
+ }
1091
+ function createReadonlyMethod(type) {
1092
+ return function(...args) {
1093
+ {
1094
+ const key = args[0] ? `on key "${args[0]}" ` : ``;
1095
+ warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, /* @__PURE__ */ toRaw(this));
1096
+ }
1097
+ return type === "delete" ? false : type === "clear" ? void 0 : this;
1098
+ };
1099
+ }
1100
+ function createInstrumentations(readonly, shallow) {
1101
+ const instrumentations = {
1102
+ get(key) {
1103
+ const target = this["__v_raw"];
1104
+ const rawTarget = /* @__PURE__ */ toRaw(target);
1105
+ const rawKey = /* @__PURE__ */ toRaw(key);
1106
+ if (!readonly) {
1107
+ if (hasChanged(key, rawKey)) track(rawTarget, "get", key);
1108
+ track(rawTarget, "get", rawKey);
1109
+ }
1110
+ const { has } = getProto(rawTarget);
1111
+ const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
1112
+ if (has.call(rawTarget, key)) return wrap(target.get(key));
1113
+ else if (has.call(rawTarget, rawKey)) return wrap(target.get(rawKey));
1114
+ else if (target !== rawTarget) target.get(key);
1115
+ },
1116
+ get size() {
1117
+ const target = this["__v_raw"];
1118
+ !readonly && track(/* @__PURE__ */ toRaw(target), "iterate", ITERATE_KEY);
1119
+ return target.size;
1120
+ },
1121
+ has(key) {
1122
+ const target = this["__v_raw"];
1123
+ const rawTarget = /* @__PURE__ */ toRaw(target);
1124
+ const rawKey = /* @__PURE__ */ toRaw(key);
1125
+ if (!readonly) {
1126
+ if (hasChanged(key, rawKey)) track(rawTarget, "has", key);
1127
+ track(rawTarget, "has", rawKey);
1128
+ }
1129
+ return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
1130
+ },
1131
+ forEach(callback, thisArg) {
1132
+ const observed = this;
1133
+ const target = observed["__v_raw"];
1134
+ const rawTarget = /* @__PURE__ */ toRaw(target);
1135
+ const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
1136
+ !readonly && track(rawTarget, "iterate", ITERATE_KEY);
1137
+ return target.forEach((value, key) => {
1138
+ return callback.call(thisArg, wrap(value), wrap(key), observed);
1139
+ });
1140
+ }
1141
+ };
1142
+ extend(instrumentations, readonly ? {
1143
+ add: createReadonlyMethod("add"),
1144
+ set: createReadonlyMethod("set"),
1145
+ delete: createReadonlyMethod("delete"),
1146
+ clear: createReadonlyMethod("clear")
1147
+ } : {
1148
+ add(value) {
1149
+ const target = /* @__PURE__ */ toRaw(this);
1150
+ const proto = getProto(target);
1151
+ const rawValue = /* @__PURE__ */ toRaw(value);
1152
+ const valueToAdd = !shallow && !/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value) ? rawValue : value;
1153
+ if (!(proto.has.call(target, valueToAdd) || hasChanged(value, valueToAdd) && proto.has.call(target, value) || hasChanged(rawValue, valueToAdd) && proto.has.call(target, rawValue))) {
1154
+ target.add(valueToAdd);
1155
+ trigger(target, "add", valueToAdd, valueToAdd);
1156
+ }
1157
+ return this;
1158
+ },
1159
+ set(key, value) {
1160
+ if (!shallow && !/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value)) value = /* @__PURE__ */ toRaw(value);
1161
+ const target = /* @__PURE__ */ toRaw(this);
1162
+ const { has, get } = getProto(target);
1163
+ let hadKey = has.call(target, key);
1164
+ if (!hadKey) {
1165
+ key = /* @__PURE__ */ toRaw(key);
1166
+ hadKey = has.call(target, key);
1167
+ } else checkIdentityKeys(target, has, key);
1168
+ const oldValue = get.call(target, key);
1169
+ target.set(key, value);
1170
+ if (!hadKey) trigger(target, "add", key, value);
1171
+ else if (hasChanged(value, oldValue)) trigger(target, "set", key, value, oldValue);
1172
+ return this;
1173
+ },
1174
+ delete(key) {
1175
+ const target = /* @__PURE__ */ toRaw(this);
1176
+ const { has, get } = getProto(target);
1177
+ let hadKey = has.call(target, key);
1178
+ if (!hadKey) {
1179
+ key = /* @__PURE__ */ toRaw(key);
1180
+ hadKey = has.call(target, key);
1181
+ } else checkIdentityKeys(target, has, key);
1182
+ const oldValue = get ? get.call(target, key) : void 0;
1183
+ const result = target.delete(key);
1184
+ if (hadKey) trigger(target, "delete", key, void 0, oldValue);
1185
+ return result;
1186
+ },
1187
+ clear() {
1188
+ const target = /* @__PURE__ */ toRaw(this);
1189
+ const hadItems = target.size !== 0;
1190
+ const oldTarget = isMap(target) ? new Map(target) : new Set(target);
1191
+ const result = target.clear();
1192
+ if (hadItems) trigger(target, "clear", void 0, void 0, oldTarget);
1193
+ return result;
1194
+ }
1195
+ });
1196
+ [
1197
+ "keys",
1198
+ "values",
1199
+ "entries",
1200
+ Symbol.iterator
1201
+ ].forEach((method) => {
1202
+ instrumentations[method] = createIterableMethod(method, readonly, shallow);
1203
+ });
1204
+ return instrumentations;
1205
+ }
1206
+ function createInstrumentationGetter(isReadonly, shallow) {
1207
+ const instrumentations = createInstrumentations(isReadonly, shallow);
1208
+ return (target, key, receiver) => {
1209
+ if (key === "__v_isReactive") return !isReadonly;
1210
+ else if (key === "__v_isReadonly") return isReadonly;
1211
+ else if (key === "__v_raw") return target;
1212
+ return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver);
1213
+ };
1214
+ }
1215
+ const mutableCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(false, false) };
1216
+ const readonlyCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(true, false) };
1217
+ function checkIdentityKeys(target, has, key) {
1218
+ const rawKey = /* @__PURE__ */ toRaw(key);
1219
+ if (rawKey !== key && has.call(target, rawKey)) {
1220
+ const type = toRawType(target);
1221
+ warn(`Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`);
1222
+ }
1223
+ }
1224
+ //#endregion
1225
+ //#region packages/signal/src/reactive.ts
1226
+ const reactiveMap = /* @__PURE__ */ new WeakMap();
1227
+ const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
1228
+ const readonlyMap = /* @__PURE__ */ new WeakMap();
1229
+ const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
1230
+ function targetTypeMap(rawType) {
1231
+ switch (rawType) {
1232
+ case "Object":
1233
+ case "Array": return 1;
1234
+ case "Map":
1235
+ case "Set":
1236
+ case "WeakMap":
1237
+ case "WeakSet": return 2;
1238
+ default: return 0;
1239
+ }
1240
+ }
1241
+ function getTargetType(value) {
1242
+ return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
1243
+ }
1244
+ /*@__NO_SIDE_EFFECTS__*/
1245
+ function reactive(target) {
1246
+ if (/* @__PURE__ */ isReadonly(target)) return target;
1247
+ return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
1248
+ }
1249
+ /**
1250
+ * Takes an object (reactive or plain) or a ref and returns a readonly proxy to
1251
+ * the original.
1252
+ *
1253
+ * A readonly proxy is deep: any nested property accessed will be readonly as
1254
+ * well. It also has the same ref-unwrapping behavior as {@link reactive},
1255
+ * except the unwrapped values will also be made readonly.
1256
+ *
1257
+ * @example
1258
+ * ```js
1259
+ * const original = reactive({ count: 0 })
1260
+ *
1261
+ * const copy = readonly(original)
1262
+ *
1263
+ * watchEffect(() => {
1264
+ * // works for reactivity tracking
1265
+ * console.log(copy.count)
1266
+ * })
1267
+ *
1268
+ * // mutating original will trigger watchers relying on the copy
1269
+ * original.count++
1270
+ *
1271
+ * // mutating the copy will fail and result in a warning
1272
+ * copy.count++ // warning!
1273
+ * ```
1274
+ *
1275
+ * @param target - The source object.
1276
+ * @see {@link https://vuejs.org/api/reactivity-core.html#readonly}
1277
+ */
1278
+ /*@__NO_SIDE_EFFECTS__*/
1279
+ function readonly(target) {
1280
+ return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
1281
+ }
1282
+ function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) {
1283
+ if (!isObject(target)) {
1284
+ warn(`value cannot be made ${isReadonly ? "readonly" : "reactive"}: ${String(target)}`);
1285
+ return target;
1286
+ }
1287
+ if (target["__v_raw"] && !(isReadonly && target["__v_isReactive"])) return target;
1288
+ const targetType = getTargetType(target);
1289
+ if (targetType === 0) return target;
1290
+ const existingProxy = proxyMap.get(target);
1291
+ if (existingProxy) return existingProxy;
1292
+ const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
1293
+ proxyMap.set(target, proxy);
1294
+ return proxy;
1295
+ }
1296
+ /**
1297
+ * Checks if an object is a proxy created by {@link reactive} or
1298
+ * {@link shallowReactive} (or {@link ref} in some cases).
1299
+ *
1300
+ * @example
1301
+ * ```js
1302
+ * isReactive(reactive({})) // => true
1303
+ * isReactive(readonly(reactive({}))) // => true
1304
+ * isReactive(ref({}).value) // => true
1305
+ * isReactive(readonly(ref({})).value) // => true
1306
+ * isReactive(ref(true)) // => false
1307
+ * isReactive(shallowRef({}).value) // => false
1308
+ * isReactive(shallowReactive({})) // => true
1309
+ * ```
1310
+ *
1311
+ * @param value - The value to check.
1312
+ * @see {@link https://vuejs.org/api/reactivity-utilities.html#isreactive}
1313
+ */
1314
+ /*@__NO_SIDE_EFFECTS__*/
1315
+ function isReactive(value) {
1316
+ if (/* @__PURE__ */ isReadonly(value)) return /* @__PURE__ */ isReactive(value["__v_raw"]);
1317
+ return !!(value && value["__v_isReactive"]);
1318
+ }
1319
+ /**
1320
+ * Checks whether the passed value is a readonly object. The properties of a
1321
+ * readonly object can change, but they can't be assigned directly via the
1322
+ * passed object.
1323
+ *
1324
+ * The proxies created by {@link readonly} and {@link shallowReadonly} are
1325
+ * both considered readonly, as is a computed ref without a set function.
1326
+ *
1327
+ * @param value - The value to check.
1328
+ * @see {@link https://vuejs.org/api/reactivity-utilities.html#isreadonly}
1329
+ */
1330
+ /*@__NO_SIDE_EFFECTS__*/
1331
+ function isReadonly(value) {
1332
+ return !!(value && value["__v_isReadonly"]);
1333
+ }
1334
+ /*@__NO_SIDE_EFFECTS__*/
1335
+ function isShallow(value) {
1336
+ return !!(value && value["__v_isShallow"]);
1337
+ }
1338
+ /**
1339
+ * Checks if an object is a proxy created by {@link reactive},
1340
+ * {@link readonly}, {@link shallowReactive} or {@link shallowReadonly}.
1341
+ *
1342
+ * @param value - The value to check.
1343
+ * @see {@link https://vuejs.org/api/reactivity-utilities.html#isproxy}
1344
+ */
1345
+ /*@__NO_SIDE_EFFECTS__*/
1346
+ function isProxy(value) {
1347
+ return value ? !!value["__v_raw"] : false;
1348
+ }
1349
+ /**
1350
+ * Returns the raw, original object of a Vue-created proxy.
1351
+ *
1352
+ * `toRaw()` can return the original object from proxies created by
1353
+ * {@link reactive}, {@link readonly}, {@link shallowReactive} or
1354
+ * {@link shallowReadonly}.
1355
+ *
1356
+ * This is an escape hatch that can be used to temporarily read without
1357
+ * incurring proxy access / tracking overhead or write without triggering
1358
+ * changes. It is **not** recommended to hold a persistent reference to the
1359
+ * original object. Use with caution.
1360
+ *
1361
+ * @example
1362
+ * ```js
1363
+ * const foo = {}
1364
+ * const reactiveFoo = reactive(foo)
1365
+ *
1366
+ * console.log(toRaw(reactiveFoo) === foo) // true
1367
+ * ```
1368
+ *
1369
+ * @param observed - The object for which the "raw" value is requested.
1370
+ * @see {@link https://vuejs.org/api/reactivity-advanced.html#toraw}
1371
+ */
1372
+ /*@__NO_SIDE_EFFECTS__*/
1373
+ function toRaw(observed) {
1374
+ const raw = observed && observed["__v_raw"];
1375
+ return raw ? /* @__PURE__ */ toRaw(raw) : observed;
1376
+ }
1377
+ /**
1378
+ * Returns a reactive proxy of the given value (if possible).
1379
+ *
1380
+ * If the given value is not an object, the original value itself is returned.
1381
+ *
1382
+ * @param value - The value for which a reactive proxy shall be created.
1383
+ */
1384
+ const toReactive = (value) => isObject(value) ? /* @__PURE__ */ reactive(value) : value;
1385
+ /**
1386
+ * Returns a readonly proxy of the given value (if possible).
1387
+ *
1388
+ * If the given value is not an object, the original value itself is returned.
1389
+ *
1390
+ * @param value - The value for which a readonly proxy shall be created.
1391
+ */
1392
+ const toReadonly = (value) => isObject(value) ? /* @__PURE__ */ readonly(value) : value;
1393
+ //#endregion
1394
+ //#region packages/signal/src/state.ts
1395
+ function state(value) {
1396
+ if (arguments.length === 0) return /* @__PURE__ */ ref();
1397
+ return isProxyable(value) ? /* @__PURE__ */ reactive(value) : /* @__PURE__ */ ref(value);
1398
+ }
1399
+ function isProxyable(value) {
1400
+ if (value === null || typeof value !== "object") return false;
1401
+ if (Array.isArray(value)) return true;
1402
+ if (value instanceof Map || value instanceof Set || value instanceof WeakMap || value instanceof WeakSet) return true;
1403
+ return isPlainObject(value);
1404
+ }
1405
+ function isPlainObject(value) {
1406
+ const proto = Object.getPrototypeOf(value);
1407
+ return proto === Object.prototype || proto === null;
1408
+ }
1409
+ //#endregion
1410
+ //#region packages/signal/src/computed.ts
1411
+ /**
1412
+ * @private exported by @vue/reactivity for Vue core use, but not exported from
1413
+ * the main vue package
1414
+ */
1415
+ var ComputedRefImpl = class {
1416
+ constructor(fn, setter, isSSR) {
1417
+ this.fn = fn;
1418
+ this.setter = setter;
1419
+ this._value = void 0;
1420
+ this.dep = new Dep(this);
1421
+ this.__v_isRef = true;
1422
+ this.deps = void 0;
1423
+ this.depsTail = void 0;
1424
+ this.flags = 16;
1425
+ this.globalVersion = globalVersion - 1;
1426
+ this.next = void 0;
1427
+ this.effect = this;
1428
+ this["__v_isReadonly"] = !setter;
1429
+ this.isSSR = isSSR;
1430
+ }
1431
+ /**
1432
+ * @internal
1433
+ */
1434
+ notify() {
1435
+ this.flags |= 16;
1436
+ if (!(this.flags & 8) && activeSub !== this) {
1437
+ queueSubscriber(this, true);
1438
+ return true;
1439
+ }
1440
+ }
1441
+ get value() {
1442
+ const link = this.dep.track({
1443
+ target: this,
1444
+ type: "get",
1445
+ key: "value"
1446
+ });
1447
+ refreshComputed(this);
1448
+ if (link) link.version = this.dep.version;
1449
+ return this._value;
1450
+ }
1451
+ set value(newValue) {
1452
+ if (this.setter) this.setter(newValue);
1453
+ else warn("Write operation failed: computed value is readonly");
1454
+ }
1455
+ };
1456
+ /*@__NO_SIDE_EFFECTS__*/
1457
+ function computed(getterOrOptions, debugOptions, isSSR = false) {
1458
+ let getter;
1459
+ let setter;
1460
+ if (isFunction(getterOrOptions)) getter = getterOrOptions;
1461
+ else {
1462
+ getter = getterOrOptions.get;
1463
+ setter = getterOrOptions.set;
1464
+ }
1465
+ const cRef = new ComputedRefImpl(getter, setter, isSSR);
1466
+ if (debugOptions && !isSSR) {
1467
+ cRef.onTrack = debugOptions.onTrack;
1468
+ cRef.onTrigger = debugOptions.onTrigger;
1469
+ }
1470
+ return cRef;
1471
+ }
1472
+ //#endregion
1473
+ //#region packages/signal/src/scheduler.ts
1474
+ function nextTick() {
1475
+ return Promise.resolve();
1476
+ }
1477
+ //#endregion
1478
+ //#region packages/signal/src/watch.ts
1479
+ const INITIAL_WATCHER_VALUE = {};
1480
+ const cleanupMap = /* @__PURE__ */ new WeakMap();
1481
+ let activeWatcher = void 0;
1482
+ /**
1483
+ * Registers a cleanup callback on the current active effect. This
1484
+ * registered cleanup callback will be invoked right before the
1485
+ * associated effect re-runs.
1486
+ *
1487
+ * @param cleanupFn - The callback function to attach to the effect's cleanup.
1488
+ * @param failSilently - if `true`, will not throw warning when called without
1489
+ * an active effect.
1490
+ * @param owner - The effect that this cleanup function should be attached to.
1491
+ * By default, the current active effect.
1492
+ */
1493
+ function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
1494
+ if (owner) {
1495
+ let cleanups = cleanupMap.get(owner);
1496
+ if (!cleanups) cleanupMap.set(owner, cleanups = []);
1497
+ cleanups.push(cleanupFn);
1498
+ } else if (!failSilently) warn("onWatcherCleanup() was called when there was no active watcher to associate with.");
1499
+ }
1500
+ function watch(source, cb, options = EMPTY_OBJ) {
1501
+ const { immediate, deep, once, scheduler, augmentJob, call } = options;
1502
+ const warnInvalidSource = (s) => {
1503
+ (options.onWarn || warn)(`Invalid watch source: `, s, "A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.");
1504
+ };
1505
+ const reactiveGetter = (source) => {
1506
+ if (deep) return source;
1507
+ if (/* @__PURE__ */ isShallow(source) || deep === false || deep === 0) return traverse(source, 1);
1508
+ return traverse(source);
1509
+ };
1510
+ let effect;
1511
+ let getter;
1512
+ let cleanup;
1513
+ let boundCleanup;
1514
+ let forceTrigger = false;
1515
+ let isMultiSource = false;
1516
+ if (/* @__PURE__ */ isRef(source)) {
1517
+ getter = () => source.value;
1518
+ forceTrigger = /* @__PURE__ */ isShallow(source);
1519
+ } else if (/* @__PURE__ */ isReactive(source)) {
1520
+ getter = () => reactiveGetter(source);
1521
+ forceTrigger = true;
1522
+ } else if (isArray(source)) {
1523
+ isMultiSource = true;
1524
+ forceTrigger = source.some((s) => /* @__PURE__ */ isReactive(s) || /* @__PURE__ */ isShallow(s));
1525
+ getter = () => source.map((s) => {
1526
+ if (/* @__PURE__ */ isRef(s)) return s.value;
1527
+ else if (/* @__PURE__ */ isReactive(s)) return reactiveGetter(s);
1528
+ else if (isFunction(s)) return call ? call(s, 2) : s();
1529
+ else warnInvalidSource(s);
1530
+ });
1531
+ } else if (isFunction(source)) if (cb) getter = call ? () => call(source, 2) : source;
1532
+ else getter = () => {
1533
+ if (cleanup) {
1534
+ pauseTracking();
1535
+ try {
1536
+ cleanup();
1537
+ } finally {
1538
+ resetTracking();
1539
+ }
1540
+ }
1541
+ const currentEffect = activeWatcher;
1542
+ activeWatcher = effect;
1543
+ try {
1544
+ return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
1545
+ } finally {
1546
+ activeWatcher = currentEffect;
1547
+ }
1548
+ };
1549
+ else {
1550
+ getter = NOOP;
1551
+ warnInvalidSource(source);
1552
+ }
1553
+ if (cb && deep) {
1554
+ const baseGetter = getter;
1555
+ const depth = deep === true ? Infinity : deep;
1556
+ getter = () => traverse(baseGetter(), depth);
1557
+ }
1558
+ const scope = getCurrentScope();
1559
+ const watchHandle = () => {
1560
+ effect.stop();
1561
+ if (scope && scope.active) remove(scope.effects, effect);
1562
+ };
1563
+ if (once && cb) {
1564
+ const _cb = cb;
1565
+ cb = (...args) => {
1566
+ _cb(...args);
1567
+ watchHandle();
1568
+ };
1569
+ }
1570
+ let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
1571
+ const job = (immediateFirstRun) => {
1572
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) return;
1573
+ if (cb) {
1574
+ const newValue = effect.run();
1575
+ if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
1576
+ if (cleanup) cleanup();
1577
+ const currentWatcher = activeWatcher;
1578
+ activeWatcher = effect;
1579
+ try {
1580
+ const args = [
1581
+ newValue,
1582
+ oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
1583
+ boundCleanup
1584
+ ];
1585
+ oldValue = newValue;
1586
+ call ? call(cb, 3, args) : cb(...args);
1587
+ } finally {
1588
+ activeWatcher = currentWatcher;
1589
+ }
1590
+ }
1591
+ } else effect.run();
1592
+ };
1593
+ if (augmentJob) augmentJob(job);
1594
+ effect = new ReactiveEffect(getter);
1595
+ effect.scheduler = scheduler ? () => scheduler(job, false) : job;
1596
+ boundCleanup = (fn) => onWatcherCleanup(fn, false, effect);
1597
+ cleanup = effect.onStop = () => {
1598
+ const cleanups = cleanupMap.get(effect);
1599
+ if (cleanups) {
1600
+ if (call) call(cleanups, 4);
1601
+ else for (const cleanup of cleanups) cleanup();
1602
+ cleanupMap.delete(effect);
1603
+ }
1604
+ };
1605
+ effect.onTrack = options.onTrack;
1606
+ effect.onTrigger = options.onTrigger;
1607
+ if (cb) if (immediate) job(true);
1608
+ else oldValue = effect.run();
1609
+ else if (scheduler) scheduler(job.bind(null, true), true);
1610
+ else effect.run();
1611
+ watchHandle.pause = effect.pause.bind(effect);
1612
+ watchHandle.resume = effect.resume.bind(effect);
1613
+ watchHandle.stop = watchHandle;
1614
+ return watchHandle;
1615
+ }
1616
+ function traverse(value, depth = Infinity, seen) {
1617
+ if (depth <= 0 || !isObject(value) || value["__v_skip"]) return value;
1618
+ seen = seen || /* @__PURE__ */ new Map();
1619
+ if ((seen.get(value) || 0) >= depth) return value;
1620
+ seen.set(value, depth);
1621
+ depth--;
1622
+ if (/* @__PURE__ */ isRef(value)) traverse(value.value, depth, seen);
1623
+ else if (isArray(value)) for (let i = 0; i < value.length; i++) traverse(value[i], depth, seen);
1624
+ else if (isSet(value) || isMap(value)) value.forEach((v) => {
1625
+ traverse(v, depth, seen);
1626
+ });
1627
+ else if (isPlainObject$1(value)) {
1628
+ for (const key in value) traverse(value[key], depth, seen);
1629
+ for (const key of Object.getOwnPropertySymbols(value)) if (Object.prototype.propertyIsEnumerable.call(value, key)) traverse(value[key], depth, seen);
1630
+ }
1631
+ return value;
1632
+ }
1633
+ //#endregion
1634
+ //#region packages/signal/src/lifecycle.ts
1635
+ function onCleanup(fn) {
1636
+ if (getCurrentEffect()) {
1637
+ onEffectCleanup(fn, true);
1638
+ return;
1639
+ }
1640
+ if (getCurrentScope()) {
1641
+ onScopeDispose(fn, true);
1642
+ return;
1643
+ }
1644
+ warn("onCleanup() was called without active effect or scope.");
1645
+ }
1646
+ //#endregion
1647
+ //#region packages/runtime-dom/src/hostContext.ts
1648
+ let currentHostContext;
1649
+ function getCurrentHostContext() {
1650
+ return currentHostContext;
1651
+ }
1652
+ function withHostContext(context, fn) {
1653
+ const previous = currentHostContext;
1654
+ currentHostContext = context;
1655
+ try {
1656
+ return fn();
1657
+ } finally {
1658
+ currentHostContext = previous;
1659
+ }
1660
+ }
1661
+ //#endregion
1662
+ //#region packages/runtime-dom/src/range.ts
1663
+ function insertTracked(parent, value, marker) {
1664
+ if (value === void 0 || value == null || value === false || value === true) return [];
1665
+ if (Array.isArray(value)) {
1666
+ const nodes = [];
1667
+ for (const item of value) nodes.push(...insertTracked(parent, item, marker));
1668
+ return nodes;
1669
+ }
1670
+ const node = value instanceof Node ? value : document.createTextNode(String(value));
1671
+ parent.insertBefore(node, marker);
1672
+ return [node];
1673
+ }
1674
+ //#endregion
1675
+ //#region packages/runtime-dom/src/insert.ts
1676
+ function insert(parent, value, marker = null) {
1677
+ if (value === void 0) {
1678
+ console.warn("[Zeus runtime] insert received `undefined`, which is ignored. Use `null` or a fallback value explicitly if you want to suppress this warning.");
1679
+ return;
1680
+ }
1681
+ insertTracked(parent, value, marker);
1682
+ }
1683
+ //#endregion
1684
+ //#region packages/runtime-dom/src/context.ts
1685
+ let currentOwner;
1686
+ function createOwner(parent = currentOwner) {
1687
+ return {
1688
+ parent,
1689
+ provides: /* @__PURE__ */ new Map()
1690
+ };
1691
+ }
1692
+ function runWithOwner(owner, fn) {
1693
+ const previous = currentOwner;
1694
+ currentOwner = owner;
1695
+ try {
1696
+ return fn();
1697
+ } finally {
1698
+ currentOwner = previous;
1699
+ }
1700
+ }
1701
+ function createContext(defaultValue) {
1702
+ const hasDefaultValue = arguments.length > 0;
1703
+ const context = {
1704
+ id: Symbol("ZeusContext"),
1705
+ defaultValue,
1706
+ hasDefaultValue,
1707
+ Provider(props) {
1708
+ const owner = createOwner(currentOwner);
1709
+ owner.provides.set(context.id, props.value);
1710
+ return runWithOwner(owner, () => {
1711
+ const children = resolveValue$3(props.children);
1712
+ if (props.bridge) return createDOMContextBoundary(context, props.value, children);
1713
+ return children;
1714
+ });
1715
+ },
1716
+ Bridge(props) {
1717
+ return createDOMContextBoundary(context, props.value, resolveValue$3(props.children));
1718
+ }
1719
+ };
1720
+ return context;
1721
+ }
1722
+ function provide(context, value) {
1723
+ const owner = currentOwner;
1724
+ if (!owner) {
1725
+ console.warn("[Zeus context] provide() was called without an active component owner.");
1726
+ return;
1727
+ }
1728
+ owner.provides.set(context.id, value);
1729
+ }
1730
+ function inject(context, fallback) {
1731
+ let owner = currentOwner;
1732
+ while (owner) {
1733
+ if (owner.provides.has(context.id)) return owner.provides.get(context.id);
1734
+ owner = owner.parent;
1735
+ }
1736
+ if (arguments.length >= 2) return fallback;
1737
+ if (context.hasDefaultValue) return context.defaultValue;
1738
+ throw new Error(`[Zeus context] No provider found for context.`);
1739
+ }
1740
+ function useContext(context, fallback) {
1741
+ if (arguments.length >= 2) return inject(context, fallback);
1742
+ return inject(context);
1743
+ }
1744
+ const ZEUS_CONTEXT_REQUEST = "zeus:context-request";
1745
+ /**
1746
+ * Creates a transparent DOM element that acts as a context boundary.
1747
+ * Native custom elements inside it can use `requestDOMContext` to receive
1748
+ * context values via the DOM event protocol.
1749
+ */
1750
+ function createDOMContextBoundary(context, value, children) {
1751
+ const boundary = document.createElement("zeus-context");
1752
+ boundary.style.cssText = "display:contents;position:unset;width:0;height:0;overflow:hidden";
1753
+ provideDOMContext(boundary, context, value);
1754
+ insert(boundary, children);
1755
+ return boundary;
1756
+ }
1757
+ /**
1758
+ * Registers a context value on a DOM target so that any descendant custom
1759
+ * element can pick it up via `requestDOMContext`.
1760
+ */
1761
+ function provideDOMContext(target, context, value) {
1762
+ const handler = (event) => {
1763
+ const request = event;
1764
+ if (request.type !== "zeus:context-request") return;
1765
+ if (request.detail.id !== context.id) return;
1766
+ request.stopPropagation();
1767
+ request.detail.resolve(value);
1768
+ };
1769
+ target.addEventListener(ZEUS_CONTEXT_REQUEST, handler);
1770
+ onScopeDispose(() => {
1771
+ target.removeEventListener(ZEUS_CONTEXT_REQUEST, handler);
1772
+ }, true);
1773
+ }
1774
+ /**
1775
+ * Internal precise DOM context resolver.
1776
+ *
1777
+ * Unlike requestDOMContext(), this can distinguish:
1778
+ * - found: false, value: undefined
1779
+ * - found: true, value: undefined
1780
+ */
1781
+ function resolveDOMContext(host, context) {
1782
+ let found = false;
1783
+ let value;
1784
+ const event = new CustomEvent(ZEUS_CONTEXT_REQUEST, {
1785
+ bubbles: true,
1786
+ composed: true,
1787
+ cancelable: true,
1788
+ detail: {
1789
+ id: context.id,
1790
+ resolved: false,
1791
+ value: void 0,
1792
+ resolve(nextValue) {
1793
+ found = true;
1794
+ value = nextValue;
1795
+ this.resolved = true;
1796
+ this.value = nextValue;
1797
+ }
1798
+ }
1799
+ });
1800
+ host.dispatchEvent(event);
1801
+ return {
1802
+ found,
1803
+ value
1804
+ };
1805
+ }
1806
+ function resolveValue$3(value) {
1807
+ return typeof value === "function" ? value() : value !== null && value !== void 0 ? value : null;
1808
+ }
1809
+ //#endregion
1810
+ //#region packages/runtime-dom/src/devtools.ts
1811
+ function emitDevtoolsEvent(event) {
1812
+ var _window$__ZEUS_DEVTOO;
1813
+ if (typeof window === "undefined") return;
1814
+ (_window$__ZEUS_DEVTOO = window.__ZEUS_DEVTOOLS_HOOK__) === null || _window$__ZEUS_DEVTOO === void 0 || _window$__ZEUS_DEVTOO.emit(event);
1815
+ }
1816
+ //#endregion
1817
+ //#region packages/runtime-dom/src/render.ts
1818
+ function render(value, container, options = {}) {
1819
+ var _options$owner;
1820
+ const renderScope = effectScope();
1821
+ const owner = (_options$owner = options.owner) !== null && _options$owner !== void 0 ? _options$owner : createOwner();
1822
+ renderScope.run(() => {
1823
+ container.textContent = "";
1824
+ runWithOwner(owner, () => {
1825
+ insert(container, resolveValue$2(value));
1826
+ });
1827
+ });
1828
+ emitDevtoolsEvent({
1829
+ type: "render",
1830
+ target: container
1831
+ });
1832
+ let disposed = false;
1833
+ return () => {
1834
+ if (disposed) return;
1835
+ disposed = true;
1836
+ renderScope.stop();
1837
+ container.textContent = "";
1838
+ };
1839
+ }
1840
+ function resolveValue$2(value) {
1841
+ return typeof value === "function" ? value() : value !== null && value !== void 0 ? value : null;
1842
+ }
1843
+ //#endregion
1844
+ //#region packages/runtime-dom/src/component.ts
1845
+ function createComponent(component, props) {
1846
+ return runWithOwner(createOwner(), () => component(props));
1847
+ }
1848
+ //#endregion
1849
+ //#region packages/runtime-dom/src/controlFlow.ts
1850
+ function Show(props) {
1851
+ return resolveValue$1(props.when ? props.children : props.fallback);
1852
+ }
1853
+ function resolveValue$1(value) {
1854
+ if (typeof value === "function") return value();
1855
+ return value !== null && value !== void 0 ? value : null;
1856
+ }
1857
+ function For(props) {
1858
+ var _props$each$map, _props$each;
1859
+ return (_props$each$map = (_props$each = props.each) === null || _props$each === void 0 ? void 0 : _props$each.map((item, index) => props.children(item, index))) !== null && _props$each$map !== void 0 ? _props$each$map : null;
1860
+ }
1861
+ //#endregion
1862
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
1863
+ function _typeof(o) {
1864
+ "@babel/helpers - typeof";
1865
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
1866
+ return typeof o;
1867
+ } : function(o) {
1868
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
1869
+ }, _typeof(o);
1870
+ }
1871
+ //#endregion
1872
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
1873
+ function toPrimitive(t, r) {
1874
+ if ("object" != _typeof(t) || !t) return t;
1875
+ var e = t[Symbol.toPrimitive];
1876
+ if (void 0 !== e) {
1877
+ var i = e.call(t, r || "default");
1878
+ if ("object" != _typeof(i)) return i;
1879
+ throw new TypeError("@@toPrimitive must return a primitive value.");
1880
+ }
1881
+ return ("string" === r ? String : Number)(t);
1882
+ }
1883
+ //#endregion
1884
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
1885
+ function toPropertyKey(t) {
1886
+ var i = toPrimitive(t, "string");
1887
+ return "symbol" == _typeof(i) ? i : i + "";
1888
+ }
1889
+ //#endregion
1890
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
1891
+ function _defineProperty(e, r, t) {
1892
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
1893
+ value: t,
1894
+ enumerable: !0,
1895
+ configurable: !0,
1896
+ writable: !0
1897
+ }) : e[r] = t, e;
1898
+ }
1899
+ //#endregion
1900
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/objectSpread2.js
1901
+ function ownKeys(e, r) {
1902
+ var t = Object.keys(e);
1903
+ if (Object.getOwnPropertySymbols) {
1904
+ var o = Object.getOwnPropertySymbols(e);
1905
+ r && (o = o.filter(function(r) {
1906
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
1907
+ })), t.push.apply(t, o);
1908
+ }
1909
+ return t;
1910
+ }
1911
+ function _objectSpread2(e) {
1912
+ for (var r = 1; r < arguments.length; r++) {
1913
+ var t = null != arguments[r] ? arguments[r] : {};
1914
+ r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
1915
+ _defineProperty(e, r, t[r]);
1916
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
1917
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
1918
+ });
1919
+ }
1920
+ return e;
1921
+ }
1922
+ //#endregion
1923
+ //#region packages/runtime-dom/src/defineElement.ts
1924
+ function defineElement(tagName, options, setup) {
1925
+ var _options$props;
1926
+ const propDefs = normalizePropDefinitions((_options$props = options.props) !== null && _options$props !== void 0 ? _options$props : {});
1927
+ const observedAttributes = propDefs.filter((def) => def.attr !== false).map((def) => def.attr);
1928
+ class ZeusElement extends HTMLElement {
1929
+ static get observedAttributes() {
1930
+ return observedAttributes;
1931
+ }
1932
+ constructor() {
1933
+ super();
1934
+ this.props = state({});
1935
+ this.lightChildren = [];
1936
+ this.capturedLightChildren = false;
1937
+ this.reflecting = false;
1938
+ applyPropDefaults(this.props, propDefs);
1939
+ definePropAccessors(this, this.props, propDefs);
1940
+ }
1941
+ connectedCallback() {
1942
+ var _options$shadow, _options$consumes;
1943
+ if (this.dispose) return;
1944
+ const shadow = (_options$shadow = options.shadow) !== null && _options$shadow !== void 0 ? _options$shadow : false;
1945
+ const mode = shadow ? "shadow" : "light";
1946
+ if (mode === "light" && !this.capturedLightChildren) {
1947
+ this.lightChildren = Array.from(this.childNodes);
1948
+ this.capturedLightChildren = true;
1949
+ }
1950
+ this.syncAttributesToProps(propDefs);
1951
+ const owner = createOwner();
1952
+ for (const context of (_options$consumes = options.consumes) !== null && _options$consumes !== void 0 ? _options$consumes : []) {
1953
+ const resolved = resolveDOMContext(this, context);
1954
+ if (resolved.found) owner.provides.set(context.id, resolved.value);
1955
+ else if (context.hasDefaultValue) owner.provides.set(context.id, context.defaultValue);
1956
+ }
1957
+ const target = this.resolveRenderTarget(shadow);
1958
+ const hostContext = {
1959
+ host: this,
1960
+ mode,
1961
+ lightChildren: this.lightChildren
1962
+ };
1963
+ const setupContext = {
1964
+ host: this,
1965
+ emit: (name, detail, eventOptions) => {
1966
+ return this.dispatchEvent(new CustomEvent(name, _objectSpread2(_objectSpread2({
1967
+ bubbles: true,
1968
+ composed: true,
1969
+ cancelable: true
1970
+ }, eventOptions), {}, { detail })));
1971
+ }
1972
+ };
1973
+ this.dispose = render(() => runWithOwner(owner, () => withHostContext(hostContext, () => setup(this.props, setupContext))), target, { owner });
1974
+ mountStyles(target, options.styles);
1975
+ onScopeDispose(() => {
1976
+ var _this$dispose;
1977
+ (_this$dispose = this.dispose) === null || _this$dispose === void 0 || _this$dispose.call(this);
1978
+ this.dispose = void 0;
1979
+ }, true);
1980
+ }
1981
+ disconnectedCallback() {
1982
+ var _this$dispose2;
1983
+ (_this$dispose2 = this.dispose) === null || _this$dispose2 === void 0 || _this$dispose2.call(this);
1984
+ this.dispose = void 0;
1985
+ }
1986
+ attributeChangedCallback(name, oldValue, newValue) {
1987
+ if (oldValue === newValue || this.reflecting) return;
1988
+ const def = propDefs.find((item) => item.attr === name);
1989
+ if (!def) return;
1990
+ this.props[def.key] = castAttributeValue(newValue, def);
1991
+ }
1992
+ resolveRenderTarget(shadow) {
1993
+ if (this.target) return this.target;
1994
+ if (!shadow) {
1995
+ this.target = this;
1996
+ return this.target;
1997
+ }
1998
+ this.target = this.attachShadow(typeof shadow === "object" ? shadow : { mode: "open" });
1999
+ return this.target;
2000
+ }
2001
+ syncAttributesToProps(defs) {
2002
+ for (const def of defs) {
2003
+ if (def.attr === false) continue;
2004
+ const value = this.getAttribute(def.attr);
2005
+ if (value !== null || def.type === Boolean) this.props[def.key] = castAttributeValue(value, def);
2006
+ }
2007
+ }
2008
+ _writePropFromProperty(key, value) {
2009
+ const def = propDefs.find((item) => item.key === key);
2010
+ this.props[key] = value;
2011
+ if ((def === null || def === void 0 ? void 0 : def.reflect) && def.attr !== false) {
2012
+ this.reflecting = true;
2013
+ try {
2014
+ reflectPropToAttribute(this, def, value);
2015
+ } finally {
2016
+ this.reflecting = false;
2017
+ }
2018
+ }
2019
+ }
2020
+ }
2021
+ if (!customElements.get(tagName)) customElements.define(tagName, ZeusElement);
2022
+ return ZeusElement;
2023
+ }
2024
+ function normalizePropDefinitions(props) {
2025
+ return Object.keys(props).map((key) => {
2026
+ const input = props[key];
2027
+ if (typeof input === "function") return {
2028
+ key,
2029
+ attr: toKebabCase(key),
2030
+ type: input,
2031
+ reflect: false
2032
+ };
2033
+ return {
2034
+ key,
2035
+ attr: (input === null || input === void 0 ? void 0 : input.attr) === void 0 ? toKebabCase(key) : input.attr,
2036
+ type: input === null || input === void 0 ? void 0 : input.type,
2037
+ reflect: Boolean(input === null || input === void 0 ? void 0 : input.reflect),
2038
+ default: input === null || input === void 0 ? void 0 : input.default
2039
+ };
2040
+ });
2041
+ }
2042
+ function applyPropDefaults(props, defs) {
2043
+ for (const def of defs) {
2044
+ if (!("default" in def)) continue;
2045
+ const value = typeof def.default === "function" ? def.default() : def.default;
2046
+ props[def.key] = value;
2047
+ }
2048
+ }
2049
+ function definePropAccessors(element, props, defs) {
2050
+ for (const def of defs) {
2051
+ if (def.key in element) continue;
2052
+ Object.defineProperty(element, def.key, {
2053
+ configurable: true,
2054
+ enumerable: true,
2055
+ get() {
2056
+ return props[def.key];
2057
+ },
2058
+ set(value) {
2059
+ element._writePropFromProperty(def.key, value);
2060
+ }
2061
+ });
2062
+ }
2063
+ }
2064
+ function castAttributeValue(value, def) {
2065
+ if (def.type === Boolean) return value !== null;
2066
+ if (value === null) return;
2067
+ if (def.type === Number) return Number(value);
2068
+ if (def.type === Object || def.type === Array) try {
2069
+ return JSON.parse(value);
2070
+ } catch (_unused) {
2071
+ console.warn(`[Zeus custom-element] Failed to parse JSON attribute "${def.attr}".`);
2072
+ return def.type === Array ? [] : {};
2073
+ }
2074
+ return value;
2075
+ }
2076
+ function reflectPropToAttribute(element, def, value) {
2077
+ if (def.attr === false) return;
2078
+ if (def.type === Boolean) {
2079
+ if (value) element.setAttribute(def.attr, "");
2080
+ else element.removeAttribute(def.attr);
2081
+ return;
2082
+ }
2083
+ if (value == null) {
2084
+ element.removeAttribute(def.attr);
2085
+ return;
2086
+ }
2087
+ if (def.type === Object || def.type === Array) {
2088
+ element.setAttribute(def.attr, JSON.stringify(value));
2089
+ return;
2090
+ }
2091
+ element.setAttribute(def.attr, String(value));
2092
+ }
2093
+ function mountStyles(target, styles) {
2094
+ if (!styles) return;
2095
+ const list = Array.isArray(styles) ? styles : [styles];
2096
+ for (const css of list) {
2097
+ const style = document.createElement("style");
2098
+ style.textContent = css;
2099
+ target.appendChild(style);
2100
+ }
2101
+ }
2102
+ function toKebabCase(value) {
2103
+ return value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
2104
+ }
2105
+ //#endregion
2106
+ //#region packages/runtime-dom/src/slot.ts
2107
+ function createSlot(name, fallback) {
2108
+ const context = getCurrentHostContext();
2109
+ if (!context) return createNativeSlot(name, fallback);
2110
+ if (context.mode === "shadow") return createNativeSlot(name, fallback);
2111
+ const assigned = findLightSlotNodes(context.lightChildren, name);
2112
+ if (assigned.length > 0) return Array.from(assigned);
2113
+ return fallback ? fallback() : null;
2114
+ }
2115
+ function createNativeSlot(name, fallback) {
2116
+ const slot = document.createElement("slot");
2117
+ if (name) slot.setAttribute("name", name);
2118
+ const fallbackValue = fallback === null || fallback === void 0 ? void 0 : fallback();
2119
+ if (fallbackValue != null) insert(slot, fallbackValue);
2120
+ return slot;
2121
+ }
2122
+ function findLightSlotNodes(nodes, name) {
2123
+ if (name) return nodes.filter((node) => {
2124
+ if (node.nodeType !== Node.ELEMENT_NODE) return false;
2125
+ return node.getAttribute("slot") === name;
2126
+ });
2127
+ return nodes.filter((node) => {
2128
+ if (node.nodeType === Node.ELEMENT_NODE) return !node.hasAttribute("slot");
2129
+ return isMeaningfulTextNode(node);
2130
+ });
2131
+ }
2132
+ function isMeaningfulTextNode(node) {
2133
+ var _node$textContent;
2134
+ if (node.nodeType !== Node.TEXT_NODE) return false;
2135
+ return Boolean((_node$textContent = node.textContent) === null || _node$textContent === void 0 ? void 0 : _node$textContent.trim());
2136
+ }
2137
+ //#endregion
2138
+ //#region packages/runtime-dom/src/webComponents.ts
2139
+ function Host(props) {
2140
+ return resolveValue(props.children);
2141
+ }
2142
+ function Slot(props) {
2143
+ return createSlot(props.name, () => resolveValue(props.children));
2144
+ }
2145
+ function resolveValue(value) {
2146
+ return typeof value === "function" ? value() : value;
2147
+ }
2148
+ //#endregion
2149
+ //#region packages/zeus/src/jsx-runtime.ts
2150
+ const Fragment = Symbol.for("zeus.fragment");
2151
+ function jsx(type, props) {
2152
+ return createJSXNode(type, props);
2153
+ }
2154
+ function jsxs(type, props) {
2155
+ return createJSXNode(type, props);
2156
+ }
2157
+ function jsxDEV(type, props) {
2158
+ return createJSXNode(type, props);
2159
+ }
2160
+ function createJSXNode(type, props) {
2161
+ if (typeof type === "function") return createComponent(type, props !== null && props !== void 0 ? props : {});
2162
+ if (typeof type !== "string") return null;
2163
+ const el = document.createElement(type);
2164
+ if (props) {
2165
+ const children = props.children;
2166
+ for (const key of Object.keys(props)) {
2167
+ if (key === "children") continue;
2168
+ const value = props[key];
2169
+ if (key.startsWith("on") && typeof value === "function") el.addEventListener(key.slice(2).toLowerCase(), value);
2170
+ else if (key === "ref") setFallbackRef(value, el);
2171
+ else if (value != null && value !== false) el.setAttribute(key === "className" ? "class" : key, String(value));
2172
+ }
2173
+ if (children !== void 0) insert(el, children);
2174
+ }
2175
+ return el;
2176
+ }
2177
+ function setFallbackRef(target, el) {
2178
+ if (target == null) return;
2179
+ if (typeof target === "function") {
2180
+ target(el);
2181
+ return;
2182
+ }
2183
+ if (typeof target === "object") {
2184
+ if ("value" in target) {
2185
+ target.value = el;
2186
+ return;
2187
+ }
2188
+ if ("current" in target) target.current = el;
2189
+ }
2190
+ }
2191
+ //#endregion
2192
+ exports.For = For;
2193
+ exports.Fragment = Fragment;
2194
+ exports.Host = Host;
2195
+ exports.Show = Show;
2196
+ exports.Slot = Slot;
2197
+ exports.batch = batch;
2198
+ exports.computed = computed;
2199
+ exports.createContext = createContext;
2200
+ exports.defineElement = defineElement;
2201
+ exports.effect = effect;
2202
+ exports.inject = inject;
2203
+ exports.jsx = jsx;
2204
+ exports.jsxDEV = jsxDEV;
2205
+ exports.jsxs = jsxs;
2206
+ exports.nextTick = nextTick;
2207
+ exports.onCleanup = onCleanup;
2208
+ exports.provide = provide;
2209
+ exports.render = render;
2210
+ exports.scope = effectScope;
2211
+ exports.state = state;
2212
+ exports.untrack = untrack;
2213
+ exports.useContext = useContext;
2214
+ exports.watch = watch;
2215
+ return exports;
2216
+ })({});