@fluixi/reactive 1.0.0-alpha.76 → 1.0.0-alpha.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +153 -220
  2. package/dist/cdn/reactive.cjs +1 -1
  3. package/dist/cdn/reactive.global.js +1 -1
  4. package/dist/cdn/reactive.mjs +1 -1
  5. package/dist/index.cjs +1 -1
  6. package/dist/index.mjs +1 -1
  7. package/dist/lib/index.cjs +1 -1
  8. package/dist/lib/index.d.ts +2 -0
  9. package/dist/lib/index.d.ts.map +1 -1
  10. package/dist/lib/index.js +6 -0
  11. package/dist/lib/index.mjs +1 -1
  12. package/dist/lib/observable/index.cjs +1 -1
  13. package/dist/lib/observable/index.mjs +1 -1
  14. package/dist/lib/observable/observable.cjs +1 -1
  15. package/dist/lib/observable/observable.mjs +1 -1
  16. package/dist/lib/observable/subscription.cjs +1 -1
  17. package/dist/lib/observable/subscription.d.ts.map +1 -1
  18. package/dist/lib/observable/subscription.js +1 -2
  19. package/dist/lib/observable/subscription.mjs +1 -1
  20. package/dist/lib/predicates.cjs +1 -0
  21. package/dist/lib/predicates.d.ts +37 -0
  22. package/dist/lib/predicates.d.ts.map +1 -0
  23. package/dist/lib/predicates.js +62 -0
  24. package/dist/lib/predicates.mjs +1 -0
  25. package/dist/lib/signal/cached-resource.cjs +1 -1
  26. package/dist/lib/signal/cached-resource.mjs +1 -1
  27. package/dist/lib/signal/graph/signal-next.d.ts +6 -6
  28. package/dist/lib/signal/index-legacy.cjs +1 -1
  29. package/dist/lib/signal/index-legacy.mjs +1 -1
  30. package/dist/lib/signal/signal.cjs +1 -1
  31. package/dist/lib/signal/signal.d.ts.map +1 -1
  32. package/dist/lib/signal/signal.js +16 -1
  33. package/dist/lib/signal/signal.mjs +1 -1
  34. package/dist/lib/signal/utilities.cjs +1 -1
  35. package/dist/lib/signal/utilities.mjs +1 -1
  36. package/dist/lib/store/setter.types.d.ts +1 -1
  37. package/dist/lib/store/setter.types.d.ts.map +1 -1
  38. package/dist/lib/subject.cjs +1 -1
  39. package/dist/lib/subject.mjs +1 -1
  40. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  41. package/dist/version.generated.cjs +1 -1
  42. package/dist/version.generated.d.ts +1 -1
  43. package/dist/version.generated.js +1 -1
  44. package/dist/version.generated.mjs +1 -1
  45. package/package.json +16 -18
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # @fluixi/reactive
6
6
 
7
- **Fine-grained reactive signals, memos, effects, stores and an RxJS-style observable layer.**
7
+ **Fine-grained signals, memos, effects and stores on a TC39 Signals core — standalone, no framework required.**
8
8
 
