@fluixi/reactive 1.0.0-alpha.92 → 1.0.0-alpha.94
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/cdn/reactive.cjs +105 -35
- package/dist/cdn/reactive.global.js +2 -2
- package/dist/cdn/reactive.mjs +105 -35
- package/dist/cdn/signal.cjs +1 -1
- package/dist/cdn/signal.global.js +2 -2
- package/dist/cdn/signal.mjs +1 -1
- package/dist/index.cjs +105 -35
- package/dist/index.mjs +105 -35
- package/dist/lib/index.cjs +106 -36
- package/dist/lib/index.mjs +106 -36
- package/dist/lib/observable/index.cjs +1 -1
- package/dist/lib/observable/index.mjs +1 -1
- package/dist/lib/signal/api.cjs +11 -10
- package/dist/lib/signal/api.d.ts +5 -1
- package/dist/lib/signal/api.d.ts.map +1 -1
- package/dist/lib/signal/api.js +4 -2
- package/dist/lib/signal/api.mjs +11 -10
- package/dist/lib/signal/cached-resource.cjs +77 -34
- package/dist/lib/signal/cached-resource.d.ts +48 -68
- package/dist/lib/signal/cached-resource.d.ts.map +1 -1
- package/dist/lib/signal/cached-resource.js +59 -72
- package/dist/lib/signal/cached-resource.mjs +77 -34
- package/dist/lib/signal/graph/children.cjs +3 -2
- package/dist/lib/signal/graph/children.mjs +3 -2
- package/dist/lib/signal/graph/compat.cjs +10 -9
- package/dist/lib/signal/graph/compat.d.ts +3 -1
- package/dist/lib/signal/graph/compat.d.ts.map +1 -1
- package/dist/lib/signal/graph/compat.js +2 -2
- package/dist/lib/signal/graph/compat.mjs +10 -9
- package/dist/lib/signal/graph/core.cjs +2 -2
- package/dist/lib/signal/graph/core.mjs +2 -2
- package/dist/lib/signal/graph/debounced.cjs +9 -8
- package/dist/lib/signal/graph/debounced.mjs +9 -8
- package/dist/lib/signal/graph/derived.cjs +9 -8
- package/dist/lib/signal/graph/derived.mjs +9 -8
- package/dist/lib/signal/graph/error-boundary.cjs +3 -2
- package/dist/lib/signal/graph/error-boundary.mjs +3 -2
- package/dist/lib/signal/graph/index.cjs +2 -2
- package/dist/lib/signal/graph/index.mjs +2 -2
- package/dist/lib/signal/graph/observe.cjs +38 -3
- package/dist/lib/signal/graph/observe.d.ts +44 -0
- package/dist/lib/signal/graph/observe.d.ts.map +1 -1
- package/dist/lib/signal/graph/observe.js +50 -1
- package/dist/lib/signal/graph/observe.mjs +38 -3
- package/dist/lib/signal/graph/resource.cjs +9 -8
- package/dist/lib/signal/graph/resource.mjs +9 -8
- package/dist/lib/signal/graph/runtime.cjs +7 -6
- package/dist/lib/signal/graph/runtime.d.ts +1 -1
- package/dist/lib/signal/graph/runtime.d.ts.map +1 -1
- package/dist/lib/signal/graph/runtime.js +4 -4
- package/dist/lib/signal/graph/runtime.mjs +7 -6
- package/dist/lib/signal/graph/signal-next.cjs +39 -9
- package/dist/lib/signal/graph/signal-next.d.ts +1 -1
- package/dist/lib/signal/graph/signal-next.d.ts.map +1 -1
- package/dist/lib/signal/graph/signal-next.js +1 -1
- package/dist/lib/signal/graph/signal-next.mjs +39 -9
- package/dist/lib/signal/graph/ssr-hooks.cjs +29 -0
- package/dist/lib/signal/graph/ssr-hooks.d.ts +24 -0
- package/dist/lib/signal/graph/ssr-hooks.d.ts.map +1 -1
- package/dist/lib/signal/graph/ssr-hooks.js +36 -0
- package/dist/lib/signal/graph/ssr-hooks.mjs +29 -0
- package/dist/lib/signal/graph/state.cjs +1 -1
- package/dist/lib/signal/graph/state.mjs +1 -1
- package/dist/lib/signal/graph/suspense.cjs +3 -2
- package/dist/lib/signal/graph/suspense.mjs +3 -2
- package/dist/lib/signal/index-legacy.cjs +65 -34
- package/dist/lib/signal/index-legacy.mjs +65 -34
- package/dist/lib/signal/index.cjs +76 -12
- package/dist/lib/signal/index.d.ts +2 -1
- package/dist/lib/signal/index.d.ts.map +1 -1
- package/dist/lib/signal/index.js +1 -1
- package/dist/lib/signal/index.mjs +76 -12
- package/dist/lib/signal/list.cjs +3 -2
- package/dist/lib/signal/list.mjs +3 -2
- package/dist/lib/signal/resource-api.cjs +9 -8
- package/dist/lib/signal/resource-api.mjs +9 -8
- package/dist/lib/signal/signal.cjs +9 -8
- package/dist/lib/signal/signal.mjs +9 -8
- package/dist/lib/signal/utilities.cjs +10 -9
- package/dist/lib/signal/utilities.mjs +10 -9
- package/dist/lib/store/api.cjs +3 -2
- package/dist/lib/store/api.mjs +3 -2
- package/dist/lib/store/index.cjs +4 -3
- package/dist/lib/store/index.mjs +4 -3
- package/dist/lib/store/store.cjs +3 -2
- package/dist/lib/store/store.mjs +3 -2
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/version.generated.cjs +2 -2
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/dist/version.generated.mjs +2 -2
- package/package.json +2 -2
package/dist/cdn/reactive.cjs
CHANGED
|
@@ -39,15 +39,16 @@ __export(reactive_exports, {
|
|
|
39
39
|
SuspenseContext: () => SuspenseContext,
|
|
40
40
|
VERSION: () => VERSION,
|
|
41
41
|
__DEV__: () => __DEV__,
|
|
42
|
+
adoptReactiveScope: () => adoptReactiveScope,
|
|
42
43
|
batch: () => batch2,
|
|
44
|
+
cachedResource: () => cachedResource,
|
|
43
45
|
childOwner: () => childOwner,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
clearCachedResources: () => clearCachedResources,
|
|
47
|
+
closeReactiveScope: () => closeReactiveScope,
|
|
46
48
|
combineSignal: () => combineSignal,
|
|
47
49
|
combineSignals: () => combineSignals,
|
|
48
50
|
computed: () => computed,
|
|
49
51
|
context: () => context,
|
|
50
|
-
createCachedResource: () => createCachedResource,
|
|
51
52
|
createChildOwner: () => createChildOwner,
|
|
52
53
|
createComputed: () => createComputed,
|
|
53
54
|
createComputedStore: () => createComputedStore,
|
|
@@ -62,6 +63,7 @@ __export(reactive_exports, {
|
|
|
62
63
|
createMutableStore: () => createMutableStore,
|
|
63
64
|
createRenderEffect: () => createRenderEffect,
|
|
64
65
|
createResource: () => createResource,
|
|
66
|
+
createResourceCache: () => createResourceCache,
|
|
65
67
|
createRoot: () => createRoot,
|
|
66
68
|
createSelector: () => createSelector,
|
|
67
69
|
createSignal: () => createSignal,
|
|
@@ -69,6 +71,7 @@ __export(reactive_exports, {
|
|
|
69
71
|
createStoreEffect: () => createStoreEffect,
|
|
70
72
|
createStoreMemo: () => createStoreMemo,
|
|
71
73
|
createSuspenseBoundary: () => createSuspenseBoundary,
|
|
74
|
+
currentResourceCache: () => currentResourceCache,
|
|
72
75
|
debounceSignal: () => debounceSignal,
|
|
73
76
|
disposeScope: () => disposeScope,
|
|
74
77
|
distinctSignal: () => distinctSignal,
|
|
@@ -97,6 +100,7 @@ __export(reactive_exports, {
|
|
|
97
100
|
makeArrayFlat: () => makeArrayFlat,
|
|
98
101
|
mapArray: () => mapArray,
|
|
99
102
|
mapSignal: () => mapSignal,
|
|
103
|
+
markReactiveScope: () => markReactiveScope,
|
|
100
104
|
memo: () => memo,
|
|
101
105
|
mergeSignal: () => mergeSignal,
|
|
102
106
|
modifiable: () => modifiable,
|
|
@@ -105,12 +109,14 @@ __export(reactive_exports, {
|
|
|
105
109
|
omitSignal: () => omitSignal,
|
|
106
110
|
on: () => on,
|
|
107
111
|
onCleanup: () => onCleanup,
|
|
112
|
+
openReactiveScope: () => openReactiveScope,
|
|
108
113
|
operate: () => operate,
|
|
109
114
|
pickSignal: () => pickSignal,
|
|
110
115
|
produceUtil: () => produce,
|
|
111
116
|
provide: () => provide,
|
|
112
117
|
provideErrorBoundary: () => provideErrorBoundary,
|
|
113
118
|
provideSuspense: () => provideSuspense,
|
|
119
|
+
reactiveScopeOf: () => reactiveScopeOf,
|
|
114
120
|
readChildren: () => readChildren,
|
|
115
121
|
readSignal: () => readSignal,
|
|
116
122
|
reconcileUtil: () => reconcile,
|
|
@@ -127,6 +133,7 @@ __export(reactive_exports, {
|
|
|
127
133
|
runWithOwner: () => runWithOwner,
|
|
128
134
|
selectSignal: () => selectSignal,
|
|
129
135
|
setOwner: () => setOwner,
|
|
136
|
+
setResourceCacheScope: () => setResourceCacheScope,
|
|
130
137
|
setResourceDataSink: () => setResourceDataSink,
|
|
131
138
|
setResourceIdSource: () => setResourceIdSource,
|
|
132
139
|
setResourceTracker: () => setResourceTracker,
|
|
@@ -144,13 +151,14 @@ __export(reactive_exports, {
|
|
|
144
151
|
useContext: () => useContext,
|
|
145
152
|
useTransition: () => useTransition,
|
|
146
153
|
whenSignal: () => whenSignal,
|
|
154
|
+
withReactiveScope: () => withReactiveScope,
|
|
147
155
|
wrap: () => wrap,
|
|
148
156
|
zipSignal: () => zipSignal
|
|
149
157
|
});
|
|
150
158
|
module.exports = __toCommonJS(reactive_exports);
|
|
151
159
|
|
|
152
160
|
// src/version.generated.ts
|
|
153
|
-
var VERSION = "1.0.0-alpha.
|
|
161
|
+
var VERSION = "1.0.0-alpha.94";
|
|
154
162
|
|
|
155
163
|
// src/lib/predicates.ts
|
|
156
164
|
function isFunction(value) {
|
|
@@ -641,11 +649,40 @@ function withReactiveOrigin(owner, fn) {
|
|
|
641
649
|
origin = previous;
|
|
642
650
|
}
|
|
643
651
|
}
|
|
652
|
+
var currentScope;
|
|
653
|
+
function openReactiveScope(info) {
|
|
654
|
+
const scope = {};
|
|
655
|
+
G.observer?.scope?.(scope, info, currentScope);
|
|
656
|
+
return scope;
|
|
657
|
+
}
|
|
658
|
+
function withReactiveScope(scope, fn) {
|
|
659
|
+
if (!G.observer) return fn();
|
|
660
|
+
const previous = currentScope;
|
|
661
|
+
currentScope = scope;
|
|
662
|
+
try {
|
|
663
|
+
return fn();
|
|
664
|
+
} finally {
|
|
665
|
+
currentScope = previous;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
function closeReactiveScope(scope) {
|
|
669
|
+
G.observer?.scopeEnded?.(scope);
|
|
670
|
+
}
|
|
671
|
+
function adoptReactiveScope(scope, parent) {
|
|
672
|
+
G.observer?.scopeAdopted?.(scope, parent);
|
|
673
|
+
}
|
|
674
|
+
var SCOPE_OF = /* @__PURE__ */ Symbol.for("fluixi.reactiveScope");
|
|
675
|
+
function markReactiveScope(value, scope) {
|
|
676
|
+
Object.defineProperty(value, SCOPE_OF, { value: scope, configurable: true, enumerable: false });
|
|
677
|
+
}
|
|
678
|
+
function reactiveScopeOf(value) {
|
|
679
|
+
return value !== null && (typeof value === "object" || typeof value === "function") ? value[SCOPE_OF] ?? void 0 : void 0;
|
|
680
|
+
}
|
|
644
681
|
function reportReactiveNode(report) {
|
|
645
682
|
const observer = G.observer;
|
|
646
683
|
if (observer) {
|
|
647
684
|
observer.created(
|
|
648
|
-
report.parents === void 0 ? { ...report, parents: running, origin: report.origin ?? origin } : report
|
|
685
|
+
report.parents === void 0 ? { ...report, parents: running, origin: report.origin ?? origin, scope: report.scope ?? currentScope } : { ...report, scope: report.scope ?? currentScope }
|
|
649
686
|
);
|
|
650
687
|
}
|
|
651
688
|
}
|
|
@@ -1065,7 +1102,7 @@ function batch(fn) {
|
|
|
1065
1102
|
}
|
|
1066
1103
|
}
|
|
1067
1104
|
var EffectNode = class {
|
|
1068
|
-
constructor(fn, report = false) {
|
|
1105
|
+
constructor(fn, report = false, name) {
|
|
1069
1106
|
this.queued = false;
|
|
1070
1107
|
this.disposed = false;
|
|
1071
1108
|
this.owner = makeOwner(G.owner);
|
|
@@ -1077,7 +1114,7 @@ var EffectNode = class {
|
|
|
1077
1114
|
if (typeof r === "function") (this.owner.cleanups ??= []).push(r);
|
|
1078
1115
|
});
|
|
1079
1116
|
});
|
|
1080
|
-
reportReactiveNode({ kind: "effect", node: this.computed, handle: this, internal: !report });
|
|
1117
|
+
reportReactiveNode({ kind: "effect", node: this.computed, handle: this, internal: !report, ...name ? { name } : {} });
|
|
1081
1118
|
this.watcher = new Watcher(() => enqueue(this));
|
|
1082
1119
|
this.run();
|
|
1083
1120
|
this.watcher.watch(this.computed);
|
|
@@ -1104,8 +1141,8 @@ var EffectNode = class {
|
|
|
1104
1141
|
disposeOwner(this.owner);
|
|
1105
1142
|
}
|
|
1106
1143
|
};
|
|
1107
|
-
function effect(fn, report = false) {
|
|
1108
|
-
const node = new EffectNode(fn, report);
|
|
1144
|
+
function effect(fn, report = false, name) {
|
|
1145
|
+
const node = new EffectNode(fn, report, name);
|
|
1109
1146
|
return () => node.dispose();
|
|
1110
1147
|
}
|
|
1111
1148
|
|
|
@@ -1173,12 +1210,12 @@ function createMemo(fn, value, options) {
|
|
|
1173
1210
|
if (isObserved()) onCleanup(() => reportReactiveDispose(c));
|
|
1174
1211
|
return read;
|
|
1175
1212
|
}
|
|
1176
|
-
function createEffect(fn, value) {
|
|
1213
|
+
function createEffect(fn, value, options) {
|
|
1177
1214
|
let prev = value;
|
|
1178
1215
|
return effect(() => {
|
|
1179
1216
|
const r = fn(prev);
|
|
1180
1217
|
prev = r;
|
|
1181
|
-
}, true);
|
|
1218
|
+
}, true, options?.name);
|
|
1182
1219
|
}
|
|
1183
1220
|
function createComputed(fn, value) {
|
|
1184
1221
|
let prev = value;
|
|
@@ -1424,6 +1461,32 @@ function setResourceDataSink(fn) {
|
|
|
1424
1461
|
function reportResourceData(id, value) {
|
|
1425
1462
|
if (_resourceDataSink) _resourceDataSink(id, value);
|
|
1426
1463
|
}
|
|
1464
|
+
function createResourceCache() {
|
|
1465
|
+
const entries = /* @__PURE__ */ new Map();
|
|
1466
|
+
const inflight = /* @__PURE__ */ new Map();
|
|
1467
|
+
return {
|
|
1468
|
+
get: (key) => entries.get(key),
|
|
1469
|
+
set: (key, entry) => void entries.set(key, entry),
|
|
1470
|
+
delete: (key) => void entries.delete(key),
|
|
1471
|
+
keys: () => entries.keys(),
|
|
1472
|
+
clear: () => {
|
|
1473
|
+
entries.clear();
|
|
1474
|
+
inflight.clear();
|
|
1475
|
+
},
|
|
1476
|
+
inflight
|
|
1477
|
+
};
|
|
1478
|
+
}
|
|
1479
|
+
var _cacheScope = null;
|
|
1480
|
+
function setResourceCacheScope(fn) {
|
|
1481
|
+
_cacheScope = fn;
|
|
1482
|
+
}
|
|
1483
|
+
var _pageCache;
|
|
1484
|
+
function currentResourceCache() {
|
|
1485
|
+
const scoped = _cacheScope?.();
|
|
1486
|
+
if (scoped) return scoped;
|
|
1487
|
+
if (typeof window === "undefined") return createResourceCache();
|
|
1488
|
+
return _pageCache ??= createResourceCache();
|
|
1489
|
+
}
|
|
1427
1490
|
|
|
1428
1491
|
// src/lib/signal/graph/derived.ts
|
|
1429
1492
|
function createSelector(source, fn = (k, v) => k === v) {
|
|
@@ -1743,8 +1806,8 @@ function signal(value, options) {
|
|
|
1743
1806
|
function memo(fn, value, options) {
|
|
1744
1807
|
return createMemo(fn, value, options);
|
|
1745
1808
|
}
|
|
1746
|
-
function effect2(fn, value) {
|
|
1747
|
-
return createEffect(fn, value);
|
|
1809
|
+
function effect2(fn, value, options) {
|
|
1810
|
+
return createEffect(fn, value, options);
|
|
1748
1811
|
}
|
|
1749
1812
|
function root(fn) {
|
|
1750
1813
|
return createRoot(fn);
|
|
@@ -2527,12 +2590,10 @@ function readSignal(signal2) {
|
|
|
2527
2590
|
}
|
|
2528
2591
|
|
|
2529
2592
|
// src/lib/signal/cached-resource.ts
|
|
2530
|
-
var ttlCache = /* @__PURE__ */ new Map();
|
|
2531
|
-
var inflight = /* @__PURE__ */ new Map();
|
|
2532
2593
|
var _autoId = 0;
|
|
2533
2594
|
var $SIGNAL4 = /* @__PURE__ */ Symbol.for("signal");
|
|
2534
2595
|
var $RESOURCE2 = /* @__PURE__ */ Symbol.for("resource");
|
|
2535
|
-
function
|
|
2596
|
+
function cachedResource(sourceOrFetcher, fetcherOrOptions, opts = {}) {
|
|
2536
2597
|
let sourceFn;
|
|
2537
2598
|
let fetchFn;
|
|
2538
2599
|
let options;
|
|
@@ -2551,7 +2612,13 @@ function createCachedResource(sourceOrFetcher, fetcherOrOptions, opts = {}) {
|
|
|
2551
2612
|
staleWhileRevalidate = true
|
|
2552
2613
|
} = options;
|
|
2553
2614
|
const ns = name;
|
|
2554
|
-
const
|
|
2615
|
+
const cache = options.cache ?? currentResourceCache();
|
|
2616
|
+
const inflight = cache.inflight;
|
|
2617
|
+
const ssrId = options.transport === false ? void 0 : nextResourceId();
|
|
2618
|
+
const seed = ssrId !== void 0 ? getServerData(ssrId) : void 0;
|
|
2619
|
+
const deps = options.deps ?? [];
|
|
2620
|
+
const depValues = () => deps.map((dep) => dep());
|
|
2621
|
+
const buildKey = (key, values = untrack2(depValues)) => `${ns}:${JSON.stringify(key)}` + (deps.length ? `:${JSON.stringify(values)}` : "");
|
|
2555
2622
|
const isFresh = (entry) => ttl === Infinity || Date.now() - entry.timestamp <= ttl;
|
|
2556
2623
|
const [value, setValue] = createSignal(void 0, { equals: false });
|
|
2557
2624
|
const [resourceState, setResourceState] = createSignal("unresolved", { equals: false });
|
|
@@ -2564,8 +2631,9 @@ function createCachedResource(sourceOrFetcher, fetcherOrOptions, opts = {}) {
|
|
|
2564
2631
|
let flagRefetch = false;
|
|
2565
2632
|
let flagInvalidate = false;
|
|
2566
2633
|
function doFetch(key, ck, background, isCancelled) {
|
|
2567
|
-
|
|
2568
|
-
|
|
2634
|
+
const running2 = inflight.get(ck);
|
|
2635
|
+
if (running2) {
|
|
2636
|
+
running2.then(
|
|
2569
2637
|
(v) => {
|
|
2570
2638
|
if (!isCancelled()) settle(v, background);
|
|
2571
2639
|
},
|
|
@@ -2573,12 +2641,15 @@ function createCachedResource(sourceOrFetcher, fetcherOrOptions, opts = {}) {
|
|
|
2573
2641
|
if (!isCancelled() && !background) fail(e);
|
|
2574
2642
|
}
|
|
2575
2643
|
);
|
|
2576
|
-
if (!background)
|
|
2644
|
+
if (!background) {
|
|
2645
|
+
trackResourcePromise(running2);
|
|
2646
|
+
setPendingP(running2);
|
|
2647
|
+
}
|
|
2577
2648
|
return;
|
|
2578
2649
|
}
|
|
2579
2650
|
const promise = Promise.resolve(fetchFn(key)).then(
|
|
2580
2651
|
(v) => {
|
|
2581
|
-
|
|
2652
|
+
cache.set(ck, { value: v, timestamp: Date.now() });
|
|
2582
2653
|
inflight.delete(ck);
|
|
2583
2654
|
return v;
|
|
2584
2655
|
},
|
|
@@ -2601,7 +2672,8 @@ function createCachedResource(sourceOrFetcher, fetcherOrOptions, opts = {}) {
|
|
|
2601
2672
|
}
|
|
2602
2673
|
);
|
|
2603
2674
|
}
|
|
2604
|
-
function settle(v,
|
|
2675
|
+
function settle(v, _background) {
|
|
2676
|
+
if (ssrId !== void 0) reportResourceData(ssrId, v);
|
|
2605
2677
|
batch2(() => {
|
|
2606
2678
|
setValue(() => v);
|
|
2607
2679
|
setResourceState("ready");
|
|
@@ -2619,6 +2691,7 @@ function createCachedResource(sourceOrFetcher, fetcherOrOptions, opts = {}) {
|
|
|
2619
2691
|
}
|
|
2620
2692
|
createEffect(() => {
|
|
2621
2693
|
const key = sourceFn();
|
|
2694
|
+
const values = depValues();
|
|
2622
2695
|
tick();
|
|
2623
2696
|
if (key === false || key === null || key === void 0) {
|
|
2624
2697
|
prevKey = UNSET2;
|
|
@@ -2633,16 +2706,18 @@ function createCachedResource(sourceOrFetcher, fetcherOrOptions, opts = {}) {
|
|
|
2633
2706
|
const doInvalidate = flagInvalidate;
|
|
2634
2707
|
flagRefetch = false;
|
|
2635
2708
|
flagInvalidate = false;
|
|
2636
|
-
const ck = buildKey(key);
|
|
2637
|
-
if (
|
|
2709
|
+
const ck = buildKey(key, values);
|
|
2710
|
+
if (seed && prevKey === UNSET2 && !cache.get(ck)) cache.set(ck, { value: seed.value, timestamp: Date.now() });
|
|
2711
|
+
if (doInvalidate) cache.delete(ck);
|
|
2638
2712
|
const keyChanged = prevKey === UNSET2 || key !== prevKey;
|
|
2639
2713
|
prevKey = key;
|
|
2640
2714
|
let cancelled = false;
|
|
2641
2715
|
onCleanup(() => {
|
|
2642
2716
|
cancelled = true;
|
|
2643
2717
|
});
|
|
2644
|
-
const cached =
|
|
2718
|
+
const cached = cache.get(ck);
|
|
2645
2719
|
if (cached && isFresh(cached) && !doRefetch && !doInvalidate) {
|
|
2720
|
+
if (ssrId !== void 0) reportResourceData(ssrId, cached.value);
|
|
2646
2721
|
const cur2 = untrack2(resourceState);
|
|
2647
2722
|
if (cur2 !== "ready" || untrack2(value) !== cached.value) {
|
|
2648
2723
|
batch2(() => {
|
|
@@ -2703,20 +2778,15 @@ function createCachedResource(sourceOrFetcher, fetcherOrOptions, opts = {}) {
|
|
|
2703
2778
|
const invalidate = () => {
|
|
2704
2779
|
const key = untrack2(sourceFn);
|
|
2705
2780
|
if (key !== null && key !== void 0 && key !== false) {
|
|
2706
|
-
|
|
2781
|
+
cache.delete(buildKey(key));
|
|
2707
2782
|
}
|
|
2708
2783
|
flagInvalidate = true;
|
|
2709
2784
|
setTick((v) => v + 1);
|
|
2710
2785
|
};
|
|
2711
|
-
return
|
|
2786
|
+
return Object.assign(resource2, { mutate: setValue, refetch, invalidate });
|
|
2712
2787
|
}
|
|
2713
|
-
function
|
|
2788
|
+
function clearCachedResources(name, cache = currentResourceCache()) {
|
|
2789
|
+
if (name === void 0) return cache.clear();
|
|
2714
2790
|
const prefix = `${name}:`;
|
|
2715
|
-
for (const key of
|
|
2716
|
-
if (key.startsWith(prefix)) ttlCache.delete(key);
|
|
2717
|
-
}
|
|
2718
|
-
}
|
|
2719
|
-
function clearAllCachedResources() {
|
|
2720
|
-
ttlCache.clear();
|
|
2721
|
-
inflight.clear();
|
|
2791
|
+
for (const key of [...cache.keys()]) if (key.startsWith(prefix)) cache.delete(key);
|
|
2722
2792
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @fluixi/reactive v1.0.0-alpha.
|
|
2
|
-
"use strict";var Fluixi=(()=>{var st=Object.defineProperty;var kn=Object.getOwnPropertyDescriptor;var An=Object.getOwnPropertyNames;var _n=Object.prototype.hasOwnProperty;var En=(e,t)=>{for(var r in t)st(e,r,{get:t[r],enumerable:!0})},Pn=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of An(t))!_n.call(e,o)&&o!==r&&st(e,o,{get:()=>t[o],enumerable:!(n=kn(t,o))||n.enumerable});return e};var Cn=e=>Pn(st({},"__esModule",{value:!0}),e);var vs={};En(vs,{$NAME:()=>un,$NODE:()=>J,$PROXY:()=>Jn,$RAW:()=>ye,$SELF:()=>Qe,$SIGNAL:()=>Xn,$STORE:()=>an,$TRACK:()=>Ze,Observable:()=>K,SafeSubscriber:()=>Ce,Signal:()=>Mr,Store:()=>G,StoreAPI:()=>gn,Subject:()=>ut,Subscriber:()=>oe,Subscription:()=>ne,SuspenseContext:()=>We,VERSION:()=>Y,__DEV__:()=>Ke,batch:()=>x,childOwner:()=>so,clearAllCachedResources:()=>bs,clearCachedResourceNamespace:()=>ys,combineSignal:()=>Zo,combineSignals:()=>es,computed:()=>no,context:()=>oo,createCachedResource:()=>hs,createChildOwner:()=>Ue,createComputed:()=>qe,createComputedStore:()=>pn,createContext:()=>H,createDebounce:()=>Er,createDebouncedResource:()=>Pr,createDebouncedSignal:()=>gt,createDeferred:()=>_r,createEffect:()=>E,createErrorBoundary:()=>Fr,createMemo:()=>h,createMutableStore:()=>Ut,createRenderEffect:()=>Be,createResource:()=>de,createRoot:()=>q,createSelector:()=>Ar,createSignal:()=>d,createStore:()=>Ee,createStoreEffect:()=>hn,createStoreMemo:()=>yn,createSuspenseBoundary:()=>Dr,debounceSignal:()=>as,disposeScope:()=>ir,distinctSignal:()=>Qo,effect:()=>eo,everySignal:()=>Xo,filterSignal:()=>Go,findSignal:()=>zo,flush:()=>br,getNode:()=>mn,getOwner:()=>Oe,getServerData:()=>Ve,getStoreNode:()=>Tn,guardSignal:()=>us,indexArray:()=>Vn,isComponent:()=>Sr,isMemo:()=>mr,isOwnerDisposed:()=>ur,isProvider:()=>wr,isResource:()=>Tr,isSignal:()=>$e,isStore:()=>vn,isStoreProxy:()=>ot,isSuspense:()=>gr,joinedVersions:()=>Gt,keyArray:()=>$n,makeArrayFlat:()=>yt,mapArray:()=>Kn,mapSignal:()=>Lo,memo:()=>Zn,mergeSignal:()=>ts,modifiable:()=>Sn,nextResourceId:()=>He,observeReactiveNodes:()=>at,omitSignal:()=>ss,on:()=>vr,onCleanup:()=>S,operate:()=>Dn,pickSignal:()=>os,produceUtil:()=>wn,provide:()=>ce,provideErrorBoundary:()=>Ur,provideSuspense:()=>Ir,readChildren:()=>Cr,readSignal:()=>fs,reconcileUtil:()=>xn,reduceSignal:()=>Wo,renderEffect:()=>ro,reportReactiveBinding:()=>Zt,reportReactiveContext:()=>se,reportReactiveContextCreated:()=>je,reportReactiveDirective:()=>tr,reportReactiveProps:()=>er,reportResourceData:()=>Le,resource:()=>Nr,root:()=>to,runWithOwner:()=>fe,selectSignal:()=>ns,setOwner:()=>dt,setResourceDataSink:()=>kr,setResourceIdSource:()=>Rr,setResourceTracker:()=>xr,setServerDataGetter:()=>Or,signal:()=>Qn,someSignal:()=>Yo,sortSignal:()=>Jo,startTransition:()=>ht,store:()=>On,throttleSignal:()=>cs,trackResourcePromise:()=>le,untrack:()=>g,untrackStore:()=>Mt,unwrap:()=>ve,useContext:()=>ar,useTransition:()=>yr,whenSignal:()=>is,wrap:()=>bn,zipSignal:()=>rs});var Y="1.0.0-alpha.92";function it(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function Kt(e){return e==null||Array.isArray(e)||typeof e=="function"||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error?!1:typeof e=="object"}var ne=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:r}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let n of t)n.remove(this);if(r){for(let n of r)if(it(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if(Kt(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:r,_subscriptions:n}=this;if(r){if(it(t))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(t.unsubscribe)try{t.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(t);n!==-1&&(r.splice(n,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:r}=this;r?Array.isArray(r)?r.push(t):this._parentOrParents=[r,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:r}=this;if(r===t)this._parentOrParents=null;else if(Array.isArray(r)){let n=r.indexOf(t);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var oe=class extends ne{constructor(r,n,o){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:n,complete:o}:s={},this.destination=s}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(n){throw n}else throw r;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(r){this.error(r);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},Ce=class extends oe{constructor(r,n,o,s){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(r)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};function Dn(e){return new oe(e.next,e.error,e.complete)}var K=class extends ne{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,r,n){let o;t instanceof oe?o=t:o=new Ce(t,r,n);let{_subscribe:s}=this;try{let i=s.call(this,o);i&&(typeof i=="function"||typeof i.unsubscribe=="function")&&o.add(i)}catch(i){o.error(i)}return o}pipe(...t){return t.length===0?this:t.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((t,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>t(n)})})}};var ut=class extends K{constructor(){super(r=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)r.error(this.thrownError);else if(this.isStopped)r.complete();else return this.observers.push(r),()=>{let n=this.observers.indexOf(r);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(r){if(this.isStopped)return;let{observers:n}=this,o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].next?.(r)}error(r){if(this.isStopped)return;this.hasError=!0,this.thrownError=r,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].error?.(r)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:r}=this;this.observers=[];let n=r.length,o=r.slice();for(let s=0;s<n;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new K(n=>this.subscribe(n))}};var Vt=Y.split(".")[0],$t=`__fluixi_signal_state_v${Vt}__`,Ht=`__fluixi_signal_builds_v${Vt}__`,In=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)};function Lt(){return{consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:In,onSuspend:null,onError:null,observer:null}}var De=globalThis;function jn(e){let t=Lt(),r=e;for(let n of Object.keys(t))n in e||(r[n]=t[n]);return e}function Fn(){let e=De[$t];return e?jn(e):De[$t]=Lt()}var a=Fn();(De[Ht]??=[]).push(Y);function Gt(){return[...new Set(De[Ht]??[])]}function at(e){return a.observer=e,()=>{a.observer===e&&(a.observer=null)}}var k=[],Ie;function zt(e,t){if(!a.observer)return t();let r=Ie;Ie=e;try{return t()}finally{Ie=r}}function X(e){let t=a.observer;t&&t.created(e.parents===void 0?{...e,parents:k,origin:e.origin??Ie}:e)}function Yt(e){return a.observer?(k.push(e),!0):!1}function Xt(){k.pop()}function Jt(e){a.observer?.ran?.(e)}function Qt(e,t){a.observer?.wrote?.(e,t)}function Zt(e,t,r,n){let o=a.observer;!o?.bound||!k.length||o.bound(k[k.length-1],e,t,r,n)}function er(e){let t=a.observer;!t?.props||!k.length||!e||t.props(k[k.length-1],e)}function tr(e,t,r,n){let o=a.observer;!o?.directive||!k.length||o.directive(k[k.length-1],e,t,r,n)}function je(e){a.observer?.contextCreated?.(e)}function se(e,t,r){let n=a.observer;!n?.context||!k.length||n.context(k[k.length-1],e,t,r)}function ct(e,t,r){a.observer?.moved?.(e,t,r)}function $(e){a.observer?.disposed?.(e)}var Un="__FLUIXI_DEVTOOLS_HOOK__",Wt=globalThis[Un];if(typeof Wt?.inject=="function")try{Wt.inject({observeReactiveNodes:at,version:Y})}catch{}function ie(){return a.observer!=null}var rr=0,nr=1,Se=2,Fe=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let t=a.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},ue=class extends Fe{constructor(t,r){super(),this._value=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,Qt(this,a.consumer),this.observers)for(let r of[...this.observers])r.markDirty(Se);ft(this)}}peek(){return this._value}},V=class extends Fe{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=Se;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){if(a.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===nr&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===Se)break}(this.state===Se||!this._initialized)&&this.recompute(),this.state=rr}recompute(){if(this.sources){for(let l of this.sources)l.observers?.delete(this);this.sources.clear()}let r=a.consumer,n=a.untracked,o=Yt(this);a.consumer=this,a.untracked=!1;let s,i=!1,u;try{s=this._fn()}catch(l){i=!0,u=l,s=this._value}finally{a.consumer=r,a.untracked=n,o&&Xt()}let c=!this._initialized||this._threw!==i||(i?u!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=i,this._error=u,this._value=s,Jt(this),c){if(this.version++,this.observers)for(let l of[...this.observers])l.markDirty(Se);ft(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===rr;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty(nr);ft(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function ft(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var ae=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function ge(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function or(){return a.consumer}function sr(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function Ue(e){let t=xe(e);return e&&(e.owned??=[]).push(t),t}function ir(e,t=!0){we(e,t)}function ur(e){return!!e&&e.disposed===!0}function xe(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function H(e,t){let r=Symbol(t??"context");return je(r),{id:r,defaultValue:e,Provider:o=>{se(r,"provide",o.value);let s=a.owner,i=xe(s);(i.contexts=new Map).set(r,o.value),s&&(s.owned??=[]).push(i),a.owner=i;try{return o.children}finally{a.owner=s}}}}function ar(e){let t=a.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id)){let r=t.contexts.get(e.id);return se(e.id,"read",r),r}t=t.parent}return se(e.id,"read",e.defaultValue),e.defaultValue}function Me(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function ce(e,t,r){let n=xe(a.owner);(n.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return r()}finally{a.owner=o}}function cr(e){a.onSuspend=e}function fr(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function lr(e){a.onError=e}function Oe(){return a.owner}function dt(e){let t=a.owner;return a.owner=e,t}function fe(e,t){let r=a.owner;a.owner=e;try{return t()}finally{a.owner=r}}function S(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function we(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)we(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}t&&(e.disposed=!0)}}function q(e){let t=xe(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>we(t))}finally{a.owner=r}}function dr(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function Mn(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(Re)))}function Re(){if(a.scheduled=!1,a.flushing)return;a.flushing=!0;let e=0;try{for(;a.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function pr(){a.batchDepth===0&&Re()}function pt(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&Re()}}var lt=class{constructor(t,r=!1){this.queued=!1;this.disposed=!1;this.owner=xe(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new V(()=>{we(this.owner,!1),fe(this.owner,()=>{let n=t();typeof n=="function"&&(this.owner.cleanups??=[]).push(n)})}),X({kind:"effect",node:this.computed,handle:this,internal:!r}),this.watcher=new ae(()=>Mn(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&a.onSuspend){a.onSuspend(t,this.owner);return}if(a.onError&&a.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,$(this.computed),this.watcher.unwatch(this.computed),we(this.owner))}};function Ne(e,t=!1){let r=new lt(e,t);return()=>r.dispose()}function Nn(e){return!!e&&typeof e.then=="function"}dr(()=>{});var hr=Symbol.for("signal"),qn=Symbol.for("memo"),Bn=Symbol.for("signal-node");function d(e,t){let r=new ue(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),pr(),i});return Object.defineProperty(n,hr,{value:!0,enumerable:!0}),Object.defineProperty(n,Bn,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),X({kind:"signal",node:r,handle:n,name:t?.name,set:o}),ie()&&S(()=>$(r)),[n,o]}function h(e,t,r){let n=t,o=Oe(),s=new V(()=>fe(o,()=>{try{return n=e(n)}catch(u){if(Nn(u))return fr(u),n;throw u}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,hr,{value:!0,enumerable:!0}),Object.defineProperty(i,qn,{value:!0,enumerable:!0}),X({kind:"memo",node:s,handle:i,name:r?.name}),ie()&&S(()=>$(s)),i}function E(e,t){let r=t;return Ne(()=>{r=e(r)},!0)}function qe(e,t){let r=t;Ne(()=>{r=e(r)})}function Be(e,t){let r=t;return Ne(()=>{r=e(r)})}function x(e){return pt(e)}function g(e){return ge(e)}function ht(e){return pt(e),Promise.resolve()}function yr(){return[()=>!1,ht]}function br(){return Re(),Promise.resolve()}function vr(e,t,r){let n=Array.isArray(e),o,s=r?.defer??!1;return i=>{let u=n?e.map(l=>l()):e();if(s){s=!1,o=u;return}let c=ge(()=>t(u,o,i));return o=u,c}}function Kn(e,t,r){let n=[];return S(()=>{for(let o of n)o.dispose();n=[]}),h(()=>{let o=e()||[];return g(()=>{if(o.length===0){for(let c of n)c.dispose();return n=[],r?.fallback?r.fallback():[]}let s=new Map;for(let c of n)s.has(c.item)||s.set(c.item,c);let i=[],u=new Set;for(let c=0;c<o.length;c++){let l=o[c],v=s.get(l);if(v&&!u.has(v))v.setIndex(c),i.push(v),u.add(v);else{let p,b,m;q(T=>{m=T;let[U,P]=d(c,{name:"row index"});b=P,p=t(l,U)});let O={item:l,rendered:p,dispose:m,setIndex:b};i.push(O),u.add(O)}}for(let c of n)u.has(c)||c.dispose();return n=i,i.map(c=>c.rendered)})},void 0,{name:"mapArray"})}function $n(e,t,r,n){let o=[],s=[];return S(()=>{for(let i of s)i.dispose();o=[],s=[]}),h(()=>{let i=e()||[];return g(()=>{if(i.length===0){for(let p of s)p.dispose();return o=[],s=[],n?.fallback?n.fallback():[]}let u=new Map;for(let p=0;p<o.length;p++)u.set(o[p],s[p]);let c=[],l=[],v=new Set;for(let p=0;p<i.length;p++){let b=t(i[p]),m=u.get(b);if(m&&!v.has(b))m.setIndex(p),c.push(m);else{let O,T,U;q(P=>{U=P;let[M,C]=d(p,{name:"row index"});T=C;let ee=h(D=>{let I=(e()||[])[M()];return I??D},i[p]);O=r(ee,M)}),c.push({rendered:O,dispose:U,setIndex:T})}l.push(b),v.add(b)}for(let[p,b]of u)v.has(p)||b.dispose();return o=l,s=c,c.map(p=>p.rendered)})},void 0,{name:"keyArray"})}function Vn(e,t,r){let n=[];return S(()=>{for(let o of n)o.dispose();n=[]}),h(()=>{let o=e()||[];return g(()=>{if(o.length===0){for(let c of n)c.dispose();return n=[],r?.fallback?r.fallback():[]}let s=n.length,i=o.length;for(let c=s;c<i;c++){let l,v,p,b=o[c];q(m=>{p=m;let[O,T]=d(b);v=T,l=t(O,c)}),n.push({rendered:l,setItem:v,dispose:p})}for(let c=i;c<s;c++)n[c].dispose();i<s&&(n=n.slice(0,i));let u=Math.min(s,i);for(let c=0;c<u;c++)n[c].setItem(o[c]);return n.map(c=>c.rendered)})},void 0,{name:"indexArray"})}var Hn=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,Ke=typeof process>"u"?Hn:!1,Ln=Symbol.for("signal"),Gn=Symbol.for("memo"),Wn=Symbol.for("resource");function $e(e){return typeof e=="function"&&e[Ln]===!0}function mr(e){return typeof e=="function"&&e[Gn]===!0}function Tr(e){return typeof e=="function"&&e[Wn]===!0}function Sr(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function gr(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function wr(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function yt(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?yt(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var bt=null;function xr(e){bt=e}function le(e){bt&&bt(e)}var vt=null;function Or(e){vt=e}function Ve(e){return vt?vt(e):void 0}var mt=null;function Rr(e){mt=e}function He(){return mt?mt():void 0}var Tt=null;function kr(e){Tt=e}function Le(e,t){Tt&&Tt(e,t)}function Ar(e,t=(r,n)=>r===n){let r=new Map;return E(()=>{let n=e();for(let[o,s]of r){let[i,u]=s,c=t(o,n);i()!==c&&u(c)}}),n=>{let o=r.get(n);if(!o){let[s,i]=d(!1);o=[s,i],r.set(n,o);let u=e();i(t(n,u))}return o[0]()}}function _r(e,t){let[r,n]=d(e(),t);return E(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function Er(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,e(...o)},t)};return S(()=>{r!==void 0&&clearTimeout(r)}),n}function zn(e){return!!e&&typeof e.then=="function"}var St=Symbol();function de(e,t,r={}){let n,o;typeof t=="function"?(n=typeof e=="function"?e:()=>e,o=t):(n=()=>!0,o=e,t&&typeof t=="object"&&(r=t));let s=r.transport===!1?void 0:He(),i=s!==void 0?Ve(s):void 0,u=i!==void 0,[c,l]=d(i!==void 0?i.value:r.initialValue,{equals:!1}),[v,p]=d(void 0,{equals:!1}),[b,m]=d(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[O,T]=d(void 0,{equals:!1}),[U,P]=d(void 0,{equals:!1}),M=St,C=!1;E(()=>{let R=n();if(U(),R===!1||R===null||R===void 0){M=St,x(()=>{m("unresolved"),T(void 0),p(void 0)});return}let I=C;if(C=!1,M!==St&&R===M&&!I)return;if(M=R,u){u=!1;return}let B=!1;S(()=>B=!0);let W=g(b),me=g(c),te=W==="ready"||W==="refreshing";x(()=>{m(te?"refreshing":"pending"),p(void 0)});try{let F=o(R,{value:me,refetching:te});zn(F)?(T(F),le(F),F.then(z=>{B||(s!==void 0&&Le(s,z),x(()=>{l(()=>z),m("ready"),T(void 0)}))},z=>{B||x(()=>{p(z),m("errored"),T(void 0)})})):x(()=>{l(()=>F),m("ready"),T(void 0)})}catch(F){if(B)return;x(()=>{p(F),m("errored"),T(void 0)})}});let ee=()=>{let R=b();return R==="pending"||R==="refreshing"},D=(()=>{let R=v();if(R)throw R;if(ee()){let I=O();if(I)throw I}return c()});return Object.defineProperties(D,{state:{get:b},loading:{get:ee},error:{get:v},latest:{get:c}}),Object.defineProperty(D,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(D,Symbol.for("signal"),{value:!0,enumerable:!0}),[D,{mutate:l,refetch:()=>{C=!0,P(void 0)}}]}function gt(e,t=300){let[r,n]=d(e),[o,s]=d(e),[i,u]=d(!1),c,l=()=>{c!==void 0&&(clearTimeout(c),c=void 0)},v=()=>{l();let b=g(r);return s(()=>b),u(!1),b},p=(b=>{let m=typeof b=="function"?b(g(r)):b;return n(()=>m),u(!0),l(),c=setTimeout(v,t),m});return S(l),[o,p,{immediate:r,pending:i,flush:v,cancel:()=>{l(),u(!1)}}]}function Yn(e){return e!=null&&e!==""}function Pr(e,t,r={}){let{delay:n=300,initialValue:o,shouldFetch:s=Yn}=r,[i,u,c]=gt(e,n),l=()=>s(i())?i():!1,[v,{refetch:p}]=de(l,t,o===void 0?{}:{initialValue:o});return[v,{...c,query:i,setQuery:u,refetch:p}]}function Ge(e){if(typeof e=="function"&&!e.length){let t=e();return $e(t)?t:Ge(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=Ge(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Cr(e){let t=h(e);return Ke?h(()=>Ge(t()),void 0,{name:"children"}):h(()=>Ge(t()))}var We=H();cr((e,t)=>{let r=Me(t,We);r&&(r.increment(),e.finally(()=>r.decrement()))});function Dr(){let[e,t]=d(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function Ir(e,t){return ce(We,e,t)}var jr=H();lr((e,t)=>{let r=Me(t,jr);return r?(r.setError(e),!0):!1});function Fr(){let[e,t]=d(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function Ur(e,t){return ce(jr,e,t)}var Mr={State:ue,Computed:V,subtle:{Watcher:ae,untrack:ge,currentComputed:or,hasSinks:sr}};var Xn=Symbol.for("signal"),Jn=Symbol.for("fluixi-proxy");function Qn(e,t){let[r,n]=d(e,t);return Object.assign(r,{set:n})}function Zn(e,t,r){return h(e,t,r)}function eo(e,t){return E(e,t)}function to(e){return q(e)}function ro(e,t){return Be(e,t)}function no(e,t){qe(e,t)}function oo(e,t){return H(e,t)}function so(e){return Ue(e)}function Nr(...e){let[t,r]=de(...e);return Object.assign(t,r)}var Rt="1.0.0-alpha.92",Vr=Rt.split(".")[0],qr=`__fluixi_signal_state_v${Vr}__`,io=`__fluixi_signal_builds_v${Vr}__`,uo=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)};function Hr(){return{consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:uo,onSuspend:null,onError:null,observer:null}}var wt=globalThis;function ao(e){let t=Hr(),r=e;for(let n of Object.keys(t))n in e||(r[n]=t[n]);return e}function co(){let e=wt[qr];return e?ao(e):wt[qr]=Hr()}var f=co();(wt[io]??=[]).push(Rt);function fo(e){return f.observer=e,()=>{f.observer===e&&(f.observer=null)}}var pe=[],lo;function kt(e){let t=f.observer;t&&t.created(e.parents===void 0?{...e,parents:pe,origin:e.origin??lo}:e)}function po(e){return f.observer?(pe.push(e),!0):!1}function ho(){pe.pop()}function yo(e){f.observer?.ran?.(e)}function bo(e,t){f.observer?.wrote?.(e,t)}function vo(e){f.observer?.contextCreated?.(e)}function mo(e,t,r){let n=f.observer;!n?.context||!pe.length||n.context(pe[pe.length-1],e,t,r)}function At(e){f.observer?.disposed?.(e)}var To="__FLUIXI_DEVTOOLS_HOOK__",Br=globalThis[To];if(typeof Br?.inject=="function")try{Br.inject({observeReactiveNodes:fo,version:Rt})}catch{}function Lr(){return f.observer!=null}var Kr=0,$r=1,ke=2,Gr=class{constructor(){this.observers=null,this.watchers=null,this.version=0}updateIfNecessary(){}track(){if(f.untracked)return;let e=f.consumer;e&&((this.observers??=new Set).add(e),(e.sources??=new Set).add(this))}},So=class extends Gr{constructor(e,t){super(),this._value=e,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(e){if(!this._equals(this._value,e)){if(this._value=e,this.version++,bo(this,f.consumer),this.observers)for(let t of[...this.observers])t.markDirty(ke);xt(this)}}peek(){return this._value}},Wr=class extends Gr{constructor(e,t){super(),this._threw=!1,this._initialized=!1,this.state=ke,this.sources=null,this._fn=e,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){if(f.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===$r&&this.sources){for(let e of this.sources)if(e.updateIfNecessary(),this.state===ke)break}(this.state===ke||!this._initialized)&&this.recompute(),this.state=Kr}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let e=f.consumer,t=f.untracked,r=po(this);f.consumer=this,f.untracked=!1;let n,o=!1,s;try{n=this._fn()}catch(u){o=!0,s=u,n=this._value}finally{f.consumer=e,f.untracked=t,r&&ho()}let i=!this._initialized||this._threw!==o||(o?s!==this._error:!this._equals(this._value,n));if(this._initialized=!0,this._threw=o,this._error=s,this._value=n,yo(this),i){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(ke);xt(this)}}markDirty(e){if(this.state>=e)return;let t=this.state===Kr;if(this.state=e,t){if(this.observers)for(let r of[...this.observers])r.markDirty($r);xt(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function xt(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var go=class{constructor(e){this._watched=new Set,this._pending=new Set,this._notifyFn=e}watch(...e){for(let t of e)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...e){for(let t of e)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let e=[...this._pending];return this._pending.clear(),e}_notify(e){if(!this._watched.has(e)||this._pending.has(e))return;let t=this._pending.size===0;this._pending.add(e),t&&this._notifyFn()}};function wo(e){if(f.untracked)return e();f.untracked=!0;try{return e()}finally{f.untracked=!1}}function zr(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function Yr(e,t){let r=Symbol(t??"context");return vo(r),{id:r,defaultValue:e,Provider:o=>{mo(r,"provide",o.value);let s=f.owner,i=zr(s);(i.contexts=new Map).set(r,o.value),s&&(s.owned??=[]).push(i),f.owner=i;try{return o.children}finally{f.owner=s}}}}function Xr(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function xo(e){f.onSuspend=e}function Oo(e){return f.onSuspend?(f.onSuspend(e,f.owner),!0):!1}function Ro(e){f.onError=e}function ko(){return f.owner}function Jr(e,t){let r=f.owner;f.owner=e;try{return t()}finally{f.owner=r}}function Qr(e){if(f.owner){if(f.owner.disposed){e();return}(f.owner.cleanups??=[]).push(e)}}function Ot(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)Ot(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}t&&(e.disposed=!0)}}function Ao(e){f.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function _o(e){e.queued||(e.queued=!0,f.queue.push(e),!f.scheduled&&f.batchDepth===0&&(f.scheduled=!0,f.hostSchedule(_t)))}function _t(){if(f.scheduled=!1,f.flushing)return;f.flushing=!0;let e=0;try{for(;f.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=f.queue;f.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{f.flushing=!1}}function Eo(){f.batchDepth===0&&_t()}function Po(e){f.batchDepth++;try{return e()}finally{--f.batchDepth===0&&_t()}}var Co=class{constructor(e,t=!1){this.queued=!1,this.disposed=!1,this.owner=zr(f.owner),f.owner&&(f.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new Wr(()=>{Ot(this.owner,!1),Jr(this.owner,()=>{let r=e();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),kt({kind:"effect",node:this.computed,handle:this,internal:!t}),this.watcher=new go(()=>_o(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(e){if(e&&typeof e.then=="function"&&f.onSuspend){f.onSuspend(e,this.owner);return}if(f.onError&&f.onError(e,this.owner))return;throw e}}}dispose(){this.disposed||(this.disposed=!0,At(this.computed),this.watcher.unwatch(this.computed),Ot(this.owner))}};function Do(e,t=!1){let r=new Co(e,t);return()=>r.dispose()}function Io(e){return!!e&&typeof e.then=="function"}Ao(()=>{});var Zr=Symbol.for("signal"),jo=Symbol.for("memo"),Fo=Symbol.for("signal-node");function Et(e,t){let r=new So(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),Eo(),i});return Object.defineProperty(n,Zr,{value:!0,enumerable:!0}),Object.defineProperty(n,Fo,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),kt({kind:"signal",node:r,handle:n,name:t?.name,set:o}),Lr()&&Qr(()=>At(r)),[n,o]}function ze(e,t,r){let n=t,o=ko(),s=new Wr(()=>Jr(o,()=>{try{return n=e(n)}catch(u){if(Io(u))return Oo(u),n;throw u}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,Zr,{value:!0,enumerable:!0}),Object.defineProperty(i,jo,{value:!0,enumerable:!0}),kt({kind:"memo",node:s,handle:i,name:r?.name}),Lr()&&Qr(()=>At(s)),i}function Ae(e,t){let r=t;return Do(()=>{r=e(r)},!0)}function Pt(e){return Po(e)}function en(e){return wo(e)}var Bi=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0;var Uo=Yr();xo((e,t)=>{let r=Xr(t,Uo);r&&(r.increment(),e.finally(()=>r.decrement()))});var Mo=Yr();Ro((e,t)=>{let r=Xr(t,Mo);return r?(r.setError(e),!0):!1});var Ye=Symbol.for("fluixi-proxy");var ye=Symbol("store-raw"),J=Symbol("store-node"),tn=Symbol("store-has"),Qe=Symbol("store-self"),Ze=Symbol("store-track"),un=Symbol("store-name"),an=Symbol("store-store"),_e=new WeakMap,Ct=new WeakMap,be=new WeakMap,et=new WeakMap;function No(e,t){if(!he(e)||!ie())return;let r=new Set,n=i=>{if(!(!he(i)||r.has(i))){r.add(i);for(let u of Object.values(i))n(u)}};n(et.get(t)??t);let o=new Set,s=i=>{if(!he(i))return;let u=i;if(r.has(u)||o.has(u))return;o.add(u);let c=_e.get(u);if(c){for(let l of c.keys.values())$(l);c.all&&$(c.all),_e.delete(u),be.delete(u),Ct.delete(u)}for(let l of Object.values(u))s(l)};s(e)}var tt=(e,t,r)=>r?`${e}[${String(t)}]`:`${e}.${String(t)}`;function cn(e,t,r){let n=t?.owner,o=n&&r!==void 0?tt(n.name,r,t?.array):void 0,[s,i]=zt(n?.store,()=>Et(e,o?{name:o}:void 0)),u=s;return u.$=i,u}function rt(e){let t=_e.get(e);return t?t.owner||(t.owner=be.get(e)):_e.set(e,t={keys:new Map,owner:be.get(e),array:Array.isArray(e)}),t}function rn(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=cn(r,e,t)),n}function qo(e,t,r,n){let o=be.get(e);if(o&&o.store===t&&o.name===r)return;let s={store:t,name:r};be.set(e,s),et.set(e,et.get(n)??n);let i=_e.get(e);if(i&&(i.owner=s,!!ie())){for(let[u,c]of i.keys)ct(c,t,tt(r,u,i.array));i.all&&ct(i.all,t,tt(r,"*",i.array))}}function nn(e){let t=rt(e);(t.all||(t.all=cn(void 0,t,"*")))()}function on(e,t){e.$(typeof t=="function"?()=>t:t)}function he(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Xe(e){if(!he(e))return e;let t=Ct.get(e);if(t)return t;let r=new Proxy(e,Bo);return Ct.set(e,r),r}var Bo={get(e,t,r){if(t===ye||t===J)return e;if(t===Ye)return r;if(t===tn)return c=>c in e;if(t==="__proxy")return!0;if(t===Ze||t===Qe)return nn(e),r;let n=e[t];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return n;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(r);let s=rt(e),i=rn(s,t,n),u=i();return he(u)?(s.owner&&qo(u,i,tt(s.owner.name,t,s.array),e),Xe(u)):u},set(){return!0},deleteProperty(e,t){return t in e&&j(e,t,void 0),!0},has(e,t){return t===ye||t===Ye||t===J||t===tn||t===Qe||t===Ze?!0:(rn(rt(e),t,e[t])(),t in e)},ownKeys(e){return nn(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function fn(e,t=new Set){if(e==null||typeof e!="object")return e;let r=e[ye]??e;if(t.has(r)||!he(r))return r;t.add(r);let n=!1,o=i=>{let u=fn(i,t);return u!==i&&(n=!0),u};if(Array.isArray(r)){let i=r.map(o);return n?i:r}let s={};for(let i of Object.keys(r))s[i]=o(r[i]);return n?s:r}function j(e,t,r){let n=fn(r),o=e[t];if(o===n&&(n!==void 0||t in e))return;let s=Array.isArray(e),i=s?e.length:0;n===void 0?delete e[t]:e[t]=n;let u=rt(e),c=u.keys.get(t);if(c&&on(c,n),No(o,e),s&&e.length!==i){let l=u.keys.get("length");l&&on(l,e.length)}u.all&&u.all.$(void 0)}function Dt(e,t){return typeof e=="function"?e(t):e}function It(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?It(o,n):j(e,r,n)}}function nt(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function ln(e,t,r){let n=t.length-1;for(let s=0;s<n;s++){let i=t[s];if(i==="*"){let c=t.slice(s+1);if(Array.isArray(e))for(let l=0;l<e.length;l++)ln(e[l],c,r);return}let u=e[i];(u==null||typeof u!="object")&&(u=/^\d+$/.test(t[s+1])?[]:{},j(e,i,u)),e=u}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)j(e,s,Dt(r,e[s]));return}j(e,o,Dt(r,e[o]))}function sn(e,t,r){ln(e,nt(t),r)}function Ko(e){return Array.isArray(e)&&e.length>0&&e.every(t=>Array.isArray(t)&&t.length>=2&&typeof t[0]=="string")}function Je(e,t){for(let r=e.length-1;r>=t.length;r--)j(e,String(r),void 0);e.length!==t.length&&j(e,"length",t.length);for(let r=0;r<t.length;r++)j(e,String(r),t[r])}function $o(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&It(e,n);return}if(Array.isArray(r)&&t.length===1){if(Ko(r)){for(let n of r)sn(e,n[0],n[1]);return}if(Array.isArray(e)){Je(e,r);return}if(r.length===0)return;throw new TypeError("[fluixi] set() was given an array that is neither a batch of [path, value] pairs nor a replacement for an array root. Name the path you meant, as in set('items', [...]).")}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){It(e,r);return}if(t.length>=3){jt(e,t.slice(0,-1),t[t.length-1]);return}sn(e,String(r),t[1])}function Vo(e,t){if(typeof t=="function"){if(!Array.isArray(e))return[];let r=[];for(let n=0;n<e.length;n++)t(e[n],n)&&r.push(n);return r}if(Array.isArray(t))return Array.isArray(e)?t.map(Number):t.map(String);if(t&&typeof t=="object"&&("from"in t||"to"in t||"by"in t)){if(!Array.isArray(e))return[];let r=t.by??1,n=t.from??0,o=t.to??e.length-1,s=[];for(let i=n;i<=o;i+=r)i>=0&&i<e.length&&s.push(i);return s}return t==="*"?Array.isArray(e)?e.map((r,n)=>n):Object.keys(e??{}):[t]}function jt(e,t,r){if(e==null)return;let[n,...o]=t;if(typeof n=="string"){let i=nt(n);if(i.length>1){jt(e,[...i,...o],r);return}}let s=Vo(e,n);if(o.length===0){for(let i of s)j(e,i,Dt(r,e[i]));return}for(let i of s){let u=e[i];if(u==null||typeof u!="object"){let c=o[0];u=typeof c=="number"||/^\d+$/.test(String(c))?[]:{},j(e,i,u)}jt(u,o,r)}}function Ft(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ft);let t={};for(let r of Object.keys(e))t[r]=Ft(e[r]);return t}function L(e,t){let r=e;for(let n of nt(t)){if(r==null)return;r=r[n]}return r}var G=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>Pt(()=>$o(this.root,n))),t&&typeof t=="object"&&(be.set(t,{store:this,name:r.name??"store"}),et.set(t,t)),X({kind:"store",node:this,handle:()=>this.root,name:r.name})}get state(){return Xe(this.root)}get proxy(){return Xe(this.root)}get accessor(){return(()=>Xe(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return ve(this.state);let r=this.state;for(let n of nt(t)){if(r==null)return;r=r[n]}return ve(r)}select(t){return ze(()=>t(this.state))}subscribe(t){return Ae(()=>t(this.state))}watch(t,r){let n;return Ae(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return ze(()=>this.state[t])}produce(t){this.set((r=>{let n=Ft(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=L(this.root,t);this.set(t,n.concat(r))}pop(t){let r=L(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=L(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=L(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=L(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=L(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}replace(t,r){if(arguments.length>=2){let o=L(this.root,String(t)),s=r;if(Array.isArray(o)&&Array.isArray(s)){Je(o,s);return}this.set(t,s);return}let n=this.root;if(Array.isArray(n)&&Array.isArray(t)){Je(n,t);return}this.set(t)}clear(t){let r=t===void 0?this.root:L(this.root,t);if(Array.isArray(r)){Je(r,[]);return}if(r&&typeof r=="object")for(let n of Object.keys(r))j(r,n,void 0)}toObservable(){let[t]=Et(this.state);return t.toObservable()}dispose(){}},Ho=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","replace","clear","unwrap","toObservable"];function dn(e,t){for(let r of Ho)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function Ee(e,t={immutable:!0}){let r=new G(e,t);return dn(r.set,r),[r.proxy,r.set]}function Ut(e,t={}){return new G(e,{...t,immutable:!1})}function pn(e,t={}){let r=new G(e(),t);return Ae(()=>r.set(e())),r}function hn(e,t,r){return Ae(()=>r(t(e)))}function yn(e,t,r){return ze(()=>t(e),void 0,r)}function bn(e,t={}){let r=new G(e,t),n=(()=>r.proxy);return dn(n,r),n}function ve(e){if(e==null||typeof e!="object")return e;let t=e[ye];return t!==void 0?t:e}function Mt(e){return en(()=>ve(e))}function vn(e){return ot(e)}function mn(e){return ot(e)?e[J]:null}function Tn(e){return e&&typeof e=="object"&&J in e?e[J]:null}function ot(e){return!!e&&typeof e=="object"&&(Ye in e||e.__proxy===!0)}function Sn(e){return e}var gn=Object.freeze({createStore:Ee,createMutableStore:Ut,batch:Pt,unwrap:ve,untrackStore:Mt});function Nt(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Nt);let t={};for(let r of Object.keys(e))t[r]=Nt(e[r]);return t}function wn(e){return t=>{let r=Nt(t);return e(r),r}}function xn(e,t={}){return()=>e}function On(e,t){let[r,n]=Ee(e,t);return new Proxy(r,{get:(o,s)=>s==="set"?n:o[s],has:(o,s)=>s==="set"||Reflect.has(o,s)})}function Lo(e,t,r){return h(()=>t(e()),void 0,r)}function Go(e,t,r){return h(()=>e().filter(t),void 0,r)}function Wo(e,t,r,n){return h(()=>e().reduce(t,r),void 0,n)}function zo(e,t,r){return h(()=>e().find(t),void 0,r)}function Yo(e,t,r){return h(()=>e().some(t),void 0,r)}function Xo(e,t,r){return h(()=>e().every(t),void 0,r)}function Jo(e,t,r){return h(()=>[...e()].sort(t),void 0,r)}function Qo(e,t){return h(()=>[...new Set(e())],void 0,t)}function Zo(e,t,r){return h(()=>{let n=e.map(o=>o());return t(n)},void 0,r)}function es(...e){return new K(t=>{let r=()=>e.map(o=>typeof o=="function"?o():o.get()),n=e.map(o=>typeof o=="function"&&o.subscribe?o.subscribe(()=>{t.next(r())}):typeof o!="function"?o.subscribe(()=>{t.next(r())}):E(()=>{t.next(r())}));return()=>{n.forEach(o=>{typeof o=="function"?o():o&&typeof o.unsubscribe=="function"&&o.unsubscribe()})}})}function ts(e,t,r){return h(()=>e()||t(),void 0,r)}function rs(e,t,r,n){return h(()=>r(e(),t()),void 0,n)}function ns(e,t,r){return h(()=>t(e()),void 0,{equals:r,internal:!0})}function os(e,t,r){return h(()=>{let n=e(),o={};for(let s of t)o[s]=n[s];return o},void 0,r)}function ss(e,t,r){return h(()=>{let o={...e()};for(let s of t)delete o[s];return o},void 0,r)}function is(e,t,r,n){return h(()=>e()?t():r(),void 0,n)}function us(e,t,r){return h(()=>e()?t():void 0,void 0,r)}function as(e,t,r){let[n,o]=d(e()),s;return h(()=>{let i=e();clearTimeout(s),s=setTimeout(()=>o(()=>i),t)}),n}function cs(e,t,r){let[n,o]=d(e()),s=0,i;return h(()=>{let u=e(),c=Date.now();c-s>=t?(s=c,o(()=>u)):(clearTimeout(i),i=setTimeout(()=>{s=Date.now(),o(()=>u)},t-(c-s)))}),n}function fs(e){let t=e;for(;typeof t=="function";)t=t();return t}var Z=new Map,Q=new Map,ls=0,ds=Symbol.for("signal"),ps=Symbol.for("resource");function hs(e,t,r={}){let n,o,s;typeof t=="function"?(n=e,o=t,s=r):(n=()=>!0,o=e,s=t??r);let{ttl:i=1/0,name:u=`_auto_${ls++}`,staleWhileRevalidate:c=!0}=s,l=u,v=y=>`${l}:${JSON.stringify(y)}`,p=y=>i===1/0||Date.now()-y.timestamp<=i,[b,m]=d(void 0,{equals:!1}),[O,T]=d("unresolved",{equals:!1}),[U,P]=d(void 0,{equals:!1}),[M,C]=d(void 0,{equals:!1}),[ee,D]=d(!1),[R,I]=d(0,{equals:!1}),B=Symbol("unset"),W=B,me=!1,te=!1;function F(y,A,_,N){if(Q.has(A)){Q.get(A).then(w=>{N()||z(w,_)},w=>{!N()&&!_&&qt(w)}),_||C(Q.get(A));return}let Te=Promise.resolve(o(y)).then(w=>(Z.set(A,{value:w,timestamp:Date.now()}),Q.delete(A),w),w=>{throw Q.delete(A),w});Q.set(A,Te),_||(le(Te),C(Te)),Te.then(w=>{N()||z(w,_)},w=>{!N()&&!_&&qt(w)})}function z(y,A){x(()=>{m(()=>y),T("ready"),D(!1),C(void 0),P(void 0)})}function qt(y){x(()=>{P(y),T("errored"),C(void 0)})}E(()=>{let y=n();if(R(),y===!1||y===null||y===void 0){W=B,x(()=>{T("unresolved"),C(void 0),P(void 0)});return}let A=me,_=te;me=!1,te=!1;let N=v(y);_&&Z.delete(N);let Te=W===B||y!==W;W=y;let w=!1;S(()=>{w=!0});let re=Z.get(N);if(re&&p(re)&&!A&&!_){(g(O)!=="ready"||g(b)!==re.value)&&x(()=>{m(()=>re.value),T("ready"),D(!1),P(void 0)});return}if(re&&c&&!_){x(()=>{m(()=>re.value),T("ready"),D(!0),P(void 0),C(void 0)}),F(y,N,!0,()=>w);return}let Bt=g(O),Rn=Bt==="ready"||Bt==="refreshing";x(()=>{T(Rn?"refreshing":"pending"),P(void 0),D(!1)}),F(y,N,!1,()=>w)});let Pe=(()=>{let y=U();if(y)throw y;if(O()==="pending"){let _=M();if(_)throw _}return b()});return Object.defineProperty(Pe,ps,{value:!0,enumerable:!0}),Object.defineProperty(Pe,ds,{value:!0,enumerable:!0}),Object.defineProperties(Pe,{state:{get:O},loading:{get:()=>{let y=O();return y==="pending"||y==="refreshing"}},error:{get:U},latest:{get:b},stale:{get:ee}}),[Pe,{mutate:m,refetch:()=>{me=!0,I(y=>y+1)},invalidate:()=>{let y=g(n);y!=null&&y!==!1&&Z.delete(v(y)),te=!0,I(A=>A+1)}}]}function ys(e){let t=`${e}:`;for(let r of Z.keys())r.startsWith(t)&&Z.delete(r)}function bs(){Z.clear(),Q.clear()}return Cn(vs);})();
|
|
1
|
+
/*! @fluixi/reactive v1.0.0-alpha.94 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
|
+
"use strict";var Fluixi=(()=>{var lt=Object.defineProperty;var Hn=Object.getOwnPropertyDescriptor;var Ln=Object.getOwnPropertyNames;var Gn=Object.prototype.hasOwnProperty;var Wn=(e,t)=>{for(var r in t)lt(e,r,{get:t[r],enumerable:!0})},zn=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ln(t))!Gn.call(e,o)&&o!==r&<(e,o,{get:()=>t[o],enumerable:!(n=Hn(t,o))||n.enumerable});return e};var Yn=e=>zn(lt({},"__esModule",{value:!0}),e);var Fs={};Wn(Fs,{$NAME:()=>On,$NODE:()=>re,$PROXY:()=>bo,$RAW:()=>me,$SELF:()=>tt,$SIGNAL:()=>vo,$STORE:()=>kn,$TRACK:()=>rt,Observable:()=>$,SafeSubscriber:()=>Ue,Signal:()=>en,Store:()=>W,StoreAPI:()=>qn,Subject:()=>pt,Subscriber:()=>se,Subscription:()=>oe,SuspenseContext:()=>Xe,VERSION:()=>Q,__DEV__:()=>Ge,adoptReactiveScope:()=>ir,batch:()=>R,cachedResource:()=>js,childOwner:()=>Oo,clearCachedResources:()=>Is,closeReactiveScope:()=>sr,combineSignal:()=>ms,combineSignals:()=>Ts,computed:()=>xo,context:()=>Ro,createChildOwner:()=>Ke,createComputed:()=>He,createComputedStore:()=>Pn,createContext:()=>L,createDebounce:()=>Gr,createDebouncedResource:()=>Wr,createDebouncedSignal:()=>At,createDeferred:()=>Lr,createEffect:()=>C,createErrorBoundary:()=>Qr,createMemo:()=>y,createMutableStore:()=>$t,createRenderEffect:()=>Le,createResource:()=>ye,createResourceCache:()=>ze,createRoot:()=>B,createSelector:()=>Hr,createSignal:()=>p,createStore:()=>je,createStoreEffect:()=>Dn,createStoreMemo:()=>jn,createSuspenseBoundary:()=>Yr,currentResourceCache:()=>Ce,debounceSignal:()=>As,disposeScope:()=>gr,distinctSignal:()=>bs,effect:()=>So,everySignal:()=>ys,filterSignal:()=>ls,findSignal:()=>ps,flush:()=>Pr,getNode:()=>Un,getOwner:()=>Ae,getServerData:()=>pe,getStoreNode:()=>Mn,guardSignal:()=>ks,indexArray:()=>co,isComponent:()=>Fr,isMemo:()=>jr,isOwnerDisposed:()=>wr,isProvider:()=>Mr,isResource:()=>Ir,isSignal:()=>We,isStore:()=>Fn,isStoreProxy:()=>ct,isSuspense:()=>Ur,joinedVersions:()=>er,keyArray:()=>io,makeArrayFlat:()=>gt,mapArray:()=>so,mapSignal:()=>fs,markReactiveScope:()=>ur,memo:()=>To,mergeSignal:()=>Ss,modifiable:()=>Nn,nextResourceId:()=>he,observeReactiveNodes:()=>ht,omitSignal:()=>Rs,on:()=>Dr,onCleanup:()=>T,openReactiveScope:()=>nr,operate:()=>Xn,pickSignal:()=>xs,produceUtil:()=>Bn,provide:()=>le,provideErrorBoundary:()=>Zr,provideSuspense:()=>Xr,reactiveScopeOf:()=>ar,readChildren:()=>zr,readSignal:()=>Cs,reconcileUtil:()=>Kn,reduceSignal:()=>ds,renderEffect:()=>wo,reportReactiveBinding:()=>hr,reportReactiveContext:()=>ce,reportReactiveContextCreated:()=>qe,reportReactiveDirective:()=>vr,reportReactiveProps:()=>yr,reportResourceData:()=>te,resource:()=>tn,root:()=>go,runWithOwner:()=>de,selectSignal:()=>ws,setOwner:()=>mt,setResourceCacheScope:()=>Vr,setResourceDataSink:()=>Kr,setResourceIdSource:()=>Br,setResourceTracker:()=>Nr,setServerDataGetter:()=>qr,signal:()=>mo,someSignal:()=>hs,sortSignal:()=>vs,startTransition:()=>St,store:()=>$n,throttleSignal:()=>_s,trackResourcePromise:()=>ee,untrack:()=>S,untrackStore:()=>Vt,unwrap:()=>Se,useContext:()=>xr,useTransition:()=>Er,whenSignal:()=>Os,withReactiveScope:()=>or,wrap:()=>In,zipSignal:()=>gs});var Q="1.0.0-alpha.94";function dt(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function Yt(e){return e==null||Array.isArray(e)||typeof e=="function"||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error?!1:typeof e=="object"}var oe=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:r}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let n of t)n.remove(this);if(r){for(let n of r)if(dt(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if(Yt(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:r,_subscriptions:n}=this;if(r){if(dt(t))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(t.unsubscribe)try{t.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(t);n!==-1&&(r.splice(n,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:r}=this;r?Array.isArray(r)?r.push(t):this._parentOrParents=[r,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:r}=this;if(r===t)this._parentOrParents=null;else if(Array.isArray(r)){let n=r.indexOf(t);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var se=class extends oe{constructor(r,n,o){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:n,complete:o}:s={},this.destination=s}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(n){throw n}else throw r;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(r){this.error(r);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},Ue=class extends se{constructor(r,n,o,s){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(r)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};function Xn(e){return new se(e.next,e.error,e.complete)}var $=class extends oe{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,r,n){let o;t instanceof se?o=t:o=new Ue(t,r,n);let{_subscribe:s}=this;try{let i=s.call(this,o);i&&(typeof i=="function"||typeof i.unsubscribe=="function")&&o.add(i)}catch(i){o.error(i)}return o}pipe(...t){return t.length===0?this:t.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((t,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>t(n)})})}};var pt=class extends ${constructor(){super(r=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)r.error(this.thrownError);else if(this.isStopped)r.complete();else return this.observers.push(r),()=>{let n=this.observers.indexOf(r);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(r){if(this.isStopped)return;let{observers:n}=this,o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].next?.(r)}error(r){if(this.isStopped)return;this.hasError=!0,this.thrownError=r,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].error?.(r)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:r}=this;this.observers=[];let n=r.length,o=r.slice();for(let s=0;s<n;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new $(n=>this.subscribe(n))}};var Jt=Q.split(".")[0],Xt=`__fluixi_signal_state_v${Jt}__`,Qt=`__fluixi_signal_builds_v${Jt}__`,Jn=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)};function Zt(){return{consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Jn,onSuspend:null,onError:null,observer:null}}var Me=globalThis;function Qn(e){let t=Zt(),r=e;for(let n of Object.keys(t))n in e||(r[n]=t[n]);return e}function Zn(){let e=Me[Xt];return e?Qn(e):Me[Xt]=Zt()}var u=Zn();(Me[Qt]??=[]).push(Q);function er(){return[...new Set(Me[Qt]??[])]}function ht(e){return u.observer=e,()=>{u.observer===e&&(u.observer=null)}}var k=[],Ne;function rr(e,t){if(!u.observer)return t();let r=Ne;Ne=e;try{return t()}finally{Ne=r}}var ie;function nr(e){let t={};return u.observer?.scope?.(t,e,ie),t}function or(e,t){if(!u.observer)return t();let r=ie;ie=e;try{return t()}finally{ie=r}}function sr(e){u.observer?.scopeEnded?.(e)}function ir(e,t){u.observer?.scopeAdopted?.(e,t)}var cr=Symbol.for("fluixi.reactiveScope");function ur(e,t){Object.defineProperty(e,cr,{value:t,configurable:!0,enumerable:!1})}function ar(e){return e!==null&&(typeof e=="object"||typeof e=="function")?e[cr]??void 0:void 0}function Z(e){let t=u.observer;t&&t.created(e.parents===void 0?{...e,parents:k,origin:e.origin??Ne,scope:e.scope??ie}:{...e,scope:e.scope??ie})}function fr(e){return u.observer?(k.push(e),!0):!1}function lr(){k.pop()}function dr(e){u.observer?.ran?.(e)}function pr(e,t){u.observer?.wrote?.(e,t)}function hr(e,t,r,n){let o=u.observer;!o?.bound||!k.length||o.bound(k[k.length-1],e,t,r,n)}function yr(e){let t=u.observer;!t?.props||!k.length||!e||t.props(k[k.length-1],e)}function vr(e,t,r,n){let o=u.observer;!o?.directive||!k.length||o.directive(k[k.length-1],e,t,r,n)}function qe(e){u.observer?.contextCreated?.(e)}function ce(e,t,r){let n=u.observer;!n?.context||!k.length||n.context(k[k.length-1],e,t,r)}function yt(e,t,r){u.observer?.moved?.(e,t,r)}function V(e){u.observer?.disposed?.(e)}var eo="__FLUIXI_DEVTOOLS_HOOK__",tr=globalThis[eo];if(typeof tr?.inject=="function")try{tr.inject({observeReactiveNodes:ht,version:Q})}catch{}function ue(){return u.observer!=null}var br=0,mr=1,xe=2,Be=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(u.untracked)return;let t=u.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},ae=class extends Be{constructor(t,r){super(),this._value=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,pr(this,u.consumer),this.observers)for(let r of[...this.observers])r.markDirty(xe);vt(this)}}peek(){return this._value}},H=class extends Be{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=xe;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){if(u.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===mr&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===xe)break}(this.state===xe||!this._initialized)&&this.recompute(),this.state=br}recompute(){if(this.sources){for(let l of this.sources)l.observers?.delete(this);this.sources.clear()}let r=u.consumer,n=u.untracked,o=fr(this);u.consumer=this,u.untracked=!1;let s,i=!1,c;try{s=this._fn()}catch(l){i=!0,c=l,s=this._value}finally{u.consumer=r,u.untracked=n,o&&lr()}let a=!this._initialized||this._threw!==i||(i?c!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=i,this._error=c,this._value=s,dr(this),a){if(this.version++,this.observers)for(let l of[...this.observers])l.markDirty(xe);vt(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===br;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty(mr);vt(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function vt(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var fe=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function Re(e){if(u.untracked)return e();u.untracked=!0;try{return e()}finally{u.untracked=!1}}function Tr(){return u.consumer}function Sr(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function Ke(e){let t=ke(e);return e&&(e.owned??=[]).push(t),t}function gr(e,t=!0){Oe(e,t)}function wr(e){return!!e&&e.disposed===!0}function ke(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function L(e,t){let r=Symbol(t??"context");return qe(r),{id:r,defaultValue:e,Provider:o=>{ce(r,"provide",o.value);let s=u.owner,i=ke(s);(i.contexts=new Map).set(r,o.value),s&&(s.owned??=[]).push(i),u.owner=i;try{return o.children}finally{u.owner=s}}}}function xr(e){let t=u.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id)){let r=t.contexts.get(e.id);return ce(e.id,"read",r),r}t=t.parent}return ce(e.id,"read",e.defaultValue),e.defaultValue}function $e(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function le(e,t,r){let n=ke(u.owner);(n.contexts=new Map).set(e.id,t),u.owner&&(u.owner.owned??=[]).push(n);let o=u.owner;u.owner=n;try{return r()}finally{u.owner=o}}function Rr(e){u.onSuspend=e}function Or(e){return u.onSuspend?(u.onSuspend(e,u.owner),!0):!1}function kr(e){u.onError=e}function Ae(){return u.owner}function mt(e){let t=u.owner;return u.owner=e,t}function de(e,t){let r=u.owner;u.owner=e;try{return t()}finally{u.owner=r}}function T(e){if(u.owner){if(u.owner.disposed){e();return}(u.owner.cleanups??=[]).push(e)}}function Oe(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)Oe(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}t&&(e.disposed=!0)}}function B(e){let t=ke(u.owner);u.owner&&(u.owner.owned??=[]).push(t);let r=u.owner;u.owner=t;try{return e(()=>Oe(t))}finally{u.owner=r}}function Ar(e){u.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function to(e){e.queued||(e.queued=!0,u.queue.push(e),!u.scheduled&&u.batchDepth===0&&(u.scheduled=!0,u.hostSchedule(_e)))}function _e(){if(u.scheduled=!1,u.flushing)return;u.flushing=!0;let e=0;try{for(;u.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=u.queue;u.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{u.flushing=!1}}function _r(){u.batchDepth===0&&_e()}function Tt(e){u.batchDepth++;try{return e()}finally{--u.batchDepth===0&&_e()}}var bt=class{constructor(t,r=!1,n){this.queued=!1;this.disposed=!1;this.owner=ke(u.owner),u.owner&&(u.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new H(()=>{Oe(this.owner,!1),de(this.owner,()=>{let o=t();typeof o=="function"&&(this.owner.cleanups??=[]).push(o)})}),Z({kind:"effect",node:this.computed,handle:this,internal:!r,...n?{name:n}:{}}),this.watcher=new fe(()=>to(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&u.onSuspend){u.onSuspend(t,this.owner);return}if(u.onError&&u.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,V(this.computed),this.watcher.unwatch(this.computed),Oe(this.owner))}};function Ve(e,t=!1,r){let n=new bt(e,t,r);return()=>n.dispose()}function ro(e){return!!e&&typeof e.then=="function"}Ar(()=>{});var Cr=Symbol.for("signal"),no=Symbol.for("memo"),oo=Symbol.for("signal-node");function p(e,t){let r=new ae(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),_r(),i});return Object.defineProperty(n,Cr,{value:!0,enumerable:!0}),Object.defineProperty(n,oo,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),Z({kind:"signal",node:r,handle:n,name:t?.name,set:o}),ue()&&T(()=>V(r)),[n,o]}function y(e,t,r){let n=t,o=Ae(),s=new H(()=>de(o,()=>{try{return n=e(n)}catch(c){if(ro(c))return Or(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,Cr,{value:!0,enumerable:!0}),Object.defineProperty(i,no,{value:!0,enumerable:!0}),Z({kind:"memo",node:s,handle:i,name:r?.name}),ue()&&T(()=>V(s)),i}function C(e,t,r){let n=t;return Ve(()=>{n=e(n)},!0,r?.name)}function He(e,t){let r=t;Ve(()=>{r=e(r)})}function Le(e,t){let r=t;return Ve(()=>{r=e(r)})}function R(e){return Tt(e)}function S(e){return Re(e)}function St(e){return Tt(e),Promise.resolve()}function Er(){return[()=>!1,St]}function Pr(){return _e(),Promise.resolve()}function Dr(e,t,r){let n=Array.isArray(e),o,s=r?.defer??!1;return i=>{let c=n?e.map(l=>l()):e();if(s){s=!1,o=c;return}let a=Re(()=>t(c,o,i));return o=c,a}}function so(e,t,r){let n=[];return T(()=>{for(let o of n)o.dispose();n=[]}),y(()=>{let o=e()||[];return S(()=>{if(o.length===0){for(let a of n)a.dispose();return n=[],r?.fallback?r.fallback():[]}let s=new Map;for(let a of n)s.has(a.item)||s.set(a.item,a);let i=[],c=new Set;for(let a=0;a<o.length;a++){let l=o[a],b=s.get(l);if(b&&!c.has(b))b.setIndex(a),i.push(b),c.add(b);else{let d,v,m;B(g=>{m=g;let[M,z]=p(a,{name:"row index"});v=z,d=t(l,M)});let E={item:l,rendered:d,dispose:m,setIndex:v};i.push(E),c.add(E)}}for(let a of n)c.has(a)||a.dispose();return n=i,i.map(a=>a.rendered)})},void 0,{name:"mapArray"})}function io(e,t,r,n){let o=[],s=[];return T(()=>{for(let i of s)i.dispose();o=[],s=[]}),y(()=>{let i=e()||[];return S(()=>{if(i.length===0){for(let d of s)d.dispose();return o=[],s=[],n?.fallback?n.fallback():[]}let c=new Map;for(let d=0;d<o.length;d++)c.set(o[d],s[d]);let a=[],l=[],b=new Set;for(let d=0;d<i.length;d++){let v=t(i[d]),m=c.get(v);if(m&&!b.has(v))m.setIndex(d),a.push(m);else{let E,g,M;B(z=>{M=z;let[P,F]=p(d,{name:"row index"});g=F;let U=y(A=>{let O=(e()||[])[P()];return O??A},i[d]);E=r(U,P)}),a.push({rendered:E,dispose:M,setIndex:g})}l.push(v),b.add(v)}for(let[d,v]of c)b.has(d)||v.dispose();return o=l,s=a,a.map(d=>d.rendered)})},void 0,{name:"keyArray"})}function co(e,t,r){let n=[];return T(()=>{for(let o of n)o.dispose();n=[]}),y(()=>{let o=e()||[];return S(()=>{if(o.length===0){for(let a of n)a.dispose();return n=[],r?.fallback?r.fallback():[]}let s=n.length,i=o.length;for(let a=s;a<i;a++){let l,b,d,v=o[a];B(m=>{d=m;let[E,g]=p(v);b=g,l=t(E,a)}),n.push({rendered:l,setItem:b,dispose:d})}for(let a=i;a<s;a++)n[a].dispose();i<s&&(n=n.slice(0,i));let c=Math.min(s,i);for(let a=0;a<c;a++)n[a].setItem(o[a]);return n.map(a=>a.rendered)})},void 0,{name:"indexArray"})}var uo=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,Ge=typeof process>"u"?uo:!1,ao=Symbol.for("signal"),fo=Symbol.for("memo"),lo=Symbol.for("resource");function We(e){return typeof e=="function"&&e[ao]===!0}function jr(e){return typeof e=="function"&&e[fo]===!0}function Ir(e){return typeof e=="function"&&e[lo]===!0}function Fr(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Ur(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Mr(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function gt(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?gt(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var wt=null;function Nr(e){wt=e}function ee(e){wt&&wt(e)}var xt=null;function qr(e){xt=e}function pe(e){return xt?xt(e):void 0}var Rt=null;function Br(e){Rt=e}function he(){return Rt?Rt():void 0}var Ot=null;function Kr(e){Ot=e}function te(e,t){Ot&&Ot(e,t)}function ze(){let e=new Map,t=new Map;return{get:r=>e.get(r),set:(r,n)=>{e.set(r,n)},delete:r=>{e.delete(r)},keys:()=>e.keys(),clear:()=>{e.clear(),t.clear()},inflight:t}}var $r=null;function Vr(e){$r=e}var po;function Ce(){let e=$r?.();return e||(typeof window>"u"?ze():po??=ze())}function Hr(e,t=(r,n)=>r===n){let r=new Map;return C(()=>{let n=e();for(let[o,s]of r){let[i,c]=s,a=t(o,n);i()!==a&&c(a)}}),n=>{let o=r.get(n);if(!o){let[s,i]=p(!1);o=[s,i],r.set(n,o);let c=e();i(t(n,c))}return o[0]()}}function Lr(e,t){let[r,n]=p(e(),t);return C(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function Gr(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,e(...o)},t)};return T(()=>{r!==void 0&&clearTimeout(r)}),n}function ho(e){return!!e&&typeof e.then=="function"}var kt=Symbol();function ye(e,t,r={}){let n,o;typeof t=="function"?(n=typeof e=="function"?e:()=>e,o=t):(n=()=>!0,o=e,t&&typeof t=="object"&&(r=t));let s=r.transport===!1?void 0:he(),i=s!==void 0?pe(s):void 0,c=i!==void 0,[a,l]=p(i!==void 0?i.value:r.initialValue,{equals:!1}),[b,d]=p(void 0,{equals:!1}),[v,m]=p(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[E,g]=p(void 0,{equals:!1}),[M,z]=p(void 0,{equals:!1}),P=kt,F=!1;C(()=>{let w=n();if(M(),w===!1||w===null||w===void 0){P=kt,R(()=>{m("unresolved"),g(void 0),d(void 0)});return}let O=F;if(F=!1,P!==kt&&w===P&&!O)return;if(P=w,c){c=!1;return}let ne=!1;T(()=>ne=!0);let N=S(v),ut=S(a),Y=N==="ready"||N==="refreshing";R(()=>{m(Y?"refreshing":"pending"),d(void 0)});try{let q=o(w,{value:ut,refetching:Y});ho(q)?(g(q),ee(q),q.then(X=>{ne||(s!==void 0&&te(s,X),R(()=>{l(()=>X),m("ready"),g(void 0)}))},X=>{ne||R(()=>{d(X),m("errored"),g(void 0)})})):R(()=>{l(()=>q),m("ready"),g(void 0)})}catch(q){if(ne)return;R(()=>{d(q),m("errored"),g(void 0)})}});let U=()=>{let w=v();return w==="pending"||w==="refreshing"},A=(()=>{let w=b();if(w)throw w;if(U()){let O=E();if(O)throw O}return a()});return Object.defineProperties(A,{state:{get:v},loading:{get:U},error:{get:b},latest:{get:a}}),Object.defineProperty(A,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(A,Symbol.for("signal"),{value:!0,enumerable:!0}),[A,{mutate:l,refetch:()=>{F=!0,z(void 0)}}]}function At(e,t=300){let[r,n]=p(e),[o,s]=p(e),[i,c]=p(!1),a,l=()=>{a!==void 0&&(clearTimeout(a),a=void 0)},b=()=>{l();let v=S(r);return s(()=>v),c(!1),v},d=(v=>{let m=typeof v=="function"?v(S(r)):v;return n(()=>m),c(!0),l(),a=setTimeout(b,t),m});return T(l),[o,d,{immediate:r,pending:i,flush:b,cancel:()=>{l(),c(!1)}}]}function yo(e){return e!=null&&e!==""}function Wr(e,t,r={}){let{delay:n=300,initialValue:o,shouldFetch:s=yo}=r,[i,c,a]=At(e,n),l=()=>s(i())?i():!1,[b,{refetch:d}]=ye(l,t,o===void 0?{}:{initialValue:o});return[b,{...a,query:i,setQuery:c,refetch:d}]}function Ye(e){if(typeof e=="function"&&!e.length){let t=e();return We(t)?t:Ye(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=Ye(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function zr(e){let t=y(e);return Ge?y(()=>Ye(t()),void 0,{name:"children"}):y(()=>Ye(t()))}var Xe=L();Rr((e,t)=>{let r=$e(t,Xe);r&&(r.increment(),e.finally(()=>r.decrement()))});function Yr(){let[e,t]=p(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function Xr(e,t){return le(Xe,e,t)}var Jr=L();kr((e,t)=>{let r=$e(t,Jr);return r?(r.setError(e),!0):!1});function Qr(){let[e,t]=p(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function Zr(e,t){return le(Jr,e,t)}var en={State:ae,Computed:H,subtle:{Watcher:fe,untrack:Re,currentComputed:Tr,hasSinks:Sr}};var vo=Symbol.for("signal"),bo=Symbol.for("fluixi-proxy");function mo(e,t){let[r,n]=p(e,t);return Object.assign(r,{set:n})}function To(e,t,r){return y(e,t,r)}function So(e,t,r){return C(e,t,r)}function go(e){return B(e)}function wo(e,t){return Le(e,t)}function xo(e,t){He(e,t)}function Ro(e,t){return L(e,t)}function Oo(e){return Ke(e)}function tn(...e){let[t,r]=ye(...e);return Object.assign(t,r)}var Pt="1.0.0-alpha.94",un=Pt.split(".")[0],rn=`__fluixi_signal_state_v${un}__`,ko=`__fluixi_signal_builds_v${un}__`,Ao=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)};function an(){return{consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Ao,onSuspend:null,onError:null,observer:null}}var _t=globalThis;function _o(e){let t=an(),r=e;for(let n of Object.keys(t))n in e||(r[n]=t[n]);return e}function Co(){let e=_t[rn];return e?_o(e):_t[rn]=an()}var f=Co();(_t[ko]??=[]).push(Pt);function Eo(e){return f.observer=e,()=>{f.observer===e&&(f.observer=null)}}var ve=[],Po,nn;function Dt(e){let t=f.observer;t&&t.created(e.parents===void 0?{...e,parents:ve,origin:e.origin??Po,scope:e.scope??nn}:{...e,scope:e.scope??nn})}function Do(e){return f.observer?(ve.push(e),!0):!1}function jo(){ve.pop()}function Io(e){f.observer?.ran?.(e)}function Fo(e,t){f.observer?.wrote?.(e,t)}function Uo(e){f.observer?.contextCreated?.(e)}function Mo(e,t,r){let n=f.observer;!n?.context||!ve.length||n.context(ve[ve.length-1],e,t,r)}function jt(e){f.observer?.disposed?.(e)}var No="__FLUIXI_DEVTOOLS_HOOK__",on=globalThis[No];if(typeof on?.inject=="function")try{on.inject({observeReactiveNodes:Eo,version:Pt})}catch{}function fn(){return f.observer!=null}var sn=0,cn=1,Ee=2,ln=class{constructor(){this.observers=null,this.watchers=null,this.version=0}updateIfNecessary(){}track(){if(f.untracked)return;let e=f.consumer;e&&((this.observers??=new Set).add(e),(e.sources??=new Set).add(this))}},qo=class extends ln{constructor(e,t){super(),this._value=e,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(e){if(!this._equals(this._value,e)){if(this._value=e,this.version++,Fo(this,f.consumer),this.observers)for(let t of[...this.observers])t.markDirty(Ee);Ct(this)}}peek(){return this._value}},dn=class extends ln{constructor(e,t){super(),this._threw=!1,this._initialized=!1,this.state=Ee,this.sources=null,this._fn=e,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){if(f.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===cn&&this.sources){for(let e of this.sources)if(e.updateIfNecessary(),this.state===Ee)break}(this.state===Ee||!this._initialized)&&this.recompute(),this.state=sn}recompute(){if(this.sources){for(let c of this.sources)c.observers?.delete(this);this.sources.clear()}let e=f.consumer,t=f.untracked,r=Do(this);f.consumer=this,f.untracked=!1;let n,o=!1,s;try{n=this._fn()}catch(c){o=!0,s=c,n=this._value}finally{f.consumer=e,f.untracked=t,r&&jo()}let i=!this._initialized||this._threw!==o||(o?s!==this._error:!this._equals(this._value,n));if(this._initialized=!0,this._threw=o,this._error=s,this._value=n,Io(this),i){if(this.version++,this.observers)for(let c of[...this.observers])c.markDirty(Ee);Ct(this)}}markDirty(e){if(this.state>=e)return;let t=this.state===sn;if(this.state=e,t){if(this.observers)for(let r of[...this.observers])r.markDirty(cn);Ct(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Ct(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var Bo=class{constructor(e){this._watched=new Set,this._pending=new Set,this._notifyFn=e}watch(...e){for(let t of e)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...e){for(let t of e)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let e=[...this._pending];return this._pending.clear(),e}_notify(e){if(!this._watched.has(e)||this._pending.has(e))return;let t=this._pending.size===0;this._pending.add(e),t&&this._notifyFn()}};function Ko(e){if(f.untracked)return e();f.untracked=!0;try{return e()}finally{f.untracked=!1}}function pn(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function hn(e,t){let r=Symbol(t??"context");return Uo(r),{id:r,defaultValue:e,Provider:o=>{Mo(r,"provide",o.value);let s=f.owner,i=pn(s);(i.contexts=new Map).set(r,o.value),s&&(s.owned??=[]).push(i),f.owner=i;try{return o.children}finally{f.owner=s}}}}function yn(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function $o(e){f.onSuspend=e}function Vo(e){return f.onSuspend?(f.onSuspend(e,f.owner),!0):!1}function Ho(e){f.onError=e}function Lo(){return f.owner}function vn(e,t){let r=f.owner;f.owner=e;try{return t()}finally{f.owner=r}}function bn(e){if(f.owner){if(f.owner.disposed){e();return}(f.owner.cleanups??=[]).push(e)}}function Et(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)Et(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}t&&(e.disposed=!0)}}function Go(e){f.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function Wo(e){e.queued||(e.queued=!0,f.queue.push(e),!f.scheduled&&f.batchDepth===0&&(f.scheduled=!0,f.hostSchedule(It)))}function It(){if(f.scheduled=!1,f.flushing)return;f.flushing=!0;let e=0;try{for(;f.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=f.queue;f.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{f.flushing=!1}}function zo(){f.batchDepth===0&&It()}function Yo(e){f.batchDepth++;try{return e()}finally{--f.batchDepth===0&&It()}}var Xo=class{constructor(e,t=!1,r){this.queued=!1,this.disposed=!1,this.owner=pn(f.owner),f.owner&&(f.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new dn(()=>{Et(this.owner,!1),vn(this.owner,()=>{let n=e();typeof n=="function"&&(this.owner.cleanups??=[]).push(n)})}),Dt({kind:"effect",node:this.computed,handle:this,internal:!t,...r?{name:r}:{}}),this.watcher=new Bo(()=>Wo(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(e){if(e&&typeof e.then=="function"&&f.onSuspend){f.onSuspend(e,this.owner);return}if(f.onError&&f.onError(e,this.owner))return;throw e}}}dispose(){this.disposed||(this.disposed=!0,jt(this.computed),this.watcher.unwatch(this.computed),Et(this.owner))}};function Jo(e,t=!1,r){let n=new Xo(e,t,r);return()=>n.dispose()}function Qo(e){return!!e&&typeof e.then=="function"}Go(()=>{});var mn=Symbol.for("signal"),Zo=Symbol.for("memo"),es=Symbol.for("signal-node");function Ft(e,t){let r=new qo(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),zo(),i});return Object.defineProperty(n,mn,{value:!0,enumerable:!0}),Object.defineProperty(n,es,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),Dt({kind:"signal",node:r,handle:n,name:t?.name,set:o}),fn()&&bn(()=>jt(r)),[n,o]}function Je(e,t,r){let n=t,o=Lo(),s=new dn(()=>vn(o,()=>{try{return n=e(n)}catch(c){if(Qo(c))return Vo(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,mn,{value:!0,enumerable:!0}),Object.defineProperty(i,Zo,{value:!0,enumerable:!0}),Dt({kind:"memo",node:s,handle:i,name:r?.name}),fn()&&bn(()=>jt(s)),i}function Pe(e,t,r){let n=t;return Jo(()=>{n=e(n)},!0,r?.name)}function Ut(e){return Yo(e)}function Tn(e){return Ko(e)}var oc=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0;var ts=hn();$o((e,t)=>{let r=yn(t,ts);r&&(r.increment(),e.finally(()=>r.decrement()))});var rs=hn();Ho((e,t)=>{let r=yn(t,rs);return r?(r.setError(e),!0):!1});var Qe=Symbol.for("fluixi-proxy");var me=Symbol("store-raw"),re=Symbol("store-node"),Sn=Symbol("store-has"),tt=Symbol("store-self"),rt=Symbol("store-track"),On=Symbol("store-name"),kn=Symbol("store-store"),De=new WeakMap,Mt=new WeakMap,Te=new WeakMap,nt=new WeakMap;function ns(e,t){if(!be(e)||!ue())return;let r=new Set,n=i=>{if(!(!be(i)||r.has(i))){r.add(i);for(let c of Object.values(i))n(c)}};n(nt.get(t)??t);let o=new Set,s=i=>{if(!be(i))return;let c=i;if(r.has(c)||o.has(c))return;o.add(c);let a=De.get(c);if(a){for(let l of a.keys.values())V(l);a.all&&V(a.all),De.delete(c),Te.delete(c),Mt.delete(c)}for(let l of Object.values(c))s(l)};s(e)}var ot=(e,t,r)=>r?`${e}[${String(t)}]`:`${e}.${String(t)}`;function An(e,t,r){let n=t?.owner,o=n&&r!==void 0?ot(n.name,r,t?.array):void 0,[s,i]=rr(n?.store,()=>Ft(e,o?{name:o}:void 0)),c=s;return c.$=i,c}function st(e){let t=De.get(e);return t?t.owner||(t.owner=Te.get(e)):De.set(e,t={keys:new Map,owner:Te.get(e),array:Array.isArray(e)}),t}function gn(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=An(r,e,t)),n}function os(e,t,r,n){let o=Te.get(e);if(o&&o.store===t&&o.name===r)return;let s={store:t,name:r};Te.set(e,s),nt.set(e,nt.get(n)??n);let i=De.get(e);if(i&&(i.owner=s,!!ue())){for(let[c,a]of i.keys)yt(a,t,ot(r,c,i.array));i.all&&yt(i.all,t,ot(r,"*",i.array))}}function wn(e){let t=st(e);(t.all||(t.all=An(void 0,t,"*")))()}function xn(e,t){e.$(typeof t=="function"?()=>t:t)}function be(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Ze(e){if(!be(e))return e;let t=Mt.get(e);if(t)return t;let r=new Proxy(e,ss);return Mt.set(e,r),r}var ss={get(e,t,r){if(t===me||t===re)return e;if(t===Qe)return r;if(t===Sn)return a=>a in e;if(t==="__proxy")return!0;if(t===rt||t===tt)return wn(e),r;let n=e[t];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return n;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(r);let s=st(e),i=gn(s,t,n),c=i();return be(c)?(s.owner&&os(c,i,ot(s.owner.name,t,s.array),e),Ze(c)):c},set(){return!0},deleteProperty(e,t){return t in e&&I(e,t,void 0),!0},has(e,t){return t===me||t===Qe||t===re||t===Sn||t===tt||t===rt?!0:(gn(st(e),t,e[t])(),t in e)},ownKeys(e){return wn(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function _n(e,t=new Set){if(e==null||typeof e!="object")return e;let r=e[me]??e;if(t.has(r)||!be(r))return r;t.add(r);let n=!1,o=i=>{let c=_n(i,t);return c!==i&&(n=!0),c};if(Array.isArray(r)){let i=r.map(o);return n?i:r}let s={};for(let i of Object.keys(r))s[i]=o(r[i]);return n?s:r}function I(e,t,r){let n=_n(r),o=e[t];if(o===n&&(n!==void 0||t in e))return;let s=Array.isArray(e),i=s?e.length:0;n===void 0?delete e[t]:e[t]=n;let c=st(e),a=c.keys.get(t);if(a&&xn(a,n),ns(o,e),s&&e.length!==i){let l=c.keys.get("length");l&&xn(l,e.length)}c.all&&c.all.$(void 0)}function Nt(e,t){return typeof e=="function"?e(t):e}function qt(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?qt(o,n):I(e,r,n)}}function it(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function Cn(e,t,r){let n=t.length-1;for(let s=0;s<n;s++){let i=t[s];if(i==="*"){let a=t.slice(s+1);if(Array.isArray(e))for(let l=0;l<e.length;l++)Cn(e[l],a,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},I(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)I(e,s,Nt(r,e[s]));return}I(e,o,Nt(r,e[o]))}function Rn(e,t,r){Cn(e,it(t),r)}function is(e){return Array.isArray(e)&&e.length>0&&e.every(t=>Array.isArray(t)&&t.length>=2&&typeof t[0]=="string")}function et(e,t){for(let r=e.length-1;r>=t.length;r--)I(e,String(r),void 0);e.length!==t.length&&I(e,"length",t.length);for(let r=0;r<t.length;r++)I(e,String(r),t[r])}function cs(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&qt(e,n);return}if(Array.isArray(r)&&t.length===1){if(is(r)){for(let n of r)Rn(e,n[0],n[1]);return}if(Array.isArray(e)){et(e,r);return}if(r.length===0)return;throw new TypeError("[fluixi] set() was given an array that is neither a batch of [path, value] pairs nor a replacement for an array root. Name the path you meant, as in set('items', [...]).")}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){qt(e,r);return}if(t.length>=3){Bt(e,t.slice(0,-1),t[t.length-1]);return}Rn(e,String(r),t[1])}function us(e,t){if(typeof t=="function"){if(!Array.isArray(e))return[];let r=[];for(let n=0;n<e.length;n++)t(e[n],n)&&r.push(n);return r}if(Array.isArray(t))return Array.isArray(e)?t.map(Number):t.map(String);if(t&&typeof t=="object"&&("from"in t||"to"in t||"by"in t)){if(!Array.isArray(e))return[];let r=t.by??1,n=t.from??0,o=t.to??e.length-1,s=[];for(let i=n;i<=o;i+=r)i>=0&&i<e.length&&s.push(i);return s}return t==="*"?Array.isArray(e)?e.map((r,n)=>n):Object.keys(e??{}):[t]}function Bt(e,t,r){if(e==null)return;let[n,...o]=t;if(typeof n=="string"){let i=it(n);if(i.length>1){Bt(e,[...i,...o],r);return}}let s=us(e,n);if(o.length===0){for(let i of s)I(e,i,Nt(r,e[i]));return}for(let i of s){let c=e[i];if(c==null||typeof c!="object"){let a=o[0];c=typeof a=="number"||/^\d+$/.test(String(a))?[]:{},I(e,i,c)}Bt(c,o,r)}}function Kt(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Kt);let t={};for(let r of Object.keys(e))t[r]=Kt(e[r]);return t}function G(e,t){let r=e;for(let n of it(t)){if(r==null)return;r=r[n]}return r}var W=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>Ut(()=>cs(this.root,n))),t&&typeof t=="object"&&(Te.set(t,{store:this,name:r.name??"store"}),nt.set(t,t)),Z({kind:"store",node:this,handle:()=>this.root,name:r.name})}get state(){return Ze(this.root)}get proxy(){return Ze(this.root)}get accessor(){return(()=>Ze(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return Se(this.state);let r=this.state;for(let n of it(t)){if(r==null)return;r=r[n]}return Se(r)}select(t){return Je(()=>t(this.state))}subscribe(t){return Pe(()=>t(this.state))}watch(t,r){let n;return Pe(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return Je(()=>this.state[t])}produce(t){this.set((r=>{let n=Kt(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=G(this.root,t);this.set(t,n.concat(r))}pop(t){let r=G(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=G(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=G(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=G(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=G(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}replace(t,r){if(arguments.length>=2){let o=G(this.root,String(t)),s=r;if(Array.isArray(o)&&Array.isArray(s)){et(o,s);return}this.set(t,s);return}let n=this.root;if(Array.isArray(n)&&Array.isArray(t)){et(n,t);return}this.set(t)}clear(t){let r=t===void 0?this.root:G(this.root,t);if(Array.isArray(r)){et(r,[]);return}if(r&&typeof r=="object")for(let n of Object.keys(r))I(r,n,void 0)}toObservable(){let[t]=Ft(this.state);return t.toObservable()}dispose(){}},as=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","replace","clear","unwrap","toObservable"];function En(e,t){for(let r of as)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function je(e,t={immutable:!0}){let r=new W(e,t);return En(r.set,r),[r.proxy,r.set]}function $t(e,t={}){return new W(e,{...t,immutable:!1})}function Pn(e,t={}){let r=new W(e(),t);return Pe(()=>r.set(e())),r}function Dn(e,t,r){return Pe(()=>r(t(e)))}function jn(e,t,r){return Je(()=>t(e),void 0,r)}function In(e,t={}){let r=new W(e,t),n=(()=>r.proxy);return En(n,r),n}function Se(e){if(e==null||typeof e!="object")return e;let t=e[me];return t!==void 0?t:e}function Vt(e){return Tn(()=>Se(e))}function Fn(e){return ct(e)}function Un(e){return ct(e)?e[re]:null}function Mn(e){return e&&typeof e=="object"&&re in e?e[re]:null}function ct(e){return!!e&&typeof e=="object"&&(Qe in e||e.__proxy===!0)}function Nn(e){return e}var qn=Object.freeze({createStore:je,createMutableStore:$t,batch:Ut,unwrap:Se,untrackStore:Vt});function Ht(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ht);let t={};for(let r of Object.keys(e))t[r]=Ht(e[r]);return t}function Bn(e){return t=>{let r=Ht(t);return e(r),r}}function Kn(e,t={}){return()=>e}function $n(e,t){let[r,n]=je(e,t);return new Proxy(r,{get:(o,s)=>s==="set"?n:o[s],has:(o,s)=>s==="set"||Reflect.has(o,s)})}function fs(e,t,r){return y(()=>t(e()),void 0,r)}function ls(e,t,r){return y(()=>e().filter(t),void 0,r)}function ds(e,t,r,n){return y(()=>e().reduce(t,r),void 0,n)}function ps(e,t,r){return y(()=>e().find(t),void 0,r)}function hs(e,t,r){return y(()=>e().some(t),void 0,r)}function ys(e,t,r){return y(()=>e().every(t),void 0,r)}function vs(e,t,r){return y(()=>[...e()].sort(t),void 0,r)}function bs(e,t){return y(()=>[...new Set(e())],void 0,t)}function ms(e,t,r){return y(()=>{let n=e.map(o=>o());return t(n)},void 0,r)}function Ts(...e){return new $(t=>{let r=()=>e.map(o=>typeof o=="function"?o():o.get()),n=e.map(o=>typeof o=="function"&&o.subscribe?o.subscribe(()=>{t.next(r())}):typeof o!="function"?o.subscribe(()=>{t.next(r())}):C(()=>{t.next(r())}));return()=>{n.forEach(o=>{typeof o=="function"?o():o&&typeof o.unsubscribe=="function"&&o.unsubscribe()})}})}function Ss(e,t,r){return y(()=>e()||t(),void 0,r)}function gs(e,t,r,n){return y(()=>r(e(),t()),void 0,n)}function ws(e,t,r){return y(()=>t(e()),void 0,{equals:r,internal:!0})}function xs(e,t,r){return y(()=>{let n=e(),o={};for(let s of t)o[s]=n[s];return o},void 0,r)}function Rs(e,t,r){return y(()=>{let o={...e()};for(let s of t)delete o[s];return o},void 0,r)}function Os(e,t,r,n){return y(()=>e()?t():r(),void 0,n)}function ks(e,t,r){return y(()=>e()?t():void 0,void 0,r)}function As(e,t,r){let[n,o]=p(e()),s;return y(()=>{let i=e();clearTimeout(s),s=setTimeout(()=>o(()=>i),t)}),n}function _s(e,t,r){let[n,o]=p(e()),s=0,i;return y(()=>{let c=e(),a=Date.now();a-s>=t?(s=a,o(()=>c)):(clearTimeout(i),i=setTimeout(()=>{s=Date.now(),o(()=>c)},t-(a-s)))}),n}function Cs(e){let t=e;for(;typeof t=="function";)t=t();return t}var Es=0,Ps=Symbol.for("signal"),Ds=Symbol.for("resource");function js(e,t,r={}){let n,o,s;typeof t=="function"?(n=e,o=t,s=r):(n=()=>!0,o=e,s=t??r);let{ttl:i=1/0,name:c=`_auto_${Es++}`,staleWhileRevalidate:a=!0}=s,l=c,b=s.cache??Ce(),d=b.inflight,v=s.transport===!1?void 0:he(),m=v!==void 0?pe(v):void 0,E=s.deps??[],g=()=>E.map(h=>h()),M=(h,_=S(g))=>`${l}:${JSON.stringify(h)}`+(E.length?`:${JSON.stringify(_)}`:""),z=h=>i===1/0||Date.now()-h.timestamp<=i,[P,F]=p(void 0,{equals:!1}),[U,A]=p("unresolved",{equals:!1}),[w,O]=p(void 0,{equals:!1}),[ne,N]=p(void 0,{equals:!1}),[ut,Y]=p(!1),[q,X]=p(0,{equals:!1}),Ie=Symbol("unset"),ge=Ie,at=!1,ft=!1;function Lt(h,_,D,K){let j=d.get(_);if(j){j.then(x=>{K()||Gt(x,D)},x=>{!K()&&!D&&Wt(x)}),D||(ee(j),N(j));return}let we=Promise.resolve(o(h)).then(x=>(b.set(_,{value:x,timestamp:Date.now()}),d.delete(_),x),x=>{throw d.delete(_),x});d.set(_,we),D||(ee(we),N(we)),we.then(x=>{K()||Gt(x,D)},x=>{!K()&&!D&&Wt(x)})}function Gt(h,_){v!==void 0&&te(v,h),R(()=>{F(()=>h),A("ready"),Y(!1),N(void 0),O(void 0)})}function Wt(h){R(()=>{O(h),A("errored"),N(void 0)})}C(()=>{let h=n(),_=g();if(q(),h===!1||h===null||h===void 0){ge=Ie,R(()=>{A("unresolved"),N(void 0),O(void 0)});return}let D=at,K=ft;at=!1,ft=!1;let j=M(h,_);m&&ge===Ie&&!b.get(j)&&b.set(j,{value:m.value,timestamp:Date.now()}),K&&b.delete(j);let we=ge===Ie||h!==ge;ge=h;let x=!1;T(()=>{x=!0});let J=b.get(j);if(J&&z(J)&&!D&&!K){v!==void 0&&te(v,J.value),(S(U)!=="ready"||S(P)!==J.value)&&R(()=>{F(()=>J.value),A("ready"),Y(!1),O(void 0)});return}if(J&&a&&!K){R(()=>{F(()=>J.value),A("ready"),Y(!0),O(void 0),N(void 0)}),Lt(h,j,!0,()=>x);return}let zt=S(U),Vn=zt==="ready"||zt==="refreshing";R(()=>{A(Vn?"refreshing":"pending"),O(void 0),Y(!1)}),Lt(h,j,!1,()=>x)});let Fe=(()=>{let h=w();if(h)throw h;if(U()==="pending"){let D=ne();if(D)throw D}return P()});return Object.defineProperty(Fe,Ds,{value:!0,enumerable:!0}),Object.defineProperty(Fe,Ps,{value:!0,enumerable:!0}),Object.defineProperties(Fe,{state:{get:U},loading:{get:()=>{let h=U();return h==="pending"||h==="refreshing"}},error:{get:w},latest:{get:P},stale:{get:ut}}),Object.assign(Fe,{mutate:F,refetch:()=>{at=!0,X(h=>h+1)},invalidate:()=>{let h=S(n);h!=null&&h!==!1&&b.delete(M(h)),ft=!0,X(_=>_+1)}})}function Is(e,t=Ce()){if(e===void 0)return t.clear();let r=`${e}:`;for(let n of[...t.keys()])n.startsWith(r)&&t.delete(n)}return Yn(Fs);})();
|