@fluixi/reactive 1.0.0-alpha.76 → 1.0.0-alpha.77
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 +153 -220
- package/dist/cdn/reactive.cjs +1 -1
- package/dist/cdn/reactive.global.js +1 -1
- package/dist/cdn/reactive.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/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 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Fluixi=(()=>{var ke=Object.defineProperty;var kt=Object.getOwnPropertyDescriptor;var jt=Object.getOwnPropertyNames;var Rt=Object.prototype.hasOwnProperty;var Pt=(e,r)=>{for(var t in r)ke(e,t,{get:r[t],enumerable:!0})},_t=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of jt(r))!Rt.call(e,o)&&o!==t&&ke(e,o,{get:()=>r[o],enumerable:!(n=kt(r,o))||n.enumerable});return e};var $t=e=>_t(ke({},"__esModule",{value:!0}),e);var Tn={};Pt(Tn,{$NAME:()=>at,$NODE:()=>$,$PROXY:()=>Gt,$RAW:()=>te,$SELF:()=>Te,$SIGNAL:()=>zt,$STORE:()=>ut,$TRACK:()=>Se,Observable:()=>F,SafeSubscriber:()=>ae,Signal:()=>Vr,Store:()=>j,StoreAPI:()=>wt,Subject:()=>Re,Subscriber:()=>I,Subscription:()=>D,SuspenseContext:()=>be,VERSION:()=>rr,__DEV__:()=>fe,batch:()=>O,createChildOwner:()=>ur,createComputed:()=>br,createComputedStore:()=>dt,createContext:()=>q,createDebounce:()=>Dr,createDebouncedResource:()=>Ir,createDebouncedSignal:()=>Ue,createDeferred:()=>Cr,createEffect:()=>S,createErrorBoundary:()=>Ur,createMemo:()=>A,createMutableStore:()=>Ze,createRenderEffect:()=>vr,createResource:()=>V,createRoot:()=>_,createSelector:()=>Er,createSignal:()=>d,createStore:()=>ne,createStoreEffect:()=>yt,createStoreMemo:()=>ht,createSuspenseBoundary:()=>Mr,disposeScope:()=>lr,effect:()=>Yt,flush:()=>wr,getNode:()=>bt,getOwner:()=>Y,getServerData:()=>ye,getStoreNode:()=>vt,indexArray:()=>Bt,isComponent:()=>xr,isMemo:()=>Sr,isOwnerDisposed:()=>cr,isProvider:()=>jr,isResource:()=>Or,isSignal:()=>pe,isStore:()=>gt,isStoreProxy:()=>xe,isSuspense:()=>kr,keyArray:()=>Ut,makeArrayFlat:()=>De,mapArray:()=>qt,memo:()=>Zt,modifiable:()=>At,nextResourceId:()=>he,on:()=>Tr,onCleanup:()=>v,operate:()=>Et,produceUtil:()=>Tt,provide:()=>U,provideErrorBoundary:()=>Br,provideSuspense:()=>Nr,readChildren:()=>Fr,reconcileUtil:()=>St,reportResourceData:()=>me,resource:()=>Wr,runWithOwner:()=>B,setOwner:()=>$e,setResourceDataSink:()=>$r,setResourceIdSource:()=>_r,setResourceTracker:()=>Rr,setServerDataGetter:()=>Pr,signal:()=>Jt,startTransition:()=>Ce,store:()=>Ot,trackResourcePromise:()=>de,untrack:()=>w,untrackStore:()=>Ye,unwrap:()=>L,useContext:()=>fr,useTransition:()=>Ar,wrap:()=>mt});var rr="1.0.0-alpha.76";function je(e){return typeof e=="function"&&!tr(e)}var nr=e=>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 tr(e){return typeof e=="function"&&/^class\s/.test(Function.prototype.toString.call(e))}var D=class e{constructor(r){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;r&&(this._subscriptions=[r])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:r,_subscriptions:t}=this;if(r instanceof e)r.remove(this);else if(r!==null)for(let n of r)n.remove(this);if(t){for(let n of t)if(je(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if(nr(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(r){if(!r||r===this)return this;if(r.closed)return this;let{_closed:t,_subscriptions:n}=this;if(t){if(je(r))try{r()}catch(o){console.error("Error in unsubscribe function:",o)}else if(r.unsubscribe)try{r.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(r),r instanceof e&&r._addParent(this),this}remove(r){let{_subscriptions:t}=this;if(!t)return;let n=t.indexOf(r);n!==-1&&(t.splice(n,1),r._removeParent(this))}_addParent(r){let{_parentOrParents:t}=this;t?Array.isArray(t)?t.push(r):this._parentOrParents=[t,r]:this._parentOrParents=r}_removeParent(r){let{_parentOrParents:t}=this;if(t===r)this._parentOrParents=null;else if(Array.isArray(t)){let n=t.indexOf(r);n!==-1&&(t.splice(n,1),t.length===1&&(this._parentOrParents=t[0]))}}};var I=class extends D{constructor(t,n,o){super();this.isStopped=!1;let i;t?typeof t=="object"?i=t:i={next:t,error:n,complete:o}:i={},this.destination=i}next(t){if(!this.isStopped&&this.destination.next)try{this.destination.next(t)}catch(n){this.error(n)}}error(t){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(t)}catch(n){throw n}else throw t;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(t){this.error(t);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},ae=class extends I{constructor(t,n,o,i){super(t,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=i||null}next(t){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(t)}catch(n){this.error(n)}}error(t){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(t)}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 Et(e){return new I(e.next,e.error,e.complete)}var F=class extends D{constructor(r){if(super(),r)this._subscribe=r;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(r,t,n){let o;r instanceof I?o=r:o=new ae(r,t,n);let{_subscribe:i}=this;try{let s=i.call(this,o);s&&(typeof s=="function"||typeof s.unsubscribe=="function")&&o.add(s)}catch(s){o.error(s)}return o}pipe(...r){return r.length===0?this:r.reduce((t,n)=>n(t),this)}toPromise(){return new Promise((r,t)=>{let n;this.subscribe({next:o=>n=o,error:t,complete:()=>r(n)})})}};var Re=class extends F{constructor(){super(t=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)t.error(this.thrownError);else if(this.isStopped)t.complete();else return this.observers.push(t),()=>{let n=this.observers.indexOf(t);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(t){if(this.isStopped)return;let{observers:n}=this,o=n.length,i=n.slice();for(let s=0;s<o;s++)i[s].next?.(t)}error(t){if(this.isStopped)return;this.hasError=!0,this.thrownError=t,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,i=n.slice();for(let s=0;s<o;s++)i[s].error?.(t)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:t}=this;this.observers=[];let n=t.length,o=t.slice();for(let i=0;i<n;i++)o[i].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new F(n=>this.subscribe(n))}};var Ct="__fluixi_signal_next_state__",Dt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[Ct]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Dt,onSuspend:null,onError:null};var or=0,ir=1,z=2,ue=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let r=a.consumer;r&&((this.observers??=new Set).add(r),(r.sources??=new Set).add(this))}},M=class extends ue{constructor(r,t){super(),this._value=r,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(r){if(!this._equals(this._value,r)){if(this._value=r,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(z);Pe(this)}}peek(){return this._value}},k=class extends ue{constructor(t,n){super();this._threw=!1;this._initialized=!1;this.state=z;this.sources=null;this._fn=t,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){if(a.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===ir&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===z)break}(this.state===z||!this._initialized)&&this.recompute(),this.state=or}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let t=a.consumer,n=a.untracked;a.consumer=this,a.untracked=!1;let o,i=!1,s;try{o=this._fn()}catch(u){i=!0,s=u,o=this._value}finally{a.consumer=t,a.untracked=n}let c=!this._initialized||this._threw!==i||(i?s!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=i,this._error=s,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(z);Pe(this)}}markDirty(t){if(this.state>=t)return;let n=this.state===or;if(this.state=t,n){if(this.observers)for(let o of[...this.observers])o.markDirty(ir);Pe(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Pe(e){if(e.watchers)for(let r of[...e.watchers])r._notify(e)}var N=class{constructor(r){this._watched=new Set;this._pending=new Set;this._notifyFn=r}watch(...r){for(let t of r)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...r){for(let t of r)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let r=[...this._pending];return this._pending.clear(),r}_notify(r){if(!this._watched.has(r)||this._pending.has(r))return;let t=this._pending.size===0;this._pending.add(r),t&&this._notifyFn()}};function G(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function sr(){return a.consumer}function ar(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function ur(e){let r=Z(e);return e&&(e.owned??=[]).push(r),r}function lr(e,r=!0){J(e,r)}function cr(e){return!!e&&e.disposed===!0}function Z(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function q(e){let r=Symbol("context");return{id:r,defaultValue:e,Provider:n=>{let o=a.owner,i=Z(o);(i.contexts=new Map).set(r,n.value),o&&(o.owned??=[]).push(i),a.owner=i;try{return n.children}finally{a.owner=o}}}}function fr(e){let r=a.owner;for(;r;){if(r.contexts&&r.contexts.has(e.id))return r.contexts.get(e.id);r=r.parent}return e.defaultValue}function le(e,r){let t=e;for(;t;){if(t.contexts&&t.contexts.has(r.id))return t.contexts.get(r.id);t=t.parent}return r.defaultValue}function U(e,r,t){let n=Z(a.owner);(n.contexts=new Map).set(e.id,r),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return t()}finally{a.owner=o}}function pr(e){a.onSuspend=e}function dr(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function yr(e){a.onError=e}function Y(){return a.owner}function $e(e){let r=a.owner;return a.owner=e,r}function B(e,r){let t=a.owner;a.owner=e;try{return r()}finally{a.owner=t}}function v(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function J(e,r=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)J(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}r&&(e.disposed=!0)}}function _(e){let r=Z(a.owner);a.owner&&(a.owner.owned??=[]).push(r);let t=a.owner;a.owner=r;try{return e(()=>J(r))}finally{a.owner=t}}function hr(e){a.hostSchedule=e??(r=>{Promise.resolve().then(r)})}function It(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(Q)))}function Q(){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 r=a.queue;a.queue=[];for(let t of r)t.queued=!1,t.disposed||t.run()}}finally{a.flushing=!1}}function mr(){a.batchDepth===0&&Q()}function Ee(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&Q()}}var _e=class{constructor(r){this.queued=!1;this.disposed=!1;this.owner=Z(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new k(()=>{J(this.owner,!1),B(this.owner,()=>{let t=r();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new N(()=>It(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(r){if(r&&typeof r.then=="function"&&a.onSuspend){a.onSuspend(r,this.owner);return}if(a.onError&&a.onError(r,this.owner))return;throw r}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),J(this.owner))}};function ce(e){let r=new _e(e);return()=>r.dispose()}function Ft(e){return!!e&&typeof e.then=="function"}hr(()=>{});var gr=Symbol.for("signal"),Mt=Symbol.for("memo"),Nt=Symbol.for("signal-node");function d(e,r){let t=new M(e,{equals:r?.equals}),n=(()=>t.get()),o=(i=>{let s=typeof i=="function"?i(t.peek()):i;return t.set(s),mr(),s});return Object.defineProperty(n,gr,{value:!0,enumerable:!0}),Object.defineProperty(n,Nt,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[n,o]}function A(e,r,t){let n=r,o=Y(),i=new k(()=>B(o,()=>{try{return n=e(n)}catch(c){if(Ft(c))return dr(c),n;throw c}}),{equals:t?.equals}),s=(()=>i.get());return Object.defineProperty(s,gr,{value:!0,enumerable:!0}),Object.defineProperty(s,Mt,{value:!0,enumerable:!0}),s}function S(e,r){let t=r;return ce(()=>{t=e(t)})}function br(e,r){let t=r;ce(()=>{t=e(t)})}function vr(e,r){let t=r;return ce(()=>{t=e(t)})}function O(e){return Ee(e)}function w(e){return G(e)}function Ce(e){return Ee(e),Promise.resolve()}function Ar(){return[()=>!1,Ce]}function wr(){return Q(),Promise.resolve()}function Tr(e,r,t){let n=Array.isArray(e),o,i=t?.defer??!1;return s=>{let c=n?e.map(p=>p()):e();if(i){i=!1,o=c;return}let u=G(()=>r(c,o,s));return o=c,u}}function qt(e,r,t){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),A(()=>{let o=e()||[];return w(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],t?.fallback?t.fallback():[]}let i=new Map;for(let u of n)i.has(u.item)||i.set(u.item,u);let s=[],c=new Set;for(let u=0;u<o.length;u++){let p=o[u],h=i.get(p);if(h&&!c.has(h))h.setIndex(u),s.push(h),c.add(h);else{let f,y,m;_(g=>{m=g;let[E,K]=d(u);y=K,f=r(p,E)});let T={item:p,rendered:f,dispose:m,setIndex:y};s.push(T),c.add(T)}}for(let u of n)c.has(u)||u.dispose();return n=s,s.map(u=>u.rendered)})})}function Ut(e,r,t,n){let o=[],i=[];return v(()=>{for(let s of i)s.dispose();o=[],i=[]}),A(()=>{let s=e()||[];return w(()=>{if(s.length===0){for(let f of i)f.dispose();return o=[],i=[],n?.fallback?n.fallback():[]}let c=new Map;for(let f=0;f<o.length;f++)c.set(o[f],i[f]);let u=[],p=[],h=new Set;for(let f=0;f<s.length;f++){let y=r(s[f]),m=c.get(y);if(m&&!h.has(y))m.setIndex(f),u.push(m);else{let T,g,E;_(K=>{E=K;let[R,H]=d(f);g=H;let oe=A(C=>{let x=(e()||[])[R()];return x??C},s[f]);T=t(oe,R)}),u.push({rendered:T,dispose:E,setIndex:g})}p.push(y),h.add(y)}for(let[f,y]of c)h.has(f)||y.dispose();return o=p,i=u,u.map(f=>f.rendered)})})}function Bt(e,r,t){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),A(()=>{let o=e()||[];return w(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],t?.fallback?t.fallback():[]}let i=n.length,s=o.length;for(let u=i;u<s;u++){let p,h,f,y=o[u];_(m=>{f=m;let[T,g]=d(y);h=g,p=r(T,u)}),n.push({rendered:p,setItem:h,dispose:f})}for(let u=s;u<i;u++)n[u].dispose();s<i&&(n=n.slice(0,s));let c=Math.min(i,s);for(let u=0;u<c;u++)n[u].setItem(o[u]);return n.map(u=>u.rendered)})})}var fe=!1,Vt=Symbol.for("signal"),Wt=Symbol.for("memo"),Lt=Symbol.for("resource");function pe(e){return typeof e=="function"&&e[Vt]===!0}function Sr(e){return typeof e=="function"&&e[Wt]===!0}function Or(e){return typeof e=="function"&&e[Lt]===!0}function xr(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function kr(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function jr(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function De(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?De(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var Ie=null;function Rr(e){Ie=e}function de(e){Ie&&Ie(e)}var Fe=null;function Pr(e){Fe=e}function ye(e){return Fe?Fe(e):void 0}var Me=null;function _r(e){Me=e}function he(){return Me?Me():void 0}var Ne=null;function $r(e){Ne=e}function me(e,r){Ne&&Ne(e,r)}function Er(e,r=(t,n)=>t===n){let t=new Map;return S(()=>{let n=e();for(let[o,i]of t){let[s,c]=i,u=r(o,n);s()!==u&&c(u)}}),n=>{let o=t.get(n);if(!o){let[i,s]=d(!1);o=[i,s],t.set(n,o);let c=e();s(r(n,c))}return o[0]()}}function Cr(e,r){let[t,n]=d(e(),r);return S(()=>{let o=e();r?.timeoutMs?setTimeout(()=>n(()=>o),r.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),t}function Dr(e,r){let t,n=(...o)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e(...o)},r)};return v(()=>{t!==void 0&&clearTimeout(t)}),n}function Kt(e){return!!e&&typeof e.then=="function"}var qe=Symbol();function V(e,r,t={}){let n,o;typeof r=="function"?(n=typeof e=="function"?e:()=>e,o=r):(n=()=>!0,o=e,r&&typeof r=="object"&&(t=r));let i=t.transport===!1?void 0:he(),s=i!==void 0?ye(i):void 0,c=s!==void 0,[u,p]=d(s!==void 0?s.value:t.initialValue,{equals:!1}),[h,f]=d(void 0,{equals:!1}),[y,m]=d(s!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[T,g]=d(void 0,{equals:!1}),[E,K]=d(void 0,{equals:!1}),R=qe,H=!1;S(()=>{let b=n();if(E(),b===!1||b===null||b===void 0){R=qe,O(()=>{m("unresolved"),g(void 0),f(void 0)});return}let x=H;if(H=!1,R!==qe&&b===R&&!x)return;if(R=b,c){c=!1;return}let ie=!1;v(()=>ie=!0);let Xe=w(y),xt=w(u),er=Xe==="ready"||Xe==="refreshing";O(()=>{m(er?"refreshing":"pending"),f(void 0)});try{let P=o(b,{value:xt,refetching:er});Kt(P)?(g(P),de(P),P.then(se=>{ie||(i!==void 0&&me(i,se),O(()=>{p(()=>se),m("ready"),g(void 0)}))},se=>{ie||O(()=>{f(se),m("errored"),g(void 0)})})):O(()=>{p(()=>P),m("ready"),g(void 0)})}catch(P){if(ie)return;O(()=>{f(P),m("errored"),g(void 0)})}});let oe=()=>{let b=y();return b==="pending"||b==="refreshing"},C=(()=>{let b=h();if(b)throw b;if(oe()){let x=T();if(x)throw x}return u()});return Object.defineProperties(C,{state:{get:y},loading:{get:oe},error:{get:h},latest:{get:u}}),Object.defineProperty(C,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(C,Symbol.for("signal"),{value:!0,enumerable:!0}),[C,{mutate:p,refetch:()=>{H=!0,K(void 0)}}]}function Ue(e,r=300){let[t,n]=d(e),[o,i]=d(e),[s,c]=d(!1),u,p=()=>{u!==void 0&&(clearTimeout(u),u=void 0)},h=()=>{p();let y=w(t);return i(()=>y),c(!1),y},f=(y=>{let m=typeof y=="function"?y(w(t)):y;return n(()=>m),c(!0),p(),u=setTimeout(h,r),m});return v(p),[o,f,{immediate:t,pending:s,flush:h,cancel:()=>{p(),c(!1)}}]}function Ht(e){return e!=null&&e!==""}function Ir(e,r,t={}){let{delay:n=300,initialValue:o,shouldFetch:i=Ht}=t,[s,c,u]=Ue(e,n),p=()=>i(s())?s():!1,[h,{refetch:f}]=V(p,r,o===void 0?{}:{initialValue:o});return[h,{...u,query:s,setQuery:c,refetch:f}]}function ge(e){if(typeof e=="function"&&!e.length){let r=e();return pe(r)?r:ge(r)}if(Array.isArray(e)){let r=[];for(let t=0;t<e.length;t++){let n=ge(e[t]);Array.isArray(n)?r.push.apply(r,n):r.push(n)}return r}return e}function Fr(e){let r=A(e);return A(()=>ge(r()))}var be=q();pr((e,r)=>{let t=le(r,be);t&&(t.increment(),e.finally(()=>t.decrement()))});function Mr(){let[e,r]=d(0),t=0;return{increment:()=>r(t+=1),decrement:()=>r(t-=1),inFallback:()=>e()>0}}function Nr(e,r){return U(be,e,r)}var qr=q();yr((e,r)=>{let t=le(r,qr);return t?(t.setError(e),!0):!1});function Ur(){let[e,r]=d(void 0,{equals:!1});return{error:e,reset:()=>r(()=>{}),setError:n=>r(()=>n)}}function Br(e,r){return U(qr,e,r)}var Vr={State:M,Computed:k,subtle:{Watcher:N,untrack:G,currentComputed:sr,hasSinks:ar}};var zt=Symbol.for("signal"),Gt=Symbol.for("fluixi-proxy");function Jt(e,r){let[t,n]=d(e,r);return Object.assign(t,{set:n})}function Zt(e,r,t){return A(e,r,t)}function Yt(e,r){return S(e,r)}function Wr(...e){let[r,t]=V(...e);return Object.assign(r,t)}var Qt="__fluixi_signal_next_state__",Xt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},l=globalThis[Qt]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Xt,onSuspend:null,onError:null},Lr=0,Kr=1,X=2,Hr=class{constructor(){this.observers=null,this.watchers=null,this.version=0}updateIfNecessary(){}track(){if(l.untracked)return;let e=l.consumer;e&&((this.observers??=new Set).add(e),(e.sources??=new Set).add(this))}},en=class extends Hr{constructor(e,r){super(),this._value=e,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(e){if(!this._equals(this._value,e)){if(this._value=e,this.version++,this.observers)for(let r of[...this.observers])r.markDirty(X);Be(this)}}peek(){return this._value}},zr=class extends Hr{constructor(e,r){super(),this._threw=!1,this._initialized=!1,this.state=X,this.sources=null,this._fn=e,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){if(l.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===Kr&&this.sources){for(let e of this.sources)if(e.updateIfNecessary(),this.state===X)break}(this.state===X||!this._initialized)&&this.recompute(),this.state=Lr}recompute(){if(this.sources){for(let s of this.sources)s.observers?.delete(this);this.sources.clear()}let e=l.consumer,r=l.untracked;l.consumer=this,l.untracked=!1;let t,n=!1,o;try{t=this._fn()}catch(s){n=!0,o=s,t=this._value}finally{l.consumer=e,l.untracked=r}let i=!this._initialized||this._threw!==n||(n?o!==this._error:!this._equals(this._value,t));if(this._initialized=!0,this._threw=n,this._error=o,this._value=t,i){if(this.version++,this.observers)for(let s of[...this.observers])s.markDirty(X);Be(this)}}markDirty(e){if(this.state>=e)return;let r=this.state===Lr;if(this.state=e,r){if(this.observers)for(let t of[...this.observers])t.markDirty(Kr);Be(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Be(e){if(e.watchers)for(let r of[...e.watchers])r._notify(e)}var rn=class{constructor(e){this._watched=new Set,this._pending=new Set,this._notifyFn=e}watch(...e){for(let r of e)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...e){for(let r of e)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let e=[...this._pending];return this._pending.clear(),e}_notify(e){if(!this._watched.has(e)||this._pending.has(e))return;let r=this._pending.size===0;this._pending.add(e),r&&this._notifyFn()}};function tn(e){if(l.untracked)return e();l.untracked=!0;try{return e()}finally{l.untracked=!1}}function Gr(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function Jr(e){let r=Symbol("context");return{id:r,defaultValue:e,Provider:t=>{let n=l.owner,o=Gr(n);(o.contexts=new Map).set(r,t.value),n&&(n.owned??=[]).push(o),l.owner=o;try{return t.children}finally{l.owner=n}}}}function Zr(e,r){let t=e;for(;t;){if(t.contexts&&t.contexts.has(r.id))return t.contexts.get(r.id);t=t.parent}return r.defaultValue}function nn(e){l.onSuspend=e}function on(e){return l.onSuspend?(l.onSuspend(e,l.owner),!0):!1}function sn(e){l.onError=e}function an(){return l.owner}function Yr(e,r){let t=l.owner;l.owner=e;try{return r()}finally{l.owner=t}}function Ve(e,r=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)Ve(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}r&&(e.disposed=!0)}}function un(e){l.hostSchedule=e??(r=>{Promise.resolve().then(r)})}function ln(e){e.queued||(e.queued=!0,l.queue.push(e),!l.scheduled&&l.batchDepth===0&&(l.scheduled=!0,l.hostSchedule(We)))}function We(){if(l.scheduled=!1,l.flushing)return;l.flushing=!0;let e=0;try{for(;l.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let r=l.queue;l.queue=[];for(let t of r)t.queued=!1,t.disposed||t.run()}}finally{l.flushing=!1}}function cn(){l.batchDepth===0&&We()}function fn(e){l.batchDepth++;try{return e()}finally{--l.batchDepth===0&&We()}}var pn=class{constructor(e){this.queued=!1,this.disposed=!1,this.owner=Gr(l.owner),l.owner&&(l.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new zr(()=>{Ve(this.owner,!1),Yr(this.owner,()=>{let r=e();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new rn(()=>ln(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(e){if(e&&typeof e.then=="function"&&l.onSuspend){l.onSuspend(e,this.owner);return}if(l.onError&&l.onError(e,this.owner))return;throw e}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),Ve(this.owner))}};function dn(e){let r=new pn(e);return()=>r.dispose()}function yn(e){return!!e&&typeof e.then=="function"}un(()=>{});var Qr=Symbol.for("signal"),hn=Symbol.for("memo"),mn=Symbol.for("signal-node");function Le(e,r){let t=new en(e,{equals:r?.equals}),n=(()=>t.get()),o=(i=>{let s=typeof i=="function"?i(t.peek()):i;return t.set(s),cn(),s});return Object.defineProperty(n,Qr,{value:!0,enumerable:!0}),Object.defineProperty(n,mn,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[n,o]}function ve(e,r,t){let n=r,o=an(),i=new zr(()=>Yr(o,()=>{try{return n=e(n)}catch(c){if(yn(c))return on(c),n;throw c}}),{equals:t?.equals}),s=(()=>i.get());return Object.defineProperty(s,Qr,{value:!0,enumerable:!0}),Object.defineProperty(s,hn,{value:!0,enumerable:!0}),s}function ee(e,r){let t=r;return dn(()=>{t=e(t)})}function Ke(e){return fn(e)}function Xr(e){return tn(e)}var gn=Jr();nn((e,r)=>{let t=Zr(r,gn);t&&(t.increment(),e.finally(()=>t.decrement()))});var bn=Jr();sn((e,r)=>{let t=Zr(r,bn);return t?(t.setError(e),!0):!1});var Ae=Symbol.for("fluixi-proxy");var te=Symbol("store-raw"),$=Symbol("store-node"),et=Symbol("store-has"),Te=Symbol("store-self"),Se=Symbol("store-track"),at=Symbol("store-name"),ut=Symbol("store-store"),rt=new WeakMap,tt=new WeakMap;function lt(e){let[r,t]=Le(e),n=r;return n.$=t,n}function Oe(e){let r=rt.get(e);return r||rt.set(e,r={keys:new Map}),r}function nt(e,r,t){let n=e.keys.get(r);return n||e.keys.set(r,n=lt(t)),n}function ot(e){let r=Oe(e);(r.all||(r.all=lt()))()}function it(e,r){e.$(typeof r=="function"?()=>r:r)}function ct(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let r=Object.getPrototypeOf(e);return r===Object.prototype||r===null}function we(e){if(!ct(e))return e;let r=tt.get(e);if(r)return r;let t=new Proxy(e,vn);return tt.set(e,t),t}var vn={get(e,r,t){if(r===te||r===$)return e;if(r===Ae)return t;if(r===et)return s=>s in e;if(r==="__proxy")return!0;if(r===Se||r===Te)return ot(e),t;let n=e[r];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,r))return n;let o=Object.getOwnPropertyDescriptor(e,r);if(o&&o.get)return o.get.call(t);let i=nt(Oe(e),r,n)();return ct(i)?we(i):i},set(){return!0},deleteProperty(e,r){return r in e&&re(e,r,void 0),!0},has(e,r){return r===te||r===Ae||r===$||r===et||r===Te||r===Se?!0:(nt(Oe(e),r,e[r])(),r in e)},ownKeys(e){return ot(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,r){return Reflect.getOwnPropertyDescriptor(e,r)}};function re(e,r,t){if(e[r]===t&&(t!==void 0||r in e))return;let o=Array.isArray(e),i=o?e.length:0;t===void 0?delete e[r]:e[r]=t;let s=Oe(e),c=s.keys.get(r);if(c&&it(c,t),o&&e.length!==i){let u=s.keys.get("length");u&&it(u,e.length)}s.all&&s.all.$(void 0)}function st(e,r){return typeof e=="function"?e(r):e}function ze(e,r){for(let t of Object.keys(r)){let n=r[t],o=e[t];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?ze(o,n):re(e,t,n)}}function Je(e){let r=[],t=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of t.split("."))n.length&&r.push(n);return r}function ft(e,r,t){let n=r.length-1;for(let i=0;i<n;i++){let s=r[i];if(s==="*"){let u=r.slice(i+1);if(Array.isArray(e))for(let p=0;p<e.length;p++)ft(e[p],u,t);return}let c=e[s];(c==null||typeof c!="object")&&(c=/^\d+$/.test(r[i+1])?[]:{},re(e,s,c)),e=c}let o=r[n];if(o==="*"){if(Array.isArray(e))for(let i=0;i<e.length;i++)re(e,i,st(t,e[i]));return}re(e,o,st(t,e[o]))}function He(e,r,t){ft(e,Je(r),t)}function An(e,r){let t=r[0];if(typeof t=="function"&&r.length===1){let n=t(e);n&&n!==e&&ze(e,n);return}if(Array.isArray(t)&&r.length===1){for(let n of t)Array.isArray(n)&&He(e,n[0],n[1]);return}if(t&&typeof t=="object"&&!Array.isArray(t)&&r.length===1){ze(e,t);return}if(Array.isArray(r[1])&&r.length>=3){He(e,`${t}.${r[1].join(".")}`,r[2]);return}He(e,String(t),r[1])}function Ge(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ge);let r={};for(let t of Object.keys(e))r[t]=Ge(e[t]);return r}function W(e,r){let t=e;for(let n of Je(r)){if(t==null)return;t=t[n]}return t}var j=class{constructor(r,t={immutable:!0}){this.options=t;this.root=r,this.set=((...n)=>Ke(()=>An(this.root,n)))}get state(){return we(this.root)}get proxy(){return we(this.root)}get accessor(){return(()=>we(this.root))}unwrap(){return this.root}getNode(r){return this.root&&this.root[r]}get(r){if(r==null||r==="")return L(this.state);let t=this.state;for(let n of Je(r)){if(t==null)return;t=t[n]}return L(t)}select(r){return ve(()=>r(this.state))}subscribe(r){return ee(()=>r(this.state))}watch(r,t){let n;return ee(()=>{let o=r(this.state);Object.is(o,n)||(t(o,n),n=o)})}reactive(r){return ve(()=>this.state[r])}produce(r){this.set((t=>{let n=Ge(t);return r(n),n}))}reconcile(r,t={}){this.set(r)}push(r,...t){let n=W(this.root,r);this.set(r,n.concat(t))}pop(r){let t=W(this.root,r).slice(),n=t.pop();return this.set(r,t),n}shift(r){let t=W(this.root,r).slice(),n=t.shift();return this.set(r,t),n}splice(r,t,n,...o){let i=W(this.root,r).slice(),s=i.splice(t,n,...o);return this.set(r,i),s}insert(r,t,n){let o=W(this.root,r).slice();o.splice(t,0,n),this.set(r,o)}removeAt(r,t){let n=W(this.root,r).slice(),o=n.splice(t,1);return this.set(r,n),o}toObservable(){let[r]=Le(this.state);return r.toObservable()}dispose(){}},wn=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function pt(e,r){for(let t of wn)e[t]=r[t].bind(r);e.$=r.reactive.bind(r)}function ne(e,r={immutable:!0}){let t=new j(e,r);return pt(t.set,t),[t.proxy,t.set]}function Ze(e,r={}){return new j(e,{...r,immutable:!1})}function dt(e,r={}){let t=new j(e(),r);return ee(()=>t.set(e())),t}function yt(e,r,t){return ee(()=>t(r(e)))}function ht(e,r,t){return ve(()=>r(e),void 0,t)}function mt(e,r={}){let t=new j(e,r),n=(()=>t.proxy);return pt(n,t),n}function L(e){if(e==null||typeof e!="object")return e;let r=e[te];return r!==void 0?r:e}function Ye(e){return Xr(()=>L(e))}function gt(e){return xe(e)}function bt(e){return xe(e)?e[$]:null}function vt(e){return e&&typeof e=="object"&&$ in e?e[$]:null}function xe(e){return!!e&&typeof e=="object"&&(Ae in e||e.__proxy===!0)}function At(e){return e}var wt=Object.freeze({createStore:ne,createMutableStore:Ze,batch:Ke,unwrap:L,untrackStore:Ye});function Qe(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Qe);let r={};for(let t of Object.keys(e))r[t]=Qe(e[t]);return r}function Tt(e){return r=>{let t=Qe(r);return e(t),t}}function St(e,r={}){return()=>e}function Ot(e,r){let[t,n]=ne(e,r);return new Proxy(t,{get:(o,i)=>i==="set"?n:o[i],has:(o,i)=>i==="set"||Reflect.has(o,i)})}return $t(Tn);})();
|
|
1
|
+
"use strict";var Fluixi=(()=>{var ke=Object.defineProperty;var kt=Object.getOwnPropertyDescriptor;var jt=Object.getOwnPropertyNames;var Rt=Object.prototype.hasOwnProperty;var Pt=(e,r)=>{for(var t in r)ke(e,t,{get:r[t],enumerable:!0})},_t=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of jt(r))!Rt.call(e,o)&&o!==t&&ke(e,o,{get:()=>r[o],enumerable:!(n=kt(r,o))||n.enumerable});return e};var $t=e=>_t(ke({},"__esModule",{value:!0}),e);var Tn={};Pt(Tn,{$NAME:()=>at,$NODE:()=>$,$PROXY:()=>Gt,$RAW:()=>te,$SELF:()=>Te,$SIGNAL:()=>zt,$STORE:()=>ut,$TRACK:()=>Se,Observable:()=>F,SafeSubscriber:()=>ae,Signal:()=>Vr,Store:()=>j,StoreAPI:()=>wt,Subject:()=>Re,Subscriber:()=>I,Subscription:()=>D,SuspenseContext:()=>be,VERSION:()=>rr,__DEV__:()=>fe,batch:()=>O,createChildOwner:()=>ur,createComputed:()=>br,createComputedStore:()=>dt,createContext:()=>q,createDebounce:()=>Dr,createDebouncedResource:()=>Ir,createDebouncedSignal:()=>Ue,createDeferred:()=>Cr,createEffect:()=>S,createErrorBoundary:()=>Ur,createMemo:()=>A,createMutableStore:()=>Ze,createRenderEffect:()=>vr,createResource:()=>V,createRoot:()=>_,createSelector:()=>Er,createSignal:()=>d,createStore:()=>ne,createStoreEffect:()=>yt,createStoreMemo:()=>ht,createSuspenseBoundary:()=>Mr,disposeScope:()=>lr,effect:()=>Yt,flush:()=>wr,getNode:()=>bt,getOwner:()=>Y,getServerData:()=>ye,getStoreNode:()=>vt,indexArray:()=>Bt,isComponent:()=>xr,isMemo:()=>Sr,isOwnerDisposed:()=>cr,isProvider:()=>jr,isResource:()=>Or,isSignal:()=>pe,isStore:()=>gt,isStoreProxy:()=>xe,isSuspense:()=>kr,keyArray:()=>Ut,makeArrayFlat:()=>De,mapArray:()=>qt,memo:()=>Zt,modifiable:()=>At,nextResourceId:()=>he,on:()=>Tr,onCleanup:()=>v,operate:()=>Et,produceUtil:()=>Tt,provide:()=>U,provideErrorBoundary:()=>Br,provideSuspense:()=>Nr,readChildren:()=>Fr,reconcileUtil:()=>St,reportResourceData:()=>me,resource:()=>Wr,runWithOwner:()=>B,setOwner:()=>$e,setResourceDataSink:()=>$r,setResourceIdSource:()=>_r,setResourceTracker:()=>Rr,setServerDataGetter:()=>Pr,signal:()=>Jt,startTransition:()=>Ce,store:()=>Ot,trackResourcePromise:()=>de,untrack:()=>w,untrackStore:()=>Ye,unwrap:()=>L,useContext:()=>fr,useTransition:()=>Ar,wrap:()=>mt});var rr="1.0.0-alpha.77";function je(e){return typeof e=="function"&&!tr(e)}var nr=e=>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 tr(e){return typeof e=="function"&&/^class\s/.test(Function.prototype.toString.call(e))}var D=class e{constructor(r){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;r&&(this._subscriptions=[r])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:r,_subscriptions:t}=this;if(r instanceof e)r.remove(this);else if(r!==null)for(let n of r)n.remove(this);if(t){for(let n of t)if(je(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if(nr(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(r){if(!r||r===this)return this;if(r.closed)return this;let{_closed:t,_subscriptions:n}=this;if(t){if(je(r))try{r()}catch(o){console.error("Error in unsubscribe function:",o)}else if(r.unsubscribe)try{r.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(r),r instanceof e&&r._addParent(this),this}remove(r){let{_subscriptions:t}=this;if(!t)return;let n=t.indexOf(r);n!==-1&&(t.splice(n,1),r._removeParent(this))}_addParent(r){let{_parentOrParents:t}=this;t?Array.isArray(t)?t.push(r):this._parentOrParents=[t,r]:this._parentOrParents=r}_removeParent(r){let{_parentOrParents:t}=this;if(t===r)this._parentOrParents=null;else if(Array.isArray(t)){let n=t.indexOf(r);n!==-1&&(t.splice(n,1),t.length===1&&(this._parentOrParents=t[0]))}}};var I=class extends D{constructor(t,n,o){super();this.isStopped=!1;let i;t?typeof t=="object"?i=t:i={next:t,error:n,complete:o}:i={},this.destination=i}next(t){if(!this.isStopped&&this.destination.next)try{this.destination.next(t)}catch(n){this.error(n)}}error(t){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(t)}catch(n){throw n}else throw t;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(t){this.error(t);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},ae=class extends I{constructor(t,n,o,i){super(t,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=i||null}next(t){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(t)}catch(n){this.error(n)}}error(t){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(t)}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 Et(e){return new I(e.next,e.error,e.complete)}var F=class extends D{constructor(r){if(super(),r)this._subscribe=r;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(r,t,n){let o;r instanceof I?o=r:o=new ae(r,t,n);let{_subscribe:i}=this;try{let s=i.call(this,o);s&&(typeof s=="function"||typeof s.unsubscribe=="function")&&o.add(s)}catch(s){o.error(s)}return o}pipe(...r){return r.length===0?this:r.reduce((t,n)=>n(t),this)}toPromise(){return new Promise((r,t)=>{let n;this.subscribe({next:o=>n=o,error:t,complete:()=>r(n)})})}};var Re=class extends F{constructor(){super(t=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)t.error(this.thrownError);else if(this.isStopped)t.complete();else return this.observers.push(t),()=>{let n=this.observers.indexOf(t);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(t){if(this.isStopped)return;let{observers:n}=this,o=n.length,i=n.slice();for(let s=0;s<o;s++)i[s].next?.(t)}error(t){if(this.isStopped)return;this.hasError=!0,this.thrownError=t,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,i=n.slice();for(let s=0;s<o;s++)i[s].error?.(t)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:t}=this;this.observers=[];let n=t.length,o=t.slice();for(let i=0;i<n;i++)o[i].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new F(n=>this.subscribe(n))}};var Ct="__fluixi_signal_next_state__",Dt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[Ct]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Dt,onSuspend:null,onError:null};var or=0,ir=1,z=2,ue=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let r=a.consumer;r&&((this.observers??=new Set).add(r),(r.sources??=new Set).add(this))}},M=class extends ue{constructor(r,t){super(),this._value=r,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(r){if(!this._equals(this._value,r)){if(this._value=r,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(z);Pe(this)}}peek(){return this._value}},k=class extends ue{constructor(t,n){super();this._threw=!1;this._initialized=!1;this.state=z;this.sources=null;this._fn=t,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){if(a.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===ir&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===z)break}(this.state===z||!this._initialized)&&this.recompute(),this.state=or}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let t=a.consumer,n=a.untracked;a.consumer=this,a.untracked=!1;let o,i=!1,s;try{o=this._fn()}catch(u){i=!0,s=u,o=this._value}finally{a.consumer=t,a.untracked=n}let c=!this._initialized||this._threw!==i||(i?s!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=i,this._error=s,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(z);Pe(this)}}markDirty(t){if(this.state>=t)return;let n=this.state===or;if(this.state=t,n){if(this.observers)for(let o of[...this.observers])o.markDirty(ir);Pe(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Pe(e){if(e.watchers)for(let r of[...e.watchers])r._notify(e)}var N=class{constructor(r){this._watched=new Set;this._pending=new Set;this._notifyFn=r}watch(...r){for(let t of r)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...r){for(let t of r)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let r=[...this._pending];return this._pending.clear(),r}_notify(r){if(!this._watched.has(r)||this._pending.has(r))return;let t=this._pending.size===0;this._pending.add(r),t&&this._notifyFn()}};function G(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function sr(){return a.consumer}function ar(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function ur(e){let r=Z(e);return e&&(e.owned??=[]).push(r),r}function lr(e,r=!0){J(e,r)}function cr(e){return!!e&&e.disposed===!0}function Z(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function q(e){let r=Symbol("context");return{id:r,defaultValue:e,Provider:n=>{let o=a.owner,i=Z(o);(i.contexts=new Map).set(r,n.value),o&&(o.owned??=[]).push(i),a.owner=i;try{return n.children}finally{a.owner=o}}}}function fr(e){let r=a.owner;for(;r;){if(r.contexts&&r.contexts.has(e.id))return r.contexts.get(e.id);r=r.parent}return e.defaultValue}function le(e,r){let t=e;for(;t;){if(t.contexts&&t.contexts.has(r.id))return t.contexts.get(r.id);t=t.parent}return r.defaultValue}function U(e,r,t){let n=Z(a.owner);(n.contexts=new Map).set(e.id,r),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return t()}finally{a.owner=o}}function pr(e){a.onSuspend=e}function dr(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function yr(e){a.onError=e}function Y(){return a.owner}function $e(e){let r=a.owner;return a.owner=e,r}function B(e,r){let t=a.owner;a.owner=e;try{return r()}finally{a.owner=t}}function v(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function J(e,r=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)J(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}r&&(e.disposed=!0)}}function _(e){let r=Z(a.owner);a.owner&&(a.owner.owned??=[]).push(r);let t=a.owner;a.owner=r;try{return e(()=>J(r))}finally{a.owner=t}}function hr(e){a.hostSchedule=e??(r=>{Promise.resolve().then(r)})}function It(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(Q)))}function Q(){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 r=a.queue;a.queue=[];for(let t of r)t.queued=!1,t.disposed||t.run()}}finally{a.flushing=!1}}function mr(){a.batchDepth===0&&Q()}function Ee(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&Q()}}var _e=class{constructor(r){this.queued=!1;this.disposed=!1;this.owner=Z(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new k(()=>{J(this.owner,!1),B(this.owner,()=>{let t=r();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new N(()=>It(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(r){if(r&&typeof r.then=="function"&&a.onSuspend){a.onSuspend(r,this.owner);return}if(a.onError&&a.onError(r,this.owner))return;throw r}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),J(this.owner))}};function ce(e){let r=new _e(e);return()=>r.dispose()}function Ft(e){return!!e&&typeof e.then=="function"}hr(()=>{});var gr=Symbol.for("signal"),Mt=Symbol.for("memo"),Nt=Symbol.for("signal-node");function d(e,r){let t=new M(e,{equals:r?.equals}),n=(()=>t.get()),o=(i=>{let s=typeof i=="function"?i(t.peek()):i;return t.set(s),mr(),s});return Object.defineProperty(n,gr,{value:!0,enumerable:!0}),Object.defineProperty(n,Nt,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[n,o]}function A(e,r,t){let n=r,o=Y(),i=new k(()=>B(o,()=>{try{return n=e(n)}catch(c){if(Ft(c))return dr(c),n;throw c}}),{equals:t?.equals}),s=(()=>i.get());return Object.defineProperty(s,gr,{value:!0,enumerable:!0}),Object.defineProperty(s,Mt,{value:!0,enumerable:!0}),s}function S(e,r){let t=r;return ce(()=>{t=e(t)})}function br(e,r){let t=r;ce(()=>{t=e(t)})}function vr(e,r){let t=r;return ce(()=>{t=e(t)})}function O(e){return Ee(e)}function w(e){return G(e)}function Ce(e){return Ee(e),Promise.resolve()}function Ar(){return[()=>!1,Ce]}function wr(){return Q(),Promise.resolve()}function Tr(e,r,t){let n=Array.isArray(e),o,i=t?.defer??!1;return s=>{let c=n?e.map(p=>p()):e();if(i){i=!1,o=c;return}let u=G(()=>r(c,o,s));return o=c,u}}function qt(e,r,t){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),A(()=>{let o=e()||[];return w(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],t?.fallback?t.fallback():[]}let i=new Map;for(let u of n)i.has(u.item)||i.set(u.item,u);let s=[],c=new Set;for(let u=0;u<o.length;u++){let p=o[u],h=i.get(p);if(h&&!c.has(h))h.setIndex(u),s.push(h),c.add(h);else{let f,y,m;_(g=>{m=g;let[E,K]=d(u);y=K,f=r(p,E)});let T={item:p,rendered:f,dispose:m,setIndex:y};s.push(T),c.add(T)}}for(let u of n)c.has(u)||u.dispose();return n=s,s.map(u=>u.rendered)})})}function Ut(e,r,t,n){let o=[],i=[];return v(()=>{for(let s of i)s.dispose();o=[],i=[]}),A(()=>{let s=e()||[];return w(()=>{if(s.length===0){for(let f of i)f.dispose();return o=[],i=[],n?.fallback?n.fallback():[]}let c=new Map;for(let f=0;f<o.length;f++)c.set(o[f],i[f]);let u=[],p=[],h=new Set;for(let f=0;f<s.length;f++){let y=r(s[f]),m=c.get(y);if(m&&!h.has(y))m.setIndex(f),u.push(m);else{let T,g,E;_(K=>{E=K;let[R,H]=d(f);g=H;let oe=A(C=>{let x=(e()||[])[R()];return x??C},s[f]);T=t(oe,R)}),u.push({rendered:T,dispose:E,setIndex:g})}p.push(y),h.add(y)}for(let[f,y]of c)h.has(f)||y.dispose();return o=p,i=u,u.map(f=>f.rendered)})})}function Bt(e,r,t){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),A(()=>{let o=e()||[];return w(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],t?.fallback?t.fallback():[]}let i=n.length,s=o.length;for(let u=i;u<s;u++){let p,h,f,y=o[u];_(m=>{f=m;let[T,g]=d(y);h=g,p=r(T,u)}),n.push({rendered:p,setItem:h,dispose:f})}for(let u=s;u<i;u++)n[u].dispose();s<i&&(n=n.slice(0,s));let c=Math.min(i,s);for(let u=0;u<c;u++)n[u].setItem(o[u]);return n.map(u=>u.rendered)})})}var fe=!1,Vt=Symbol.for("signal"),Wt=Symbol.for("memo"),Lt=Symbol.for("resource");function pe(e){return typeof e=="function"&&e[Vt]===!0}function Sr(e){return typeof e=="function"&&e[Wt]===!0}function Or(e){return typeof e=="function"&&e[Lt]===!0}function xr(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function kr(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function jr(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function De(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?De(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var Ie=null;function Rr(e){Ie=e}function de(e){Ie&&Ie(e)}var Fe=null;function Pr(e){Fe=e}function ye(e){return Fe?Fe(e):void 0}var Me=null;function _r(e){Me=e}function he(){return Me?Me():void 0}var Ne=null;function $r(e){Ne=e}function me(e,r){Ne&&Ne(e,r)}function Er(e,r=(t,n)=>t===n){let t=new Map;return S(()=>{let n=e();for(let[o,i]of t){let[s,c]=i,u=r(o,n);s()!==u&&c(u)}}),n=>{let o=t.get(n);if(!o){let[i,s]=d(!1);o=[i,s],t.set(n,o);let c=e();s(r(n,c))}return o[0]()}}function Cr(e,r){let[t,n]=d(e(),r);return S(()=>{let o=e();r?.timeoutMs?setTimeout(()=>n(()=>o),r.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),t}function Dr(e,r){let t,n=(...o)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e(...o)},r)};return v(()=>{t!==void 0&&clearTimeout(t)}),n}function Kt(e){return!!e&&typeof e.then=="function"}var qe=Symbol();function V(e,r,t={}){let n,o;typeof r=="function"?(n=typeof e=="function"?e:()=>e,o=r):(n=()=>!0,o=e,r&&typeof r=="object"&&(t=r));let i=t.transport===!1?void 0:he(),s=i!==void 0?ye(i):void 0,c=s!==void 0,[u,p]=d(s!==void 0?s.value:t.initialValue,{equals:!1}),[h,f]=d(void 0,{equals:!1}),[y,m]=d(s!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[T,g]=d(void 0,{equals:!1}),[E,K]=d(void 0,{equals:!1}),R=qe,H=!1;S(()=>{let b=n();if(E(),b===!1||b===null||b===void 0){R=qe,O(()=>{m("unresolved"),g(void 0),f(void 0)});return}let x=H;if(H=!1,R!==qe&&b===R&&!x)return;if(R=b,c){c=!1;return}let ie=!1;v(()=>ie=!0);let Xe=w(y),xt=w(u),er=Xe==="ready"||Xe==="refreshing";O(()=>{m(er?"refreshing":"pending"),f(void 0)});try{let P=o(b,{value:xt,refetching:er});Kt(P)?(g(P),de(P),P.then(se=>{ie||(i!==void 0&&me(i,se),O(()=>{p(()=>se),m("ready"),g(void 0)}))},se=>{ie||O(()=>{f(se),m("errored"),g(void 0)})})):O(()=>{p(()=>P),m("ready"),g(void 0)})}catch(P){if(ie)return;O(()=>{f(P),m("errored"),g(void 0)})}});let oe=()=>{let b=y();return b==="pending"||b==="refreshing"},C=(()=>{let b=h();if(b)throw b;if(oe()){let x=T();if(x)throw x}return u()});return Object.defineProperties(C,{state:{get:y},loading:{get:oe},error:{get:h},latest:{get:u}}),Object.defineProperty(C,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(C,Symbol.for("signal"),{value:!0,enumerable:!0}),[C,{mutate:p,refetch:()=>{H=!0,K(void 0)}}]}function Ue(e,r=300){let[t,n]=d(e),[o,i]=d(e),[s,c]=d(!1),u,p=()=>{u!==void 0&&(clearTimeout(u),u=void 0)},h=()=>{p();let y=w(t);return i(()=>y),c(!1),y},f=(y=>{let m=typeof y=="function"?y(w(t)):y;return n(()=>m),c(!0),p(),u=setTimeout(h,r),m});return v(p),[o,f,{immediate:t,pending:s,flush:h,cancel:()=>{p(),c(!1)}}]}function Ht(e){return e!=null&&e!==""}function Ir(e,r,t={}){let{delay:n=300,initialValue:o,shouldFetch:i=Ht}=t,[s,c,u]=Ue(e,n),p=()=>i(s())?s():!1,[h,{refetch:f}]=V(p,r,o===void 0?{}:{initialValue:o});return[h,{...u,query:s,setQuery:c,refetch:f}]}function ge(e){if(typeof e=="function"&&!e.length){let r=e();return pe(r)?r:ge(r)}if(Array.isArray(e)){let r=[];for(let t=0;t<e.length;t++){let n=ge(e[t]);Array.isArray(n)?r.push.apply(r,n):r.push(n)}return r}return e}function Fr(e){let r=A(e);return A(()=>ge(r()))}var be=q();pr((e,r)=>{let t=le(r,be);t&&(t.increment(),e.finally(()=>t.decrement()))});function Mr(){let[e,r]=d(0),t=0;return{increment:()=>r(t+=1),decrement:()=>r(t-=1),inFallback:()=>e()>0}}function Nr(e,r){return U(be,e,r)}var qr=q();yr((e,r)=>{let t=le(r,qr);return t?(t.setError(e),!0):!1});function Ur(){let[e,r]=d(void 0,{equals:!1});return{error:e,reset:()=>r(()=>{}),setError:n=>r(()=>n)}}function Br(e,r){return U(qr,e,r)}var Vr={State:M,Computed:k,subtle:{Watcher:N,untrack:G,currentComputed:sr,hasSinks:ar}};var zt=Symbol.for("signal"),Gt=Symbol.for("fluixi-proxy");function Jt(e,r){let[t,n]=d(e,r);return Object.assign(t,{set:n})}function Zt(e,r,t){return A(e,r,t)}function Yt(e,r){return S(e,r)}function Wr(...e){let[r,t]=V(...e);return Object.assign(r,t)}var Qt="__fluixi_signal_next_state__",Xt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},l=globalThis[Qt]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Xt,onSuspend:null,onError:null},Lr=0,Kr=1,X=2,Hr=class{constructor(){this.observers=null,this.watchers=null,this.version=0}updateIfNecessary(){}track(){if(l.untracked)return;let e=l.consumer;e&&((this.observers??=new Set).add(e),(e.sources??=new Set).add(this))}},en=class extends Hr{constructor(e,r){super(),this._value=e,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(e){if(!this._equals(this._value,e)){if(this._value=e,this.version++,this.observers)for(let r of[...this.observers])r.markDirty(X);Be(this)}}peek(){return this._value}},zr=class extends Hr{constructor(e,r){super(),this._threw=!1,this._initialized=!1,this.state=X,this.sources=null,this._fn=e,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){if(l.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===Kr&&this.sources){for(let e of this.sources)if(e.updateIfNecessary(),this.state===X)break}(this.state===X||!this._initialized)&&this.recompute(),this.state=Lr}recompute(){if(this.sources){for(let s of this.sources)s.observers?.delete(this);this.sources.clear()}let e=l.consumer,r=l.untracked;l.consumer=this,l.untracked=!1;let t,n=!1,o;try{t=this._fn()}catch(s){n=!0,o=s,t=this._value}finally{l.consumer=e,l.untracked=r}let i=!this._initialized||this._threw!==n||(n?o!==this._error:!this._equals(this._value,t));if(this._initialized=!0,this._threw=n,this._error=o,this._value=t,i){if(this.version++,this.observers)for(let s of[...this.observers])s.markDirty(X);Be(this)}}markDirty(e){if(this.state>=e)return;let r=this.state===Lr;if(this.state=e,r){if(this.observers)for(let t of[...this.observers])t.markDirty(Kr);Be(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Be(e){if(e.watchers)for(let r of[...e.watchers])r._notify(e)}var rn=class{constructor(e){this._watched=new Set,this._pending=new Set,this._notifyFn=e}watch(...e){for(let r of e)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...e){for(let r of e)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let e=[...this._pending];return this._pending.clear(),e}_notify(e){if(!this._watched.has(e)||this._pending.has(e))return;let r=this._pending.size===0;this._pending.add(e),r&&this._notifyFn()}};function tn(e){if(l.untracked)return e();l.untracked=!0;try{return e()}finally{l.untracked=!1}}function Gr(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function Jr(e){let r=Symbol("context");return{id:r,defaultValue:e,Provider:t=>{let n=l.owner,o=Gr(n);(o.contexts=new Map).set(r,t.value),n&&(n.owned??=[]).push(o),l.owner=o;try{return t.children}finally{l.owner=n}}}}function Zr(e,r){let t=e;for(;t;){if(t.contexts&&t.contexts.has(r.id))return t.contexts.get(r.id);t=t.parent}return r.defaultValue}function nn(e){l.onSuspend=e}function on(e){return l.onSuspend?(l.onSuspend(e,l.owner),!0):!1}function sn(e){l.onError=e}function an(){return l.owner}function Yr(e,r){let t=l.owner;l.owner=e;try{return r()}finally{l.owner=t}}function Ve(e,r=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)Ve(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}r&&(e.disposed=!0)}}function un(e){l.hostSchedule=e??(r=>{Promise.resolve().then(r)})}function ln(e){e.queued||(e.queued=!0,l.queue.push(e),!l.scheduled&&l.batchDepth===0&&(l.scheduled=!0,l.hostSchedule(We)))}function We(){if(l.scheduled=!1,l.flushing)return;l.flushing=!0;let e=0;try{for(;l.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let r=l.queue;l.queue=[];for(let t of r)t.queued=!1,t.disposed||t.run()}}finally{l.flushing=!1}}function cn(){l.batchDepth===0&&We()}function fn(e){l.batchDepth++;try{return e()}finally{--l.batchDepth===0&&We()}}var pn=class{constructor(e){this.queued=!1,this.disposed=!1,this.owner=Gr(l.owner),l.owner&&(l.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new zr(()=>{Ve(this.owner,!1),Yr(this.owner,()=>{let r=e();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new rn(()=>ln(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(e){if(e&&typeof e.then=="function"&&l.onSuspend){l.onSuspend(e,this.owner);return}if(l.onError&&l.onError(e,this.owner))return;throw e}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),Ve(this.owner))}};function dn(e){let r=new pn(e);return()=>r.dispose()}function yn(e){return!!e&&typeof e.then=="function"}un(()=>{});var Qr=Symbol.for("signal"),hn=Symbol.for("memo"),mn=Symbol.for("signal-node");function Le(e,r){let t=new en(e,{equals:r?.equals}),n=(()=>t.get()),o=(i=>{let s=typeof i=="function"?i(t.peek()):i;return t.set(s),cn(),s});return Object.defineProperty(n,Qr,{value:!0,enumerable:!0}),Object.defineProperty(n,mn,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[n,o]}function ve(e,r,t){let n=r,o=an(),i=new zr(()=>Yr(o,()=>{try{return n=e(n)}catch(c){if(yn(c))return on(c),n;throw c}}),{equals:t?.equals}),s=(()=>i.get());return Object.defineProperty(s,Qr,{value:!0,enumerable:!0}),Object.defineProperty(s,hn,{value:!0,enumerable:!0}),s}function ee(e,r){let t=r;return dn(()=>{t=e(t)})}function Ke(e){return fn(e)}function Xr(e){return tn(e)}var gn=Jr();nn((e,r)=>{let t=Zr(r,gn);t&&(t.increment(),e.finally(()=>t.decrement()))});var bn=Jr();sn((e,r)=>{let t=Zr(r,bn);return t?(t.setError(e),!0):!1});var Ae=Symbol.for("fluixi-proxy");var te=Symbol("store-raw"),$=Symbol("store-node"),et=Symbol("store-has"),Te=Symbol("store-self"),Se=Symbol("store-track"),at=Symbol("store-name"),ut=Symbol("store-store"),rt=new WeakMap,tt=new WeakMap;function lt(e){let[r,t]=Le(e),n=r;return n.$=t,n}function Oe(e){let r=rt.get(e);return r||rt.set(e,r={keys:new Map}),r}function nt(e,r,t){let n=e.keys.get(r);return n||e.keys.set(r,n=lt(t)),n}function ot(e){let r=Oe(e);(r.all||(r.all=lt()))()}function it(e,r){e.$(typeof r=="function"?()=>r:r)}function ct(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let r=Object.getPrototypeOf(e);return r===Object.prototype||r===null}function we(e){if(!ct(e))return e;let r=tt.get(e);if(r)return r;let t=new Proxy(e,vn);return tt.set(e,t),t}var vn={get(e,r,t){if(r===te||r===$)return e;if(r===Ae)return t;if(r===et)return s=>s in e;if(r==="__proxy")return!0;if(r===Se||r===Te)return ot(e),t;let n=e[r];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,r))return n;let o=Object.getOwnPropertyDescriptor(e,r);if(o&&o.get)return o.get.call(t);let i=nt(Oe(e),r,n)();return ct(i)?we(i):i},set(){return!0},deleteProperty(e,r){return r in e&&re(e,r,void 0),!0},has(e,r){return r===te||r===Ae||r===$||r===et||r===Te||r===Se?!0:(nt(Oe(e),r,e[r])(),r in e)},ownKeys(e){return ot(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,r){return Reflect.getOwnPropertyDescriptor(e,r)}};function re(e,r,t){if(e[r]===t&&(t!==void 0||r in e))return;let o=Array.isArray(e),i=o?e.length:0;t===void 0?delete e[r]:e[r]=t;let s=Oe(e),c=s.keys.get(r);if(c&&it(c,t),o&&e.length!==i){let u=s.keys.get("length");u&&it(u,e.length)}s.all&&s.all.$(void 0)}function st(e,r){return typeof e=="function"?e(r):e}function ze(e,r){for(let t of Object.keys(r)){let n=r[t],o=e[t];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?ze(o,n):re(e,t,n)}}function Je(e){let r=[],t=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of t.split("."))n.length&&r.push(n);return r}function ft(e,r,t){let n=r.length-1;for(let i=0;i<n;i++){let s=r[i];if(s==="*"){let u=r.slice(i+1);if(Array.isArray(e))for(let p=0;p<e.length;p++)ft(e[p],u,t);return}let c=e[s];(c==null||typeof c!="object")&&(c=/^\d+$/.test(r[i+1])?[]:{},re(e,s,c)),e=c}let o=r[n];if(o==="*"){if(Array.isArray(e))for(let i=0;i<e.length;i++)re(e,i,st(t,e[i]));return}re(e,o,st(t,e[o]))}function He(e,r,t){ft(e,Je(r),t)}function An(e,r){let t=r[0];if(typeof t=="function"&&r.length===1){let n=t(e);n&&n!==e&&ze(e,n);return}if(Array.isArray(t)&&r.length===1){for(let n of t)Array.isArray(n)&&He(e,n[0],n[1]);return}if(t&&typeof t=="object"&&!Array.isArray(t)&&r.length===1){ze(e,t);return}if(Array.isArray(r[1])&&r.length>=3){He(e,`${t}.${r[1].join(".")}`,r[2]);return}He(e,String(t),r[1])}function Ge(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ge);let r={};for(let t of Object.keys(e))r[t]=Ge(e[t]);return r}function W(e,r){let t=e;for(let n of Je(r)){if(t==null)return;t=t[n]}return t}var j=class{constructor(r,t={immutable:!0}){this.options=t;this.root=r,this.set=((...n)=>Ke(()=>An(this.root,n)))}get state(){return we(this.root)}get proxy(){return we(this.root)}get accessor(){return(()=>we(this.root))}unwrap(){return this.root}getNode(r){return this.root&&this.root[r]}get(r){if(r==null||r==="")return L(this.state);let t=this.state;for(let n of Je(r)){if(t==null)return;t=t[n]}return L(t)}select(r){return ve(()=>r(this.state))}subscribe(r){return ee(()=>r(this.state))}watch(r,t){let n;return ee(()=>{let o=r(this.state);Object.is(o,n)||(t(o,n),n=o)})}reactive(r){return ve(()=>this.state[r])}produce(r){this.set((t=>{let n=Ge(t);return r(n),n}))}reconcile(r,t={}){this.set(r)}push(r,...t){let n=W(this.root,r);this.set(r,n.concat(t))}pop(r){let t=W(this.root,r).slice(),n=t.pop();return this.set(r,t),n}shift(r){let t=W(this.root,r).slice(),n=t.shift();return this.set(r,t),n}splice(r,t,n,...o){let i=W(this.root,r).slice(),s=i.splice(t,n,...o);return this.set(r,i),s}insert(r,t,n){let o=W(this.root,r).slice();o.splice(t,0,n),this.set(r,o)}removeAt(r,t){let n=W(this.root,r).slice(),o=n.splice(t,1);return this.set(r,n),o}toObservable(){let[r]=Le(this.state);return r.toObservable()}dispose(){}},wn=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function pt(e,r){for(let t of wn)e[t]=r[t].bind(r);e.$=r.reactive.bind(r)}function ne(e,r={immutable:!0}){let t=new j(e,r);return pt(t.set,t),[t.proxy,t.set]}function Ze(e,r={}){return new j(e,{...r,immutable:!1})}function dt(e,r={}){let t=new j(e(),r);return ee(()=>t.set(e())),t}function yt(e,r,t){return ee(()=>t(r(e)))}function ht(e,r,t){return ve(()=>r(e),void 0,t)}function mt(e,r={}){let t=new j(e,r),n=(()=>t.proxy);return pt(n,t),n}function L(e){if(e==null||typeof e!="object")return e;let r=e[te];return r!==void 0?r:e}function Ye(e){return Xr(()=>L(e))}function gt(e){return xe(e)}function bt(e){return xe(e)?e[$]:null}function vt(e){return e&&typeof e=="object"&&$ in e?e[$]:null}function xe(e){return!!e&&typeof e=="object"&&(Ae in e||e.__proxy===!0)}function At(e){return e}var wt=Object.freeze({createStore:ne,createMutableStore:Ze,batch:Ke,unwrap:L,untrackStore:Ye});function Qe(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Qe);let r={};for(let t of Object.keys(e))r[t]=Qe(e[t]);return r}function Tt(e){return r=>{let t=Qe(r);return e(t),t}}function St(e,r={}){return()=>e}function Ot(e,r){let[t,n]=ne(e,r);return new Proxy(t,{get:(o,i)=>i==="set"?n:o[i],has:(o,i)=>i==="set"||Reflect.has(o,i)})}return $t(Tn);})();
|
package/dist/cdn/reactive.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var mt="1.0.0-alpha.76";import{isObject as vt}from"@fluixi/utils/object";import{isFunction as Ne}from"@fluixi/utils/functions";var q=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:r}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let n of t)n.remove(this);if(r){for(let n of r)if(Ne(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if(vt(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:r,_subscriptions:n}=this;if(r){if(Ne(t))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(t.unsubscribe)try{t.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(t);n!==-1&&(r.splice(n,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:r}=this;r?Array.isArray(r)?r.push(t):this._parentOrParents=[r,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:r}=this;if(r===t)this._parentOrParents=null;else if(Array.isArray(r)){let n=r.indexOf(t);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var N=class extends q{constructor(r,n,o){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:n,complete:o}:s={},this.destination=s}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(n){throw n}else throw r;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(r){this.error(r);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},pe=class extends N{constructor(r,n,o,s){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(r)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};function kr(e){return new N(e.next,e.error,e.complete)}var M=class extends q{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,r,n){let o;t instanceof N?o=t:o=new pe(t,r,n);let{_subscribe:s}=this;try{let i=s.call(this,o);i&&(typeof i=="function"||typeof i.unsubscribe=="function")&&o.add(i)}catch(i){o.error(i)}return o}pipe(...t){return t.length===0?this:t.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((t,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>t(n)})})}};var Me=class extends M{constructor(){super(r=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)r.error(this.thrownError);else if(this.isStopped)r.complete();else return this.observers.push(r),()=>{let n=this.observers.indexOf(r);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(r){if(this.isStopped)return;let{observers:n}=this,o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].next?.(r)}error(r){if(this.isStopped)return;this.hasError=!0,this.thrownError=r,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].error?.(r)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:r}=this;this.observers=[];let n=r.length,o=r.slice();for(let s=0;s<n;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new M(n=>this.subscribe(n))}};var St="__fluixi_signal_next_state__",xt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[St]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:xt,onSuspend:null,onError:null};var He=0,$e=1,H=2,te=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))}},D=class extends te{constructor(t,r){super(),this._value=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let r of[...this.observers])r.markDirty(H);fe(this)}}peek(){return this._value}},O=class extends te{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=H;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){if(a.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===$e&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===H)break}(this.state===H||!this._initialized)&&this.recompute(),this.state=He}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=a.consumer,n=a.untracked;a.consumer=this,a.untracked=!1;let o,s=!1,i;try{o=this._fn()}catch(u){s=!0,i=u,o=this._value}finally{a.consumer=r,a.untracked=n}let c=!this._initialized||this._threw!==s||(s?i!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=s,this._error=i,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(H);fe(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===He;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty($e);fe(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function fe(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var C=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function $(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function Le(){return a.consumer}function Ve(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function wt(e){let t=V(e);return e&&(e.owned??=[]).push(t),t}function Ot(e,t=!0){L(e,t)}function gt(e){return!!e&&e.disposed===!0}function V(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function G(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=V(o);(s.contexts=new Map).set(t,n.value),o&&(o.owned??=[]).push(s),a.owner=s;try{return n.children}finally{a.owner=o}}}}function At(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 re(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function K(e,t,r){let n=V(a.owner);(n.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return r()}finally{a.owner=o}}function Ge(e){a.onSuspend=e}function Ke(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function We(e){a.onError=e}function ne(){return a.owner}function ze(e){let t=a.owner;return a.owner=e,t}function W(e,t){let r=a.owner;a.owner=e;try{return t()}finally{a.owner=r}}function m(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function L(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)L(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}t&&(e.disposed=!0)}}function F(e){let t=V(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>L(t))}finally{a.owner=r}}function Ye(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function Rt(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(z)))}function z(){if(a.scheduled=!1,a.flushing)return;a.flushing=!0;let e=0;try{for(;a.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function Xe(){a.batchDepth===0&&z()}function ye(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&z()}}var de=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=V(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new O(()=>{L(this.owner,!1),W(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new C(()=>Rt(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),L(this.owner))}};function oe(e){let t=new de(e);return()=>t.dispose()}function _t(e){return!!e&&typeof e.then=="function"}Ye(()=>{});var Qe=Symbol.for("signal"),Et=Symbol.for("memo"),kt=Symbol.for("signal-node");function f(e,t){let r=new D(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),Xe(),i});return Object.defineProperty(n,Qe,{value:!0,enumerable:!0}),Object.defineProperty(n,kt,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function v(e,t,r){let n=t,o=ne(),s=new O(()=>W(o,()=>{try{return n=e(n)}catch(c){if(_t(c))return Ke(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,Qe,{value:!0,enumerable:!0}),Object.defineProperty(i,Et,{value:!0,enumerable:!0}),i}function g(e,t){let r=t;return oe(()=>{r=e(r)})}function Pt(e,t){let r=t;oe(()=>{r=e(r)})}function Dt(e,t){let r=t;return oe(()=>{r=e(r)})}function A(e){return ye(e)}function S(e){return $(e)}function Je(e){return ye(e),Promise.resolve()}function Ct(){return[()=>!1,Je]}function Ft(){return z(),Promise.resolve()}function It(e,t,r){let n=Array.isArray(e),o,s=r?.defer??!1;return i=>{let c=n?e.map(p=>p()):e();if(s){s=!1,o=c;return}let u=$(()=>t(c,o,i));return o=c,u}}function Vr(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),v(()=>{let o=e()||[];return S(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=new Map;for(let u of n)s.has(u.item)||s.set(u.item,u);let i=[],c=new Set;for(let u=0;u<o.length;u++){let p=o[u],y=s.get(p);if(y&&!c.has(y))y.setIndex(u),i.push(y),c.add(y);else{let l,d,T;F(h=>{T=h;let[k,j]=f(u);d=j,l=t(p,k)});let x={item:p,rendered:l,dispose:T,setIndex:d};i.push(x),c.add(x)}}for(let u of n)c.has(u)||u.dispose();return n=i,i.map(u=>u.rendered)})})}function Gr(e,t,r,n){let o=[],s=[];return m(()=>{for(let i of s)i.dispose();o=[],s=[]}),v(()=>{let i=e()||[];return S(()=>{if(i.length===0){for(let l of s)l.dispose();return o=[],s=[],n?.fallback?n.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],s[l]);let u=[],p=[],y=new Set;for(let l=0;l<i.length;l++){let d=t(i[l]),T=c.get(d);if(T&&!y.has(d))T.setIndex(l),u.push(T);else{let x,h,k;F(j=>{k=j;let[R,B]=f(l);h=B;let J=v(P=>{let w=(e()||[])[R()];return w??P},i[l]);x=r(J,R)}),u.push({rendered:x,dispose:k,setIndex:h})}p.push(d),y.add(d)}for(let[l,d]of c)y.has(l)||d.dispose();return o=p,s=u,u.map(l=>l.rendered)})})}function Kr(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),v(()=>{let o=e()||[];return S(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=n.length,i=o.length;for(let u=s;u<i;u++){let p,y,l,d=o[u];F(T=>{l=T;let[x,h]=f(d);y=h,p=t(x,u)}),n.push({rendered:p,setItem:y,dispose:l})}for(let u=i;u<s;u++)n[u].dispose();i<s&&(n=n.slice(0,i));let c=Math.min(s,i);for(let u=0;u<c;u++)n[u].setItem(o[u]);return n.map(u=>u.rendered)})})}var Te=!1,Ut=Symbol.for("signal"),jt=Symbol.for("memo"),Bt=Symbol.for("resource");function he(e){return typeof e=="function"&&e[Ut]===!0}function qt(e){return typeof e=="function"&&e[jt]===!0}function Nt(e){return typeof e=="function"&&e[Bt]===!0}function Mt(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Ht(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function $t(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 be=null;function Lt(e){be=e}function xe(e){be&&be(e)}var me=null;function Vt(e){me=e}function we(e){return me?me(e):void 0}var ve=null;function Gt(e){ve=e}function Oe(){return ve?ve():void 0}var Se=null;function Kt(e){Se=e}function ge(e,t){Se&&Se(e,t)}function Wt(e,t=(r,n)=>r===n){let r=new Map;return g(()=>{let n=e();for(let[o,s]of r){let[i,c]=s,u=t(o,n);i()!==u&&c(u)}}),n=>{let o=r.get(n);if(!o){let[s,i]=f(!1);o=[s,i],r.set(n,o);let c=e();i(t(n,c))}return o[0]()}}function zt(e,t){let[r,n]=f(e(),t);return g(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function Yt(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,e(...o)},t)};return m(()=>{r!==void 0&&clearTimeout(r)}),n}function Xt(e){return!!e&&typeof e.then=="function"}var Ae=Symbol();function Y(e,t,r={}){let n,o;typeof t=="function"?(n=typeof e=="function"?e:()=>e,o=t):(n=()=>!0,o=e,t&&typeof t=="object"&&(r=t));let s=r.transport===!1?void 0:Oe(),i=s!==void 0?we(s):void 0,c=i!==void 0,[u,p]=f(i!==void 0?i.value:r.initialValue,{equals:!1}),[y,l]=f(void 0,{equals:!1}),[d,T]=f(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[x,h]=f(void 0,{equals:!1}),[k,j]=f(void 0,{equals:!1}),R=Ae,B=!1;g(()=>{let b=n();if(k(),b===!1||b===null||b===void 0){R=Ae,A(()=>{T("unresolved"),h(void 0),l(void 0)});return}let w=B;if(B=!1,R!==Ae&&b===R&&!w)return;if(R=b,c){c=!1;return}let Z=!1;m(()=>Z=!0);let Be=S(d),bt=S(u),qe=Be==="ready"||Be==="refreshing";A(()=>{T(qe?"refreshing":"pending"),l(void 0)});try{let _=o(b,{value:bt,refetching:qe});Xt(_)?(h(_),xe(_),_.then(ee=>{Z||(s!==void 0&&ge(s,ee),A(()=>{p(()=>ee),T("ready"),h(void 0)}))},ee=>{Z||A(()=>{l(ee),T("errored"),h(void 0)})})):A(()=>{p(()=>_),T("ready"),h(void 0)})}catch(_){if(Z)return;A(()=>{l(_),T("errored"),h(void 0)})}});let J=()=>{let b=d();return b==="pending"||b==="refreshing"},P=(()=>{let b=y();if(b)throw b;if(J()){let w=x();if(w)throw w}return u()});return Object.defineProperties(P,{state:{get:d},loading:{get:J},error:{get:y},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:p,refetch:()=>{B=!0,j(void 0)}}]}function et(e,t=300){let[r,n]=f(e),[o,s]=f(e),[i,c]=f(!1),u,p=()=>{u!==void 0&&(clearTimeout(u),u=void 0)},y=()=>{p();let d=S(r);return s(()=>d),c(!1),d},l=(d=>{let T=typeof d=="function"?d(S(r)):d;return n(()=>T),c(!0),p(),u=setTimeout(y,t),T});return m(p),[o,l,{immediate:r,pending:i,flush:y,cancel:()=>{p(),c(!1)}}]}function Qt(e){return e!=null&&e!==""}function Jt(e,t,r={}){let{delay:n=300,initialValue:o,shouldFetch:s=Qt}=r,[i,c,u]=et(e,n),p=()=>s(i())?i():!1,[y,{refetch:l}]=Y(p,t,o===void 0?{}:{initialValue:o});return[y,{...u,query:i,setQuery:c,refetch:l}]}function se(e){if(typeof e=="function"&&!e.length){let t=e();return he(t)?t:se(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=se(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Zt(e){let t=v(e);return v(()=>se(t()))}var Re=G();Ge((e,t)=>{let r=re(t,Re);r&&(r.increment(),e.finally(()=>r.decrement()))});function er(){let[e,t]=f(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function tr(e,t){return K(Re,e,t)}var tt=G();We((e,t)=>{let r=re(t,tt);return r?(r.setError(e),!0):!1});function rr(){let[e,t]=f(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function nr(e,t){return K(tt,e,t)}var or={State:D,Computed:O,subtle:{Watcher:C,untrack:$,currentComputed:Le,hasSinks:Ve}};var hn=Symbol.for("signal"),bn=Symbol.for("fluixi-proxy");function Cn(e,t){let[r,n]=f(e,t);return Object.assign(r,{set:n})}function Fn(e,t,r){return v(e,t,r)}function In(e,t){return g(e,t)}function sr(...e){let[t,r]=Y(...e);return Object.assign(t,r)}import{$PROXY as Ee,batch as ct,createEffect as ae,createMemo as ke,createSignal as lt,untrack as ir}from"@fluixi/reactive/signal";var ue=Symbol("store-raw"),U=Symbol("store-node"),rt=Symbol("store-has"),Pe=Symbol("store-self"),De=Symbol("store-track"),ar=Symbol("store-name"),ur=Symbol("store-store"),nt=new WeakMap,ot=new WeakMap;function pt(e){let[t,r]=lt(e),n=t;return n.$=r,n}function ce(e){let t=nt.get(e);return t||nt.set(e,t={keys:new Map}),t}function st(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=pt(r)),n}function it(e){let t=ce(e);(t.all||(t.all=pt()))()}function at(e,t){e.$(typeof t=="function"?()=>t:t)}function ft(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 ie(e){if(!ft(e))return e;let t=ot.get(e);if(t)return t;let r=new Proxy(e,cr);return ot.set(e,r),r}var cr={get(e,t,r){if(t===ue||t===U)return e;if(t===Ee)return r;if(t===rt)return i=>i in e;if(t==="__proxy")return!0;if(t===De||t===Pe)return it(e),r;let n=e[t];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return n;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(r);let s=st(ce(e),t,n)();return ft(s)?ie(s):s},set(){return!0},deleteProperty(e,t){return t in e&&X(e,t,void 0),!0},has(e,t){return t===ue||t===Ee||t===U||t===rt||t===Pe||t===De?!0:(st(ce(e),t,e[t])(),t in e)},ownKeys(e){return it(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function X(e,t,r){if(e[t]===r&&(r!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;r===void 0?delete e[t]:e[t]=r;let i=ce(e),c=i.keys.get(t);if(c&&at(c,r),o&&e.length!==s){let u=i.keys.get("length");u&&at(u,e.length)}i.all&&i.all.$(void 0)}function ut(e,t){return typeof e=="function"?e(t):e}function Ce(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?Ce(o,n):X(e,r,n)}}function Ie(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function dt(e,t,r){let n=t.length-1;for(let s=0;s<n;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let p=0;p<e.length;p++)dt(e[p],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},X(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)X(e,s,ut(r,e[s]));return}X(e,o,ut(r,e[o]))}function _e(e,t,r){dt(e,Ie(t),r)}function lr(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&Ce(e,n);return}if(Array.isArray(r)&&t.length===1){for(let n of r)Array.isArray(n)&&_e(e,n[0],n[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){Ce(e,r);return}if(Array.isArray(t[1])&&t.length>=3){_e(e,`${r}.${t[1].join(".")}`,t[2]);return}_e(e,String(r),t[1])}function Fe(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Fe);let t={};for(let r of Object.keys(e))t[r]=Fe(e[r]);return t}function I(e,t){let r=e;for(let n of Ie(t)){if(r==null)return;r=r[n]}return r}var E=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>ct(()=>lr(this.root,n)))}get state(){return ie(this.root)}get proxy(){return ie(this.root)}get accessor(){return(()=>ie(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return Q(this.state);let r=this.state;for(let n of Ie(t)){if(r==null)return;r=r[n]}return Q(r)}select(t){return ke(()=>t(this.state))}subscribe(t){return ae(()=>t(this.state))}watch(t,r){let n;return ae(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return ke(()=>this.state[t])}produce(t){this.set((r=>{let n=Fe(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=I(this.root,t);this.set(t,n.concat(r))}pop(t){let r=I(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=I(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=I(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=I(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=I(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}toObservable(){let[t]=lt(this.state);return t.toObservable()}dispose(){}},pr=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function yt(e,t){for(let r of pr)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function le(e,t={immutable:!0}){let r=new E(e,t);return yt(r.set,r),[r.proxy,r.set]}function Tt(e,t={}){return new E(e,{...t,immutable:!1})}function fr(e,t={}){let r=new E(e(),t);return ae(()=>r.set(e())),r}function dr(e,t,r){return ae(()=>r(t(e)))}function yr(e,t,r){return ke(()=>t(e),void 0,r)}function Tr(e,t={}){let r=new E(e,t),n=(()=>r.proxy);return yt(n,r),n}function Q(e){if(e==null||typeof e!="object")return e;let t=e[ue];return t!==void 0?t:e}function ht(e){return ir(()=>Q(e))}function hr(e){return Ue(e)}function br(e){return Ue(e)?e[U]:null}function mr(e){return e&&typeof e=="object"&&U in e?e[U]:null}function Ue(e){return!!e&&typeof e=="object"&&(Ee in e||e.__proxy===!0)}function vr(e){return e}var Sr=Object.freeze({createStore:le,createMutableStore:Tt,batch:ct,unwrap:Q,untrackStore:ht});function je(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(je);let t={};for(let r of Object.keys(e))t[r]=je(e[r]);return t}function xr(e){return t=>{let r=je(t);return e(r),r}}function wr(e,t={}){return()=>e}function Or(e,t){let[r,n]=le(e,t);return new Proxy(r,{get:(o,s)=>s==="set"?n:o[s],has:(o,s)=>s==="set"||Reflect.has(o,s)})}export{ar as $NAME,U as $NODE,bn as $PROXY,ue as $RAW,Pe as $SELF,hn as $SIGNAL,ur as $STORE,De as $TRACK,M as Observable,pe as SafeSubscriber,or as Signal,E as Store,Sr as StoreAPI,Me as Subject,N as Subscriber,q as Subscription,Re as SuspenseContext,mt as VERSION,Te as __DEV__,A as batch,wt as createChildOwner,Pt as createComputed,fr as createComputedStore,G as createContext,Yt as createDebounce,Jt as createDebouncedResource,et as createDebouncedSignal,zt as createDeferred,g as createEffect,rr as createErrorBoundary,v as createMemo,Tt as createMutableStore,Dt as createRenderEffect,Y as createResource,F as createRoot,Wt as createSelector,f as createSignal,le as createStore,dr as createStoreEffect,yr as createStoreMemo,er as createSuspenseBoundary,Ot as disposeScope,In as effect,Ft as flush,br as getNode,ne as getOwner,we as getServerData,mr as getStoreNode,Kr as indexArray,Mt as isComponent,qt as isMemo,gt as isOwnerDisposed,$t as isProvider,Nt as isResource,he as isSignal,hr as isStore,Ue as isStoreProxy,Ht as isSuspense,Gr as keyArray,Ze as makeArrayFlat,Vr as mapArray,Fn as memo,vr as modifiable,Oe as nextResourceId,It as on,m as onCleanup,kr as operate,xr as produceUtil,K as provide,nr as provideErrorBoundary,tr as provideSuspense,Zt as readChildren,wr as reconcileUtil,ge as reportResourceData,sr as resource,W as runWithOwner,ze as setOwner,Kt as setResourceDataSink,Gt as setResourceIdSource,Lt as setResourceTracker,Vt as setServerDataGetter,Cn as signal,Je as startTransition,Or as store,xe as trackResourcePromise,S as untrack,ht as untrackStore,Q as unwrap,At as useContext,Ct as useTransition,Tr as wrap};
|
|
1
|
+
var mt="1.0.0-alpha.77";import{isObject as vt}from"@fluixi/utils/object";import{isFunction as Ne}from"@fluixi/utils/functions";var q=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:r}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let n of t)n.remove(this);if(r){for(let n of r)if(Ne(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if(vt(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:r,_subscriptions:n}=this;if(r){if(Ne(t))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(t.unsubscribe)try{t.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(t);n!==-1&&(r.splice(n,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:r}=this;r?Array.isArray(r)?r.push(t):this._parentOrParents=[r,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:r}=this;if(r===t)this._parentOrParents=null;else if(Array.isArray(r)){let n=r.indexOf(t);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var N=class extends q{constructor(r,n,o){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:n,complete:o}:s={},this.destination=s}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(n){throw n}else throw r;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(r){this.error(r);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},pe=class extends N{constructor(r,n,o,s){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(r)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};function kr(e){return new N(e.next,e.error,e.complete)}var M=class extends q{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,r,n){let o;t instanceof N?o=t:o=new pe(t,r,n);let{_subscribe:s}=this;try{let i=s.call(this,o);i&&(typeof i=="function"||typeof i.unsubscribe=="function")&&o.add(i)}catch(i){o.error(i)}return o}pipe(...t){return t.length===0?this:t.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((t,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>t(n)})})}};var Me=class extends M{constructor(){super(r=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)r.error(this.thrownError);else if(this.isStopped)r.complete();else return this.observers.push(r),()=>{let n=this.observers.indexOf(r);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(r){if(this.isStopped)return;let{observers:n}=this,o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].next?.(r)}error(r){if(this.isStopped)return;this.hasError=!0,this.thrownError=r,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].error?.(r)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:r}=this;this.observers=[];let n=r.length,o=r.slice();for(let s=0;s<n;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new M(n=>this.subscribe(n))}};var St="__fluixi_signal_next_state__",xt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[St]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:xt,onSuspend:null,onError:null};var He=0,$e=1,H=2,te=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))}},D=class extends te{constructor(t,r){super(),this._value=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let r of[...this.observers])r.markDirty(H);fe(this)}}peek(){return this._value}},O=class extends te{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=H;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){if(a.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===$e&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===H)break}(this.state===H||!this._initialized)&&this.recompute(),this.state=He}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=a.consumer,n=a.untracked;a.consumer=this,a.untracked=!1;let o,s=!1,i;try{o=this._fn()}catch(u){s=!0,i=u,o=this._value}finally{a.consumer=r,a.untracked=n}let c=!this._initialized||this._threw!==s||(s?i!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=s,this._error=i,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(H);fe(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===He;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty($e);fe(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function fe(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var C=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function $(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function Le(){return a.consumer}function Ve(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function wt(e){let t=V(e);return e&&(e.owned??=[]).push(t),t}function Ot(e,t=!0){L(e,t)}function gt(e){return!!e&&e.disposed===!0}function V(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function G(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=V(o);(s.contexts=new Map).set(t,n.value),o&&(o.owned??=[]).push(s),a.owner=s;try{return n.children}finally{a.owner=o}}}}function At(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 re(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function K(e,t,r){let n=V(a.owner);(n.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return r()}finally{a.owner=o}}function Ge(e){a.onSuspend=e}function Ke(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function We(e){a.onError=e}function ne(){return a.owner}function ze(e){let t=a.owner;return a.owner=e,t}function W(e,t){let r=a.owner;a.owner=e;try{return t()}finally{a.owner=r}}function m(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function L(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)L(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}t&&(e.disposed=!0)}}function F(e){let t=V(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>L(t))}finally{a.owner=r}}function Ye(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function Rt(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(z)))}function z(){if(a.scheduled=!1,a.flushing)return;a.flushing=!0;let e=0;try{for(;a.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function Xe(){a.batchDepth===0&&z()}function ye(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&z()}}var de=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=V(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new O(()=>{L(this.owner,!1),W(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new C(()=>Rt(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),L(this.owner))}};function oe(e){let t=new de(e);return()=>t.dispose()}function _t(e){return!!e&&typeof e.then=="function"}Ye(()=>{});var Qe=Symbol.for("signal"),Et=Symbol.for("memo"),kt=Symbol.for("signal-node");function f(e,t){let r=new D(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),Xe(),i});return Object.defineProperty(n,Qe,{value:!0,enumerable:!0}),Object.defineProperty(n,kt,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function v(e,t,r){let n=t,o=ne(),s=new O(()=>W(o,()=>{try{return n=e(n)}catch(c){if(_t(c))return Ke(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,Qe,{value:!0,enumerable:!0}),Object.defineProperty(i,Et,{value:!0,enumerable:!0}),i}function g(e,t){let r=t;return oe(()=>{r=e(r)})}function Pt(e,t){let r=t;oe(()=>{r=e(r)})}function Dt(e,t){let r=t;return oe(()=>{r=e(r)})}function A(e){return ye(e)}function S(e){return $(e)}function Je(e){return ye(e),Promise.resolve()}function Ct(){return[()=>!1,Je]}function Ft(){return z(),Promise.resolve()}function It(e,t,r){let n=Array.isArray(e),o,s=r?.defer??!1;return i=>{let c=n?e.map(p=>p()):e();if(s){s=!1,o=c;return}let u=$(()=>t(c,o,i));return o=c,u}}function Vr(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),v(()=>{let o=e()||[];return S(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=new Map;for(let u of n)s.has(u.item)||s.set(u.item,u);let i=[],c=new Set;for(let u=0;u<o.length;u++){let p=o[u],y=s.get(p);if(y&&!c.has(y))y.setIndex(u),i.push(y),c.add(y);else{let l,d,T;F(h=>{T=h;let[k,j]=f(u);d=j,l=t(p,k)});let x={item:p,rendered:l,dispose:T,setIndex:d};i.push(x),c.add(x)}}for(let u of n)c.has(u)||u.dispose();return n=i,i.map(u=>u.rendered)})})}function Gr(e,t,r,n){let o=[],s=[];return m(()=>{for(let i of s)i.dispose();o=[],s=[]}),v(()=>{let i=e()||[];return S(()=>{if(i.length===0){for(let l of s)l.dispose();return o=[],s=[],n?.fallback?n.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],s[l]);let u=[],p=[],y=new Set;for(let l=0;l<i.length;l++){let d=t(i[l]),T=c.get(d);if(T&&!y.has(d))T.setIndex(l),u.push(T);else{let x,h,k;F(j=>{k=j;let[R,B]=f(l);h=B;let J=v(P=>{let w=(e()||[])[R()];return w??P},i[l]);x=r(J,R)}),u.push({rendered:x,dispose:k,setIndex:h})}p.push(d),y.add(d)}for(let[l,d]of c)y.has(l)||d.dispose();return o=p,s=u,u.map(l=>l.rendered)})})}function Kr(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),v(()=>{let o=e()||[];return S(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=n.length,i=o.length;for(let u=s;u<i;u++){let p,y,l,d=o[u];F(T=>{l=T;let[x,h]=f(d);y=h,p=t(x,u)}),n.push({rendered:p,setItem:y,dispose:l})}for(let u=i;u<s;u++)n[u].dispose();i<s&&(n=n.slice(0,i));let c=Math.min(s,i);for(let u=0;u<c;u++)n[u].setItem(o[u]);return n.map(u=>u.rendered)})})}var Te=!1,Ut=Symbol.for("signal"),jt=Symbol.for("memo"),Bt=Symbol.for("resource");function he(e){return typeof e=="function"&&e[Ut]===!0}function qt(e){return typeof e=="function"&&e[jt]===!0}function Nt(e){return typeof e=="function"&&e[Bt]===!0}function Mt(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Ht(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function $t(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 be=null;function Lt(e){be=e}function xe(e){be&&be(e)}var me=null;function Vt(e){me=e}function we(e){return me?me(e):void 0}var ve=null;function Gt(e){ve=e}function Oe(){return ve?ve():void 0}var Se=null;function Kt(e){Se=e}function ge(e,t){Se&&Se(e,t)}function Wt(e,t=(r,n)=>r===n){let r=new Map;return g(()=>{let n=e();for(let[o,s]of r){let[i,c]=s,u=t(o,n);i()!==u&&c(u)}}),n=>{let o=r.get(n);if(!o){let[s,i]=f(!1);o=[s,i],r.set(n,o);let c=e();i(t(n,c))}return o[0]()}}function zt(e,t){let[r,n]=f(e(),t);return g(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function Yt(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,e(...o)},t)};return m(()=>{r!==void 0&&clearTimeout(r)}),n}function Xt(e){return!!e&&typeof e.then=="function"}var Ae=Symbol();function Y(e,t,r={}){let n,o;typeof t=="function"?(n=typeof e=="function"?e:()=>e,o=t):(n=()=>!0,o=e,t&&typeof t=="object"&&(r=t));let s=r.transport===!1?void 0:Oe(),i=s!==void 0?we(s):void 0,c=i!==void 0,[u,p]=f(i!==void 0?i.value:r.initialValue,{equals:!1}),[y,l]=f(void 0,{equals:!1}),[d,T]=f(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[x,h]=f(void 0,{equals:!1}),[k,j]=f(void 0,{equals:!1}),R=Ae,B=!1;g(()=>{let b=n();if(k(),b===!1||b===null||b===void 0){R=Ae,A(()=>{T("unresolved"),h(void 0),l(void 0)});return}let w=B;if(B=!1,R!==Ae&&b===R&&!w)return;if(R=b,c){c=!1;return}let Z=!1;m(()=>Z=!0);let Be=S(d),bt=S(u),qe=Be==="ready"||Be==="refreshing";A(()=>{T(qe?"refreshing":"pending"),l(void 0)});try{let _=o(b,{value:bt,refetching:qe});Xt(_)?(h(_),xe(_),_.then(ee=>{Z||(s!==void 0&&ge(s,ee),A(()=>{p(()=>ee),T("ready"),h(void 0)}))},ee=>{Z||A(()=>{l(ee),T("errored"),h(void 0)})})):A(()=>{p(()=>_),T("ready"),h(void 0)})}catch(_){if(Z)return;A(()=>{l(_),T("errored"),h(void 0)})}});let J=()=>{let b=d();return b==="pending"||b==="refreshing"},P=(()=>{let b=y();if(b)throw b;if(J()){let w=x();if(w)throw w}return u()});return Object.defineProperties(P,{state:{get:d},loading:{get:J},error:{get:y},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:p,refetch:()=>{B=!0,j(void 0)}}]}function et(e,t=300){let[r,n]=f(e),[o,s]=f(e),[i,c]=f(!1),u,p=()=>{u!==void 0&&(clearTimeout(u),u=void 0)},y=()=>{p();let d=S(r);return s(()=>d),c(!1),d},l=(d=>{let T=typeof d=="function"?d(S(r)):d;return n(()=>T),c(!0),p(),u=setTimeout(y,t),T});return m(p),[o,l,{immediate:r,pending:i,flush:y,cancel:()=>{p(),c(!1)}}]}function Qt(e){return e!=null&&e!==""}function Jt(e,t,r={}){let{delay:n=300,initialValue:o,shouldFetch:s=Qt}=r,[i,c,u]=et(e,n),p=()=>s(i())?i():!1,[y,{refetch:l}]=Y(p,t,o===void 0?{}:{initialValue:o});return[y,{...u,query:i,setQuery:c,refetch:l}]}function se(e){if(typeof e=="function"&&!e.length){let t=e();return he(t)?t:se(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=se(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Zt(e){let t=v(e);return v(()=>se(t()))}var Re=G();Ge((e,t)=>{let r=re(t,Re);r&&(r.increment(),e.finally(()=>r.decrement()))});function er(){let[e,t]=f(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function tr(e,t){return K(Re,e,t)}var tt=G();We((e,t)=>{let r=re(t,tt);return r?(r.setError(e),!0):!1});function rr(){let[e,t]=f(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function nr(e,t){return K(tt,e,t)}var or={State:D,Computed:O,subtle:{Watcher:C,untrack:$,currentComputed:Le,hasSinks:Ve}};var hn=Symbol.for("signal"),bn=Symbol.for("fluixi-proxy");function Cn(e,t){let[r,n]=f(e,t);return Object.assign(r,{set:n})}function Fn(e,t,r){return v(e,t,r)}function In(e,t){return g(e,t)}function sr(...e){let[t,r]=Y(...e);return Object.assign(t,r)}import{$PROXY as Ee,batch as ct,createEffect as ae,createMemo as ke,createSignal as lt,untrack as ir}from"@fluixi/reactive/signal";var ue=Symbol("store-raw"),U=Symbol("store-node"),rt=Symbol("store-has"),Pe=Symbol("store-self"),De=Symbol("store-track"),ar=Symbol("store-name"),ur=Symbol("store-store"),nt=new WeakMap,ot=new WeakMap;function pt(e){let[t,r]=lt(e),n=t;return n.$=r,n}function ce(e){let t=nt.get(e);return t||nt.set(e,t={keys:new Map}),t}function st(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=pt(r)),n}function it(e){let t=ce(e);(t.all||(t.all=pt()))()}function at(e,t){e.$(typeof t=="function"?()=>t:t)}function ft(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 ie(e){if(!ft(e))return e;let t=ot.get(e);if(t)return t;let r=new Proxy(e,cr);return ot.set(e,r),r}var cr={get(e,t,r){if(t===ue||t===U)return e;if(t===Ee)return r;if(t===rt)return i=>i in e;if(t==="__proxy")return!0;if(t===De||t===Pe)return it(e),r;let n=e[t];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return n;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(r);let s=st(ce(e),t,n)();return ft(s)?ie(s):s},set(){return!0},deleteProperty(e,t){return t in e&&X(e,t,void 0),!0},has(e,t){return t===ue||t===Ee||t===U||t===rt||t===Pe||t===De?!0:(st(ce(e),t,e[t])(),t in e)},ownKeys(e){return it(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function X(e,t,r){if(e[t]===r&&(r!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;r===void 0?delete e[t]:e[t]=r;let i=ce(e),c=i.keys.get(t);if(c&&at(c,r),o&&e.length!==s){let u=i.keys.get("length");u&&at(u,e.length)}i.all&&i.all.$(void 0)}function ut(e,t){return typeof e=="function"?e(t):e}function Ce(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?Ce(o,n):X(e,r,n)}}function Ie(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function dt(e,t,r){let n=t.length-1;for(let s=0;s<n;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let p=0;p<e.length;p++)dt(e[p],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},X(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)X(e,s,ut(r,e[s]));return}X(e,o,ut(r,e[o]))}function _e(e,t,r){dt(e,Ie(t),r)}function lr(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&Ce(e,n);return}if(Array.isArray(r)&&t.length===1){for(let n of r)Array.isArray(n)&&_e(e,n[0],n[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){Ce(e,r);return}if(Array.isArray(t[1])&&t.length>=3){_e(e,`${r}.${t[1].join(".")}`,t[2]);return}_e(e,String(r),t[1])}function Fe(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Fe);let t={};for(let r of Object.keys(e))t[r]=Fe(e[r]);return t}function I(e,t){let r=e;for(let n of Ie(t)){if(r==null)return;r=r[n]}return r}var E=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>ct(()=>lr(this.root,n)))}get state(){return ie(this.root)}get proxy(){return ie(this.root)}get accessor(){return(()=>ie(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return Q(this.state);let r=this.state;for(let n of Ie(t)){if(r==null)return;r=r[n]}return Q(r)}select(t){return ke(()=>t(this.state))}subscribe(t){return ae(()=>t(this.state))}watch(t,r){let n;return ae(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return ke(()=>this.state[t])}produce(t){this.set((r=>{let n=Fe(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=I(this.root,t);this.set(t,n.concat(r))}pop(t){let r=I(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=I(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=I(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=I(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=I(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}toObservable(){let[t]=lt(this.state);return t.toObservable()}dispose(){}},pr=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function yt(e,t){for(let r of pr)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function le(e,t={immutable:!0}){let r=new E(e,t);return yt(r.set,r),[r.proxy,r.set]}function Tt(e,t={}){return new E(e,{...t,immutable:!1})}function fr(e,t={}){let r=new E(e(),t);return ae(()=>r.set(e())),r}function dr(e,t,r){return ae(()=>r(t(e)))}function yr(e,t,r){return ke(()=>t(e),void 0,r)}function Tr(e,t={}){let r=new E(e,t),n=(()=>r.proxy);return yt(n,r),n}function Q(e){if(e==null||typeof e!="object")return e;let t=e[ue];return t!==void 0?t:e}function ht(e){return ir(()=>Q(e))}function hr(e){return Ue(e)}function br(e){return Ue(e)?e[U]:null}function mr(e){return e&&typeof e=="object"&&U in e?e[U]:null}function Ue(e){return!!e&&typeof e=="object"&&(Ee in e||e.__proxy===!0)}function vr(e){return e}var Sr=Object.freeze({createStore:le,createMutableStore:Tt,batch:ct,unwrap:Q,untrackStore:ht});function je(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(je);let t={};for(let r of Object.keys(e))t[r]=je(e[r]);return t}function xr(e){return t=>{let r=je(t);return e(r),r}}function wr(e,t={}){return()=>e}function Or(e,t){let[r,n]=le(e,t);return new Proxy(r,{get:(o,s)=>s==="set"?n:o[s],has:(o,s)=>s==="set"||Reflect.has(o,s)})}export{ar as $NAME,U as $NODE,bn as $PROXY,ue as $RAW,Pe as $SELF,hn as $SIGNAL,ur as $STORE,De as $TRACK,M as Observable,pe as SafeSubscriber,or as Signal,E as Store,Sr as StoreAPI,Me as Subject,N as Subscriber,q as Subscription,Re as SuspenseContext,mt as VERSION,Te as __DEV__,A as batch,wt as createChildOwner,Pt as createComputed,fr as createComputedStore,G as createContext,Yt as createDebounce,Jt as createDebouncedResource,et as createDebouncedSignal,zt as createDeferred,g as createEffect,rr as createErrorBoundary,v as createMemo,Tt as createMutableStore,Dt as createRenderEffect,Y as createResource,F as createRoot,Wt as createSelector,f as createSignal,le as createStore,dr as createStoreEffect,yr as createStoreMemo,er as createSuspenseBoundary,Ot as disposeScope,In as effect,Ft as flush,br as getNode,ne as getOwner,we as getServerData,mr as getStoreNode,Kr as indexArray,Mt as isComponent,qt as isMemo,gt as isOwnerDisposed,$t as isProvider,Nt as isResource,he as isSignal,hr as isStore,Ue as isStoreProxy,Ht as isSuspense,Gr as keyArray,Ze as makeArrayFlat,Vr as mapArray,Fn as memo,vr as modifiable,Oe as nextResourceId,It as on,m as onCleanup,kr as operate,xr as produceUtil,K as provide,nr as provideErrorBoundary,tr as provideSuspense,Zt as readChildren,wr as reconcileUtil,ge as reportResourceData,sr as resource,W as runWithOwner,ze as setOwner,Kt as setResourceDataSink,Gt as setResourceIdSource,Lt as setResourceTracker,Vt as setServerDataGetter,Cn as signal,Je as startTransition,Or as store,xe as trackResourcePromise,S as untrack,ht as untrackStore,Q as unwrap,At as useContext,Ct as useTransition,Tr as wrap};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var we=Object.defineProperty;var ir=Object.getOwnPropertyDescriptor;var ar=Object.getOwnPropertyNames;var ur=Object.prototype.hasOwnProperty;var cr=(e,t)=>{for(var r in t)we(e,r,{get:t[r],enumerable:!0})},lr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ar(t))!ur.call(e,o)&&o!==r&&we(e,o,{get:()=>t[o],enumerable:!(n=ir(t,o))||n.enumerable});return e};var pr=e=>lr(we({},"__esModule",{value:!0}),e);var Ur={};cr(Ur,{$NAME:()=>Ht,$NODE:()=>D,$PROXY:()=>Er,$RAW:()=>ee,$SELF:()=>me,$SIGNAL:()=>_r,$STORE:()=>$t,$TRACK:()=>ve,Observable:()=>j,SafeSubscriber:()=>se,Signal:()=>Ct,Store:()=>_,StoreAPI:()=>tr,Subject:()=>ge,Subscriber:()=>U,Subscription:()=>I,SuspenseContext:()=>he,VERSION:()=>Ke,__DEV__:()=>ce,batch:()=>g,createChildOwner:()=>Je,createComputed:()=>ut,createComputedStore:()=>Wt,createContext:()=>N,createDebounce:()=>gt,createDebouncedResource:()=>At,createDebouncedSignal:()=>je,createDeferred:()=>Ot,createEffect:()=>O,createErrorBoundary:()=>Pt,createMemo:()=>S,createMutableStore:()=>He,createRenderEffect:()=>ct,createResource:()=>$,createRoot:()=>P,createSelector:()=>wt,createSignal:()=>f,createStore:()=>te,createStoreEffect:()=>zt,createStoreMemo:()=>Yt,createSuspenseBoundary:()=>_t,disposeScope:()=>Ze,effect:()=>Dr,flush:()=>pt,getNode:()=>Jt,getOwner:()=>Q,getServerData:()=>fe,getStoreNode:()=>Zt,indexArray:()=>xr,isComponent:()=>Tt,isMemo:()=>dt,isOwnerDisposed:()=>et,isProvider:()=>bt,isResource:()=>yt,isSignal:()=>le,isStore:()=>Qt,isStoreProxy:()=>xe,isSuspense:()=>ht,keyArray:()=>Sr,makeArrayFlat:()=>Pe,mapArray:()=>vr,memo:()=>Pr,modifiable:()=>er,nextResourceId:()=>de,on:()=>ft,onCleanup:()=>v,operate:()=>fr,produceUtil:()=>rr,provide:()=>M,provideErrorBoundary:()=>Dt,provideSuspense:()=>Et,readChildren:()=>Rt,reconcileUtil:()=>nr,reportResourceData:()=>ye,resource:()=>Ft,runWithOwner:()=>H,setOwner:()=>_e,setResourceDataSink:()=>xt,setResourceIdSource:()=>St,setResourceTracker:()=>mt,setServerDataGetter:()=>vt,signal:()=>kr,startTransition:()=>ke,store:()=>or,trackResourcePromise:()=>pe,untrack:()=>x,untrackStore:()=>$e,unwrap:()=>V,useContext:()=>tt,useTransition:()=>lt,wrap:()=>Xt});module.exports=pr(Ur);var Ke="1.0.0-alpha.76";var We=require("@fluixi/utils/object"),Oe=require("@fluixi/utils/functions"),I=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:r}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let n of t)n.remove(this);if(r){for(let n of r)if((0,Oe.isFunction)(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if((0,We.isObject)(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:r,_subscriptions:n}=this;if(r){if((0,Oe.isFunction)(t))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(t.unsubscribe)try{t.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(t);n!==-1&&(r.splice(n,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:r}=this;r?Array.isArray(r)?r.push(t):this._parentOrParents=[r,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:r}=this;if(r===t)this._parentOrParents=null;else if(Array.isArray(r)){let n=r.indexOf(t);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var U=class extends I{constructor(r,n,o){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:n,complete:o}:s={},this.destination=s}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(n){throw n}else throw r;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(r){this.error(r);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},se=class extends U{constructor(r,n,o,s){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(r)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};function fr(e){return new U(e.next,e.error,e.complete)}var j=class extends I{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,r,n){let o;t instanceof U?o=t:o=new se(t,r,n);let{_subscribe:s}=this;try{let i=s.call(this,o);i&&(typeof i=="function"||typeof i.unsubscribe=="function")&&o.add(i)}catch(i){o.error(i)}return o}pipe(...t){return t.length===0?this:t.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((t,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>t(n)})})}};var ge=class extends j{constructor(){super(r=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)r.error(this.thrownError);else if(this.isStopped)r.complete();else return this.observers.push(r),()=>{let n=this.observers.indexOf(r);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(r){if(this.isStopped)return;let{observers:n}=this,o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].next?.(r)}error(r){if(this.isStopped)return;this.hasError=!0,this.thrownError=r,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].error?.(r)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:r}=this;this.observers=[];let n=r.length,o=r.slice();for(let s=0;s<n;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new j(n=>this.subscribe(n))}};var dr="__fluixi_signal_next_state__",yr=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[dr]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:yr,onSuspend:null,onError:null};var ze=0,Ye=1,W=2,ie=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let t=a.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},B=class extends ie{constructor(t,r){super(),this._value=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let r of[...this.observers])r.markDirty(W);Ae(this)}}peek(){return this._value}},R=class extends ie{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=W;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){if(a.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===Ye&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===W)break}(this.state===W||!this._initialized)&&this.recompute(),this.state=ze}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=a.consumer,n=a.untracked;a.consumer=this,a.untracked=!1;let o,s=!1,i;try{o=this._fn()}catch(u){s=!0,i=u,o=this._value}finally{a.consumer=r,a.untracked=n}let c=!this._initialized||this._threw!==s||(s?i!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=s,this._error=i,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(W);Ae(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===ze;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty(Ye);Ae(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Ae(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var q=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function z(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function Xe(){return a.consumer}function Qe(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function Je(e){let t=X(e);return e&&(e.owned??=[]).push(t),t}function Ze(e,t=!0){Y(e,t)}function et(e){return!!e&&e.disposed===!0}function X(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function N(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=X(o);(s.contexts=new Map).set(t,n.value),o&&(o.owned??=[]).push(s),a.owner=s;try{return n.children}finally{a.owner=o}}}}function tt(e){let t=a.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function ae(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function M(e,t,r){let n=X(a.owner);(n.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return r()}finally{a.owner=o}}function rt(e){a.onSuspend=e}function nt(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function ot(e){a.onError=e}function Q(){return a.owner}function _e(e){let t=a.owner;return a.owner=e,t}function H(e,t){let r=a.owner;a.owner=e;try{return t()}finally{a.owner=r}}function v(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function Y(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)Y(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}t&&(e.disposed=!0)}}function P(e){let t=X(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>Y(t))}finally{a.owner=r}}function st(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function Tr(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(J)))}function J(){if(a.scheduled=!1,a.flushing)return;a.flushing=!0;let e=0;try{for(;a.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function it(){a.batchDepth===0&&J()}function Ee(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&J()}}var Re=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=X(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new R(()=>{Y(this.owner,!1),H(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new q(()=>Tr(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&a.onSuspend){a.onSuspend(t,this.owner);return}if(a.onError&&a.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),Y(this.owner))}};function ue(e){let t=new Re(e);return()=>t.dispose()}function hr(e){return!!e&&typeof e.then=="function"}st(()=>{});var at=Symbol.for("signal"),br=Symbol.for("memo"),mr=Symbol.for("signal-node");function f(e,t){let r=new B(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),it(),i});return Object.defineProperty(n,at,{value:!0,enumerable:!0}),Object.defineProperty(n,mr,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function S(e,t,r){let n=t,o=Q(),s=new R(()=>H(o,()=>{try{return n=e(n)}catch(c){if(hr(c))return nt(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,at,{value:!0,enumerable:!0}),Object.defineProperty(i,br,{value:!0,enumerable:!0}),i}function O(e,t){let r=t;return ue(()=>{r=e(r)})}function ut(e,t){let r=t;ue(()=>{r=e(r)})}function ct(e,t){let r=t;return ue(()=>{r=e(r)})}function g(e){return Ee(e)}function x(e){return z(e)}function ke(e){return Ee(e),Promise.resolve()}function lt(){return[()=>!1,ke]}function pt(){return J(),Promise.resolve()}function ft(e,t,r){let n=Array.isArray(e),o,s=r?.defer??!1;return i=>{let c=n?e.map(p=>p()):e();if(s){s=!1,o=c;return}let u=z(()=>t(c,o,i));return o=c,u}}function vr(e,t,r){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),S(()=>{let o=e()||[];return x(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=new Map;for(let u of n)s.has(u.item)||s.set(u.item,u);let i=[],c=new Set;for(let u=0;u<o.length;u++){let p=o[u],T=s.get(p);if(T&&!c.has(T))T.setIndex(u),i.push(T),c.add(T);else{let l,d,h;P(b=>{h=b;let[C,G]=f(u);d=G,l=t(p,C)});let w={item:p,rendered:l,dispose:h,setIndex:d};i.push(w),c.add(w)}}for(let u of n)c.has(u)||u.dispose();return n=i,i.map(u=>u.rendered)})})}function Sr(e,t,r,n){let o=[],s=[];return v(()=>{for(let i of s)i.dispose();o=[],s=[]}),S(()=>{let i=e()||[];return x(()=>{if(i.length===0){for(let l of s)l.dispose();return o=[],s=[],n?.fallback?n.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],s[l]);let u=[],p=[],T=new Set;for(let l=0;l<i.length;l++){let d=t(i[l]),h=c.get(d);if(h&&!T.has(d))h.setIndex(l),u.push(h);else{let w,b,C;P(G=>{C=G;let[E,K]=f(l);b=K;let re=S(F=>{let A=(e()||[])[E()];return A??F},i[l]);w=r(re,E)}),u.push({rendered:w,dispose:C,setIndex:b})}p.push(d),T.add(d)}for(let[l,d]of c)T.has(l)||d.dispose();return o=p,s=u,u.map(l=>l.rendered)})})}function xr(e,t,r){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),S(()=>{let o=e()||[];return x(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=n.length,i=o.length;for(let u=s;u<i;u++){let p,T,l,d=o[u];P(h=>{l=h;let[w,b]=f(d);T=b,p=t(w,u)}),n.push({rendered:p,setItem:T,dispose:l})}for(let u=i;u<s;u++)n[u].dispose();i<s&&(n=n.slice(0,i));let c=Math.min(s,i);for(let u=0;u<c;u++)n[u].setItem(o[u]);return n.map(u=>u.rendered)})})}var ce=!1,wr=Symbol.for("signal"),Or=Symbol.for("memo"),gr=Symbol.for("resource");function le(e){return typeof e=="function"&&e[wr]===!0}function dt(e){return typeof e=="function"&&e[Or]===!0}function yt(e){return typeof e=="function"&&e[gr]===!0}function Tt(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function ht(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function bt(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Pe(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Pe(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var De=null;function mt(e){De=e}function pe(e){De&&De(e)}var Ce=null;function vt(e){Ce=e}function fe(e){return Ce?Ce(e):void 0}var Fe=null;function St(e){Fe=e}function de(){return Fe?Fe():void 0}var Ie=null;function xt(e){Ie=e}function ye(e,t){Ie&&Ie(e,t)}function wt(e,t=(r,n)=>r===n){let r=new Map;return O(()=>{let n=e();for(let[o,s]of r){let[i,c]=s,u=t(o,n);i()!==u&&c(u)}}),n=>{let o=r.get(n);if(!o){let[s,i]=f(!1);o=[s,i],r.set(n,o);let c=e();i(t(n,c))}return o[0]()}}function Ot(e,t){let[r,n]=f(e(),t);return O(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function gt(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,e(...o)},t)};return v(()=>{r!==void 0&&clearTimeout(r)}),n}function Ar(e){return!!e&&typeof e.then=="function"}var Ue=Symbol();function $(e,t,r={}){let n,o;typeof t=="function"?(n=typeof e=="function"?e:()=>e,o=t):(n=()=>!0,o=e,t&&typeof t=="object"&&(r=t));let s=r.transport===!1?void 0:de(),i=s!==void 0?fe(s):void 0,c=i!==void 0,[u,p]=f(i!==void 0?i.value:r.initialValue,{equals:!1}),[T,l]=f(void 0,{equals:!1}),[d,h]=f(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[w,b]=f(void 0,{equals:!1}),[C,G]=f(void 0,{equals:!1}),E=Ue,K=!1;O(()=>{let m=n();if(C(),m===!1||m===null||m===void 0){E=Ue,g(()=>{h("unresolved"),b(void 0),l(void 0)});return}let A=K;if(K=!1,E!==Ue&&m===E&&!A)return;if(E=m,c){c=!1;return}let ne=!1;v(()=>ne=!0);let Ve=x(d),sr=x(u),Ge=Ve==="ready"||Ve==="refreshing";g(()=>{h(Ge?"refreshing":"pending"),l(void 0)});try{let k=o(m,{value:sr,refetching:Ge});Ar(k)?(b(k),pe(k),k.then(oe=>{ne||(s!==void 0&&ye(s,oe),g(()=>{p(()=>oe),h("ready"),b(void 0)}))},oe=>{ne||g(()=>{l(oe),h("errored"),b(void 0)})})):g(()=>{p(()=>k),h("ready"),b(void 0)})}catch(k){if(ne)return;g(()=>{l(k),h("errored"),b(void 0)})}});let re=()=>{let m=d();return m==="pending"||m==="refreshing"},F=(()=>{let m=T();if(m)throw m;if(re()){let A=w();if(A)throw A}return u()});return Object.defineProperties(F,{state:{get:d},loading:{get:re},error:{get:T},latest:{get:u}}),Object.defineProperty(F,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(F,Symbol.for("signal"),{value:!0,enumerable:!0}),[F,{mutate:p,refetch:()=>{K=!0,G(void 0)}}]}function je(e,t=300){let[r,n]=f(e),[o,s]=f(e),[i,c]=f(!1),u,p=()=>{u!==void 0&&(clearTimeout(u),u=void 0)},T=()=>{p();let d=x(r);return s(()=>d),c(!1),d},l=(d=>{let h=typeof d=="function"?d(x(r)):d;return n(()=>h),c(!0),p(),u=setTimeout(T,t),h});return v(p),[o,l,{immediate:r,pending:i,flush:T,cancel:()=>{p(),c(!1)}}]}function Rr(e){return e!=null&&e!==""}function At(e,t,r={}){let{delay:n=300,initialValue:o,shouldFetch:s=Rr}=r,[i,c,u]=je(e,n),p=()=>s(i())?i():!1,[T,{refetch:l}]=$(p,t,o===void 0?{}:{initialValue:o});return[T,{...u,query:i,setQuery:c,refetch:l}]}function Te(e){if(typeof e=="function"&&!e.length){let t=e();return le(t)?t:Te(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=Te(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Rt(e){let t=S(e);return S(()=>Te(t()))}var he=N();rt((e,t)=>{let r=ae(t,he);r&&(r.increment(),e.finally(()=>r.decrement()))});function _t(){let[e,t]=f(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function Et(e,t){return M(he,e,t)}var kt=N();ot((e,t)=>{let r=ae(t,kt);return r?(r.setError(e),!0):!1});function Pt(){let[e,t]=f(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function Dt(e,t){return M(kt,e,t)}var Ct={State:B,Computed:R,subtle:{Watcher:q,untrack:z,currentComputed:Xe,hasSinks:Qe}};var _r=Symbol.for("signal"),Er=Symbol.for("fluixi-proxy");function kr(e,t){let[r,n]=f(e,t);return Object.assign(r,{set:n})}function Pr(e,t,r){return S(e,t,r)}function Dr(e,t){return O(e,t)}function Ft(...e){let[t,r]=$(...e);return Object.assign(t,r)}var y=require("@fluixi/reactive/signal"),ee=Symbol("store-raw"),D=Symbol("store-node"),It=Symbol("store-has"),me=Symbol("store-self"),ve=Symbol("store-track"),Ht=Symbol("store-name"),$t=Symbol("store-store"),Ut=new WeakMap,jt=new WeakMap;function Lt(e){let[t,r]=(0,y.createSignal)(e),n=t;return n.$=r,n}function Se(e){let t=Ut.get(e);return t||Ut.set(e,t={keys:new Map}),t}function Bt(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=Lt(r)),n}function qt(e){let t=Se(e);(t.all||(t.all=Lt()))()}function Nt(e,t){e.$(typeof t=="function"?()=>t:t)}function Vt(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function be(e){if(!Vt(e))return e;let t=jt.get(e);if(t)return t;let r=new Proxy(e,Cr);return jt.set(e,r),r}var Cr={get(e,t,r){if(t===ee||t===D)return e;if(t===y.$PROXY)return r;if(t===It)return i=>i in e;if(t==="__proxy")return!0;if(t===ve||t===me)return qt(e),r;let n=e[t];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return n;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(r);let s=Bt(Se(e),t,n)();return Vt(s)?be(s):s},set(){return!0},deleteProperty(e,t){return t in e&&Z(e,t,void 0),!0},has(e,t){return t===ee||t===y.$PROXY||t===D||t===It||t===me||t===ve?!0:(Bt(Se(e),t,e[t])(),t in e)},ownKeys(e){return qt(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function Z(e,t,r){if(e[t]===r&&(r!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;r===void 0?delete e[t]:e[t]=r;let i=Se(e),c=i.keys.get(t);if(c&&Nt(c,r),o&&e.length!==s){let u=i.keys.get("length");u&&Nt(u,e.length)}i.all&&i.all.$(void 0)}function Mt(e,t){return typeof e=="function"?e(t):e}function qe(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?qe(o,n):Z(e,r,n)}}function Me(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function Gt(e,t,r){let n=t.length-1;for(let s=0;s<n;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let p=0;p<e.length;p++)Gt(e[p],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},Z(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)Z(e,s,Mt(r,e[s]));return}Z(e,o,Mt(r,e[o]))}function Be(e,t,r){Gt(e,Me(t),r)}function Fr(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&qe(e,n);return}if(Array.isArray(r)&&t.length===1){for(let n of r)Array.isArray(n)&&Be(e,n[0],n[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){qe(e,r);return}if(Array.isArray(t[1])&&t.length>=3){Be(e,`${r}.${t[1].join(".")}`,t[2]);return}Be(e,String(r),t[1])}function Ne(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ne);let t={};for(let r of Object.keys(e))t[r]=Ne(e[r]);return t}function L(e,t){let r=e;for(let n of Me(t)){if(r==null)return;r=r[n]}return r}var _=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>(0,y.batch)(()=>Fr(this.root,n)))}get state(){return be(this.root)}get proxy(){return be(this.root)}get accessor(){return(()=>be(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return V(this.state);let r=this.state;for(let n of Me(t)){if(r==null)return;r=r[n]}return V(r)}select(t){return(0,y.createMemo)(()=>t(this.state))}subscribe(t){return(0,y.createEffect)(()=>t(this.state))}watch(t,r){let n;return(0,y.createEffect)(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return(0,y.createMemo)(()=>this.state[t])}produce(t){this.set((r=>{let n=Ne(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=L(this.root,t);this.set(t,n.concat(r))}pop(t){let r=L(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=L(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=L(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=L(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=L(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}toObservable(){let[t]=(0,y.createSignal)(this.state);return t.toObservable()}dispose(){}},Ir=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function Kt(e,t){for(let r of Ir)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function te(e,t={immutable:!0}){let r=new _(e,t);return Kt(r.set,r),[r.proxy,r.set]}function He(e,t={}){return new _(e,{...t,immutable:!1})}function Wt(e,t={}){let r=new _(e(),t);return(0,y.createEffect)(()=>r.set(e())),r}function zt(e,t,r){return(0,y.createEffect)(()=>r(t(e)))}function Yt(e,t,r){return(0,y.createMemo)(()=>t(e),void 0,r)}function Xt(e,t={}){let r=new _(e,t),n=(()=>r.proxy);return Kt(n,r),n}function V(e){if(e==null||typeof e!="object")return e;let t=e[ee];return t!==void 0?t:e}function $e(e){return(0,y.untrack)(()=>V(e))}function Qt(e){return xe(e)}function Jt(e){return xe(e)?e[D]:null}function Zt(e){return e&&typeof e=="object"&&D in e?e[D]:null}function xe(e){return!!e&&typeof e=="object"&&(y.$PROXY in e||e.__proxy===!0)}function er(e){return e}var tr=Object.freeze({createStore:te,createMutableStore:He,batch:y.batch,unwrap:V,untrackStore:$e});function Le(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Le);let t={};for(let r of Object.keys(e))t[r]=Le(e[r]);return t}function rr(e){return t=>{let r=Le(t);return e(r),r}}function nr(e,t={}){return()=>e}function or(e,t){let[r,n]=te(e,t);return new Proxy(r,{get:(o,s)=>s==="set"?n:o[s],has:(o,s)=>s==="set"||Reflect.has(o,s)})}
|
|
1
|
+
"use strict";var we=Object.defineProperty;var ir=Object.getOwnPropertyDescriptor;var ar=Object.getOwnPropertyNames;var ur=Object.prototype.hasOwnProperty;var cr=(e,t)=>{for(var r in t)we(e,r,{get:t[r],enumerable:!0})},lr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ar(t))!ur.call(e,o)&&o!==r&&we(e,o,{get:()=>t[o],enumerable:!(n=ir(t,o))||n.enumerable});return e};var pr=e=>lr(we({},"__esModule",{value:!0}),e);var Ur={};cr(Ur,{$NAME:()=>Ht,$NODE:()=>D,$PROXY:()=>Er,$RAW:()=>ee,$SELF:()=>me,$SIGNAL:()=>_r,$STORE:()=>$t,$TRACK:()=>ve,Observable:()=>j,SafeSubscriber:()=>se,Signal:()=>Ct,Store:()=>_,StoreAPI:()=>tr,Subject:()=>ge,Subscriber:()=>U,Subscription:()=>I,SuspenseContext:()=>he,VERSION:()=>Ke,__DEV__:()=>ce,batch:()=>g,createChildOwner:()=>Je,createComputed:()=>ut,createComputedStore:()=>Wt,createContext:()=>N,createDebounce:()=>gt,createDebouncedResource:()=>At,createDebouncedSignal:()=>je,createDeferred:()=>Ot,createEffect:()=>O,createErrorBoundary:()=>Pt,createMemo:()=>S,createMutableStore:()=>He,createRenderEffect:()=>ct,createResource:()=>$,createRoot:()=>P,createSelector:()=>wt,createSignal:()=>f,createStore:()=>te,createStoreEffect:()=>zt,createStoreMemo:()=>Yt,createSuspenseBoundary:()=>_t,disposeScope:()=>Ze,effect:()=>Dr,flush:()=>pt,getNode:()=>Jt,getOwner:()=>Q,getServerData:()=>fe,getStoreNode:()=>Zt,indexArray:()=>xr,isComponent:()=>Tt,isMemo:()=>dt,isOwnerDisposed:()=>et,isProvider:()=>bt,isResource:()=>yt,isSignal:()=>le,isStore:()=>Qt,isStoreProxy:()=>xe,isSuspense:()=>ht,keyArray:()=>Sr,makeArrayFlat:()=>Pe,mapArray:()=>vr,memo:()=>Pr,modifiable:()=>er,nextResourceId:()=>de,on:()=>ft,onCleanup:()=>v,operate:()=>fr,produceUtil:()=>rr,provide:()=>M,provideErrorBoundary:()=>Dt,provideSuspense:()=>Et,readChildren:()=>Rt,reconcileUtil:()=>nr,reportResourceData:()=>ye,resource:()=>Ft,runWithOwner:()=>H,setOwner:()=>_e,setResourceDataSink:()=>xt,setResourceIdSource:()=>St,setResourceTracker:()=>mt,setServerDataGetter:()=>vt,signal:()=>kr,startTransition:()=>ke,store:()=>or,trackResourcePromise:()=>pe,untrack:()=>x,untrackStore:()=>$e,unwrap:()=>V,useContext:()=>tt,useTransition:()=>lt,wrap:()=>Xt});module.exports=pr(Ur);var Ke="1.0.0-alpha.77";var We=require("@fluixi/utils/object"),Oe=require("@fluixi/utils/functions"),I=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:r}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let n of t)n.remove(this);if(r){for(let n of r)if((0,Oe.isFunction)(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if((0,We.isObject)(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:r,_subscriptions:n}=this;if(r){if((0,Oe.isFunction)(t))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(t.unsubscribe)try{t.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(t);n!==-1&&(r.splice(n,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:r}=this;r?Array.isArray(r)?r.push(t):this._parentOrParents=[r,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:r}=this;if(r===t)this._parentOrParents=null;else if(Array.isArray(r)){let n=r.indexOf(t);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var U=class extends I{constructor(r,n,o){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:n,complete:o}:s={},this.destination=s}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(n){throw n}else throw r;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(r){this.error(r);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},se=class extends U{constructor(r,n,o,s){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(r)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};function fr(e){return new U(e.next,e.error,e.complete)}var j=class extends I{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,r,n){let o;t instanceof U?o=t:o=new se(t,r,n);let{_subscribe:s}=this;try{let i=s.call(this,o);i&&(typeof i=="function"||typeof i.unsubscribe=="function")&&o.add(i)}catch(i){o.error(i)}return o}pipe(...t){return t.length===0?this:t.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((t,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>t(n)})})}};var ge=class extends j{constructor(){super(r=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)r.error(this.thrownError);else if(this.isStopped)r.complete();else return this.observers.push(r),()=>{let n=this.observers.indexOf(r);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(r){if(this.isStopped)return;let{observers:n}=this,o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].next?.(r)}error(r){if(this.isStopped)return;this.hasError=!0,this.thrownError=r,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].error?.(r)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:r}=this;this.observers=[];let n=r.length,o=r.slice();for(let s=0;s<n;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new j(n=>this.subscribe(n))}};var dr="__fluixi_signal_next_state__",yr=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[dr]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:yr,onSuspend:null,onError:null};var ze=0,Ye=1,W=2,ie=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let t=a.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},B=class extends ie{constructor(t,r){super(),this._value=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let r of[...this.observers])r.markDirty(W);Ae(this)}}peek(){return this._value}},R=class extends ie{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=W;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){if(a.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===Ye&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===W)break}(this.state===W||!this._initialized)&&this.recompute(),this.state=ze}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=a.consumer,n=a.untracked;a.consumer=this,a.untracked=!1;let o,s=!1,i;try{o=this._fn()}catch(u){s=!0,i=u,o=this._value}finally{a.consumer=r,a.untracked=n}let c=!this._initialized||this._threw!==s||(s?i!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=s,this._error=i,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(W);Ae(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===ze;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty(Ye);Ae(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Ae(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var q=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function z(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function Xe(){return a.consumer}function Qe(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function Je(e){let t=X(e);return e&&(e.owned??=[]).push(t),t}function Ze(e,t=!0){Y(e,t)}function et(e){return!!e&&e.disposed===!0}function X(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function N(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=X(o);(s.contexts=new Map).set(t,n.value),o&&(o.owned??=[]).push(s),a.owner=s;try{return n.children}finally{a.owner=o}}}}function tt(e){let t=a.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function ae(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function M(e,t,r){let n=X(a.owner);(n.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return r()}finally{a.owner=o}}function rt(e){a.onSuspend=e}function nt(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function ot(e){a.onError=e}function Q(){return a.owner}function _e(e){let t=a.owner;return a.owner=e,t}function H(e,t){let r=a.owner;a.owner=e;try{return t()}finally{a.owner=r}}function v(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function Y(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)Y(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}t&&(e.disposed=!0)}}function P(e){let t=X(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>Y(t))}finally{a.owner=r}}function st(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function Tr(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(J)))}function J(){if(a.scheduled=!1,a.flushing)return;a.flushing=!0;let e=0;try{for(;a.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function it(){a.batchDepth===0&&J()}function Ee(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&J()}}var Re=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=X(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new R(()=>{Y(this.owner,!1),H(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new q(()=>Tr(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&a.onSuspend){a.onSuspend(t,this.owner);return}if(a.onError&&a.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),Y(this.owner))}};function ue(e){let t=new Re(e);return()=>t.dispose()}function hr(e){return!!e&&typeof e.then=="function"}st(()=>{});var at=Symbol.for("signal"),br=Symbol.for("memo"),mr=Symbol.for("signal-node");function f(e,t){let r=new B(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),it(),i});return Object.defineProperty(n,at,{value:!0,enumerable:!0}),Object.defineProperty(n,mr,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function S(e,t,r){let n=t,o=Q(),s=new R(()=>H(o,()=>{try{return n=e(n)}catch(c){if(hr(c))return nt(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,at,{value:!0,enumerable:!0}),Object.defineProperty(i,br,{value:!0,enumerable:!0}),i}function O(e,t){let r=t;return ue(()=>{r=e(r)})}function ut(e,t){let r=t;ue(()=>{r=e(r)})}function ct(e,t){let r=t;return ue(()=>{r=e(r)})}function g(e){return Ee(e)}function x(e){return z(e)}function ke(e){return Ee(e),Promise.resolve()}function lt(){return[()=>!1,ke]}function pt(){return J(),Promise.resolve()}function ft(e,t,r){let n=Array.isArray(e),o,s=r?.defer??!1;return i=>{let c=n?e.map(p=>p()):e();if(s){s=!1,o=c;return}let u=z(()=>t(c,o,i));return o=c,u}}function vr(e,t,r){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),S(()=>{let o=e()||[];return x(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=new Map;for(let u of n)s.has(u.item)||s.set(u.item,u);let i=[],c=new Set;for(let u=0;u<o.length;u++){let p=o[u],T=s.get(p);if(T&&!c.has(T))T.setIndex(u),i.push(T),c.add(T);else{let l,d,h;P(b=>{h=b;let[C,G]=f(u);d=G,l=t(p,C)});let w={item:p,rendered:l,dispose:h,setIndex:d};i.push(w),c.add(w)}}for(let u of n)c.has(u)||u.dispose();return n=i,i.map(u=>u.rendered)})})}function Sr(e,t,r,n){let o=[],s=[];return v(()=>{for(let i of s)i.dispose();o=[],s=[]}),S(()=>{let i=e()||[];return x(()=>{if(i.length===0){for(let l of s)l.dispose();return o=[],s=[],n?.fallback?n.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],s[l]);let u=[],p=[],T=new Set;for(let l=0;l<i.length;l++){let d=t(i[l]),h=c.get(d);if(h&&!T.has(d))h.setIndex(l),u.push(h);else{let w,b,C;P(G=>{C=G;let[E,K]=f(l);b=K;let re=S(F=>{let A=(e()||[])[E()];return A??F},i[l]);w=r(re,E)}),u.push({rendered:w,dispose:C,setIndex:b})}p.push(d),T.add(d)}for(let[l,d]of c)T.has(l)||d.dispose();return o=p,s=u,u.map(l=>l.rendered)})})}function xr(e,t,r){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),S(()=>{let o=e()||[];return x(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=n.length,i=o.length;for(let u=s;u<i;u++){let p,T,l,d=o[u];P(h=>{l=h;let[w,b]=f(d);T=b,p=t(w,u)}),n.push({rendered:p,setItem:T,dispose:l})}for(let u=i;u<s;u++)n[u].dispose();i<s&&(n=n.slice(0,i));let c=Math.min(s,i);for(let u=0;u<c;u++)n[u].setItem(o[u]);return n.map(u=>u.rendered)})})}var ce=!1,wr=Symbol.for("signal"),Or=Symbol.for("memo"),gr=Symbol.for("resource");function le(e){return typeof e=="function"&&e[wr]===!0}function dt(e){return typeof e=="function"&&e[Or]===!0}function yt(e){return typeof e=="function"&&e[gr]===!0}function Tt(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function ht(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function bt(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Pe(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Pe(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var De=null;function mt(e){De=e}function pe(e){De&&De(e)}var Ce=null;function vt(e){Ce=e}function fe(e){return Ce?Ce(e):void 0}var Fe=null;function St(e){Fe=e}function de(){return Fe?Fe():void 0}var Ie=null;function xt(e){Ie=e}function ye(e,t){Ie&&Ie(e,t)}function wt(e,t=(r,n)=>r===n){let r=new Map;return O(()=>{let n=e();for(let[o,s]of r){let[i,c]=s,u=t(o,n);i()!==u&&c(u)}}),n=>{let o=r.get(n);if(!o){let[s,i]=f(!1);o=[s,i],r.set(n,o);let c=e();i(t(n,c))}return o[0]()}}function Ot(e,t){let[r,n]=f(e(),t);return O(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function gt(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,e(...o)},t)};return v(()=>{r!==void 0&&clearTimeout(r)}),n}function Ar(e){return!!e&&typeof e.then=="function"}var Ue=Symbol();function $(e,t,r={}){let n,o;typeof t=="function"?(n=typeof e=="function"?e:()=>e,o=t):(n=()=>!0,o=e,t&&typeof t=="object"&&(r=t));let s=r.transport===!1?void 0:de(),i=s!==void 0?fe(s):void 0,c=i!==void 0,[u,p]=f(i!==void 0?i.value:r.initialValue,{equals:!1}),[T,l]=f(void 0,{equals:!1}),[d,h]=f(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[w,b]=f(void 0,{equals:!1}),[C,G]=f(void 0,{equals:!1}),E=Ue,K=!1;O(()=>{let m=n();if(C(),m===!1||m===null||m===void 0){E=Ue,g(()=>{h("unresolved"),b(void 0),l(void 0)});return}let A=K;if(K=!1,E!==Ue&&m===E&&!A)return;if(E=m,c){c=!1;return}let ne=!1;v(()=>ne=!0);let Ve=x(d),sr=x(u),Ge=Ve==="ready"||Ve==="refreshing";g(()=>{h(Ge?"refreshing":"pending"),l(void 0)});try{let k=o(m,{value:sr,refetching:Ge});Ar(k)?(b(k),pe(k),k.then(oe=>{ne||(s!==void 0&&ye(s,oe),g(()=>{p(()=>oe),h("ready"),b(void 0)}))},oe=>{ne||g(()=>{l(oe),h("errored"),b(void 0)})})):g(()=>{p(()=>k),h("ready"),b(void 0)})}catch(k){if(ne)return;g(()=>{l(k),h("errored"),b(void 0)})}});let re=()=>{let m=d();return m==="pending"||m==="refreshing"},F=(()=>{let m=T();if(m)throw m;if(re()){let A=w();if(A)throw A}return u()});return Object.defineProperties(F,{state:{get:d},loading:{get:re},error:{get:T},latest:{get:u}}),Object.defineProperty(F,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(F,Symbol.for("signal"),{value:!0,enumerable:!0}),[F,{mutate:p,refetch:()=>{K=!0,G(void 0)}}]}function je(e,t=300){let[r,n]=f(e),[o,s]=f(e),[i,c]=f(!1),u,p=()=>{u!==void 0&&(clearTimeout(u),u=void 0)},T=()=>{p();let d=x(r);return s(()=>d),c(!1),d},l=(d=>{let h=typeof d=="function"?d(x(r)):d;return n(()=>h),c(!0),p(),u=setTimeout(T,t),h});return v(p),[o,l,{immediate:r,pending:i,flush:T,cancel:()=>{p(),c(!1)}}]}function Rr(e){return e!=null&&e!==""}function At(e,t,r={}){let{delay:n=300,initialValue:o,shouldFetch:s=Rr}=r,[i,c,u]=je(e,n),p=()=>s(i())?i():!1,[T,{refetch:l}]=$(p,t,o===void 0?{}:{initialValue:o});return[T,{...u,query:i,setQuery:c,refetch:l}]}function Te(e){if(typeof e=="function"&&!e.length){let t=e();return le(t)?t:Te(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=Te(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Rt(e){let t=S(e);return S(()=>Te(t()))}var he=N();rt((e,t)=>{let r=ae(t,he);r&&(r.increment(),e.finally(()=>r.decrement()))});function _t(){let[e,t]=f(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function Et(e,t){return M(he,e,t)}var kt=N();ot((e,t)=>{let r=ae(t,kt);return r?(r.setError(e),!0):!1});function Pt(){let[e,t]=f(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function Dt(e,t){return M(kt,e,t)}var Ct={State:B,Computed:R,subtle:{Watcher:q,untrack:z,currentComputed:Xe,hasSinks:Qe}};var _r=Symbol.for("signal"),Er=Symbol.for("fluixi-proxy");function kr(e,t){let[r,n]=f(e,t);return Object.assign(r,{set:n})}function Pr(e,t,r){return S(e,t,r)}function Dr(e,t){return O(e,t)}function Ft(...e){let[t,r]=$(...e);return Object.assign(t,r)}var y=require("@fluixi/reactive/signal"),ee=Symbol("store-raw"),D=Symbol("store-node"),It=Symbol("store-has"),me=Symbol("store-self"),ve=Symbol("store-track"),Ht=Symbol("store-name"),$t=Symbol("store-store"),Ut=new WeakMap,jt=new WeakMap;function Lt(e){let[t,r]=(0,y.createSignal)(e),n=t;return n.$=r,n}function Se(e){let t=Ut.get(e);return t||Ut.set(e,t={keys:new Map}),t}function Bt(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=Lt(r)),n}function qt(e){let t=Se(e);(t.all||(t.all=Lt()))()}function Nt(e,t){e.$(typeof t=="function"?()=>t:t)}function Vt(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function be(e){if(!Vt(e))return e;let t=jt.get(e);if(t)return t;let r=new Proxy(e,Cr);return jt.set(e,r),r}var Cr={get(e,t,r){if(t===ee||t===D)return e;if(t===y.$PROXY)return r;if(t===It)return i=>i in e;if(t==="__proxy")return!0;if(t===ve||t===me)return qt(e),r;let n=e[t];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return n;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(r);let s=Bt(Se(e),t,n)();return Vt(s)?be(s):s},set(){return!0},deleteProperty(e,t){return t in e&&Z(e,t,void 0),!0},has(e,t){return t===ee||t===y.$PROXY||t===D||t===It||t===me||t===ve?!0:(Bt(Se(e),t,e[t])(),t in e)},ownKeys(e){return qt(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function Z(e,t,r){if(e[t]===r&&(r!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;r===void 0?delete e[t]:e[t]=r;let i=Se(e),c=i.keys.get(t);if(c&&Nt(c,r),o&&e.length!==s){let u=i.keys.get("length");u&&Nt(u,e.length)}i.all&&i.all.$(void 0)}function Mt(e,t){return typeof e=="function"?e(t):e}function qe(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?qe(o,n):Z(e,r,n)}}function Me(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function Gt(e,t,r){let n=t.length-1;for(let s=0;s<n;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let p=0;p<e.length;p++)Gt(e[p],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},Z(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)Z(e,s,Mt(r,e[s]));return}Z(e,o,Mt(r,e[o]))}function Be(e,t,r){Gt(e,Me(t),r)}function Fr(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&qe(e,n);return}if(Array.isArray(r)&&t.length===1){for(let n of r)Array.isArray(n)&&Be(e,n[0],n[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){qe(e,r);return}if(Array.isArray(t[1])&&t.length>=3){Be(e,`${r}.${t[1].join(".")}`,t[2]);return}Be(e,String(r),t[1])}function Ne(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ne);let t={};for(let r of Object.keys(e))t[r]=Ne(e[r]);return t}function L(e,t){let r=e;for(let n of Me(t)){if(r==null)return;r=r[n]}return r}var _=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>(0,y.batch)(()=>Fr(this.root,n)))}get state(){return be(this.root)}get proxy(){return be(this.root)}get accessor(){return(()=>be(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return V(this.state);let r=this.state;for(let n of Me(t)){if(r==null)return;r=r[n]}return V(r)}select(t){return(0,y.createMemo)(()=>t(this.state))}subscribe(t){return(0,y.createEffect)(()=>t(this.state))}watch(t,r){let n;return(0,y.createEffect)(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return(0,y.createMemo)(()=>this.state[t])}produce(t){this.set((r=>{let n=Ne(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=L(this.root,t);this.set(t,n.concat(r))}pop(t){let r=L(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=L(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=L(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=L(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=L(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}toObservable(){let[t]=(0,y.createSignal)(this.state);return t.toObservable()}dispose(){}},Ir=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function Kt(e,t){for(let r of Ir)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function te(e,t={immutable:!0}){let r=new _(e,t);return Kt(r.set,r),[r.proxy,r.set]}function He(e,t={}){return new _(e,{...t,immutable:!1})}function Wt(e,t={}){let r=new _(e(),t);return(0,y.createEffect)(()=>r.set(e())),r}function zt(e,t,r){return(0,y.createEffect)(()=>r(t(e)))}function Yt(e,t,r){return(0,y.createMemo)(()=>t(e),void 0,r)}function Xt(e,t={}){let r=new _(e,t),n=(()=>r.proxy);return Kt(n,r),n}function V(e){if(e==null||typeof e!="object")return e;let t=e[ee];return t!==void 0?t:e}function $e(e){return(0,y.untrack)(()=>V(e))}function Qt(e){return xe(e)}function Jt(e){return xe(e)?e[D]:null}function Zt(e){return e&&typeof e=="object"&&D in e?e[D]:null}function xe(e){return!!e&&typeof e=="object"&&(y.$PROXY in e||e.__proxy===!0)}function er(e){return e}var tr=Object.freeze({createStore:te,createMutableStore:He,batch:y.batch,unwrap:V,untrackStore:$e});function Le(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Le);let t={};for(let r of Object.keys(e))t[r]=Le(e[r]);return t}function rr(e){return t=>{let r=Le(t);return e(r),r}}function nr(e,t={}){return()=>e}function or(e,t){let[r,n]=te(e,t);return new Proxy(r,{get:(o,s)=>s==="set"?n:o[s],has:(o,s)=>s==="set"||Reflect.has(o,s)})}
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var mt="1.0.0-alpha.76";import{isObject as vt}from"@fluixi/utils/object";import{isFunction as Ne}from"@fluixi/utils/functions";var q=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:r}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let n of t)n.remove(this);if(r){for(let n of r)if(Ne(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if(vt(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:r,_subscriptions:n}=this;if(r){if(Ne(t))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(t.unsubscribe)try{t.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(t);n!==-1&&(r.splice(n,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:r}=this;r?Array.isArray(r)?r.push(t):this._parentOrParents=[r,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:r}=this;if(r===t)this._parentOrParents=null;else if(Array.isArray(r)){let n=r.indexOf(t);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var N=class extends q{constructor(r,n,o){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:n,complete:o}:s={},this.destination=s}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(n){throw n}else throw r;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(r){this.error(r);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},pe=class extends N{constructor(r,n,o,s){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(r)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};function kr(e){return new N(e.next,e.error,e.complete)}var M=class extends q{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,r,n){let o;t instanceof N?o=t:o=new pe(t,r,n);let{_subscribe:s}=this;try{let i=s.call(this,o);i&&(typeof i=="function"||typeof i.unsubscribe=="function")&&o.add(i)}catch(i){o.error(i)}return o}pipe(...t){return t.length===0?this:t.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((t,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>t(n)})})}};var Me=class extends M{constructor(){super(r=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)r.error(this.thrownError);else if(this.isStopped)r.complete();else return this.observers.push(r),()=>{let n=this.observers.indexOf(r);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(r){if(this.isStopped)return;let{observers:n}=this,o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].next?.(r)}error(r){if(this.isStopped)return;this.hasError=!0,this.thrownError=r,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].error?.(r)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:r}=this;this.observers=[];let n=r.length,o=r.slice();for(let s=0;s<n;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new M(n=>this.subscribe(n))}};var St="__fluixi_signal_next_state__",xt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[St]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:xt,onSuspend:null,onError:null};var He=0,$e=1,H=2,te=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))}},D=class extends te{constructor(t,r){super(),this._value=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let r of[...this.observers])r.markDirty(H);fe(this)}}peek(){return this._value}},O=class extends te{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=H;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){if(a.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===$e&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===H)break}(this.state===H||!this._initialized)&&this.recompute(),this.state=He}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=a.consumer,n=a.untracked;a.consumer=this,a.untracked=!1;let o,s=!1,i;try{o=this._fn()}catch(u){s=!0,i=u,o=this._value}finally{a.consumer=r,a.untracked=n}let c=!this._initialized||this._threw!==s||(s?i!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=s,this._error=i,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(H);fe(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===He;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty($e);fe(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function fe(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var C=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function $(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function Le(){return a.consumer}function Ve(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function wt(e){let t=V(e);return e&&(e.owned??=[]).push(t),t}function Ot(e,t=!0){L(e,t)}function gt(e){return!!e&&e.disposed===!0}function V(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function G(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=V(o);(s.contexts=new Map).set(t,n.value),o&&(o.owned??=[]).push(s),a.owner=s;try{return n.children}finally{a.owner=o}}}}function At(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 re(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function K(e,t,r){let n=V(a.owner);(n.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return r()}finally{a.owner=o}}function Ge(e){a.onSuspend=e}function Ke(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function We(e){a.onError=e}function ne(){return a.owner}function ze(e){let t=a.owner;return a.owner=e,t}function W(e,t){let r=a.owner;a.owner=e;try{return t()}finally{a.owner=r}}function m(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function L(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)L(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}t&&(e.disposed=!0)}}function F(e){let t=V(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>L(t))}finally{a.owner=r}}function Ye(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function Rt(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(z)))}function z(){if(a.scheduled=!1,a.flushing)return;a.flushing=!0;let e=0;try{for(;a.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function Xe(){a.batchDepth===0&&z()}function ye(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&z()}}var de=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=V(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new O(()=>{L(this.owner,!1),W(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new C(()=>Rt(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),L(this.owner))}};function oe(e){let t=new de(e);return()=>t.dispose()}function _t(e){return!!e&&typeof e.then=="function"}Ye(()=>{});var Qe=Symbol.for("signal"),Et=Symbol.for("memo"),kt=Symbol.for("signal-node");function f(e,t){let r=new D(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),Xe(),i});return Object.defineProperty(n,Qe,{value:!0,enumerable:!0}),Object.defineProperty(n,kt,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function v(e,t,r){let n=t,o=ne(),s=new O(()=>W(o,()=>{try{return n=e(n)}catch(c){if(_t(c))return Ke(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,Qe,{value:!0,enumerable:!0}),Object.defineProperty(i,Et,{value:!0,enumerable:!0}),i}function g(e,t){let r=t;return oe(()=>{r=e(r)})}function Pt(e,t){let r=t;oe(()=>{r=e(r)})}function Dt(e,t){let r=t;return oe(()=>{r=e(r)})}function A(e){return ye(e)}function S(e){return $(e)}function Je(e){return ye(e),Promise.resolve()}function Ct(){return[()=>!1,Je]}function Ft(){return z(),Promise.resolve()}function It(e,t,r){let n=Array.isArray(e),o,s=r?.defer??!1;return i=>{let c=n?e.map(p=>p()):e();if(s){s=!1,o=c;return}let u=$(()=>t(c,o,i));return o=c,u}}function Vr(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),v(()=>{let o=e()||[];return S(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=new Map;for(let u of n)s.has(u.item)||s.set(u.item,u);let i=[],c=new Set;for(let u=0;u<o.length;u++){let p=o[u],y=s.get(p);if(y&&!c.has(y))y.setIndex(u),i.push(y),c.add(y);else{let l,d,T;F(h=>{T=h;let[k,j]=f(u);d=j,l=t(p,k)});let x={item:p,rendered:l,dispose:T,setIndex:d};i.push(x),c.add(x)}}for(let u of n)c.has(u)||u.dispose();return n=i,i.map(u=>u.rendered)})})}function Gr(e,t,r,n){let o=[],s=[];return m(()=>{for(let i of s)i.dispose();o=[],s=[]}),v(()=>{let i=e()||[];return S(()=>{if(i.length===0){for(let l of s)l.dispose();return o=[],s=[],n?.fallback?n.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],s[l]);let u=[],p=[],y=new Set;for(let l=0;l<i.length;l++){let d=t(i[l]),T=c.get(d);if(T&&!y.has(d))T.setIndex(l),u.push(T);else{let x,h,k;F(j=>{k=j;let[R,B]=f(l);h=B;let J=v(P=>{let w=(e()||[])[R()];return w??P},i[l]);x=r(J,R)}),u.push({rendered:x,dispose:k,setIndex:h})}p.push(d),y.add(d)}for(let[l,d]of c)y.has(l)||d.dispose();return o=p,s=u,u.map(l=>l.rendered)})})}function Kr(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),v(()=>{let o=e()||[];return S(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=n.length,i=o.length;for(let u=s;u<i;u++){let p,y,l,d=o[u];F(T=>{l=T;let[x,h]=f(d);y=h,p=t(x,u)}),n.push({rendered:p,setItem:y,dispose:l})}for(let u=i;u<s;u++)n[u].dispose();i<s&&(n=n.slice(0,i));let c=Math.min(s,i);for(let u=0;u<c;u++)n[u].setItem(o[u]);return n.map(u=>u.rendered)})})}var Te=!1,Ut=Symbol.for("signal"),jt=Symbol.for("memo"),Bt=Symbol.for("resource");function he(e){return typeof e=="function"&&e[Ut]===!0}function qt(e){return typeof e=="function"&&e[jt]===!0}function Nt(e){return typeof e=="function"&&e[Bt]===!0}function Mt(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Ht(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function $t(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 be=null;function Lt(e){be=e}function xe(e){be&&be(e)}var me=null;function Vt(e){me=e}function we(e){return me?me(e):void 0}var ve=null;function Gt(e){ve=e}function Oe(){return ve?ve():void 0}var Se=null;function Kt(e){Se=e}function ge(e,t){Se&&Se(e,t)}function Wt(e,t=(r,n)=>r===n){let r=new Map;return g(()=>{let n=e();for(let[o,s]of r){let[i,c]=s,u=t(o,n);i()!==u&&c(u)}}),n=>{let o=r.get(n);if(!o){let[s,i]=f(!1);o=[s,i],r.set(n,o);let c=e();i(t(n,c))}return o[0]()}}function zt(e,t){let[r,n]=f(e(),t);return g(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function Yt(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,e(...o)},t)};return m(()=>{r!==void 0&&clearTimeout(r)}),n}function Xt(e){return!!e&&typeof e.then=="function"}var Ae=Symbol();function Y(e,t,r={}){let n,o;typeof t=="function"?(n=typeof e=="function"?e:()=>e,o=t):(n=()=>!0,o=e,t&&typeof t=="object"&&(r=t));let s=r.transport===!1?void 0:Oe(),i=s!==void 0?we(s):void 0,c=i!==void 0,[u,p]=f(i!==void 0?i.value:r.initialValue,{equals:!1}),[y,l]=f(void 0,{equals:!1}),[d,T]=f(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[x,h]=f(void 0,{equals:!1}),[k,j]=f(void 0,{equals:!1}),R=Ae,B=!1;g(()=>{let b=n();if(k(),b===!1||b===null||b===void 0){R=Ae,A(()=>{T("unresolved"),h(void 0),l(void 0)});return}let w=B;if(B=!1,R!==Ae&&b===R&&!w)return;if(R=b,c){c=!1;return}let Z=!1;m(()=>Z=!0);let Be=S(d),bt=S(u),qe=Be==="ready"||Be==="refreshing";A(()=>{T(qe?"refreshing":"pending"),l(void 0)});try{let _=o(b,{value:bt,refetching:qe});Xt(_)?(h(_),xe(_),_.then(ee=>{Z||(s!==void 0&&ge(s,ee),A(()=>{p(()=>ee),T("ready"),h(void 0)}))},ee=>{Z||A(()=>{l(ee),T("errored"),h(void 0)})})):A(()=>{p(()=>_),T("ready"),h(void 0)})}catch(_){if(Z)return;A(()=>{l(_),T("errored"),h(void 0)})}});let J=()=>{let b=d();return b==="pending"||b==="refreshing"},P=(()=>{let b=y();if(b)throw b;if(J()){let w=x();if(w)throw w}return u()});return Object.defineProperties(P,{state:{get:d},loading:{get:J},error:{get:y},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:p,refetch:()=>{B=!0,j(void 0)}}]}function et(e,t=300){let[r,n]=f(e),[o,s]=f(e),[i,c]=f(!1),u,p=()=>{u!==void 0&&(clearTimeout(u),u=void 0)},y=()=>{p();let d=S(r);return s(()=>d),c(!1),d},l=(d=>{let T=typeof d=="function"?d(S(r)):d;return n(()=>T),c(!0),p(),u=setTimeout(y,t),T});return m(p),[o,l,{immediate:r,pending:i,flush:y,cancel:()=>{p(),c(!1)}}]}function Qt(e){return e!=null&&e!==""}function Jt(e,t,r={}){let{delay:n=300,initialValue:o,shouldFetch:s=Qt}=r,[i,c,u]=et(e,n),p=()=>s(i())?i():!1,[y,{refetch:l}]=Y(p,t,o===void 0?{}:{initialValue:o});return[y,{...u,query:i,setQuery:c,refetch:l}]}function se(e){if(typeof e=="function"&&!e.length){let t=e();return he(t)?t:se(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=se(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Zt(e){let t=v(e);return v(()=>se(t()))}var Re=G();Ge((e,t)=>{let r=re(t,Re);r&&(r.increment(),e.finally(()=>r.decrement()))});function er(){let[e,t]=f(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function tr(e,t){return K(Re,e,t)}var tt=G();We((e,t)=>{let r=re(t,tt);return r?(r.setError(e),!0):!1});function rr(){let[e,t]=f(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function nr(e,t){return K(tt,e,t)}var or={State:D,Computed:O,subtle:{Watcher:C,untrack:$,currentComputed:Le,hasSinks:Ve}};var hn=Symbol.for("signal"),bn=Symbol.for("fluixi-proxy");function Cn(e,t){let[r,n]=f(e,t);return Object.assign(r,{set:n})}function Fn(e,t,r){return v(e,t,r)}function In(e,t){return g(e,t)}function sr(...e){let[t,r]=Y(...e);return Object.assign(t,r)}import{$PROXY as Ee,batch as ct,createEffect as ae,createMemo as ke,createSignal as lt,untrack as ir}from"@fluixi/reactive/signal";var ue=Symbol("store-raw"),U=Symbol("store-node"),rt=Symbol("store-has"),Pe=Symbol("store-self"),De=Symbol("store-track"),ar=Symbol("store-name"),ur=Symbol("store-store"),nt=new WeakMap,ot=new WeakMap;function pt(e){let[t,r]=lt(e),n=t;return n.$=r,n}function ce(e){let t=nt.get(e);return t||nt.set(e,t={keys:new Map}),t}function st(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=pt(r)),n}function it(e){let t=ce(e);(t.all||(t.all=pt()))()}function at(e,t){e.$(typeof t=="function"?()=>t:t)}function ft(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 ie(e){if(!ft(e))return e;let t=ot.get(e);if(t)return t;let r=new Proxy(e,cr);return ot.set(e,r),r}var cr={get(e,t,r){if(t===ue||t===U)return e;if(t===Ee)return r;if(t===rt)return i=>i in e;if(t==="__proxy")return!0;if(t===De||t===Pe)return it(e),r;let n=e[t];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return n;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(r);let s=st(ce(e),t,n)();return ft(s)?ie(s):s},set(){return!0},deleteProperty(e,t){return t in e&&X(e,t,void 0),!0},has(e,t){return t===ue||t===Ee||t===U||t===rt||t===Pe||t===De?!0:(st(ce(e),t,e[t])(),t in e)},ownKeys(e){return it(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function X(e,t,r){if(e[t]===r&&(r!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;r===void 0?delete e[t]:e[t]=r;let i=ce(e),c=i.keys.get(t);if(c&&at(c,r),o&&e.length!==s){let u=i.keys.get("length");u&&at(u,e.length)}i.all&&i.all.$(void 0)}function ut(e,t){return typeof e=="function"?e(t):e}function Ce(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?Ce(o,n):X(e,r,n)}}function Ie(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function dt(e,t,r){let n=t.length-1;for(let s=0;s<n;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let p=0;p<e.length;p++)dt(e[p],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},X(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)X(e,s,ut(r,e[s]));return}X(e,o,ut(r,e[o]))}function _e(e,t,r){dt(e,Ie(t),r)}function lr(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&Ce(e,n);return}if(Array.isArray(r)&&t.length===1){for(let n of r)Array.isArray(n)&&_e(e,n[0],n[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){Ce(e,r);return}if(Array.isArray(t[1])&&t.length>=3){_e(e,`${r}.${t[1].join(".")}`,t[2]);return}_e(e,String(r),t[1])}function Fe(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Fe);let t={};for(let r of Object.keys(e))t[r]=Fe(e[r]);return t}function I(e,t){let r=e;for(let n of Ie(t)){if(r==null)return;r=r[n]}return r}var E=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>ct(()=>lr(this.root,n)))}get state(){return ie(this.root)}get proxy(){return ie(this.root)}get accessor(){return(()=>ie(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return Q(this.state);let r=this.state;for(let n of Ie(t)){if(r==null)return;r=r[n]}return Q(r)}select(t){return ke(()=>t(this.state))}subscribe(t){return ae(()=>t(this.state))}watch(t,r){let n;return ae(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return ke(()=>this.state[t])}produce(t){this.set((r=>{let n=Fe(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=I(this.root,t);this.set(t,n.concat(r))}pop(t){let r=I(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=I(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=I(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=I(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=I(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}toObservable(){let[t]=lt(this.state);return t.toObservable()}dispose(){}},pr=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function yt(e,t){for(let r of pr)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function le(e,t={immutable:!0}){let r=new E(e,t);return yt(r.set,r),[r.proxy,r.set]}function Tt(e,t={}){return new E(e,{...t,immutable:!1})}function fr(e,t={}){let r=new E(e(),t);return ae(()=>r.set(e())),r}function dr(e,t,r){return ae(()=>r(t(e)))}function yr(e,t,r){return ke(()=>t(e),void 0,r)}function Tr(e,t={}){let r=new E(e,t),n=(()=>r.proxy);return yt(n,r),n}function Q(e){if(e==null||typeof e!="object")return e;let t=e[ue];return t!==void 0?t:e}function ht(e){return ir(()=>Q(e))}function hr(e){return Ue(e)}function br(e){return Ue(e)?e[U]:null}function mr(e){return e&&typeof e=="object"&&U in e?e[U]:null}function Ue(e){return!!e&&typeof e=="object"&&(Ee in e||e.__proxy===!0)}function vr(e){return e}var Sr=Object.freeze({createStore:le,createMutableStore:Tt,batch:ct,unwrap:Q,untrackStore:ht});function je(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(je);let t={};for(let r of Object.keys(e))t[r]=je(e[r]);return t}function xr(e){return t=>{let r=je(t);return e(r),r}}function wr(e,t={}){return()=>e}function Or(e,t){let[r,n]=le(e,t);return new Proxy(r,{get:(o,s)=>s==="set"?n:o[s],has:(o,s)=>s==="set"||Reflect.has(o,s)})}export{ar as $NAME,U as $NODE,bn as $PROXY,ue as $RAW,Pe as $SELF,hn as $SIGNAL,ur as $STORE,De as $TRACK,M as Observable,pe as SafeSubscriber,or as Signal,E as Store,Sr as StoreAPI,Me as Subject,N as Subscriber,q as Subscription,Re as SuspenseContext,mt as VERSION,Te as __DEV__,A as batch,wt as createChildOwner,Pt as createComputed,fr as createComputedStore,G as createContext,Yt as createDebounce,Jt as createDebouncedResource,et as createDebouncedSignal,zt as createDeferred,g as createEffect,rr as createErrorBoundary,v as createMemo,Tt as createMutableStore,Dt as createRenderEffect,Y as createResource,F as createRoot,Wt as createSelector,f as createSignal,le as createStore,dr as createStoreEffect,yr as createStoreMemo,er as createSuspenseBoundary,Ot as disposeScope,In as effect,Ft as flush,br as getNode,ne as getOwner,we as getServerData,mr as getStoreNode,Kr as indexArray,Mt as isComponent,qt as isMemo,gt as isOwnerDisposed,$t as isProvider,Nt as isResource,he as isSignal,hr as isStore,Ue as isStoreProxy,Ht as isSuspense,Gr as keyArray,Ze as makeArrayFlat,Vr as mapArray,Fn as memo,vr as modifiable,Oe as nextResourceId,It as on,m as onCleanup,kr as operate,xr as produceUtil,K as provide,nr as provideErrorBoundary,tr as provideSuspense,Zt as readChildren,wr as reconcileUtil,ge as reportResourceData,sr as resource,W as runWithOwner,ze as setOwner,Kt as setResourceDataSink,Gt as setResourceIdSource,Lt as setResourceTracker,Vt as setServerDataGetter,Cn as signal,Je as startTransition,Or as store,xe as trackResourcePromise,S as untrack,ht as untrackStore,Q as unwrap,At as useContext,Ct as useTransition,Tr as wrap};
|
|
1
|
+
var mt="1.0.0-alpha.77";import{isObject as vt}from"@fluixi/utils/object";import{isFunction as Ne}from"@fluixi/utils/functions";var q=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:r}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let n of t)n.remove(this);if(r){for(let n of r)if(Ne(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if(vt(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:r,_subscriptions:n}=this;if(r){if(Ne(t))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(t.unsubscribe)try{t.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(t);n!==-1&&(r.splice(n,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:r}=this;r?Array.isArray(r)?r.push(t):this._parentOrParents=[r,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:r}=this;if(r===t)this._parentOrParents=null;else if(Array.isArray(r)){let n=r.indexOf(t);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var N=class extends q{constructor(r,n,o){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:n,complete:o}:s={},this.destination=s}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(n){throw n}else throw r;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(r){this.error(r);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},pe=class extends N{constructor(r,n,o,s){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(r)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};function kr(e){return new N(e.next,e.error,e.complete)}var M=class extends q{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,r,n){let o;t instanceof N?o=t:o=new pe(t,r,n);let{_subscribe:s}=this;try{let i=s.call(this,o);i&&(typeof i=="function"||typeof i.unsubscribe=="function")&&o.add(i)}catch(i){o.error(i)}return o}pipe(...t){return t.length===0?this:t.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((t,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>t(n)})})}};var Me=class extends M{constructor(){super(r=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)r.error(this.thrownError);else if(this.isStopped)r.complete();else return this.observers.push(r),()=>{let n=this.observers.indexOf(r);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(r){if(this.isStopped)return;let{observers:n}=this,o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].next?.(r)}error(r){if(this.isStopped)return;this.hasError=!0,this.thrownError=r,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].error?.(r)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:r}=this;this.observers=[];let n=r.length,o=r.slice();for(let s=0;s<n;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new M(n=>this.subscribe(n))}};var St="__fluixi_signal_next_state__",xt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[St]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:xt,onSuspend:null,onError:null};var He=0,$e=1,H=2,te=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))}},D=class extends te{constructor(t,r){super(),this._value=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let r of[...this.observers])r.markDirty(H);fe(this)}}peek(){return this._value}},O=class extends te{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=H;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){if(a.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===$e&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===H)break}(this.state===H||!this._initialized)&&this.recompute(),this.state=He}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=a.consumer,n=a.untracked;a.consumer=this,a.untracked=!1;let o,s=!1,i;try{o=this._fn()}catch(u){s=!0,i=u,o=this._value}finally{a.consumer=r,a.untracked=n}let c=!this._initialized||this._threw!==s||(s?i!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=s,this._error=i,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(H);fe(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===He;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty($e);fe(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function fe(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var C=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function $(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function Le(){return a.consumer}function Ve(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function wt(e){let t=V(e);return e&&(e.owned??=[]).push(t),t}function Ot(e,t=!0){L(e,t)}function gt(e){return!!e&&e.disposed===!0}function V(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function G(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=V(o);(s.contexts=new Map).set(t,n.value),o&&(o.owned??=[]).push(s),a.owner=s;try{return n.children}finally{a.owner=o}}}}function At(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 re(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function K(e,t,r){let n=V(a.owner);(n.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return r()}finally{a.owner=o}}function Ge(e){a.onSuspend=e}function Ke(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function We(e){a.onError=e}function ne(){return a.owner}function ze(e){let t=a.owner;return a.owner=e,t}function W(e,t){let r=a.owner;a.owner=e;try{return t()}finally{a.owner=r}}function m(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function L(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)L(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}t&&(e.disposed=!0)}}function F(e){let t=V(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>L(t))}finally{a.owner=r}}function Ye(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function Rt(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(z)))}function z(){if(a.scheduled=!1,a.flushing)return;a.flushing=!0;let e=0;try{for(;a.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function Xe(){a.batchDepth===0&&z()}function ye(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&z()}}var de=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=V(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new O(()=>{L(this.owner,!1),W(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new C(()=>Rt(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),L(this.owner))}};function oe(e){let t=new de(e);return()=>t.dispose()}function _t(e){return!!e&&typeof e.then=="function"}Ye(()=>{});var Qe=Symbol.for("signal"),Et=Symbol.for("memo"),kt=Symbol.for("signal-node");function f(e,t){let r=new D(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),Xe(),i});return Object.defineProperty(n,Qe,{value:!0,enumerable:!0}),Object.defineProperty(n,kt,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function v(e,t,r){let n=t,o=ne(),s=new O(()=>W(o,()=>{try{return n=e(n)}catch(c){if(_t(c))return Ke(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,Qe,{value:!0,enumerable:!0}),Object.defineProperty(i,Et,{value:!0,enumerable:!0}),i}function g(e,t){let r=t;return oe(()=>{r=e(r)})}function Pt(e,t){let r=t;oe(()=>{r=e(r)})}function Dt(e,t){let r=t;return oe(()=>{r=e(r)})}function A(e){return ye(e)}function S(e){return $(e)}function Je(e){return ye(e),Promise.resolve()}function Ct(){return[()=>!1,Je]}function Ft(){return z(),Promise.resolve()}function It(e,t,r){let n=Array.isArray(e),o,s=r?.defer??!1;return i=>{let c=n?e.map(p=>p()):e();if(s){s=!1,o=c;return}let u=$(()=>t(c,o,i));return o=c,u}}function Vr(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),v(()=>{let o=e()||[];return S(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=new Map;for(let u of n)s.has(u.item)||s.set(u.item,u);let i=[],c=new Set;for(let u=0;u<o.length;u++){let p=o[u],y=s.get(p);if(y&&!c.has(y))y.setIndex(u),i.push(y),c.add(y);else{let l,d,T;F(h=>{T=h;let[k,j]=f(u);d=j,l=t(p,k)});let x={item:p,rendered:l,dispose:T,setIndex:d};i.push(x),c.add(x)}}for(let u of n)c.has(u)||u.dispose();return n=i,i.map(u=>u.rendered)})})}function Gr(e,t,r,n){let o=[],s=[];return m(()=>{for(let i of s)i.dispose();o=[],s=[]}),v(()=>{let i=e()||[];return S(()=>{if(i.length===0){for(let l of s)l.dispose();return o=[],s=[],n?.fallback?n.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],s[l]);let u=[],p=[],y=new Set;for(let l=0;l<i.length;l++){let d=t(i[l]),T=c.get(d);if(T&&!y.has(d))T.setIndex(l),u.push(T);else{let x,h,k;F(j=>{k=j;let[R,B]=f(l);h=B;let J=v(P=>{let w=(e()||[])[R()];return w??P},i[l]);x=r(J,R)}),u.push({rendered:x,dispose:k,setIndex:h})}p.push(d),y.add(d)}for(let[l,d]of c)y.has(l)||d.dispose();return o=p,s=u,u.map(l=>l.rendered)})})}function Kr(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),v(()=>{let o=e()||[];return S(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=n.length,i=o.length;for(let u=s;u<i;u++){let p,y,l,d=o[u];F(T=>{l=T;let[x,h]=f(d);y=h,p=t(x,u)}),n.push({rendered:p,setItem:y,dispose:l})}for(let u=i;u<s;u++)n[u].dispose();i<s&&(n=n.slice(0,i));let c=Math.min(s,i);for(let u=0;u<c;u++)n[u].setItem(o[u]);return n.map(u=>u.rendered)})})}var Te=!1,Ut=Symbol.for("signal"),jt=Symbol.for("memo"),Bt=Symbol.for("resource");function he(e){return typeof e=="function"&&e[Ut]===!0}function qt(e){return typeof e=="function"&&e[jt]===!0}function Nt(e){return typeof e=="function"&&e[Bt]===!0}function Mt(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Ht(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function $t(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 be=null;function Lt(e){be=e}function xe(e){be&&be(e)}var me=null;function Vt(e){me=e}function we(e){return me?me(e):void 0}var ve=null;function Gt(e){ve=e}function Oe(){return ve?ve():void 0}var Se=null;function Kt(e){Se=e}function ge(e,t){Se&&Se(e,t)}function Wt(e,t=(r,n)=>r===n){let r=new Map;return g(()=>{let n=e();for(let[o,s]of r){let[i,c]=s,u=t(o,n);i()!==u&&c(u)}}),n=>{let o=r.get(n);if(!o){let[s,i]=f(!1);o=[s,i],r.set(n,o);let c=e();i(t(n,c))}return o[0]()}}function zt(e,t){let[r,n]=f(e(),t);return g(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function Yt(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,e(...o)},t)};return m(()=>{r!==void 0&&clearTimeout(r)}),n}function Xt(e){return!!e&&typeof e.then=="function"}var Ae=Symbol();function Y(e,t,r={}){let n,o;typeof t=="function"?(n=typeof e=="function"?e:()=>e,o=t):(n=()=>!0,o=e,t&&typeof t=="object"&&(r=t));let s=r.transport===!1?void 0:Oe(),i=s!==void 0?we(s):void 0,c=i!==void 0,[u,p]=f(i!==void 0?i.value:r.initialValue,{equals:!1}),[y,l]=f(void 0,{equals:!1}),[d,T]=f(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[x,h]=f(void 0,{equals:!1}),[k,j]=f(void 0,{equals:!1}),R=Ae,B=!1;g(()=>{let b=n();if(k(),b===!1||b===null||b===void 0){R=Ae,A(()=>{T("unresolved"),h(void 0),l(void 0)});return}let w=B;if(B=!1,R!==Ae&&b===R&&!w)return;if(R=b,c){c=!1;return}let Z=!1;m(()=>Z=!0);let Be=S(d),bt=S(u),qe=Be==="ready"||Be==="refreshing";A(()=>{T(qe?"refreshing":"pending"),l(void 0)});try{let _=o(b,{value:bt,refetching:qe});Xt(_)?(h(_),xe(_),_.then(ee=>{Z||(s!==void 0&&ge(s,ee),A(()=>{p(()=>ee),T("ready"),h(void 0)}))},ee=>{Z||A(()=>{l(ee),T("errored"),h(void 0)})})):A(()=>{p(()=>_),T("ready"),h(void 0)})}catch(_){if(Z)return;A(()=>{l(_),T("errored"),h(void 0)})}});let J=()=>{let b=d();return b==="pending"||b==="refreshing"},P=(()=>{let b=y();if(b)throw b;if(J()){let w=x();if(w)throw w}return u()});return Object.defineProperties(P,{state:{get:d},loading:{get:J},error:{get:y},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:p,refetch:()=>{B=!0,j(void 0)}}]}function et(e,t=300){let[r,n]=f(e),[o,s]=f(e),[i,c]=f(!1),u,p=()=>{u!==void 0&&(clearTimeout(u),u=void 0)},y=()=>{p();let d=S(r);return s(()=>d),c(!1),d},l=(d=>{let T=typeof d=="function"?d(S(r)):d;return n(()=>T),c(!0),p(),u=setTimeout(y,t),T});return m(p),[o,l,{immediate:r,pending:i,flush:y,cancel:()=>{p(),c(!1)}}]}function Qt(e){return e!=null&&e!==""}function Jt(e,t,r={}){let{delay:n=300,initialValue:o,shouldFetch:s=Qt}=r,[i,c,u]=et(e,n),p=()=>s(i())?i():!1,[y,{refetch:l}]=Y(p,t,o===void 0?{}:{initialValue:o});return[y,{...u,query:i,setQuery:c,refetch:l}]}function se(e){if(typeof e=="function"&&!e.length){let t=e();return he(t)?t:se(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=se(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Zt(e){let t=v(e);return v(()=>se(t()))}var Re=G();Ge((e,t)=>{let r=re(t,Re);r&&(r.increment(),e.finally(()=>r.decrement()))});function er(){let[e,t]=f(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function tr(e,t){return K(Re,e,t)}var tt=G();We((e,t)=>{let r=re(t,tt);return r?(r.setError(e),!0):!1});function rr(){let[e,t]=f(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function nr(e,t){return K(tt,e,t)}var or={State:D,Computed:O,subtle:{Watcher:C,untrack:$,currentComputed:Le,hasSinks:Ve}};var hn=Symbol.for("signal"),bn=Symbol.for("fluixi-proxy");function Cn(e,t){let[r,n]=f(e,t);return Object.assign(r,{set:n})}function Fn(e,t,r){return v(e,t,r)}function In(e,t){return g(e,t)}function sr(...e){let[t,r]=Y(...e);return Object.assign(t,r)}import{$PROXY as Ee,batch as ct,createEffect as ae,createMemo as ke,createSignal as lt,untrack as ir}from"@fluixi/reactive/signal";var ue=Symbol("store-raw"),U=Symbol("store-node"),rt=Symbol("store-has"),Pe=Symbol("store-self"),De=Symbol("store-track"),ar=Symbol("store-name"),ur=Symbol("store-store"),nt=new WeakMap,ot=new WeakMap;function pt(e){let[t,r]=lt(e),n=t;return n.$=r,n}function ce(e){let t=nt.get(e);return t||nt.set(e,t={keys:new Map}),t}function st(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=pt(r)),n}function it(e){let t=ce(e);(t.all||(t.all=pt()))()}function at(e,t){e.$(typeof t=="function"?()=>t:t)}function ft(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 ie(e){if(!ft(e))return e;let t=ot.get(e);if(t)return t;let r=new Proxy(e,cr);return ot.set(e,r),r}var cr={get(e,t,r){if(t===ue||t===U)return e;if(t===Ee)return r;if(t===rt)return i=>i in e;if(t==="__proxy")return!0;if(t===De||t===Pe)return it(e),r;let n=e[t];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return n;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(r);let s=st(ce(e),t,n)();return ft(s)?ie(s):s},set(){return!0},deleteProperty(e,t){return t in e&&X(e,t,void 0),!0},has(e,t){return t===ue||t===Ee||t===U||t===rt||t===Pe||t===De?!0:(st(ce(e),t,e[t])(),t in e)},ownKeys(e){return it(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function X(e,t,r){if(e[t]===r&&(r!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;r===void 0?delete e[t]:e[t]=r;let i=ce(e),c=i.keys.get(t);if(c&&at(c,r),o&&e.length!==s){let u=i.keys.get("length");u&&at(u,e.length)}i.all&&i.all.$(void 0)}function ut(e,t){return typeof e=="function"?e(t):e}function Ce(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?Ce(o,n):X(e,r,n)}}function Ie(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function dt(e,t,r){let n=t.length-1;for(let s=0;s<n;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let p=0;p<e.length;p++)dt(e[p],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},X(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)X(e,s,ut(r,e[s]));return}X(e,o,ut(r,e[o]))}function _e(e,t,r){dt(e,Ie(t),r)}function lr(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&Ce(e,n);return}if(Array.isArray(r)&&t.length===1){for(let n of r)Array.isArray(n)&&_e(e,n[0],n[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){Ce(e,r);return}if(Array.isArray(t[1])&&t.length>=3){_e(e,`${r}.${t[1].join(".")}`,t[2]);return}_e(e,String(r),t[1])}function Fe(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Fe);let t={};for(let r of Object.keys(e))t[r]=Fe(e[r]);return t}function I(e,t){let r=e;for(let n of Ie(t)){if(r==null)return;r=r[n]}return r}var E=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>ct(()=>lr(this.root,n)))}get state(){return ie(this.root)}get proxy(){return ie(this.root)}get accessor(){return(()=>ie(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return Q(this.state);let r=this.state;for(let n of Ie(t)){if(r==null)return;r=r[n]}return Q(r)}select(t){return ke(()=>t(this.state))}subscribe(t){return ae(()=>t(this.state))}watch(t,r){let n;return ae(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return ke(()=>this.state[t])}produce(t){this.set((r=>{let n=Fe(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=I(this.root,t);this.set(t,n.concat(r))}pop(t){let r=I(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=I(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=I(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=I(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=I(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}toObservable(){let[t]=lt(this.state);return t.toObservable()}dispose(){}},pr=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function yt(e,t){for(let r of pr)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function le(e,t={immutable:!0}){let r=new E(e,t);return yt(r.set,r),[r.proxy,r.set]}function Tt(e,t={}){return new E(e,{...t,immutable:!1})}function fr(e,t={}){let r=new E(e(),t);return ae(()=>r.set(e())),r}function dr(e,t,r){return ae(()=>r(t(e)))}function yr(e,t,r){return ke(()=>t(e),void 0,r)}function Tr(e,t={}){let r=new E(e,t),n=(()=>r.proxy);return yt(n,r),n}function Q(e){if(e==null||typeof e!="object")return e;let t=e[ue];return t!==void 0?t:e}function ht(e){return ir(()=>Q(e))}function hr(e){return Ue(e)}function br(e){return Ue(e)?e[U]:null}function mr(e){return e&&typeof e=="object"&&U in e?e[U]:null}function Ue(e){return!!e&&typeof e=="object"&&(Ee in e||e.__proxy===!0)}function vr(e){return e}var Sr=Object.freeze({createStore:le,createMutableStore:Tt,batch:ct,unwrap:Q,untrackStore:ht});function je(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(je);let t={};for(let r of Object.keys(e))t[r]=je(e[r]);return t}function xr(e){return t=>{let r=je(t);return e(r),r}}function wr(e,t={}){return()=>e}function Or(e,t){let[r,n]=le(e,t);return new Proxy(r,{get:(o,s)=>s==="set"?n:o[s],has:(o,s)=>s==="set"||Reflect.has(o,s)})}export{ar as $NAME,U as $NODE,bn as $PROXY,ue as $RAW,Pe as $SELF,hn as $SIGNAL,ur as $STORE,De as $TRACK,M as Observable,pe as SafeSubscriber,or as Signal,E as Store,Sr as StoreAPI,Me as Subject,N as Subscriber,q as Subscription,Re as SuspenseContext,mt as VERSION,Te as __DEV__,A as batch,wt as createChildOwner,Pt as createComputed,fr as createComputedStore,G as createContext,Yt as createDebounce,Jt as createDebouncedResource,et as createDebouncedSignal,zt as createDeferred,g as createEffect,rr as createErrorBoundary,v as createMemo,Tt as createMutableStore,Dt as createRenderEffect,Y as createResource,F as createRoot,Wt as createSelector,f as createSignal,le as createStore,dr as createStoreEffect,yr as createStoreMemo,er as createSuspenseBoundary,Ot as disposeScope,In as effect,Ft as flush,br as getNode,ne as getOwner,we as getServerData,mr as getStoreNode,Kr as indexArray,Mt as isComponent,qt as isMemo,gt as isOwnerDisposed,$t as isProvider,Nt as isResource,he as isSignal,hr as isStore,Ue as isStoreProxy,Ht as isSuspense,Gr as keyArray,Ze as makeArrayFlat,Vr as mapArray,Fn as memo,vr as modifiable,Oe as nextResourceId,It as on,m as onCleanup,kr as operate,xr as produceUtil,K as provide,nr as provideErrorBoundary,tr as provideSuspense,Zt as readChildren,wr as reconcileUtil,ge as reportResourceData,sr as resource,W as runWithOwner,ze as setOwner,Kt as setResourceDataSink,Gt as setResourceIdSource,Lt as setResourceTracker,Vt as setServerDataGetter,Cn as signal,Je as startTransition,Or as store,xe as trackResourcePromise,S as untrack,ht as untrackStore,Q as unwrap,At as useContext,Ct as useTransition,Tr as wrap};
|