@fluixi/reactive 1.0.0-alpha.81 → 1.0.0-alpha.83
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/README.md +4 -0
- package/dist/cdn/reactive.cjs +1 -1
- package/dist/cdn/reactive.global.js +1 -1
- package/dist/cdn/reactive.mjs +1 -1
- package/dist/cdn/signal.cjs +1 -1
- package/dist/cdn/signal.global.js +1 -1
- package/dist/cdn/signal.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/lib/index.cjs +1 -1
- package/dist/lib/index.mjs +1 -1
- package/dist/lib/signal/api.cjs +1 -1
- package/dist/lib/signal/api.mjs +1 -1
- package/dist/lib/signal/cached-resource.cjs +1 -1
- package/dist/lib/signal/cached-resource.mjs +1 -1
- package/dist/lib/signal/graph/children.cjs +1 -1
- package/dist/lib/signal/graph/children.mjs +1 -1
- package/dist/lib/signal/graph/compat.cjs +1 -1
- package/dist/lib/signal/graph/compat.d.ts.map +1 -1
- package/dist/lib/signal/graph/compat.js +19 -2
- package/dist/lib/signal/graph/compat.mjs +1 -1
- package/dist/lib/signal/graph/core.cjs +1 -1
- package/dist/lib/signal/graph/core.d.ts.map +1 -1
- package/dist/lib/signal/graph/core.js +7 -0
- package/dist/lib/signal/graph/core.mjs +1 -1
- package/dist/lib/signal/graph/debounced.cjs +1 -1
- package/dist/lib/signal/graph/debounced.mjs +1 -1
- package/dist/lib/signal/graph/derived.cjs +1 -1
- package/dist/lib/signal/graph/derived.mjs +1 -1
- package/dist/lib/signal/graph/error-boundary.cjs +1 -1
- package/dist/lib/signal/graph/error-boundary.mjs +1 -1
- package/dist/lib/signal/graph/index.cjs +1 -1
- package/dist/lib/signal/graph/index.mjs +1 -1
- package/dist/lib/signal/graph/observe.cjs +1 -0
- package/dist/lib/signal/graph/observe.d.ts +141 -0
- package/dist/lib/signal/graph/observe.d.ts.map +1 -0
- package/dist/lib/signal/graph/observe.js +149 -0
- package/dist/lib/signal/graph/observe.mjs +1 -0
- package/dist/lib/signal/graph/resource.cjs +1 -1
- package/dist/lib/signal/graph/resource.mjs +1 -1
- package/dist/lib/signal/graph/runtime.cjs +1 -1
- package/dist/lib/signal/graph/runtime.d.ts +2 -2
- package/dist/lib/signal/graph/runtime.d.ts.map +1 -1
- package/dist/lib/signal/graph/runtime.js +22 -7
- package/dist/lib/signal/graph/runtime.mjs +1 -1
- package/dist/lib/signal/graph/signal-next.cjs +1 -1
- package/dist/lib/signal/graph/signal-next.mjs +1 -1
- package/dist/lib/signal/graph/state.cjs +1 -1
- package/dist/lib/signal/graph/state.d.ts +2 -0
- package/dist/lib/signal/graph/state.d.ts.map +1 -1
- package/dist/lib/signal/graph/state.js +1 -0
- package/dist/lib/signal/graph/state.mjs +1 -1
- package/dist/lib/signal/graph/suspense.cjs +1 -1
- package/dist/lib/signal/graph/suspense.mjs +1 -1
- package/dist/lib/signal/index-legacy.cjs +1 -1
- package/dist/lib/signal/index-legacy.mjs +1 -1
- package/dist/lib/signal/index.cjs +1 -1
- package/dist/lib/signal/index.d.ts +2 -0
- package/dist/lib/signal/index.d.ts.map +1 -1
- package/dist/lib/signal/index.js +2 -0
- package/dist/lib/signal/index.mjs +1 -1
- package/dist/lib/signal/list.cjs +1 -1
- package/dist/lib/signal/list.js +5 -5
- package/dist/lib/signal/list.mjs +1 -1
- package/dist/lib/signal/resource-api.cjs +1 -1
- package/dist/lib/signal/resource-api.mjs +1 -1
- package/dist/lib/signal/signal.cjs +1 -1
- package/dist/lib/signal/signal.mjs +1 -1
- package/dist/lib/signal/utilities.cjs +1 -1
- package/dist/lib/signal/utilities.mjs +1 -1
- package/dist/lib/store/api.cjs +1 -1
- package/dist/lib/store/api.mjs +1 -1
- package/dist/lib/store/index.cjs +1 -1
- package/dist/lib/store/index.mjs +1 -1
- package/dist/lib/store/store.cjs +1 -1
- package/dist/lib/store/store.d.ts.map +1 -1
- package/dist/lib/store/store.js +148 -8
- package/dist/lib/store/store.mjs +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/version.generated.cjs +1 -1
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/dist/version.generated.mjs +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Sn="1.0.0-alpha.81";function Ye(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function Rt(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 Xe(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}var pe=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(Ye(r)&&!(r instanceof e))try{r()}catch(o){console.error("Error in unsubscribe function:",o)}else if(Rt(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(Ye(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 Te=class extends pe{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 Te{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 $r(e){return new Te(e.next,e.error,e.complete)}var B=class extends pe{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 Te?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 At=class extends B{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 B(r=>this.subscribe(r))}};var xn="__fluixi_signal_next_state__",gn=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[xn]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:gn,onSuspend:null,onError:null};var Ct=0,Et=1,ye=2,ke=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))}},te=class extends ke{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(ye);Je(this)}}peek(){return this._value}},$=class extends ke{constructor(n,r){super();this._threw=!1;this._initialized=!1;this.state=ye;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===Et&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===ye)break}(this.state===ye||!this._initialized)&&this.recompute(),this.state=Ct}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(ye);Je(this)}}markDirty(n){if(this.state>=n)return;let r=this.state===Ct;if(this.state=n,r){if(this.observers)for(let o of[...this.observers])o.markDirty(Et);Je(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Je(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var ne=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 me(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function Pt(){return a.consumer}function kt(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function wn(e){let t=be(e);return e&&(e.owned??=[]).push(t),t}function On(e,t=!0){he(e,t)}function Rn(e){return!!e&&e.disposed===!0}function be(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function ve(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:r=>{let o=a.owner,s=be(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 An(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 _e(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 Se(e,t,n){let r=be(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 _t(e){a.onSuspend=e}function Ft(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function Dt(e){a.onError=e}function Fe(){return a.owner}function Ut(e){let t=a.owner;return a.owner=e,t}function xe(e,t){let n=a.owner;a.owner=e;try{return t()}finally{a.owner=n}}function _(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function he(e,t=!0){if(!e.disposed){if(e.owned){for(let n=e.owned.length-1;n>=0;n--)he(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 re(e){let t=be(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let n=a.owner;a.owner=t;try{return e(()=>he(t))}finally{a.owner=n}}function It(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function Cn(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(ge)))}function ge(){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 Mt(){a.batchDepth===0&&ge()}function et(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&ge()}}var Ze=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=be(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new $(()=>{he(this.owner,!1),xe(this.owner,()=>{let n=t();typeof n=="function"&&(this.owner.cleanups??=[]).push(n)})}),this.watcher=new ne(()=>Cn(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),he(this.owner))}};function De(e){let t=new Ze(e);return()=>t.dispose()}function En(e){return!!e&&typeof e.then=="function"}It(()=>{});var qt=Symbol.for("signal"),Pn=Symbol.for("memo"),kn=Symbol.for("signal-node");function h(e,t){let n=new te(e,{equals:t?.equals}),r=(()=>n.get()),o=(s=>{let i=typeof s=="function"?s(n.peek()):s;return n.set(i),Mt(),i});return Object.defineProperty(r,qt,{value:!0,enumerable:!0}),Object.defineProperty(r,kn,{value:{get value(){return n.peek()},get version(){return n.version}},enumerable:!1}),[r,o]}function y(e,t,n){let r=t,o=Fe(),s=new $(()=>xe(o,()=>{try{return r=e(r)}catch(c){if(En(c))return Ft(c),r;throw c}}),{equals:n?.equals}),i=(()=>s.get());return Object.defineProperty(i,qt,{value:!0,enumerable:!0}),Object.defineProperty(i,Pn,{value:!0,enumerable:!0}),i}function M(e,t){let n=t;return De(()=>{n=e(n)})}function _n(e,t){let n=t;De(()=>{n=e(n)})}function Fn(e,t){let n=t;return De(()=>{n=e(n)})}function V(e){return et(e)}function U(e){return me(e)}function Nt(e){return et(e),Promise.resolve()}function Dn(){return[()=>!1,Nt]}function Un(){return ge(),Promise.resolve()}function In(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=me(()=>t(c,o,i));return o=c,u}}function ro(e,t,n){let r=[];return _(()=>{for(let o of r)o.dispose();r=[]}),y(()=>{let o=e()||[];return U(()=>{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;re(x=>{v=x;let[C,p]=h(u);m=p,d=t(l,C)});let w={item:l,rendered:d,dispose:v,setIndex:m};i.push(w),c.add(w)}}for(let u of r)c.has(u)||u.dispose();return r=i,i.map(u=>u.rendered)})})}function oo(e,t,n,r){let o=[],s=[];return _(()=>{for(let i of s)i.dispose();o=[],s=[]}),y(()=>{let i=e()||[];return U(()=>{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 w,x,C;re(p=>{C=p;let[F,R]=h(d);x=R;let N=y(E=>{let D=(e()||[])[F()];return D??E},i[d]);w=n(N,F)}),u.push({rendered:w,dispose:C,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 so(e,t,n){let r=[];return _(()=>{for(let o of r)o.dispose();r=[]}),y(()=>{let o=e()||[];return U(()=>{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];re(v=>{d=v;let[w,x]=h(m);b=x,l=t(w,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 Mn=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,we=typeof process>"u"?Mn:!1,qn=Symbol.for("signal"),Nn=Symbol.for("memo"),jn=Symbol.for("resource");function Ue(e){return typeof e=="function"&&e[qn]===!0}function jt(e){return typeof e=="function"&&e[Nn]===!0}function Bt(e){return typeof e=="function"&&e[jn]===!0}function Lt(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function $t(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Vt(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function tt(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?tt(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var nt=null;function Kt(e){nt=e}function oe(e){nt&&nt(e)}var rt=null;function Ht(e){rt=e}function Ie(e){return rt?rt(e):void 0}var ot=null;function Wt(e){ot=e}function Me(){return ot?ot():void 0}var st=null;function Gt(e){st=e}function qe(e,t){st&&st(e,t)}function Bn(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 Ln(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 $n(e,t){let n,r=(...o)=>{n!==void 0&&clearTimeout(n),n=setTimeout(()=>{n=void 0,e(...o)},t)};return _(()=>{n!==void 0&&clearTimeout(n)}),r}function Vn(e){return!!e&&typeof e.then=="function"}var it=Symbol();function Oe(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:Me(),i=s!==void 0?Ie(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}),[w,x]=h(void 0,{equals:!1}),[C,p]=h(void 0,{equals:!1}),F=it,R=!1;M(()=>{let A=r();if(C(),A===!1||A===null||A===void 0){F=it,V(()=>{v("unresolved"),x(void 0),d(void 0)});return}let D=R;if(R=!1,F!==it&&A===F&&!D)return;if(F=A,c){c=!1;return}let L=!1;_(()=>L=!0);let H=U(m),de=U(u),J=H==="ready"||H==="refreshing";V(()=>{v(J?"refreshing":"pending"),d(void 0)});try{let I=o(A,{value:de,refetching:J});Vn(I)?(x(I),oe(I),I.then(W=>{L||(s!==void 0&&qe(s,W),V(()=>{l(()=>W),v("ready"),x(void 0)}))},W=>{L||V(()=>{d(W),v("errored"),x(void 0)})})):V(()=>{l(()=>I),v("ready"),x(void 0)})}catch(I){if(L)return;V(()=>{d(I),v("errored"),x(void 0)})}});let N=()=>{let A=m();return A==="pending"||A==="refreshing"},E=(()=>{let A=b();if(A)throw A;if(N()){let D=w();if(D)throw D}return u()});return Object.defineProperties(E,{state:{get:m},loading:{get:N},error:{get:b},latest:{get:u}}),Object.defineProperty(E,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(E,Symbol.for("signal"),{value:!0,enumerable:!0}),[E,{mutate:l,refetch:()=>{R=!0,p(void 0)}}]}function zt(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=U(n);return s(()=>m),c(!1),m},d=(m=>{let v=typeof m=="function"?m(U(n)):m;return r(()=>v),c(!0),l(),u=setTimeout(b,t),v});return _(l),[o,d,{immediate:n,pending:i,flush:b,cancel:()=>{l(),c(!1)}}]}function Kn(e){return e!=null&&e!==""}function Hn(e,t,n={}){let{delay:r=300,initialValue:o,shouldFetch:s=Kn}=n,[i,c,u]=zt(e,r),l=()=>s(i())?i():!1,[b,{refetch:d}]=Oe(l,t,o===void 0?{}:{initialValue:o});return[b,{...u,query:i,setQuery:c,refetch:d}]}function Ne(e){if(typeof e=="function"&&!e.length){let t=e();return Ue(t)?t:Ne(t)}if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let r=Ne(e[n]);Array.isArray(r)?t.push.apply(t,r):t.push(r)}return t}return e}function ut(e){let t=y(e);return we?y(()=>Ne(t()),void 0,{name:"children"}):y(()=>Ne(t()))}var at=ve();_t((e,t)=>{let n=_e(t,at);n&&(n.increment(),e.finally(()=>n.decrement()))});function Wn(){let[e,t]=h(0),n=0;return{increment:()=>t(n+=1),decrement:()=>t(n-=1),inFallback:()=>e()>0}}function Gn(e,t){return Se(at,e,t)}var Yt=ve();Dt((e,t)=>{let n=_e(t,Yt);return n?(n.setError(e),!0):!1});function zn(){let[e,t]=h(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:r=>t(()=>r)}}function Yn(e,t){return Se(Yt,e,t)}var Xn={State:te,Computed:$,subtle:{Watcher:ne,untrack:me,currentComputed:Pt,hasSinks:kt}};var Po=Symbol.for("signal"),ko=Symbol.for("fluixi-proxy");function Ho(e,t){let[n,r]=h(e,t);return Object.assign(n,{set:r})}function Wo(e,t,n){return y(e,t,n)}function Go(e,t){return M(e,t)}function Qn(...e){let[t,n]=Oe(...e);return Object.assign(t,n)}import{$PROXY as lt,batch as rn,createEffect as Be,createMemo as ft,createSignal as on,untrack as Jn}from"@fluixi/reactive/signal";var Le=Symbol("store-raw"),ie=Symbol("store-node"),Xt=Symbol("store-has"),dt=Symbol("store-self"),pt=Symbol("store-track"),Zn=Symbol("store-name"),er=Symbol("store-store"),Qt=new WeakMap,Jt=new WeakMap;function sn(e){let[t,n]=on(e),r=t;return r.$=n,r}function $e(e){let t=Qt.get(e);return t||Qt.set(e,t={keys:new Map}),t}function Zt(e,t,n){let r=e.keys.get(t);return r||e.keys.set(t,r=sn(n)),r}function en(e){let t=$e(e);(t.all||(t.all=sn()))()}function tn(e,t){e.$(typeof t=="function"?()=>t:t)}function un(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 je(e){if(!un(e))return e;let t=Jt.get(e);if(t)return t;let n=new Proxy(e,tr);return Jt.set(e,n),n}var tr={get(e,t,n){if(t===Le||t===ie)return e;if(t===lt)return n;if(t===Xt)return i=>i in e;if(t==="__proxy")return!0;if(t===pt||t===dt)return en(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=Zt($e(e),t,r)();return un(s)?je(s):s},set(){return!0},deleteProperty(e,t){return t in e&&Re(e,t,void 0),!0},has(e,t){return t===Le||t===lt||t===ie||t===Xt||t===dt||t===pt?!0:(Zt($e(e),t,e[t])(),t in e)},ownKeys(e){return en(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function Re(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=$e(e),c=i.keys.get(t);if(c&&tn(c,n),o&&e.length!==s){let u=i.keys.get("length");u&&tn(u,e.length)}i.all&&i.all.$(void 0)}function nn(e,t){return typeof e=="function"?e(t):e}function Tt(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)?Tt(o,r):Re(e,n,r)}}function mt(e){let t=[],n=e.replace(/\[([^\]]*)\]/g,".$1");for(let r of n.split("."))r.length&&t.push(r);return t}function an(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++)an(e[l],u,n);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},Re(e,i,c)),e=c}let o=t[r];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)Re(e,s,nn(n,e[s]));return}Re(e,o,nn(n,e[o]))}function ct(e,t,n){an(e,mt(t),n)}function nr(e,t){let n=t[0];if(typeof n=="function"&&t.length===1){let r=n(e);r&&r!==e&&Tt(e,r);return}if(Array.isArray(n)&&t.length===1){for(let r of n)Array.isArray(r)&&ct(e,r[0],r[1]);return}if(n&&typeof n=="object"&&!Array.isArray(n)&&t.length===1){Tt(e,n);return}if(Array.isArray(t[1])&&t.length>=3){ct(e,`${n}.${t[1].join(".")}`,t[2]);return}ct(e,String(n),t[1])}function yt(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(yt);let t={};for(let n of Object.keys(e))t[n]=yt(e[n]);return t}function se(e,t){let n=e;for(let r of mt(t)){if(n==null)return;n=n[r]}return n}var G=class{constructor(t,n={immutable:!0}){this.options=n;this.root=t,this.set=((...r)=>rn(()=>nr(this.root,r)))}get state(){return je(this.root)}get proxy(){return je(this.root)}get accessor(){return(()=>je(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return Ae(this.state);let n=this.state;for(let r of mt(t)){if(n==null)return;n=n[r]}return Ae(n)}select(t){return ft(()=>t(this.state))}subscribe(t){return Be(()=>t(this.state))}watch(t,n){let r;return Be(()=>{let o=t(this.state);Object.is(o,r)||(n(o,r),r=o)})}reactive(t){return ft(()=>this.state[t])}produce(t){this.set((n=>{let r=yt(n);return t(r),r}))}reconcile(t,n={}){this.set(t)}push(t,...n){let r=se(this.root,t);this.set(t,r.concat(n))}pop(t){let n=se(this.root,t).slice(),r=n.pop();return this.set(t,n),r}shift(t){let n=se(this.root,t).slice(),r=n.shift();return this.set(t,n),r}splice(t,n,r,...o){let s=se(this.root,t).slice(),i=s.splice(n,r,...o);return this.set(t,s),i}insert(t,n,r){let o=se(this.root,t).slice();o.splice(n,0,r),this.set(t,o)}removeAt(t,n){let r=se(this.root,t).slice(),o=r.splice(n,1);return this.set(t,r),o}toObservable(){let[t]=on(this.state);return t.toObservable()}dispose(){}},rr=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function cn(e,t){for(let n of rr)e[n]=t[n].bind(t);e.$=t.reactive.bind(t)}function Ve(e,t={immutable:!0}){let n=new G(e,t);return cn(n.set,n),[n.proxy,n.set]}function ln(e,t={}){return new G(e,{...t,immutable:!1})}function or(e,t={}){let n=new G(e(),t);return Be(()=>n.set(e())),n}function sr(e,t,n){return Be(()=>n(t(e)))}function ir(e,t,n){return ft(()=>t(e),void 0,n)}function ur(e,t={}){let n=new G(e,t),r=(()=>n.proxy);return cn(r,n),r}function Ae(e){if(e==null||typeof e!="object")return e;let t=e[Le];return t!==void 0?t:e}function fn(e){return Jn(()=>Ae(e))}function ar(e){return ht(e)}function cr(e){return ht(e)?e[ie]:null}function lr(e){return e&&typeof e=="object"&&ie in e?e[ie]:null}function ht(e){return!!e&&typeof e=="object"&&(lt in e||e.__proxy===!0)}function fr(e){return e}var dr=Object.freeze({createStore:Ve,createMutableStore:ln,batch:rn,unwrap:Ae,untrackStore:fn});function bt(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(bt);let t={};for(let n of Object.keys(e))t[n]=bt(e[n]);return t}function pr(e){return t=>{let n=bt(t);return e(n),n}}function Tr(e,t={}){return()=>e}function yr(e,t){let[n,r]=Ve(e,t);return new Proxy(n,{get:(o,s)=>s==="set"?r:o[s],has:(o,s)=>s==="set"||Reflect.has(o,s)})}function ds(e,t,n){return y(()=>t(e()),void 0,n)}function ps(e,t,n){return y(()=>e().filter(t),void 0,n)}function Ts(e,t,n,r){return y(()=>e().reduce(t,n),void 0,r)}function ys(e,t,n){return y(()=>e().find(t),void 0,n)}function ms(e,t,n){return y(()=>e().some(t),void 0,n)}function hs(e,t,n){return y(()=>e().every(t),void 0,n)}function bs(e,t,n){return y(()=>[...e()].sort(t),void 0,n)}function vs(e,t){return y(()=>[...new Set(e())],void 0,t)}function Ss(e,t,n){return y(()=>{let r=e.map(o=>o());return t(r)},void 0,n)}function xs(...e){return new B(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 gs(e,t,n){return y(()=>e()||t(),void 0,n)}function ws(e,t,n,r){return y(()=>n(e(),t()),void 0,r)}function Os(e,t,n){return y(()=>t(e()),void 0,{equals:n,internal:!0})}function Rs(e,t,n){return y(()=>{let r=e(),o={};for(let s of t)o[s]=r[s];return o},void 0,n)}function As(e,t,n){return y(()=>{let o={...e()};for(let s of t)delete o[s];return o},void 0,n)}function Cs(e,t,n,r){return y(()=>e()?t():n(),void 0,r)}function Es(e,t,n){return y(()=>e()?t():void 0,void 0,n)}function Ps(e,t,n){let[r,o]=h(e()),s;return y(()=>{let i=e();clearTimeout(s),s=setTimeout(()=>o(()=>i),t)}),r}function ks(e,t,n){let[r,o]=h(e()),s=0,i;return y(()=>{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 _s(e){let t=e;for(;typeof t=="function";)t=t();return t}var mr=Symbol.for("signal");var dn=Symbol("fluixi-proxy"),hr=Symbol.for("signal-node"),Ce=0,St=1,Ge=2,ae=3,S=null,O=null,f=null,He=null,We=0,br=!1,vt=!1,ue=0,vr=1e6,K=new WeakMap,Ke=null;var Sr=new Map,xr=0;function gr(){return`node_${++xr}_${Date.now()}`}function wr(e){we&&Sr.set(e.id,new WeakRef(e))}function Or(e,t,n){let r={id:gr(),type:e,value:t,version:0,equals:n?.equals,name:n?.name,created:Date.now(),updated:Date.now()};return wr(r),r}function Rr(e,t){return e===t}function Tn(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}function Ar(e){if(f)f.indexOf(e)===-1&&f.push(e);else if(Ke&&Ke.running&&!e.pure)Ke.effects.indexOf(e)===-1&&Ke.effects.push(e);else if(!e.pure||e.computed)gt(e);else if(e.pure&&!e.computed&&e.accessor){let t=O,n=f;O=null,f=[],e.accessor(),O=t;let r=f;if(f=n,r.length>0){let o=f;ze(r),f=o}}}function pn(e,t){for(let n=0;n<e.length;n++)t(e[n])}function z(e,t){let n=e;typeof n=="object"&&n&&dn in n&&delete n[dn];let r=Or("signal",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),o=[i,c];K.set(o,new Set);let s;function i(){let u=O;if(u){u.sources?u.sources.indexOf(o)===-1&&u.sources.push(o):u.sources=[o];let l=K.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||Rr;if(t?.equals===!1||!b(n,l)){n=l,r.value=l,r.version++,r.updated=Date.now();let m=K.get(o);if(m&&m.size>0){let C=function(p,F=!1){let R=p.state;if(!(R===ae&&p===O)){if(F&&!p.pure){R===Ce&&(p.state=St,br&&(f!==null&&f.indexOf(p)===-1?f.push(p):w.push(p)));return}if(!x.has(p)&&(x.add(p),p.state=Ge,R===Ce||R===St?w.push(p):!p.pure&&f!==null&&f.indexOf(p)===-1&&f.push(p),p.pure&&p.accessor)){let N=K.get(p.accessor);N&&pn(Array.from(N),E=>C(E,!0))}}};var d=C;let v=Array.from(m),w=[],x=new Set;pn(v,C);for(let p of w)Ar(p)}}}return i.toObservable=()=>new B(u=>{let l=!0;return xt(()=>{let d=i();l?l=!1:u.next(d)})}),Object.defineProperty(i,mr,{value:!0,enumerable:!0}),Object.defineProperty(i,hr,{value:r,enumerable:!1}),o}function xt(e,t,n){let r={fn:e,state:Ge,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=q&&fe(q);return o&&(r.suspense=o),yn(r,t),()=>ce(r)}function yn(e,t){if(e.sources){for(let o of e.sources){let s=K.get(o);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.owned){for(let o=0;o<e.owned.length;o++)ce(e.owned[o]);e.owned=null}let n=O,r=S;if(O=e,S=e,We++,We>vr)throw We=0,O=n,S=r,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=ae;let o=e.fn(t);typeof o=="function"&&(e.cleanups?e.cleanups.push(o):e.cleanups=[o]),e.state===ae&&(e.state=Ce)}catch(o){if(Xe(o)){let s=q&&fe(q);s&&(s.increment(),o.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Tn(o)}finally{O=n,S=r}}function gt(e){if(!(e.disposed||!e.fn||e.state===Ce)&&(e.state===Ge||e.state===St||e.state===ae)){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++)ce(e.owned[t]);e.owned=null}e.renderEffect?hn(e):yn(e,e.value)}}function ce(e){if(e.disposed=!0,e.sources)for(let t of e.sources){let n=K.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++)ce(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 ze(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=K.get(o.accessor);if(s&&s.size>0){let c=O;O=null,o.accessor(),O=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)&>(o)}function Y(e){if(f&&ue>0)return e();if(f&&ue===0){let t=f,n=[];f=n,ue++;let r;try{r=e()}finally{ue--,f=t}let o=f;return ze(n),f=o,r}ue++,f=[],He=[];try{return e()}finally{ue--,Cr()}}function Cr(){if(!vt){vt=!0,We=0;try{for(;f&&f.length>0;){let e=f;f=null,ze(e)}if(f=null,He){let e=He;He=null;for(let t=0;t<e.length;t++)gt(e[t])}}finally{vt=!1}}}function le(e){let t=O;O=null;try{return e()}finally{O=t}}function mn(e){S&&(S.cleanups?S.cleanups.push(e):S.cleanups=[e])}function Er(e){let t=Symbol("context"),n=Pr(t);return{id:t,Provider:n,defaultValue:e}}function Pr(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 kr(()=>{r=le(()=>{let o=S;return o&&(o.contexts||(o.contexts=new Map),o.contexts.set(e,t.value)),ut(()=>t.children)})}),r}}function fe(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 kr(e,t,n){let r={fn:e,state:Ge,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=q&&fe(q);return o&&(r.suspense=o),hn(r),()=>ce(r)}function hn(e){if(e.sources){for(let o of e.sources){let s=K.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++)ce(e.owned[o]);e.owned=null}let t=O,n=S,r=f;O=e,S=e,f===null&&(f=[]),e.state=ae;try{let o=e.fn(e.value);typeof o=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(o)),e.value=o,e.state===ae&&(e.state=Ce)}catch(o){if(Xe(o)){let s=q&&fe(q);s&&(s.increment(),o.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Tn(o)}finally{O=t,S=n;let o=f;if(f=r,o!==r&&o&&o.length>0){let s=f;ze(o),f=s}}}var q;function bn(){return q||(q=Er())}var Q=new Map,X=new Map,_r=0,Fr=Symbol.for("signal"),Dr=Symbol.for("resource");function Ls(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_${_r++}`,staleWhileRevalidate:u=!0}=s,l=c,b=T=>`${l}:${JSON.stringify(T)}`,d=T=>i===1/0||Date.now()-T.timestamp<=i,[m,v]=z(void 0,{equals:!1}),[w,x]=z("unresolved",{equals:!1}),[C,p]=z(void 0,{equals:!1}),[F,R]=z(void 0,{equals:!1}),[N,E]=z(!1),[A,D]=z(0,{equals:!1}),L=Symbol("unset"),H=L,de=!1,J=!1;function I(T,P,k,j){if(X.has(P)){X.get(P).then(g=>{j()||W(g,k)},g=>{!j()&&!k&&wt(g)}),k||R(X.get(P));return}let Z=Promise.resolve(o(T)).then(g=>(Q.set(P,{value:g,timestamp:Date.now()}),X.delete(P),g),g=>{throw X.delete(P),g});if(X.set(P,Z),!k){oe(Z),R(Z);let g=Ee&&fe(Ee);g&&(g.increment(),Z.finally(()=>g.decrement()))}Z.then(g=>{j()||W(g,k)},g=>{!j()&&!k&&wt(g)})}function W(T,P){Y(()=>{v(()=>T),x("ready"),E(!1),R(void 0),p(void 0)})}function wt(T){Y(()=>{p(T),x("errored"),R(void 0)})}let Ee;xt(()=>{Ee===void 0&&(Ee=bn());let T=r();if(A(),T===!1||T===null||T===void 0){H=L,Y(()=>{x("unresolved"),R(void 0),p(void 0)});return}let P=de,k=J;de=!1,J=!1;let j=b(T);k&&Q.delete(j);let Z=H===L||T!==H;H=T;let g=!1;mn(()=>{g=!0});let ee=Q.get(j);if(ee&&d(ee)&&!P&&!k){(le(w)!=="ready"||le(m)!==ee.value)&&Y(()=>{v(()=>ee.value),x("ready"),E(!1),p(void 0)});return}if(ee&&u&&!k){Y(()=>{v(()=>ee.value),x("ready"),E(!0),p(void 0),R(void 0)}),I(T,j,!0,()=>g);return}let Ot=le(w),vn=Ot==="ready"||Ot==="refreshing";Y(()=>{x(vn?"refreshing":"pending"),p(void 0),E(!1)}),I(T,j,!1,()=>g)});let Pe=(()=>{let T=C();if(T)throw T;if(w()==="pending"){let k=F();if(k)throw k}return m()});return Object.defineProperty(Pe,Dr,{value:!0,enumerable:!0}),Object.defineProperty(Pe,Fr,{value:!0,enumerable:!0}),Object.defineProperties(Pe,{state:{get:w},loading:{get:()=>{let T=w();return T==="pending"||T==="refreshing"}},error:{get:C},latest:{get:m},stale:{get:N}}),[Pe,{mutate:v,refetch:()=>{de=!0,D(T=>T+1)},invalidate:()=>{let T=le(r);T!=null&&T!==!1&&Q.delete(b(T)),J=!0,D(P=>P+1)}}]}function $s(e){let t=`${e}:`;for(let n of Q.keys())n.startsWith(t)&&Q.delete(n)}function Vs(){Q.clear(),X.clear()}export{Zn as $NAME,ie as $NODE,ko as $PROXY,Le as $RAW,dt as $SELF,Po as $SIGNAL,er as $STORE,pt as $TRACK,B as Observable,Qe as SafeSubscriber,Xn as Signal,G as Store,dr as StoreAPI,At as Subject,Te as Subscriber,pe as Subscription,at as SuspenseContext,Sn as VERSION,we as __DEV__,V as batch,Vs as clearAllCachedResources,$s as clearCachedResourceNamespace,Ss as combineSignal,xs as combineSignals,Ls as createCachedResource,wn as createChildOwner,_n as createComputed,or as createComputedStore,ve as createContext,$n as createDebounce,Hn as createDebouncedResource,zt as createDebouncedSignal,Ln as createDeferred,M as createEffect,zn as createErrorBoundary,y as createMemo,ln as createMutableStore,Fn as createRenderEffect,Oe as createResource,re as createRoot,Bn as createSelector,h as createSignal,Ve as createStore,sr as createStoreEffect,ir as createStoreMemo,Wn as createSuspenseBoundary,Ps as debounceSignal,On as disposeScope,vs as distinctSignal,Go as effect,hs as everySignal,ps as filterSignal,ys as findSignal,Un as flush,cr as getNode,Fe as getOwner,Ie as getServerData,lr as getStoreNode,Es as guardSignal,so as indexArray,Lt as isComponent,jt as isMemo,Rn as isOwnerDisposed,Vt as isProvider,Bt as isResource,Ue as isSignal,ar as isStore,ht as isStoreProxy,$t as isSuspense,oo as keyArray,tt as makeArrayFlat,ro as mapArray,ds as mapSignal,Wo as memo,gs as mergeSignal,fr as modifiable,Me as nextResourceId,As as omitSignal,In as on,_ as onCleanup,$r as operate,Rs as pickSignal,pr as produceUtil,Se as provide,Yn as provideErrorBoundary,Gn as provideSuspense,ut as readChildren,_s as readSignal,Tr as reconcileUtil,Ts as reduceSignal,qe as reportResourceData,Qn as resource,xe as runWithOwner,Os as selectSignal,Ut as setOwner,Gt as setResourceDataSink,Wt as setResourceIdSource,Kt as setResourceTracker,Ht as setServerDataGetter,Ho as signal,ms as someSignal,bs as sortSignal,Nt as startTransition,yr as store,ks as throttleSignal,oe as trackResourcePromise,U as untrack,fn as untrackStore,Ae as unwrap,An as useContext,Dn as useTransition,Cs as whenSignal,ur as wrap,ws as zipSignal};
|
|
1
|
+
var it="1.0.0-alpha.83";function at(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function Bt(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 ut(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}var he=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(at(r)&&!(r instanceof e))try{r()}catch(o){console.error("Error in unsubscribe function:",o)}else if(Bt(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(at(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 Se=class extends he{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())}},ct=class extends Se{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 yo(e){return new Se(e.next,e.error,e.complete)}var L=class extends he{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 Se?o=t:o=new ct(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 Lt=class extends L{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 L(r=>this.subscribe(r))}};var Bn="__fluixi_signal_next_state__",Ln=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},c=globalThis[Bn]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Ln,onSuspend:null,onError:null,observer:null};function Vt(e){return c.observer=e,()=>{c.observer===e&&(c.observer=null)}}var k=[],qe;function Kt(e,t){if(!c.observer)return t();let n=qe;qe=e;try{return t()}finally{qe=n}}function X(e){let t=c.observer;t&&t.created(e.parents===void 0?{...e,parents:k,origin:e.origin??qe}:e)}function Ht(e){return c.observer?(k.push(e),!0):!1}function Wt(){k.pop()}function Gt(e){c.observer?.ran?.(e)}function zt(e,t){c.observer?.wrote?.(e,t)}function $n(e,t,n,r){let o=c.observer;!o?.bound||!k.length||o.bound(k[k.length-1],e,t,n,r)}function Vn(e){let t=c.observer;!t?.props||!k.length||!e||t.props(k[k.length-1],e)}function Kn(e,t,n,r){let o=c.observer;!o?.directive||!k.length||o.directive(k[k.length-1],e,t,n,r)}function lt(e){c.observer?.contextCreated?.(e)}function xe(e,t,n){let r=c.observer;!r?.context||!k.length||r.context(k[k.length-1],e,t,n)}function ft(e,t,n){c.observer?.moved?.(e,t,n)}function V(e){c.observer?.disposed?.(e)}var Hn="__FLUIXI_DEVTOOLS_HOOK__",$t=globalThis[Hn];if(typeof $t?.inject=="function")try{$t.inject({observeReactiveNodes:Vt,version:it})}catch{}function oe(){return c.observer!=null}var Xt=0,Yt=1,ge=2,Be=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(c.untracked)return;let t=c.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},se=class extends Be{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++,zt(this,c.consumer),this.observers)for(let n of[...this.observers])n.markDirty(ge);dt(this)}}peek(){return this._value}},K=class extends Be{constructor(n,r){super();this._threw=!1;this._initialized=!1;this.state=ge;this.sources=null;this._fn=n,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){if(c.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===Yt&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===ge)break}(this.state===ge||!this._initialized)&&this.recompute(),this.state=Xt}recompute(){if(this.sources){for(let l of this.sources)l.observers?.delete(this);this.sources.clear()}let n=c.consumer,r=c.untracked,o=Ht(this);c.consumer=this,c.untracked=!1;let s,i=!1,u;try{s=this._fn()}catch(l){i=!0,u=l,s=this._value}finally{c.consumer=n,c.untracked=r,o&&Wt()}let a=!this._initialized||this._threw!==i||(i?u!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=i,this._error=u,this._value=s,Gt(this),a){if(this.version++,this.observers)for(let l of[...this.observers])l.markDirty(ge);dt(this)}}markDirty(n){if(this.state>=n)return;let r=this.state===Xt;if(this.state=n,r){if(this.observers)for(let o of[...this.observers])o.markDirty(Yt);dt(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function dt(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var ie=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 we(e){if(c.untracked)return e();c.untracked=!0;try{return e()}finally{c.untracked=!1}}function Qt(){return c.consumer}function Jt(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function Wn(e){let t=Re(e);return e&&(e.owned??=[]).push(t),t}function Gn(e,t=!0){Oe(e,t)}function zn(e){return!!e&&e.disposed===!0}function Re(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function Ae(e,t){let n=Symbol(t??"context");return lt(n),{id:n,defaultValue:e,Provider:o=>{xe(n,"provide",o.value);let s=c.owner,i=Re(s);(i.contexts=new Map).set(n,o.value),s&&(s.owned??=[]).push(i),c.owner=i;try{return o.children}finally{c.owner=s}}}}function Xn(e){let t=c.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id)){let n=t.contexts.get(e.id);return xe(e.id,"read",n),n}t=t.parent}return xe(e.id,"read",e.defaultValue),e.defaultValue}function Le(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 ke(e,t,n){let r=Re(c.owner);(r.contexts=new Map).set(e.id,t),c.owner&&(c.owner.owned??=[]).push(r);let o=c.owner;c.owner=r;try{return n()}finally{c.owner=o}}function Zt(e){c.onSuspend=e}function en(e){return c.onSuspend?(c.onSuspend(e,c.owner),!0):!1}function tn(e){c.onError=e}function $e(){return c.owner}function nn(e){let t=c.owner;return c.owner=e,t}function Ce(e,t){let n=c.owner;c.owner=e;try{return t()}finally{c.owner=n}}function C(e){if(c.owner){if(c.owner.disposed){e();return}(c.owner.cleanups??=[]).push(e)}}function Oe(e,t=!0){if(!e.disposed){if(e.owned){for(let n=e.owned.length-1;n>=0;n--)Oe(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 ae(e){let t=Re(c.owner);c.owner&&(c.owner.owned??=[]).push(t);let n=c.owner;c.owner=t;try{return e(()=>Oe(t))}finally{c.owner=n}}function rn(e){c.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function Yn(e){e.queued||(e.queued=!0,c.queue.push(e),!c.scheduled&&c.batchDepth===0&&(c.scheduled=!0,c.hostSchedule(Ee)))}function Ee(){if(c.scheduled=!1,c.flushing)return;c.flushing=!0;let e=0;try{for(;c.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=c.queue;c.queue=[];for(let n of t)n.queued=!1,n.disposed||n.run()}}finally{c.flushing=!1}}function on(){c.batchDepth===0&&Ee()}function yt(e){c.batchDepth++;try{return e()}finally{--c.batchDepth===0&&Ee()}}var pt=class{constructor(t,n=!1){this.queued=!1;this.disposed=!1;this.owner=Re(c.owner),c.owner&&(c.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new K(()=>{Oe(this.owner,!1),Ce(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),X({kind:"effect",node:this.computed,handle:this,internal:!n}),this.watcher=new ie(()=>Yn(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"&&c.onSuspend){c.onSuspend(t,this.owner);return}if(c.onError&&c.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,V(this.computed),this.watcher.unwatch(this.computed),Oe(this.owner))}};function Ve(e,t=!1){let n=new pt(e,t);return()=>n.dispose()}function Qn(e){return!!e&&typeof e.then=="function"}rn(()=>{});var sn=Symbol.for("signal"),Jn=Symbol.for("memo"),Zn=Symbol.for("signal-node");function b(e,t){let n=new se(e,{equals:t?.equals}),r=(()=>n.get()),o=(s=>{let i=typeof s=="function"?s(n.peek()):s;return n.set(i),on(),i});return Object.defineProperty(r,sn,{value:!0,enumerable:!0}),Object.defineProperty(r,Zn,{value:{get value(){return n.peek()},get version(){return n.version}},enumerable:!1}),X({kind:"signal",node:n,handle:r,name:t?.name,set:o}),oe()&&C(()=>V(n)),[r,o]}function T(e,t,n){let r=t,o=$e(),s=new K(()=>Ce(o,()=>{try{return r=e(r)}catch(u){if(Qn(u))return en(u),r;throw u}}),{equals:n?.equals}),i=(()=>s.get());return Object.defineProperty(i,sn,{value:!0,enumerable:!0}),Object.defineProperty(i,Jn,{value:!0,enumerable:!0}),X({kind:"memo",node:s,handle:i,name:n?.name}),oe()&&C(()=>V(s)),i}function N(e,t){let n=t;return Ve(()=>{n=e(n)},!0)}function er(e,t){let n=t;Ve(()=>{n=e(n)})}function tr(e,t){let n=t;return Ve(()=>{n=e(n)})}function H(e){return yt(e)}function I(e){return we(e)}function an(e){return yt(e),Promise.resolve()}function nr(){return[()=>!1,an]}function rr(){return Ee(),Promise.resolve()}function or(e,t,n){let r=Array.isArray(e),o,s=n?.defer??!1;return i=>{let u=r?e.map(l=>l()):e();if(s){s=!1,o=u;return}let a=we(()=>t(u,o,i));return o=u,a}}function Io(e,t,n){let r=[];return C(()=>{for(let o of r)o.dispose();r=[]}),T(()=>{let o=e()||[];return I(()=>{if(o.length===0){for(let a of r)a.dispose();return r=[],n?.fallback?n.fallback():[]}let s=new Map;for(let a of r)s.has(a.item)||s.set(a.item,a);let i=[],u=new Set;for(let a=0;a<o.length;a++){let l=o[a],m=s.get(l);if(m&&!u.has(m))m.setIndex(a),i.push(m),u.add(m);else{let d,v,h;ae(x=>{h=x;let[E,p]=b(a,{name:"row index"});v=p,d=t(l,E)});let w={item:l,rendered:d,dispose:h,setIndex:v};i.push(w),u.add(w)}}for(let a of r)u.has(a)||a.dispose();return r=i,i.map(a=>a.rendered)})},void 0,{name:"mapArray"})}function jo(e,t,n,r){let o=[],s=[];return C(()=>{for(let i of s)i.dispose();o=[],s=[]}),T(()=>{let i=e()||[];return I(()=>{if(i.length===0){for(let d of s)d.dispose();return o=[],s=[],r?.fallback?r.fallback():[]}let u=new Map;for(let d=0;d<o.length;d++)u.set(o[d],s[d]);let a=[],l=[],m=new Set;for(let d=0;d<i.length;d++){let v=t(i[d]),h=u.get(v);if(h&&!m.has(v))h.setIndex(d),a.push(h);else{let w,x,E;ae(p=>{E=p;let[F,R]=b(d,{name:"row index"});x=R;let q=T(P=>{let U=(e()||[])[F()];return U??P},i[d]);w=n(q,F)}),a.push({rendered:w,dispose:E,setIndex:x})}l.push(v),m.add(v)}for(let[d,v]of u)m.has(d)||v.dispose();return o=l,s=a,a.map(d=>d.rendered)})},void 0,{name:"keyArray"})}function No(e,t,n){let r=[];return C(()=>{for(let o of r)o.dispose();r=[]}),T(()=>{let o=e()||[];return I(()=>{if(o.length===0){for(let a of r)a.dispose();return r=[],n?.fallback?n.fallback():[]}let s=r.length,i=o.length;for(let a=s;a<i;a++){let l,m,d,v=o[a];ae(h=>{d=h;let[w,x]=b(v);m=x,l=t(w,a)}),r.push({rendered:l,setItem:m,dispose:d})}for(let a=i;a<s;a++)r[a].dispose();i<s&&(r=r.slice(0,i));let u=Math.min(s,i);for(let a=0;a<u;a++)r[a].setItem(o[a]);return r.map(a=>a.rendered)})},void 0,{name:"indexArray"})}var sr=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,Pe=typeof process>"u"?sr:!1,ir=Symbol.for("signal"),ar=Symbol.for("memo"),ur=Symbol.for("resource");function Ke(e){return typeof e=="function"&&e[ir]===!0}function un(e){return typeof e=="function"&&e[ar]===!0}function cn(e){return typeof e=="function"&&e[ur]===!0}function ln(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function fn(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function dn(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Tt(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Tt(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var vt=null;function pn(e){vt=e}function ue(e){vt&&vt(e)}var bt=null;function yn(e){bt=e}function He(e){return bt?bt(e):void 0}var mt=null;function Tn(e){mt=e}function We(){return mt?mt():void 0}var ht=null;function vn(e){ht=e}function Ge(e,t){ht&&ht(e,t)}function cr(e,t=(n,r)=>n===r){let n=new Map;return N(()=>{let r=e();for(let[o,s]of n){let[i,u]=s,a=t(o,r);i()!==a&&u(a)}}),r=>{let o=n.get(r);if(!o){let[s,i]=b(!1);o=[s,i],n.set(r,o);let u=e();i(t(r,u))}return o[0]()}}function lr(e,t){let[n,r]=b(e(),t);return N(()=>{let o=e();t?.timeoutMs?setTimeout(()=>r(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>r(()=>o)):Promise.resolve().then(()=>r(()=>o))}),n}function fr(e,t){let n,r=(...o)=>{n!==void 0&&clearTimeout(n),n=setTimeout(()=>{n=void 0,e(...o)},t)};return C(()=>{n!==void 0&&clearTimeout(n)}),r}function dr(e){return!!e&&typeof e.then=="function"}var St=Symbol();function _e(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:We(),i=s!==void 0?He(s):void 0,u=i!==void 0,[a,l]=b(i!==void 0?i.value:n.initialValue,{equals:!1}),[m,d]=b(void 0,{equals:!1}),[v,h]=b(i!==void 0||n.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[w,x]=b(void 0,{equals:!1}),[E,p]=b(void 0,{equals:!1}),F=St,R=!1;N(()=>{let A=r();if(E(),A===!1||A===null||A===void 0){F=St,H(()=>{h("unresolved"),x(void 0),d(void 0)});return}let U=R;if(R=!1,F!==St&&A===F&&!U)return;if(F=A,u){u=!1;return}let $=!1;C(()=>$=!0);let G=I(v),me=I(a),te=G==="ready"||G==="refreshing";H(()=>{h(te?"refreshing":"pending"),d(void 0)});try{let j=o(A,{value:me,refetching:te});dr(j)?(x(j),ue(j),j.then(z=>{$||(s!==void 0&&Ge(s,z),H(()=>{l(()=>z),h("ready"),x(void 0)}))},z=>{$||H(()=>{d(z),h("errored"),x(void 0)})})):H(()=>{l(()=>j),h("ready"),x(void 0)})}catch(j){if($)return;H(()=>{d(j),h("errored"),x(void 0)})}});let q=()=>{let A=v();return A==="pending"||A==="refreshing"},P=(()=>{let A=m();if(A)throw A;if(q()){let U=w();if(U)throw U}return a()});return Object.defineProperties(P,{state:{get:v},loading:{get:q},error:{get:m},latest:{get:a}}),Object.defineProperty(P,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(P,Symbol.for("signal"),{value:!0,enumerable:!0}),[P,{mutate:l,refetch:()=>{R=!0,p(void 0)}}]}function bn(e,t=300){let[n,r]=b(e),[o,s]=b(e),[i,u]=b(!1),a,l=()=>{a!==void 0&&(clearTimeout(a),a=void 0)},m=()=>{l();let v=I(n);return s(()=>v),u(!1),v},d=(v=>{let h=typeof v=="function"?v(I(n)):v;return r(()=>h),u(!0),l(),a=setTimeout(m,t),h});return C(l),[o,d,{immediate:n,pending:i,flush:m,cancel:()=>{l(),u(!1)}}]}function pr(e){return e!=null&&e!==""}function yr(e,t,n={}){let{delay:r=300,initialValue:o,shouldFetch:s=pr}=n,[i,u,a]=bn(e,r),l=()=>s(i())?i():!1,[m,{refetch:d}]=_e(l,t,o===void 0?{}:{initialValue:o});return[m,{...a,query:i,setQuery:u,refetch:d}]}function ze(e){if(typeof e=="function"&&!e.length){let t=e();return Ke(t)?t:ze(t)}if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let r=ze(e[n]);Array.isArray(r)?t.push.apply(t,r):t.push(r)}return t}return e}function xt(e){let t=T(e);return Pe?T(()=>ze(t()),void 0,{name:"children"}):T(()=>ze(t()))}var gt=Ae();Zt((e,t)=>{let n=Le(t,gt);n&&(n.increment(),e.finally(()=>n.decrement()))});function Tr(){let[e,t]=b(0),n=0;return{increment:()=>t(n+=1),decrement:()=>t(n-=1),inFallback:()=>e()>0}}function vr(e,t){return ke(gt,e,t)}var mn=Ae();tn((e,t)=>{let n=Le(t,mn);return n?(n.setError(e),!0):!1});function br(){let[e,t]=b(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:r=>t(()=>r)}}function mr(e,t){return ke(mn,e,t)}var hr={State:se,Computed:K,subtle:{Watcher:ie,untrack:we,currentComputed:Qt,hasSinks:Jt}};var is=Symbol.for("signal"),as=Symbol.for("fluixi-proxy");function gs(e,t){let[n,r]=b(e,t);return Object.assign(n,{set:r})}function ws(e,t,n){return T(e,t,n)}function Os(e,t){return N(e,t)}function Sr(...e){let[t,n]=_e(...e);return Object.assign(t,n)}import{$PROXY as Ot,batch as On,createEffect as Ye,createMemo as Rt,createSignal as Rn,untrack as xr}from"@fluixi/reactive/signal";var Fe=Symbol("store-raw"),fe=Symbol("store-node"),hn=Symbol("store-has"),At=Symbol("store-self"),kt=Symbol("store-track"),gr=Symbol("store-name"),wr=Symbol("store-store"),Ue=new WeakMap,Ct=new WeakMap,de=new WeakMap,Qe=new WeakMap;function Or(e,t){if(!le(e)||!oe())return;let n=new Set,r=i=>{if(!(!le(i)||n.has(i))){n.add(i);for(let u of Object.values(i))r(u)}};r(Qe.get(t)??t);let o=new Set,s=i=>{if(!le(i))return;let u=i;if(n.has(u)||o.has(u))return;o.add(u);let a=Ue.get(u);if(a){for(let l of a.keys.values())V(l);a.all&&V(a.all),Ue.delete(u),de.delete(u),Ct.delete(u)}for(let l of Object.values(u))s(l)};s(e)}var Je=(e,t,n)=>n?`${e}[${String(t)}]`:`${e}.${String(t)}`;function An(e,t,n){let r=t?.owner,o=r&&n!==void 0?Je(r.name,n,t?.array):void 0,[s,i]=Kt(r?.store,()=>Rn(e,o?{name:o}:void 0)),u=s;return u.$=i,u}function Ze(e){let t=Ue.get(e);return t?t.owner||(t.owner=de.get(e)):Ue.set(e,t={keys:new Map,owner:de.get(e),array:Array.isArray(e)}),t}function Sn(e,t,n){let r=e.keys.get(t);return r||e.keys.set(t,r=An(n,e,t)),r}function Rr(e,t,n,r){let o=de.get(e);if(o&&o.store===t&&o.name===n)return;let s={store:t,name:n};de.set(e,s),Qe.set(e,Qe.get(r)??r);let i=Ue.get(e);if(i&&(i.owner=s,!!oe())){for(let[u,a]of i.keys)ft(a,t,Je(n,u,i.array));i.all&&ft(i.all,t,Je(n,"*",i.array))}}function xn(e){let t=Ze(e);(t.all||(t.all=An(void 0,t,"*")))()}function gn(e,t){e.$(typeof t=="function"?()=>t:t)}function le(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Xe(e){if(!le(e))return e;let t=Ct.get(e);if(t)return t;let n=new Proxy(e,Ar);return Ct.set(e,n),n}var Ar={get(e,t,n){if(t===Fe||t===fe)return e;if(t===Ot)return n;if(t===hn)return a=>a in e;if(t==="__proxy")return!0;if(t===kt||t===At)return xn(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=Ze(e),i=Sn(s,t,r),u=i();return le(u)?(s.owner&&Rr(u,i,Je(s.owner.name,t,s.array),e),Xe(u)):u},set(){return!0},deleteProperty(e,t){return t in e&&De(e,t,void 0),!0},has(e,t){return t===Fe||t===Ot||t===fe||t===hn||t===At||t===kt?!0:(Sn(Ze(e),t,e[t])(),t in e)},ownKeys(e){return xn(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function kn(e,t=new Set){if(e==null||typeof e!="object")return e;let n=e[Fe]??e;if(t.has(n)||!le(n))return n;t.add(n);let r=!1,o=i=>{let u=kn(i,t);return u!==i&&(r=!0),u};if(Array.isArray(n)){let i=n.map(o);return r?i:n}let s={};for(let i of Object.keys(n))s[i]=o(n[i]);return r?s:n}function De(e,t,n){let r=kn(n),o=e[t];if(o===r&&(r!==void 0||t in e))return;let s=Array.isArray(e),i=s?e.length:0;r===void 0?delete e[t]:e[t]=r;let u=Ze(e),a=u.keys.get(t);if(a&&gn(a,r),Or(o,e),s&&e.length!==i){let l=u.keys.get("length");l&&gn(l,e.length)}u.all&&u.all.$(void 0)}function wn(e,t){return typeof e=="function"?e(t):e}function Et(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)?Et(o,r):De(e,n,r)}}function _t(e){let t=[],n=e.replace(/\[([^\]]*)\]/g,".$1");for(let r of n.split("."))r.length&&t.push(r);return t}function Cn(e,t,n){let r=t.length-1;for(let s=0;s<r;s++){let i=t[s];if(i==="*"){let a=t.slice(s+1);if(Array.isArray(e))for(let l=0;l<e.length;l++)Cn(e[l],a,n);return}let u=e[i];(u==null||typeof u!="object")&&(u=/^\d+$/.test(t[s+1])?[]:{},De(e,i,u)),e=u}let o=t[r];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)De(e,s,wn(n,e[s]));return}De(e,o,wn(n,e[o]))}function wt(e,t,n){Cn(e,_t(t),n)}function kr(e,t){let n=t[0];if(typeof n=="function"&&t.length===1){let r=n(e);r&&r!==e&&Et(e,r);return}if(Array.isArray(n)&&t.length===1){for(let r of n)Array.isArray(r)&&wt(e,r[0],r[1]);return}if(n&&typeof n=="object"&&!Array.isArray(n)&&t.length===1){Et(e,n);return}if(Array.isArray(t[1])&&t.length>=3){wt(e,`${n}.${t[1].join(".")}`,t[2]);return}wt(e,String(n),t[1])}function Pt(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Pt);let t={};for(let n of Object.keys(e))t[n]=Pt(e[n]);return t}function ce(e,t){let n=e;for(let r of _t(t)){if(n==null)return;n=n[r]}return n}var Y=class{constructor(t,n={immutable:!0}){this.options=n;this.root=t,this.set=((...r)=>On(()=>kr(this.root,r))),t&&typeof t=="object"&&(de.set(t,{store:this,name:n.name??"store"}),Qe.set(t,t)),X({kind:"store",node:this,handle:()=>this.root,name:n.name})}get state(){return Xe(this.root)}get proxy(){return Xe(this.root)}get accessor(){return(()=>Xe(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return Ie(this.state);let n=this.state;for(let r of _t(t)){if(n==null)return;n=n[r]}return Ie(n)}select(t){return Rt(()=>t(this.state))}subscribe(t){return Ye(()=>t(this.state))}watch(t,n){let r;return Ye(()=>{let o=t(this.state);Object.is(o,r)||(n(o,r),r=o)})}reactive(t){return Rt(()=>this.state[t])}produce(t){this.set((n=>{let r=Pt(n);return t(r),r}))}reconcile(t,n={}){this.set(t)}push(t,...n){let r=ce(this.root,t);this.set(t,r.concat(n))}pop(t){let n=ce(this.root,t).slice(),r=n.pop();return this.set(t,n),r}shift(t){let n=ce(this.root,t).slice(),r=n.shift();return this.set(t,n),r}splice(t,n,r,...o){let s=ce(this.root,t).slice(),i=s.splice(n,r,...o);return this.set(t,s),i}insert(t,n,r){let o=ce(this.root,t).slice();o.splice(n,0,r),this.set(t,o)}removeAt(t,n){let r=ce(this.root,t).slice(),o=r.splice(n,1);return this.set(t,r),o}toObservable(){let[t]=Rn(this.state);return t.toObservable()}dispose(){}},Cr=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function En(e,t){for(let n of Cr)e[n]=t[n].bind(t);e.$=t.reactive.bind(t)}function et(e,t={immutable:!0}){let n=new Y(e,t);return En(n.set,n),[n.proxy,n.set]}function Pn(e,t={}){return new Y(e,{...t,immutable:!1})}function Er(e,t={}){let n=new Y(e(),t);return Ye(()=>n.set(e())),n}function Pr(e,t,n){return Ye(()=>n(t(e)))}function _r(e,t,n){return Rt(()=>t(e),void 0,n)}function Dr(e,t={}){let n=new Y(e,t),r=(()=>n.proxy);return En(r,n),r}function Ie(e){if(e==null||typeof e!="object")return e;let t=e[Fe];return t!==void 0?t:e}function _n(e){return xr(()=>Ie(e))}function Fr(e){return Dt(e)}function Ur(e){return Dt(e)?e[fe]:null}function Ir(e){return e&&typeof e=="object"&&fe in e?e[fe]:null}function Dt(e){return!!e&&typeof e=="object"&&(Ot in e||e.__proxy===!0)}function jr(e){return e}var Nr=Object.freeze({createStore:et,createMutableStore:Pn,batch:On,unwrap:Ie,untrackStore:_n});function Ft(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ft);let t={};for(let n of Object.keys(e))t[n]=Ft(e[n]);return t}function Mr(e){return t=>{let n=Ft(t);return e(n),n}}function qr(e,t={}){return()=>e}function Br(e,t){let[n,r]=et(e,t);return new Proxy(n,{get:(o,s)=>s==="set"?r:o[s],has:(o,s)=>s==="set"||Reflect.has(o,s)})}function Hs(e,t,n){return T(()=>t(e()),void 0,n)}function Ws(e,t,n){return T(()=>e().filter(t),void 0,n)}function Gs(e,t,n,r){return T(()=>e().reduce(t,n),void 0,r)}function zs(e,t,n){return T(()=>e().find(t),void 0,n)}function Xs(e,t,n){return T(()=>e().some(t),void 0,n)}function Ys(e,t,n){return T(()=>e().every(t),void 0,n)}function Qs(e,t,n){return T(()=>[...e()].sort(t),void 0,n)}function Js(e,t){return T(()=>[...new Set(e())],void 0,t)}function Zs(e,t,n){return T(()=>{let r=e.map(o=>o());return t(r)},void 0,n)}function ei(...e){return new L(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())}):N(()=>{t.next(n())}));return()=>{r.forEach(o=>{typeof o=="function"?o():o&&typeof o.unsubscribe=="function"&&o.unsubscribe()})}})}function ti(e,t,n){return T(()=>e()||t(),void 0,n)}function ni(e,t,n,r){return T(()=>n(e(),t()),void 0,r)}function ri(e,t,n){return T(()=>t(e()),void 0,{equals:n,internal:!0})}function oi(e,t,n){return T(()=>{let r=e(),o={};for(let s of t)o[s]=r[s];return o},void 0,n)}function si(e,t,n){return T(()=>{let o={...e()};for(let s of t)delete o[s];return o},void 0,n)}function ii(e,t,n,r){return T(()=>e()?t():n(),void 0,r)}function ai(e,t,n){return T(()=>e()?t():void 0,void 0,n)}function ui(e,t,n){let[r,o]=b(e()),s;return T(()=>{let i=e();clearTimeout(s),s=setTimeout(()=>o(()=>i),t)}),r}function ci(e,t,n){let[r,o]=b(e()),s=0,i;return T(()=>{let u=e(),a=Date.now();a-s>=t?(s=a,o(()=>u)):(clearTimeout(i),i=setTimeout(()=>{s=Date.now(),o(()=>u)},t-(a-s)))}),r}function li(e){let t=e;for(;typeof t=="function";)t=t();return t}var Lr=Symbol.for("signal");var Dn=Symbol("fluixi-proxy"),$r=Symbol.for("signal-node"),je=0,It=1,ot=2,ye=3,S=null,O=null,f=null,nt=null,rt=0,Vr=!1,Ut=!1,pe=0,Kr=1e6,W=new WeakMap,tt=null;var Hr=new Map,Wr=0;function Gr(){return`node_${++Wr}_${Date.now()}`}function zr(e){Pe&&Hr.set(e.id,new WeakRef(e))}function Xr(e,t,n){let r={id:Gr(),type:e,value:t,version:0,equals:n?.equals,name:n?.name,created:Date.now(),updated:Date.now()};return zr(r),r}function Yr(e,t){return e===t}function Un(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}function Qr(e){if(f)f.indexOf(e)===-1&&f.push(e);else if(tt&&tt.running&&!e.pure)tt.effects.indexOf(e)===-1&&tt.effects.push(e);else if(!e.pure||e.computed)Nt(e);else if(e.pure&&!e.computed&&e.accessor){let t=O,n=f;O=null,f=[],e.accessor(),O=t;let r=f;if(f=n,r.length>0){let o=f;st(r),f=o}}}function Fn(e,t){for(let n=0;n<e.length;n++)t(e[n])}function Q(e,t){let n=e;typeof n=="object"&&n&&Dn in n&&delete n[Dn];let r=Xr("signal",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),o=[i,u];W.set(o,new Set);let s;function i(){let a=O;if(a){a.sources?a.sources.indexOf(o)===-1&&a.sources.push(o):a.sources=[o];let l=W.get(o);l&&!l.has(a)&&l.add(a)}return n}function u(a){let l=typeof a=="function"?a(n):a,m=r.equals||Yr;if(t?.equals===!1||!m(n,l)){n=l,r.value=l,r.version++,r.updated=Date.now();let v=W.get(o);if(v&&v.size>0){let E=function(p,F=!1){let R=p.state;if(!(R===ye&&p===O)){if(F&&!p.pure){R===je&&(p.state=It,Vr&&(f!==null&&f.indexOf(p)===-1?f.push(p):w.push(p)));return}if(!x.has(p)&&(x.add(p),p.state=ot,R===je||R===It?w.push(p):!p.pure&&f!==null&&f.indexOf(p)===-1&&f.push(p),p.pure&&p.accessor)){let q=W.get(p.accessor);q&&Fn(Array.from(q),P=>E(P,!0))}}};var d=E;let h=Array.from(v),w=[],x=new Set;Fn(h,E);for(let p of w)Qr(p)}}}return i.toObservable=()=>new L(a=>{let l=!0;return jt(()=>{let d=i();l?l=!1:a.next(d)})}),Object.defineProperty(i,Lr,{value:!0,enumerable:!0}),Object.defineProperty(i,$r,{value:r,enumerable:!1}),o}function jt(e,t,n){let r={fn:e,state:ot,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=M&&be(M);return o&&(r.suspense=o),In(r,t),()=>Te(r)}function In(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++)Te(e.owned[o]);e.owned=null}let n=O,r=S;if(O=e,S=e,rt++,rt>Kr)throw rt=0,O=n,S=r,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=ye;let o=e.fn(t);typeof o=="function"&&(e.cleanups?e.cleanups.push(o):e.cleanups=[o]),e.state===ye&&(e.state=je)}catch(o){if(ut(o)){let s=M&&be(M);s&&(s.increment(),o.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Un(o)}finally{O=n,S=r}}function Nt(e){if(!(e.disposed||!e.fn||e.state===je)&&(e.state===ot||e.state===It||e.state===ye)){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++)Te(e.owned[t]);e.owned=null}e.renderEffect?Nn(e):In(e,e.value)}}function Te(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++)Te(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 st(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 u=O;O=null,o.accessor(),O=u}let i=f.splice(0);for(let u of i)u.pure&&!u.computed&&u.accessor?t.indexOf(u)===-1&&t.push(u):(u.computed||!u.pure)&&n.indexOf(u)===-1&&n.push(u)}f=null;for(let o of n)(o.computed||!o.pure)&&Nt(o)}function J(e){if(f&&pe>0)return e();if(f&&pe===0){let t=f,n=[];f=n,pe++;let r;try{r=e()}finally{pe--,f=t}let o=f;return st(n),f=o,r}pe++,f=[],nt=[];try{return e()}finally{pe--,Jr()}}function Jr(){if(!Ut){Ut=!0,rt=0;try{for(;f&&f.length>0;){let e=f;f=null,st(e)}if(f=null,nt){let e=nt;nt=null;for(let t=0;t<e.length;t++)Nt(e[t])}}finally{Ut=!1}}}function ve(e){let t=O;O=null;try{return e()}finally{O=t}}function jn(e){S&&(S.cleanups?S.cleanups.push(e):S.cleanups=[e])}function Zr(e){let t=Symbol("context"),n=eo(t);return{id:t,Provider:n,defaultValue:e}}function eo(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 to(()=>{r=ve(()=>{let o=S;return o&&(o.contexts||(o.contexts=new Map),o.contexts.set(e,t.value)),xt(()=>t.children)})}),r}}function be(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 to(e,t,n){let r={fn:e,state:ot,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=M&&be(M);return o&&(r.suspense=o),Nn(r),()=>Te(r)}function Nn(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++)Te(e.owned[o]);e.owned=null}let t=O,n=S,r=f;O=e,S=e,f===null&&(f=[]),e.state=ye;try{let o=e.fn(e.value);typeof o=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(o)),e.value=o,e.state===ye&&(e.state=je)}catch(o){if(ut(o)){let s=M&&be(M);s&&(s.increment(),o.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Un(o)}finally{O=t,S=n;let o=f;if(f=r,o!==r&&o&&o.length>0){let s=f;st(o),f=s}}}var M;function Mn(){return M||(M=Zr())}var ee=new Map,Z=new Map,no=0,ro=Symbol.for("signal"),oo=Symbol.for("resource");function Si(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:u=`_auto_${no++}`,staleWhileRevalidate:a=!0}=s,l=u,m=y=>`${l}:${JSON.stringify(y)}`,d=y=>i===1/0||Date.now()-y.timestamp<=i,[v,h]=Q(void 0,{equals:!1}),[w,x]=Q("unresolved",{equals:!1}),[E,p]=Q(void 0,{equals:!1}),[F,R]=Q(void 0,{equals:!1}),[q,P]=Q(!1),[A,U]=Q(0,{equals:!1}),$=Symbol("unset"),G=$,me=!1,te=!1;function j(y,_,D,B){if(Z.has(_)){Z.get(_).then(g=>{B()||z(g,D)},g=>{!B()&&!D&&Mt(g)}),D||R(Z.get(_));return}let ne=Promise.resolve(o(y)).then(g=>(ee.set(_,{value:g,timestamp:Date.now()}),Z.delete(_),g),g=>{throw Z.delete(_),g});if(Z.set(_,ne),!D){ue(ne),R(ne);let g=Ne&&be(Ne);g&&(g.increment(),ne.finally(()=>g.decrement()))}ne.then(g=>{B()||z(g,D)},g=>{!B()&&!D&&Mt(g)})}function z(y,_){J(()=>{h(()=>y),x("ready"),P(!1),R(void 0),p(void 0)})}function Mt(y){J(()=>{p(y),x("errored"),R(void 0)})}let Ne;jt(()=>{Ne===void 0&&(Ne=Mn());let y=r();if(A(),y===!1||y===null||y===void 0){G=$,J(()=>{x("unresolved"),R(void 0),p(void 0)});return}let _=me,D=te;me=!1,te=!1;let B=m(y);D&&ee.delete(B);let ne=G===$||y!==G;G=y;let g=!1;jn(()=>{g=!0});let re=ee.get(B);if(re&&d(re)&&!_&&!D){(ve(w)!=="ready"||ve(v)!==re.value)&&J(()=>{h(()=>re.value),x("ready"),P(!1),p(void 0)});return}if(re&&a&&!D){J(()=>{h(()=>re.value),x("ready"),P(!0),p(void 0),R(void 0)}),j(y,B,!0,()=>g);return}let qt=ve(w),qn=qt==="ready"||qt==="refreshing";J(()=>{x(qn?"refreshing":"pending"),p(void 0),P(!1)}),j(y,B,!1,()=>g)});let Me=(()=>{let y=E();if(y)throw y;if(w()==="pending"){let D=F();if(D)throw D}return v()});return Object.defineProperty(Me,oo,{value:!0,enumerable:!0}),Object.defineProperty(Me,ro,{value:!0,enumerable:!0}),Object.defineProperties(Me,{state:{get:w},loading:{get:()=>{let y=w();return y==="pending"||y==="refreshing"}},error:{get:E},latest:{get:v},stale:{get:q}}),[Me,{mutate:h,refetch:()=>{me=!0,U(y=>y+1)},invalidate:()=>{let y=ve(r);y!=null&&y!==!1&&ee.delete(m(y)),te=!0,U(_=>_+1)}}]}function xi(e){let t=`${e}:`;for(let n of ee.keys())n.startsWith(t)&&ee.delete(n)}function gi(){ee.clear(),Z.clear()}export{gr as $NAME,fe as $NODE,as as $PROXY,Fe as $RAW,At as $SELF,is as $SIGNAL,wr as $STORE,kt as $TRACK,L as Observable,ct as SafeSubscriber,hr as Signal,Y as Store,Nr as StoreAPI,Lt as Subject,Se as Subscriber,he as Subscription,gt as SuspenseContext,it as VERSION,Pe as __DEV__,H as batch,gi as clearAllCachedResources,xi as clearCachedResourceNamespace,Zs as combineSignal,ei as combineSignals,Si as createCachedResource,Wn as createChildOwner,er as createComputed,Er as createComputedStore,Ae as createContext,fr as createDebounce,yr as createDebouncedResource,bn as createDebouncedSignal,lr as createDeferred,N as createEffect,br as createErrorBoundary,T as createMemo,Pn as createMutableStore,tr as createRenderEffect,_e as createResource,ae as createRoot,cr as createSelector,b as createSignal,et as createStore,Pr as createStoreEffect,_r as createStoreMemo,Tr as createSuspenseBoundary,ui as debounceSignal,Gn as disposeScope,Js as distinctSignal,Os as effect,Ys as everySignal,Ws as filterSignal,zs as findSignal,rr as flush,Ur as getNode,$e as getOwner,He as getServerData,Ir as getStoreNode,ai as guardSignal,No as indexArray,ln as isComponent,un as isMemo,zn as isOwnerDisposed,dn as isProvider,cn as isResource,Ke as isSignal,Fr as isStore,Dt as isStoreProxy,fn as isSuspense,jo as keyArray,Tt as makeArrayFlat,Io as mapArray,Hs as mapSignal,ws as memo,ti as mergeSignal,jr as modifiable,We as nextResourceId,Vt as observeReactiveNodes,si as omitSignal,or as on,C as onCleanup,yo as operate,oi as pickSignal,Mr as produceUtil,ke as provide,mr as provideErrorBoundary,vr as provideSuspense,xt as readChildren,li as readSignal,qr as reconcileUtil,Gs as reduceSignal,$n as reportReactiveBinding,xe as reportReactiveContext,lt as reportReactiveContextCreated,Kn as reportReactiveDirective,Vn as reportReactiveProps,Ge as reportResourceData,Sr as resource,Ce as runWithOwner,ri as selectSignal,nn as setOwner,vn as setResourceDataSink,Tn as setResourceIdSource,pn as setResourceTracker,yn as setServerDataGetter,gs as signal,Xs as someSignal,Qs as sortSignal,an as startTransition,Br as store,ci as throttleSignal,ue as trackResourcePromise,I as untrack,_n as untrackStore,Ie as unwrap,Xn as useContext,nr as useTransition,ii as whenSignal,Dr as wrap,ni as zipSignal};
|
package/dist/lib/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var nt=Object.defineProperty;var Qn=Object.getOwnPropertyDescriptor;var Jn=Object.getOwnPropertyNames;var Zn=Object.prototype.hasOwnProperty;var er=(e,t)=>{for(var n in t)nt(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&&nt(e,o,{get:()=>t[o],enumerable:!(r=Qn(t,o))||r.enumerable});return e};var nr=e=>tr(nt({},"__esModule",{value:!0}),e);var yo={};er(yo,{$NAME:()=>Rn,$NODE:()=>Q,$PROXY:()=>Sr,$RAW:()=>De,$SELF:()=>Ge,$SIGNAL:()=>vr,$STORE:()=>An,$TRACK:()=>ze,Observable:()=>N,SafeSubscriber:()=>Ne,Signal:()=>mn,Store:()=>H,StoreAPI:()=>jn,Subject:()=>st,Subscriber:()=>ie,Subscription:()=>se,SuspenseContext:()=>He,VERSION:()=>jt,__DEV__:()=>de,batch:()=>$,clearAllCachedResources:()=>To,clearCachedResourceNamespace:()=>po,combineSignal:()=>Ir,combineSignals:()=>Mr,createCachedResource:()=>fo,createChildOwner:()=>Ht,createComputed:()=>tn,createComputedStore:()=>_n,createContext:()=>ce,createDebounce:()=>cn,createDebouncedResource:()=>ln,createDebouncedSignal:()=>Rt,createDeferred:()=>an,createEffect:()=>M,createErrorBoundary:()=>Tn,createMemo:()=>T,createMutableStore:()=>kt,createRenderEffect:()=>nn,createResource:()=>pe,createRoot:()=>Y,createSelector:()=>un,createSignal:()=>h,createStore:()=>Ue,createStoreEffect:()=>Fn,createStoreMemo:()=>Dn,createSuspenseBoundary:()=>fn,debounceSignal:()=>Kr,disposeScope:()=>Wt,distinctSignal:()=>Ur,effect:()=>wr,everySignal:()=>Fr,filterSignal:()=>Er,findSignal:()=>kr,flush:()=>on,getNode:()=>Mn,getOwner:()=>Ae,getServerData:()=>Pe,getStoreNode:()=>qn,guardSignal:()=>Vr,indexArray:()=>dr,isComponent:()=>pt,isMemo:()=>ft,isOwnerDisposed:()=>Gt,isProvider:()=>yt,isResource:()=>dt,isSignal:()=>Ee,isStore:()=>In,isStoreProxy:()=>Xe,isSuspense:()=>Tt,keyArray:()=>fr,makeArrayFlat:()=>$e,mapArray:()=>lr,mapSignal:()=>Cr,memo:()=>gr,mergeSignal:()=>qr,modifiable:()=>Nn,nextResourceId:()=>ke,omitSignal:()=>Lr,on:()=>sn,onCleanup:()=>F,operate:()=>rr,pickSignal:()=>Br,produceUtil:()=>Bn,provide:()=>le,provideErrorBoundary:()=>yn,provideSuspense:()=>dn,readChildren:()=>Ke,readSignal:()=>Wr,reconcileUtil:()=>Ln,reduceSignal:()=>Pr,reportResourceData:()=>_e,resource:()=>hn,runWithOwner:()=>fe,selectSignal:()=>jr,setOwner:()=>at,setResourceDataSink:()=>wt,setResourceIdSource:()=>gt,setResourceTracker:()=>St,setServerDataGetter:()=>xt,signal:()=>xr,someSignal:()=>_r,sortSignal:()=>Dr,startTransition:()=>lt,store:()=>$n,throttleSignal:()=>Hr,trackResourcePromise:()=>X,untrack:()=>D,untrackStore:()=>_t,unwrap:()=>ye,useContext:()=>zt,useTransition:()=>rn,whenSignal:()=>$r,wrap:()=>Un,zipSignal:()=>Nr});module.exports=nr(yo);var jt="1.0.0-alpha.81";function rt(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function Bt(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 ot(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(rt(r)&&!(r instanceof e))try{r()}catch(o){console.error("Error in unsubscribe function:",o)}else if(Bt(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(rt(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())}},Ne=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 Ne(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 st=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 Lt=0,$t=1,ge=2,je=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 je{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(ge);it(this)}}peek(){return this._value}},K=class extends je{constructor(n,r){super();this._threw=!1;this._initialized=!1;this.state=ge;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===$t&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===ge)break}(this.state===ge||!this._initialized)&&this.recompute(),this.state=Lt}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(ge);it(this)}}markDirty(n){if(this.state>=n)return;let r=this.state===Lt;if(this.state=n,r){if(this.observers)for(let o of[...this.observers])o.markDirty($t);it(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function it(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 we(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function Vt(){return a.consumer}function Kt(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function Ht(e){let t=Re(e);return e&&(e.owned??=[]).push(t),t}function Wt(e,t=!0){Oe(e,t)}function Gt(e){return!!e&&e.disposed===!0}function Re(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=Re(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 zt(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 Be(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=Re(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 Yt(e){a.onSuspend=e}function Xt(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function Qt(e){a.onError=e}function Ae(){return a.owner}function at(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 Oe(e,t=!0){if(!e.disposed){if(e.owned){for(let n=e.owned.length-1;n>=0;n--)Oe(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=Re(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let n=a.owner;a.owner=t;try{return e(()=>Oe(t))}finally{a.owner=n}}function Jt(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(Ce)))}function Ce(){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&&Ce()}function ct(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&Ce()}}var ut=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=Re(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new K(()=>{Oe(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),Oe(this.owner))}};function Le(e){let t=new ut(e);return()=>t.dispose()}function ur(e){return!!e&&typeof e.then=="function"}Jt(()=>{});var en=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,en,{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=Ae(),s=new K(()=>fe(o,()=>{try{return r=e(r)}catch(c){if(ur(c))return Xt(c),r;throw c}}),{equals:n?.equals}),i=(()=>s.get());return Object.defineProperty(i,en,{value:!0,enumerable:!0}),Object.defineProperty(i,ar,{value:!0,enumerable:!0}),i}function M(e,t){let n=t;return Le(()=>{n=e(n)})}function tn(e,t){let n=t;Le(()=>{n=e(n)})}function nn(e,t){let n=t;return Le(()=>{n=e(n)})}function $(e){return ct(e)}function D(e){return we(e)}function lt(e){return ct(e),Promise.resolve()}function rn(){return[()=>!1,lt]}function on(){return Ce(),Promise.resolve()}function sn(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=we(()=>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 pr=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,de=typeof process>"u"?pr:!1,Tr=Symbol.for("signal"),yr=Symbol.for("memo"),mr=Symbol.for("resource");function Ee(e){return typeof e=="function"&&e[Tr]===!0}function ft(e){return typeof e=="function"&&e[yr]===!0}function dt(e){return typeof e=="function"&&e[mr]===!0}function pt(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Tt(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function yt(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function $e(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?$e(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var mt=null;function St(e){mt=e}function X(e){mt&&mt(e)}var ht=null;function xt(e){ht=e}function Pe(e){return ht?ht(e):void 0}var bt=null;function gt(e){bt=e}function ke(){return bt?bt():void 0}var vt=null;function wt(e){vt=e}function _e(e,t){vt&&vt(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 hr(e){return!!e&&typeof e.then=="function"}var Ot=Symbol();function pe(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:ke(),i=s!==void 0?Pe(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=Ot,A=!1;M(()=>{let C=r();if(E(),C===!1||C===null||C===void 0){U=Ot,$(()=>{v("unresolved"),x(void 0),d(void 0)});return}let I=A;if(A=!1,U!==Ot&&C===U&&!I)return;if(U=C,c){c=!1;return}let V=!1;F(()=>V=!0);let G=D(m),xe=D(u),ne=G==="ready"||G==="refreshing";$(()=>{v(ne?"refreshing":"pending"),d(void 0)});try{let q=o(C,{value:xe,refetching:ne});hr(q)?(x(q),X(q),q.then(z=>{V||(s!==void 0&&_e(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 Rt(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 br(e){return e!=null&&e!==""}function ln(e,t,n={}){let{delay:r=300,initialValue:o,shouldFetch:s=br}=n,[i,c,u]=Rt(e,r),l=()=>s(i())?i():!1,[b,{refetch:d}]=pe(l,t,o===void 0?{}:{initialValue:o});return[b,{...u,query:i,setQuery:c,refetch:d}]}function Ve(e){if(typeof e=="function"&&!e.length){let t=e();return Ee(t)?t:Ve(t)}if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let r=Ve(e[n]);Array.isArray(r)?t.push.apply(t,r):t.push(r)}return t}return e}function Ke(e){let t=T(e);return de?T(()=>Ve(t()),void 0,{name:"children"}):T(()=>Ve(t()))}var He=ce();Yt((e,t)=>{let n=Be(t,He);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(He,e,t)}var pn=ce();Qt((e,t)=>{let n=Be(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:we,currentComputed:Vt,hasSinks:Kt}};var vr=Symbol.for("signal"),Sr=Symbol.for("fluixi-proxy");function xr(e,t){let[n,r]=h(e,t);return Object.assign(n,{set:r})}function gr(e,t,n){return T(e,t,n)}function wr(e,t){return M(e,t)}function hn(...e){let[t,n]=pe(...e);return Object.assign(t,n)}var g=require("@fluixi/reactive/signal"),De=Symbol("store-raw"),Q=Symbol("store-node"),bn=Symbol("store-has"),Ge=Symbol("store-self"),ze=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 Ye(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=Ye(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 We(e){if(!En(e))return e;let t=Sn.get(e);if(t)return t;let n=new Proxy(e,Or);return Sn.set(e,n),n}var Or={get(e,t,n){if(t===De||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===ze||t===Ge)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(Ye(e),t,r)();return En(s)?We(s):s},set(){return!0},deleteProperty(e,t){return t in e&&Fe(e,t,void 0),!0},has(e,t){return t===De||t===g.$PROXY||t===Q||t===bn||t===Ge||t===ze?!0:(xn(Ye(e),t,e[t])(),t in e)},ownKeys(e){return gn(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function Fe(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=Ye(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 Ct(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)?Ct(o,r):Fe(e,n,r)}}function Pt(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])?[]:{},Fe(e,i,c)),e=c}let o=t[r];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)Fe(e,s,On(n,e[s]));return}Fe(e,o,On(n,e[o]))}function At(e,t,n){Pn(e,Pt(t),n)}function Rr(e,t){let n=t[0];if(typeof n=="function"&&t.length===1){let r=n(e);r&&r!==e&&Ct(e,r);return}if(Array.isArray(n)&&t.length===1){for(let r of n)Array.isArray(r)&&At(e,r[0],r[1]);return}if(n&&typeof n=="object"&&!Array.isArray(n)&&t.length===1){Ct(e,n);return}if(Array.isArray(t[1])&&t.length>=3){At(e,`${n}.${t[1].join(".")}`,t[2]);return}At(e,String(n),t[1])}function Et(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Et);let t={};for(let n of Object.keys(e))t[n]=Et(e[n]);return t}function Te(e,t){let n=e;for(let r of Pt(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)(()=>Rr(this.root,r)))}get state(){return We(this.root)}get proxy(){return We(this.root)}get accessor(){return(()=>We(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return ye(this.state);let n=this.state;for(let r of Pt(t)){if(n==null)return;n=n[r]}return ye(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=Et(n);return t(r),r}))}reconcile(t,n={}){this.set(t)}push(t,...n){let r=Te(this.root,t);this.set(t,r.concat(n))}pop(t){let n=Te(this.root,t).slice(),r=n.pop();return this.set(t,n),r}shift(t){let n=Te(this.root,t).slice(),r=n.shift();return this.set(t,n),r}splice(t,n,r,...o){let s=Te(this.root,t).slice(),i=s.splice(n,r,...o);return this.set(t,s),i}insert(t,n,r){let o=Te(this.root,t).slice();o.splice(n,0,r),this.set(t,o)}removeAt(t,n){let r=Te(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(){}},Ar=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function kn(e,t){for(let n of Ar)e[n]=t[n].bind(t);e.$=t.reactive.bind(t)}function Ue(e,t={immutable:!0}){let n=new H(e,t);return kn(n.set,n),[n.proxy,n.set]}function kt(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 ye(e){if(e==null||typeof e!="object")return e;let t=e[De];return t!==void 0?t:e}function _t(e){return(0,g.untrack)(()=>ye(e))}function In(e){return Xe(e)}function Mn(e){return Xe(e)?e[Q]:null}function qn(e){return e&&typeof e=="object"&&Q in e?e[Q]:null}function Xe(e){return!!e&&typeof e=="object"&&(g.$PROXY in e||e.__proxy===!0)}function Nn(e){return e}var jn=Object.freeze({createStore:Ue,createMutableStore:kt,batch:g.batch,unwrap:ye,untrackStore:_t});function Ft(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ft);let t={};for(let n of Object.keys(e))t[n]=Ft(e[n]);return t}function Bn(e){return t=>{let n=Ft(t);return e(n),n}}function Ln(e,t={}){return()=>e}function $n(e,t){let[n,r]=Ue(e,t);return new Proxy(n,{get:(o,s)=>s==="set"?r:o[s],has:(o,s)=>s==="set"||Reflect.has(o,s)})}function Cr(e,t,n){return T(()=>t(e()),void 0,n)}function Er(e,t,n){return T(()=>e().filter(t),void 0,n)}function Pr(e,t,n,r){return T(()=>e().reduce(t,n),void 0,r)}function kr(e,t,n){return T(()=>e().find(t),void 0,n)}function _r(e,t,n){return T(()=>e().some(t),void 0,n)}function Fr(e,t,n){return T(()=>e().every(t),void 0,n)}function Dr(e,t,n){return T(()=>[...e()].sort(t),void 0,n)}function Ur(e,t){return T(()=>[...new Set(e())],void 0,t)}function Ir(e,t,n){return T(()=>{let r=e.map(o=>o());return t(r)},void 0,n)}function Mr(...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 qr(e,t,n){return T(()=>e()||t(),void 0,n)}function Nr(e,t,n,r){return T(()=>n(e(),t()),void 0,r)}function jr(e,t,n){return T(()=>t(e()),void 0,{equals:n,internal:!0})}function Br(e,t,n){return T(()=>{let r=e(),o={};for(let s of t)o[s]=r[s];return o},void 0,n)}function Lr(e,t,n){return T(()=>{let o={...e()};for(let s of t)delete o[s];return o},void 0,n)}function $r(e,t,n,r){return T(()=>e()?t():n(),void 0,r)}function Vr(e,t,n){return T(()=>e()?t():void 0,void 0,n)}function Kr(e,t,n){let[r,o]=h(e()),s;return T(()=>{let i=e();clearTimeout(s),s=setTimeout(()=>o(()=>i),t)}),r}function Hr(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 Wr(e){let t=e;for(;typeof t=="function";)t=t();return t}var Gr=Symbol.for("signal");var Vn=Symbol("fluixi-proxy"),zr=Symbol.for("signal-node"),Ie=0,Ut=1,et=2,he=3,S=null,R=null,f=null,Je=null,Ze=0,Yr=!1,Dt=!1,me=0,Xr=1e6,W=new WeakMap,Qe=null;var Qr=new Map,Jr=0;function Zr(){return`node_${++Jr}_${Date.now()}`}function eo(e){de&&Qr.set(e.id,new WeakRef(e))}function to(e,t,n){let r={id:Zr(),type:e,value:t,version:0,equals:n?.equals,name:n?.name,created:Date.now(),updated:Date.now()};return eo(r),r}function no(e,t){return e===t}function Hn(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}function ro(e){if(f)f.indexOf(e)===-1&&f.push(e);else if(Qe&&Qe.running&&!e.pure)Qe.effects.indexOf(e)===-1&&Qe.effects.push(e);else if(!e.pure||e.computed)Mt(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;tt(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=to("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||no;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===he&&p===R)){if(U&&!p.pure){A===Ie&&(p.state=Ut,Yr&&(f!==null&&f.indexOf(p)===-1?f.push(p):O.push(p)));return}if(!x.has(p)&&(x.add(p),p.state=et,A===Ie||A===Ut?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)ro(p)}}}return i.toObservable=()=>new N(u=>{let l=!0;return It(()=>{let d=i();l?l=!1:u.next(d)})}),Object.defineProperty(i,Gr,{value:!0,enumerable:!0}),Object.defineProperty(i,zr,{value:r,enumerable:!1}),o}function It(e,t,n){let r={fn:e,state:et,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&&Se(j);return o&&(r.suspense=o),Wn(r,t),()=>be(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++)be(e.owned[o]);e.owned=null}let n=R,r=S;if(R=e,S=e,Ze++,Ze>Xr)throw Ze=0,R=n,S=r,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=he;let o=e.fn(t);typeof o=="function"&&(e.cleanups?e.cleanups.push(o):e.cleanups=[o]),e.state===he&&(e.state=Ie)}catch(o){if(ot(o)){let s=j&&Se(j);s&&(s.increment(),o.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Hn(o)}finally{R=n,S=r}}function Mt(e){if(!(e.disposed||!e.fn||e.state===Ie)&&(e.state===et||e.state===Ut||e.state===he)){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++)be(e.owned[t]);e.owned=null}e.renderEffect?zn(e):Wn(e,e.value)}}function be(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++)be(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 tt(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)&&Mt(o)}function Z(e){if(f&&me>0)return e();if(f&&me===0){let t=f,n=[];f=n,me++;let r;try{r=e()}finally{me--,f=t}let o=f;return tt(n),f=o,r}me++,f=[],Je=[];try{return e()}finally{me--,oo()}}function oo(){if(!Dt){Dt=!0,Ze=0;try{for(;f&&f.length>0;){let e=f;f=null,tt(e)}if(f=null,Je){let e=Je;Je=null;for(let t=0;t<e.length;t++)Mt(e[t])}}finally{Dt=!1}}}function ve(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 so(e){let t=Symbol("context"),n=io(t);return{id:t,Provider:n,defaultValue:e}}function io(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 uo(()=>{r=ve(()=>{let o=S;return o&&(o.contexts||(o.contexts=new Map),o.contexts.set(e,t.value)),Ke(()=>t.children)})}),r}}function Se(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 uo(e,t,n){let r={fn:e,state:et,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&&Se(j);return o&&(r.suspense=o),zn(r),()=>be(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++)be(e.owned[o]);e.owned=null}let t=R,n=S,r=f;R=e,S=e,f===null&&(f=[]),e.state=he;try{let o=e.fn(e.value);typeof o=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(o)),e.value=o,e.state===he&&(e.state=Ie)}catch(o){if(ot(o)){let s=j&&Se(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;tt(o),f=s}}}var j;function Yn(){return j||(j=so())}var te=new Map,ee=new Map,ao=0,co=Symbol.for("signal"),lo=Symbol.for("resource");function fo(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_${ao++}`,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,xe=!1,ne=!1;function q(y,k,_,L){if(ee.has(k)){ee.get(k).then(w=>{L()||z(w,_)},w=>{!L()&&!_&&qt(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=Me&&Se(Me);w&&(w.increment(),re.finally(()=>w.decrement()))}re.then(w=>{L()||z(w,_)},w=>{!L()&&!_&&qt(w)})}function z(y,k){Z(()=>{v(()=>y),x("ready"),P(!1),A(void 0),p(void 0)})}function qt(y){Z(()=>{p(y),x("errored"),A(void 0)})}let Me;It(()=>{Me===void 0&&(Me=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=xe,_=ne;xe=!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&&!_){(ve(O)!=="ready"||ve(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 Nt=ve(O),Xn=Nt==="ready"||Nt==="refreshing";Z(()=>{x(Xn?"refreshing":"pending"),p(void 0),P(!1)}),q(y,L,!1,()=>w)});let qe=(()=>{let y=E();if(y)throw y;if(O()==="pending"){let _=U();if(_)throw _}return m()});return Object.defineProperty(qe,lo,{value:!0,enumerable:!0}),Object.defineProperty(qe,co,{value:!0,enumerable:!0}),Object.defineProperties(qe,{state:{get:O},loading:{get:()=>{let y=O();return y==="pending"||y==="refreshing"}},error:{get:E},latest:{get:m},stale:{get:B}}),[qe,{mutate:v,refetch:()=>{xe=!0,I(y=>y+1)},invalidate:()=>{let y=ve(r);y!=null&&y!==!1&&te.delete(b(y)),ne=!0,I(k=>k+1)}}]}function po(e){let t=`${e}:`;for(let n of te.keys())n.startsWith(t)&&te.delete(n)}function To(){te.clear(),ee.clear()}
|
|
1
|
+
"use strict";var Tt=Object.defineProperty;var hr=Object.getOwnPropertyDescriptor;var Sr=Object.getOwnPropertyNames;var xr=Object.prototype.hasOwnProperty;var gr=(e,t)=>{for(var n in t)Tt(e,n,{get:t[n],enumerable:!0})},wr=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Sr(t))!xr.call(e,o)&&o!==n&&Tt(e,o,{get:()=>t[o],enumerable:!(r=hr(t,o))||r.enumerable});return e};var Or=e=>wr(Tt({},"__esModule",{value:!0}),e);var Bo={};gr(Bo,{$NAME:()=>Gn,$NODE:()=>ee,$PROXY:()=>Vr,$RAW:()=>xe,$SELF:()=>ot,$SIGNAL:()=>$r,$STORE:()=>zn,$TRACK:()=>st,Observable:()=>q,SafeSubscriber:()=>Ge,Signal:()=>Bn,Store:()=>G,StoreAPI:()=>ar,Subject:()=>mt,Subscriber:()=>ce,Subscription:()=>ue,SuspenseContext:()=>nt,VERSION:()=>We,__DEV__:()=>be,batch:()=>V,clearAllCachedResources:()=>qo,clearCachedResourceNamespace:()=>Mo,combineSignal:()=>io,combineSignals:()=>ao,createCachedResource:()=>No,createChildOwner:()=>vn,createComputed:()=>An,createComputedStore:()=>Zn,createContext:()=>ye,createDebounce:()=>Fn,createDebouncedResource:()=>Un,createDebouncedSignal:()=>Bt,createDeferred:()=>Dn,createEffect:()=>N,createErrorBoundary:()=>Mn,createMemo:()=>y,createMutableStore:()=>Wt,createRenderEffect:()=>kn,createResource:()=>me,createRoot:()=>J,createSelector:()=>_n,createSignal:()=>b,createStore:()=>$e,createStoreEffect:()=>er,createStoreMemo:()=>tr,createSuspenseBoundary:()=>In,debounceSignal:()=>vo,disposeScope:()=>bn,distinctSignal:()=>so,effect:()=>Wr,everySignal:()=>ro,filterSignal:()=>Zr,findSignal:()=>to,flush:()=>En,getNode:()=>or,getOwner:()=>Ue,getServerData:()=>Ne,getStoreNode:()=>sr,guardSignal:()=>To,indexArray:()=>Ir,isComponent:()=>Ct,isMemo:()=>At,isOwnerDisposed:()=>mn,isProvider:()=>Pt,isResource:()=>kt,isSignal:()=>je,isStore:()=>rr,isStoreProxy:()=>ct,isSuspense:()=>Et,keyArray:()=>Ur,makeArrayFlat:()=>Ze,mapArray:()=>Fr,mapSignal:()=>Jr,memo:()=>Hr,mergeSignal:()=>uo,modifiable:()=>ir,nextResourceId:()=>Me,observeReactiveNodes:()=>ht,omitSignal:()=>po,on:()=>Pn,onCleanup:()=>k,operate:()=>Rr,pickSignal:()=>fo,produceUtil:()=>ur,provide:()=>Te,provideErrorBoundary:()=>qn,provideSuspense:()=>jn,readChildren:()=>tt,readSignal:()=>mo,reconcileUtil:()=>cr,reduceSignal:()=>eo,reportReactiveBinding:()=>cn,reportReactiveContext:()=>le,reportReactiveContextCreated:()=>Xe,reportReactiveDirective:()=>fn,reportReactiveProps:()=>ln,reportResourceData:()=>qe,resource:()=>Ln,runWithOwner:()=>ve,selectSignal:()=>lo,setOwner:()=>wt,setResourceDataSink:()=>Mt,setResourceIdSource:()=>Nt,setResourceTracker:()=>It,setServerDataGetter:()=>jt,signal:()=>Kr,someSignal:()=>no,sortSignal:()=>oo,startTransition:()=>Rt,store:()=>lr,throttleSignal:()=>bo,trackResourcePromise:()=>Z,untrack:()=>U,untrackStore:()=>Gt,unwrap:()=>we,useContext:()=>hn,useTransition:()=>Cn,whenSignal:()=>yo,wrap:()=>nr,zipSignal:()=>co});module.exports=Or(Bo);var We="1.0.0-alpha.83";function vt(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function tn(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 bt(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}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: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(vt(r)&&!(r instanceof e))try{r()}catch(o){console.error("Error in unsubscribe function:",o)}else if(tn(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(vt(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 ce=class extends ue{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())}},Ge=class extends ce{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 ce(e.next,e.error,e.complete)}var q=class extends ue{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 ce?o=t:o=new Ge(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 mt=class extends q{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 q(r=>this.subscribe(r))}};var Ar="__fluixi_signal_next_state__",kr=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},c=globalThis[Ar]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:kr,onSuspend:null,onError:null,observer:null};function ht(e){return c.observer=e,()=>{c.observer===e&&(c.observer=null)}}var E=[],ze;function rn(e,t){if(!c.observer)return t();let n=ze;ze=e;try{return t()}finally{ze=n}}function Q(e){let t=c.observer;t&&t.created(e.parents===void 0?{...e,parents:E,origin:e.origin??ze}:e)}function on(e){return c.observer?(E.push(e),!0):!1}function sn(){E.pop()}function an(e){c.observer?.ran?.(e)}function un(e,t){c.observer?.wrote?.(e,t)}function cn(e,t,n,r){let o=c.observer;!o?.bound||!E.length||o.bound(E[E.length-1],e,t,n,r)}function ln(e){let t=c.observer;!t?.props||!E.length||!e||t.props(E[E.length-1],e)}function fn(e,t,n,r){let o=c.observer;!o?.directive||!E.length||o.directive(E[E.length-1],e,t,n,r)}function Xe(e){c.observer?.contextCreated?.(e)}function le(e,t,n){let r=c.observer;!r?.context||!E.length||r.context(E[E.length-1],e,t,n)}function St(e,t,n){c.observer?.moved?.(e,t,n)}function H(e){c.observer?.disposed?.(e)}var Cr="__FLUIXI_DEVTOOLS_HOOK__",nn=globalThis[Cr];if(typeof nn?.inject=="function")try{nn.inject({observeReactiveNodes:ht,version:We})}catch{}function fe(){return c.observer!=null}var dn=0,pn=1,Pe=2,Ye=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(c.untracked)return;let t=c.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},de=class extends Ye{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++,un(this,c.consumer),this.observers)for(let n of[...this.observers])n.markDirty(Pe);xt(this)}}peek(){return this._value}},W=class extends Ye{constructor(n,r){super();this._threw=!1;this._initialized=!1;this.state=Pe;this.sources=null;this._fn=n,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){if(c.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===pn&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===Pe)break}(this.state===Pe||!this._initialized)&&this.recompute(),this.state=dn}recompute(){if(this.sources){for(let l of this.sources)l.observers?.delete(this);this.sources.clear()}let n=c.consumer,r=c.untracked,o=on(this);c.consumer=this,c.untracked=!1;let s,i=!1,u;try{s=this._fn()}catch(l){i=!0,u=l,s=this._value}finally{c.consumer=n,c.untracked=r,o&&sn()}let a=!this._initialized||this._threw!==i||(i?u!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=i,this._error=u,this._value=s,an(this),a){if(this.version++,this.observers)for(let l of[...this.observers])l.markDirty(Pe);xt(this)}}markDirty(n){if(this.state>=n)return;let r=this.state===dn;if(this.state=n,r){if(this.observers)for(let o of[...this.observers])o.markDirty(pn);xt(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function xt(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var pe=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 _e(e){if(c.untracked)return e();c.untracked=!0;try{return e()}finally{c.untracked=!1}}function yn(){return c.consumer}function Tn(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function vn(e){let t=Fe(e);return e&&(e.owned??=[]).push(t),t}function bn(e,t=!0){De(e,t)}function mn(e){return!!e&&e.disposed===!0}function Fe(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function ye(e,t){let n=Symbol(t??"context");return Xe(n),{id:n,defaultValue:e,Provider:o=>{le(n,"provide",o.value);let s=c.owner,i=Fe(s);(i.contexts=new Map).set(n,o.value),s&&(s.owned??=[]).push(i),c.owner=i;try{return o.children}finally{c.owner=s}}}}function hn(e){let t=c.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id)){let n=t.contexts.get(e.id);return le(e.id,"read",n),n}t=t.parent}return le(e.id,"read",e.defaultValue),e.defaultValue}function Qe(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 Te(e,t,n){let r=Fe(c.owner);(r.contexts=new Map).set(e.id,t),c.owner&&(c.owner.owned??=[]).push(r);let o=c.owner;c.owner=r;try{return n()}finally{c.owner=o}}function Sn(e){c.onSuspend=e}function xn(e){return c.onSuspend?(c.onSuspend(e,c.owner),!0):!1}function gn(e){c.onError=e}function Ue(){return c.owner}function wt(e){let t=c.owner;return c.owner=e,t}function ve(e,t){let n=c.owner;c.owner=e;try{return t()}finally{c.owner=n}}function k(e){if(c.owner){if(c.owner.disposed){e();return}(c.owner.cleanups??=[]).push(e)}}function De(e,t=!0){if(!e.disposed){if(e.owned){for(let n=e.owned.length-1;n>=0;n--)De(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 J(e){let t=Fe(c.owner);c.owner&&(c.owner.owned??=[]).push(t);let n=c.owner;c.owner=t;try{return e(()=>De(t))}finally{c.owner=n}}function wn(e){c.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function Er(e){e.queued||(e.queued=!0,c.queue.push(e),!c.scheduled&&c.batchDepth===0&&(c.scheduled=!0,c.hostSchedule(Ie)))}function Ie(){if(c.scheduled=!1,c.flushing)return;c.flushing=!0;let e=0;try{for(;c.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=c.queue;c.queue=[];for(let n of t)n.queued=!1,n.disposed||n.run()}}finally{c.flushing=!1}}function On(){c.batchDepth===0&&Ie()}function Ot(e){c.batchDepth++;try{return e()}finally{--c.batchDepth===0&&Ie()}}var gt=class{constructor(t,n=!1){this.queued=!1;this.disposed=!1;this.owner=Fe(c.owner),c.owner&&(c.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new W(()=>{De(this.owner,!1),ve(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),Q({kind:"effect",node:this.computed,handle:this,internal:!n}),this.watcher=new pe(()=>Er(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"&&c.onSuspend){c.onSuspend(t,this.owner);return}if(c.onError&&c.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,H(this.computed),this.watcher.unwatch(this.computed),De(this.owner))}};function Je(e,t=!1){let n=new gt(e,t);return()=>n.dispose()}function Pr(e){return!!e&&typeof e.then=="function"}wn(()=>{});var Rn=Symbol.for("signal"),_r=Symbol.for("memo"),Dr=Symbol.for("signal-node");function b(e,t){let n=new de(e,{equals:t?.equals}),r=(()=>n.get()),o=(s=>{let i=typeof s=="function"?s(n.peek()):s;return n.set(i),On(),i});return Object.defineProperty(r,Rn,{value:!0,enumerable:!0}),Object.defineProperty(r,Dr,{value:{get value(){return n.peek()},get version(){return n.version}},enumerable:!1}),Q({kind:"signal",node:n,handle:r,name:t?.name,set:o}),fe()&&k(()=>H(n)),[r,o]}function y(e,t,n){let r=t,o=Ue(),s=new W(()=>ve(o,()=>{try{return r=e(r)}catch(u){if(Pr(u))return xn(u),r;throw u}}),{equals:n?.equals}),i=(()=>s.get());return Object.defineProperty(i,Rn,{value:!0,enumerable:!0}),Object.defineProperty(i,_r,{value:!0,enumerable:!0}),Q({kind:"memo",node:s,handle:i,name:n?.name}),fe()&&k(()=>H(s)),i}function N(e,t){let n=t;return Je(()=>{n=e(n)},!0)}function An(e,t){let n=t;Je(()=>{n=e(n)})}function kn(e,t){let n=t;return Je(()=>{n=e(n)})}function V(e){return Ot(e)}function U(e){return _e(e)}function Rt(e){return Ot(e),Promise.resolve()}function Cn(){return[()=>!1,Rt]}function En(){return Ie(),Promise.resolve()}function Pn(e,t,n){let r=Array.isArray(e),o,s=n?.defer??!1;return i=>{let u=r?e.map(l=>l()):e();if(s){s=!1,o=u;return}let a=_e(()=>t(u,o,i));return o=u,a}}function Fr(e,t,n){let r=[];return k(()=>{for(let o of r)o.dispose();r=[]}),y(()=>{let o=e()||[];return U(()=>{if(o.length===0){for(let a of r)a.dispose();return r=[],n?.fallback?n.fallback():[]}let s=new Map;for(let a of r)s.has(a.item)||s.set(a.item,a);let i=[],u=new Set;for(let a=0;a<o.length;a++){let l=o[a],m=s.get(l);if(m&&!u.has(m))m.setIndex(a),i.push(m),u.add(m);else{let d,v,h;J(x=>{h=x;let[P,p]=b(a,{name:"row index"});v=p,d=t(l,P)});let O={item:l,rendered:d,dispose:h,setIndex:v};i.push(O),u.add(O)}}for(let a of r)u.has(a)||a.dispose();return r=i,i.map(a=>a.rendered)})},void 0,{name:"mapArray"})}function Ur(e,t,n,r){let o=[],s=[];return k(()=>{for(let i of s)i.dispose();o=[],s=[]}),y(()=>{let i=e()||[];return U(()=>{if(i.length===0){for(let d of s)d.dispose();return o=[],s=[],r?.fallback?r.fallback():[]}let u=new Map;for(let d=0;d<o.length;d++)u.set(o[d],s[d]);let a=[],l=[],m=new Set;for(let d=0;d<i.length;d++){let v=t(i[d]),h=u.get(v);if(h&&!m.has(v))h.setIndex(d),a.push(h);else{let O,x,P;J(p=>{P=p;let[I,A]=b(d,{name:"row index"});x=A;let L=y(_=>{let j=(e()||[])[I()];return j??_},i[d]);O=n(L,I)}),a.push({rendered:O,dispose:P,setIndex:x})}l.push(v),m.add(v)}for(let[d,v]of u)m.has(d)||v.dispose();return o=l,s=a,a.map(d=>d.rendered)})},void 0,{name:"keyArray"})}function Ir(e,t,n){let r=[];return k(()=>{for(let o of r)o.dispose();r=[]}),y(()=>{let o=e()||[];return U(()=>{if(o.length===0){for(let a of r)a.dispose();return r=[],n?.fallback?n.fallback():[]}let s=r.length,i=o.length;for(let a=s;a<i;a++){let l,m,d,v=o[a];J(h=>{d=h;let[O,x]=b(v);m=x,l=t(O,a)}),r.push({rendered:l,setItem:m,dispose:d})}for(let a=i;a<s;a++)r[a].dispose();i<s&&(r=r.slice(0,i));let u=Math.min(s,i);for(let a=0;a<u;a++)r[a].setItem(o[a]);return r.map(a=>a.rendered)})},void 0,{name:"indexArray"})}var jr=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,be=typeof process>"u"?jr:!1,Nr=Symbol.for("signal"),Mr=Symbol.for("memo"),qr=Symbol.for("resource");function je(e){return typeof e=="function"&&e[Nr]===!0}function At(e){return typeof e=="function"&&e[Mr]===!0}function kt(e){return typeof e=="function"&&e[qr]===!0}function Ct(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Et(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Pt(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Ze(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Ze(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var _t=null;function It(e){_t=e}function Z(e){_t&&_t(e)}var Dt=null;function jt(e){Dt=e}function Ne(e){return Dt?Dt(e):void 0}var Ft=null;function Nt(e){Ft=e}function Me(){return Ft?Ft():void 0}var Ut=null;function Mt(e){Ut=e}function qe(e,t){Ut&&Ut(e,t)}function _n(e,t=(n,r)=>n===r){let n=new Map;return N(()=>{let r=e();for(let[o,s]of n){let[i,u]=s,a=t(o,r);i()!==a&&u(a)}}),r=>{let o=n.get(r);if(!o){let[s,i]=b(!1);o=[s,i],n.set(r,o);let u=e();i(t(r,u))}return o[0]()}}function Dn(e,t){let[n,r]=b(e(),t);return N(()=>{let o=e();t?.timeoutMs?setTimeout(()=>r(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>r(()=>o)):Promise.resolve().then(()=>r(()=>o))}),n}function Fn(e,t){let n,r=(...o)=>{n!==void 0&&clearTimeout(n),n=setTimeout(()=>{n=void 0,e(...o)},t)};return k(()=>{n!==void 0&&clearTimeout(n)}),r}function Br(e){return!!e&&typeof e.then=="function"}var qt=Symbol();function me(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:Me(),i=s!==void 0?Ne(s):void 0,u=i!==void 0,[a,l]=b(i!==void 0?i.value:n.initialValue,{equals:!1}),[m,d]=b(void 0,{equals:!1}),[v,h]=b(i!==void 0||n.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[O,x]=b(void 0,{equals:!1}),[P,p]=b(void 0,{equals:!1}),I=qt,A=!1;N(()=>{let C=r();if(P(),C===!1||C===null||C===void 0){I=qt,V(()=>{h("unresolved"),x(void 0),d(void 0)});return}let j=A;if(A=!1,I!==qt&&C===I&&!j)return;if(I=C,u){u=!1;return}let K=!1;k(()=>K=!0);let X=U(v),Ee=U(a),se=X==="ready"||X==="refreshing";V(()=>{h(se?"refreshing":"pending"),d(void 0)});try{let M=o(C,{value:Ee,refetching:se});Br(M)?(x(M),Z(M),M.then(Y=>{K||(s!==void 0&&qe(s,Y),V(()=>{l(()=>Y),h("ready"),x(void 0)}))},Y=>{K||V(()=>{d(Y),h("errored"),x(void 0)})})):V(()=>{l(()=>M),h("ready"),x(void 0)})}catch(M){if(K)return;V(()=>{d(M),h("errored"),x(void 0)})}});let L=()=>{let C=v();return C==="pending"||C==="refreshing"},_=(()=>{let C=m();if(C)throw C;if(L()){let j=O();if(j)throw j}return a()});return Object.defineProperties(_,{state:{get:v},loading:{get:L},error:{get:m},latest:{get:a}}),Object.defineProperty(_,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(_,Symbol.for("signal"),{value:!0,enumerable:!0}),[_,{mutate:l,refetch:()=>{A=!0,p(void 0)}}]}function Bt(e,t=300){let[n,r]=b(e),[o,s]=b(e),[i,u]=b(!1),a,l=()=>{a!==void 0&&(clearTimeout(a),a=void 0)},m=()=>{l();let v=U(n);return s(()=>v),u(!1),v},d=(v=>{let h=typeof v=="function"?v(U(n)):v;return r(()=>h),u(!0),l(),a=setTimeout(m,t),h});return k(l),[o,d,{immediate:n,pending:i,flush:m,cancel:()=>{l(),u(!1)}}]}function Lr(e){return e!=null&&e!==""}function Un(e,t,n={}){let{delay:r=300,initialValue:o,shouldFetch:s=Lr}=n,[i,u,a]=Bt(e,r),l=()=>s(i())?i():!1,[m,{refetch:d}]=me(l,t,o===void 0?{}:{initialValue:o});return[m,{...a,query:i,setQuery:u,refetch:d}]}function et(e){if(typeof e=="function"&&!e.length){let t=e();return je(t)?t:et(t)}if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let r=et(e[n]);Array.isArray(r)?t.push.apply(t,r):t.push(r)}return t}return e}function tt(e){let t=y(e);return be?y(()=>et(t()),void 0,{name:"children"}):y(()=>et(t()))}var nt=ye();Sn((e,t)=>{let n=Qe(t,nt);n&&(n.increment(),e.finally(()=>n.decrement()))});function In(){let[e,t]=b(0),n=0;return{increment:()=>t(n+=1),decrement:()=>t(n-=1),inFallback:()=>e()>0}}function jn(e,t){return Te(nt,e,t)}var Nn=ye();gn((e,t)=>{let n=Qe(t,Nn);return n?(n.setError(e),!0):!1});function Mn(){let[e,t]=b(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:r=>t(()=>r)}}function qn(e,t){return Te(Nn,e,t)}var Bn={State:de,Computed:W,subtle:{Watcher:pe,untrack:_e,currentComputed:yn,hasSinks:Tn}};var $r=Symbol.for("signal"),Vr=Symbol.for("fluixi-proxy");function Kr(e,t){let[n,r]=b(e,t);return Object.assign(n,{set:r})}function Hr(e,t,n){return y(e,t,n)}function Wr(e,t){return N(e,t)}function Ln(...e){let[t,n]=me(...e);return Object.assign(t,n)}var g=require("@fluixi/reactive/signal");var xe=Symbol("store-raw"),ee=Symbol("store-node"),$n=Symbol("store-has"),ot=Symbol("store-self"),st=Symbol("store-track"),Gn=Symbol("store-name"),zn=Symbol("store-store"),Le=new WeakMap,$t=new WeakMap,ge=new WeakMap,it=new WeakMap;function Gr(e,t){if(!Se(e)||!fe())return;let n=new Set,r=i=>{if(!(!Se(i)||n.has(i))){n.add(i);for(let u of Object.values(i))r(u)}};r(it.get(t)??t);let o=new Set,s=i=>{if(!Se(i))return;let u=i;if(n.has(u)||o.has(u))return;o.add(u);let a=Le.get(u);if(a){for(let l of a.keys.values())H(l);a.all&&H(a.all),Le.delete(u),ge.delete(u),$t.delete(u)}for(let l of Object.values(u))s(l)};s(e)}var at=(e,t,n)=>n?`${e}[${String(t)}]`:`${e}.${String(t)}`;function Xn(e,t,n){let r=t?.owner,o=r&&n!==void 0?at(r.name,n,t?.array):void 0,[s,i]=rn(r?.store,()=>(0,g.createSignal)(e,o?{name:o}:void 0)),u=s;return u.$=i,u}function ut(e){let t=Le.get(e);return t?t.owner||(t.owner=ge.get(e)):Le.set(e,t={keys:new Map,owner:ge.get(e),array:Array.isArray(e)}),t}function Vn(e,t,n){let r=e.keys.get(t);return r||e.keys.set(t,r=Xn(n,e,t)),r}function zr(e,t,n,r){let o=ge.get(e);if(o&&o.store===t&&o.name===n)return;let s={store:t,name:n};ge.set(e,s),it.set(e,it.get(r)??r);let i=Le.get(e);if(i&&(i.owner=s,!!fe())){for(let[u,a]of i.keys)St(a,t,at(n,u,i.array));i.all&&St(i.all,t,at(n,"*",i.array))}}function Kn(e){let t=ut(e);(t.all||(t.all=Xn(void 0,t,"*")))()}function Hn(e,t){e.$(typeof t=="function"?()=>t:t)}function Se(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 rt(e){if(!Se(e))return e;let t=$t.get(e);if(t)return t;let n=new Proxy(e,Xr);return $t.set(e,n),n}var Xr={get(e,t,n){if(t===xe||t===ee)return e;if(t===g.$PROXY)return n;if(t===$n)return a=>a in e;if(t==="__proxy")return!0;if(t===st||t===ot)return Kn(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=ut(e),i=Vn(s,t,r),u=i();return Se(u)?(s.owner&&zr(u,i,at(s.owner.name,t,s.array),e),rt(u)):u},set(){return!0},deleteProperty(e,t){return t in e&&Be(e,t,void 0),!0},has(e,t){return t===xe||t===g.$PROXY||t===ee||t===$n||t===ot||t===st?!0:(Vn(ut(e),t,e[t])(),t in e)},ownKeys(e){return Kn(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function Yn(e,t=new Set){if(e==null||typeof e!="object")return e;let n=e[xe]??e;if(t.has(n)||!Se(n))return n;t.add(n);let r=!1,o=i=>{let u=Yn(i,t);return u!==i&&(r=!0),u};if(Array.isArray(n)){let i=n.map(o);return r?i:n}let s={};for(let i of Object.keys(n))s[i]=o(n[i]);return r?s:n}function Be(e,t,n){let r=Yn(n),o=e[t];if(o===r&&(r!==void 0||t in e))return;let s=Array.isArray(e),i=s?e.length:0;r===void 0?delete e[t]:e[t]=r;let u=ut(e),a=u.keys.get(t);if(a&&Hn(a,r),Gr(o,e),s&&e.length!==i){let l=u.keys.get("length");l&&Hn(l,e.length)}u.all&&u.all.$(void 0)}function Wn(e,t){return typeof e=="function"?e(t):e}function Vt(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)?Vt(o,r):Be(e,n,r)}}function Ht(e){let t=[],n=e.replace(/\[([^\]]*)\]/g,".$1");for(let r of n.split("."))r.length&&t.push(r);return t}function Qn(e,t,n){let r=t.length-1;for(let s=0;s<r;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++)Qn(e[l],a,n);return}let u=e[i];(u==null||typeof u!="object")&&(u=/^\d+$/.test(t[s+1])?[]:{},Be(e,i,u)),e=u}let o=t[r];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)Be(e,s,Wn(n,e[s]));return}Be(e,o,Wn(n,e[o]))}function Lt(e,t,n){Qn(e,Ht(t),n)}function Yr(e,t){let n=t[0];if(typeof n=="function"&&t.length===1){let r=n(e);r&&r!==e&&Vt(e,r);return}if(Array.isArray(n)&&t.length===1){for(let r of n)Array.isArray(r)&&Lt(e,r[0],r[1]);return}if(n&&typeof n=="object"&&!Array.isArray(n)&&t.length===1){Vt(e,n);return}if(Array.isArray(t[1])&&t.length>=3){Lt(e,`${n}.${t[1].join(".")}`,t[2]);return}Lt(e,String(n),t[1])}function Kt(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Kt);let t={};for(let n of Object.keys(e))t[n]=Kt(e[n]);return t}function he(e,t){let n=e;for(let r of Ht(t)){if(n==null)return;n=n[r]}return n}var G=class{constructor(t,n={immutable:!0}){this.options=n;this.root=t,this.set=((...r)=>(0,g.batch)(()=>Yr(this.root,r))),t&&typeof t=="object"&&(ge.set(t,{store:this,name:n.name??"store"}),it.set(t,t)),Q({kind:"store",node:this,handle:()=>this.root,name:n.name})}get state(){return rt(this.root)}get proxy(){return rt(this.root)}get accessor(){return(()=>rt(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return we(this.state);let n=this.state;for(let r of Ht(t)){if(n==null)return;n=n[r]}return we(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=Kt(n);return t(r),r}))}reconcile(t,n={}){this.set(t)}push(t,...n){let r=he(this.root,t);this.set(t,r.concat(n))}pop(t){let n=he(this.root,t).slice(),r=n.pop();return this.set(t,n),r}shift(t){let n=he(this.root,t).slice(),r=n.shift();return this.set(t,n),r}splice(t,n,r,...o){let s=he(this.root,t).slice(),i=s.splice(n,r,...o);return this.set(t,s),i}insert(t,n,r){let o=he(this.root,t).slice();o.splice(n,0,r),this.set(t,o)}removeAt(t,n){let r=he(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(){}},Qr=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function Jn(e,t){for(let n of Qr)e[n]=t[n].bind(t);e.$=t.reactive.bind(t)}function $e(e,t={immutable:!0}){let n=new G(e,t);return Jn(n.set,n),[n.proxy,n.set]}function Wt(e,t={}){return new G(e,{...t,immutable:!1})}function Zn(e,t={}){let n=new G(e(),t);return(0,g.createEffect)(()=>n.set(e())),n}function er(e,t,n){return(0,g.createEffect)(()=>n(t(e)))}function tr(e,t,n){return(0,g.createMemo)(()=>t(e),void 0,n)}function nr(e,t={}){let n=new G(e,t),r=(()=>n.proxy);return Jn(r,n),r}function we(e){if(e==null||typeof e!="object")return e;let t=e[xe];return t!==void 0?t:e}function Gt(e){return(0,g.untrack)(()=>we(e))}function rr(e){return ct(e)}function or(e){return ct(e)?e[ee]:null}function sr(e){return e&&typeof e=="object"&&ee in e?e[ee]:null}function ct(e){return!!e&&typeof e=="object"&&(g.$PROXY in e||e.__proxy===!0)}function ir(e){return e}var ar=Object.freeze({createStore:$e,createMutableStore:Wt,batch:g.batch,unwrap:we,untrackStore:Gt});function zt(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(zt);let t={};for(let n of Object.keys(e))t[n]=zt(e[n]);return t}function ur(e){return t=>{let n=zt(t);return e(n),n}}function cr(e,t={}){return()=>e}function lr(e,t){let[n,r]=$e(e,t);return new Proxy(n,{get:(o,s)=>s==="set"?r:o[s],has:(o,s)=>s==="set"||Reflect.has(o,s)})}function Jr(e,t,n){return y(()=>t(e()),void 0,n)}function Zr(e,t,n){return y(()=>e().filter(t),void 0,n)}function eo(e,t,n,r){return y(()=>e().reduce(t,n),void 0,r)}function to(e,t,n){return y(()=>e().find(t),void 0,n)}function no(e,t,n){return y(()=>e().some(t),void 0,n)}function ro(e,t,n){return y(()=>e().every(t),void 0,n)}function oo(e,t,n){return y(()=>[...e()].sort(t),void 0,n)}function so(e,t){return y(()=>[...new Set(e())],void 0,t)}function io(e,t,n){return y(()=>{let r=e.map(o=>o());return t(r)},void 0,n)}function ao(...e){return new q(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())}):N(()=>{t.next(n())}));return()=>{r.forEach(o=>{typeof o=="function"?o():o&&typeof o.unsubscribe=="function"&&o.unsubscribe()})}})}function uo(e,t,n){return y(()=>e()||t(),void 0,n)}function co(e,t,n,r){return y(()=>n(e(),t()),void 0,r)}function lo(e,t,n){return y(()=>t(e()),void 0,{equals:n,internal:!0})}function fo(e,t,n){return y(()=>{let r=e(),o={};for(let s of t)o[s]=r[s];return o},void 0,n)}function po(e,t,n){return y(()=>{let o={...e()};for(let s of t)delete o[s];return o},void 0,n)}function yo(e,t,n,r){return y(()=>e()?t():n(),void 0,r)}function To(e,t,n){return y(()=>e()?t():void 0,void 0,n)}function vo(e,t,n){let[r,o]=b(e()),s;return y(()=>{let i=e();clearTimeout(s),s=setTimeout(()=>o(()=>i),t)}),r}function bo(e,t,n){let[r,o]=b(e()),s=0,i;return y(()=>{let u=e(),a=Date.now();a-s>=t?(s=a,o(()=>u)):(clearTimeout(i),i=setTimeout(()=>{s=Date.now(),o(()=>u)},t-(a-s)))}),r}function mo(e){let t=e;for(;typeof t=="function";)t=t();return t}var ho=Symbol.for("signal");var fr=Symbol("fluixi-proxy"),So=Symbol.for("signal-node"),Ve=0,Yt=1,pt=2,Re=3,S=null,R=null,f=null,ft=null,dt=0,xo=!1,Xt=!1,Oe=0,go=1e6,z=new WeakMap,lt=null;var wo=new Map,Oo=0;function Ro(){return`node_${++Oo}_${Date.now()}`}function Ao(e){be&&wo.set(e.id,new WeakRef(e))}function ko(e,t,n){let r={id:Ro(),type:e,value:t,version:0,equals:n?.equals,name:n?.name,created:Date.now(),updated:Date.now()};return Ao(r),r}function Co(e,t){return e===t}function pr(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}function Eo(e){if(f)f.indexOf(e)===-1&&f.push(e);else if(lt&<.running&&!e.pure)lt.effects.indexOf(e)===-1&<.effects.push(e);else if(!e.pure||e.computed)Jt(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;yt(r),f=o}}}function dr(e,t){for(let n=0;n<e.length;n++)t(e[n])}function te(e,t){let n=e;typeof n=="object"&&n&&fr in n&&delete n[fr];let r=ko("signal",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),o=[i,u];z.set(o,new Set);let s;function i(){let a=R;if(a){a.sources?a.sources.indexOf(o)===-1&&a.sources.push(o):a.sources=[o];let l=z.get(o);l&&!l.has(a)&&l.add(a)}return n}function u(a){let l=typeof a=="function"?a(n):a,m=r.equals||Co;if(t?.equals===!1||!m(n,l)){n=l,r.value=l,r.version++,r.updated=Date.now();let v=z.get(o);if(v&&v.size>0){let P=function(p,I=!1){let A=p.state;if(!(A===Re&&p===R)){if(I&&!p.pure){A===Ve&&(p.state=Yt,xo&&(f!==null&&f.indexOf(p)===-1?f.push(p):O.push(p)));return}if(!x.has(p)&&(x.add(p),p.state=pt,A===Ve||A===Yt?O.push(p):!p.pure&&f!==null&&f.indexOf(p)===-1&&f.push(p),p.pure&&p.accessor)){let L=z.get(p.accessor);L&&dr(Array.from(L),_=>P(_,!0))}}};var d=P;let h=Array.from(v),O=[],x=new Set;dr(h,P);for(let p of O)Eo(p)}}}return i.toObservable=()=>new q(a=>{let l=!0;return Qt(()=>{let d=i();l?l=!1:a.next(d)})}),Object.defineProperty(i,ho,{value:!0,enumerable:!0}),Object.defineProperty(i,So,{value:r,enumerable:!1}),o}function Qt(e,t,n){let r={fn:e,state:pt,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=B&&Ce(B);return o&&(r.suspense=o),yr(r,t),()=>Ae(r)}function yr(e,t){if(e.sources){for(let o of e.sources){let s=z.get(o);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.owned){for(let o=0;o<e.owned.length;o++)Ae(e.owned[o]);e.owned=null}let n=R,r=S;if(R=e,S=e,dt++,dt>go)throw dt=0,R=n,S=r,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=Re;let o=e.fn(t);typeof o=="function"&&(e.cleanups?e.cleanups.push(o):e.cleanups=[o]),e.state===Re&&(e.state=Ve)}catch(o){if(bt(o)){let s=B&&Ce(B);s&&(s.increment(),o.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}pr(o)}finally{R=n,S=r}}function Jt(e){if(!(e.disposed||!e.fn||e.state===Ve)&&(e.state===pt||e.state===Yt||e.state===Re)){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++)Ae(e.owned[t]);e.owned=null}e.renderEffect?vr(e):yr(e,e.value)}}function Ae(e){if(e.disposed=!0,e.sources)for(let t of e.sources){let n=z.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++)Ae(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 yt(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=z.get(o.accessor);if(s&&s.size>0){let u=R;R=null,o.accessor(),R=u}let i=f.splice(0);for(let u of i)u.pure&&!u.computed&&u.accessor?t.indexOf(u)===-1&&t.push(u):(u.computed||!u.pure)&&n.indexOf(u)===-1&&n.push(u)}f=null;for(let o of n)(o.computed||!o.pure)&&Jt(o)}function ne(e){if(f&&Oe>0)return e();if(f&&Oe===0){let t=f,n=[];f=n,Oe++;let r;try{r=e()}finally{Oe--,f=t}let o=f;return yt(n),f=o,r}Oe++,f=[],ft=[];try{return e()}finally{Oe--,Po()}}function Po(){if(!Xt){Xt=!0,dt=0;try{for(;f&&f.length>0;){let e=f;f=null,yt(e)}if(f=null,ft){let e=ft;ft=null;for(let t=0;t<e.length;t++)Jt(e[t])}}finally{Xt=!1}}}function ke(e){let t=R;R=null;try{return e()}finally{R=t}}function Tr(e){S&&(S.cleanups?S.cleanups.push(e):S.cleanups=[e])}function _o(e){let t=Symbol("context"),n=Do(t);return{id:t,Provider:n,defaultValue:e}}function Do(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 Fo(()=>{r=ke(()=>{let o=S;return o&&(o.contexts||(o.contexts=new Map),o.contexts.set(e,t.value)),tt(()=>t.children)})}),r}}function Ce(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 Fo(e,t,n){let r={fn:e,state:pt,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=B&&Ce(B);return o&&(r.suspense=o),vr(r),()=>Ae(r)}function vr(e){if(e.sources){for(let o of e.sources){let s=z.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++)Ae(e.owned[o]);e.owned=null}let t=R,n=S,r=f;R=e,S=e,f===null&&(f=[]),e.state=Re;try{let o=e.fn(e.value);typeof o=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(o)),e.value=o,e.state===Re&&(e.state=Ve)}catch(o){if(bt(o)){let s=B&&Ce(B);s&&(s.increment(),o.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}pr(o)}finally{R=t,S=n;let o=f;if(f=r,o!==r&&o&&o.length>0){let s=f;yt(o),f=s}}}var B;function br(){return B||(B=_o())}var oe=new Map,re=new Map,Uo=0,Io=Symbol.for("signal"),jo=Symbol.for("resource");function No(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:u=`_auto_${Uo++}`,staleWhileRevalidate:a=!0}=s,l=u,m=T=>`${l}:${JSON.stringify(T)}`,d=T=>i===1/0||Date.now()-T.timestamp<=i,[v,h]=te(void 0,{equals:!1}),[O,x]=te("unresolved",{equals:!1}),[P,p]=te(void 0,{equals:!1}),[I,A]=te(void 0,{equals:!1}),[L,_]=te(!1),[C,j]=te(0,{equals:!1}),K=Symbol("unset"),X=K,Ee=!1,se=!1;function M(T,D,F,$){if(re.has(D)){re.get(D).then(w=>{$()||Y(w,F)},w=>{!$()&&!F&&Zt(w)}),F||A(re.get(D));return}let ie=Promise.resolve(o(T)).then(w=>(oe.set(D,{value:w,timestamp:Date.now()}),re.delete(D),w),w=>{throw re.delete(D),w});if(re.set(D,ie),!F){Z(ie),A(ie);let w=Ke&&Ce(Ke);w&&(w.increment(),ie.finally(()=>w.decrement()))}ie.then(w=>{$()||Y(w,F)},w=>{!$()&&!F&&Zt(w)})}function Y(T,D){ne(()=>{h(()=>T),x("ready"),_(!1),A(void 0),p(void 0)})}function Zt(T){ne(()=>{p(T),x("errored"),A(void 0)})}let Ke;Qt(()=>{Ke===void 0&&(Ke=br());let T=r();if(C(),T===!1||T===null||T===void 0){X=K,ne(()=>{x("unresolved"),A(void 0),p(void 0)});return}let D=Ee,F=se;Ee=!1,se=!1;let $=m(T);F&&oe.delete($);let ie=X===K||T!==X;X=T;let w=!1;Tr(()=>{w=!0});let ae=oe.get($);if(ae&&d(ae)&&!D&&!F){(ke(O)!=="ready"||ke(v)!==ae.value)&&ne(()=>{h(()=>ae.value),x("ready"),_(!1),p(void 0)});return}if(ae&&a&&!F){ne(()=>{h(()=>ae.value),x("ready"),_(!0),p(void 0),A(void 0)}),M(T,$,!0,()=>w);return}let en=ke(O),mr=en==="ready"||en==="refreshing";ne(()=>{x(mr?"refreshing":"pending"),p(void 0),_(!1)}),M(T,$,!1,()=>w)});let He=(()=>{let T=P();if(T)throw T;if(O()==="pending"){let F=I();if(F)throw F}return v()});return Object.defineProperty(He,jo,{value:!0,enumerable:!0}),Object.defineProperty(He,Io,{value:!0,enumerable:!0}),Object.defineProperties(He,{state:{get:O},loading:{get:()=>{let T=O();return T==="pending"||T==="refreshing"}},error:{get:P},latest:{get:v},stale:{get:L}}),[He,{mutate:h,refetch:()=>{Ee=!0,j(T=>T+1)},invalidate:()=>{let T=ke(r);T!=null&&T!==!1&&oe.delete(m(T)),se=!0,j(D=>D+1)}}]}function Mo(e){let t=`${e}:`;for(let n of oe.keys())n.startsWith(t)&&oe.delete(n)}function qo(){oe.clear(),re.clear()}
|
package/dist/lib/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Sn="1.0.0-alpha.81";function Ye(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function Rt(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 Xe(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}var pe=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(Ye(r)&&!(r instanceof e))try{r()}catch(o){console.error("Error in unsubscribe function:",o)}else if(Rt(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(Ye(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 Te=class extends pe{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 Te{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 $r(e){return new Te(e.next,e.error,e.complete)}var B=class extends pe{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 Te?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 At=class extends B{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 B(r=>this.subscribe(r))}};var xn="__fluixi_signal_next_state__",gn=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[xn]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:gn,onSuspend:null,onError:null};var Ct=0,Et=1,ye=2,ke=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))}},te=class extends ke{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(ye);Je(this)}}peek(){return this._value}},$=class extends ke{constructor(n,r){super();this._threw=!1;this._initialized=!1;this.state=ye;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===Et&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===ye)break}(this.state===ye||!this._initialized)&&this.recompute(),this.state=Ct}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(ye);Je(this)}}markDirty(n){if(this.state>=n)return;let r=this.state===Ct;if(this.state=n,r){if(this.observers)for(let o of[...this.observers])o.markDirty(Et);Je(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Je(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var ne=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 me(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function Pt(){return a.consumer}function kt(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function wn(e){let t=be(e);return e&&(e.owned??=[]).push(t),t}function On(e,t=!0){he(e,t)}function Rn(e){return!!e&&e.disposed===!0}function be(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function ve(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:r=>{let o=a.owner,s=be(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 An(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 _e(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 Se(e,t,n){let r=be(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 _t(e){a.onSuspend=e}function Ft(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function Dt(e){a.onError=e}function Fe(){return a.owner}function Ut(e){let t=a.owner;return a.owner=e,t}function xe(e,t){let n=a.owner;a.owner=e;try{return t()}finally{a.owner=n}}function _(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function he(e,t=!0){if(!e.disposed){if(e.owned){for(let n=e.owned.length-1;n>=0;n--)he(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 re(e){let t=be(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let n=a.owner;a.owner=t;try{return e(()=>he(t))}finally{a.owner=n}}function It(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function Cn(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(ge)))}function ge(){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 Mt(){a.batchDepth===0&&ge()}function et(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&ge()}}var Ze=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=be(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new $(()=>{he(this.owner,!1),xe(this.owner,()=>{let n=t();typeof n=="function"&&(this.owner.cleanups??=[]).push(n)})}),this.watcher=new ne(()=>Cn(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),he(this.owner))}};function De(e){let t=new Ze(e);return()=>t.dispose()}function En(e){return!!e&&typeof e.then=="function"}It(()=>{});var qt=Symbol.for("signal"),Pn=Symbol.for("memo"),kn=Symbol.for("signal-node");function h(e,t){let n=new te(e,{equals:t?.equals}),r=(()=>n.get()),o=(s=>{let i=typeof s=="function"?s(n.peek()):s;return n.set(i),Mt(),i});return Object.defineProperty(r,qt,{value:!0,enumerable:!0}),Object.defineProperty(r,kn,{value:{get value(){return n.peek()},get version(){return n.version}},enumerable:!1}),[r,o]}function y(e,t,n){let r=t,o=Fe(),s=new $(()=>xe(o,()=>{try{return r=e(r)}catch(c){if(En(c))return Ft(c),r;throw c}}),{equals:n?.equals}),i=(()=>s.get());return Object.defineProperty(i,qt,{value:!0,enumerable:!0}),Object.defineProperty(i,Pn,{value:!0,enumerable:!0}),i}function M(e,t){let n=t;return De(()=>{n=e(n)})}function _n(e,t){let n=t;De(()=>{n=e(n)})}function Fn(e,t){let n=t;return De(()=>{n=e(n)})}function V(e){return et(e)}function U(e){return me(e)}function Nt(e){return et(e),Promise.resolve()}function Dn(){return[()=>!1,Nt]}function Un(){return ge(),Promise.resolve()}function In(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=me(()=>t(c,o,i));return o=c,u}}function ro(e,t,n){let r=[];return _(()=>{for(let o of r)o.dispose();r=[]}),y(()=>{let o=e()||[];return U(()=>{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;re(x=>{v=x;let[C,p]=h(u);m=p,d=t(l,C)});let w={item:l,rendered:d,dispose:v,setIndex:m};i.push(w),c.add(w)}}for(let u of r)c.has(u)||u.dispose();return r=i,i.map(u=>u.rendered)})})}function oo(e,t,n,r){let o=[],s=[];return _(()=>{for(let i of s)i.dispose();o=[],s=[]}),y(()=>{let i=e()||[];return U(()=>{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 w,x,C;re(p=>{C=p;let[F,R]=h(d);x=R;let N=y(E=>{let D=(e()||[])[F()];return D??E},i[d]);w=n(N,F)}),u.push({rendered:w,dispose:C,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 so(e,t,n){let r=[];return _(()=>{for(let o of r)o.dispose();r=[]}),y(()=>{let o=e()||[];return U(()=>{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];re(v=>{d=v;let[w,x]=h(m);b=x,l=t(w,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 Mn=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,we=typeof process>"u"?Mn:!1,qn=Symbol.for("signal"),Nn=Symbol.for("memo"),jn=Symbol.for("resource");function Ue(e){return typeof e=="function"&&e[qn]===!0}function jt(e){return typeof e=="function"&&e[Nn]===!0}function Bt(e){return typeof e=="function"&&e[jn]===!0}function Lt(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function $t(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Vt(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function tt(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?tt(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var nt=null;function Kt(e){nt=e}function oe(e){nt&&nt(e)}var rt=null;function Ht(e){rt=e}function Ie(e){return rt?rt(e):void 0}var ot=null;function Wt(e){ot=e}function Me(){return ot?ot():void 0}var st=null;function Gt(e){st=e}function qe(e,t){st&&st(e,t)}function Bn(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 Ln(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 $n(e,t){let n,r=(...o)=>{n!==void 0&&clearTimeout(n),n=setTimeout(()=>{n=void 0,e(...o)},t)};return _(()=>{n!==void 0&&clearTimeout(n)}),r}function Vn(e){return!!e&&typeof e.then=="function"}var it=Symbol();function Oe(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:Me(),i=s!==void 0?Ie(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}),[w,x]=h(void 0,{equals:!1}),[C,p]=h(void 0,{equals:!1}),F=it,R=!1;M(()=>{let A=r();if(C(),A===!1||A===null||A===void 0){F=it,V(()=>{v("unresolved"),x(void 0),d(void 0)});return}let D=R;if(R=!1,F!==it&&A===F&&!D)return;if(F=A,c){c=!1;return}let L=!1;_(()=>L=!0);let H=U(m),de=U(u),J=H==="ready"||H==="refreshing";V(()=>{v(J?"refreshing":"pending"),d(void 0)});try{let I=o(A,{value:de,refetching:J});Vn(I)?(x(I),oe(I),I.then(W=>{L||(s!==void 0&&qe(s,W),V(()=>{l(()=>W),v("ready"),x(void 0)}))},W=>{L||V(()=>{d(W),v("errored"),x(void 0)})})):V(()=>{l(()=>I),v("ready"),x(void 0)})}catch(I){if(L)return;V(()=>{d(I),v("errored"),x(void 0)})}});let N=()=>{let A=m();return A==="pending"||A==="refreshing"},E=(()=>{let A=b();if(A)throw A;if(N()){let D=w();if(D)throw D}return u()});return Object.defineProperties(E,{state:{get:m},loading:{get:N},error:{get:b},latest:{get:u}}),Object.defineProperty(E,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(E,Symbol.for("signal"),{value:!0,enumerable:!0}),[E,{mutate:l,refetch:()=>{R=!0,p(void 0)}}]}function zt(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=U(n);return s(()=>m),c(!1),m},d=(m=>{let v=typeof m=="function"?m(U(n)):m;return r(()=>v),c(!0),l(),u=setTimeout(b,t),v});return _(l),[o,d,{immediate:n,pending:i,flush:b,cancel:()=>{l(),c(!1)}}]}function Kn(e){return e!=null&&e!==""}function Hn(e,t,n={}){let{delay:r=300,initialValue:o,shouldFetch:s=Kn}=n,[i,c,u]=zt(e,r),l=()=>s(i())?i():!1,[b,{refetch:d}]=Oe(l,t,o===void 0?{}:{initialValue:o});return[b,{...u,query:i,setQuery:c,refetch:d}]}function Ne(e){if(typeof e=="function"&&!e.length){let t=e();return Ue(t)?t:Ne(t)}if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let r=Ne(e[n]);Array.isArray(r)?t.push.apply(t,r):t.push(r)}return t}return e}function ut(e){let t=y(e);return we?y(()=>Ne(t()),void 0,{name:"children"}):y(()=>Ne(t()))}var at=ve();_t((e,t)=>{let n=_e(t,at);n&&(n.increment(),e.finally(()=>n.decrement()))});function Wn(){let[e,t]=h(0),n=0;return{increment:()=>t(n+=1),decrement:()=>t(n-=1),inFallback:()=>e()>0}}function Gn(e,t){return Se(at,e,t)}var Yt=ve();Dt((e,t)=>{let n=_e(t,Yt);return n?(n.setError(e),!0):!1});function zn(){let[e,t]=h(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:r=>t(()=>r)}}function Yn(e,t){return Se(Yt,e,t)}var Xn={State:te,Computed:$,subtle:{Watcher:ne,untrack:me,currentComputed:Pt,hasSinks:kt}};var Po=Symbol.for("signal"),ko=Symbol.for("fluixi-proxy");function Ho(e,t){let[n,r]=h(e,t);return Object.assign(n,{set:r})}function Wo(e,t,n){return y(e,t,n)}function Go(e,t){return M(e,t)}function Qn(...e){let[t,n]=Oe(...e);return Object.assign(t,n)}import{$PROXY as lt,batch as rn,createEffect as Be,createMemo as ft,createSignal as on,untrack as Jn}from"@fluixi/reactive/signal";var Le=Symbol("store-raw"),ie=Symbol("store-node"),Xt=Symbol("store-has"),dt=Symbol("store-self"),pt=Symbol("store-track"),Zn=Symbol("store-name"),er=Symbol("store-store"),Qt=new WeakMap,Jt=new WeakMap;function sn(e){let[t,n]=on(e),r=t;return r.$=n,r}function $e(e){let t=Qt.get(e);return t||Qt.set(e,t={keys:new Map}),t}function Zt(e,t,n){let r=e.keys.get(t);return r||e.keys.set(t,r=sn(n)),r}function en(e){let t=$e(e);(t.all||(t.all=sn()))()}function tn(e,t){e.$(typeof t=="function"?()=>t:t)}function un(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 je(e){if(!un(e))return e;let t=Jt.get(e);if(t)return t;let n=new Proxy(e,tr);return Jt.set(e,n),n}var tr={get(e,t,n){if(t===Le||t===ie)return e;if(t===lt)return n;if(t===Xt)return i=>i in e;if(t==="__proxy")return!0;if(t===pt||t===dt)return en(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=Zt($e(e),t,r)();return un(s)?je(s):s},set(){return!0},deleteProperty(e,t){return t in e&&Re(e,t,void 0),!0},has(e,t){return t===Le||t===lt||t===ie||t===Xt||t===dt||t===pt?!0:(Zt($e(e),t,e[t])(),t in e)},ownKeys(e){return en(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function Re(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=$e(e),c=i.keys.get(t);if(c&&tn(c,n),o&&e.length!==s){let u=i.keys.get("length");u&&tn(u,e.length)}i.all&&i.all.$(void 0)}function nn(e,t){return typeof e=="function"?e(t):e}function Tt(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)?Tt(o,r):Re(e,n,r)}}function mt(e){let t=[],n=e.replace(/\[([^\]]*)\]/g,".$1");for(let r of n.split("."))r.length&&t.push(r);return t}function an(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++)an(e[l],u,n);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},Re(e,i,c)),e=c}let o=t[r];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)Re(e,s,nn(n,e[s]));return}Re(e,o,nn(n,e[o]))}function ct(e,t,n){an(e,mt(t),n)}function nr(e,t){let n=t[0];if(typeof n=="function"&&t.length===1){let r=n(e);r&&r!==e&&Tt(e,r);return}if(Array.isArray(n)&&t.length===1){for(let r of n)Array.isArray(r)&&ct(e,r[0],r[1]);return}if(n&&typeof n=="object"&&!Array.isArray(n)&&t.length===1){Tt(e,n);return}if(Array.isArray(t[1])&&t.length>=3){ct(e,`${n}.${t[1].join(".")}`,t[2]);return}ct(e,String(n),t[1])}function yt(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(yt);let t={};for(let n of Object.keys(e))t[n]=yt(e[n]);return t}function se(e,t){let n=e;for(let r of mt(t)){if(n==null)return;n=n[r]}return n}var G=class{constructor(t,n={immutable:!0}){this.options=n;this.root=t,this.set=((...r)=>rn(()=>nr(this.root,r)))}get state(){return je(this.root)}get proxy(){return je(this.root)}get accessor(){return(()=>je(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return Ae(this.state);let n=this.state;for(let r of mt(t)){if(n==null)return;n=n[r]}return Ae(n)}select(t){return ft(()=>t(this.state))}subscribe(t){return Be(()=>t(this.state))}watch(t,n){let r;return Be(()=>{let o=t(this.state);Object.is(o,r)||(n(o,r),r=o)})}reactive(t){return ft(()=>this.state[t])}produce(t){this.set((n=>{let r=yt(n);return t(r),r}))}reconcile(t,n={}){this.set(t)}push(t,...n){let r=se(this.root,t);this.set(t,r.concat(n))}pop(t){let n=se(this.root,t).slice(),r=n.pop();return this.set(t,n),r}shift(t){let n=se(this.root,t).slice(),r=n.shift();return this.set(t,n),r}splice(t,n,r,...o){let s=se(this.root,t).slice(),i=s.splice(n,r,...o);return this.set(t,s),i}insert(t,n,r){let o=se(this.root,t).slice();o.splice(n,0,r),this.set(t,o)}removeAt(t,n){let r=se(this.root,t).slice(),o=r.splice(n,1);return this.set(t,r),o}toObservable(){let[t]=on(this.state);return t.toObservable()}dispose(){}},rr=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function cn(e,t){for(let n of rr)e[n]=t[n].bind(t);e.$=t.reactive.bind(t)}function Ve(e,t={immutable:!0}){let n=new G(e,t);return cn(n.set,n),[n.proxy,n.set]}function ln(e,t={}){return new G(e,{...t,immutable:!1})}function or(e,t={}){let n=new G(e(),t);return Be(()=>n.set(e())),n}function sr(e,t,n){return Be(()=>n(t(e)))}function ir(e,t,n){return ft(()=>t(e),void 0,n)}function ur(e,t={}){let n=new G(e,t),r=(()=>n.proxy);return cn(r,n),r}function Ae(e){if(e==null||typeof e!="object")return e;let t=e[Le];return t!==void 0?t:e}function fn(e){return Jn(()=>Ae(e))}function ar(e){return ht(e)}function cr(e){return ht(e)?e[ie]:null}function lr(e){return e&&typeof e=="object"&&ie in e?e[ie]:null}function ht(e){return!!e&&typeof e=="object"&&(lt in e||e.__proxy===!0)}function fr(e){return e}var dr=Object.freeze({createStore:Ve,createMutableStore:ln,batch:rn,unwrap:Ae,untrackStore:fn});function bt(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(bt);let t={};for(let n of Object.keys(e))t[n]=bt(e[n]);return t}function pr(e){return t=>{let n=bt(t);return e(n),n}}function Tr(e,t={}){return()=>e}function yr(e,t){let[n,r]=Ve(e,t);return new Proxy(n,{get:(o,s)=>s==="set"?r:o[s],has:(o,s)=>s==="set"||Reflect.has(o,s)})}function ds(e,t,n){return y(()=>t(e()),void 0,n)}function ps(e,t,n){return y(()=>e().filter(t),void 0,n)}function Ts(e,t,n,r){return y(()=>e().reduce(t,n),void 0,r)}function ys(e,t,n){return y(()=>e().find(t),void 0,n)}function ms(e,t,n){return y(()=>e().some(t),void 0,n)}function hs(e,t,n){return y(()=>e().every(t),void 0,n)}function bs(e,t,n){return y(()=>[...e()].sort(t),void 0,n)}function vs(e,t){return y(()=>[...new Set(e())],void 0,t)}function Ss(e,t,n){return y(()=>{let r=e.map(o=>o());return t(r)},void 0,n)}function xs(...e){return new B(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 gs(e,t,n){return y(()=>e()||t(),void 0,n)}function ws(e,t,n,r){return y(()=>n(e(),t()),void 0,r)}function Os(e,t,n){return y(()=>t(e()),void 0,{equals:n,internal:!0})}function Rs(e,t,n){return y(()=>{let r=e(),o={};for(let s of t)o[s]=r[s];return o},void 0,n)}function As(e,t,n){return y(()=>{let o={...e()};for(let s of t)delete o[s];return o},void 0,n)}function Cs(e,t,n,r){return y(()=>e()?t():n(),void 0,r)}function Es(e,t,n){return y(()=>e()?t():void 0,void 0,n)}function Ps(e,t,n){let[r,o]=h(e()),s;return y(()=>{let i=e();clearTimeout(s),s=setTimeout(()=>o(()=>i),t)}),r}function ks(e,t,n){let[r,o]=h(e()),s=0,i;return y(()=>{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 _s(e){let t=e;for(;typeof t=="function";)t=t();return t}var mr=Symbol.for("signal");var dn=Symbol("fluixi-proxy"),hr=Symbol.for("signal-node"),Ce=0,St=1,Ge=2,ae=3,S=null,O=null,f=null,He=null,We=0,br=!1,vt=!1,ue=0,vr=1e6,K=new WeakMap,Ke=null;var Sr=new Map,xr=0;function gr(){return`node_${++xr}_${Date.now()}`}function wr(e){we&&Sr.set(e.id,new WeakRef(e))}function Or(e,t,n){let r={id:gr(),type:e,value:t,version:0,equals:n?.equals,name:n?.name,created:Date.now(),updated:Date.now()};return wr(r),r}function Rr(e,t){return e===t}function Tn(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}function Ar(e){if(f)f.indexOf(e)===-1&&f.push(e);else if(Ke&&Ke.running&&!e.pure)Ke.effects.indexOf(e)===-1&&Ke.effects.push(e);else if(!e.pure||e.computed)gt(e);else if(e.pure&&!e.computed&&e.accessor){let t=O,n=f;O=null,f=[],e.accessor(),O=t;let r=f;if(f=n,r.length>0){let o=f;ze(r),f=o}}}function pn(e,t){for(let n=0;n<e.length;n++)t(e[n])}function z(e,t){let n=e;typeof n=="object"&&n&&dn in n&&delete n[dn];let r=Or("signal",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),o=[i,c];K.set(o,new Set);let s;function i(){let u=O;if(u){u.sources?u.sources.indexOf(o)===-1&&u.sources.push(o):u.sources=[o];let l=K.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||Rr;if(t?.equals===!1||!b(n,l)){n=l,r.value=l,r.version++,r.updated=Date.now();let m=K.get(o);if(m&&m.size>0){let C=function(p,F=!1){let R=p.state;if(!(R===ae&&p===O)){if(F&&!p.pure){R===Ce&&(p.state=St,br&&(f!==null&&f.indexOf(p)===-1?f.push(p):w.push(p)));return}if(!x.has(p)&&(x.add(p),p.state=Ge,R===Ce||R===St?w.push(p):!p.pure&&f!==null&&f.indexOf(p)===-1&&f.push(p),p.pure&&p.accessor)){let N=K.get(p.accessor);N&&pn(Array.from(N),E=>C(E,!0))}}};var d=C;let v=Array.from(m),w=[],x=new Set;pn(v,C);for(let p of w)Ar(p)}}}return i.toObservable=()=>new B(u=>{let l=!0;return xt(()=>{let d=i();l?l=!1:u.next(d)})}),Object.defineProperty(i,mr,{value:!0,enumerable:!0}),Object.defineProperty(i,hr,{value:r,enumerable:!1}),o}function xt(e,t,n){let r={fn:e,state:Ge,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=q&&fe(q);return o&&(r.suspense=o),yn(r,t),()=>ce(r)}function yn(e,t){if(e.sources){for(let o of e.sources){let s=K.get(o);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.owned){for(let o=0;o<e.owned.length;o++)ce(e.owned[o]);e.owned=null}let n=O,r=S;if(O=e,S=e,We++,We>vr)throw We=0,O=n,S=r,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=ae;let o=e.fn(t);typeof o=="function"&&(e.cleanups?e.cleanups.push(o):e.cleanups=[o]),e.state===ae&&(e.state=Ce)}catch(o){if(Xe(o)){let s=q&&fe(q);s&&(s.increment(),o.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Tn(o)}finally{O=n,S=r}}function gt(e){if(!(e.disposed||!e.fn||e.state===Ce)&&(e.state===Ge||e.state===St||e.state===ae)){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++)ce(e.owned[t]);e.owned=null}e.renderEffect?hn(e):yn(e,e.value)}}function ce(e){if(e.disposed=!0,e.sources)for(let t of e.sources){let n=K.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++)ce(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 ze(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=K.get(o.accessor);if(s&&s.size>0){let c=O;O=null,o.accessor(),O=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)&>(o)}function Y(e){if(f&&ue>0)return e();if(f&&ue===0){let t=f,n=[];f=n,ue++;let r;try{r=e()}finally{ue--,f=t}let o=f;return ze(n),f=o,r}ue++,f=[],He=[];try{return e()}finally{ue--,Cr()}}function Cr(){if(!vt){vt=!0,We=0;try{for(;f&&f.length>0;){let e=f;f=null,ze(e)}if(f=null,He){let e=He;He=null;for(let t=0;t<e.length;t++)gt(e[t])}}finally{vt=!1}}}function le(e){let t=O;O=null;try{return e()}finally{O=t}}function mn(e){S&&(S.cleanups?S.cleanups.push(e):S.cleanups=[e])}function Er(e){let t=Symbol("context"),n=Pr(t);return{id:t,Provider:n,defaultValue:e}}function Pr(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 kr(()=>{r=le(()=>{let o=S;return o&&(o.contexts||(o.contexts=new Map),o.contexts.set(e,t.value)),ut(()=>t.children)})}),r}}function fe(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 kr(e,t,n){let r={fn:e,state:Ge,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=q&&fe(q);return o&&(r.suspense=o),hn(r),()=>ce(r)}function hn(e){if(e.sources){for(let o of e.sources){let s=K.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++)ce(e.owned[o]);e.owned=null}let t=O,n=S,r=f;O=e,S=e,f===null&&(f=[]),e.state=ae;try{let o=e.fn(e.value);typeof o=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(o)),e.value=o,e.state===ae&&(e.state=Ce)}catch(o){if(Xe(o)){let s=q&&fe(q);s&&(s.increment(),o.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Tn(o)}finally{O=t,S=n;let o=f;if(f=r,o!==r&&o&&o.length>0){let s=f;ze(o),f=s}}}var q;function bn(){return q||(q=Er())}var Q=new Map,X=new Map,_r=0,Fr=Symbol.for("signal"),Dr=Symbol.for("resource");function Ls(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_${_r++}`,staleWhileRevalidate:u=!0}=s,l=c,b=T=>`${l}:${JSON.stringify(T)}`,d=T=>i===1/0||Date.now()-T.timestamp<=i,[m,v]=z(void 0,{equals:!1}),[w,x]=z("unresolved",{equals:!1}),[C,p]=z(void 0,{equals:!1}),[F,R]=z(void 0,{equals:!1}),[N,E]=z(!1),[A,D]=z(0,{equals:!1}),L=Symbol("unset"),H=L,de=!1,J=!1;function I(T,P,k,j){if(X.has(P)){X.get(P).then(g=>{j()||W(g,k)},g=>{!j()&&!k&&wt(g)}),k||R(X.get(P));return}let Z=Promise.resolve(o(T)).then(g=>(Q.set(P,{value:g,timestamp:Date.now()}),X.delete(P),g),g=>{throw X.delete(P),g});if(X.set(P,Z),!k){oe(Z),R(Z);let g=Ee&&fe(Ee);g&&(g.increment(),Z.finally(()=>g.decrement()))}Z.then(g=>{j()||W(g,k)},g=>{!j()&&!k&&wt(g)})}function W(T,P){Y(()=>{v(()=>T),x("ready"),E(!1),R(void 0),p(void 0)})}function wt(T){Y(()=>{p(T),x("errored"),R(void 0)})}let Ee;xt(()=>{Ee===void 0&&(Ee=bn());let T=r();if(A(),T===!1||T===null||T===void 0){H=L,Y(()=>{x("unresolved"),R(void 0),p(void 0)});return}let P=de,k=J;de=!1,J=!1;let j=b(T);k&&Q.delete(j);let Z=H===L||T!==H;H=T;let g=!1;mn(()=>{g=!0});let ee=Q.get(j);if(ee&&d(ee)&&!P&&!k){(le(w)!=="ready"||le(m)!==ee.value)&&Y(()=>{v(()=>ee.value),x("ready"),E(!1),p(void 0)});return}if(ee&&u&&!k){Y(()=>{v(()=>ee.value),x("ready"),E(!0),p(void 0),R(void 0)}),I(T,j,!0,()=>g);return}let Ot=le(w),vn=Ot==="ready"||Ot==="refreshing";Y(()=>{x(vn?"refreshing":"pending"),p(void 0),E(!1)}),I(T,j,!1,()=>g)});let Pe=(()=>{let T=C();if(T)throw T;if(w()==="pending"){let k=F();if(k)throw k}return m()});return Object.defineProperty(Pe,Dr,{value:!0,enumerable:!0}),Object.defineProperty(Pe,Fr,{value:!0,enumerable:!0}),Object.defineProperties(Pe,{state:{get:w},loading:{get:()=>{let T=w();return T==="pending"||T==="refreshing"}},error:{get:C},latest:{get:m},stale:{get:N}}),[Pe,{mutate:v,refetch:()=>{de=!0,D(T=>T+1)},invalidate:()=>{let T=le(r);T!=null&&T!==!1&&Q.delete(b(T)),J=!0,D(P=>P+1)}}]}function $s(e){let t=`${e}:`;for(let n of Q.keys())n.startsWith(t)&&Q.delete(n)}function Vs(){Q.clear(),X.clear()}export{Zn as $NAME,ie as $NODE,ko as $PROXY,Le as $RAW,dt as $SELF,Po as $SIGNAL,er as $STORE,pt as $TRACK,B as Observable,Qe as SafeSubscriber,Xn as Signal,G as Store,dr as StoreAPI,At as Subject,Te as Subscriber,pe as Subscription,at as SuspenseContext,Sn as VERSION,we as __DEV__,V as batch,Vs as clearAllCachedResources,$s as clearCachedResourceNamespace,Ss as combineSignal,xs as combineSignals,Ls as createCachedResource,wn as createChildOwner,_n as createComputed,or as createComputedStore,ve as createContext,$n as createDebounce,Hn as createDebouncedResource,zt as createDebouncedSignal,Ln as createDeferred,M as createEffect,zn as createErrorBoundary,y as createMemo,ln as createMutableStore,Fn as createRenderEffect,Oe as createResource,re as createRoot,Bn as createSelector,h as createSignal,Ve as createStore,sr as createStoreEffect,ir as createStoreMemo,Wn as createSuspenseBoundary,Ps as debounceSignal,On as disposeScope,vs as distinctSignal,Go as effect,hs as everySignal,ps as filterSignal,ys as findSignal,Un as flush,cr as getNode,Fe as getOwner,Ie as getServerData,lr as getStoreNode,Es as guardSignal,so as indexArray,Lt as isComponent,jt as isMemo,Rn as isOwnerDisposed,Vt as isProvider,Bt as isResource,Ue as isSignal,ar as isStore,ht as isStoreProxy,$t as isSuspense,oo as keyArray,tt as makeArrayFlat,ro as mapArray,ds as mapSignal,Wo as memo,gs as mergeSignal,fr as modifiable,Me as nextResourceId,As as omitSignal,In as on,_ as onCleanup,$r as operate,Rs as pickSignal,pr as produceUtil,Se as provide,Yn as provideErrorBoundary,Gn as provideSuspense,ut as readChildren,_s as readSignal,Tr as reconcileUtil,Ts as reduceSignal,qe as reportResourceData,Qn as resource,xe as runWithOwner,Os as selectSignal,Ut as setOwner,Gt as setResourceDataSink,Wt as setResourceIdSource,Kt as setResourceTracker,Ht as setServerDataGetter,Ho as signal,ms as someSignal,bs as sortSignal,Nt as startTransition,yr as store,ks as throttleSignal,oe as trackResourcePromise,U as untrack,fn as untrackStore,Ae as unwrap,An as useContext,Dn as useTransition,Cs as whenSignal,ur as wrap,ws as zipSignal};
|
|
1
|
+
var it="1.0.0-alpha.83";function at(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function Bt(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 ut(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}var he=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(at(r)&&!(r instanceof e))try{r()}catch(o){console.error("Error in unsubscribe function:",o)}else if(Bt(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(at(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 Se=class extends he{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())}},ct=class extends Se{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 yo(e){return new Se(e.next,e.error,e.complete)}var L=class extends he{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 Se?o=t:o=new ct(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 Lt=class extends L{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 L(r=>this.subscribe(r))}};var Bn="__fluixi_signal_next_state__",Ln=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},c=globalThis[Bn]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Ln,onSuspend:null,onError:null,observer:null};function Vt(e){return c.observer=e,()=>{c.observer===e&&(c.observer=null)}}var k=[],qe;function Kt(e,t){if(!c.observer)return t();let n=qe;qe=e;try{return t()}finally{qe=n}}function X(e){let t=c.observer;t&&t.created(e.parents===void 0?{...e,parents:k,origin:e.origin??qe}:e)}function Ht(e){return c.observer?(k.push(e),!0):!1}function Wt(){k.pop()}function Gt(e){c.observer?.ran?.(e)}function zt(e,t){c.observer?.wrote?.(e,t)}function $n(e,t,n,r){let o=c.observer;!o?.bound||!k.length||o.bound(k[k.length-1],e,t,n,r)}function Vn(e){let t=c.observer;!t?.props||!k.length||!e||t.props(k[k.length-1],e)}function Kn(e,t,n,r){let o=c.observer;!o?.directive||!k.length||o.directive(k[k.length-1],e,t,n,r)}function lt(e){c.observer?.contextCreated?.(e)}function xe(e,t,n){let r=c.observer;!r?.context||!k.length||r.context(k[k.length-1],e,t,n)}function ft(e,t,n){c.observer?.moved?.(e,t,n)}function V(e){c.observer?.disposed?.(e)}var Hn="__FLUIXI_DEVTOOLS_HOOK__",$t=globalThis[Hn];if(typeof $t?.inject=="function")try{$t.inject({observeReactiveNodes:Vt,version:it})}catch{}function oe(){return c.observer!=null}var Xt=0,Yt=1,ge=2,Be=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(c.untracked)return;let t=c.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},se=class extends Be{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++,zt(this,c.consumer),this.observers)for(let n of[...this.observers])n.markDirty(ge);dt(this)}}peek(){return this._value}},K=class extends Be{constructor(n,r){super();this._threw=!1;this._initialized=!1;this.state=ge;this.sources=null;this._fn=n,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){if(c.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===Yt&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===ge)break}(this.state===ge||!this._initialized)&&this.recompute(),this.state=Xt}recompute(){if(this.sources){for(let l of this.sources)l.observers?.delete(this);this.sources.clear()}let n=c.consumer,r=c.untracked,o=Ht(this);c.consumer=this,c.untracked=!1;let s,i=!1,u;try{s=this._fn()}catch(l){i=!0,u=l,s=this._value}finally{c.consumer=n,c.untracked=r,o&&Wt()}let a=!this._initialized||this._threw!==i||(i?u!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=i,this._error=u,this._value=s,Gt(this),a){if(this.version++,this.observers)for(let l of[...this.observers])l.markDirty(ge);dt(this)}}markDirty(n){if(this.state>=n)return;let r=this.state===Xt;if(this.state=n,r){if(this.observers)for(let o of[...this.observers])o.markDirty(Yt);dt(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function dt(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var ie=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 we(e){if(c.untracked)return e();c.untracked=!0;try{return e()}finally{c.untracked=!1}}function Qt(){return c.consumer}function Jt(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function Wn(e){let t=Re(e);return e&&(e.owned??=[]).push(t),t}function Gn(e,t=!0){Oe(e,t)}function zn(e){return!!e&&e.disposed===!0}function Re(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function Ae(e,t){let n=Symbol(t??"context");return lt(n),{id:n,defaultValue:e,Provider:o=>{xe(n,"provide",o.value);let s=c.owner,i=Re(s);(i.contexts=new Map).set(n,o.value),s&&(s.owned??=[]).push(i),c.owner=i;try{return o.children}finally{c.owner=s}}}}function Xn(e){let t=c.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id)){let n=t.contexts.get(e.id);return xe(e.id,"read",n),n}t=t.parent}return xe(e.id,"read",e.defaultValue),e.defaultValue}function Le(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 ke(e,t,n){let r=Re(c.owner);(r.contexts=new Map).set(e.id,t),c.owner&&(c.owner.owned??=[]).push(r);let o=c.owner;c.owner=r;try{return n()}finally{c.owner=o}}function Zt(e){c.onSuspend=e}function en(e){return c.onSuspend?(c.onSuspend(e,c.owner),!0):!1}function tn(e){c.onError=e}function $e(){return c.owner}function nn(e){let t=c.owner;return c.owner=e,t}function Ce(e,t){let n=c.owner;c.owner=e;try{return t()}finally{c.owner=n}}function C(e){if(c.owner){if(c.owner.disposed){e();return}(c.owner.cleanups??=[]).push(e)}}function Oe(e,t=!0){if(!e.disposed){if(e.owned){for(let n=e.owned.length-1;n>=0;n--)Oe(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 ae(e){let t=Re(c.owner);c.owner&&(c.owner.owned??=[]).push(t);let n=c.owner;c.owner=t;try{return e(()=>Oe(t))}finally{c.owner=n}}function rn(e){c.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function Yn(e){e.queued||(e.queued=!0,c.queue.push(e),!c.scheduled&&c.batchDepth===0&&(c.scheduled=!0,c.hostSchedule(Ee)))}function Ee(){if(c.scheduled=!1,c.flushing)return;c.flushing=!0;let e=0;try{for(;c.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=c.queue;c.queue=[];for(let n of t)n.queued=!1,n.disposed||n.run()}}finally{c.flushing=!1}}function on(){c.batchDepth===0&&Ee()}function yt(e){c.batchDepth++;try{return e()}finally{--c.batchDepth===0&&Ee()}}var pt=class{constructor(t,n=!1){this.queued=!1;this.disposed=!1;this.owner=Re(c.owner),c.owner&&(c.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new K(()=>{Oe(this.owner,!1),Ce(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),X({kind:"effect",node:this.computed,handle:this,internal:!n}),this.watcher=new ie(()=>Yn(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"&&c.onSuspend){c.onSuspend(t,this.owner);return}if(c.onError&&c.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,V(this.computed),this.watcher.unwatch(this.computed),Oe(this.owner))}};function Ve(e,t=!1){let n=new pt(e,t);return()=>n.dispose()}function Qn(e){return!!e&&typeof e.then=="function"}rn(()=>{});var sn=Symbol.for("signal"),Jn=Symbol.for("memo"),Zn=Symbol.for("signal-node");function b(e,t){let n=new se(e,{equals:t?.equals}),r=(()=>n.get()),o=(s=>{let i=typeof s=="function"?s(n.peek()):s;return n.set(i),on(),i});return Object.defineProperty(r,sn,{value:!0,enumerable:!0}),Object.defineProperty(r,Zn,{value:{get value(){return n.peek()},get version(){return n.version}},enumerable:!1}),X({kind:"signal",node:n,handle:r,name:t?.name,set:o}),oe()&&C(()=>V(n)),[r,o]}function T(e,t,n){let r=t,o=$e(),s=new K(()=>Ce(o,()=>{try{return r=e(r)}catch(u){if(Qn(u))return en(u),r;throw u}}),{equals:n?.equals}),i=(()=>s.get());return Object.defineProperty(i,sn,{value:!0,enumerable:!0}),Object.defineProperty(i,Jn,{value:!0,enumerable:!0}),X({kind:"memo",node:s,handle:i,name:n?.name}),oe()&&C(()=>V(s)),i}function N(e,t){let n=t;return Ve(()=>{n=e(n)},!0)}function er(e,t){let n=t;Ve(()=>{n=e(n)})}function tr(e,t){let n=t;return Ve(()=>{n=e(n)})}function H(e){return yt(e)}function I(e){return we(e)}function an(e){return yt(e),Promise.resolve()}function nr(){return[()=>!1,an]}function rr(){return Ee(),Promise.resolve()}function or(e,t,n){let r=Array.isArray(e),o,s=n?.defer??!1;return i=>{let u=r?e.map(l=>l()):e();if(s){s=!1,o=u;return}let a=we(()=>t(u,o,i));return o=u,a}}function Io(e,t,n){let r=[];return C(()=>{for(let o of r)o.dispose();r=[]}),T(()=>{let o=e()||[];return I(()=>{if(o.length===0){for(let a of r)a.dispose();return r=[],n?.fallback?n.fallback():[]}let s=new Map;for(let a of r)s.has(a.item)||s.set(a.item,a);let i=[],u=new Set;for(let a=0;a<o.length;a++){let l=o[a],m=s.get(l);if(m&&!u.has(m))m.setIndex(a),i.push(m),u.add(m);else{let d,v,h;ae(x=>{h=x;let[E,p]=b(a,{name:"row index"});v=p,d=t(l,E)});let w={item:l,rendered:d,dispose:h,setIndex:v};i.push(w),u.add(w)}}for(let a of r)u.has(a)||a.dispose();return r=i,i.map(a=>a.rendered)})},void 0,{name:"mapArray"})}function jo(e,t,n,r){let o=[],s=[];return C(()=>{for(let i of s)i.dispose();o=[],s=[]}),T(()=>{let i=e()||[];return I(()=>{if(i.length===0){for(let d of s)d.dispose();return o=[],s=[],r?.fallback?r.fallback():[]}let u=new Map;for(let d=0;d<o.length;d++)u.set(o[d],s[d]);let a=[],l=[],m=new Set;for(let d=0;d<i.length;d++){let v=t(i[d]),h=u.get(v);if(h&&!m.has(v))h.setIndex(d),a.push(h);else{let w,x,E;ae(p=>{E=p;let[F,R]=b(d,{name:"row index"});x=R;let q=T(P=>{let U=(e()||[])[F()];return U??P},i[d]);w=n(q,F)}),a.push({rendered:w,dispose:E,setIndex:x})}l.push(v),m.add(v)}for(let[d,v]of u)m.has(d)||v.dispose();return o=l,s=a,a.map(d=>d.rendered)})},void 0,{name:"keyArray"})}function No(e,t,n){let r=[];return C(()=>{for(let o of r)o.dispose();r=[]}),T(()=>{let o=e()||[];return I(()=>{if(o.length===0){for(let a of r)a.dispose();return r=[],n?.fallback?n.fallback():[]}let s=r.length,i=o.length;for(let a=s;a<i;a++){let l,m,d,v=o[a];ae(h=>{d=h;let[w,x]=b(v);m=x,l=t(w,a)}),r.push({rendered:l,setItem:m,dispose:d})}for(let a=i;a<s;a++)r[a].dispose();i<s&&(r=r.slice(0,i));let u=Math.min(s,i);for(let a=0;a<u;a++)r[a].setItem(o[a]);return r.map(a=>a.rendered)})},void 0,{name:"indexArray"})}var sr=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,Pe=typeof process>"u"?sr:!1,ir=Symbol.for("signal"),ar=Symbol.for("memo"),ur=Symbol.for("resource");function Ke(e){return typeof e=="function"&&e[ir]===!0}function un(e){return typeof e=="function"&&e[ar]===!0}function cn(e){return typeof e=="function"&&e[ur]===!0}function ln(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function fn(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function dn(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Tt(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Tt(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var vt=null;function pn(e){vt=e}function ue(e){vt&&vt(e)}var bt=null;function yn(e){bt=e}function He(e){return bt?bt(e):void 0}var mt=null;function Tn(e){mt=e}function We(){return mt?mt():void 0}var ht=null;function vn(e){ht=e}function Ge(e,t){ht&&ht(e,t)}function cr(e,t=(n,r)=>n===r){let n=new Map;return N(()=>{let r=e();for(let[o,s]of n){let[i,u]=s,a=t(o,r);i()!==a&&u(a)}}),r=>{let o=n.get(r);if(!o){let[s,i]=b(!1);o=[s,i],n.set(r,o);let u=e();i(t(r,u))}return o[0]()}}function lr(e,t){let[n,r]=b(e(),t);return N(()=>{let o=e();t?.timeoutMs?setTimeout(()=>r(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>r(()=>o)):Promise.resolve().then(()=>r(()=>o))}),n}function fr(e,t){let n,r=(...o)=>{n!==void 0&&clearTimeout(n),n=setTimeout(()=>{n=void 0,e(...o)},t)};return C(()=>{n!==void 0&&clearTimeout(n)}),r}function dr(e){return!!e&&typeof e.then=="function"}var St=Symbol();function _e(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:We(),i=s!==void 0?He(s):void 0,u=i!==void 0,[a,l]=b(i!==void 0?i.value:n.initialValue,{equals:!1}),[m,d]=b(void 0,{equals:!1}),[v,h]=b(i!==void 0||n.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[w,x]=b(void 0,{equals:!1}),[E,p]=b(void 0,{equals:!1}),F=St,R=!1;N(()=>{let A=r();if(E(),A===!1||A===null||A===void 0){F=St,H(()=>{h("unresolved"),x(void 0),d(void 0)});return}let U=R;if(R=!1,F!==St&&A===F&&!U)return;if(F=A,u){u=!1;return}let $=!1;C(()=>$=!0);let G=I(v),me=I(a),te=G==="ready"||G==="refreshing";H(()=>{h(te?"refreshing":"pending"),d(void 0)});try{let j=o(A,{value:me,refetching:te});dr(j)?(x(j),ue(j),j.then(z=>{$||(s!==void 0&&Ge(s,z),H(()=>{l(()=>z),h("ready"),x(void 0)}))},z=>{$||H(()=>{d(z),h("errored"),x(void 0)})})):H(()=>{l(()=>j),h("ready"),x(void 0)})}catch(j){if($)return;H(()=>{d(j),h("errored"),x(void 0)})}});let q=()=>{let A=v();return A==="pending"||A==="refreshing"},P=(()=>{let A=m();if(A)throw A;if(q()){let U=w();if(U)throw U}return a()});return Object.defineProperties(P,{state:{get:v},loading:{get:q},error:{get:m},latest:{get:a}}),Object.defineProperty(P,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(P,Symbol.for("signal"),{value:!0,enumerable:!0}),[P,{mutate:l,refetch:()=>{R=!0,p(void 0)}}]}function bn(e,t=300){let[n,r]=b(e),[o,s]=b(e),[i,u]=b(!1),a,l=()=>{a!==void 0&&(clearTimeout(a),a=void 0)},m=()=>{l();let v=I(n);return s(()=>v),u(!1),v},d=(v=>{let h=typeof v=="function"?v(I(n)):v;return r(()=>h),u(!0),l(),a=setTimeout(m,t),h});return C(l),[o,d,{immediate:n,pending:i,flush:m,cancel:()=>{l(),u(!1)}}]}function pr(e){return e!=null&&e!==""}function yr(e,t,n={}){let{delay:r=300,initialValue:o,shouldFetch:s=pr}=n,[i,u,a]=bn(e,r),l=()=>s(i())?i():!1,[m,{refetch:d}]=_e(l,t,o===void 0?{}:{initialValue:o});return[m,{...a,query:i,setQuery:u,refetch:d}]}function ze(e){if(typeof e=="function"&&!e.length){let t=e();return Ke(t)?t:ze(t)}if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let r=ze(e[n]);Array.isArray(r)?t.push.apply(t,r):t.push(r)}return t}return e}function xt(e){let t=T(e);return Pe?T(()=>ze(t()),void 0,{name:"children"}):T(()=>ze(t()))}var gt=Ae();Zt((e,t)=>{let n=Le(t,gt);n&&(n.increment(),e.finally(()=>n.decrement()))});function Tr(){let[e,t]=b(0),n=0;return{increment:()=>t(n+=1),decrement:()=>t(n-=1),inFallback:()=>e()>0}}function vr(e,t){return ke(gt,e,t)}var mn=Ae();tn((e,t)=>{let n=Le(t,mn);return n?(n.setError(e),!0):!1});function br(){let[e,t]=b(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:r=>t(()=>r)}}function mr(e,t){return ke(mn,e,t)}var hr={State:se,Computed:K,subtle:{Watcher:ie,untrack:we,currentComputed:Qt,hasSinks:Jt}};var is=Symbol.for("signal"),as=Symbol.for("fluixi-proxy");function gs(e,t){let[n,r]=b(e,t);return Object.assign(n,{set:r})}function ws(e,t,n){return T(e,t,n)}function Os(e,t){return N(e,t)}function Sr(...e){let[t,n]=_e(...e);return Object.assign(t,n)}import{$PROXY as Ot,batch as On,createEffect as Ye,createMemo as Rt,createSignal as Rn,untrack as xr}from"@fluixi/reactive/signal";var Fe=Symbol("store-raw"),fe=Symbol("store-node"),hn=Symbol("store-has"),At=Symbol("store-self"),kt=Symbol("store-track"),gr=Symbol("store-name"),wr=Symbol("store-store"),Ue=new WeakMap,Ct=new WeakMap,de=new WeakMap,Qe=new WeakMap;function Or(e,t){if(!le(e)||!oe())return;let n=new Set,r=i=>{if(!(!le(i)||n.has(i))){n.add(i);for(let u of Object.values(i))r(u)}};r(Qe.get(t)??t);let o=new Set,s=i=>{if(!le(i))return;let u=i;if(n.has(u)||o.has(u))return;o.add(u);let a=Ue.get(u);if(a){for(let l of a.keys.values())V(l);a.all&&V(a.all),Ue.delete(u),de.delete(u),Ct.delete(u)}for(let l of Object.values(u))s(l)};s(e)}var Je=(e,t,n)=>n?`${e}[${String(t)}]`:`${e}.${String(t)}`;function An(e,t,n){let r=t?.owner,o=r&&n!==void 0?Je(r.name,n,t?.array):void 0,[s,i]=Kt(r?.store,()=>Rn(e,o?{name:o}:void 0)),u=s;return u.$=i,u}function Ze(e){let t=Ue.get(e);return t?t.owner||(t.owner=de.get(e)):Ue.set(e,t={keys:new Map,owner:de.get(e),array:Array.isArray(e)}),t}function Sn(e,t,n){let r=e.keys.get(t);return r||e.keys.set(t,r=An(n,e,t)),r}function Rr(e,t,n,r){let o=de.get(e);if(o&&o.store===t&&o.name===n)return;let s={store:t,name:n};de.set(e,s),Qe.set(e,Qe.get(r)??r);let i=Ue.get(e);if(i&&(i.owner=s,!!oe())){for(let[u,a]of i.keys)ft(a,t,Je(n,u,i.array));i.all&&ft(i.all,t,Je(n,"*",i.array))}}function xn(e){let t=Ze(e);(t.all||(t.all=An(void 0,t,"*")))()}function gn(e,t){e.$(typeof t=="function"?()=>t:t)}function le(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Xe(e){if(!le(e))return e;let t=Ct.get(e);if(t)return t;let n=new Proxy(e,Ar);return Ct.set(e,n),n}var Ar={get(e,t,n){if(t===Fe||t===fe)return e;if(t===Ot)return n;if(t===hn)return a=>a in e;if(t==="__proxy")return!0;if(t===kt||t===At)return xn(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=Ze(e),i=Sn(s,t,r),u=i();return le(u)?(s.owner&&Rr(u,i,Je(s.owner.name,t,s.array),e),Xe(u)):u},set(){return!0},deleteProperty(e,t){return t in e&&De(e,t,void 0),!0},has(e,t){return t===Fe||t===Ot||t===fe||t===hn||t===At||t===kt?!0:(Sn(Ze(e),t,e[t])(),t in e)},ownKeys(e){return xn(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function kn(e,t=new Set){if(e==null||typeof e!="object")return e;let n=e[Fe]??e;if(t.has(n)||!le(n))return n;t.add(n);let r=!1,o=i=>{let u=kn(i,t);return u!==i&&(r=!0),u};if(Array.isArray(n)){let i=n.map(o);return r?i:n}let s={};for(let i of Object.keys(n))s[i]=o(n[i]);return r?s:n}function De(e,t,n){let r=kn(n),o=e[t];if(o===r&&(r!==void 0||t in e))return;let s=Array.isArray(e),i=s?e.length:0;r===void 0?delete e[t]:e[t]=r;let u=Ze(e),a=u.keys.get(t);if(a&&gn(a,r),Or(o,e),s&&e.length!==i){let l=u.keys.get("length");l&&gn(l,e.length)}u.all&&u.all.$(void 0)}function wn(e,t){return typeof e=="function"?e(t):e}function Et(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)?Et(o,r):De(e,n,r)}}function _t(e){let t=[],n=e.replace(/\[([^\]]*)\]/g,".$1");for(let r of n.split("."))r.length&&t.push(r);return t}function Cn(e,t,n){let r=t.length-1;for(let s=0;s<r;s++){let i=t[s];if(i==="*"){let a=t.slice(s+1);if(Array.isArray(e))for(let l=0;l<e.length;l++)Cn(e[l],a,n);return}let u=e[i];(u==null||typeof u!="object")&&(u=/^\d+$/.test(t[s+1])?[]:{},De(e,i,u)),e=u}let o=t[r];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)De(e,s,wn(n,e[s]));return}De(e,o,wn(n,e[o]))}function wt(e,t,n){Cn(e,_t(t),n)}function kr(e,t){let n=t[0];if(typeof n=="function"&&t.length===1){let r=n(e);r&&r!==e&&Et(e,r);return}if(Array.isArray(n)&&t.length===1){for(let r of n)Array.isArray(r)&&wt(e,r[0],r[1]);return}if(n&&typeof n=="object"&&!Array.isArray(n)&&t.length===1){Et(e,n);return}if(Array.isArray(t[1])&&t.length>=3){wt(e,`${n}.${t[1].join(".")}`,t[2]);return}wt(e,String(n),t[1])}function Pt(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Pt);let t={};for(let n of Object.keys(e))t[n]=Pt(e[n]);return t}function ce(e,t){let n=e;for(let r of _t(t)){if(n==null)return;n=n[r]}return n}var Y=class{constructor(t,n={immutable:!0}){this.options=n;this.root=t,this.set=((...r)=>On(()=>kr(this.root,r))),t&&typeof t=="object"&&(de.set(t,{store:this,name:n.name??"store"}),Qe.set(t,t)),X({kind:"store",node:this,handle:()=>this.root,name:n.name})}get state(){return Xe(this.root)}get proxy(){return Xe(this.root)}get accessor(){return(()=>Xe(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return Ie(this.state);let n=this.state;for(let r of _t(t)){if(n==null)return;n=n[r]}return Ie(n)}select(t){return Rt(()=>t(this.state))}subscribe(t){return Ye(()=>t(this.state))}watch(t,n){let r;return Ye(()=>{let o=t(this.state);Object.is(o,r)||(n(o,r),r=o)})}reactive(t){return Rt(()=>this.state[t])}produce(t){this.set((n=>{let r=Pt(n);return t(r),r}))}reconcile(t,n={}){this.set(t)}push(t,...n){let r=ce(this.root,t);this.set(t,r.concat(n))}pop(t){let n=ce(this.root,t).slice(),r=n.pop();return this.set(t,n),r}shift(t){let n=ce(this.root,t).slice(),r=n.shift();return this.set(t,n),r}splice(t,n,r,...o){let s=ce(this.root,t).slice(),i=s.splice(n,r,...o);return this.set(t,s),i}insert(t,n,r){let o=ce(this.root,t).slice();o.splice(n,0,r),this.set(t,o)}removeAt(t,n){let r=ce(this.root,t).slice(),o=r.splice(n,1);return this.set(t,r),o}toObservable(){let[t]=Rn(this.state);return t.toObservable()}dispose(){}},Cr=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function En(e,t){for(let n of Cr)e[n]=t[n].bind(t);e.$=t.reactive.bind(t)}function et(e,t={immutable:!0}){let n=new Y(e,t);return En(n.set,n),[n.proxy,n.set]}function Pn(e,t={}){return new Y(e,{...t,immutable:!1})}function Er(e,t={}){let n=new Y(e(),t);return Ye(()=>n.set(e())),n}function Pr(e,t,n){return Ye(()=>n(t(e)))}function _r(e,t,n){return Rt(()=>t(e),void 0,n)}function Dr(e,t={}){let n=new Y(e,t),r=(()=>n.proxy);return En(r,n),r}function Ie(e){if(e==null||typeof e!="object")return e;let t=e[Fe];return t!==void 0?t:e}function _n(e){return xr(()=>Ie(e))}function Fr(e){return Dt(e)}function Ur(e){return Dt(e)?e[fe]:null}function Ir(e){return e&&typeof e=="object"&&fe in e?e[fe]:null}function Dt(e){return!!e&&typeof e=="object"&&(Ot in e||e.__proxy===!0)}function jr(e){return e}var Nr=Object.freeze({createStore:et,createMutableStore:Pn,batch:On,unwrap:Ie,untrackStore:_n});function Ft(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ft);let t={};for(let n of Object.keys(e))t[n]=Ft(e[n]);return t}function Mr(e){return t=>{let n=Ft(t);return e(n),n}}function qr(e,t={}){return()=>e}function Br(e,t){let[n,r]=et(e,t);return new Proxy(n,{get:(o,s)=>s==="set"?r:o[s],has:(o,s)=>s==="set"||Reflect.has(o,s)})}function Hs(e,t,n){return T(()=>t(e()),void 0,n)}function Ws(e,t,n){return T(()=>e().filter(t),void 0,n)}function Gs(e,t,n,r){return T(()=>e().reduce(t,n),void 0,r)}function zs(e,t,n){return T(()=>e().find(t),void 0,n)}function Xs(e,t,n){return T(()=>e().some(t),void 0,n)}function Ys(e,t,n){return T(()=>e().every(t),void 0,n)}function Qs(e,t,n){return T(()=>[...e()].sort(t),void 0,n)}function Js(e,t){return T(()=>[...new Set(e())],void 0,t)}function Zs(e,t,n){return T(()=>{let r=e.map(o=>o());return t(r)},void 0,n)}function ei(...e){return new L(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())}):N(()=>{t.next(n())}));return()=>{r.forEach(o=>{typeof o=="function"?o():o&&typeof o.unsubscribe=="function"&&o.unsubscribe()})}})}function ti(e,t,n){return T(()=>e()||t(),void 0,n)}function ni(e,t,n,r){return T(()=>n(e(),t()),void 0,r)}function ri(e,t,n){return T(()=>t(e()),void 0,{equals:n,internal:!0})}function oi(e,t,n){return T(()=>{let r=e(),o={};for(let s of t)o[s]=r[s];return o},void 0,n)}function si(e,t,n){return T(()=>{let o={...e()};for(let s of t)delete o[s];return o},void 0,n)}function ii(e,t,n,r){return T(()=>e()?t():n(),void 0,r)}function ai(e,t,n){return T(()=>e()?t():void 0,void 0,n)}function ui(e,t,n){let[r,o]=b(e()),s;return T(()=>{let i=e();clearTimeout(s),s=setTimeout(()=>o(()=>i),t)}),r}function ci(e,t,n){let[r,o]=b(e()),s=0,i;return T(()=>{let u=e(),a=Date.now();a-s>=t?(s=a,o(()=>u)):(clearTimeout(i),i=setTimeout(()=>{s=Date.now(),o(()=>u)},t-(a-s)))}),r}function li(e){let t=e;for(;typeof t=="function";)t=t();return t}var Lr=Symbol.for("signal");var Dn=Symbol("fluixi-proxy"),$r=Symbol.for("signal-node"),je=0,It=1,ot=2,ye=3,S=null,O=null,f=null,nt=null,rt=0,Vr=!1,Ut=!1,pe=0,Kr=1e6,W=new WeakMap,tt=null;var Hr=new Map,Wr=0;function Gr(){return`node_${++Wr}_${Date.now()}`}function zr(e){Pe&&Hr.set(e.id,new WeakRef(e))}function Xr(e,t,n){let r={id:Gr(),type:e,value:t,version:0,equals:n?.equals,name:n?.name,created:Date.now(),updated:Date.now()};return zr(r),r}function Yr(e,t){return e===t}function Un(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}function Qr(e){if(f)f.indexOf(e)===-1&&f.push(e);else if(tt&&tt.running&&!e.pure)tt.effects.indexOf(e)===-1&&tt.effects.push(e);else if(!e.pure||e.computed)Nt(e);else if(e.pure&&!e.computed&&e.accessor){let t=O,n=f;O=null,f=[],e.accessor(),O=t;let r=f;if(f=n,r.length>0){let o=f;st(r),f=o}}}function Fn(e,t){for(let n=0;n<e.length;n++)t(e[n])}function Q(e,t){let n=e;typeof n=="object"&&n&&Dn in n&&delete n[Dn];let r=Xr("signal",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),o=[i,u];W.set(o,new Set);let s;function i(){let a=O;if(a){a.sources?a.sources.indexOf(o)===-1&&a.sources.push(o):a.sources=[o];let l=W.get(o);l&&!l.has(a)&&l.add(a)}return n}function u(a){let l=typeof a=="function"?a(n):a,m=r.equals||Yr;if(t?.equals===!1||!m(n,l)){n=l,r.value=l,r.version++,r.updated=Date.now();let v=W.get(o);if(v&&v.size>0){let E=function(p,F=!1){let R=p.state;if(!(R===ye&&p===O)){if(F&&!p.pure){R===je&&(p.state=It,Vr&&(f!==null&&f.indexOf(p)===-1?f.push(p):w.push(p)));return}if(!x.has(p)&&(x.add(p),p.state=ot,R===je||R===It?w.push(p):!p.pure&&f!==null&&f.indexOf(p)===-1&&f.push(p),p.pure&&p.accessor)){let q=W.get(p.accessor);q&&Fn(Array.from(q),P=>E(P,!0))}}};var d=E;let h=Array.from(v),w=[],x=new Set;Fn(h,E);for(let p of w)Qr(p)}}}return i.toObservable=()=>new L(a=>{let l=!0;return jt(()=>{let d=i();l?l=!1:a.next(d)})}),Object.defineProperty(i,Lr,{value:!0,enumerable:!0}),Object.defineProperty(i,$r,{value:r,enumerable:!1}),o}function jt(e,t,n){let r={fn:e,state:ot,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=M&&be(M);return o&&(r.suspense=o),In(r,t),()=>Te(r)}function In(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++)Te(e.owned[o]);e.owned=null}let n=O,r=S;if(O=e,S=e,rt++,rt>Kr)throw rt=0,O=n,S=r,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=ye;let o=e.fn(t);typeof o=="function"&&(e.cleanups?e.cleanups.push(o):e.cleanups=[o]),e.state===ye&&(e.state=je)}catch(o){if(ut(o)){let s=M&&be(M);s&&(s.increment(),o.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Un(o)}finally{O=n,S=r}}function Nt(e){if(!(e.disposed||!e.fn||e.state===je)&&(e.state===ot||e.state===It||e.state===ye)){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++)Te(e.owned[t]);e.owned=null}e.renderEffect?Nn(e):In(e,e.value)}}function Te(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++)Te(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 st(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 u=O;O=null,o.accessor(),O=u}let i=f.splice(0);for(let u of i)u.pure&&!u.computed&&u.accessor?t.indexOf(u)===-1&&t.push(u):(u.computed||!u.pure)&&n.indexOf(u)===-1&&n.push(u)}f=null;for(let o of n)(o.computed||!o.pure)&&Nt(o)}function J(e){if(f&&pe>0)return e();if(f&&pe===0){let t=f,n=[];f=n,pe++;let r;try{r=e()}finally{pe--,f=t}let o=f;return st(n),f=o,r}pe++,f=[],nt=[];try{return e()}finally{pe--,Jr()}}function Jr(){if(!Ut){Ut=!0,rt=0;try{for(;f&&f.length>0;){let e=f;f=null,st(e)}if(f=null,nt){let e=nt;nt=null;for(let t=0;t<e.length;t++)Nt(e[t])}}finally{Ut=!1}}}function ve(e){let t=O;O=null;try{return e()}finally{O=t}}function jn(e){S&&(S.cleanups?S.cleanups.push(e):S.cleanups=[e])}function Zr(e){let t=Symbol("context"),n=eo(t);return{id:t,Provider:n,defaultValue:e}}function eo(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 to(()=>{r=ve(()=>{let o=S;return o&&(o.contexts||(o.contexts=new Map),o.contexts.set(e,t.value)),xt(()=>t.children)})}),r}}function be(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 to(e,t,n){let r={fn:e,state:ot,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=M&&be(M);return o&&(r.suspense=o),Nn(r),()=>Te(r)}function Nn(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++)Te(e.owned[o]);e.owned=null}let t=O,n=S,r=f;O=e,S=e,f===null&&(f=[]),e.state=ye;try{let o=e.fn(e.value);typeof o=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(o)),e.value=o,e.state===ye&&(e.state=je)}catch(o){if(ut(o)){let s=M&&be(M);s&&(s.increment(),o.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Un(o)}finally{O=t,S=n;let o=f;if(f=r,o!==r&&o&&o.length>0){let s=f;st(o),f=s}}}var M;function Mn(){return M||(M=Zr())}var ee=new Map,Z=new Map,no=0,ro=Symbol.for("signal"),oo=Symbol.for("resource");function Si(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:u=`_auto_${no++}`,staleWhileRevalidate:a=!0}=s,l=u,m=y=>`${l}:${JSON.stringify(y)}`,d=y=>i===1/0||Date.now()-y.timestamp<=i,[v,h]=Q(void 0,{equals:!1}),[w,x]=Q("unresolved",{equals:!1}),[E,p]=Q(void 0,{equals:!1}),[F,R]=Q(void 0,{equals:!1}),[q,P]=Q(!1),[A,U]=Q(0,{equals:!1}),$=Symbol("unset"),G=$,me=!1,te=!1;function j(y,_,D,B){if(Z.has(_)){Z.get(_).then(g=>{B()||z(g,D)},g=>{!B()&&!D&&Mt(g)}),D||R(Z.get(_));return}let ne=Promise.resolve(o(y)).then(g=>(ee.set(_,{value:g,timestamp:Date.now()}),Z.delete(_),g),g=>{throw Z.delete(_),g});if(Z.set(_,ne),!D){ue(ne),R(ne);let g=Ne&&be(Ne);g&&(g.increment(),ne.finally(()=>g.decrement()))}ne.then(g=>{B()||z(g,D)},g=>{!B()&&!D&&Mt(g)})}function z(y,_){J(()=>{h(()=>y),x("ready"),P(!1),R(void 0),p(void 0)})}function Mt(y){J(()=>{p(y),x("errored"),R(void 0)})}let Ne;jt(()=>{Ne===void 0&&(Ne=Mn());let y=r();if(A(),y===!1||y===null||y===void 0){G=$,J(()=>{x("unresolved"),R(void 0),p(void 0)});return}let _=me,D=te;me=!1,te=!1;let B=m(y);D&&ee.delete(B);let ne=G===$||y!==G;G=y;let g=!1;jn(()=>{g=!0});let re=ee.get(B);if(re&&d(re)&&!_&&!D){(ve(w)!=="ready"||ve(v)!==re.value)&&J(()=>{h(()=>re.value),x("ready"),P(!1),p(void 0)});return}if(re&&a&&!D){J(()=>{h(()=>re.value),x("ready"),P(!0),p(void 0),R(void 0)}),j(y,B,!0,()=>g);return}let qt=ve(w),qn=qt==="ready"||qt==="refreshing";J(()=>{x(qn?"refreshing":"pending"),p(void 0),P(!1)}),j(y,B,!1,()=>g)});let Me=(()=>{let y=E();if(y)throw y;if(w()==="pending"){let D=F();if(D)throw D}return v()});return Object.defineProperty(Me,oo,{value:!0,enumerable:!0}),Object.defineProperty(Me,ro,{value:!0,enumerable:!0}),Object.defineProperties(Me,{state:{get:w},loading:{get:()=>{let y=w();return y==="pending"||y==="refreshing"}},error:{get:E},latest:{get:v},stale:{get:q}}),[Me,{mutate:h,refetch:()=>{me=!0,U(y=>y+1)},invalidate:()=>{let y=ve(r);y!=null&&y!==!1&&ee.delete(m(y)),te=!0,U(_=>_+1)}}]}function xi(e){let t=`${e}:`;for(let n of ee.keys())n.startsWith(t)&&ee.delete(n)}function gi(){ee.clear(),Z.clear()}export{gr as $NAME,fe as $NODE,as as $PROXY,Fe as $RAW,At as $SELF,is as $SIGNAL,wr as $STORE,kt as $TRACK,L as Observable,ct as SafeSubscriber,hr as Signal,Y as Store,Nr as StoreAPI,Lt as Subject,Se as Subscriber,he as Subscription,gt as SuspenseContext,it as VERSION,Pe as __DEV__,H as batch,gi as clearAllCachedResources,xi as clearCachedResourceNamespace,Zs as combineSignal,ei as combineSignals,Si as createCachedResource,Wn as createChildOwner,er as createComputed,Er as createComputedStore,Ae as createContext,fr as createDebounce,yr as createDebouncedResource,bn as createDebouncedSignal,lr as createDeferred,N as createEffect,br as createErrorBoundary,T as createMemo,Pn as createMutableStore,tr as createRenderEffect,_e as createResource,ae as createRoot,cr as createSelector,b as createSignal,et as createStore,Pr as createStoreEffect,_r as createStoreMemo,Tr as createSuspenseBoundary,ui as debounceSignal,Gn as disposeScope,Js as distinctSignal,Os as effect,Ys as everySignal,Ws as filterSignal,zs as findSignal,rr as flush,Ur as getNode,$e as getOwner,He as getServerData,Ir as getStoreNode,ai as guardSignal,No as indexArray,ln as isComponent,un as isMemo,zn as isOwnerDisposed,dn as isProvider,cn as isResource,Ke as isSignal,Fr as isStore,Dt as isStoreProxy,fn as isSuspense,jo as keyArray,Tt as makeArrayFlat,Io as mapArray,Hs as mapSignal,ws as memo,ti as mergeSignal,jr as modifiable,We as nextResourceId,Vt as observeReactiveNodes,si as omitSignal,or as on,C as onCleanup,yo as operate,oi as pickSignal,Mr as produceUtil,ke as provide,mr as provideErrorBoundary,vr as provideSuspense,xt as readChildren,li as readSignal,qr as reconcileUtil,Gs as reduceSignal,$n as reportReactiveBinding,xe as reportReactiveContext,lt as reportReactiveContextCreated,Kn as reportReactiveDirective,Vn as reportReactiveProps,Ge as reportResourceData,Sr as resource,Ce as runWithOwner,ri as selectSignal,nn as setOwner,vn as setResourceDataSink,Tn as setResourceIdSource,pn as setResourceTracker,yn as setServerDataGetter,gs as signal,Xs as someSignal,Qs as sortSignal,an as startTransition,Br as store,ci as throttleSignal,ue as trackResourcePromise,I as untrack,_n as untrackStore,Ie as unwrap,Xn as useContext,nr as useTransition,ii as whenSignal,Dr as wrap,ni as zipSignal};
|