9
9
  [![License: MIT](https://img.shields.io/badge/License-MIT-22c55e.svg)](./LICENSE)
10
10
  ![TypeScript](https://img.shields.io/badge/TypeScript-strict-3178c6?logo=typescript&logoColor=white)
@@ -13,32 +13,26 @@
13
13
 
14
14
  ---
15
15
 
16
- A powerful, fine-grained reactive system with SolidJS-inspired features for building high-performance applications.
16
+ A fine-grained reactive system built on the **TC39 Signals** graph: glitch-free, lazy,
17
+ push-pull. It has no DOM dependency and no framework dependency, so it works in the
18
+ browser, on the server, or on its own.
17
19
 
18
20
  ## Features
19
21
 
20
- ### 🎯 Core Reactivity
21
- - **Signals** - Fine-grained reactive primitives
22
- - **Effects** - Automatic dependency tracking
23
- - **Memos** - Cached computed values
24
- - **Batch Updates** - SolidJS-style batching with `runUpdates()`
25
-
26
- ### Advanced Features
27
- - **Priority-Based Scheduling** - Optimal update ordering (RENDER COMPUTE EFFECT → TRANSITION)
28
- - **Transitions** - Non-blocking updates for better UX
29
- - **Suspense Boundaries** - Declarative async data loading
30
- - **Error Boundaries** - Graceful error handling
31
- - **Context API** - State sharing without prop drilling
32
- - **Render Effects** - Synchronous DOM updates
33
- - **Reactions** - Manual dependency tracking
34
- - **Owner Management** - Advanced lifecycle control
35
-
36
- ### 🔍 Developer Experience
37
- - **Enhanced Debugging** - Detailed warnings with dependency chains and performance metrics
38
- - **Memory Leak Detection** - Find potential issues early
39
- - **Node Statistics** - Monitor reactive graph performance
40
- - **TypeScript** - Full type safety and inference
41
- - **RxJS Integration** - Seamless Observable interop
22
+ ### Core
23
+ - **Signals, memos, effects** fine-grained state, derived values, automatic tracking
24
+ - **Stores** nested reactive objects where reading a property *is* the read
25
+ - **Resources** async values that integrate with suspense
26
+ - **Batching** `batch()` collects writes so dependents run once
27
+
28
+ ### Beyond the basics
29
+ - **Transitions** `startTransition` defers non-critical effects so the view stays interactive
30
+ - **Suspense and error boundaries** as plain values, so any view layer can wrap them
31
+ - **Context** provide a value for the duration of a call, without prop drilling
32
+ - **Owners** explicit ownership and disposal, so a graph tears down completely
33
+ - **Debounced primitives** signal, resource and function variants
34
+ - **Observable interop** `Observable`/`Subject` for RxJS-shaped code
35
+ - **TypeScript** full type safety and inference
42
36
 
43
37
  ## Installation
44
38
 
@@ -51,136 +45,129 @@ npm install @fluixi/reactive
51
45
  ### Basic Usage
52
46
 
53
47
  ```typescript
54
- import { createSignal, createEffect, createMemo, batch } from '@fluixi/reactive';
48
+ import { signal, memo, effect, batch } from '@fluixi/reactive';
55
49
 
56
- // Create reactive state
57
- const [count, setCount] = createSignal(0);
50
+ // Reactive state — call it to read, .set() to write
51
+ const count = signal(0);
58
52
 
59
53
  // Derived state (cached)
60
- const doubled = createMemo(() => count() * 2);
54
+ const doubled = memo(() => count() * 2);
61
55
 
62
56
  // Side effects (auto-tracking)
63
- createEffect(() => {
57
+ effect(() => {
64
58
  console.log(`Count: ${count()}, Doubled: ${doubled()}`);
65
59
  });
66
60
 
67
- // Update state
68
- setCount(1); // Effect runs: "Count: 1, Doubled: 2"
61
+ count.set(1); // Effect runs: "Count: 1, Doubled: 2"
69
62
 
70
63
  // Batch multiple updates
71
64
  batch(() => {
72
- setCount(2);
73
- setCount(3);
65
+ count.set(2);
66
+ count.set(3);
74
67
  }); // Effect runs once: "Count: 3, Doubled: 6"
75
68
  ```
76
69
 
77
- ### Advanced Usage
70
+ ### The tuple form
71
+
72
+ `createSignal` returns the same signal as a `[read, write]` pair, and `createMemo` /
73
+ `createEffect` are `memo` / `effect` under their original names:
74
+
75
+ ```typescript
76
+ import { createSignal, createMemo, createEffect } from '@fluixi/reactive';
77
+
78
+ const [count, setCount] = createSignal(0);
79
+ const doubled = createMemo(() => count() * 2);
80
+ createEffect(() => console.log(count(), doubled()));
81
+ setCount(1);
82
+ ```
83
+
84
+ `signal` **is** the accessor `createSignal` returns with the setter attached, so a read is
85
+ the same call either way. They track each other and mix freely in one module — pick
86
+ whichever reads better, and keep the tuple when you want the halves apart.
87
+
88
+ ### Stores and resources
89
+
90
+ ```typescript
91
+ import { store } from '@fluixi/reactive/store';
92
+ import { resource } from '@fluixi/reactive/signal';
93
+
94
+ const cart = store({ items: [], total: 0 });
95
+ cart.total; // reading a property IS the reactive read
96
+ cart.set('total', 42); // only readers of `total` re-run
97
+
98
+ const user = resource(() => fetch('/api/me').then((r) => r.json()));
99
+ user(); // the value — suspends under a Suspense boundary
100
+ user.loading; // boolean
101
+ user.refetch();
102
+ ```
103
+
104
+ ### Transitions, context and boundaries
78
105
 
79
106
  ```typescript
80
107
  import {
81
- startTransition,
82
- useTransition,
83
- createSuspense,
84
- trackPromise,
85
- catchError,
86
- createContext,
87
- useContext
108
+ startTransition, useTransition,
109
+ createContext, useContext, provide,
110
+ createErrorBoundary, provideErrorBoundary,
88
111
  } from '@fluixi/reactive';
89
112
 
90
- // Non-blocking updates
113
+ // Non-blocking updates — `isPending` is a signal you can read while it runs
91
114
  const [isPending, start] = useTransition();
92
- start(() => {
93
- setLargeDataSet(expensiveComputation());
94
- });
115
+ start(() => setLargeDataSet(expensiveComputation()));
95
116
 
96
- // Async data with suspense
97
- const UserProfile = createSuspense(
98
- () => {
99
- const data = trackPromise(fetchUser(userId()));
100
- return <Profile data={data} />;
101
- },
102
- <ProfileSkeleton />
103
- );
104
-
105
- // Error handling
106
- const safeData = catchError(
107
- () => parseData(input()),
108
- (error) => {
109
- console.error(error);
110
- return fallbackValue;
111
- }
112
- );
113
-
114
- // Context for state sharing
117
+ // Context: create it, provide a value for the duration of a call, consume inside
115
118
  const ThemeContext = createContext({ mode: 'light' });
116
- ThemeContext.Provider({
117
- value: { mode: 'dark' },
118
- children: () => <App />
119
+ provide(ThemeContext, { mode: 'dark' }, () => {
120
+ useContext(ThemeContext); // { mode: 'dark' }
119
121
  });
120
122
 
121
- // Consume context
122
- const theme = useContext(ThemeContext);
123
+ // Boundaries are values here, not components. A view layer wraps these into
124
+ // <ErrorBoundary> / <Suspense>; on their own they are plain functions.
125
+ const boundary = createErrorBoundary();
126
+ provideErrorBoundary(boundary, () => risky());
127
+ boundary.error(); // the thrown value, or undefined
128
+ boundary.reset();
123
129
  ```
124
130
 
125
- ## Priority-Based Scheduling
126
-
127
- Updates are processed in optimal order:
131
+ ### Debouncing
128
132
 
129
133
  ```typescript
130
- enum UpdatePriority {
131
- IMMEDIATE = 0, // Immediate synchronous updates
132
- RENDER = 1, // DOM updates (highest priority)
133
- COMPUTE = 2, // Memos and computed values
134
- EFFECT = 3, // Side effects
135
- TRANSITION = 4, // Low-priority updates (lowest)
136
- }
134
+ import { createDebounce, createDebouncedSignal, createDebouncedResource } from '@fluixi/reactive';
135
+
136
+ const [term, setTerm, controls] = createDebouncedSignal('', 300);
137
+ term(); // settles 300ms after the last write
138
+ controls.immediate(); // the value as written — bind the input to this one
139
+ controls.pending(); // a write is waiting (not the same as a request in flight)
140
+ controls.flush(); // settle now
141
+
142
+ // Search-as-you-type as one primitive: the query debounces, the fetch follows it,
143
+ // and an empty query doesn't fetch at all.
144
+ const [results, search] = createDebouncedResource('', (q) => fetchResults(q), { delay: 300 });
145
+ search.setQuery('fluix');
146
+ results.loading;
147
+
148
+ // Or debounce any function
149
+ const save = createDebounce((draft) => persist(draft), 500);
137
150
  ```
138
151
 
139
- ## Batch & Update Queue
152
+ ## Batching
140
153
 
141
- SolidJS-inspired batching with `runUpdates()`:
154
+ A write marks its dependents dirty and schedules them; memos stay lazy and recompute on
155
+ read, so the graph is glitch-free — nothing observes a half-applied update.
142
156
 
143
157
  ```typescript
144
158
  batch(() => {
145
- setA(1);
146
- setB(2);
147
- setC(3);
148
- }); // All effects run once in priority order
149
-
150
- // Internal mechanism:
151
- // 1. Updates queued in updateQueue
152
- // 2. runUpdates() processes queue
153
- // 3. Flushes in priority order: renders → computations → effects
154
- ```
155
-
156
- ## Enhanced Debugging
159
+ a.set(1);
160
+ b.set(2);
161
+ c.set(3);
162
+ }); // dependents run once, after the batch closes
157
163
 
158
- Automatic warnings for performance issues:
159
-
160
- ```
161
- ⚠️ [Reactivity Warning] Coarse Dependency Detected
162
-
163
- Node Information:
164
- ┌─────────────┬──────────────────┐
165
- │ Node Name │ userData │
166
- │ Observers │ 18 │
167
- └─────────────┴──────────────────┘
168
-
169
- Reason:
170
- Reading large object (23 keys) - consider using
171
- derived signals for specific properties
172
-
173
- Performance Metrics:
174
- ┌───────────────────┬──────────┐
175
- │ Updates │ 45 │
176
- │ Avg Frequency │ 120ms │
177
- └───────────────────┴──────────┘
178
-
179
- Suggestions:
180
- • Use derived signals for specific properties
181
- • Consider breaking into smaller signals
164
+ await flush(); // await the pending queue — mostly useful in tests
182
165
  ```
183
166
 
167
+ `startTransition` is the other half: it runs `fn` synchronously and captures the non-pure
168
+ effects it would fire into a deferred queue, so an expensive update doesn't block the
169
+ current view. Pure computations still settle immediately.
170
+
184
171
  ## API Reference
185
172
 
186
173
  ### Core API
@@ -197,24 +184,22 @@ Suggestions:
197
184
  - `startTransition(fn)` - Mark updates as low priority
198
185
  - `useTransition()` - Track transition state
199
186
 
200
- ### Suspense
201
-
202
- - `createSuspense(fn, fallback)` - Create async boundary
203
- - `trackPromise(promise)` - Register promise with suspense
204
-
205
- ### Error Handling
187
+ ### Boundaries
206
188
 
207
- - `catchError(fn, handler)` - Handle errors gracefully
189
+ - `createSuspenseBoundary()` / `provideSuspense(boundary, fn)` - Async boundary as a value
190
+ - `createErrorBoundary()` / `provideErrorBoundary(boundary, fn)` - Error boundary as a value
191
+ - `trackResourcePromise(promise)` - Register a promise with the enclosing suspense
208
192
 
209
193
  ### Context
210
194
 
211
195
  - `createContext(defaultValue)` - Create context
196
+ - `provide(context, value, fn)` - Supply a value for the duration of a call
212
197
  - `useContext(context)` - Consume context
213
198
 
214
- ### Enhanced Effects
199
+ ### Other effects
215
200
 
216
- - `createRenderEffect(fn)` - Synchronous DOM updates
217
- - `createReaction(onInvalidate)` - Manual dependency tracking
201
+ - `createRenderEffect(fn)` - Runs before paint, for DOM writes
202
+ - `createComputed(fn)` - Runs eagerly, unlike a memo
218
203
  - `on(deps, fn, options?)` - Explicit dependencies
219
204
 
220
205
  ### Owner Management
@@ -222,97 +207,51 @@ Suggestions:
222
207
  - `getOwner()` - Get current reactive owner
223
208
  - `runWithOwner(owner, fn)` - Run with specific owner
224
209
 
225
- ### Debugging
210
+ ### Lists
226
211
 
227
- - `warnCoarseRead(node, reason)` - Enhanced warnings
228
- - `getNodeStats()` - Get reactive graph statistics
229
- - `findPotentialLeaks()` - Find memory leaks
230
- - `enableDevMode()` - Enable dev mode features
212
+ - `mapArray(list, fn)` - Map keyed by identity; a row survives a reorder
213
+ - `indexArray(list, fn)` - Map keyed by index
214
+ - `keyArray(list, key, fn)` - Map keyed by an explicit key
231
215
 
232
216
  ### Utilities
233
217
 
234
- - `createEnhancedSignal(initialValue)` - Signal with extras
235
- - `createAsyncSignal(asyncFn)` - Async signal
236
- - `createLazySignal(fn)` - Lazy-evaluated signal
237
- - `createSignalWithHistory(initialValue)` - Signal with undo/redo
238
- - `createThrottledSignal(signal, delay)` - Throttled updates
239
- - `createDebouncedSignal(signal, delay)` - Debounced updates
240
- - `createTrigger()` - Manual trigger
241
- - `createSelector(source, fn)` - Keyed selector
242
- - `createResource(fetcher, source?)` - Async resource
243
- - `createStore(initialValue)` - Nested reactive object
218
+ - `createSelector(source, fn)` - Keyed selector; only the row that changed re-runs
219
+ - `createResource(fetcher, source?)` / `resource(...)` - Async resource
220
+ - `createStore(initial)` / `store(initial)` - Nested reactive object
221
+ - `createDeferred(source, options?)` - A value that trails behind under load
222
+ - `createDebounce(fn, ms)` / `createDebouncedSignal(initial, ms)` / `createDebouncedResource(...)`
223
+ - `flush()` - Await the pending effect queue
224
+ - `unwrap(store)` / `untrackStore(fn)` - Escape hatches out of a store proxy
225
+ - `onCleanup(fn)` / `disposeScope(owner)` - Teardown
244
226
 
245
227
  ## Documentation
246
228
 
247
- Complete documentation available at:
248
- - [Overview](../../my-docusaurus-app/docs/signal/overview.md) - Introduction and concepts
249
- - [Core API](../../my-docusaurus-app/docs/signal/signal.md) - Complete API reference
250
- - [SolidJS Features](../../my-docusaurus-app/docs/signal/solidjs-features.md) - Advanced features guide
251
- - [Advanced Patterns](../../my-docusaurus-app/docs/signal/advanced-patterns.md) - Complex patterns
252
- - [Quick Reference](../../my-docusaurus-app/docs/signal/quick-reference.md) - Quick lookup
253
- - [What's New](../../my-docusaurus-app/docs/signal/whats-new.md) - Latest enhancements
254
-
255
- ## What's New (v3.2.0+)
256
-
257
- ### Major Enhancements
258
-
259
- **Priority-Based Scheduling** - Updates execute in optimal order
260
- **SolidJS-Style Batching** - New `runUpdates()` mechanism
261
- ✨ **Transitions API** - Non-blocking updates with `startTransition()`
262
- **Suspense Boundaries** - Declarative async with `createSuspense()`
263
- ✨ **Error Boundaries** - Graceful error handling with `catchError()`
264
- **Context API** - State sharing with `createContext()`
265
- **Enhanced Debugging** - Detailed warnings and performance metrics
266
- **Transition State Tracking** - Automatic priority in computations
267
-
268
- ### Breaking Changes
269
-
270
- **None!** All enhancements are 100% backward compatible.
271
-
272
- ## Performance Tips
273
-
274
- 1. **Use transitions for expensive updates**
275
- ```typescript
276
- startTransition(() => setLargeList(compute()));
277
- ```
278
-
279
- 2. **Batch related updates**
280
- ```typescript
281
- batch(() => { setA(1); setB(2); });
282
- ```
283
-
284
- 3. **Use memos for expensive computations**
285
- ```typescript
286
- const result = createMemo(() => expensive(signal()));
287
- ```
288
-
289
- 4. **Leverage suspense for async**
290
- ```typescript
291
- createSuspense(() => trackPromise(fetch()), <Loading />);
292
- ```
293
-
294
- 5. **Monitor with debugging tools**
295
- ```typescript
296
- const stats = getNodeStats();
297
- const leaks = findPotentialLeaks();
298
- ```
299
-
300
- ## Best Practices
301
-
302
- ### ✅ Do
303
-
304
- - Use `batch()` for multiple related updates
305
- - Use `startTransition()` for non-urgent updates
306
- - Add error boundaries with `catchError()`
307
- - Use context instead of prop drilling
308
- - Monitor performance with debugging tools
309
-
310
- ### ❌ Don't
311
-
312
- - Update signals without batching when multiple updates needed
313
- - Block UI with expensive synchronous computations
314
- - Ignore errors in reactive code
315
- - Prop drill when context would work better
229
+ - [Signals](https://docs.fluixi.com/v1/en/signals) state, reading and writing
230
+ - [Derived values](https://docs.fluixi.com/v1/en/derived-values) memos and selectors
231
+ - [Effects](https://docs.fluixi.com/v1/en/effects) side effects and cleanup
232
+ - [Stores](https://docs.fluixi.com/v1/en/stores) nested reactive objects
233
+ - [Async](https://docs.fluixi.com/v1/en/async) resources, suspense, transitions
234
+ - [TC39 Signals](https://docs.fluixi.com/v1/en/tc39-signals) the model underneath
235
+
236
+ ## Compiler intrinsics
237
+
238
+ Inside an app compiled by `@fluixi/compiler`, these primitives have `$`-prefixed twins that
239
+ need no import — `$signal`, `$memo`, `$effect`, `$store`, `$resource`. They compile to the
240
+ calls above, so there is one reactive graph and no difference in behaviour. This package
241
+ stays importable exactly as documented here, which is what a library that never runs the
242
+ compiler needs.
243
+
244
+ ## Performance tips
245
+
246
+ 1. **Batch related updates** `batch(() => { a.set(1); b.set(2); })` runs dependents once.
247
+ 2. **Transitions for expensive updates** `startTransition(() => list.set(compute()))`
248
+ keeps the current view interactive while the next one is prepared.
249
+ 3. **Memo the expensive part** — a memo costs a node; it pays for itself when the
250
+ computation is heavier than the bookkeeping.
251
+ 4. **Read narrowly** — reading a whole object subscribes you to every write to it. Reach
252
+ for the property you need, or derive it.
253
+ 5. **Key your lists** — `mapArray` keeps a row's nodes across a reorder; `indexArray`
254
+ rebuilds them.
316
255
 
317
256
  ## Building
318
257
 
@@ -332,12 +271,6 @@ MIT
332
271
 
333
272
  ## Credits
334
273
 
335
- Inspired by:
336
- - [SolidJS](https://www.solidjs.com/) - Reactivity primitives and scheduling
337
- - [React](https://react.dev/) - Transitions and Suspense concepts
338
- - [Vue 3](https://vuejs.org/) - Reactivity system design
339
-
340
- ---
341
-
342
- **Version:** 3.2.0+
343
- **Status:** ✅ Production Ready
274
+ The graph implements the **TC39 Signals** model. The ergonomics owe a lot to prior art —
275
+ SolidJS for fine-grained primitives and scheduling, React for transitions and suspense as
276
+ concepts, Vue 3 for reactivity design. None of that was invented here.
@@ -1 +1 @@
1
- "use strict";var we=Object.defineProperty;var ir=Object.getOwnPropertyDescriptor;var ar=Object.getOwnPropertyNames;var ur=Object.prototype.hasOwnProperty;var cr=(e,t)=>{for(var r in t)we(e,r,{get:t[r],enumerable:!0})},lr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ar(t))!ur.call(e,o)&&o!==r&&we(e,o,{get:()=>t[o],enumerable:!(n=ir(t,o))||n.enumerable});return e};var pr=e=>lr(we({},"__esModule",{value:!0}),e);var Ur={};cr(Ur,{$NAME:()=>Ht,$NODE:()=>D,$PROXY:()=>Er,$RAW:()=>ee,$SELF:()=>me,$SIGNAL:()=>_r,$STORE:()=>$t,$TRACK:()=>ve,Observable:()=>j,SafeSubscriber:()=>se,Signal:()=>Ct,Store:()=>_,StoreAPI:()=>tr,Subject:()=>ge,Subscriber:()=>U,Subscription:()=>I,SuspenseContext:()=>he,VERSION:()=>Ke,__DEV__:()=>ce,batch:()=>g,createChildOwner:()=>Je,createComputed:()=>ut,createComputedStore:()=>Wt,createContext:()=>N,createDebounce:()=>gt,createDebouncedResource:()=>At,createDebouncedSignal:()=>je,createDeferred:()=>Ot,createEffect:()=>O,createErrorBoundary:()=>Pt,createMemo:()=>S,createMutableStore:()=>He,createRenderEffect:()=>ct,createResource:()=>$,createRoot:()=>P,createSelector:()=>wt,createSignal:()=>f,createStore:()=>te,createStoreEffect:()=>zt,createStoreMemo:()=>Yt,createSuspenseBoundary:()=>_t,disposeScope:()=>Ze,effect:()=>Dr,flush:()=>pt,getNode:()=>Jt,getOwner:()=>Q,getServerData:()=>fe,getStoreNode:()=>Zt,indexArray:()=>xr,isComponent:()=>Tt,isMemo:()=>dt,isOwnerDisposed:()=>et,isProvider:()=>bt,isResource:()=>yt,isSignal:()=>le,isStore:()=>Qt,isStoreProxy:()=>xe,isSuspense:()=>ht,keyArray:()=>Sr,makeArrayFlat:()=>Pe,mapArray:()=>vr,memo:()=>Pr,modifiable:()=>er,nextResourceId:()=>de,on:()=>ft,onCleanup:()=>v,operate:()=>fr,produceUtil:()=>rr,provide:()=>M,provideErrorBoundary:()=>Dt,provideSuspense:()=>Et,readChildren:()=>Rt,reconcileUtil:()=>nr,reportResourceData:()=>ye,resource:()=>Ft,runWithOwner:()=>H,setOwner:()=>_e,setResourceDataSink:()=>xt,setResourceIdSource:()=>St,setResourceTracker:()=>mt,setServerDataGetter:()=>vt,signal:()=>kr,startTransition:()=>ke,store:()=>or,trackResourcePromise:()=>pe,untrack:()=>x,untrackStore:()=>$e,unwrap:()=>V,useContext:()=>tt,useTransition:()=>lt,wrap:()=>Xt});module.exports=pr(Ur);var Ke="1.0.0-alpha.76";var We=require("@fluixi/utils/object"),Oe=require("@fluixi/utils/functions"),I=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((0,Oe.isFunction)(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if((0,We.isObject)(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((0,Oe.isFunction)(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 U=class extends I{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())}},se=class extends U{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 fr(e){return new U(e.next,e.error,e.complete)}var j=class extends I{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 U?o=t:o=new se(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 ge=class extends j{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 j(n=>this.subscribe(n))}};var dr="__fluixi_signal_next_state__",yr=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[dr]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:yr,onSuspend:null,onError:null};var ze=0,Ye=1,W=2,ie=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let t=a.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},B=class extends ie{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++,this.observers)for(let r of[...this.observers])r.markDirty(W);Ae(this)}}peek(){return this._value}},R=class extends ie{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=W;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){if(a.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===Ye&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===W)break}(this.state===W||!this._initialized)&&this.recompute(),this.state=ze}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=a.consumer,n=a.untracked;a.consumer=this,a.untracked=!1;let o,s=!1,i;try{o=this._fn()}catch(u){s=!0,i=u,o=this._value}finally{a.consumer=r,a.untracked=n}let c=!this._initialized||this._threw!==s||(s?i!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=s,this._error=i,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(W);Ae(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===ze;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty(Ye);Ae(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Ae(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var q=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 z(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function Xe(){return a.consumer}function Qe(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function Je(e){let t=X(e);return e&&(e.owned??=[]).push(t),t}function Ze(e,t=!0){Y(e,t)}function et(e){return!!e&&e.disposed===!0}function X(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function N(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=X(o);(s.contexts=new Map).set(t,n.value),o&&(o.owned??=[]).push(s),a.owner=s;try{return n.children}finally{a.owner=o}}}}function tt(e){let t=a.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function ae(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 M(e,t,r){let n=X(a.owner);(n.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return r()}finally{a.owner=o}}function rt(e){a.onSuspend=e}function nt(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function ot(e){a.onError=e}function Q(){return a.owner}function _e(e){let t=a.owner;return a.owner=e,t}function H(e,t){let r=a.owner;a.owner=e;try{return t()}finally{a.owner=r}}function v(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function Y(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)Y(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 P(e){let t=X(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>Y(t))}finally{a.owner=r}}function st(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function Tr(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(J)))}function J(){if(a.scheduled=!1,a.flushing)return;a.flushing=!0;let e=0;try{for(;a.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function it(){a.batchDepth===0&&J()}function Ee(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&J()}}var Re=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=X(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new R(()=>{Y(this.owner,!1),H(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new q(()=>Tr(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&a.onSuspend){a.onSuspend(t,this.owner);return}if(a.onError&&a.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),Y(this.owner))}};function ue(e){let t=new Re(e);return()=>t.dispose()}function hr(e){return!!e&&typeof e.then=="function"}st(()=>{});var at=Symbol.for("signal"),br=Symbol.for("memo"),mr=Symbol.for("signal-node");function f(e,t){let r=new B(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),it(),i});return Object.defineProperty(n,at,{value:!0,enumerable:!0}),Object.defineProperty(n,mr,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function S(e,t,r){let n=t,o=Q(),s=new R(()=>H(o,()=>{try{return n=e(n)}catch(c){if(hr(c))return nt(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,at,{value:!0,enumerable:!0}),Object.defineProperty(i,br,{value:!0,enumerable:!0}),i}function O(e,t){let r=t;return ue(()=>{r=e(r)})}function ut(e,t){let r=t;ue(()=>{r=e(r)})}function ct(e,t){let r=t;return ue(()=>{r=e(r)})}function g(e){return Ee(e)}function x(e){return z(e)}function ke(e){return Ee(e),Promise.resolve()}function lt(){return[()=>!1,ke]}function pt(){return J(),Promise.resolve()}function ft(e,t,r){let n=Array.isArray(e),o,s=r?.defer??!1;return i=>{let c=n?e.map(p=>p()):e();if(s){s=!1,o=c;return}let u=z(()=>t(c,o,i));return o=c,u}}function vr(e,t,r){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),S(()=>{let o=e()||[];return x(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=new Map;for(let u of n)s.has(u.item)||s.set(u.item,u);let i=[],c=new Set;for(let u=0;u<o.length;u++){let p=o[u],T=s.get(p);if(T&&!c.has(T))T.setIndex(u),i.push(T),c.add(T);else{let l,d,h;P(b=>{h=b;let[C,G]=f(u);d=G,l=t(p,C)});let w={item:p,rendered:l,dispose:h,setIndex:d};i.push(w),c.add(w)}}for(let u of n)c.has(u)||u.dispose();return n=i,i.map(u=>u.rendered)})})}function Sr(e,t,r,n){let o=[],s=[];return v(()=>{for(let i of s)i.dispose();o=[],s=[]}),S(()=>{let i=e()||[];return x(()=>{if(i.length===0){for(let l of s)l.dispose();return o=[],s=[],n?.fallback?n.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],s[l]);let u=[],p=[],T=new Set;for(let l=0;l<i.length;l++){let d=t(i[l]),h=c.get(d);if(h&&!T.has(d))h.setIndex(l),u.push(h);else{let w,b,C;P(G=>{C=G;let[E,K]=f(l);b=K;let re=S(F=>{let A=(e()||[])[E()];return A??F},i[l]);w=r(re,E)}),u.push({rendered:w,dispose:C,setIndex:b})}p.push(d),T.add(d)}for(let[l,d]of c)T.has(l)||d.dispose();return o=p,s=u,u.map(l=>l.rendered)})})}function xr(e,t,r){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),S(()=>{let o=e()||[];return x(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=n.length,i=o.length;for(let u=s;u<i;u++){let p,T,l,d=o[u];P(h=>{l=h;let[w,b]=f(d);T=b,p=t(w,u)}),n.push({rendered:p,setItem:T,dispose:l})}for(let u=i;u<s;u++)n[u].dispose();i<s&&(n=n.slice(0,i));let c=Math.min(s,i);for(let u=0;u<c;u++)n[u].setItem(o[u]);return n.map(u=>u.rendered)})})}var ce=!1,wr=Symbol.for("signal"),Or=Symbol.for("memo"),gr=Symbol.for("resource");function le(e){return typeof e=="function"&&e[wr]===!0}function dt(e){return typeof e=="function"&&e[Or]===!0}function yt(e){return typeof e=="function"&&e[gr]===!0}function Tt(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function ht(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function bt(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Pe(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Pe(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var De=null;function mt(e){De=e}function pe(e){De&&De(e)}var Ce=null;function vt(e){Ce=e}function fe(e){return Ce?Ce(e):void 0}var Fe=null;function St(e){Fe=e}function de(){return Fe?Fe():void 0}var Ie=null;function xt(e){Ie=e}function ye(e,t){Ie&&Ie(e,t)}function wt(e,t=(r,n)=>r===n){let r=new Map;return O(()=>{let n=e();for(let[o,s]of r){let[i,c]=s,u=t(o,n);i()!==u&&c(u)}}),n=>{let o=r.get(n);if(!o){let[s,i]=f(!1);o=[s,i],r.set(n,o);let c=e();i(t(n,c))}return o[0]()}}function Ot(e,t){let[r,n]=f(e(),t);return O(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function gt(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,e(...o)},t)};return v(()=>{r!==void 0&&clearTimeout(r)}),n}function Ar(e){return!!e&&typeof e.then=="function"}var Ue=Symbol();function $(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:de(),i=s!==void 0?fe(s):void 0,c=i!==void 0,[u,p]=f(i!==void 0?i.value:r.initialValue,{equals:!1}),[T,l]=f(void 0,{equals:!1}),[d,h]=f(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[w,b]=f(void 0,{equals:!1}),[C,G]=f(void 0,{equals:!1}),E=Ue,K=!1;O(()=>{let m=n();if(C(),m===!1||m===null||m===void 0){E=Ue,g(()=>{h("unresolved"),b(void 0),l(void 0)});return}let A=K;if(K=!1,E!==Ue&&m===E&&!A)return;if(E=m,c){c=!1;return}let ne=!1;v(()=>ne=!0);let Ve=x(d),sr=x(u),Ge=Ve==="ready"||Ve==="refreshing";g(()=>{h(Ge?"refreshing":"pending"),l(void 0)});try{let k=o(m,{value:sr,refetching:Ge});Ar(k)?(b(k),pe(k),k.then(oe=>{ne||(s!==void 0&&ye(s,oe),g(()=>{p(()=>oe),h("ready"),b(void 0)}))},oe=>{ne||g(()=>{l(oe),h("errored"),b(void 0)})})):g(()=>{p(()=>k),h("ready"),b(void 0)})}catch(k){if(ne)return;g(()=>{l(k),h("errored"),b(void 0)})}});let re=()=>{let m=d();return m==="pending"||m==="refreshing"},F=(()=>{let m=T();if(m)throw m;if(re()){let A=w();if(A)throw A}return u()});return Object.defineProperties(F,{state:{get:d},loading:{get:re},error:{get:T},latest:{get:u}}),Object.defineProperty(F,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(F,Symbol.for("signal"),{value:!0,enumerable:!0}),[F,{mutate:p,refetch:()=>{K=!0,G(void 0)}}]}function je(e,t=300){let[r,n]=f(e),[o,s]=f(e),[i,c]=f(!1),u,p=()=>{u!==void 0&&(clearTimeout(u),u=void 0)},T=()=>{p();let d=x(r);return s(()=>d),c(!1),d},l=(d=>{let h=typeof d=="function"?d(x(r)):d;return n(()=>h),c(!0),p(),u=setTimeout(T,t),h});return v(p),[o,l,{immediate:r,pending:i,flush:T,cancel:()=>{p(),c(!1)}}]}function Rr(e){return e!=null&&e!==""}function At(e,t,r={}){let{delay:n=300,initialValue:o,shouldFetch:s=Rr}=r,[i,c,u]=je(e,n),p=()=>s(i())?i():!1,[T,{refetch:l}]=$(p,t,o===void 0?{}:{initialValue:o});return[T,{...u,query:i,setQuery:c,refetch:l}]}function Te(e){if(typeof e=="function"&&!e.length){let t=e();return le(t)?t:Te(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=Te(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Rt(e){let t=S(e);return S(()=>Te(t()))}var he=N();rt((e,t)=>{let r=ae(t,he);r&&(r.increment(),e.finally(()=>r.decrement()))});function _t(){let[e,t]=f(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function Et(e,t){return M(he,e,t)}var kt=N();ot((e,t)=>{let r=ae(t,kt);return r?(r.setError(e),!0):!1});function Pt(){let[e,t]=f(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function Dt(e,t){return M(kt,e,t)}var Ct={State:B,Computed:R,subtle:{Watcher:q,untrack:z,currentComputed:Xe,hasSinks:Qe}};var _r=Symbol.for("signal"),Er=Symbol.for("fluixi-proxy");function kr(e,t){let[r,n]=f(e,t);return Object.assign(r,{set:n})}function Pr(e,t,r){return S(e,t,r)}function Dr(e,t){return O(e,t)}function Ft(...e){let[t,r]=$(...e);return Object.assign(t,r)}var y=require("@fluixi/reactive/signal"),ee=Symbol("store-raw"),D=Symbol("store-node"),It=Symbol("store-has"),me=Symbol("store-self"),ve=Symbol("store-track"),Ht=Symbol("store-name"),$t=Symbol("store-store"),Ut=new WeakMap,jt=new WeakMap;function Lt(e){let[t,r]=(0,y.createSignal)(e),n=t;return n.$=r,n}function Se(e){let t=Ut.get(e);return t||Ut.set(e,t={keys:new Map}),t}function Bt(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=Lt(r)),n}function qt(e){let t=Se(e);(t.all||(t.all=Lt()))()}function Nt(e,t){e.$(typeof t=="function"?()=>t:t)}function Vt(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 be(e){if(!Vt(e))return e;let t=jt.get(e);if(t)return t;let r=new Proxy(e,Cr);return jt.set(e,r),r}var Cr={get(e,t,r){if(t===ee||t===D)return e;if(t===y.$PROXY)return r;if(t===It)return i=>i in e;if(t==="__proxy")return!0;if(t===ve||t===me)return qt(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=Bt(Se(e),t,n)();return Vt(s)?be(s):s},set(){return!0},deleteProperty(e,t){return t in e&&Z(e,t,void 0),!0},has(e,t){return t===ee||t===y.$PROXY||t===D||t===It||t===me||t===ve?!0:(Bt(Se(e),t,e[t])(),t in e)},ownKeys(e){return qt(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function Z(e,t,r){if(e[t]===r&&(r!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;r===void 0?delete e[t]:e[t]=r;let i=Se(e),c=i.keys.get(t);if(c&&Nt(c,r),o&&e.length!==s){let u=i.keys.get("length");u&&Nt(u,e.length)}i.all&&i.all.$(void 0)}function Mt(e,t){return typeof e=="function"?e(t):e}function qe(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)?qe(o,n):Z(e,r,n)}}function Me(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function Gt(e,t,r){let n=t.length-1;for(let s=0;s<n;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let p=0;p<e.length;p++)Gt(e[p],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},Z(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)Z(e,s,Mt(r,e[s]));return}Z(e,o,Mt(r,e[o]))}function Be(e,t,r){Gt(e,Me(t),r)}function Fr(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&qe(e,n);return}if(Array.isArray(r)&&t.length===1){for(let n of r)Array.isArray(n)&&Be(e,n[0],n[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){qe(e,r);return}if(Array.isArray(t[1])&&t.length>=3){Be(e,`${r}.${t[1].join(".")}`,t[2]);return}Be(e,String(r),t[1])}function Ne(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ne);let t={};for(let r of Object.keys(e))t[r]=Ne(e[r]);return t}function L(e,t){let r=e;for(let n of Me(t)){if(r==null)return;r=r[n]}return r}var _=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>(0,y.batch)(()=>Fr(this.root,n)))}get state(){return be(this.root)}get proxy(){return be(this.root)}get accessor(){return(()=>be(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return V(this.state);let r=this.state;for(let n of Me(t)){if(r==null)return;r=r[n]}return V(r)}select(t){return(0,y.createMemo)(()=>t(this.state))}subscribe(t){return(0,y.createEffect)(()=>t(this.state))}watch(t,r){let n;return(0,y.createEffect)(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return(0,y.createMemo)(()=>this.state[t])}produce(t){this.set((r=>{let n=Ne(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=L(this.root,t);this.set(t,n.concat(r))}pop(t){let r=L(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=L(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=L(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=L(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=L(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}toObservable(){let[t]=(0,y.createSignal)(this.state);return t.toObservable()}dispose(){}},Ir=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function Kt(e,t){for(let r of Ir)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function te(e,t={immutable:!0}){let r=new _(e,t);return Kt(r.set,r),[r.proxy,r.set]}function He(e,t={}){return new _(e,{...t,immutable:!1})}function Wt(e,t={}){let r=new _(e(),t);return(0,y.createEffect)(()=>r.set(e())),r}function zt(e,t,r){return(0,y.createEffect)(()=>r(t(e)))}function Yt(e,t,r){return(0,y.createMemo)(()=>t(e),void 0,r)}function Xt(e,t={}){let r=new _(e,t),n=(()=>r.proxy);return Kt(n,r),n}function V(e){if(e==null||typeof e!="object")return e;let t=e[ee];return t!==void 0?t:e}function $e(e){return(0,y.untrack)(()=>V(e))}function Qt(e){return xe(e)}function Jt(e){return xe(e)?e[D]:null}function Zt(e){return e&&typeof e=="object"&&D in e?e[D]:null}function xe(e){return!!e&&typeof e=="object"&&(y.$PROXY in e||e.__proxy===!0)}function er(e){return e}var tr=Object.freeze({createStore:te,createMutableStore:He,batch:y.batch,unwrap:V,untrackStore:$e});function Le(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Le);let t={};for(let r of Object.keys(e))t[r]=Le(e[r]);return t}function rr(e){return t=>{let r=Le(t);return e(r),r}}function nr(e,t={}){return()=>e}function or(e,t){let[r,n]=te(e,t);return new Proxy(r,{get:(o,s)=>s==="set"?n:o[s],has:(o,s)=>s==="set"||Reflect.has(o,s)})}
1
+ "use strict";var tt=Object.defineProperty;var Qn=Object.getOwnPropertyDescriptor;var Jn=Object.getOwnPropertyNames;var Zn=Object.prototype.hasOwnProperty;var er=(e,t)=>{for(var n in t)tt(e,n,{get:t[n],enumerable:!0})},tr=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Jn(t))!Zn.call(e,o)&&o!==n&&tt(e,o,{get:()=>t[o],enumerable:!(r=Qn(t,o))||r.enumerable});return e};var nr=e=>tr(tt({},"__esModule",{value:!0}),e);var To={};er(To,{$NAME:()=>Rn,$NODE:()=>Q,$PROXY:()=>vr,$RAW:()=>Fe,$SELF:()=>We,$SIGNAL:()=>br,$STORE:()=>An,$TRACK:()=>Ge,Observable:()=>N,SafeSubscriber:()=>qe,Signal:()=>mn,Store:()=>H,StoreAPI:()=>jn,Subject:()=>ot,Subscriber:()=>ie,Subscription:()=>se,SuspenseContext:()=>Ke,VERSION:()=>Ut,__DEV__:()=>Ce,batch:()=>$,clearAllCachedResources:()=>po,clearCachedResourceNamespace:()=>fo,combineSignal:()=>Ur,combineSignals:()=>Ir,createCachedResource:()=>lo,createChildOwner:()=>Bt,createComputed:()=>Xt,createComputedStore:()=>_n,createContext:()=>ce,createDebounce:()=>cn,createDebouncedResource:()=>ln,createDebouncedSignal:()=>St,createDeferred:()=>an,createEffect:()=>M,createErrorBoundary:()=>Tn,createMemo:()=>T,createMutableStore:()=>Rt,createRenderEffect:()=>Qt,createResource:()=>de,createRoot:()=>Y,createSelector:()=>un,createSignal:()=>h,createStore:()=>De,createStoreEffect:()=>Fn,createStoreMemo:()=>Dn,createSuspenseBoundary:()=>fn,debounceSignal:()=>Vr,disposeScope:()=>Lt,distinctSignal:()=>Dr,effect:()=>gr,everySignal:()=>_r,filterSignal:()=>Cr,findSignal:()=>Pr,flush:()=>Zt,getNode:()=>Mn,getOwner:()=>Re,getServerData:()=>Ee,getStoreNode:()=>qn,guardSignal:()=>$r,indexArray:()=>dr,isComponent:()=>rn,isMemo:()=>tn,isOwnerDisposed:()=>$t,isProvider:()=>sn,isResource:()=>nn,isSignal:()=>Le,isStore:()=>In,isStoreProxy:()=>Ye,isSuspense:()=>on,keyArray:()=>fr,makeArrayFlat:()=>lt,mapArray:()=>lr,mapSignal:()=>Ar,memo:()=>xr,mergeSignal:()=>Mr,modifiable:()=>Nn,nextResourceId:()=>Pe,omitSignal:()=>Br,on:()=>en,onCleanup:()=>F,operate:()=>rr,pickSignal:()=>jr,produceUtil:()=>Bn,provide:()=>le,provideErrorBoundary:()=>yn,provideSuspense:()=>dn,readChildren:()=>Ve,readSignal:()=>Hr,reconcileUtil:()=>Ln,reduceSignal:()=>Er,reportResourceData:()=>ke,resource:()=>hn,runWithOwner:()=>fe,selectSignal:()=>Nr,setOwner:()=>ut,setResourceDataSink:()=>bt,setResourceIdSource:()=>ht,setResourceTracker:()=>yt,setServerDataGetter:()=>mt,signal:()=>Sr,someSignal:()=>kr,sortSignal:()=>Fr,startTransition:()=>ct,store:()=>$n,throttleSignal:()=>Kr,trackResourcePromise:()=>X,untrack:()=>D,untrackStore:()=>At,unwrap:()=>Te,useContext:()=>Vt,useTransition:()=>Jt,whenSignal:()=>Lr,wrap:()=>Un,zipSignal:()=>qr});module.exports=nr(To);var Ut="1.0.0-alpha.78";function nt(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function It(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"}function rt(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}var se=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:n}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let r of t)r.remove(this);if(n){for(let r of n)if(nt(r)&&!(r instanceof e))try{r()}catch(o){console.error("Error in unsubscribe function:",o)}else if(It(r)&&typeof r.unsubscribe=="function")try{r.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:n,_subscriptions:r}=this;if(n){if(nt(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 r||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:n}=this;if(!n)return;let r=n.indexOf(t);r!==-1&&(n.splice(r,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:n}=this;n?Array.isArray(n)?n.push(t):this._parentOrParents=[n,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:n}=this;if(n===t)this._parentOrParents=null;else if(Array.isArray(n)){let r=n.indexOf(t);r!==-1&&(n.splice(r,1),n.length===1&&(this._parentOrParents=n[0]))}}};var ie=class extends se{constructor(n,r,o){super();this.isStopped=!1;let s;n?typeof n=="object"?s=n:s={next:n,error:r,complete:o}:s={},this.destination=s}next(n){if(!this.isStopped&&this.destination.next)try{this.destination.next(n)}catch(r){this.error(r)}}error(n){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(n)}catch(r){throw r}else throw n;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(n){this.error(n);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},qe=class extends ie{constructor(n,r,o,s){super(n,r,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(n){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(n)}catch(r){this.error(r)}}error(n){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(n)}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 rr(e){return new ie(e.next,e.error,e.complete)}var N=class extends se{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,n,r){let o;t instanceof ie?o=t:o=new qe(t,n,r);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((n,r)=>r(n),this)}toPromise(){return new Promise((t,n)=>{let r;this.subscribe({next:o=>r=o,error:n,complete:()=>t(r)})})}};var ot=class extends N{constructor(){super(n=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)n.error(this.thrownError);else if(this.isStopped)n.complete();else return this.observers.push(n),()=>{let r=this.observers.indexOf(n);r!==-1&&this.observers.splice(r,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(n){if(this.isStopped)return;let{observers:r}=this,o=r.length,s=r.slice();for(let i=0;i<o;i++)s[i].next?.(n)}error(n){if(this.isStopped)return;this.hasError=!0,this.thrownError=n,this.isStopped=!0;let{observers:r}=this;this.observers=[];let o=r.length,s=r.slice();for(let i=0;i<o;i++)s[i].error?.(n)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:n}=this;this.observers=[];let r=n.length,o=n.slice();for(let s=0;s<r;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new N(r=>this.subscribe(r))}};var or="__fluixi_signal_next_state__",sr=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[or]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:sr,onSuspend:null,onError:null};var Mt=0,qt=1,xe=2,Ne=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let t=a.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},ue=class extends Ne{constructor(t,n){super(),this._value=t,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let n of[...this.observers])n.markDirty(xe);st(this)}}peek(){return this._value}},K=class extends Ne{constructor(n,r){super();this._threw=!1;this._initialized=!1;this.state=xe;this.sources=null;this._fn=n,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){if(a.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===qt&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===xe)break}(this.state===xe||!this._initialized)&&this.recompute(),this.state=Mt}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let n=a.consumer,r=a.untracked;a.consumer=this,a.untracked=!1;let o,s=!1,i;try{o=this._fn()}catch(u){s=!0,i=u,o=this._value}finally{a.consumer=n,a.untracked=r}let c=!this._initialized||this._threw!==s||(s?i!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=s,this._error=i,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(xe);st(this)}}markDirty(n){if(this.state>=n)return;let r=this.state===Mt;if(this.state=n,r){if(this.observers)for(let o of[...this.observers])o.markDirty(qt);st(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function st(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var ae=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let n of t)this._watched.add(n),(n.watchers??=new Set).add(this)}unwatch(...t){for(let n of t)this._watched.delete(n),n.watchers?.delete(this),this._pending.delete(n)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let n=this._pending.size===0;this._pending.add(t),n&&this._notifyFn()}};function ge(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function Nt(){return a.consumer}function jt(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function Bt(e){let t=Oe(e);return e&&(e.owned??=[]).push(t),t}function Lt(e,t=!0){we(e,t)}function $t(e){return!!e&&e.disposed===!0}function Oe(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function ce(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:r=>{let o=a.owner,s=Oe(o);(s.contexts=new Map).set(t,r.value),o&&(o.owned??=[]).push(s),a.owner=s;try{return r.children}finally{a.owner=o}}}}function Vt(e){let t=a.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function je(e,t){let n=e;for(;n;){if(n.contexts&&n.contexts.has(t.id))return n.contexts.get(t.id);n=n.parent}return t.defaultValue}function le(e,t,n){let r=Oe(a.owner);(r.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(r);let o=a.owner;a.owner=r;try{return n()}finally{a.owner=o}}function Kt(e){a.onSuspend=e}function Ht(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function Wt(e){a.onError=e}function Re(){return a.owner}function ut(e){let t=a.owner;return a.owner=e,t}function fe(e,t){let n=a.owner;a.owner=e;try{return t()}finally{a.owner=n}}function F(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function we(e,t=!0){if(!e.disposed){if(e.owned){for(let n=e.owned.length-1;n>=0;n--)we(e.owned[n]);e.owned=null}if(e.cleanups){for(let n=e.cleanups.length-1;n>=0;n--)e.cleanups[n]();e.cleanups=null}t&&(e.disposed=!0)}}function Y(e){let t=Oe(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let n=a.owner;a.owner=t;try{return e(()=>we(t))}finally{a.owner=n}}function Gt(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function ir(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(Ae)))}function Ae(){if(a.scheduled=!1,a.flushing)return;a.flushing=!0;let e=0;try{for(;a.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=a.queue;a.queue=[];for(let n of t)n.queued=!1,n.disposed||n.run()}}finally{a.flushing=!1}}function zt(){a.batchDepth===0&&Ae()}function at(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&Ae()}}var it=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=Oe(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new K(()=>{we(this.owner,!1),fe(this.owner,()=>{let n=t();typeof n=="function"&&(this.owner.cleanups??=[]).push(n)})}),this.watcher=new ae(()=>ir(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&a.onSuspend){a.onSuspend(t,this.owner);return}if(a.onError&&a.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),we(this.owner))}};function Be(e){let t=new it(e);return()=>t.dispose()}function ur(e){return!!e&&typeof e.then=="function"}Gt(()=>{});var Yt=Symbol.for("signal"),ar=Symbol.for("memo"),cr=Symbol.for("signal-node");function h(e,t){let n=new ue(e,{equals:t?.equals}),r=(()=>n.get()),o=(s=>{let i=typeof s=="function"?s(n.peek()):s;return n.set(i),zt(),i});return Object.defineProperty(r,Yt,{value:!0,enumerable:!0}),Object.defineProperty(r,cr,{value:{get value(){return n.peek()},get version(){return n.version}},enumerable:!1}),[r,o]}function T(e,t,n){let r=t,o=Re(),s=new K(()=>fe(o,()=>{try{return r=e(r)}catch(c){if(ur(c))return Ht(c),r;throw c}}),{equals:n?.equals}),i=(()=>s.get());return Object.defineProperty(i,Yt,{value:!0,enumerable:!0}),Object.defineProperty(i,ar,{value:!0,enumerable:!0}),i}function M(e,t){let n=t;return Be(()=>{n=e(n)})}function Xt(e,t){let n=t;Be(()=>{n=e(n)})}function Qt(e,t){let n=t;return Be(()=>{n=e(n)})}function $(e){return at(e)}function D(e){return ge(e)}function ct(e){return at(e),Promise.resolve()}function Jt(){return[()=>!1,ct]}function Zt(){return Ae(),Promise.resolve()}function en(e,t,n){let r=Array.isArray(e),o,s=n?.defer??!1;return i=>{let c=r?e.map(l=>l()):e();if(s){s=!1,o=c;return}let u=ge(()=>t(c,o,i));return o=c,u}}function lr(e,t,n){let r=[];return F(()=>{for(let o of r)o.dispose();r=[]}),T(()=>{let o=e()||[];return D(()=>{if(o.length===0){for(let u of r)u.dispose();return r=[],n?.fallback?n.fallback():[]}let s=new Map;for(let u of r)s.has(u.item)||s.set(u.item,u);let i=[],c=new Set;for(let u=0;u<o.length;u++){let l=o[u],b=s.get(l);if(b&&!c.has(b))b.setIndex(u),i.push(b),c.add(b);else{let d,m,v;Y(x=>{v=x;let[E,p]=h(u);m=p,d=t(l,E)});let O={item:l,rendered:d,dispose:v,setIndex:m};i.push(O),c.add(O)}}for(let u of r)c.has(u)||u.dispose();return r=i,i.map(u=>u.rendered)})})}function fr(e,t,n,r){let o=[],s=[];return F(()=>{for(let i of s)i.dispose();o=[],s=[]}),T(()=>{let i=e()||[];return D(()=>{if(i.length===0){for(let d of s)d.dispose();return o=[],s=[],r?.fallback?r.fallback():[]}let c=new Map;for(let d=0;d<o.length;d++)c.set(o[d],s[d]);let u=[],l=[],b=new Set;for(let d=0;d<i.length;d++){let m=t(i[d]),v=c.get(m);if(v&&!b.has(m))v.setIndex(d),u.push(v);else{let O,x,E;Y(p=>{E=p;let[U,A]=h(d);x=A;let B=T(P=>{let I=(e()||[])[U()];return I??P},i[d]);O=n(B,U)}),u.push({rendered:O,dispose:E,setIndex:x})}l.push(m),b.add(m)}for(let[d,m]of c)b.has(d)||m.dispose();return o=l,s=u,u.map(d=>d.rendered)})})}function dr(e,t,n){let r=[];return F(()=>{for(let o of r)o.dispose();r=[]}),T(()=>{let o=e()||[];return D(()=>{if(o.length===0){for(let u of r)u.dispose();return r=[],n?.fallback?n.fallback():[]}let s=r.length,i=o.length;for(let u=s;u<i;u++){let l,b,d,m=o[u];Y(v=>{d=v;let[O,x]=h(m);b=x,l=t(O,u)}),r.push({rendered:l,setItem:b,dispose:d})}for(let u=i;u<s;u++)r[u].dispose();i<s&&(r=r.slice(0,i));let c=Math.min(s,i);for(let u=0;u<c;u++)r[u].setItem(o[u]);return r.map(u=>u.rendered)})})}var Ce=!1,pr=Symbol.for("signal"),Tr=Symbol.for("memo"),yr=Symbol.for("resource");function Le(e){return typeof e=="function"&&e[pr]===!0}function tn(e){return typeof e=="function"&&e[Tr]===!0}function nn(e){return typeof e=="function"&&e[yr]===!0}function rn(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function on(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function sn(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function lt(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?lt(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var ft=null;function yt(e){ft=e}function X(e){ft&&ft(e)}var dt=null;function mt(e){dt=e}function Ee(e){return dt?dt(e):void 0}var pt=null;function ht(e){pt=e}function Pe(){return pt?pt():void 0}var Tt=null;function bt(e){Tt=e}function ke(e,t){Tt&&Tt(e,t)}function un(e,t=(n,r)=>n===r){let n=new Map;return M(()=>{let r=e();for(let[o,s]of n){let[i,c]=s,u=t(o,r);i()!==u&&c(u)}}),r=>{let o=n.get(r);if(!o){let[s,i]=h(!1);o=[s,i],n.set(r,o);let c=e();i(t(r,c))}return o[0]()}}function an(e,t){let[n,r]=h(e(),t);return M(()=>{let o=e();t?.timeoutMs?setTimeout(()=>r(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>r(()=>o)):Promise.resolve().then(()=>r(()=>o))}),n}function cn(e,t){let n,r=(...o)=>{n!==void 0&&clearTimeout(n),n=setTimeout(()=>{n=void 0,e(...o)},t)};return F(()=>{n!==void 0&&clearTimeout(n)}),r}function mr(e){return!!e&&typeof e.then=="function"}var vt=Symbol();function de(e,t,n={}){let r,o;typeof t=="function"?(r=typeof e=="function"?e:()=>e,o=t):(r=()=>!0,o=e,t&&typeof t=="object"&&(n=t));let s=n.transport===!1?void 0:Pe(),i=s!==void 0?Ee(s):void 0,c=i!==void 0,[u,l]=h(i!==void 0?i.value:n.initialValue,{equals:!1}),[b,d]=h(void 0,{equals:!1}),[m,v]=h(i!==void 0||n.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[O,x]=h(void 0,{equals:!1}),[E,p]=h(void 0,{equals:!1}),U=vt,A=!1;M(()=>{let C=r();if(E(),C===!1||C===null||C===void 0){U=vt,$(()=>{v("unresolved"),x(void 0),d(void 0)});return}let I=A;if(A=!1,U!==vt&&C===U&&!I)return;if(U=C,c){c=!1;return}let V=!1;F(()=>V=!0);let G=D(m),Se=D(u),ne=G==="ready"||G==="refreshing";$(()=>{v(ne?"refreshing":"pending"),d(void 0)});try{let q=o(C,{value:Se,refetching:ne});mr(q)?(x(q),X(q),q.then(z=>{V||(s!==void 0&&ke(s,z),$(()=>{l(()=>z),v("ready"),x(void 0)}))},z=>{V||$(()=>{d(z),v("errored"),x(void 0)})})):$(()=>{l(()=>q),v("ready"),x(void 0)})}catch(q){if(V)return;$(()=>{d(q),v("errored"),x(void 0)})}});let B=()=>{let C=m();return C==="pending"||C==="refreshing"},P=(()=>{let C=b();if(C)throw C;if(B()){let I=O();if(I)throw I}return u()});return Object.defineProperties(P,{state:{get:m},loading:{get:B},error:{get:b},latest:{get:u}}),Object.defineProperty(P,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(P,Symbol.for("signal"),{value:!0,enumerable:!0}),[P,{mutate:l,refetch:()=>{A=!0,p(void 0)}}]}function St(e,t=300){let[n,r]=h(e),[o,s]=h(e),[i,c]=h(!1),u,l=()=>{u!==void 0&&(clearTimeout(u),u=void 0)},b=()=>{l();let m=D(n);return s(()=>m),c(!1),m},d=(m=>{let v=typeof m=="function"?m(D(n)):m;return r(()=>v),c(!0),l(),u=setTimeout(b,t),v});return F(l),[o,d,{immediate:n,pending:i,flush:b,cancel:()=>{l(),c(!1)}}]}function hr(e){return e!=null&&e!==""}function ln(e,t,n={}){let{delay:r=300,initialValue:o,shouldFetch:s=hr}=n,[i,c,u]=St(e,r),l=()=>s(i())?i():!1,[b,{refetch:d}]=de(l,t,o===void 0?{}:{initialValue:o});return[b,{...u,query:i,setQuery:c,refetch:d}]}function $e(e){if(typeof e=="function"&&!e.length){let t=e();return Le(t)?t:$e(t)}if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let r=$e(e[n]);Array.isArray(r)?t.push.apply(t,r):t.push(r)}return t}return e}function Ve(e){let t=T(e);return T(()=>$e(t()))}var Ke=ce();Kt((e,t)=>{let n=je(t,Ke);n&&(n.increment(),e.finally(()=>n.decrement()))});function fn(){let[e,t]=h(0),n=0;return{increment:()=>t(n+=1),decrement:()=>t(n-=1),inFallback:()=>e()>0}}function dn(e,t){return le(Ke,e,t)}var pn=ce();Wt((e,t)=>{let n=je(t,pn);return n?(n.setError(e),!0):!1});function Tn(){let[e,t]=h(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:r=>t(()=>r)}}function yn(e,t){return le(pn,e,t)}var mn={State:ue,Computed:K,subtle:{Watcher:ae,untrack:ge,currentComputed:Nt,hasSinks:jt}};var br=Symbol.for("signal"),vr=Symbol.for("fluixi-proxy");function Sr(e,t){let[n,r]=h(e,t);return Object.assign(n,{set:r})}function xr(e,t,n){return T(e,t,n)}function gr(e,t){return M(e,t)}function hn(...e){let[t,n]=de(...e);return Object.assign(t,n)}var g=require("@fluixi/reactive/signal"),Fe=Symbol("store-raw"),Q=Symbol("store-node"),bn=Symbol("store-has"),We=Symbol("store-self"),Ge=Symbol("store-track"),Rn=Symbol("store-name"),An=Symbol("store-store"),vn=new WeakMap,Sn=new WeakMap;function Cn(e){let[t,n]=(0,g.createSignal)(e),r=t;return r.$=n,r}function ze(e){let t=vn.get(e);return t||vn.set(e,t={keys:new Map}),t}function xn(e,t,n){let r=e.keys.get(t);return r||e.keys.set(t,r=Cn(n)),r}function gn(e){let t=ze(e);(t.all||(t.all=Cn()))()}function wn(e,t){e.$(typeof t=="function"?()=>t:t)}function En(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 He(e){if(!En(e))return e;let t=Sn.get(e);if(t)return t;let n=new Proxy(e,wr);return Sn.set(e,n),n}var wr={get(e,t,n){if(t===Fe||t===Q)return e;if(t===g.$PROXY)return n;if(t===bn)return i=>i in e;if(t==="__proxy")return!0;if(t===Ge||t===We)return gn(e),n;let r=e[t];if(typeof r=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return r;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(n);let s=xn(ze(e),t,r)();return En(s)?He(s):s},set(){return!0},deleteProperty(e,t){return t in e&&_e(e,t,void 0),!0},has(e,t){return t===Fe||t===g.$PROXY||t===Q||t===bn||t===We||t===Ge?!0:(xn(ze(e),t,e[t])(),t in e)},ownKeys(e){return gn(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function _e(e,t,n){if(e[t]===n&&(n!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;n===void 0?delete e[t]:e[t]=n;let i=ze(e),c=i.keys.get(t);if(c&&wn(c,n),o&&e.length!==s){let u=i.keys.get("length");u&&wn(u,e.length)}i.all&&i.all.$(void 0)}function On(e,t){return typeof e=="function"?e(t):e}function gt(e,t){for(let n of Object.keys(t)){let r=t[n],o=e[n];r&&typeof r=="object"&&!Array.isArray(r)&&o&&typeof o=="object"&&!Array.isArray(o)?gt(o,r):_e(e,n,r)}}function Ot(e){let t=[],n=e.replace(/\[([^\]]*)\]/g,".$1");for(let r of n.split("."))r.length&&t.push(r);return t}function Pn(e,t,n){let r=t.length-1;for(let s=0;s<r;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let l=0;l<e.length;l++)Pn(e[l],u,n);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},_e(e,i,c)),e=c}let o=t[r];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)_e(e,s,On(n,e[s]));return}_e(e,o,On(n,e[o]))}function xt(e,t,n){Pn(e,Ot(t),n)}function Or(e,t){let n=t[0];if(typeof n=="function"&&t.length===1){let r=n(e);r&&r!==e&&gt(e,r);return}if(Array.isArray(n)&&t.length===1){for(let r of n)Array.isArray(r)&&xt(e,r[0],r[1]);return}if(n&&typeof n=="object"&&!Array.isArray(n)&&t.length===1){gt(e,n);return}if(Array.isArray(t[1])&&t.length>=3){xt(e,`${n}.${t[1].join(".")}`,t[2]);return}xt(e,String(n),t[1])}function wt(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(wt);let t={};for(let n of Object.keys(e))t[n]=wt(e[n]);return t}function pe(e,t){let n=e;for(let r of Ot(t)){if(n==null)return;n=n[r]}return n}var H=class{constructor(t,n={immutable:!0}){this.options=n;this.root=t,this.set=((...r)=>(0,g.batch)(()=>Or(this.root,r)))}get state(){return He(this.root)}get proxy(){return He(this.root)}get accessor(){return(()=>He(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return Te(this.state);let n=this.state;for(let r of Ot(t)){if(n==null)return;n=n[r]}return Te(n)}select(t){return(0,g.createMemo)(()=>t(this.state))}subscribe(t){return(0,g.createEffect)(()=>t(this.state))}watch(t,n){let r;return(0,g.createEffect)(()=>{let o=t(this.state);Object.is(o,r)||(n(o,r),r=o)})}reactive(t){return(0,g.createMemo)(()=>this.state[t])}produce(t){this.set((n=>{let r=wt(n);return t(r),r}))}reconcile(t,n={}){this.set(t)}push(t,...n){let r=pe(this.root,t);this.set(t,r.concat(n))}pop(t){let n=pe(this.root,t).slice(),r=n.pop();return this.set(t,n),r}shift(t){let n=pe(this.root,t).slice(),r=n.shift();return this.set(t,n),r}splice(t,n,r,...o){let s=pe(this.root,t).slice(),i=s.splice(n,r,...o);return this.set(t,s),i}insert(t,n,r){let o=pe(this.root,t).slice();o.splice(n,0,r),this.set(t,o)}removeAt(t,n){let r=pe(this.root,t).slice(),o=r.splice(n,1);return this.set(t,r),o}toObservable(){let[t]=(0,g.createSignal)(this.state);return t.toObservable()}dispose(){}},Rr=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function kn(e,t){for(let n of Rr)e[n]=t[n].bind(t);e.$=t.reactive.bind(t)}function De(e,t={immutable:!0}){let n=new H(e,t);return kn(n.set,n),[n.proxy,n.set]}function Rt(e,t={}){return new H(e,{...t,immutable:!1})}function _n(e,t={}){let n=new H(e(),t);return(0,g.createEffect)(()=>n.set(e())),n}function Fn(e,t,n){return(0,g.createEffect)(()=>n(t(e)))}function Dn(e,t,n){return(0,g.createMemo)(()=>t(e),void 0,n)}function Un(e,t={}){let n=new H(e,t),r=(()=>n.proxy);return kn(r,n),r}function Te(e){if(e==null||typeof e!="object")return e;let t=e[Fe];return t!==void 0?t:e}function At(e){return(0,g.untrack)(()=>Te(e))}function In(e){return Ye(e)}function Mn(e){return Ye(e)?e[Q]:null}function qn(e){return e&&typeof e=="object"&&Q in e?e[Q]:null}function Ye(e){return!!e&&typeof e=="object"&&(g.$PROXY in e||e.__proxy===!0)}function Nn(e){return e}var jn=Object.freeze({createStore:De,createMutableStore:Rt,batch:g.batch,unwrap:Te,untrackStore:At});function Ct(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ct);let t={};for(let n of Object.keys(e))t[n]=Ct(e[n]);return t}function Bn(e){return t=>{let n=Ct(t);return e(n),n}}function Ln(e,t={}){return()=>e}function $n(e,t){let[n,r]=De(e,t);return new Proxy(n,{get:(o,s)=>s==="set"?r:o[s],has:(o,s)=>s==="set"||Reflect.has(o,s)})}function Ar(e,t,n){return T(()=>t(e()),void 0,n)}function Cr(e,t,n){return T(()=>e().filter(t),void 0,n)}function Er(e,t,n,r){return T(()=>e().reduce(t,n),void 0,r)}function Pr(e,t,n){return T(()=>e().find(t),void 0,n)}function kr(e,t,n){return T(()=>e().some(t),void 0,n)}function _r(e,t,n){return T(()=>e().every(t),void 0,n)}function Fr(e,t,n){return T(()=>[...e()].sort(t),void 0,n)}function Dr(e,t){return T(()=>[...new Set(e())],void 0,t)}function Ur(e,t,n){return T(()=>{let r=e.map(o=>o());return t(r)},void 0,n)}function Ir(...e){return new N(t=>{let n=()=>e.map(o=>typeof o=="function"?o():o.get()),r=e.map(o=>typeof o=="function"&&o.subscribe?o.subscribe(()=>{t.next(n())}):typeof o!="function"?o.subscribe(()=>{t.next(n())}):M(()=>{t.next(n())}));return()=>{r.forEach(o=>{typeof o=="function"?o():o&&typeof o.unsubscribe=="function"&&o.unsubscribe()})}})}function Mr(e,t,n){return T(()=>e()||t(),void 0,n)}function qr(e,t,n,r){return T(()=>n(e(),t()),void 0,r)}function Nr(e,t,n){return T(()=>t(e()),void 0,{equals:n,internal:!0})}function jr(e,t,n){return T(()=>{let r=e(),o={};for(let s of t)o[s]=r[s];return o},void 0,n)}function Br(e,t,n){return T(()=>{let o={...e()};for(let s of t)delete o[s];return o},void 0,n)}function Lr(e,t,n,r){return T(()=>e()?t():n(),void 0,r)}function $r(e,t,n){return T(()=>e()?t():void 0,void 0,n)}function Vr(e,t,n){let[r,o]=h(e()),s;return T(()=>{let i=e();clearTimeout(s),s=setTimeout(()=>o(()=>i),t)}),r}function Kr(e,t,n){let[r,o]=h(e()),s=0,i;return T(()=>{let c=e(),u=Date.now();u-s>=t?(s=u,o(()=>c)):(clearTimeout(i),i=setTimeout(()=>{s=Date.now(),o(()=>c)},t-(u-s)))}),r}function Hr(e){let t=e;for(;typeof t=="function";)t=t();return t}var Wr=Symbol.for("signal");var Vn=Symbol("fluixi-proxy"),Gr=Symbol.for("signal-node"),Ue=0,Pt=1,Ze=2,me=3,S=null,R=null,f=null,Qe=null,Je=0,zr=!1,Et=!1,ye=0,Yr=1e6,W=new WeakMap,Xe=null;var Xr=new Map,Qr=0;function Jr(){return`node_${++Qr}_${Date.now()}`}function Zr(e){!1}function eo(e,t,n){let r={id:Jr(),type:e,value:t,version:0,equals:n?.equals,name:n?.name,created:Date.now(),updated:Date.now()};return Zr(r),r}function to(e,t){return e===t}function Hn(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}function no(e){if(f)f.indexOf(e)===-1&&f.push(e);else if(Xe&&Xe.running&&!e.pure)Xe.effects.indexOf(e)===-1&&Xe.effects.push(e);else if(!e.pure||e.computed)_t(e);else if(e.pure&&!e.computed&&e.accessor){let t=R,n=f;R=null,f=[],e.accessor(),R=t;let r=f;if(f=n,r.length>0){let o=f;et(r),f=o}}}function Kn(e,t){for(let n=0;n<e.length;n++)t(e[n])}function J(e,t){let n=e;typeof n=="object"&&n&&Vn in n&&delete n[Vn];let r=eo("signal",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),o=[i,c];W.set(o,new Set);let s;function i(){let u=R;if(u){u.sources?u.sources.indexOf(o)===-1&&u.sources.push(o):u.sources=[o];let l=W.get(o);l&&!l.has(u)&&l.add(u)}return n}function c(u){let l=typeof u=="function"?u(n):u,b=r.equals||to;if(t?.equals===!1||!b(n,l)){n=l,r.value=l,r.version++,r.updated=Date.now();let m=W.get(o);if(m&&m.size>0){let E=function(p,U=!1){let A=p.state;if(!(A===me&&p===R)){if(U&&!p.pure){A===Ue&&(p.state=Pt,zr&&(f!==null&&f.indexOf(p)===-1?f.push(p):O.push(p)));return}if(!x.has(p)&&(x.add(p),p.state=Ze,A===Ue||A===Pt?O.push(p):!p.pure&&f!==null&&f.indexOf(p)===-1&&f.push(p),p.pure&&p.accessor)){let B=W.get(p.accessor);B&&Kn(Array.from(B),P=>E(P,!0))}}};var d=E;let v=Array.from(m),O=[],x=new Set;Kn(v,E);for(let p of O)no(p)}}}return i.toObservable=()=>new N(u=>{let l=!0;return kt(()=>{let d=i();l?l=!1:u.next(d)})}),Object.defineProperty(i,Wr,{value:!0,enumerable:!0}),Object.defineProperty(i,Gr,{value:r,enumerable:!1}),o}function kt(e,t,n){let r={fn:e,state:Ze,sources:null,sourceSlots:null,owned:null,cleanups:null,owner:S,contexts:null,pure:!1,updatedAt:null};S&&(S.owned?S.owned.push(r):S.owned=[r]);let o=j&&ve(j);return o&&(r.suspense=o),Wn(r,t),()=>he(r)}function Wn(e,t){if(e.sources){for(let o of e.sources){let s=W.get(o);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.owned){for(let o=0;o<e.owned.length;o++)he(e.owned[o]);e.owned=null}let n=R,r=S;if(R=e,S=e,Je++,Je>Yr)throw Je=0,R=n,S=r,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=me;let o=e.fn(t);typeof o=="function"&&(e.cleanups?e.cleanups.push(o):e.cleanups=[o]),e.state===me&&(e.state=Ue)}catch(o){if(rt(o)){let s=j&&ve(j);s&&(s.increment(),o.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Hn(o)}finally{R=n,S=r}}function _t(e){if(!(e.disposed||!e.fn||e.state===Ue)&&(e.state===Ze||e.state===Pt||e.state===me)){if(e.cleanups){for(let t=0;t<e.cleanups.length;t++)e.cleanups[t]();e.cleanups=null}if(e.owned){for(let t=0;t<e.owned.length;t++)he(e.owned[t]);e.owned=null}e.renderEffect?zn(e):Wn(e,e.value)}}function he(e){if(e.disposed=!0,e.sources)for(let t of e.sources){let n=W.get(t);n&&n.delete(e)}if(e.cleanups)for(let t=0;t<e.cleanups.length;t++)e.cleanups[t]();if(e.owned)for(let t=0;t<e.owned.length;t++)he(e.owned[t]);if(e.owner&&e.owner.owned){let t=e.owner.owned.indexOf(e);t!==-1&&e.owner.owned.splice(t,1)}}function et(e){let t=[],n=[];for(let o of e)o.pure&&!o.computed&&o.accessor?t.indexOf(o)===-1&&t.push(o):(o.computed||!o.pure)&&n.indexOf(o)===-1&&n.push(o);f=[];let r=0;for(;r<t.length;){let o=t[r++],s=W.get(o.accessor);if(s&&s.size>0){let c=R;R=null,o.accessor(),R=c}let i=f.splice(0);for(let c of i)c.pure&&!c.computed&&c.accessor?t.indexOf(c)===-1&&t.push(c):(c.computed||!c.pure)&&n.indexOf(c)===-1&&n.push(c)}f=null;for(let o of n)(o.computed||!o.pure)&&_t(o)}function Z(e){if(f&&ye>0)return e();if(f&&ye===0){let t=f,n=[];f=n,ye++;let r;try{r=e()}finally{ye--,f=t}let o=f;return et(n),f=o,r}ye++,f=[],Qe=[];try{return e()}finally{ye--,ro()}}function ro(){if(!Et){Et=!0,Je=0;try{for(;f&&f.length>0;){let e=f;f=null,et(e)}if(f=null,Qe){let e=Qe;Qe=null;for(let t=0;t<e.length;t++)_t(e[t])}}finally{Et=!1}}}function be(e){let t=R;R=null;try{return e()}finally{R=t}}function Gn(e){S&&(S.cleanups?S.cleanups.push(e):S.cleanups=[e])}function oo(e){let t=Symbol("context"),n=so(t);return{id:t,Provider:n,defaultValue:e}}function so(e){return t=>{let n=S;for(;n;)n.contexts||(n.contexts=new Map),n.contexts.has(e)||n.contexts.set(e,t.value),n=n.owner;let r;return io(()=>{r=be(()=>{let o=S;return o&&(o.contexts||(o.contexts=new Map),o.contexts.set(e,t.value)),Ve(()=>t.children)})}),r}}function ve(e){let t=S;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.owner}if(e)return e.defaultValue}function io(e,t,n){let r={fn:e,state:Ze,sources:null,sourceSlots:null,value:t,owned:null,cleanups:null,owner:S,contexts:null,pure:!1,updatedAt:null,renderEffect:!0};S&&(S.owned?S.owned.push(r):S.owned=[r]);let o=j&&ve(j);return o&&(r.suspense=o),zn(r),()=>he(r)}function zn(e){if(e.sources){for(let o of e.sources){let s=W.get(o);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.cleanups){for(let o=0;o<e.cleanups.length;o++)e.cleanups[o]();e.cleanups=null}if(e.owned){for(let o=0;o<e.owned.length;o++)he(e.owned[o]);e.owned=null}let t=R,n=S,r=f;R=e,S=e,f===null&&(f=[]),e.state=me;try{let o=e.fn(e.value);typeof o=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(o)),e.value=o,e.state===me&&(e.state=Ue)}catch(o){if(rt(o)){let s=j&&ve(j);s&&(s.increment(),o.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Hn(o)}finally{R=t,S=n;let o=f;if(f=r,o!==r&&o&&o.length>0){let s=f;et(o),f=s}}}var j;function Yn(){return j||(j=oo())}var te=new Map,ee=new Map,uo=0,ao=Symbol.for("signal"),co=Symbol.for("resource");function lo(e,t,n={}){let r,o,s;typeof t=="function"?(r=e,o=t,s=n):(r=()=>!0,o=e,s=t??n);let{ttl:i=1/0,name:c=`_auto_${uo++}`,staleWhileRevalidate:u=!0}=s,l=c,b=y=>`${l}:${JSON.stringify(y)}`,d=y=>i===1/0||Date.now()-y.timestamp<=i,[m,v]=J(void 0,{equals:!1}),[O,x]=J("unresolved",{equals:!1}),[E,p]=J(void 0,{equals:!1}),[U,A]=J(void 0,{equals:!1}),[B,P]=J(!1),[C,I]=J(0,{equals:!1}),V=Symbol("unset"),G=V,Se=!1,ne=!1;function q(y,k,_,L){if(ee.has(k)){ee.get(k).then(w=>{L()||z(w,_)},w=>{!L()&&!_&&Ft(w)}),_||A(ee.get(k));return}let re=Promise.resolve(o(y)).then(w=>(te.set(k,{value:w,timestamp:Date.now()}),ee.delete(k),w),w=>{throw ee.delete(k),w});if(ee.set(k,re),!_){X(re),A(re);let w=Ie&&ve(Ie);w&&(w.increment(),re.finally(()=>w.decrement()))}re.then(w=>{L()||z(w,_)},w=>{!L()&&!_&&Ft(w)})}function z(y,k){Z(()=>{v(()=>y),x("ready"),P(!1),A(void 0),p(void 0)})}function Ft(y){Z(()=>{p(y),x("errored"),A(void 0)})}let Ie;kt(()=>{Ie===void 0&&(Ie=Yn());let y=r();if(C(),y===!1||y===null||y===void 0){G=V,Z(()=>{x("unresolved"),A(void 0),p(void 0)});return}let k=Se,_=ne;Se=!1,ne=!1;let L=b(y);_&&te.delete(L);let re=G===V||y!==G;G=y;let w=!1;Gn(()=>{w=!0});let oe=te.get(L);if(oe&&d(oe)&&!k&&!_){(be(O)!=="ready"||be(m)!==oe.value)&&Z(()=>{v(()=>oe.value),x("ready"),P(!1),p(void 0)});return}if(oe&&u&&!_){Z(()=>{v(()=>oe.value),x("ready"),P(!0),p(void 0),A(void 0)}),q(y,L,!0,()=>w);return}let Dt=be(O),Xn=Dt==="ready"||Dt==="refreshing";Z(()=>{x(Xn?"refreshing":"pending"),p(void 0),P(!1)}),q(y,L,!1,()=>w)});let Me=(()=>{let y=E();if(y)throw y;if(O()==="pending"){let _=U();if(_)throw _}return m()});return Object.defineProperty(Me,co,{value:!0,enumerable:!0}),Object.defineProperty(Me,ao,{value:!0,enumerable:!0}),Object.defineProperties(Me,{state:{get:O},loading:{get:()=>{let y=O();return y==="pending"||y==="refreshing"}},error:{get:E},latest:{get:m},stale:{get:B}}),[Me,{mutate:v,refetch:()=>{Se=!0,I(y=>y+1)},invalidate:()=>{let y=be(r);y!=null&&y!==!1&&te.delete(b(y)),ne=!0,I(k=>k+1)}}]}function fo(e){let t=`${e}:`;for(let n of te.keys())n.startsWith(t)&&te.delete(n)}function po(){te.clear(),ee.clear()}