@fluixi/reactive 1.0.0-alpha.104 → 1.0.0-alpha.106
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 +74 -34
- package/dist/cdn/reactive.global.js +2 -2
- package/dist/cdn/reactive.mjs +74 -34
- package/dist/cdn/signal.cjs +23 -3
- package/dist/cdn/signal.global.js +2 -2
- package/dist/cdn/signal.mjs +23 -3
- package/dist/index.cjs +74 -34
- package/dist/index.mjs +74 -34
- package/dist/lib/index.cjs +75 -35
- package/dist/lib/index.mjs +75 -35
- package/dist/lib/observable/index.cjs +1 -1
- package/dist/lib/observable/index.mjs +1 -1
- package/dist/lib/signal/api.cjs +40 -14
- package/dist/lib/signal/api.mjs +40 -14
- package/dist/lib/signal/cached-resource.cjs +36 -13
- package/dist/lib/signal/cached-resource.mjs +36 -13
- package/dist/lib/signal/graph/children.cjs +25 -6
- package/dist/lib/signal/graph/children.mjs +25 -6
- package/dist/lib/signal/graph/compat.cjs +41 -15
- package/dist/lib/signal/graph/compat.d.ts.map +1 -1
- package/dist/lib/signal/graph/compat.js +20 -11
- package/dist/lib/signal/graph/compat.mjs +41 -15
- package/dist/lib/signal/graph/context-children.cjs +1 -1
- package/dist/lib/signal/graph/context-children.mjs +1 -1
- package/dist/lib/signal/graph/core.cjs +24 -4
- package/dist/lib/signal/graph/core.d.ts +10 -0
- package/dist/lib/signal/graph/core.d.ts.map +1 -1
- package/dist/lib/signal/graph/core.js +27 -2
- package/dist/lib/signal/graph/core.mjs +24 -4
- package/dist/lib/signal/graph/debounced.cjs +35 -12
- package/dist/lib/signal/graph/debounced.mjs +35 -12
- package/dist/lib/signal/graph/derived.cjs +35 -12
- package/dist/lib/signal/graph/derived.mjs +35 -12
- package/dist/lib/signal/graph/detect.cjs +1 -1
- package/dist/lib/signal/graph/detect.mjs +1 -1
- package/dist/lib/signal/graph/error-boundary.cjs +10 -8
- package/dist/lib/signal/graph/error-boundary.mjs +10 -8
- package/dist/lib/signal/graph/index.cjs +24 -4
- package/dist/lib/signal/graph/index.mjs +24 -4
- package/dist/lib/signal/graph/observe.cjs +1 -1
- package/dist/lib/signal/graph/observe.mjs +1 -1
- package/dist/lib/signal/graph/resource.cjs +35 -12
- package/dist/lib/signal/graph/resource.mjs +35 -12
- package/dist/lib/signal/graph/runtime.cjs +29 -5
- package/dist/lib/signal/graph/runtime.d.ts.map +1 -1
- package/dist/lib/signal/graph/runtime.js +5 -3
- package/dist/lib/signal/graph/runtime.mjs +29 -5
- package/dist/lib/signal/graph/signal-next.cjs +67 -29
- package/dist/lib/signal/graph/signal-next.mjs +67 -29
- 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 +10 -8
- package/dist/lib/signal/graph/suspense.mjs +10 -8
- package/dist/lib/signal/index-legacy.cjs +67 -29
- package/dist/lib/signal/index-legacy.mjs +67 -29
- package/dist/lib/signal/index.cjs +67 -29
- package/dist/lib/signal/index.mjs +67 -29
- package/dist/lib/signal/list.cjs +58 -25
- package/dist/lib/signal/list.d.ts +3 -8
- package/dist/lib/signal/list.d.ts.map +1 -1
- package/dist/lib/signal/list.js +40 -18
- package/dist/lib/signal/list.mjs +58 -25
- package/dist/lib/signal/resource-api.cjs +35 -12
- package/dist/lib/signal/resource-api.mjs +35 -12
- package/dist/lib/signal/signal.cjs +41 -15
- package/dist/lib/signal/signal.mjs +41 -15
- package/dist/lib/signal/utilities.cjs +41 -15
- package/dist/lib/signal/utilities.mjs +41 -15
- package/dist/lib/store/api.cjs +9 -7
- package/dist/lib/store/api.mjs +9 -7
- package/dist/lib/store/index.cjs +10 -8
- package/dist/lib/store/index.mjs +10 -8
- package/dist/lib/store/store.cjs +9 -7
- package/dist/lib/store/store.d.ts.map +1 -1
- package/dist/lib/store/store.js +8 -6
- package/dist/lib/store/store.mjs +9 -7
- 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
|
@@ -158,7 +158,7 @@ __export(reactive_exports, {
|
|
|
158
158
|
module.exports = __toCommonJS(reactive_exports);
|
|
159
159
|
|
|
160
160
|
// src/version.generated.ts
|
|
161
|
-
var VERSION = "1.0.0-alpha.
|
|
161
|
+
var VERSION = "1.0.0-alpha.106";
|
|
162
162
|
|
|
163
163
|
// src/lib/predicates.ts
|
|
164
164
|
function isFunction(value) {
|
|
@@ -795,6 +795,7 @@ var Computed = class extends Source {
|
|
|
795
795
|
super();
|
|
796
796
|
this._threw = false;
|
|
797
797
|
this._initialized = false;
|
|
798
|
+
this._disposed = false;
|
|
798
799
|
this.state = DIRTY;
|
|
799
800
|
/** Nodes this computation read on its last run. Rebuilt on every run. */
|
|
800
801
|
this.sources = null;
|
|
@@ -810,8 +811,23 @@ var Computed = class extends Source {
|
|
|
810
811
|
if (this._threw) throw this._error;
|
|
811
812
|
return this._value;
|
|
812
813
|
}
|
|
814
|
+
/**
|
|
815
|
+
* Unlink from every source, for good. Without this, a source outlives the
|
|
816
|
+
* computation and keeps it (and everything its function captured) reachable
|
|
817
|
+
* through its observers set: a disposed list row stayed in memory that way.
|
|
818
|
+
* The last value stays readable; the node simply never updates again.
|
|
819
|
+
*/
|
|
820
|
+
dispose() {
|
|
821
|
+
if (this._disposed) return;
|
|
822
|
+
this._disposed = true;
|
|
823
|
+
if (this.sources) {
|
|
824
|
+
for (const s of this.sources) s.observers?.delete(this);
|
|
825
|
+
this.sources = null;
|
|
826
|
+
}
|
|
827
|
+
}
|
|
813
828
|
/** Settle, if CHECK, verify sources; if DIRTY (or never run), recompute. */
|
|
814
829
|
updateIfNecessary() {
|
|
830
|
+
if (this._disposed) return;
|
|
815
831
|
if (this.state === CHECK) {
|
|
816
832
|
if (this.sources) {
|
|
817
833
|
for (const s of this.sources) {
|
|
@@ -855,7 +871,7 @@ var Computed = class extends Source {
|
|
|
855
871
|
reportReactiveRun(this);
|
|
856
872
|
if (changed) {
|
|
857
873
|
this.version++;
|
|
858
|
-
if (this.observers) for (const o of
|
|
874
|
+
if (this.observers) for (const o of this.observers) o.markDirty(DIRTY);
|
|
859
875
|
notifyWatchers(this);
|
|
860
876
|
}
|
|
861
877
|
}
|
|
@@ -869,7 +885,7 @@ var Computed = class extends Source {
|
|
|
869
885
|
const wasClean = this.state === CLEAN;
|
|
870
886
|
this.state = level;
|
|
871
887
|
if (wasClean) {
|
|
872
|
-
if (this.observers) for (const o of
|
|
888
|
+
if (this.observers) for (const o of this.observers) o.markDirty(CHECK);
|
|
873
889
|
notifyWatchers(this);
|
|
874
890
|
}
|
|
875
891
|
}
|
|
@@ -908,6 +924,10 @@ var Watcher = class {
|
|
|
908
924
|
this._pending.clear();
|
|
909
925
|
return out;
|
|
910
926
|
}
|
|
927
|
+
/** Drain pending without the array, for callers that only need it empty. */
|
|
928
|
+
clearPending() {
|
|
929
|
+
this._pending.clear();
|
|
930
|
+
}
|
|
911
931
|
/** @internal, a watched node became non-clean. Edge-triggered: notify once. */
|
|
912
932
|
_notify(node) {
|
|
913
933
|
if (!this._watched.has(node) || this._pending.has(node)) return;
|
|
@@ -1125,14 +1145,14 @@ var EffectNode = class {
|
|
|
1125
1145
|
if (typeof r === "function") (this.owner.cleanups ??= []).push(r);
|
|
1126
1146
|
});
|
|
1127
1147
|
});
|
|
1128
|
-
reportReactiveNode({ kind: "effect", node: this.computed, handle: this, internal: !report, ...name ? { name } : {} });
|
|
1148
|
+
if (isObserved()) reportReactiveNode({ kind: "effect", node: this.computed, handle: this, internal: !report, ...name ? { name } : {} });
|
|
1129
1149
|
this.watcher = new Watcher(() => enqueue(this));
|
|
1130
1150
|
this.run();
|
|
1131
1151
|
this.watcher.watch(this.computed);
|
|
1132
1152
|
}
|
|
1133
1153
|
run() {
|
|
1134
1154
|
if (this.disposed) return;
|
|
1135
|
-
this.watcher.
|
|
1155
|
+
this.watcher.clearPending();
|
|
1136
1156
|
try {
|
|
1137
1157
|
this.computed.get();
|
|
1138
1158
|
} catch (e) {
|
|
@@ -1149,6 +1169,7 @@ var EffectNode = class {
|
|
|
1149
1169
|
this.disposed = true;
|
|
1150
1170
|
reportReactiveDispose(this.computed);
|
|
1151
1171
|
this.watcher.unwatch(this.computed);
|
|
1172
|
+
this.computed.dispose();
|
|
1152
1173
|
disposeOwner(this.owner);
|
|
1153
1174
|
}
|
|
1154
1175
|
};
|
|
@@ -1187,13 +1208,15 @@ function createSignal(value, options) {
|
|
|
1187
1208
|
},
|
|
1188
1209
|
enumerable: false
|
|
1189
1210
|
});
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1211
|
+
if (isObserved()) {
|
|
1212
|
+
reportReactiveNode({
|
|
1213
|
+
kind: "signal",
|
|
1214
|
+
node: state,
|
|
1215
|
+
handle: read,
|
|
1216
|
+
name: options?.name,
|
|
1217
|
+
set: write
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1197
1220
|
if (isObserved()) onCleanup(() => reportReactiveDispose(state));
|
|
1198
1221
|
return [read, write];
|
|
1199
1222
|
}
|
|
@@ -1217,8 +1240,11 @@ function createMemo(fn, value, options) {
|
|
|
1217
1240
|
const read = (() => c.get());
|
|
1218
1241
|
Object.defineProperty(read, $SIGNAL, { value: true, enumerable: true });
|
|
1219
1242
|
Object.defineProperty(read, $MEMO, { value: true, enumerable: true });
|
|
1220
|
-
reportReactiveNode({ kind: "memo", node: c, handle: read, name: options?.name });
|
|
1221
|
-
|
|
1243
|
+
if (isObserved()) reportReactiveNode({ kind: "memo", node: c, handle: read, name: options?.name });
|
|
1244
|
+
onCleanup(() => {
|
|
1245
|
+
c.dispose();
|
|
1246
|
+
if (isObserved()) reportReactiveDispose(c);
|
|
1247
|
+
});
|
|
1222
1248
|
return read;
|
|
1223
1249
|
}
|
|
1224
1250
|
function createEffect(fn, value, options) {
|
|
@@ -1275,6 +1301,20 @@ function on(deps, fn, options) {
|
|
|
1275
1301
|
}
|
|
1276
1302
|
|
|
1277
1303
|
// src/lib/signal/list.ts
|
|
1304
|
+
function lazyIndex(initial) {
|
|
1305
|
+
let current = initial;
|
|
1306
|
+
let state = null;
|
|
1307
|
+
return {
|
|
1308
|
+
index: () => {
|
|
1309
|
+
if (!state) state = createSignal(current, { name: "row index" });
|
|
1310
|
+
return state[0]();
|
|
1311
|
+
},
|
|
1312
|
+
set: (n) => {
|
|
1313
|
+
current = n;
|
|
1314
|
+
if (state) state[1](n);
|
|
1315
|
+
}
|
|
1316
|
+
};
|
|
1317
|
+
}
|
|
1278
1318
|
function mapArray(list, mapFn, options) {
|
|
1279
1319
|
let items = [];
|
|
1280
1320
|
onCleanup(() => {
|
|
@@ -1304,9 +1344,9 @@ function mapArray(list, mapFn, options) {
|
|
|
1304
1344
|
let rendered, setIndex, dispose;
|
|
1305
1345
|
createRoot((d) => {
|
|
1306
1346
|
dispose = d;
|
|
1307
|
-
const
|
|
1308
|
-
setIndex =
|
|
1309
|
-
rendered = mapFn(value, index);
|
|
1347
|
+
const idx = lazyIndex(i);
|
|
1348
|
+
setIndex = idx.set;
|
|
1349
|
+
rendered = mapFn(value, idx.index);
|
|
1310
1350
|
});
|
|
1311
1351
|
const entry = { item: value, rendered, dispose, setIndex };
|
|
1312
1352
|
result.push(entry);
|
|
@@ -1346,21 +1386,19 @@ function keyArray(list, keyFn, mapFn, options) {
|
|
|
1346
1386
|
const reuse = prevByKey.get(key);
|
|
1347
1387
|
if (reuse && !usedKeys.has(key)) {
|
|
1348
1388
|
reuse.setIndex(i);
|
|
1389
|
+
reuse.setItem(next[i]);
|
|
1349
1390
|
resultEntries.push(reuse);
|
|
1350
1391
|
} else {
|
|
1351
|
-
let rendered, setIndex, dispose;
|
|
1392
|
+
let rendered, setIndex, setItem, dispose;
|
|
1352
1393
|
createRoot((d) => {
|
|
1353
1394
|
dispose = d;
|
|
1354
|
-
const
|
|
1355
|
-
setIndex =
|
|
1356
|
-
const item =
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
return v !== void 0 && v !== null ? v : prev;
|
|
1360
|
-
}, next[i]);
|
|
1361
|
-
rendered = mapFn(item, index);
|
|
1395
|
+
const idx = lazyIndex(i);
|
|
1396
|
+
setIndex = idx.set;
|
|
1397
|
+
const [item, writeItem] = createSignal(next[i]);
|
|
1398
|
+
setItem = (v) => writeItem(() => v);
|
|
1399
|
+
rendered = mapFn(item, idx.index);
|
|
1362
1400
|
});
|
|
1363
|
-
resultEntries.push({ rendered, dispose, setIndex });
|
|
1401
|
+
resultEntries.push({ rendered, dispose, setIndex, setItem });
|
|
1364
1402
|
}
|
|
1365
1403
|
resultKeys.push(key);
|
|
1366
1404
|
usedKeys.add(key);
|
|
@@ -1410,7 +1448,7 @@ function indexArray(list, mapFn, options) {
|
|
|
1410
1448
|
|
|
1411
1449
|
// src/lib/signal/graph/detect.ts
|
|
1412
1450
|
var __BROWSER_PROD__ = typeof window === "undefined" ? false : window.__FLUIXI_PROD__ === true;
|
|
1413
|
-
var __DEV__ = typeof process === "undefined" ? __BROWSER_PROD__ :
|
|
1451
|
+
var __DEV__ = typeof process === "undefined" ? __BROWSER_PROD__ : process.env.NODE_ENV !== "production";
|
|
1414
1452
|
var $SIGNAL2 = /* @__PURE__ */ Symbol.for("signal");
|
|
1415
1453
|
var $MEMO2 = /* @__PURE__ */ Symbol.for("memo");
|
|
1416
1454
|
var $RESOURCE = /* @__PURE__ */ Symbol.for("resource");
|
|
@@ -2222,12 +2260,14 @@ var Store = class {
|
|
|
2222
2260
|
OWNERS.set(initialState, { store: this, name: options.name ?? "store" });
|
|
2223
2261
|
ROOTS.set(initialState, initialState);
|
|
2224
2262
|
}
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2263
|
+
if (isObserved()) {
|
|
2264
|
+
reportReactiveNode({
|
|
2265
|
+
kind: "store",
|
|
2266
|
+
node: this,
|
|
2267
|
+
handle: () => this.root,
|
|
2268
|
+
name: options.name
|
|
2269
|
+
});
|
|
2270
|
+
}
|
|
2231
2271
|
}
|
|
2232
2272
|
get state() {
|
|
2233
2273
|
return box(this.root);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @fluixi/reactive v1.0.0-alpha.
|
|
2
|
-
"use strict";var Fluixi=(()=>{var dt=Object.defineProperty;var Gn=Object.getOwnPropertyDescriptor;var Wn=Object.getOwnPropertyNames;var zn=Object.prototype.hasOwnProperty;var Yn=(e,t)=>{for(var r in t)dt(e,r,{get:t[r],enumerable:!0})},Xn=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Wn(t))!zn.call(e,o)&&o!==r&&dt(e,o,{get:()=>t[o],enumerable:!(n=Gn(t,o))||n.enumerable});return e};var Jn=e=>Xn(dt({},"__esModule",{value:!0}),e);var Ns={};Yn(Ns,{$NAME:()=>An,$NODE:()=>se,$PROXY:()=>So,$RAW:()=>we,$SELF:()=>rt,$SIGNAL:()=>To,$STORE:()=>_n,$TRACK:()=>nt,Observable:()=>$,SafeSubscriber:()=>Ne,Signal:()=>rn,Store:()=>z,StoreAPI:()=>Kn,Subject:()=>ht,Subscriber:()=>ue,Subscription:()=>ce,SuspenseContext:()=>Je,VERSION:()=>Z,__DEV__:()=>ze,adoptReactiveScope:()=>cr,batch:()=>R,cachedResource:()=>Us,childOwner:()=>_o,clearCachedResources:()=>Ms,closeReactiveScope:()=>ir,combineSignal:()=>gs,combineSignals:()=>ws,computed:()=>ko,context:()=>Ao,createChildOwner:()=>he,createComputed:()=>Ge,createComputedStore:()=>jn,createContext:()=>Xr,createDebounce:()=>Gr,createDebouncedResource:()=>Wr,createDebouncedSignal:()=>_t,createDeferred:()=>Lr,createEffect:()=>C,createErrorBoundary:()=>en,createMemo:()=>y,createMutableStore:()=>Vt,createRenderEffect:()=>We,createResource:()=>Te,createResourceCache:()=>Ye,createRoot:()=>B,createSelector:()=>Hr,createSignal:()=>p,createStore:()=>Fe,createStoreEffect:()=>In,createStoreMemo:()=>Fn,createSuspenseBoundary:()=>Jr,currentResourceCache:()=>Pe,debounceSignal:()=>Es,disposeScope:()=>Ve,distinctSignal:()=>Ss,effect:()=>xo,everySignal:()=>ms,filterSignal:()=>hs,findSignal:()=>vs,flush:()=>Pr,getNode:()=>Nn,getOwner:()=>re,getServerData:()=>be,getStoreNode:()=>qn,guardSignal:()=>Cs,indexArray:()=>ao,isComponent:()=>Fr,isMemo:()=>jr,isOwnerDisposed:()=>wr,isProvider:()=>Mr,isResource:()=>Ir,isSignal:()=>ve,isStore:()=>Mn,isStoreProxy:()=>ut,isSuspense:()=>Ur,joinedVersions:()=>tr,keyArray:()=>uo,makeArrayFlat:()=>wt,mapArray:()=>co,mapSignal:()=>ps,markReactiveScope:()=>ar,memo:()=>wo,mergeSignal:()=>xs,modifiable:()=>Bn,nextResourceId:()=>me,observeReactiveNodes:()=>yt,omitSignal:()=>As,on:()=>Dr,onCleanup:()=>T,openReactiveScope:()=>or,operate:()=>Qn,pickSignal:()=>ks,produceUtil:()=>$n,provide:()=>ye,provideErrorBoundary:()=>tn,provideSuspense:()=>Qr,reactiveScopeOf:()=>fr,readChildren:()=>zr,readSignal:()=>Ds,reconcileUtil:()=>Vn,reduceSignal:()=>ys,renderEffect:()=>Oo,reportReactiveBinding:()=>yr,reportReactiveContext:()=>fe,reportReactiveContextCreated:()=>Ke,reportReactiveDirective:()=>br,reportReactiveProps:()=>vr,reportResourceData:()=>oe,resource:()=>nn,root:()=>Ro,runWithOwner:()=>G,selectSignal:()=>Os,setOwner:()=>Tt,setResourceCacheScope:()=>Vr,setResourceDataSink:()=>Kr,setResourceIdSource:()=>Br,setResourceTracker:()=>Nr,setServerDataGetter:()=>qr,signal:()=>go,someSignal:()=>bs,sortSignal:()=>Ts,startTransition:()=>gt,store:()=>Hn,throttleSignal:()=>Ps,trackResourcePromise:()=>ne,untrack:()=>S,untrackStore:()=>Ht,unwrap:()=>Re,useContext:()=>xr,useTransition:()=>Er,whenSignal:()=>_s,withReactiveScope:()=>sr,wrap:()=>Un,zipSignal:()=>Rs});var Z="1.0.0-alpha.104";function pt(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function Xt(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 ce=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(pt(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if(Xt(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(pt(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 ue=class extends ce{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())}},Ne=class extends ue{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 Qn(e){return new ue(e.next,e.error,e.complete)}var $=class extends ce{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 ue?o=t:o=new Ne(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 ht=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 Qt=Z.split(".")[0],Jt=`__fluixi_signal_state_v${Qt}__`,Zt=`__fluixi_signal_builds_v${Qt}__`,Zn=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)};function er(){return{consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Zn,onSuspend:null,onError:null,observer:null}}var qe=globalThis;function eo(e){let t=er(),r=e;for(let n of Object.keys(t))n in e||(r[n]=t[n]);return e}function to(){let e=qe[Jt];return e?eo(e):qe[Jt]=er()}var u=to();(qe[Zt]??=[]).push(Z);function tr(){return[...new Set(qe[Zt]??[])]}function yt(e){return u.observer=e,()=>{u.observer===e&&(u.observer=null)}}var k=[],Be;function nr(e,t){if(!u.observer)return t();let r=Be;Be=e;try{return t()}finally{Be=r}}var ae;function or(e){let t={};return u.observer?.scope?.(t,e,ae),t}function sr(e,t){if(!u.observer)return t();let r=ae;ae=e;try{return t()}finally{ae=r}}function ir(e){u.observer?.scopeEnded?.(e)}function cr(e,t){u.observer?.scopeAdopted?.(e,t)}var ur=Symbol.for("fluixi.reactiveScope");function ar(e,t){Object.defineProperty(e,ur,{value:t,configurable:!0,enumerable:!1})}function fr(e){return e!==null&&(typeof e=="object"||typeof e=="function")?e[ur]??void 0:void 0}function ee(e){let t=u.observer;t&&t.created(e.parents===void 0?{...e,parents:k,origin:e.origin??Be,scope:e.scope??ae}:{...e,scope:e.scope??ae})}function lr(e){return u.observer?(k.push(e),!0):!1}function dr(){k.pop()}function pr(e){u.observer?.ran?.(e)}function hr(e,t){u.observer?.wrote?.(e,t)}function yr(e,t,r,n){let o=u.observer;!o?.bound||!k.length||o.bound(k[k.length-1],e,t,r,n)}function vr(e){let t=u.observer;!t?.props||!k.length||!e||t.props(k[k.length-1],e)}function br(e,t,r,n){let o=u.observer;!o?.directive||!k.length||o.directive(k[k.length-1],e,t,r,n)}function Ke(e){u.observer?.contextCreated?.(e)}function fe(e,t,r){let n=u.observer;!n?.context||!k.length||n.context(k[k.length-1],e,t,r)}function vt(e,t,r){u.observer?.moved?.(e,t,r)}function V(e){u.observer?.disposed?.(e)}var ro="__FLUIXI_DEVTOOLS_HOOK__",rr=globalThis[ro];if(typeof rr?.inject=="function")try{rr.inject({observeReactiveNodes:yt,version:Z})}catch{}function le(){return u.observer!=null}var mr=0,Tr=1,Ae=2,$e=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))}},de=class extends $e{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++,hr(this,u.consumer),this.observers)for(let r of[...this.observers])r.markDirty(Ae);bt(this)}}peek(){return this._value}},H=class extends $e{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=Ae;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===Tr&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===Ae)break}(this.state===Ae||!this._initialized)&&this.recompute(),this.state=mr}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=lr(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&&dr()}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,pr(this),a){if(this.version++,this.observers)for(let l of[...this.observers])l.markDirty(Ae);bt(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===mr;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty(Tr);bt(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function bt(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var pe=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 te(e){if(u.untracked)return e();u.untracked=!0;try{return e()}finally{u.untracked=!1}}function Sr(){return u.consumer}function gr(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function he(e){let t=Ce(e);return e&&(e.owned??=[]).push(t),t}function Ve(e,t=!0){_e(e,t)}function wr(e){return!!e&&e.disposed===!0}function Ce(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function L(e,t){let r=Symbol(t??"context");return Ke(r),{id:r,defaultValue:e,Provider:o=>{fe(r,"provide",o.value);let s=u.owner,i=Ce(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 fe(e.id,"read",r),r}t=t.parent}return fe(e.id,"read",e.defaultValue),e.defaultValue}function He(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 ye(e,t,r){let n=Ce(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 re(){return u.owner}function Tt(e){let t=u.owner;return u.owner=e,t}function G(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 _e(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)_e(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=Ce(u.owner);u.owner&&(u.owner.owned??=[]).push(t);let r=u.owner;u.owner=t;try{return te(()=>e(()=>_e(t)))}finally{u.owner=r}}function Ar(e){u.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function no(e){e.queued||(e.queued=!0,u.queue.push(e),!u.scheduled&&u.batchDepth===0&&(u.scheduled=!0,u.hostSchedule(Ee)))}function Ee(){if(u.scheduled=!1,u.flushing)return;u.flushing=!0;let e=0,t=!1,r;try{for(;u.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=u.queue;u.queue=[];for(let o of n)if(o.queued=!1,!o.disposed)try{o.run()}catch(s){t||(t=!0,r=s)}}}finally{u.flushing=!1}if(t)throw r}function _r(){u.batchDepth===0&&Ee()}function St(e){u.batchDepth++;try{return e()}finally{--u.batchDepth===0&&Ee()}}var mt=class{constructor(t,r=!1,n){this.queued=!1;this.disposed=!1;this.owner=Ce(u.owner),u.owner&&(u.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new H(()=>{_e(this.owner,!1),G(this.owner,()=>{let o=t();typeof o=="function"&&(this.owner.cleanups??=[]).push(o)})}),ee({kind:"effect",node:this.computed,handle:this,internal:!r,...n?{name:n}:{}}),this.watcher=new pe(()=>no(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),_e(this.owner))}};function Le(e,t=!1,r){let n=new mt(e,t,r);return()=>n.dispose()}function oo(e){return!!e&&typeof e.then=="function"}Ar(()=>{});var Cr=Symbol.for("signal"),so=Symbol.for("memo"),io=Symbol.for("signal-node");function p(e,t){let r=new de(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,io,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),ee({kind:"signal",node:r,handle:n,name:t?.name,set:o}),le()&&T(()=>V(r)),[n,o]}function y(e,t,r){let n=t,o=re(),s=new H(()=>G(o,()=>{try{return n=e(n)}catch(c){if(oo(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,so,{value:!0,enumerable:!0}),ee({kind:"memo",node:s,handle:i,name:r?.name}),le()&&T(()=>V(s)),i}function C(e,t,r){let n=t;return Le(()=>{n=e(n)},!0,r?.name)}function Ge(e,t){let r=t;Le(()=>{r=e(r)})}function We(e,t){let r=t;return Le(()=>{r=e(r)})}function R(e){return St(e)}function S(e){return te(e)}function gt(e){return St(e),Promise.resolve()}function Er(){return[()=>!1,gt]}function Pr(){return Ee(),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=te(()=>t(c,o,i));return o=c,a}}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=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,Y]=p(a,{name:"row index"});v=Y,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 uo(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(Y=>{M=Y;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 ao(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 fo=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,ze=typeof process>"u"?fo:!1,lo=Symbol.for("signal"),po=Symbol.for("memo"),ho=Symbol.for("resource");function ve(e){return typeof e=="function"&&e[lo]===!0}function jr(e){return typeof e=="function"&&e[po]===!0}function Ir(e){return typeof e=="function"&&e[ho]===!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 wt(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?wt(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var xt=null;function Nr(e){xt=e}function ne(e){xt&&xt(e)}var Rt=null;function qr(e){Rt=e}function be(e){return Rt?Rt(e):void 0}var Ot=null;function Br(e){Ot=e}function me(){return Ot?Ot():void 0}var kt=null;function Kr(e){kt=e}function oe(e,t){kt&&kt(e,t)}function Ye(){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 yo;function Pe(){let e=$r?.();return e||(typeof window>"u"?Ye():yo??=Ye())}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 vo(e){return!!e&&typeof e.then=="function"}var At=Symbol();function Te(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:me(),i=s!==void 0?be(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,Y]=p(void 0,{equals:!1}),P=At,F=!1;C(()=>{let w=n();if(M(),w===!1||w===null||w===void 0){P=At,R(()=>{m("unresolved"),g(void 0),d(void 0)});return}let O=F;if(F=!1,P!==At&&w===P&&!O)return;if(P=w,c){c=!1;return}let ie=!1;T(()=>ie=!0);let N=S(v),at=S(a),X=N==="ready"||N==="refreshing";R(()=>{m(X?"refreshing":"pending"),d(void 0)});try{let q=o(w,{value:at,refetching:X});vo(q)?(g(q),ne(q),q.then(J=>{ie||(s!==void 0&&oe(s,J),R(()=>{l(()=>J),m("ready"),g(void 0)}))},J=>{ie||R(()=>{d(J),m("errored"),g(void 0)})})):R(()=>{l(()=>q),m("ready"),g(void 0)})}catch(q){if(ie)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,Y(void 0)}}]}function _t(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 bo(e){return e!=null&&e!==""}function Wr(e,t,r={}){let{delay:n=300,initialValue:o,shouldFetch:s=bo}=r,[i,c,a]=_t(e,n),l=()=>s(i())?i():!1,[b,{refetch:d}]=Te(l,t,o===void 0?{}:{initialValue:o});return[b,{...a,query:i,setQuery:c,refetch:d}]}function Xe(e){if(typeof e=="function"&&!e.length){let t=e();return ve(t)?t:Xe(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=Xe(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 ze?y(()=>Xe(t()),void 0,{name:"children"}):y(()=>Xe(t()))}function mo(e,t){return()=>{let r=he(t);return T(()=>{Ve(r);let n=t.owned,o=n?n.indexOf(r):-1;o>=0&&n.splice(o,1)}),G(r,e)}}function Yr(e,t){return typeof e=="function"?ve(e)||e.length?e:mo(e,t):Array.isArray(e)?e.map(r=>Yr(r,t)):e}function Xr(e,t){let r=L(e,t),n=r.Provider;return{...r,Provider:s=>n({get value(){return s.value},get debug(){return s.debug},get children(){let i=re(),c=s.children;return i?Yr(c,i):c}})}}var Je=L();Rr((e,t)=>{let r=He(t,Je);r&&(r.increment(),e.finally(()=>r.decrement()))});function Jr(){let[e,t]=p(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function Qr(e,t){return ye(Je,e,t)}var Zr=L();kr((e,t)=>{let r=He(t,Zr);return r?(r.setError(e),!0):!1});function en(){let[e,t]=p(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function tn(e,t){return ye(Zr,e,t)}var rn={State:de,Computed:H,subtle:{Watcher:pe,untrack:te,currentComputed:Sr,hasSinks:gr}};var To=Symbol.for("signal"),So=Symbol.for("fluixi-proxy");function go(e,t){let[r,n]=p(e,t);return Object.assign(r,{set:n})}function wo(e,t,r){return y(e,t,r)}function xo(e,t,r){return C(e,t,r)}function Ro(e){return B(e)}function Oo(e,t){return We(e,t)}function ko(e,t){Ge(e,t)}function Ao(e,t){return L(e,t)}function _o(e){return he(e)}function nn(...e){let[t,r]=Te(...e);return Object.assign(t,r)}var Dt="1.0.0-alpha.104",fn=Dt.split(".")[0],on=`__fluixi_signal_state_v${fn}__`,Co=`__fluixi_signal_builds_v${fn}__`,Eo=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)};function ln(){return{consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Eo,onSuspend:null,onError:null,observer:null}}var Ct=globalThis;function Po(e){let t=ln(),r=e;for(let n of Object.keys(t))n in e||(r[n]=t[n]);return e}function Do(){let e=Ct[on];return e?Po(e):Ct[on]=ln()}var f=Do();(Ct[Co]??=[]).push(Dt);function jo(e){return f.observer=e,()=>{f.observer===e&&(f.observer=null)}}var Se=[],Io,sn;function jt(e){let t=f.observer;t&&t.created(e.parents===void 0?{...e,parents:Se,origin:e.origin??Io,scope:e.scope??sn}:{...e,scope:e.scope??sn})}function Fo(e){return f.observer?(Se.push(e),!0):!1}function Uo(){Se.pop()}function Mo(e){f.observer?.ran?.(e)}function No(e,t){f.observer?.wrote?.(e,t)}function qo(e){f.observer?.contextCreated?.(e)}function Bo(e,t,r){let n=f.observer;!n?.context||!Se.length||n.context(Se[Se.length-1],e,t,r)}function It(e){f.observer?.disposed?.(e)}var Ko="__FLUIXI_DEVTOOLS_HOOK__",cn=globalThis[Ko];if(typeof cn?.inject=="function")try{cn.inject({observeReactiveNodes:jo,version:Dt})}catch{}function dn(){return f.observer!=null}var un=0,an=1,De=2,pn=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))}},$o=class extends pn{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++,No(this,f.consumer),this.observers)for(let t of[...this.observers])t.markDirty(De);Et(this)}}peek(){return this._value}},hn=class extends pn{constructor(e,t){super(),this._threw=!1,this._initialized=!1,this.state=De,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===an&&this.sources){for(let e of this.sources)if(e.updateIfNecessary(),this.state===De)break}(this.state===De||!this._initialized)&&this.recompute(),this.state=un}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=Fo(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&&Uo()}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,Mo(this),i){if(this.version++,this.observers)for(let c of[...this.observers])c.markDirty(De);Et(this)}}markDirty(e){if(this.state>=e)return;let t=this.state===un;if(this.state=e,t){if(this.observers)for(let r of[...this.observers])r.markDirty(an);Et(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Et(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var Vo=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 Ho(e){if(f.untracked)return e();f.untracked=!0;try{return e()}finally{f.untracked=!1}}function yn(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function vn(e,t){let r=Symbol(t??"context");return qo(r),{id:r,defaultValue:e,Provider:o=>{Bo(r,"provide",o.value);let s=f.owner,i=yn(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 bn(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 Lo(e){f.onSuspend=e}function Go(e){return f.onSuspend?(f.onSuspend(e,f.owner),!0):!1}function Wo(e){f.onError=e}function zo(){return f.owner}function mn(e,t){let r=f.owner;f.owner=e;try{return t()}finally{f.owner=r}}function Tn(e){if(f.owner){if(f.owner.disposed){e();return}(f.owner.cleanups??=[]).push(e)}}function Pt(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)Pt(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 Yo(e){f.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function Xo(e){e.queued||(e.queued=!0,f.queue.push(e),!f.scheduled&&f.batchDepth===0&&(f.scheduled=!0,f.hostSchedule(Ft)))}function Ft(){if(f.scheduled=!1,f.flushing)return;f.flushing=!0;let e=0,t=!1,r;try{for(;f.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=f.queue;f.queue=[];for(let o of n)if(o.queued=!1,!o.disposed)try{o.run()}catch(s){t||(t=!0,r=s)}}}finally{f.flushing=!1}if(t)throw r}function Jo(){f.batchDepth===0&&Ft()}function Qo(e){f.batchDepth++;try{return e()}finally{--f.batchDepth===0&&Ft()}}var Zo=class{constructor(e,t=!1,r){this.queued=!1,this.disposed=!1,this.owner=yn(f.owner),f.owner&&(f.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new hn(()=>{Pt(this.owner,!1),mn(this.owner,()=>{let n=e();typeof n=="function"&&(this.owner.cleanups??=[]).push(n)})}),jt({kind:"effect",node:this.computed,handle:this,internal:!t,...r?{name:r}:{}}),this.watcher=new Vo(()=>Xo(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,It(this.computed),this.watcher.unwatch(this.computed),Pt(this.owner))}};function es(e,t=!1,r){let n=new Zo(e,t,r);return()=>n.dispose()}function ts(e){return!!e&&typeof e.then=="function"}Yo(()=>{});var Sn=Symbol.for("signal"),rs=Symbol.for("memo"),ns=Symbol.for("signal-node");function Ut(e,t){let r=new $o(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),Jo(),i});return Object.defineProperty(n,Sn,{value:!0,enumerable:!0}),Object.defineProperty(n,ns,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),jt({kind:"signal",node:r,handle:n,name:t?.name,set:o}),dn()&&Tn(()=>It(r)),[n,o]}function Qe(e,t,r){let n=t,o=zo(),s=new hn(()=>mn(o,()=>{try{return n=e(n)}catch(c){if(ts(c))return Go(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,Sn,{value:!0,enumerable:!0}),Object.defineProperty(i,rs,{value:!0,enumerable:!0}),jt({kind:"memo",node:s,handle:i,name:r?.name}),dn()&&Tn(()=>It(s)),i}function je(e,t,r){let n=t;return es(()=>{n=e(n)},!0,r?.name)}function Mt(e){return Qo(e)}function gn(e){return Ho(e)}var lc=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0;var os=vn();Lo((e,t)=>{let r=bn(t,os);r&&(r.increment(),e.finally(()=>r.decrement()))});var ss=vn();Wo((e,t)=>{let r=bn(t,ss);return r?(r.setError(e),!0):!1});var Ze=Symbol.for("fluixi-proxy");var we=Symbol("store-raw"),se=Symbol("store-node"),wn=Symbol("store-has"),rt=Symbol("store-self"),nt=Symbol("store-track"),An=Symbol("store-name"),_n=Symbol("store-store"),Ie=new WeakMap,Nt=new WeakMap,xe=new WeakMap,ot=new WeakMap;function is(e,t){if(!ge(e)||!le())return;let r=new Set,n=i=>{if(!(!ge(i)||r.has(i))){r.add(i);for(let c of Object.values(i))n(c)}};n(ot.get(t)??t);let o=new Set,s=i=>{if(!ge(i))return;let c=i;if(r.has(c)||o.has(c))return;o.add(c);let a=Ie.get(c);if(a){for(let l of a.keys.values())V(l);a.all&&V(a.all),Ie.delete(c),xe.delete(c),Nt.delete(c)}for(let l of Object.values(c))s(l)};s(e)}var st=(e,t,r)=>r?`${e}[${String(t)}]`:`${e}.${String(t)}`;function Cn(e,t,r){let n=t?.owner,o=n&&r!==void 0?st(n.name,r,t?.array):void 0,[s,i]=nr(n?.store,()=>Ut(e,o?{name:o}:void 0)),c=s;return c.$=i,c}function it(e){let t=Ie.get(e);return t?t.owner||(t.owner=xe.get(e)):Ie.set(e,t={keys:new Map,owner:xe.get(e),array:Array.isArray(e)}),t}function xn(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=Cn(r,e,t)),n}function cs(e,t,r,n){let o=xe.get(e);if(o&&o.store===t&&o.name===r)return;let s={store:t,name:r};xe.set(e,s),ot.set(e,ot.get(n)??n);let i=Ie.get(e);if(i&&(i.owner=s,!!le())){for(let[c,a]of i.keys)vt(a,t,st(r,c,i.array));i.all&&vt(i.all,t,st(r,"*",i.array))}}function Rn(e){let t=it(e);(t.all||(t.all=Cn(void 0,t,"*")))()}function On(e,t){e.$(typeof t=="function"?()=>t:t)}function ge(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 et(e){if(!ge(e))return e;let t=Nt.get(e);if(t)return t;let r=new Proxy(e,us);return Nt.set(e,r),r}var us={get(e,t,r){if(t===we||t===se)return e;if(t===Ze)return r;if(t===wn)return a=>a in e;if(t==="__proxy")return!0;if(t===nt||t===rt)return Rn(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=it(e),i=xn(s,t,n),c=i();return ge(c)?(s.owner&&cs(c,i,st(s.owner.name,t,s.array),e),et(c)):c},set(){return!0},deleteProperty(e,t){return t in e&&I(e,t,void 0),!0},has(e,t){return t===we||t===Ze||t===se||t===wn||t===rt||t===nt?!0:(xn(it(e),t,e[t])(),t in e)},ownKeys(e){return Rn(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function En(e,t=new Set){if(e==null||typeof e!="object")return e;let r=e[we]??e;if(t.has(r)||!ge(r))return r;t.add(r);let n=!1,o=i=>{let c=En(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=En(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=it(e),a=c.keys.get(t);if(a&&On(a,n),is(o,e),s&&e.length!==i){let l=c.keys.get("length");l&&On(l,e.length)}c.all&&c.all.$(void 0)}function qt(e,t){return typeof e=="function"?e(t):e}function Bt(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)?Bt(o,n):I(e,r,n)}}function ct(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function Pn(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++)Pn(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,qt(r,e[s]));return}I(e,o,qt(r,e[o]))}function kn(e,t,r){Pn(e,ct(t),r)}function as(e){return Array.isArray(e)&&e.length>0&&e.every(t=>Array.isArray(t)&&t.length>=2&&typeof t[0]=="string")}function tt(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 fs(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&Bt(e,n);return}if(Array.isArray(r)&&t.length===1){if(as(r)){for(let n of r)kn(e,n[0],n[1]);return}if(Array.isArray(e)){tt(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){Bt(e,r);return}if(t.length>=3){Kt(e,t.slice(0,-1),t[t.length-1]);return}kn(e,String(r),t[1])}function ls(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 Kt(e,t,r){if(e==null)return;let[n,...o]=t;if(typeof n=="string"){let i=ct(n);if(i.length>1){Kt(e,[...i,...o],r);return}}let s=ls(e,n);if(o.length===0){for(let i of s)I(e,i,qt(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)}Kt(c,o,r)}}function $t(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map($t);let t={};for(let r of Object.keys(e))t[r]=$t(e[r]);return t}function W(e,t){let r=e;for(let n of ct(t)){if(r==null)return;r=r[n]}return r}var z=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>Mt(()=>fs(this.root,n))),t&&typeof t=="object"&&(xe.set(t,{store:this,name:r.name??"store"}),ot.set(t,t)),ee({kind:"store",node:this,handle:()=>this.root,name:r.name})}get state(){return et(this.root)}get proxy(){return et(this.root)}get accessor(){return(()=>et(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return Re(this.state);let r=this.state;for(let n of ct(t)){if(r==null)return;r=r[n]}return Re(r)}select(t){return Qe(()=>t(this.state))}subscribe(t){return je(()=>t(this.state))}watch(t,r){let n;return je(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return Qe(()=>this.state[t])}produce(t){this.set((r=>{let n=$t(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=W(this.root,t);this.set(t,n.concat(r))}pop(t){let r=W(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=W(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=W(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=W(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=W(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}replace(t,r){if(arguments.length>=2){let o=W(this.root,String(t)),s=r;if(Array.isArray(o)&&Array.isArray(s)){tt(o,s);return}this.set(t,s);return}let n=this.root;if(Array.isArray(n)&&Array.isArray(t)){tt(n,t);return}this.set(t)}clear(t){let r=t===void 0?this.root:W(this.root,t);if(Array.isArray(r)){tt(r,[]);return}if(r&&typeof r=="object")for(let n of Object.keys(r))I(r,n,void 0)}toObservable(){let[t]=Ut(this.state);return t.toObservable()}dispose(){}},ds=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","replace","clear","unwrap","toObservable"];function Dn(e,t){for(let r of ds)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function Fe(e,t={immutable:!0}){let r=new z(e,t);return Dn(r.set,r),[r.proxy,r.set]}function Vt(e,t={}){return new z(e,{...t,immutable:!1})}function jn(e,t={}){let r=new z(e(),t);return je(()=>r.set(e())),r}function In(e,t,r){return je(()=>r(t(e)))}function Fn(e,t,r){return Qe(()=>t(e),void 0,r)}function Un(e,t={}){let r=new z(e,t),n=(()=>r.proxy);return Dn(n,r),n}function Re(e){if(e==null||typeof e!="object")return e;let t=e[we];return t!==void 0?t:e}function Ht(e){return gn(()=>Re(e))}function Mn(e){return ut(e)}function Nn(e){return ut(e)?e[se]:null}function qn(e){return e&&typeof e=="object"&&se in e?e[se]:null}function ut(e){return!!e&&typeof e=="object"&&(Ze in e||e.__proxy===!0)}function Bn(e){return e}var Kn=Object.freeze({createStore:Fe,createMutableStore:Vt,batch:Mt,unwrap:Re,untrackStore:Ht});function Lt(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Lt);let t={};for(let r of Object.keys(e))t[r]=Lt(e[r]);return t}function $n(e){return t=>{let r=Lt(t);return e(r),r}}function Vn(e,t={}){return()=>e}function Hn(e,t){let[r,n]=Fe(e,t);return new Proxy(r,{get:(o,s)=>s==="set"?n:o[s],has:(o,s)=>s==="set"||Reflect.has(o,s)})}function ps(e,t,r){return y(()=>t(e()),void 0,r)}function hs(e,t,r){return y(()=>e().filter(t),void 0,r)}function ys(e,t,r,n){return y(()=>e().reduce(t,r),void 0,n)}function vs(e,t,r){return y(()=>e().find(t),void 0,r)}function bs(e,t,r){return y(()=>e().some(t),void 0,r)}function ms(e,t,r){return y(()=>e().every(t),void 0,r)}function Ts(e,t,r){return y(()=>[...e()].sort(t),void 0,r)}function Ss(e,t){return y(()=>[...new Set(e())],void 0,t)}function gs(e,t,r){return y(()=>{let n=e.map(o=>o());return t(n)},void 0,r)}function ws(...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 xs(e,t,r){return y(()=>e()||t(),void 0,r)}function Rs(e,t,r,n){return y(()=>r(e(),t()),void 0,n)}function Os(e,t,r){return y(()=>t(e()),void 0,{equals:r,internal:!0})}function ks(e,t,r){return y(()=>{let n=e(),o={};for(let s of t)o[s]=n[s];return o},void 0,r)}function As(e,t,r){return y(()=>{let o={...e()};for(let s of t)delete o[s];return o},void 0,r)}function _s(e,t,r,n){return y(()=>e()?t():r(),void 0,n)}function Cs(e,t,r){return y(()=>e()?t():void 0,void 0,r)}function Es(e,t,r){let[n,o]=p(e()),s;return y(()=>{let i=e();clearTimeout(s),s=setTimeout(()=>o(()=>i),t)}),n}function Ps(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 Ds(e){let t=e;for(;typeof t=="function";)t=t();return t}var js=0,Is=Symbol.for("signal"),Fs=Symbol.for("resource");function Us(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_${js++}`,staleWhileRevalidate:a=!0}=s,l=c,b=s.cache??Pe(),d=b.inflight,v=s.transport===!1?void 0:me(),m=v!==void 0?be(v):void 0,E=s.deps??[],g=()=>E.map(h=>h()),M=(h,_=S(g))=>`${l}:${JSON.stringify(h)}`+(E.length?`:${JSON.stringify(_)}`:""),Y=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}),[ie,N]=p(void 0,{equals:!1}),[at,X]=p(!1),[q,J]=p(0,{equals:!1}),Ue=Symbol("unset"),Oe=Ue,ft=!1,lt=!1;function Gt(h,_,D,K){let j=d.get(_);if(j){j.then(x=>{K()||Wt(x,D)},x=>{!K()&&!D&&zt(x)}),D||(ne(j),N(j));return}let ke=Promise.resolve(o(h)).then(x=>(b.set(_,{value:x,timestamp:Date.now()}),d.delete(_),x),x=>{throw d.delete(_),x});d.set(_,ke),D||(ne(ke),N(ke)),ke.then(x=>{K()||Wt(x,D)},x=>{!K()&&!D&&zt(x)})}function Wt(h,_){v!==void 0&&oe(v,h),R(()=>{F(()=>h),A("ready"),X(!1),N(void 0),O(void 0)})}function zt(h){R(()=>{O(h),A("errored"),N(void 0)})}C(()=>{let h=n(),_=g();if(q(),h===!1||h===null||h===void 0){Oe=Ue,R(()=>{A("unresolved"),N(void 0),O(void 0)});return}let D=ft,K=lt;ft=!1,lt=!1;let j=M(h,_);m&&Oe===Ue&&!b.get(j)&&b.set(j,{value:m.value,timestamp:Date.now()}),K&&b.delete(j);let ke=Oe===Ue||h!==Oe;Oe=h;let x=!1;T(()=>{x=!0});let Q=b.get(j);if(Q&&Y(Q)&&!D&&!K){v!==void 0&&oe(v,Q.value),(S(U)!=="ready"||S(P)!==Q.value)&&R(()=>{F(()=>Q.value),A("ready"),X(!1),O(void 0)});return}if(Q&&a&&!K){R(()=>{F(()=>Q.value),A("ready"),X(!0),O(void 0),N(void 0)}),Gt(h,j,!0,()=>x);return}let Yt=S(U),Ln=Yt==="ready"||Yt==="refreshing";R(()=>{A(Ln?"refreshing":"pending"),O(void 0),X(!1)}),Gt(h,j,!1,()=>x)});let Me=(()=>{let h=w();if(h)throw h;if(U()==="pending"){let D=ie();if(D)throw D}return P()});return Object.defineProperty(Me,Fs,{value:!0,enumerable:!0}),Object.defineProperty(Me,Is,{value:!0,enumerable:!0}),Object.defineProperties(Me,{state:{get:U},loading:{get:()=>{let h=U();return h==="pending"||h==="refreshing"}},error:{get:w},latest:{get:P},stale:{get:at}}),Object.assign(Me,{mutate:F,refetch:()=>{ft=!0,J(h=>h+1)},invalidate:()=>{let h=S(n);h!=null&&h!==!1&&b.delete(M(h)),lt=!0,J(_=>_+1)}})}function Ms(e,t=Pe()){if(e===void 0)return t.clear();let r=`${e}:`;for(let n of[...t.keys()])n.startsWith(r)&&t.delete(n)}return Jn(Ns);})();
|
|
1
|
+
/*! @fluixi/reactive v1.0.0-alpha.106 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
|
+
"use strict";var Fluixi=(()=>{var pt=Object.defineProperty;var Wn=Object.getOwnPropertyDescriptor;var zn=Object.getOwnPropertyNames;var Yn=Object.prototype.hasOwnProperty;var Xn=(e,t)=>{for(var r in t)pt(e,r,{get:t[r],enumerable:!0})},Jn=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of zn(t))!Yn.call(e,o)&&o!==r&&pt(e,o,{get:()=>t[o],enumerable:!(n=Wn(t,o))||n.enumerable});return e};var Qn=e=>Jn(pt({},"__esModule",{value:!0}),e);var qs={};Xn(qs,{$NAME:()=>_n,$NODE:()=>se,$PROXY:()=>go,$RAW:()=>we,$SELF:()=>nt,$SIGNAL:()=>So,$STORE:()=>Cn,$TRACK:()=>ot,Observable:()=>$,SafeSubscriber:()=>qe,Signal:()=>on,Store:()=>Y,StoreAPI:()=>Vn,Subject:()=>yt,Subscriber:()=>ae,Subscription:()=>ue,SuspenseContext:()=>Qe,VERSION:()=>Z,__DEV__:()=>Ye,adoptReactiveScope:()=>ur,batch:()=>R,cachedResource:()=>Ms,childOwner:()=>Co,clearCachedResources:()=>Ns,closeReactiveScope:()=>cr,combineSignal:()=>ws,combineSignals:()=>xs,computed:()=>Ao,context:()=>_o,createChildOwner:()=>he,createComputed:()=>We,createComputedStore:()=>jn,createContext:()=>Qr,createDebounce:()=>zr,createDebouncedResource:()=>Yr,createDebouncedSignal:()=>Ct,createDeferred:()=>Wr,createEffect:()=>_,createErrorBoundary:()=>rn,createMemo:()=>y,createMutableStore:()=>Ht,createRenderEffect:()=>ze,createResource:()=>Te,createResourceCache:()=>Xe,createRoot:()=>K,createSelector:()=>Gr,createSignal:()=>p,createStore:()=>Ue,createStoreEffect:()=>Fn,createStoreMemo:()=>Un,createSuspenseBoundary:()=>Zr,currentResourceCache:()=>Pe,debounceSignal:()=>Ps,disposeScope:()=>He,distinctSignal:()=>gs,effect:()=>Ro,everySignal:()=>Ts,filterSignal:()=>ys,findSignal:()=>bs,flush:()=>Dr,getNode:()=>qn,getOwner:()=>re,getServerData:()=>be,getStoreNode:()=>Bn,guardSignal:()=>Es,indexArray:()=>fo,isComponent:()=>Mr,isMemo:()=>Fr,isOwnerDisposed:()=>xr,isProvider:()=>qr,isResource:()=>Ur,isSignal:()=>ve,isStore:()=>Nn,isStoreProxy:()=>at,isSuspense:()=>Nr,joinedVersions:()=>rr,keyArray:()=>ao,makeArrayFlat:()=>xt,mapArray:()=>uo,mapSignal:()=>hs,markReactiveScope:()=>fr,memo:()=>xo,mergeSignal:()=>Rs,modifiable:()=>Kn,nextResourceId:()=>me,observeReactiveNodes:()=>vt,omitSignal:()=>_s,on:()=>Ir,onCleanup:()=>T,openReactiveScope:()=>sr,operate:()=>Zn,pickSignal:()=>As,produceUtil:()=>$n,provide:()=>ye,provideErrorBoundary:()=>nn,provideSuspense:()=>en,reactiveScopeOf:()=>lr,readChildren:()=>Xr,readSignal:()=>Is,reconcileUtil:()=>Hn,reduceSignal:()=>vs,renderEffect:()=>ko,reportReactiveBinding:()=>vr,reportReactiveContext:()=>le,reportReactiveContextCreated:()=>Ve,reportReactiveDirective:()=>mr,reportReactiveProps:()=>br,reportResourceData:()=>oe,resource:()=>sn,root:()=>Oo,runWithOwner:()=>W,selectSignal:()=>ks,setOwner:()=>St,setResourceCacheScope:()=>Lr,setResourceDataSink:()=>$r,setResourceIdSource:()=>Vr,setResourceTracker:()=>Br,setServerDataGetter:()=>Kr,signal:()=>wo,someSignal:()=>ms,sortSignal:()=>Ss,startTransition:()=>wt,store:()=>Ln,throttleSignal:()=>Ds,trackResourcePromise:()=>ne,untrack:()=>S,untrackStore:()=>Lt,unwrap:()=>Re,useContext:()=>Rr,useTransition:()=>Pr,whenSignal:()=>Cs,withReactiveScope:()=>ir,wrap:()=>Mn,zipSignal:()=>Os});var Z="1.0.0-alpha.106";function ht(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function Jt(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 ue=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(ht(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if(Jt(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(ht(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 ae=class extends ue{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())}},qe=class extends ae{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 Zn(e){return new ae(e.next,e.error,e.complete)}var $=class extends ue{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 ae?o=t:o=new qe(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 yt=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 Zt=Z.split(".")[0],Qt=`__fluixi_signal_state_v${Zt}__`,er=`__fluixi_signal_builds_v${Zt}__`,eo=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)};function tr(){return{consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:eo,onSuspend:null,onError:null,observer:null}}var Be=globalThis;function to(e){let t=tr(),r=e;for(let n of Object.keys(t))n in e||(r[n]=t[n]);return e}function ro(){let e=Be[Qt];return e?to(e):Be[Qt]=tr()}var u=ro();(Be[er]??=[]).push(Z);function rr(){return[...new Set(Be[er]??[])]}function vt(e){return u.observer=e,()=>{u.observer===e&&(u.observer=null)}}var O=[],Ke;function or(e,t){if(!u.observer)return t();let r=Ke;Ke=e;try{return t()}finally{Ke=r}}var fe;function sr(e){let t={};return u.observer?.scope?.(t,e,fe),t}function ir(e,t){if(!u.observer)return t();let r=fe;fe=e;try{return t()}finally{fe=r}}function cr(e){u.observer?.scopeEnded?.(e)}function ur(e,t){u.observer?.scopeAdopted?.(e,t)}var ar=Symbol.for("fluixi.reactiveScope");function fr(e,t){Object.defineProperty(e,ar,{value:t,configurable:!0,enumerable:!1})}function lr(e){return e!==null&&(typeof e=="object"||typeof e=="function")?e[ar]??void 0:void 0}function ee(e){let t=u.observer;t&&t.created(e.parents===void 0?{...e,parents:O,origin:e.origin??Ke,scope:e.scope??fe}:{...e,scope:e.scope??fe})}function dr(e){return u.observer?(O.push(e),!0):!1}function pr(){O.pop()}function hr(e){u.observer?.ran?.(e)}function yr(e,t){u.observer?.wrote?.(e,t)}function vr(e,t,r,n){let o=u.observer;!o?.bound||!O.length||o.bound(O[O.length-1],e,t,r,n)}function br(e){let t=u.observer;!t?.props||!O.length||!e||t.props(O[O.length-1],e)}function mr(e,t,r,n){let o=u.observer;!o?.directive||!O.length||o.directive(O[O.length-1],e,t,r,n)}function Ve(e){u.observer?.contextCreated?.(e)}function le(e,t,r){let n=u.observer;!n?.context||!O.length||n.context(O[O.length-1],e,t,r)}function bt(e,t,r){u.observer?.moved?.(e,t,r)}function H(e){u.observer?.disposed?.(e)}var no="__FLUIXI_DEVTOOLS_HOOK__",nr=globalThis[no];if(typeof nr?.inject=="function")try{nr.inject({observeReactiveNodes:vt,version:Z})}catch{}function j(){return u.observer!=null}var Tr=0,Sr=1,Ae=2,$e=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))}},de=class extends $e{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++,yr(this,u.consumer),this.observers)for(let r of[...this.observers])r.markDirty(Ae);mt(this)}}peek(){return this._value}},L=class extends $e{constructor(r,n){super();this._threw=!1;this._initialized=!1;this._disposed=!1;this.state=Ae;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}dispose(){if(!this._disposed&&(this._disposed=!0,this.sources)){for(let r of this.sources)r.observers?.delete(this);this.sources=null}}updateIfNecessary(){if(!this._disposed){if(this.state===Sr&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===Ae)break}(this.state===Ae||!this._initialized)&&this.recompute(),this.state=Tr}}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=dr(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&&pr()}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,hr(this),a){if(this.version++,this.observers)for(let l of this.observers)l.markDirty(Ae);mt(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===Tr;if(this.state=r,n){if(this.observers)for(let o of this.observers)o.markDirty(Sr);mt(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function mt(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var pe=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}clearPending(){this._pending.clear()}_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 te(e){if(u.untracked)return e();u.untracked=!0;try{return e()}finally{u.untracked=!1}}function gr(){return u.consumer}function wr(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function he(e){let t=Ce(e);return e&&(e.owned??=[]).push(t),t}function He(e,t=!0){_e(e,t)}function xr(e){return!!e&&e.disposed===!0}function Ce(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function G(e,t){let r=Symbol(t??"context");return Ve(r),{id:r,defaultValue:e,Provider:o=>{le(r,"provide",o.value);let s=u.owner,i=Ce(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 Rr(e){let t=u.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id)){let r=t.contexts.get(e.id);return le(e.id,"read",r),r}t=t.parent}return le(e.id,"read",e.defaultValue),e.defaultValue}function Le(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 ye(e,t,r){let n=Ce(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 Or(e){u.onSuspend=e}function kr(e){return u.onSuspend?(u.onSuspend(e,u.owner),!0):!1}function Ar(e){u.onError=e}function re(){return u.owner}function St(e){let t=u.owner;return u.owner=e,t}function W(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 _e(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)_e(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 K(e){let t=Ce(u.owner);u.owner&&(u.owner.owned??=[]).push(t);let r=u.owner;u.owner=t;try{return te(()=>e(()=>_e(t)))}finally{u.owner=r}}function _r(e){u.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function oo(e){e.queued||(e.queued=!0,u.queue.push(e),!u.scheduled&&u.batchDepth===0&&(u.scheduled=!0,u.hostSchedule(Ee)))}function Ee(){if(u.scheduled=!1,u.flushing)return;u.flushing=!0;let e=0,t=!1,r;try{for(;u.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=u.queue;u.queue=[];for(let o of n)if(o.queued=!1,!o.disposed)try{o.run()}catch(s){t||(t=!0,r=s)}}}finally{u.flushing=!1}if(t)throw r}function Cr(){u.batchDepth===0&&Ee()}function gt(e){u.batchDepth++;try{return e()}finally{--u.batchDepth===0&&Ee()}}var Tt=class{constructor(t,r=!1,n){this.queued=!1;this.disposed=!1;this.owner=Ce(u.owner),u.owner&&(u.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new L(()=>{_e(this.owner,!1),W(this.owner,()=>{let o=t();typeof o=="function"&&(this.owner.cleanups??=[]).push(o)})}),j()&&ee({kind:"effect",node:this.computed,handle:this,internal:!r,...n?{name:n}:{}}),this.watcher=new pe(()=>oo(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.clearPending();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,H(this.computed),this.watcher.unwatch(this.computed),this.computed.dispose(),_e(this.owner))}};function Ge(e,t=!1,r){let n=new Tt(e,t,r);return()=>n.dispose()}function so(e){return!!e&&typeof e.then=="function"}_r(()=>{});var Er=Symbol.for("signal"),io=Symbol.for("memo"),co=Symbol.for("signal-node");function p(e,t){let r=new de(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),Cr(),i});return Object.defineProperty(n,Er,{value:!0,enumerable:!0}),Object.defineProperty(n,co,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),j()&&ee({kind:"signal",node:r,handle:n,name:t?.name,set:o}),j()&&T(()=>H(r)),[n,o]}function y(e,t,r){let n=t,o=re(),s=new L(()=>W(o,()=>{try{return n=e(n)}catch(c){if(so(c))return kr(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,Er,{value:!0,enumerable:!0}),Object.defineProperty(i,io,{value:!0,enumerable:!0}),j()&&ee({kind:"memo",node:s,handle:i,name:r?.name}),T(()=>{s.dispose(),j()&&H(s)}),i}function _(e,t,r){let n=t;return Ge(()=>{n=e(n)},!0,r?.name)}function We(e,t){let r=t;Ge(()=>{r=e(r)})}function ze(e,t){let r=t;return Ge(()=>{r=e(r)})}function R(e){return gt(e)}function S(e){return te(e)}function wt(e){return gt(e),Promise.resolve()}function Pr(){return[()=>!1,wt]}function Dr(){return Ee(),Promise.resolve()}function Ir(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=te(()=>t(c,o,i));return o=c,a}}function jr(e){let t=e,r=null;return{index:()=>(r||(r=p(t,{name:"row index"})),r[0]()),set:n=>{t=n,r&&r[1](n)}}}function uo(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;K(w=>{m=w;let U=jr(a);v=U.set,d=t(l,U.index)});let C={item:l,rendered:d,dispose:m,setIndex:v};i.push(C),c.add(C)}}for(let a of n)c.has(a)||a.dispose();return n=i,i.map(a=>a.rendered)})},void 0,{name:"mapArray"})}function ao(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),m.setItem(i[d]),a.push(m);else{let C,w,U,ie;K(M=>{ie=M;let E=jr(d);w=E.set;let[N,k]=p(i[d]);U=g=>k(()=>g),C=r(N,E.index)}),a.push({rendered:C,dispose:ie,setIndex:w,setItem:U})}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 fo(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];K(m=>{d=m;let[C,w]=p(v);b=w,l=t(C,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 lo=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,Ye=typeof process>"u"?lo:!1,po=Symbol.for("signal"),ho=Symbol.for("memo"),yo=Symbol.for("resource");function ve(e){return typeof e=="function"&&e[po]===!0}function Fr(e){return typeof e=="function"&&e[ho]===!0}function Ur(e){return typeof e=="function"&&e[yo]===!0}function Mr(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Nr(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function qr(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function xt(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?xt(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var Rt=null;function Br(e){Rt=e}function ne(e){Rt&&Rt(e)}var Ot=null;function Kr(e){Ot=e}function be(e){return Ot?Ot(e):void 0}var kt=null;function Vr(e){kt=e}function me(){return kt?kt():void 0}var At=null;function $r(e){At=e}function oe(e,t){At&&At(e,t)}function Xe(){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 Hr=null;function Lr(e){Hr=e}var vo;function Pe(){let e=Hr?.();return e||(typeof window>"u"?Xe():vo??=Xe())}function Gr(e,t=(r,n)=>r===n){let r=new Map;return _(()=>{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 Wr(e,t){let[r,n]=p(e(),t);return _(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function zr(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 bo(e){return!!e&&typeof e.then=="function"}var _t=Symbol();function Te(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:me(),i=s!==void 0?be(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}),[C,w]=p(void 0,{equals:!1}),[U,ie]=p(void 0,{equals:!1}),M=_t,E=!1;_(()=>{let g=n();if(U(),g===!1||g===null||g===void 0){M=_t,R(()=>{m("unresolved"),w(void 0),d(void 0)});return}let P=E;if(E=!1,M!==_t&&g===M&&!P)return;if(M=g,c){c=!1;return}let ce=!1;T(()=>ce=!0);let q=S(v),ft=S(a),X=q==="ready"||q==="refreshing";R(()=>{m(X?"refreshing":"pending"),d(void 0)});try{let B=o(g,{value:ft,refetching:X});bo(B)?(w(B),ne(B),B.then(J=>{ce||(s!==void 0&&oe(s,J),R(()=>{l(()=>J),m("ready"),w(void 0)}))},J=>{ce||R(()=>{d(J),m("errored"),w(void 0)})})):R(()=>{l(()=>B),m("ready"),w(void 0)})}catch(B){if(ce)return;R(()=>{d(B),m("errored"),w(void 0)})}});let N=()=>{let g=v();return g==="pending"||g==="refreshing"},k=(()=>{let g=b();if(g)throw g;if(N()){let P=C();if(P)throw P}return a()});return Object.defineProperties(k,{state:{get:v},loading:{get:N},error:{get:b},latest:{get:a}}),Object.defineProperty(k,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(k,Symbol.for("signal"),{value:!0,enumerable:!0}),[k,{mutate:l,refetch:()=>{E=!0,ie(void 0)}}]}function Ct(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 mo(e){return e!=null&&e!==""}function Yr(e,t,r={}){let{delay:n=300,initialValue:o,shouldFetch:s=mo}=r,[i,c,a]=Ct(e,n),l=()=>s(i())?i():!1,[b,{refetch:d}]=Te(l,t,o===void 0?{}:{initialValue:o});return[b,{...a,query:i,setQuery:c,refetch:d}]}function Je(e){if(typeof e=="function"&&!e.length){let t=e();return ve(t)?t:Je(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=Je(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Xr(e){let t=y(e);return Ye?y(()=>Je(t()),void 0,{name:"children"}):y(()=>Je(t()))}function To(e,t){return()=>{let r=he(t);return T(()=>{He(r);let n=t.owned,o=n?n.indexOf(r):-1;o>=0&&n.splice(o,1)}),W(r,e)}}function Jr(e,t){return typeof e=="function"?ve(e)||e.length?e:To(e,t):Array.isArray(e)?e.map(r=>Jr(r,t)):e}function Qr(e,t){let r=G(e,t),n=r.Provider;return{...r,Provider:s=>n({get value(){return s.value},get debug(){return s.debug},get children(){let i=re(),c=s.children;return i?Jr(c,i):c}})}}var Qe=G();Or((e,t)=>{let r=Le(t,Qe);r&&(r.increment(),e.finally(()=>r.decrement()))});function Zr(){let[e,t]=p(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function en(e,t){return ye(Qe,e,t)}var tn=G();Ar((e,t)=>{let r=Le(t,tn);return r?(r.setError(e),!0):!1});function rn(){let[e,t]=p(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function nn(e,t){return ye(tn,e,t)}var on={State:de,Computed:L,subtle:{Watcher:pe,untrack:te,currentComputed:gr,hasSinks:wr}};var So=Symbol.for("signal"),go=Symbol.for("fluixi-proxy");function wo(e,t){let[r,n]=p(e,t);return Object.assign(r,{set:n})}function xo(e,t,r){return y(e,t,r)}function Ro(e,t,r){return _(e,t,r)}function Oo(e){return K(e)}function ko(e,t){return ze(e,t)}function Ao(e,t){We(e,t)}function _o(e,t){return G(e,t)}function Co(e){return he(e)}function sn(...e){let[t,r]=Te(...e);return Object.assign(t,r)}var It="1.0.0-alpha.106",dn=It.split(".")[0],cn=`__fluixi_signal_state_v${dn}__`,Eo=`__fluixi_signal_builds_v${dn}__`,Po=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)};function pn(){return{consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Po,onSuspend:null,onError:null,observer:null}}var Et=globalThis;function Do(e){let t=pn(),r=e;for(let n of Object.keys(t))n in e||(r[n]=t[n]);return e}function Io(){let e=Et[cn];return e?Do(e):Et[cn]=pn()}var f=Io();(Et[Eo]??=[]).push(It);function jo(e){return f.observer=e,()=>{f.observer===e&&(f.observer=null)}}var Se=[],Fo,un;function jt(e){let t=f.observer;t&&t.created(e.parents===void 0?{...e,parents:Se,origin:e.origin??Fo,scope:e.scope??un}:{...e,scope:e.scope??un})}function Uo(e){return f.observer?(Se.push(e),!0):!1}function Mo(){Se.pop()}function No(e){f.observer?.ran?.(e)}function qo(e,t){f.observer?.wrote?.(e,t)}function Bo(e){f.observer?.contextCreated?.(e)}function Ko(e,t,r){let n=f.observer;!n?.context||!Se.length||n.context(Se[Se.length-1],e,t,r)}function Ft(e){f.observer?.disposed?.(e)}var Vo="__FLUIXI_DEVTOOLS_HOOK__",an=globalThis[Vo];if(typeof an?.inject=="function")try{an.inject({observeReactiveNodes:jo,version:It})}catch{}function Ie(){return f.observer!=null}var fn=0,ln=1,De=2,hn=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))}},$o=class extends hn{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++,qo(this,f.consumer),this.observers)for(let t of[...this.observers])t.markDirty(De);Pt(this)}}peek(){return this._value}},yn=class extends hn{constructor(e,t){super(),this._threw=!1,this._initialized=!1,this._disposed=!1,this.state=De,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}dispose(){if(!this._disposed&&(this._disposed=!0,this.sources)){for(let e of this.sources)e.observers?.delete(this);this.sources=null}}updateIfNecessary(){if(!this._disposed){if(this.state===ln&&this.sources){for(let e of this.sources)if(e.updateIfNecessary(),this.state===De)break}(this.state===De||!this._initialized)&&this.recompute(),this.state=fn}}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=Uo(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&&Mo()}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,No(this),i){if(this.version++,this.observers)for(let c of this.observers)c.markDirty(De);Pt(this)}}markDirty(e){if(this.state>=e)return;let t=this.state===fn;if(this.state=e,t){if(this.observers)for(let r of this.observers)r.markDirty(ln);Pt(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Pt(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var Ho=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}clearPending(){this._pending.clear()}_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 Lo(e){if(f.untracked)return e();f.untracked=!0;try{return e()}finally{f.untracked=!1}}function vn(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function bn(e,t){let r=Symbol(t??"context");return Bo(r),{id:r,defaultValue:e,Provider:o=>{Ko(r,"provide",o.value);let s=f.owner,i=vn(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 mn(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 Go(e){f.onSuspend=e}function Wo(e){return f.onSuspend?(f.onSuspend(e,f.owner),!0):!1}function zo(e){f.onError=e}function Yo(){return f.owner}function Tn(e,t){let r=f.owner;f.owner=e;try{return t()}finally{f.owner=r}}function Sn(e){if(f.owner){if(f.owner.disposed){e();return}(f.owner.cleanups??=[]).push(e)}}function Dt(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)Dt(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 Xo(e){f.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function Jo(e){e.queued||(e.queued=!0,f.queue.push(e),!f.scheduled&&f.batchDepth===0&&(f.scheduled=!0,f.hostSchedule(Ut)))}function Ut(){if(f.scheduled=!1,f.flushing)return;f.flushing=!0;let e=0,t=!1,r;try{for(;f.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=f.queue;f.queue=[];for(let o of n)if(o.queued=!1,!o.disposed)try{o.run()}catch(s){t||(t=!0,r=s)}}}finally{f.flushing=!1}if(t)throw r}function Qo(){f.batchDepth===0&&Ut()}function Zo(e){f.batchDepth++;try{return e()}finally{--f.batchDepth===0&&Ut()}}var es=class{constructor(e,t=!1,r){this.queued=!1,this.disposed=!1,this.owner=vn(f.owner),f.owner&&(f.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new yn(()=>{Dt(this.owner,!1),Tn(this.owner,()=>{let n=e();typeof n=="function"&&(this.owner.cleanups??=[]).push(n)})}),Ie()&&jt({kind:"effect",node:this.computed,handle:this,internal:!t,...r?{name:r}:{}}),this.watcher=new Ho(()=>Jo(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.clearPending();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,Ft(this.computed),this.watcher.unwatch(this.computed),this.computed.dispose(),Dt(this.owner))}};function ts(e,t=!1,r){let n=new es(e,t,r);return()=>n.dispose()}function rs(e){return!!e&&typeof e.then=="function"}Xo(()=>{});var gn=Symbol.for("signal"),ns=Symbol.for("memo"),os=Symbol.for("signal-node");function Mt(e,t){let r=new $o(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),Qo(),i});return Object.defineProperty(n,gn,{value:!0,enumerable:!0}),Object.defineProperty(n,os,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),Ie()&&jt({kind:"signal",node:r,handle:n,name:t?.name,set:o}),Ie()&&Sn(()=>Ft(r)),[n,o]}function Ze(e,t,r){let n=t,o=Yo(),s=new yn(()=>Tn(o,()=>{try{return n=e(n)}catch(c){if(rs(c))return Wo(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,gn,{value:!0,enumerable:!0}),Object.defineProperty(i,ns,{value:!0,enumerable:!0}),Ie()&&jt({kind:"memo",node:s,handle:i,name:r?.name}),Sn(()=>{s.dispose(),Ie()&&Ft(s)}),i}function je(e,t,r){let n=t;return ts(()=>{n=e(n)},!0,r?.name)}function Nt(e){return Zo(e)}function wn(e){return Lo(e)}var dc=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0;var ss=bn();Go((e,t)=>{let r=mn(t,ss);r&&(r.increment(),e.finally(()=>r.decrement()))});var is=bn();zo((e,t)=>{let r=mn(t,is);return r?(r.setError(e),!0):!1});var et=Symbol.for("fluixi-proxy");var we=Symbol("store-raw"),se=Symbol("store-node"),xn=Symbol("store-has"),nt=Symbol("store-self"),ot=Symbol("store-track"),_n=Symbol("store-name"),Cn=Symbol("store-store"),Fe=new WeakMap,qt=new WeakMap,xe=new WeakMap,st=new WeakMap;function cs(e,t){if(!ge(e)||!j())return;let r=new Set,n=i=>{if(!(!ge(i)||r.has(i))){r.add(i);for(let c of Object.values(i))n(c)}};n(st.get(t)??t);let o=new Set,s=i=>{if(!ge(i))return;let c=i;if(r.has(c)||o.has(c))return;o.add(c);let a=Fe.get(c);if(a){for(let l of a.keys.values())H(l);a.all&&H(a.all),Fe.delete(c),xe.delete(c),qt.delete(c)}for(let l of Object.values(c))s(l)};s(e)}var it=(e,t,r)=>r?`${e}[${String(t)}]`:`${e}.${String(t)}`;function En(e,t,r){let n=t?.owner,o=n&&r!==void 0?it(n.name,r,t?.array):void 0,[s,i]=or(n?.store,()=>Mt(e,o?{name:o}:void 0)),c=s;return c.$=i,c}function ct(e){let t=Fe.get(e);return t?t.owner||(t.owner=xe.get(e)):Fe.set(e,t={keys:new Map,owner:xe.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=En(r,e,t)),n}function us(e,t,r,n){let o=xe.get(e);if(o&&o.store===t&&o.name===r)return;let s={store:t,name:r};xe.set(e,s),st.set(e,st.get(n)??n);let i=Fe.get(e);if(i&&(i.owner=s,!!j())){for(let[c,a]of i.keys)bt(a,t,it(r,c,i.array));i.all&&bt(i.all,t,it(r,"*",i.array))}}function On(e){let t=ct(e);(t.all||(t.all=En(void 0,t,"*")))()}function kn(e,t){e.$(typeof t=="function"?()=>t:t)}function ge(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 tt(e){if(!ge(e))return e;let t=qt.get(e);if(t)return t;let r=new Proxy(e,as);return qt.set(e,r),r}var as={get(e,t,r){if(t===we||t===se)return e;if(t===et)return r;if(t===xn)return a=>a in e;if(t==="__proxy")return!0;if(t===ot||t===nt)return On(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=ct(e),i=Rn(s,t,n),c=i();return ge(c)?(s.owner&&us(c,i,it(s.owner.name,t,s.array),e),tt(c)):c},set(){return!0},deleteProperty(e,t){return t in e&&F(e,t,void 0),!0},has(e,t){return t===we||t===et||t===se||t===xn||t===nt||t===ot?!0:(Rn(ct(e),t,e[t])(),t in e)},ownKeys(e){return On(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function Pn(e,t=new Set){if(e==null||typeof e!="object")return e;let r=e[we]??e;if(t.has(r)||!ge(r))return r;t.add(r);let n=!1,o=i=>{let c=Pn(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 F(e,t,r){let n=Pn(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=ct(e),a=c.keys.get(t);if(a&&kn(a,n),cs(o,e),s&&e.length!==i){let l=c.keys.get("length");l&&kn(l,e.length)}c.all&&c.all.$(void 0)}function Bt(e,t){return typeof e=="function"?e(t):e}function Kt(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)?Kt(o,n):F(e,r,n)}}function ut(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function Dn(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++)Dn(e[l],a,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},F(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)F(e,s,Bt(r,e[s]));return}F(e,o,Bt(r,e[o]))}function An(e,t,r){Dn(e,ut(t),r)}function fs(e){return Array.isArray(e)&&e.length>0&&e.every(t=>Array.isArray(t)&&t.length>=2&&typeof t[0]=="string")}function rt(e,t){for(let r=e.length-1;r>=t.length;r--)F(e,String(r),void 0);e.length!==t.length&&F(e,"length",t.length);for(let r=0;r<t.length;r++)F(e,String(r),t[r])}function ls(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&Kt(e,n);return}if(Array.isArray(r)&&t.length===1){if(fs(r)){for(let n of r)An(e,n[0],n[1]);return}if(Array.isArray(e)){rt(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){Kt(e,r);return}if(t.length>=3){Vt(e,t.slice(0,-1),t[t.length-1]);return}An(e,String(r),t[1])}function ds(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 Vt(e,t,r){if(e==null)return;let[n,...o]=t;if(typeof n=="string"){let i=ut(n);if(i.length>1){Vt(e,[...i,...o],r);return}}let s=ds(e,n);if(o.length===0){for(let i of s)F(e,i,Bt(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))?[]:{},F(e,i,c)}Vt(c,o,r)}}function $t(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map($t);let t={};for(let r of Object.keys(e))t[r]=$t(e[r]);return t}function z(e,t){let r=e;for(let n of ut(t)){if(r==null)return;r=r[n]}return r}var Y=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>Nt(()=>ls(this.root,n))),t&&typeof t=="object"&&(xe.set(t,{store:this,name:r.name??"store"}),st.set(t,t)),j()&&ee({kind:"store",node:this,handle:()=>this.root,name:r.name})}get state(){return tt(this.root)}get proxy(){return tt(this.root)}get accessor(){return(()=>tt(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return Re(this.state);let r=this.state;for(let n of ut(t)){if(r==null)return;r=r[n]}return Re(r)}select(t){return Ze(()=>t(this.state))}subscribe(t){return je(()=>t(this.state))}watch(t,r){let n;return je(()=>{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=$t(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=z(this.root,t);this.set(t,n.concat(r))}pop(t){let r=z(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=z(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=z(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=z(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=z(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}replace(t,r){if(arguments.length>=2){let o=z(this.root,String(t)),s=r;if(Array.isArray(o)&&Array.isArray(s)){rt(o,s);return}this.set(t,s);return}let n=this.root;if(Array.isArray(n)&&Array.isArray(t)){rt(n,t);return}this.set(t)}clear(t){let r=t===void 0?this.root:z(this.root,t);if(Array.isArray(r)){rt(r,[]);return}if(r&&typeof r=="object")for(let n of Object.keys(r))F(r,n,void 0)}toObservable(){let[t]=Mt(this.state);return t.toObservable()}dispose(){}},ps=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","replace","clear","unwrap","toObservable"];function In(e,t){for(let r of ps)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function Ue(e,t={immutable:!0}){let r=new Y(e,t);return In(r.set,r),[r.proxy,r.set]}function Ht(e,t={}){return new Y(e,{...t,immutable:!1})}function jn(e,t={}){let r=new Y(e(),t);return je(()=>r.set(e())),r}function Fn(e,t,r){return je(()=>r(t(e)))}function Un(e,t,r){return Ze(()=>t(e),void 0,r)}function Mn(e,t={}){let r=new Y(e,t),n=(()=>r.proxy);return In(n,r),n}function Re(e){if(e==null||typeof e!="object")return e;let t=e[we];return t!==void 0?t:e}function Lt(e){return wn(()=>Re(e))}function Nn(e){return at(e)}function qn(e){return at(e)?e[se]:null}function Bn(e){return e&&typeof e=="object"&&se in e?e[se]:null}function at(e){return!!e&&typeof e=="object"&&(et in e||e.__proxy===!0)}function Kn(e){return e}var Vn=Object.freeze({createStore:Ue,createMutableStore:Ht,batch:Nt,unwrap:Re,untrackStore:Lt});function Gt(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Gt);let t={};for(let r of Object.keys(e))t[r]=Gt(e[r]);return t}function $n(e){return t=>{let r=Gt(t);return e(r),r}}function Hn(e,t={}){return()=>e}function Ln(e,t){let[r,n]=Ue(e,t);return new Proxy(r,{get:(o,s)=>s==="set"?n:o[s],has:(o,s)=>s==="set"||Reflect.has(o,s)})}function hs(e,t,r){return y(()=>t(e()),void 0,r)}function ys(e,t,r){return y(()=>e().filter(t),void 0,r)}function vs(e,t,r,n){return y(()=>e().reduce(t,r),void 0,n)}function bs(e,t,r){return y(()=>e().find(t),void 0,r)}function ms(e,t,r){return y(()=>e().some(t),void 0,r)}function Ts(e,t,r){return y(()=>e().every(t),void 0,r)}function Ss(e,t,r){return y(()=>[...e()].sort(t),void 0,r)}function gs(e,t){return y(()=>[...new Set(e())],void 0,t)}function ws(e,t,r){return y(()=>{let n=e.map(o=>o());return t(n)},void 0,r)}function xs(...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())}):_(()=>{t.next(r())}));return()=>{n.forEach(o=>{typeof o=="function"?o():o&&typeof o.unsubscribe=="function"&&o.unsubscribe()})}})}function Rs(e,t,r){return y(()=>e()||t(),void 0,r)}function Os(e,t,r,n){return y(()=>r(e(),t()),void 0,n)}function ks(e,t,r){return y(()=>t(e()),void 0,{equals:r,internal:!0})}function As(e,t,r){return y(()=>{let n=e(),o={};for(let s of t)o[s]=n[s];return o},void 0,r)}function _s(e,t,r){return y(()=>{let o={...e()};for(let s of t)delete o[s];return o},void 0,r)}function Cs(e,t,r,n){return y(()=>e()?t():r(),void 0,n)}function Es(e,t,r){return y(()=>e()?t():void 0,void 0,r)}function Ps(e,t,r){let[n,o]=p(e()),s;return y(()=>{let i=e();clearTimeout(s),s=setTimeout(()=>o(()=>i),t)}),n}function Ds(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 Is(e){let t=e;for(;typeof t=="function";)t=t();return t}var js=0,Fs=Symbol.for("signal"),Us=Symbol.for("resource");function Ms(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_${js++}`,staleWhileRevalidate:a=!0}=s,l=c,b=s.cache??Pe(),d=b.inflight,v=s.transport===!1?void 0:me(),m=v!==void 0?be(v):void 0,C=s.deps??[],w=()=>C.map(h=>h()),U=(h,A=S(w))=>`${l}:${JSON.stringify(h)}`+(C.length?`:${JSON.stringify(A)}`:""),ie=h=>i===1/0||Date.now()-h.timestamp<=i,[M,E]=p(void 0,{equals:!1}),[N,k]=p("unresolved",{equals:!1}),[g,P]=p(void 0,{equals:!1}),[ce,q]=p(void 0,{equals:!1}),[ft,X]=p(!1),[B,J]=p(0,{equals:!1}),Me=Symbol("unset"),Oe=Me,lt=!1,dt=!1;function Wt(h,A,D,V){let I=d.get(A);if(I){I.then(x=>{V()||zt(x,D)},x=>{!V()&&!D&&Yt(x)}),D||(ne(I),q(I));return}let ke=Promise.resolve(o(h)).then(x=>(b.set(A,{value:x,timestamp:Date.now()}),d.delete(A),x),x=>{throw d.delete(A),x});d.set(A,ke),D||(ne(ke),q(ke)),ke.then(x=>{V()||zt(x,D)},x=>{!V()&&!D&&Yt(x)})}function zt(h,A){v!==void 0&&oe(v,h),R(()=>{E(()=>h),k("ready"),X(!1),q(void 0),P(void 0)})}function Yt(h){R(()=>{P(h),k("errored"),q(void 0)})}_(()=>{let h=n(),A=w();if(B(),h===!1||h===null||h===void 0){Oe=Me,R(()=>{k("unresolved"),q(void 0),P(void 0)});return}let D=lt,V=dt;lt=!1,dt=!1;let I=U(h,A);m&&Oe===Me&&!b.get(I)&&b.set(I,{value:m.value,timestamp:Date.now()}),V&&b.delete(I);let ke=Oe===Me||h!==Oe;Oe=h;let x=!1;T(()=>{x=!0});let Q=b.get(I);if(Q&&ie(Q)&&!D&&!V){v!==void 0&&oe(v,Q.value),(S(N)!=="ready"||S(M)!==Q.value)&&R(()=>{E(()=>Q.value),k("ready"),X(!1),P(void 0)});return}if(Q&&a&&!V){R(()=>{E(()=>Q.value),k("ready"),X(!0),P(void 0),q(void 0)}),Wt(h,I,!0,()=>x);return}let Xt=S(N),Gn=Xt==="ready"||Xt==="refreshing";R(()=>{k(Gn?"refreshing":"pending"),P(void 0),X(!1)}),Wt(h,I,!1,()=>x)});let Ne=(()=>{let h=g();if(h)throw h;if(N()==="pending"){let D=ce();if(D)throw D}return M()});return Object.defineProperty(Ne,Us,{value:!0,enumerable:!0}),Object.defineProperty(Ne,Fs,{value:!0,enumerable:!0}),Object.defineProperties(Ne,{state:{get:N},loading:{get:()=>{let h=N();return h==="pending"||h==="refreshing"}},error:{get:g},latest:{get:M},stale:{get:ft}}),Object.assign(Ne,{mutate:E,refetch:()=>{lt=!0,J(h=>h+1)},invalidate:()=>{let h=S(n);h!=null&&h!==!1&&b.delete(U(h)),dt=!0,J(A=>A+1)}})}function Ns(e,t=Pe()){if(e===void 0)return t.clear();let r=`${e}:`;for(let n of[...t.keys()])n.startsWith(r)&&t.delete(n)}return Qn(qs);})();
|