@fluixi/reactive 1.0.0-alpha.82 → 1.0.0-alpha.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +4 -0
  2. package/dist/cdn/reactive.cjs +1 -1
  3. package/dist/cdn/reactive.global.js +1 -1
  4. package/dist/cdn/reactive.mjs +1 -1
  5. package/dist/cdn/signal.cjs +1 -1
  6. package/dist/cdn/signal.global.js +1 -1
  7. package/dist/cdn/signal.mjs +1 -1
  8. package/dist/index.cjs +1 -1
  9. package/dist/index.mjs +1 -1
  10. package/dist/lib/index.cjs +1 -1
  11. package/dist/lib/index.mjs +1 -1
  12. package/dist/lib/signal/api.cjs +1 -1
  13. package/dist/lib/signal/api.mjs +1 -1
  14. package/dist/lib/signal/cached-resource.cjs +1 -1
  15. package/dist/lib/signal/cached-resource.mjs +1 -1
  16. package/dist/lib/signal/graph/children.cjs +1 -1
  17. package/dist/lib/signal/graph/children.mjs +1 -1
  18. package/dist/lib/signal/graph/compat.cjs +1 -1
  19. package/dist/lib/signal/graph/compat.d.ts.map +1 -1
  20. package/dist/lib/signal/graph/compat.js +19 -2
  21. package/dist/lib/signal/graph/compat.mjs +1 -1
  22. package/dist/lib/signal/graph/core.cjs +1 -1
  23. package/dist/lib/signal/graph/core.d.ts.map +1 -1
  24. package/dist/lib/signal/graph/core.js +7 -0
  25. package/dist/lib/signal/graph/core.mjs +1 -1
  26. package/dist/lib/signal/graph/debounced.cjs +1 -1
  27. package/dist/lib/signal/graph/debounced.mjs +1 -1
  28. package/dist/lib/signal/graph/derived.cjs +1 -1
  29. package/dist/lib/signal/graph/derived.mjs +1 -1
  30. package/dist/lib/signal/graph/error-boundary.cjs +1 -1
  31. package/dist/lib/signal/graph/error-boundary.mjs +1 -1
  32. package/dist/lib/signal/graph/index.cjs +1 -1
  33. package/dist/lib/signal/graph/index.mjs +1 -1
  34. package/dist/lib/signal/graph/observe.cjs +1 -0
  35. package/dist/lib/signal/graph/observe.d.ts +141 -0
  36. package/dist/lib/signal/graph/observe.d.ts.map +1 -0
  37. package/dist/lib/signal/graph/observe.js +149 -0
  38. package/dist/lib/signal/graph/observe.mjs +1 -0
  39. package/dist/lib/signal/graph/resource.cjs +1 -1
  40. package/dist/lib/signal/graph/resource.mjs +1 -1
  41. package/dist/lib/signal/graph/runtime.cjs +1 -1
  42. package/dist/lib/signal/graph/runtime.d.ts +2 -2
  43. package/dist/lib/signal/graph/runtime.d.ts.map +1 -1
  44. package/dist/lib/signal/graph/runtime.js +22 -7
  45. package/dist/lib/signal/graph/runtime.mjs +1 -1
  46. package/dist/lib/signal/graph/signal-next.cjs +1 -1
  47. package/dist/lib/signal/graph/signal-next.mjs +1 -1
  48. package/dist/lib/signal/graph/state.cjs +1 -1
  49. package/dist/lib/signal/graph/state.d.ts +2 -0
  50. package/dist/lib/signal/graph/state.d.ts.map +1 -1
  51. package/dist/lib/signal/graph/state.js +1 -0
  52. package/dist/lib/signal/graph/state.mjs +1 -1
  53. package/dist/lib/signal/graph/suspense.cjs +1 -1
  54. package/dist/lib/signal/graph/suspense.mjs +1 -1
  55. package/dist/lib/signal/index-legacy.cjs +1 -1
  56. package/dist/lib/signal/index-legacy.mjs +1 -1
  57. package/dist/lib/signal/index.cjs +1 -1
  58. package/dist/lib/signal/index.d.ts +2 -0
  59. package/dist/lib/signal/index.d.ts.map +1 -1
  60. package/dist/lib/signal/index.js +2 -0
  61. package/dist/lib/signal/index.mjs +1 -1
  62. package/dist/lib/signal/list.cjs +1 -1
  63. package/dist/lib/signal/list.js +5 -5
  64. package/dist/lib/signal/list.mjs +1 -1
  65. package/dist/lib/signal/resource-api.cjs +1 -1
  66. package/dist/lib/signal/resource-api.mjs +1 -1
  67. package/dist/lib/signal/signal.cjs +1 -1
  68. package/dist/lib/signal/signal.mjs +1 -1
  69. package/dist/lib/signal/utilities.cjs +1 -1
  70. package/dist/lib/signal/utilities.mjs +1 -1
  71. package/dist/lib/store/api.cjs +1 -1
  72. package/dist/lib/store/api.mjs +1 -1
  73. package/dist/lib/store/index.cjs +1 -1
  74. package/dist/lib/store/index.mjs +1 -1
  75. package/dist/lib/store/store.cjs +1 -1
  76. package/dist/lib/store/store.d.ts.map +1 -1
  77. package/dist/lib/store/store.js +148 -8
  78. package/dist/lib/store/store.mjs +1 -1
  79. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  80. package/dist/version.generated.cjs +1 -1
  81. package/dist/version.generated.d.ts +1 -1
  82. package/dist/version.generated.js +1 -1
  83. package/dist/version.generated.mjs +1 -1
  84. package/package.json +2 -2
@@ -9,6 +9,8 @@
9
9
  * `@fluixi/reactive/signal-legacy` entry (./index-legacy.ts).
10
10
  */
11
11
  export * from './graph/signal-next.js';
12
+ // Watching nodes as they are made — what @fluixi/devtools attaches to.
13
+ export { observeReactiveNodes, reportReactiveBinding, reportReactiveProps, reportReactiveDirective, reportReactiveContext, reportReactiveContextCreated } from './graph/observe.js';
12
14
  // The short API — `signal`/`memo`/`effect` over the same primitives.
13
15
  export * from './api.js';
14
16
  export { resource } from './resource-api.js';
@@ -1 +1 @@
1
- var De="__fluixi_signal_next_state__",Pe=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},o=globalThis[De]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Pe,onSuspend:null,onError:null};var Te=0,ye=1,M=2,$=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(o.untracked)return;let n=o.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},C=class extends ${constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(M);J(this)}}peek(){return this._value}},b=class extends ${constructor(t,r){super();this._threw=!1;this._initialized=!1;this.state=M;this.sources=null;this._fn=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){if(o.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 t of this.sources)if(t.updateIfNecessary(),this.state===M)break}(this.state===M||!this._initialized)&&this.recompute(),this.state=Te}recompute(){if(this.sources){for(let i of this.sources)i.observers?.delete(this);this.sources.clear()}let t=o.consumer,r=o.untracked;o.consumer=this,o.untracked=!1;let s,u=!1,a;try{s=this._fn()}catch(i){u=!0,a=i,s=this._value}finally{o.consumer=t,o.untracked=r}let c=!this._initialized||this._threw!==u||(u?a!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=u,this._error=a,this._value=s,c){if(this.version++,this.observers)for(let i of[...this.observers])i.markDirty(M);J(this)}}markDirty(t){if(this.state>=t)return;let r=this.state===Te;if(this.state=t,r){if(this.observers)for(let s of[...this.observers])s.markDirty(ye);J(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function J(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var D=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function U(e){if(o.untracked)return e();o.untracked=!0;try{return e()}finally{o.untracked=!1}}function me(){return o.consumer}function ve(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function qe(e){let n=B(e);return e&&(e.owned??=[]).push(n),n}function Ie(e,n=!0){F(e,n)}function Me(e){return!!e&&e.disposed===!0}function B(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function j(e){let n=Symbol("context");return{id:n,defaultValue:e,Provider:r=>{let s=o.owner,u=B(s);(u.contexts=new Map).set(n,r.value),s&&(s.owned??=[]).push(u),o.owner=u;try{return r.children}finally{o.owner=s}}}}function Ue(e){let n=o.owner;for(;n;){if(n.contexts&&n.contexts.has(e.id))return n.contexts.get(e.id);n=n.parent}return e.defaultValue}function K(e,n){let t=e;for(;t;){if(t.contexts&&t.contexts.has(n.id))return t.contexts.get(n.id);t=t.parent}return n.defaultValue}function N(e,n,t){let r=B(o.owner);(r.contexts=new Map).set(e.id,n),o.owner&&(o.owner.owned??=[]).push(r);let s=o.owner;o.owner=r;try{return t()}finally{o.owner=s}}function we(e){o.onSuspend=e}function Se(e){return o.onSuspend?(o.onSuspend(e,o.owner),!0):!1}function xe(e){o.onError=e}function Y(){return o.owner}function ge(e){let n=o.owner;return o.owner=e,n}function V(e,n){let t=o.owner;o.owner=e;try{return n()}finally{o.owner=t}}function v(e){if(o.owner){if(o.owner.disposed){e();return}(o.owner.cleanups??=[]).push(e)}}function F(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)F(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}n&&(e.disposed=!0)}}function P(e){let n=B(o.owner);o.owner&&(o.owner.owned??=[]).push(n);let t=o.owner;o.owner=n;try{return e(()=>F(n))}finally{o.owner=t}}function be(e){o.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function Fe(e){e.queued||(e.queued=!0,o.queue.push(e),!o.scheduled&&o.batchDepth===0&&(o.scheduled=!0,o.hostSchedule(L)))}function L(){if(o.scheduled=!1,o.flushing)return;o.flushing=!0;let e=0;try{for(;o.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=o.queue;o.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{o.flushing=!1}}function Re(){o.batchDepth===0&&L()}function ee(e){o.batchDepth++;try{return e()}finally{--o.batchDepth===0&&L()}}var Z=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=B(o.owner),o.owner&&(o.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new b(()=>{F(this.owner,!1),V(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new D(()=>Fe(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&o.onSuspend){o.onSuspend(n,this.owner);return}if(o.onError&&o.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),F(this.owner))}};function Q(e){let n=new Z(e);return()=>n.dispose()}function Be(e){return!!e&&typeof e.then=="function"}be(()=>{});var ke=Symbol.for("signal"),je=Symbol.for("memo"),Ne=Symbol.for("signal-node");function d(e,n){let t=new C(e,{equals:n?.equals}),r=(()=>t.get()),s=(u=>{let a=typeof u=="function"?u(t.peek()):u;return t.set(a),Re(),a});return Object.defineProperty(r,ke,{value:!0,enumerable:!0}),Object.defineProperty(r,Ne,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[r,s]}function w(e,n,t){let r=n,s=Y(),u=new b(()=>V(s,()=>{try{return r=e(r)}catch(c){if(Be(c))return Se(c),r;throw c}}),{equals:t?.equals}),a=(()=>u.get());return Object.defineProperty(a,ke,{value:!0,enumerable:!0}),Object.defineProperty(a,je,{value:!0,enumerable:!0}),a}function R(e,n){let t=n;return Q(()=>{t=e(t)})}function Ve(e,n){let t=n;Q(()=>{t=e(t)})}function Le(e,n){let t=n;return Q(()=>{t=e(t)})}function k(e){return ee(e)}function S(e){return U(e)}function _e(e){return ee(e),Promise.resolve()}function He(){return[()=>!1,_e]}function We(){return L(),Promise.resolve()}function Ge(e,n,t){let r=Array.isArray(e),s,u=t?.defer??!1;return a=>{let c=r?e.map(f=>f()):e();if(u){u=!1,s=c;return}let i=U(()=>n(c,s,a));return s=c,i}}function Cn(e,n,t){let r=[];return v(()=>{for(let s of r)s.dispose();r=[]}),w(()=>{let s=e()||[];return S(()=>{if(s.length===0){for(let i of r)i.dispose();return r=[],t?.fallback?t.fallback():[]}let u=new Map;for(let i of r)u.has(i.item)||u.set(i.item,i);let a=[],c=new Set;for(let i=0;i<s.length;i++){let f=s[i],h=u.get(f);if(h&&!c.has(h))h.setIndex(i),a.push(h),c.add(h);else{let l,p,T;P(y=>{T=y;let[A,q]=d(i);p=q,l=n(f,A)});let x={item:f,rendered:l,dispose:T,setIndex:p};a.push(x),c.add(x)}}for(let i of r)c.has(i)||i.dispose();return r=a,a.map(i=>i.rendered)})})}function Dn(e,n,t,r){let s=[],u=[];return v(()=>{for(let a of u)a.dispose();s=[],u=[]}),w(()=>{let a=e()||[];return S(()=>{if(a.length===0){for(let l of u)l.dispose();return s=[],u=[],r?.fallback?r.fallback():[]}let c=new Map;for(let l=0;l<s.length;l++)c.set(s[l],u[l]);let i=[],f=[],h=new Set;for(let l=0;l<a.length;l++){let p=n(a[l]),T=c.get(p);if(T&&!h.has(p))T.setIndex(l),i.push(T);else{let x,y,A;P(q=>{A=q;let[_,I]=d(l);y=I;let W=w(E=>{let g=(e()||[])[_()];return g??E},a[l]);x=t(W,_)}),i.push({rendered:x,dispose:A,setIndex:y})}f.push(p),h.add(p)}for(let[l,p]of c)h.has(l)||p.dispose();return s=f,u=i,i.map(l=>l.rendered)})})}function Pn(e,n,t){let r=[];return v(()=>{for(let s of r)s.dispose();r=[]}),w(()=>{let s=e()||[];return S(()=>{if(s.length===0){for(let i of r)i.dispose();return r=[],t?.fallback?t.fallback():[]}let u=r.length,a=s.length;for(let i=u;i<a;i++){let f,h,l,p=s[i];P(T=>{l=T;let[x,y]=d(p);h=y,f=n(x,i)}),r.push({rendered:f,setItem:h,dispose:l})}for(let i=a;i<u;i++)r[i].dispose();a<u&&(r=r.slice(0,a));let c=Math.min(u,a);for(let i=0;i<c;i++)r[i].setItem(s[i]);return r.map(i=>i.rendered)})})}var ze=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,ne=typeof process>"u"?ze:!1,$e=Symbol.for("signal"),Ke=Symbol.for("memo"),Ye=Symbol.for("resource");function te(e){return typeof e=="function"&&e[$e]===!0}function Qe(e){return typeof e=="function"&&e[Ke]===!0}function Xe(e){return typeof e=="function"&&e[Ye]===!0}function Je(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Ze(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function en(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Oe(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Oe(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var re=null;function nn(e){re=e}function ue(e){re&&re(e)}var oe=null;function tn(e){oe=e}function ae(e){return oe?oe(e):void 0}var se=null;function rn(e){se=e}function ce(){return se?se():void 0}var ie=null;function on(e){ie=e}function le(e,n){ie&&ie(e,n)}function sn(e,n=(t,r)=>t===r){let t=new Map;return R(()=>{let r=e();for(let[s,u]of t){let[a,c]=u,i=n(s,r);a()!==i&&c(i)}}),r=>{let s=t.get(r);if(!s){let[u,a]=d(!1);s=[u,a],t.set(r,s);let c=e();a(n(r,c))}return s[0]()}}function un(e,n){let[t,r]=d(e(),n);return R(()=>{let s=e();n?.timeoutMs?setTimeout(()=>r(()=>s),n.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>r(()=>s)):Promise.resolve().then(()=>r(()=>s))}),t}function an(e,n){let t,r=(...s)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e(...s)},n)};return v(()=>{t!==void 0&&clearTimeout(t)}),r}function cn(e){return!!e&&typeof e.then=="function"}var de=Symbol();function H(e,n,t={}){let r,s;typeof n=="function"?(r=typeof e=="function"?e:()=>e,s=n):(r=()=>!0,s=e,n&&typeof n=="object"&&(t=n));let u=t.transport===!1?void 0:ce(),a=u!==void 0?ae(u):void 0,c=a!==void 0,[i,f]=d(a!==void 0?a.value:t.initialValue,{equals:!1}),[h,l]=d(void 0,{equals:!1}),[p,T]=d(a!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[x,y]=d(void 0,{equals:!1}),[A,q]=d(void 0,{equals:!1}),_=de,I=!1;R(()=>{let m=r();if(A(),m===!1||m===null||m===void 0){_=de,k(()=>{T("unresolved"),y(void 0),l(void 0)});return}let g=I;if(I=!1,_!==de&&m===_&&!g)return;if(_=m,c){c=!1;return}let G=!1;v(()=>G=!0);let pe=S(p),Ce=S(i),he=pe==="ready"||pe==="refreshing";k(()=>{T(he?"refreshing":"pending"),l(void 0)});try{let O=s(m,{value:Ce,refetching:he});cn(O)?(y(O),ue(O),O.then(z=>{G||(u!==void 0&&le(u,z),k(()=>{f(()=>z),T("ready"),y(void 0)}))},z=>{G||k(()=>{l(z),T("errored"),y(void 0)})})):k(()=>{f(()=>O),T("ready"),y(void 0)})}catch(O){if(G)return;k(()=>{l(O),T("errored"),y(void 0)})}});let W=()=>{let m=p();return m==="pending"||m==="refreshing"},E=(()=>{let m=h();if(m)throw m;if(W()){let g=x();if(g)throw g}return i()});return Object.defineProperties(E,{state:{get:p},loading:{get:W},error:{get:h},latest:{get:i}}),Object.defineProperty(E,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(E,Symbol.for("signal"),{value:!0,enumerable:!0}),[E,{mutate:f,refetch:()=>{I=!0,q(void 0)}}]}function Ae(e,n=300){let[t,r]=d(e),[s,u]=d(e),[a,c]=d(!1),i,f=()=>{i!==void 0&&(clearTimeout(i),i=void 0)},h=()=>{f();let p=S(t);return u(()=>p),c(!1),p},l=(p=>{let T=typeof p=="function"?p(S(t)):p;return r(()=>T),c(!0),f(),i=setTimeout(h,n),T});return v(f),[s,l,{immediate:t,pending:a,flush:h,cancel:()=>{f(),c(!1)}}]}function ln(e){return e!=null&&e!==""}function dn(e,n,t={}){let{delay:r=300,initialValue:s,shouldFetch:u=ln}=t,[a,c,i]=Ae(e,r),f=()=>u(a())?a():!1,[h,{refetch:l}]=H(f,n,s===void 0?{}:{initialValue:s});return[h,{...i,query:a,setQuery:c,refetch:l}]}function X(e){if(typeof e=="function"&&!e.length){let n=e();return te(n)?n:X(n)}if(Array.isArray(e)){let n=[];for(let t=0;t<e.length;t++){let r=X(e[t]);Array.isArray(r)?n.push.apply(n,r):n.push(r)}return n}return e}function fn(e){let n=w(e);return ne?w(()=>X(n()),void 0,{name:"children"}):w(()=>X(n()))}var fe=j();we((e,n)=>{let t=K(n,fe);t&&(t.increment(),e.finally(()=>t.decrement()))});function pn(){let[e,n]=d(0),t=0;return{increment:()=>n(t+=1),decrement:()=>n(t-=1),inFallback:()=>e()>0}}function hn(e,n){return N(fe,e,n)}var Ee=j();xe((e,n)=>{let t=K(n,Ee);return t?(t.setError(e),!0):!1});function Tn(){let[e,n]=d(void 0,{equals:!1});return{error:e,reset:()=>n(()=>{}),setError:r=>n(()=>r)}}function yn(e,n){return N(Ee,e,n)}var mn={State:C,Computed:b,subtle:{Watcher:D,untrack:U,currentComputed:me,hasSinks:ve}};var nt=Symbol.for("signal"),tt=Symbol.for("fluixi-proxy");function mt(e,n){let[t,r]=d(e,n);return Object.assign(t,{set:r})}function vt(e,n,t){return w(e,n,t)}function wt(e,n){return R(e,n)}function vn(...e){let[n,t]=H(...e);return Object.assign(n,t)}export{tt as $PROXY,nt as $SIGNAL,mn as Signal,fe as SuspenseContext,ne as __DEV__,k as batch,qe as createChildOwner,Ve as createComputed,j as createContext,an as createDebounce,dn as createDebouncedResource,Ae as createDebouncedSignal,un as createDeferred,R as createEffect,Tn as createErrorBoundary,w as createMemo,Le as createRenderEffect,H as createResource,P as createRoot,sn as createSelector,d as createSignal,pn as createSuspenseBoundary,Ie as disposeScope,wt as effect,We as flush,Y as getOwner,ae as getServerData,Pn as indexArray,Je as isComponent,Qe as isMemo,Me as isOwnerDisposed,en as isProvider,Xe as isResource,te as isSignal,Ze as isSuspense,Dn as keyArray,Oe as makeArrayFlat,Cn as mapArray,vt as memo,ce as nextResourceId,Ge as on,v as onCleanup,N as provide,yn as provideErrorBoundary,hn as provideSuspense,fn as readChildren,le as reportResourceData,vn as resource,V as runWithOwner,ge as setOwner,on as setResourceDataSink,rn as setResourceIdSource,nn as setResourceTracker,tn as setServerDataGetter,mt as signal,_e as startTransition,ue as trackResourcePromise,S as untrack,Ue as useContext,He as useTransition};
1
+ var We="__fluixi_signal_next_state__",Ge=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},o=globalThis[We]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Ge,onSuspend:null,onError:null,observer:null};var be="1.0.0-alpha.83";function Se(e){return o.observer=e,()=>{o.observer===e&&(o.observer=null)}}var m=[],Ke;function M(e){let n=o.observer;n&&n.created(e.parents===void 0?{...e,parents:m,origin:e.origin??Ke}:e)}function Re(e){return o.observer?(m.push(e),!0):!1}function ke(){m.pop()}function Oe(e){o.observer?.ran?.(e)}function _e(e,n){o.observer?.wrote?.(e,n)}function ze(e,n,r,t){let s=o.observer;!s?.bound||!m.length||s.bound(m[m.length-1],e,n,r,t)}function $e(e){let n=o.observer;!n?.props||!m.length||!e||n.props(m[m.length-1],e)}function Ye(e,n,r,t){let s=o.observer;!s?.directive||!m.length||s.directive(m[m.length-1],e,n,r,t)}function re(e){o.observer?.contextCreated?.(e)}function U(e,n,r){let t=o.observer;!t?.context||!m.length||t.context(m[m.length-1],e,n,r)}function B(e){o.observer?.disposed?.(e)}var Xe="__FLUIXI_DEVTOOLS_HOOK__",ge=globalThis[Xe];if(typeof ge?.inject=="function")try{ge.inject({observeReactiveNodes:Se,version:be})}catch{}function te(){return o.observer!=null}var Ce=0,Ae=1,F=2,Q=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(o.untracked)return;let n=o.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},D=class extends Q{constructor(n,r){super(),this._value=n,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,_e(this,o.consumer),this.observers)for(let r of[...this.observers])r.markDirty(F);oe(this)}}peek(){return this._value}},R=class extends Q{constructor(r,t){super();this._threw=!1;this._initialized=!1;this.state=F;this.sources=null;this._fn=r,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){if(o.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===Ae&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===F)break}(this.state===F||!this._initialized)&&this.recompute(),this.state=Ce}recompute(){if(this.sources){for(let l of this.sources)l.observers?.delete(this);this.sources.clear()}let r=o.consumer,t=o.untracked,s=Re(this);o.consumer=this,o.untracked=!1;let a,u=!1,c;try{a=this._fn()}catch(l){u=!0,c=l,a=this._value}finally{o.consumer=r,o.untracked=t,s&&ke()}let i=!this._initialized||this._threw!==u||(u?c!==this._error:!this._equals(this._value,a));if(this._initialized=!0,this._threw=u,this._error=c,this._value=a,Oe(this),i){if(this.version++,this.observers)for(let l of[...this.observers])l.markDirty(F);oe(this)}}markDirty(r){if(this.state>=r)return;let t=this.state===Ce;if(this.state=r,t){if(this.observers)for(let s of[...this.observers])s.markDirty(Ae);oe(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function oe(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var P=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let r of n)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...n){for(let r of n)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let r=this._pending.size===0;this._pending.add(n),r&&this._notifyFn()}};function j(e){if(o.untracked)return e();o.untracked=!0;try{return e()}finally{o.untracked=!1}}function Ee(){return o.consumer}function De(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function Qe(e){let n=H(e);return e&&(e.owned??=[]).push(n),n}function Je(e,n=!0){V(e,n)}function Ze(e){return!!e&&e.disposed===!0}function H(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function L(e,n){let r=Symbol(n??"context");return re(r),{id:r,defaultValue:e,Provider:s=>{U(r,"provide",s.value);let a=o.owner,u=H(a);(u.contexts=new Map).set(r,s.value),a&&(a.owned??=[]).push(u),o.owner=u;try{return s.children}finally{o.owner=a}}}}function en(e){let n=o.owner;for(;n;){if(n.contexts&&n.contexts.has(e.id)){let r=n.contexts.get(e.id);return U(e.id,"read",r),r}n=n.parent}return U(e.id,"read",e.defaultValue),e.defaultValue}function J(e,n){let r=e;for(;r;){if(r.contexts&&r.contexts.has(n.id))return r.contexts.get(n.id);r=r.parent}return n.defaultValue}function W(e,n,r){let t=H(o.owner);(t.contexts=new Map).set(e.id,n),o.owner&&(o.owner.owned??=[]).push(t);let s=o.owner;o.owner=t;try{return r()}finally{o.owner=s}}function Pe(e){o.onSuspend=e}function Ie(e){return o.onSuspend?(o.onSuspend(e,o.owner),!0):!1}function qe(e){o.onError=e}function Z(){return o.owner}function Ne(e){let n=o.owner;return o.owner=e,n}function G(e,n){let r=o.owner;o.owner=e;try{return n()}finally{o.owner=r}}function y(e){if(o.owner){if(o.owner.disposed){e();return}(o.owner.cleanups??=[]).push(e)}}function V(e,n=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)V(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}n&&(e.disposed=!0)}}function I(e){let n=H(o.owner);o.owner&&(o.owner.owned??=[]).push(n);let r=o.owner;o.owner=n;try{return e(()=>V(n))}finally{o.owner=r}}function Me(e){o.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function nn(e){e.queued||(e.queued=!0,o.queue.push(e),!o.scheduled&&o.batchDepth===0&&(o.scheduled=!0,o.hostSchedule(K)))}function K(){if(o.scheduled=!1,o.flushing)return;o.flushing=!0;let e=0;try{for(;o.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=o.queue;o.queue=[];for(let r of n)r.queued=!1,r.disposed||r.run()}}finally{o.flushing=!1}}function Ue(){o.batchDepth===0&&K()}function ie(e){o.batchDepth++;try{return e()}finally{--o.batchDepth===0&&K()}}var se=class{constructor(n,r=!1){this.queued=!1;this.disposed=!1;this.owner=H(o.owner),o.owner&&(o.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new R(()=>{V(this.owner,!1),G(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),M({kind:"effect",node:this.computed,handle:this,internal:!r}),this.watcher=new P(()=>nn(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&o.onSuspend){o.onSuspend(n,this.owner);return}if(o.onError&&o.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,B(this.computed),this.watcher.unwatch(this.computed),V(this.owner))}};function ee(e,n=!1){let r=new se(e,n);return()=>r.dispose()}function rn(e){return!!e&&typeof e.then=="function"}Me(()=>{});var Be=Symbol.for("signal"),tn=Symbol.for("memo"),on=Symbol.for("signal-node");function f(e,n){let r=new D(e,{equals:n?.equals}),t=(()=>r.get()),s=(a=>{let u=typeof a=="function"?a(r.peek()):a;return r.set(u),Ue(),u});return Object.defineProperty(t,Be,{value:!0,enumerable:!0}),Object.defineProperty(t,on,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),M({kind:"signal",node:r,handle:t,name:n?.name,set:s}),te()&&y(()=>B(r)),[t,s]}function x(e,n,r){let t=n,s=Z(),a=new R(()=>G(s,()=>{try{return t=e(t)}catch(c){if(rn(c))return Ie(c),t;throw c}}),{equals:r?.equals}),u=(()=>a.get());return Object.defineProperty(u,Be,{value:!0,enumerable:!0}),Object.defineProperty(u,tn,{value:!0,enumerable:!0}),M({kind:"memo",node:a,handle:u,name:r?.name}),te()&&y(()=>B(a)),u}function k(e,n){let r=n;return ee(()=>{r=e(r)},!0)}function sn(e,n){let r=n;ee(()=>{r=e(r)})}function un(e,n){let r=n;return ee(()=>{r=e(r)})}function O(e){return ie(e)}function b(e){return j(e)}function Fe(e){return ie(e),Promise.resolve()}function an(){return[()=>!1,Fe]}function cn(){return K(),Promise.resolve()}function dn(e,n,r){let t=Array.isArray(e),s,a=r?.defer??!1;return u=>{let c=t?e.map(l=>l()):e();if(a){a=!1,s=c;return}let i=j(()=>n(c,s,u));return s=c,i}}function nr(e,n,r){let t=[];return y(()=>{for(let s of t)s.dispose();t=[]}),x(()=>{let s=e()||[];return b(()=>{if(s.length===0){for(let i of t)i.dispose();return t=[],r?.fallback?r.fallback():[]}let a=new Map;for(let i of t)a.has(i.item)||a.set(i.item,i);let u=[],c=new Set;for(let i=0;i<s.length;i++){let l=s[i],v=a.get(l);if(v&&!c.has(v))v.setIndex(i),u.push(v),c.add(v);else{let d,p,h;I(T=>{h=T;let[A,q]=f(i,{name:"row index"});p=q,d=n(l,A)});let g={item:l,rendered:d,dispose:h,setIndex:p};u.push(g),c.add(g)}}for(let i of t)c.has(i)||i.dispose();return t=u,u.map(i=>i.rendered)})},void 0,{name:"mapArray"})}function rr(e,n,r,t){let s=[],a=[];return y(()=>{for(let u of a)u.dispose();s=[],a=[]}),x(()=>{let u=e()||[];return b(()=>{if(u.length===0){for(let d of a)d.dispose();return s=[],a=[],t?.fallback?t.fallback():[]}let c=new Map;for(let d=0;d<s.length;d++)c.set(s[d],a[d]);let i=[],l=[],v=new Set;for(let d=0;d<u.length;d++){let p=n(u[d]),h=c.get(p);if(h&&!v.has(p))h.setIndex(d),i.push(h);else{let g,T,A;I(q=>{A=q;let[_,N]=f(d,{name:"row index"});T=N;let $=x(E=>{let S=(e()||[])[_()];return S??E},u[d]);g=r($,_)}),i.push({rendered:g,dispose:A,setIndex:T})}l.push(p),v.add(p)}for(let[d,p]of c)v.has(d)||p.dispose();return s=l,a=i,i.map(d=>d.rendered)})},void 0,{name:"keyArray"})}function tr(e,n,r){let t=[];return y(()=>{for(let s of t)s.dispose();t=[]}),x(()=>{let s=e()||[];return b(()=>{if(s.length===0){for(let i of t)i.dispose();return t=[],r?.fallback?r.fallback():[]}let a=t.length,u=s.length;for(let i=a;i<u;i++){let l,v,d,p=s[i];I(h=>{d=h;let[g,T]=f(p);v=T,l=n(g,i)}),t.push({rendered:l,setItem:v,dispose:d})}for(let i=u;i<a;i++)t[i].dispose();u<a&&(t=t.slice(0,u));let c=Math.min(a,u);for(let i=0;i<c;i++)t[i].setItem(s[i]);return t.map(i=>i.rendered)})},void 0,{name:"indexArray"})}var ln=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,ue=typeof process>"u"?ln:!1,fn=Symbol.for("signal"),pn=Symbol.for("memo"),vn=Symbol.for("resource");function ae(e){return typeof e=="function"&&e[fn]===!0}function hn(e){return typeof e=="function"&&e[pn]===!0}function mn(e){return typeof e=="function"&&e[vn]===!0}function yn(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Tn(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function wn(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function je(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?je(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var ce=null;function xn(e){ce=e}function pe(e){ce&&ce(e)}var de=null;function bn(e){de=e}function ve(e){return de?de(e):void 0}var le=null;function gn(e){le=e}function he(){return le?le():void 0}var fe=null;function Sn(e){fe=e}function me(e,n){fe&&fe(e,n)}function Rn(e,n=(r,t)=>r===t){let r=new Map;return k(()=>{let t=e();for(let[s,a]of r){let[u,c]=a,i=n(s,t);u()!==i&&c(i)}}),t=>{let s=r.get(t);if(!s){let[a,u]=f(!1);s=[a,u],r.set(t,s);let c=e();u(n(t,c))}return s[0]()}}function kn(e,n){let[r,t]=f(e(),n);return k(()=>{let s=e();n?.timeoutMs?setTimeout(()=>t(()=>s),n.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>t(()=>s)):Promise.resolve().then(()=>t(()=>s))}),r}function On(e,n){let r,t=(...s)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,e(...s)},n)};return y(()=>{r!==void 0&&clearTimeout(r)}),t}function _n(e){return!!e&&typeof e.then=="function"}var ye=Symbol();function z(e,n,r={}){let t,s;typeof n=="function"?(t=typeof e=="function"?e:()=>e,s=n):(t=()=>!0,s=e,n&&typeof n=="object"&&(r=n));let a=r.transport===!1?void 0:he(),u=a!==void 0?ve(a):void 0,c=u!==void 0,[i,l]=f(u!==void 0?u.value:r.initialValue,{equals:!1}),[v,d]=f(void 0,{equals:!1}),[p,h]=f(u!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[g,T]=f(void 0,{equals:!1}),[A,q]=f(void 0,{equals:!1}),_=ye,N=!1;k(()=>{let w=t();if(A(),w===!1||w===null||w===void 0){_=ye,O(()=>{h("unresolved"),T(void 0),d(void 0)});return}let S=N;if(N=!1,_!==ye&&w===_&&!S)return;if(_=w,c){c=!1;return}let Y=!1;y(()=>Y=!0);let we=b(p),Le=b(i),xe=we==="ready"||we==="refreshing";O(()=>{h(xe?"refreshing":"pending"),d(void 0)});try{let C=s(w,{value:Le,refetching:xe});_n(C)?(T(C),pe(C),C.then(X=>{Y||(a!==void 0&&me(a,X),O(()=>{l(()=>X),h("ready"),T(void 0)}))},X=>{Y||O(()=>{d(X),h("errored"),T(void 0)})})):O(()=>{l(()=>C),h("ready"),T(void 0)})}catch(C){if(Y)return;O(()=>{d(C),h("errored"),T(void 0)})}});let $=()=>{let w=p();return w==="pending"||w==="refreshing"},E=(()=>{let w=v();if(w)throw w;if($()){let S=g();if(S)throw S}return i()});return Object.defineProperties(E,{state:{get:p},loading:{get:$},error:{get:v},latest:{get:i}}),Object.defineProperty(E,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(E,Symbol.for("signal"),{value:!0,enumerable:!0}),[E,{mutate:l,refetch:()=>{N=!0,q(void 0)}}]}function Ve(e,n=300){let[r,t]=f(e),[s,a]=f(e),[u,c]=f(!1),i,l=()=>{i!==void 0&&(clearTimeout(i),i=void 0)},v=()=>{l();let p=b(r);return a(()=>p),c(!1),p},d=(p=>{let h=typeof p=="function"?p(b(r)):p;return t(()=>h),c(!0),l(),i=setTimeout(v,n),h});return y(l),[s,d,{immediate:r,pending:u,flush:v,cancel:()=>{l(),c(!1)}}]}function Cn(e){return e!=null&&e!==""}function An(e,n,r={}){let{delay:t=300,initialValue:s,shouldFetch:a=Cn}=r,[u,c,i]=Ve(e,t),l=()=>a(u())?u():!1,[v,{refetch:d}]=z(l,n,s===void 0?{}:{initialValue:s});return[v,{...i,query:u,setQuery:c,refetch:d}]}function ne(e){if(typeof e=="function"&&!e.length){let n=e();return ae(n)?n:ne(n)}if(Array.isArray(e)){let n=[];for(let r=0;r<e.length;r++){let t=ne(e[r]);Array.isArray(t)?n.push.apply(n,t):n.push(t)}return n}return e}function En(e){let n=x(e);return ue?x(()=>ne(n()),void 0,{name:"children"}):x(()=>ne(n()))}var Te=L();Pe((e,n)=>{let r=J(n,Te);r&&(r.increment(),e.finally(()=>r.decrement()))});function Dn(){let[e,n]=f(0),r=0;return{increment:()=>n(r+=1),decrement:()=>n(r-=1),inFallback:()=>e()>0}}function Pn(e,n){return W(Te,e,n)}var He=L();qe((e,n)=>{let r=J(n,He);return r?(r.setError(e),!0):!1});function In(){let[e,n]=f(void 0,{equals:!1});return{error:e,reset:()=>n(()=>{}),setError:t=>n(()=>t)}}function qn(e,n){return W(He,e,n)}var Nn={State:D,Computed:R,subtle:{Watcher:P,untrack:j,currentComputed:Ee,hasSinks:De}};var Or=Symbol.for("signal"),_r=Symbol.for("fluixi-proxy");function Hr(e,n){let[r,t]=f(e,n);return Object.assign(r,{set:t})}function Lr(e,n,r){return x(e,n,r)}function Wr(e,n){return k(e,n)}function Mn(...e){let[n,r]=z(...e);return Object.assign(n,r)}export{_r as $PROXY,Or as $SIGNAL,Nn as Signal,Te as SuspenseContext,ue as __DEV__,O as batch,Qe as createChildOwner,sn as createComputed,L as createContext,On as createDebounce,An as createDebouncedResource,Ve as createDebouncedSignal,kn as createDeferred,k as createEffect,In as createErrorBoundary,x as createMemo,un as createRenderEffect,z as createResource,I as createRoot,Rn as createSelector,f as createSignal,Dn as createSuspenseBoundary,Je as disposeScope,Wr as effect,cn as flush,Z as getOwner,ve as getServerData,tr as indexArray,yn as isComponent,hn as isMemo,Ze as isOwnerDisposed,wn as isProvider,mn as isResource,ae as isSignal,Tn as isSuspense,rr as keyArray,je as makeArrayFlat,nr as mapArray,Lr as memo,he as nextResourceId,Se as observeReactiveNodes,dn as on,y as onCleanup,W as provide,qn as provideErrorBoundary,Pn as provideSuspense,En as readChildren,ze as reportReactiveBinding,U as reportReactiveContext,re as reportReactiveContextCreated,Ye as reportReactiveDirective,$e as reportReactiveProps,me as reportResourceData,Mn as resource,G as runWithOwner,Ne as setOwner,Sn as setResourceDataSink,gn as setResourceIdSource,xn as setResourceTracker,bn as setServerDataGetter,Hr as signal,Fe as startTransition,pe as trackResourcePromise,b as untrack,en as useContext,an as useTransition};
@@ -1 +1 @@
1
- "use strict";var E=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var $=Object.prototype.hasOwnProperty;var B=(e,r)=>{for(var t in r)E(e,t,{get:r[t],enumerable:!0})},J=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of Y(r))!$.call(e,i)&&i!==t&&E(e,i,{get:()=>r[i],enumerable:!(o=H(r,i))||o.enumerable});return e};var Q=e=>J(E({},"__esModule",{value:!0}),e);var ue={};B(ue,{indexArray:()=>ie,keyArray:()=>se,mapArray:()=>oe});module.exports=Q(ue);var X="__fluixi_signal_next_state__",Z=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},s=globalThis[X]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Z,onSuspend:null,onError:null};var R=0,U=1,T=2,S=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(s.untracked)return;let r=s.consumer;r&&((this.observers??=new Set).add(r),(r.sources??=new Set).add(this))}},g=class extends S{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(T);C(this)}}peek(){return this._value}},k=class extends S{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=T;this.sources=null;this._fn=t,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(s.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===U&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===T)break}(this.state===T||!this._initialized)&&this.recompute(),this.state=R}recompute(){if(this.sources){for(let n of this.sources)n.observers?.delete(this);this.sources.clear()}let t=s.consumer,o=s.untracked;s.consumer=this,s.untracked=!1;let i,a=!1,u;try{i=this._fn()}catch(n){a=!0,u=n,i=this._value}finally{s.consumer=t,s.untracked=o}let l=!this._initialized||this._threw!==a||(a?u!==this._error:!this._equals(this._value,i));if(this._initialized=!0,this._threw=a,this._error=u,this._value=i,l){if(this.version++,this.observers)for(let n of[...this.observers])n.markDirty(T);C(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===R;if(this.state=t,o){if(this.observers)for(let i of[...this.observers])i.markDirty(U);C(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function C(e){if(e.watchers)for(let r of[...e.watchers])r._notify(e)}function L(e){if(s.untracked)return e();s.untracked=!0;try{return e()}finally{s.untracked=!1}}function ee(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function M(e){return s.onSuspend?(s.onSuspend(e,s.owner),!0):!1}function D(){return s.owner}function P(e,r){let t=s.owner;s.owner=e;try{return r()}finally{s.owner=t}}function y(e){if(s.owner){if(s.owner.disposed){e();return}(s.owner.cleanups??=[]).push(e)}}function N(e,r=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)N(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 m(e){let r=ee(s.owner);s.owner&&(s.owner.owned??=[]).push(r);let t=s.owner;s.owner=r;try{return e(()=>N(r))}finally{s.owner=t}}function W(e){s.hostSchedule=e??(r=>{Promise.resolve().then(r)})}function z(){if(s.scheduled=!1,s.flushing)return;s.flushing=!0;let e=0;try{for(;s.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let r=s.queue;s.queue=[];for(let t of r)t.queued=!1,t.disposed||t.run()}}finally{s.flushing=!1}}function G(){s.batchDepth===0&&z()}function te(e){return!!e&&typeof e.then=="function"}W(()=>{});var j=Symbol.for("signal"),ne=Symbol.for("memo"),re=Symbol.for("signal-node");function _(e,r){let t=new g(e,{equals:r?.equals}),o=(()=>t.get()),i=(a=>{let u=typeof a=="function"?a(t.peek()):a;return t.set(u),G(),u});return Object.defineProperty(o,j,{value:!0,enumerable:!0}),Object.defineProperty(o,re,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[o,i]}function x(e,r,t){let o=r,i=D(),a=new k(()=>P(i,()=>{try{return o=e(o)}catch(l){if(te(l))return M(l),o;throw l}}),{equals:t?.equals}),u=(()=>a.get());return Object.defineProperty(u,j,{value:!0,enumerable:!0}),Object.defineProperty(u,ne,{value:!0,enumerable:!0}),u}function O(e){return L(e)}function oe(e,r,t){let o=[];return y(()=>{for(let i of o)i.dispose();o=[]}),x(()=>{let i=e()||[];return O(()=>{if(i.length===0){for(let n of o)n.dispose();return o=[],t?.fallback?t.fallback():[]}let a=new Map;for(let n of o)a.has(n.item)||a.set(n.item,n);let u=[],l=new Set;for(let n=0;n<i.length;n++){let p=i[n],d=a.get(p);if(d&&!l.has(d))d.setIndex(n),u.push(d),l.add(d);else{let c,f,h;m(w=>{h=w;let[b,q]=_(n);f=q,c=r(p,b)});let v={item:p,rendered:c,dispose:h,setIndex:f};u.push(v),l.add(v)}}for(let n of o)l.has(n)||n.dispose();return o=u,u.map(n=>n.rendered)})})}function se(e,r,t,o){let i=[],a=[];return y(()=>{for(let u of a)u.dispose();i=[],a=[]}),x(()=>{let u=e()||[];return O(()=>{if(u.length===0){for(let c of a)c.dispose();return i=[],a=[],o?.fallback?o.fallback():[]}let l=new Map;for(let c=0;c<i.length;c++)l.set(i[c],a[c]);let n=[],p=[],d=new Set;for(let c=0;c<u.length;c++){let f=r(u[c]),h=l.get(f);if(h&&!d.has(f))h.setIndex(c),n.push(h);else{let v,w,b;m(q=>{b=q;let[I,K]=_(c);w=K;let V=x(F=>{let A=(e()||[])[I()];return A??F},u[c]);v=t(V,I)}),n.push({rendered:v,dispose:b,setIndex:w})}p.push(f),d.add(f)}for(let[c,f]of l)d.has(c)||f.dispose();return i=p,a=n,n.map(c=>c.rendered)})})}function ie(e,r,t){let o=[];return y(()=>{for(let i of o)i.dispose();o=[]}),x(()=>{let i=e()||[];return O(()=>{if(i.length===0){for(let n of o)n.dispose();return o=[],t?.fallback?t.fallback():[]}let a=o.length,u=i.length;for(let n=a;n<u;n++){let p,d,c,f=i[n];m(h=>{c=h;let[v,w]=_(f);d=w,p=r(v,n)}),o.push({rendered:p,setItem:d,dispose:c})}for(let n=u;n<a;n++)o[n].dispose();u<a&&(o=o.slice(0,u));let l=Math.min(a,u);for(let n=0;n<l;n++)o[n].setItem(i[n]);return o.map(n=>n.rendered)})})}
1
+ "use strict";var A=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var oe=Object.prototype.hasOwnProperty;var se=(e,r)=>{for(var n in r)A(e,n,{get:r[n],enumerable:!0})},ie=(e,r,n,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of re(r))!oe.call(e,i)&&i!==n&&A(e,i,{get:()=>r[i],enumerable:!(o=te(r,i))||o.enumerable});return e};var ue=e=>ie(A({},"__esModule",{value:!0}),e);var be={};se(be,{indexArray:()=>ye,keyArray:()=>me,mapArray:()=>Te});module.exports=ue(be);var ae="__fluixi_signal_next_state__",ce=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},t=globalThis[ae]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:ce,onSuspend:null,onError:null,observer:null};var M="1.0.0-alpha.83";function de(e){return t.observer=e,()=>{t.observer===e&&(t.observer=null)}}var E=[],le;function q(e){let r=t.observer;r&&r.created(e.parents===void 0?{...e,parents:E,origin:e.origin??le}:e)}function V(e){return t.observer?(E.push(e),!0):!1}function W(){E.pop()}function j(e){t.observer?.ran?.(e)}function G(e,r){t.observer?.wrote?.(e,r)}function D(e){t.observer?.disposed?.(e)}var fe="__FLUIXI_DEVTOOLS_HOOK__",K=globalThis[fe];if(typeof K?.inject=="function")try{K.inject({observeReactiveNodes:de,version:M})}catch{}function N(){return t.observer!=null}var H=0,z=1,m=2,k=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(t.untracked)return;let r=t.consumer;r&&((this.observers??=new Set).add(r),(r.sources??=new Set).add(this))}},g=class extends k{constructor(r,n){super(),this._value=r,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){return this.track(),this._value}set(r){if(!this._equals(this._value,r)){if(this._value=r,this.version++,G(this,t.consumer),this.observers)for(let n of[...this.observers])n.markDirty(m);I(this)}}peek(){return this._value}},S=class extends k{constructor(n,o){super();this._threw=!1;this._initialized=!1;this.state=m;this.sources=null;this._fn=n,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(t.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===z&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===m)break}(this.state===m||!this._initialized)&&this.recompute(),this.state=H}recompute(){if(this.sources){for(let l of this.sources)l.observers?.delete(this);this.sources.clear()}let n=t.consumer,o=t.untracked,i=V(this);t.consumer=this,t.untracked=!1;let a,u=!1,d;try{a=this._fn()}catch(l){u=!0,d=l,a=this._value}finally{t.consumer=n,t.untracked=o,i&&W()}let s=!this._initialized||this._threw!==u||(u?d!==this._error:!this._equals(this._value,a));if(this._initialized=!0,this._threw=u,this._error=d,this._value=a,j(this),s){if(this.version++,this.observers)for(let l of[...this.observers])l.markDirty(m);I(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===H;if(this.state=n,o){if(this.observers)for(let i of[...this.observers])i.markDirty(z);I(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function I(e){if(e.watchers)for(let r of[...e.watchers])r._notify(e)}function F(e){if(t.untracked)return e();t.untracked=!0;try{return e()}finally{t.untracked=!1}}function pe(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function B(e){return t.onSuspend?(t.onSuspend(e,t.owner),!0):!1}function P(){return t.owner}function U(e,r){let n=t.owner;t.owner=e;try{return r()}finally{t.owner=n}}function h(e){if(t.owner){if(t.owner.disposed){e();return}(t.owner.cleanups??=[]).push(e)}}function Y(e,r=!0){if(!e.disposed){if(e.owned){for(let n=e.owned.length-1;n>=0;n--)Y(e.owned[n]);e.owned=null}if(e.cleanups){for(let n=e.cleanups.length-1;n>=0;n--)e.cleanups[n]();e.cleanups=null}r&&(e.disposed=!0)}}function y(e){let r=pe(t.owner);t.owner&&(t.owner.owned??=[]).push(r);let n=t.owner;t.owner=r;try{return e(()=>Y(r))}finally{t.owner=n}}function $(e){t.hostSchedule=e??(r=>{Promise.resolve().then(r)})}function X(){if(t.scheduled=!1,t.flushing)return;t.flushing=!0;let e=0;try{for(;t.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let r=t.queue;t.queue=[];for(let n of r)n.queued=!1,n.disposed||n.run()}}finally{t.flushing=!1}}function J(){t.batchDepth===0&&X()}function ve(e){return!!e&&typeof e.then=="function"}$(()=>{});var Q=Symbol.for("signal"),he=Symbol.for("memo"),we=Symbol.for("signal-node");function O(e,r){let n=new g(e,{equals:r?.equals}),o=(()=>n.get()),i=(a=>{let u=typeof a=="function"?a(n.peek()):a;return n.set(u),J(),u});return Object.defineProperty(o,Q,{value:!0,enumerable:!0}),Object.defineProperty(o,we,{value:{get value(){return n.peek()},get version(){return n.version}},enumerable:!1}),q({kind:"signal",node:n,handle:o,name:r?.name,set:i}),N()&&h(()=>D(n)),[o,i]}function b(e,r,n){let o=r,i=P(),a=new S(()=>U(i,()=>{try{return o=e(o)}catch(d){if(ve(d))return B(d),o;throw d}}),{equals:n?.equals}),u=(()=>a.get());return Object.defineProperty(u,Q,{value:!0,enumerable:!0}),Object.defineProperty(u,he,{value:!0,enumerable:!0}),q({kind:"memo",node:a,handle:u,name:n?.name}),N()&&h(()=>D(a)),u}function R(e){return F(e)}function Te(e,r,n){let o=[];return h(()=>{for(let i of o)i.dispose();o=[]}),b(()=>{let i=e()||[];return R(()=>{if(i.length===0){for(let s of o)s.dispose();return o=[],n?.fallback?n.fallback():[]}let a=new Map;for(let s of o)a.has(s.item)||a.set(s.item,s);let u=[],d=new Set;for(let s=0;s<i.length;s++){let l=i[s],f=a.get(l);if(f&&!d.has(f))f.setIndex(s),u.push(f),d.add(f);else{let c,p,v;y(T=>{v=T;let[x,_]=O(s,{name:"row index"});p=_,c=r(l,x)});let w={item:l,rendered:c,dispose:v,setIndex:p};u.push(w),d.add(w)}}for(let s of o)d.has(s)||s.dispose();return o=u,u.map(s=>s.rendered)})},void 0,{name:"mapArray"})}function me(e,r,n,o){let i=[],a=[];return h(()=>{for(let u of a)u.dispose();i=[],a=[]}),b(()=>{let u=e()||[];return R(()=>{if(u.length===0){for(let c of a)c.dispose();return i=[],a=[],o?.fallback?o.fallback():[]}let d=new Map;for(let c=0;c<i.length;c++)d.set(i[c],a[c]);let s=[],l=[],f=new Set;for(let c=0;c<u.length;c++){let p=r(u[c]),v=d.get(p);if(v&&!f.has(p))v.setIndex(c),s.push(v);else{let w,T,x;y(_=>{x=_;let[L,Z]=O(c,{name:"row index"});T=Z;let ee=b(ne=>{let C=(e()||[])[L()];return C??ne},u[c]);w=n(ee,L)}),s.push({rendered:w,dispose:x,setIndex:T})}l.push(p),f.add(p)}for(let[c,p]of d)f.has(c)||p.dispose();return i=l,a=s,s.map(c=>c.rendered)})},void 0,{name:"keyArray"})}function ye(e,r,n){let o=[];return h(()=>{for(let i of o)i.dispose();o=[]}),b(()=>{let i=e()||[];return R(()=>{if(i.length===0){for(let s of o)s.dispose();return o=[],n?.fallback?n.fallback():[]}let a=o.length,u=i.length;for(let s=a;s<u;s++){let l,f,c,p=i[s];y(v=>{c=v;let[w,T]=O(p);f=T,l=r(w,s)}),o.push({rendered:l,setItem:f,dispose:c})}for(let s=u;s<a;s++)o[s].dispose();u<a&&(o=o.slice(0,u));let d=Math.min(a,u);for(let s=0;s<d;s++)o[s].setItem(i[s]);return o.map(s=>s.rendered)})},void 0,{name:"indexArray"})}
@@ -46,7 +46,7 @@ export function mapArray(list, mapFn, options) {
46
46
  let rendered, setIndex, dispose;
47
47
  createRoot((d) => {
48
48
  dispose = d;
49
- const [index, setIdx] = createSignal(i);
49
+ const [index, setIdx] = createSignal(i, { name: 'row index' });
50
50
  setIndex = setIdx;
51
51
  rendered = mapFn(value, index);
52
52
  });
@@ -61,7 +61,7 @@ export function mapArray(list, mapFn, options) {
61
61
  items = result;
62
62
  return result.map((e) => e.rendered);
63
63
  });
64
- });
64
+ }, undefined, { name: 'mapArray' });
65
65
  }
66
66
  /**
67
67
  * Key-function map. Like `mapArray` but reuse is keyed by `keyFn(item)` (so the
@@ -101,7 +101,7 @@ export function keyArray(list, keyFn, mapFn, options) {
101
101
  let rendered, setIndex, dispose;
102
102
  createRoot((d) => {
103
103
  dispose = d;
104
- const [index, setIdx] = createSignal(i);
104
+ const [index, setIdx] = createSignal(i, { name: 'row index' });
105
105
  setIndex = setIdx;
106
106
  // Live accessor: reads the current list at this index. Falls back to the
107
107
  // last known value while the array is mid-shrink (idx out of bounds)
@@ -125,7 +125,7 @@ export function keyArray(list, keyFn, mapFn, options) {
125
125
  entries = resultEntries;
126
126
  return resultEntries.map((e) => e.rendered);
127
127
  });
128
- });
128
+ }, undefined, { name: 'keyArray' });
129
129
  }
130
130
  /**
131
131
  * Index-keyed map. Reuse is keyed by *position*: growing adds slots, shrinking
@@ -168,5 +168,5 @@ export function indexArray(list, mapFn, options) {
168
168
  slots[i].setItem(next[i]);
169
169
  return slots.map((s) => s.rendered);
170
170
  });
171
- });
171
+ }, undefined, { name: 'indexArray' });
172
172
  }
@@ -1 +1 @@
1
- var F="__fluixi_signal_next_state__",H=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[F]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:H,onSuspend:null,onError:null};var I=0,R=1,T=2,S=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(r.untracked)return;let s=r.consumer;s&&((this.observers??=new Set).add(s),(s.sources??=new Set).add(this))}},g=class extends S{constructor(s,t){super(),this._value=s,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(s){if(!this._equals(this._value,s)){if(this._value=s,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(T);E(this)}}peek(){return this._value}},k=class extends S{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=T;this.sources=null;this._fn=t,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(r.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===R&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===T)break}(this.state===T||!this._initialized)&&this.recompute(),this.state=I}recompute(){if(this.sources){for(let n of this.sources)n.observers?.delete(this);this.sources.clear()}let t=r.consumer,o=r.untracked;r.consumer=this,r.untracked=!1;let i,a=!1,u;try{i=this._fn()}catch(n){a=!0,u=n,i=this._value}finally{r.consumer=t,r.untracked=o}let l=!this._initialized||this._threw!==a||(a?u!==this._error:!this._equals(this._value,i));if(this._initialized=!0,this._threw=a,this._error=u,this._value=i,l){if(this.version++,this.observers)for(let n of[...this.observers])n.markDirty(T);E(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===I;if(this.state=t,o){if(this.observers)for(let i of[...this.observers])i.markDirty(R);E(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function E(e){if(e.watchers)for(let s of[...e.watchers])s._notify(e)}function U(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function Y(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function L(e){return r.onSuspend?(r.onSuspend(e,r.owner),!0):!1}function C(){return r.owner}function D(e,s){let t=r.owner;r.owner=e;try{return s()}finally{r.owner=t}}function y(e){if(r.owner){if(r.owner.disposed){e();return}(r.owner.cleanups??=[]).push(e)}}function M(e,s=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)M(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}s&&(e.disposed=!0)}}function m(e){let s=Y(r.owner);r.owner&&(r.owner.owned??=[]).push(s);let t=r.owner;r.owner=s;try{return e(()=>M(s))}finally{r.owner=t}}function N(e){r.hostSchedule=e??(s=>{Promise.resolve().then(s)})}function W(){if(r.scheduled=!1,r.flushing)return;r.flushing=!0;let e=0;try{for(;r.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let s=r.queue;r.queue=[];for(let t of s)t.queued=!1,t.disposed||t.run()}}finally{r.flushing=!1}}function z(){r.batchDepth===0&&W()}function $(e){return!!e&&typeof e.then=="function"}N(()=>{});var G=Symbol.for("signal"),B=Symbol.for("memo"),J=Symbol.for("signal-node");function _(e,s){let t=new g(e,{equals:s?.equals}),o=(()=>t.get()),i=(a=>{let u=typeof a=="function"?a(t.peek()):a;return t.set(u),z(),u});return Object.defineProperty(o,G,{value:!0,enumerable:!0}),Object.defineProperty(o,J,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[o,i]}function x(e,s,t){let o=s,i=C(),a=new k(()=>D(i,()=>{try{return o=e(o)}catch(l){if($(l))return L(l),o;throw l}}),{equals:t?.equals}),u=(()=>a.get());return Object.defineProperty(u,G,{value:!0,enumerable:!0}),Object.defineProperty(u,B,{value:!0,enumerable:!0}),u}function O(e){return U(e)}function de(e,s,t){let o=[];return y(()=>{for(let i of o)i.dispose();o=[]}),x(()=>{let i=e()||[];return O(()=>{if(i.length===0){for(let n of o)n.dispose();return o=[],t?.fallback?t.fallback():[]}let a=new Map;for(let n of o)a.has(n.item)||a.set(n.item,n);let u=[],l=new Set;for(let n=0;n<i.length;n++){let p=i[n],d=a.get(p);if(d&&!l.has(d))d.setIndex(n),u.push(d),l.add(d);else{let c,f,h;m(w=>{h=w;let[b,q]=_(n);f=q,c=s(p,b)});let v={item:p,rendered:c,dispose:h,setIndex:f};u.push(v),l.add(v)}}for(let n of o)l.has(n)||n.dispose();return o=u,u.map(n=>n.rendered)})})}function fe(e,s,t,o){let i=[],a=[];return y(()=>{for(let u of a)u.dispose();i=[],a=[]}),x(()=>{let u=e()||[];return O(()=>{if(u.length===0){for(let c of a)c.dispose();return i=[],a=[],o?.fallback?o.fallback():[]}let l=new Map;for(let c=0;c<i.length;c++)l.set(i[c],a[c]);let n=[],p=[],d=new Set;for(let c=0;c<u.length;c++){let f=s(u[c]),h=l.get(f);if(h&&!d.has(f))h.setIndex(c),n.push(h);else{let v,w,b;m(q=>{b=q;let[P,j]=_(c);w=j;let K=x(V=>{let A=(e()||[])[P()];return A??V},u[c]);v=t(K,P)}),n.push({rendered:v,dispose:b,setIndex:w})}p.push(f),d.add(f)}for(let[c,f]of l)d.has(c)||f.dispose();return i=p,a=n,n.map(c=>c.rendered)})})}function pe(e,s,t){let o=[];return y(()=>{for(let i of o)i.dispose();o=[]}),x(()=>{let i=e()||[];return O(()=>{if(i.length===0){for(let n of o)n.dispose();return o=[],t?.fallback?t.fallback():[]}let a=o.length,u=i.length;for(let n=a;n<u;n++){let p,d,c,f=i[n];m(h=>{c=h;let[v,w]=_(f);d=w,p=s(v,n)}),o.push({rendered:p,setItem:d,dispose:c})}for(let n=u;n<a;n++)o[n].dispose();u<a&&(o=o.slice(0,u));let l=Math.min(a,u);for(let n=0;n<l;n++)o[n].setItem(i[n]);return o.map(n=>n.rendered)})})}export{pe as indexArray,fe as keyArray,de as mapArray};
1
+ var ne="__fluixi_signal_next_state__",te=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},n=globalThis[ne]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:te,onSuspend:null,onError:null,observer:null};var L="1.0.0-alpha.83";function re(e){return n.observer=e,()=>{n.observer===e&&(n.observer=null)}}var A=[],oe;function E(e){let o=n.observer;o&&o.created(e.parents===void 0?{...e,parents:A,origin:e.origin??oe}:e)}function K(e){return n.observer?(A.push(e),!0):!1}function V(){A.pop()}function W(e){n.observer?.ran?.(e)}function j(e,o){n.observer?.wrote?.(e,o)}function q(e){n.observer?.disposed?.(e)}var se="__FLUIXI_DEVTOOLS_HOOK__",M=globalThis[se];if(typeof M?.inject=="function")try{M.inject({observeReactiveNodes:re,version:L})}catch{}function D(){return n.observer!=null}var G=0,H=1,m=2,k=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(n.untracked)return;let o=n.consumer;o&&((this.observers??=new Set).add(o),(o.sources??=new Set).add(this))}},g=class extends k{constructor(o,t){super(),this._value=o,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(o){if(!this._equals(this._value,o)){if(this._value=o,this.version++,j(this,n.consumer),this.observers)for(let t of[...this.observers])t.markDirty(m);N(this)}}peek(){return this._value}},S=class extends k{constructor(t,s){super();this._threw=!1;this._initialized=!1;this.state=m;this.sources=null;this._fn=t,this._equals=s?.equals===!1?()=>!1:s?.equals??Object.is}get(){if(n.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===H&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===m)break}(this.state===m||!this._initialized)&&this.recompute(),this.state=G}recompute(){if(this.sources){for(let l of this.sources)l.observers?.delete(this);this.sources.clear()}let t=n.consumer,s=n.untracked,a=K(this);n.consumer=this,n.untracked=!1;let u,i=!1,d;try{u=this._fn()}catch(l){i=!0,d=l,u=this._value}finally{n.consumer=t,n.untracked=s,a&&V()}let r=!this._initialized||this._threw!==i||(i?d!==this._error:!this._equals(this._value,u));if(this._initialized=!0,this._threw=i,this._error=d,this._value=u,W(this),r){if(this.version++,this.observers)for(let l of[...this.observers])l.markDirty(m);N(this)}}markDirty(t){if(this.state>=t)return;let s=this.state===G;if(this.state=t,s){if(this.observers)for(let a of[...this.observers])a.markDirty(H);N(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function N(e){if(e.watchers)for(let o of[...e.watchers])o._notify(e)}function z(e){if(n.untracked)return e();n.untracked=!0;try{return e()}finally{n.untracked=!1}}function ie(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function F(e){return n.onSuspend?(n.onSuspend(e,n.owner),!0):!1}function I(){return n.owner}function P(e,o){let t=n.owner;n.owner=e;try{return o()}finally{n.owner=t}}function h(e){if(n.owner){if(n.owner.disposed){e();return}(n.owner.cleanups??=[]).push(e)}}function B(e,o=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)B(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}o&&(e.disposed=!0)}}function y(e){let o=ie(n.owner);n.owner&&(n.owner.owned??=[]).push(o);let t=n.owner;n.owner=o;try{return e(()=>B(o))}finally{n.owner=t}}function Y(e){n.hostSchedule=e??(o=>{Promise.resolve().then(o)})}function $(){if(n.scheduled=!1,n.flushing)return;n.flushing=!0;let e=0;try{for(;n.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let o=n.queue;n.queue=[];for(let t of o)t.queued=!1,t.disposed||t.run()}}finally{n.flushing=!1}}function X(){n.batchDepth===0&&$()}function ue(e){return!!e&&typeof e.then=="function"}Y(()=>{});var J=Symbol.for("signal"),ae=Symbol.for("memo"),ce=Symbol.for("signal-node");function O(e,o){let t=new g(e,{equals:o?.equals}),s=(()=>t.get()),a=(u=>{let i=typeof u=="function"?u(t.peek()):u;return t.set(i),X(),i});return Object.defineProperty(s,J,{value:!0,enumerable:!0}),Object.defineProperty(s,ce,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),E({kind:"signal",node:t,handle:s,name:o?.name,set:a}),D()&&h(()=>q(t)),[s,a]}function b(e,o,t){let s=o,a=I(),u=new S(()=>P(a,()=>{try{return s=e(s)}catch(d){if(ue(d))return F(d),s;throw d}}),{equals:t?.equals}),i=(()=>u.get());return Object.defineProperty(i,J,{value:!0,enumerable:!0}),Object.defineProperty(i,ae,{value:!0,enumerable:!0}),E({kind:"memo",node:u,handle:i,name:t?.name}),D()&&h(()=>q(u)),i}function R(e){return z(e)}function Ee(e,o,t){let s=[];return h(()=>{for(let a of s)a.dispose();s=[]}),b(()=>{let a=e()||[];return R(()=>{if(a.length===0){for(let r of s)r.dispose();return s=[],t?.fallback?t.fallback():[]}let u=new Map;for(let r of s)u.has(r.item)||u.set(r.item,r);let i=[],d=new Set;for(let r=0;r<a.length;r++){let l=a[r],f=u.get(l);if(f&&!d.has(f))f.setIndex(r),i.push(f),d.add(f);else{let c,p,v;y(T=>{v=T;let[x,_]=O(r,{name:"row index"});p=_,c=o(l,x)});let w={item:l,rendered:c,dispose:v,setIndex:p};i.push(w),d.add(w)}}for(let r of s)d.has(r)||r.dispose();return s=i,i.map(r=>r.rendered)})},void 0,{name:"mapArray"})}function qe(e,o,t,s){let a=[],u=[];return h(()=>{for(let i of u)i.dispose();a=[],u=[]}),b(()=>{let i=e()||[];return R(()=>{if(i.length===0){for(let c of u)c.dispose();return a=[],u=[],s?.fallback?s.fallback():[]}let d=new Map;for(let c=0;c<a.length;c++)d.set(a[c],u[c]);let r=[],l=[],f=new Set;for(let c=0;c<i.length;c++){let p=o(i[c]),v=d.get(p);if(v&&!f.has(p))v.setIndex(c),r.push(v);else{let w,T,x;y(_=>{x=_;let[U,Q]=O(c,{name:"row index"});T=Q;let Z=b(ee=>{let C=(e()||[])[U()];return C??ee},i[c]);w=t(Z,U)}),r.push({rendered:w,dispose:x,setIndex:T})}l.push(p),f.add(p)}for(let[c,p]of d)f.has(c)||p.dispose();return a=l,u=r,r.map(c=>c.rendered)})},void 0,{name:"keyArray"})}function De(e,o,t){let s=[];return h(()=>{for(let a of s)a.dispose();s=[]}),b(()=>{let a=e()||[];return R(()=>{if(a.length===0){for(let r of s)r.dispose();return s=[],t?.fallback?t.fallback():[]}let u=s.length,i=a.length;for(let r=u;r<i;r++){let l,f,c,p=a[r];y(v=>{c=v;let[w,T]=O(p);f=T,l=o(w,r)}),s.push({rendered:l,setItem:f,dispose:c})}for(let r=i;r<u;r++)s[r].dispose();i<u&&(s=s.slice(0,i));let d=Math.min(u,i);for(let r=0;r<d;r++)s[r].setItem(a[r]);return s.map(r=>r.rendered)})},void 0,{name:"indexArray"})}export{De as indexArray,qe as keyArray,Ee as mapArray};
@@ -1 +1 @@
1
- "use strict";var A=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var fe=Object.prototype.hasOwnProperty;var pe=(e,t)=>{for(var n in t)A(e,n,{get:t[n],enumerable:!0})},he=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of de(t))!fe.call(e,s)&&s!==n&&A(e,s,{get:()=>t[s],enumerable:!(o=le(t,s))||o.enumerable});return e};var ve=e=>he(A({},"__esModule",{value:!0}),e);var Re={};pe(Re,{resource:()=>ke});module.exports=ve(Re);var Te="__fluixi_signal_next_state__",we=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[Te]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:we,onSuspend:null,onError:null};var F=0,K=1,v=2,k=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(r.untracked)return;let t=r.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},R=class extends k{constructor(t,n){super(),this._value=t,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let n of[...this.observers])n.markDirty(v);C(this)}}peek(){return this._value}},T=class extends k{constructor(n,o){super();this._threw=!1;this._initialized=!1;this.state=v;this.sources=null;this._fn=n,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(r.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===K&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===v)break}(this.state===v||!this._initialized)&&this.recompute(),this.state=F}recompute(){if(this.sources){for(let c of this.sources)c.observers?.delete(this);this.sources.clear()}let n=r.consumer,o=r.untracked;r.consumer=this,r.untracked=!1;let s,i=!1,a;try{s=this._fn()}catch(c){i=!0,a=c,s=this._value}finally{r.consumer=n,r.untracked=o}let w=!this._initialized||this._threw!==i||(i?a!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=i,this._error=a,this._value=s,w){if(this.version++,this.observers)for(let c of[...this.observers])c.markDirty(v);C(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===F;if(this.state=n,o){if(this.observers)for(let s of[...this.observers])s.markDirty(K);C(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function C(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var _=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let n of t)this._watched.add(n),(n.watchers??=new Set).add(this)}unwatch(...t){for(let n of t)this._watched.delete(n),n.watchers?.delete(this),this._pending.delete(n)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let n=this._pending.size===0;this._pending.add(t),n&&this._notifyFn()}};function L(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function ye(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function N(e,t){let n=r.owner;r.owner=e;try{return t()}finally{r.owner=n}}function j(e){if(r.owner){if(r.owner.disposed){e();return}(r.owner.cleanups??=[]).push(e)}}function E(e,t=!0){if(!e.disposed){if(e.owned){for(let n=e.owned.length-1;n>=0;n--)E(e.owned[n]);e.owned=null}if(e.cleanups){for(let n=e.cleanups.length-1;n>=0;n--)e.cleanups[n]();e.cleanups=null}t&&(e.disposed=!0)}}function U(e){r.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function me(e){e.queued||(e.queued=!0,r.queue.push(e),!r.scheduled&&r.batchDepth===0&&(r.scheduled=!0,r.hostSchedule(O)))}function O(){if(r.scheduled=!1,r.flushing)return;r.flushing=!0;let e=0;try{for(;r.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=r.queue;r.queue=[];for(let n of t)n.queued=!1,n.disposed||n.run()}}finally{r.flushing=!1}}function Y(){r.batchDepth===0&&O()}function $(e){r.batchDepth++;try{return e()}finally{--r.batchDepth===0&&O()}}var I=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=ye(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new T(()=>{E(this.owner,!1),N(this.owner,()=>{let n=t();typeof n=="function"&&(this.owner.cleanups??=[]).push(n)})}),this.watcher=new _(()=>me(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"&&r.onSuspend){r.onSuspend(t,this.owner);return}if(r.onError&&r.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),E(this.owner))}};function B(e){let t=new I(e);return()=>t.dispose()}U(()=>{});var Se=Symbol.for("signal");var ge=Symbol.for("signal-node");function h(e,t){let n=new R(e,{equals:t?.equals}),o=(()=>n.get()),s=(i=>{let a=typeof i=="function"?i(n.peek()):i;return n.set(a),Y(),a});return Object.defineProperty(o,Se,{value:!0,enumerable:!0}),Object.defineProperty(o,ge,{value:{get value(){return n.peek()},get version(){return n.version}},enumerable:!1}),[o,s]}function J(e,t){let n=t;return B(()=>{n=e(n)})}function d(e){return $(e)}function V(e){return L(e)}var Q=null;function te(e){Q&&Q(e)}var X=null;function ne(e){return X?X(e):void 0}var Z=null;function re(){return Z?Z():void 0}var ee=null;function oe(e,t){ee&&ee(e,t)}function xe(e){return!!e&&typeof e.then=="function"}var M=Symbol();function se(e,t,n={}){let o,s;typeof t=="function"?(o=typeof e=="function"?e:()=>e,s=t):(o=()=>!0,s=e,t&&typeof t=="object"&&(n=t));let i=n.transport===!1?void 0:re(),a=i!==void 0?ne(i):void 0,w=a!==void 0,[c,P]=h(a!==void 0?a.value:n.initialValue,{equals:!1}),[G,y]=h(void 0,{equals:!1}),[q,f]=h(a!==void 0||n.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[ie,p]=h(void 0,{equals:!1}),[ue,ae]=h(void 0,{equals:!1}),m=M,D=!1;J(()=>{let u=o();if(ue(),u===!1||u===null||u===void 0){m=M,d(()=>{f("unresolved"),p(void 0),y(void 0)});return}let S=D;if(D=!1,m!==M&&u===m&&!S)return;if(m=u,w){w=!1;return}let g=!1;j(()=>g=!0);let z=V(q),ce=V(c),H=z==="ready"||z==="refreshing";d(()=>{f(H?"refreshing":"pending"),y(void 0)});try{let l=s(u,{value:ce,refetching:H});xe(l)?(p(l),te(l),l.then(x=>{g||(i!==void 0&&oe(i,x),d(()=>{P(()=>x),f("ready"),p(void 0)}))},x=>{g||d(()=>{y(x),f("errored"),p(void 0)})})):d(()=>{P(()=>l),f("ready"),p(void 0)})}catch(l){if(g)return;d(()=>{y(l),f("errored"),p(void 0)})}});let W=()=>{let u=q();return u==="pending"||u==="refreshing"},b=(()=>{let u=G();if(u)throw u;if(W()){let S=ie();if(S)throw S}return c()});return Object.defineProperties(b,{state:{get:q},loading:{get:W},error:{get:G},latest:{get:c}}),Object.defineProperty(b,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(b,Symbol.for("signal"),{value:!0,enumerable:!0}),[b,{mutate:P,refetch:()=>{D=!0,ae(void 0)}}]}function ke(...e){let[t,n]=se(...e);return Object.assign(t,n)}
1
+ "use strict";var E=Object.defineProperty;var ye=Object.getOwnPropertyDescriptor;var ge=Object.getOwnPropertyNames;var ke=Object.prototype.hasOwnProperty;var Re=(e,n)=>{for(var t in n)E(e,t,{get:n[t],enumerable:!0})},xe=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of ge(n))!ke.call(e,s)&&s!==t&&E(e,s,{get:()=>n[s],enumerable:!(o=ye(n,s))||o.enumerable});return e};var Se=e=>xe(E({},"__esModule",{value:!0}),e);var He={};Re(He,{resource:()=>je});module.exports=Se(He);var Oe="__fluixi_signal_next_state__",_e=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[Oe]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:_e,onSuspend:null,onError:null,observer:null};var U="1.0.0-alpha.83";function Pe(e){return r.observer=e,()=>{r.observer===e&&(r.observer=null)}}var I=[],qe;function O(e){let n=r.observer;n&&n.created(e.parents===void 0?{...e,parents:I,origin:e.origin??qe}:e)}function $(e){return r.observer?(I.push(e),!0):!1}function B(){I.pop()}function X(e){r.observer?.ran?.(e)}function J(e,n){r.observer?.wrote?.(e,n)}function _(e){r.observer?.disposed?.(e)}var Ce="__FLUIXI_DEVTOOLS_HOOK__",Y=globalThis[Ce];if(typeof Y?.inject=="function")try{Y.inject({observeReactiveNodes:Pe,version:U})}catch{}function Q(){return r.observer!=null}var Z=0,ee=1,T=2,P=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(r.untracked)return;let n=r.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},q=class extends P{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,J(this,r.consumer),this.observers)for(let t of[...this.observers])t.markDirty(T);V(this)}}peek(){return this._value}},m=class extends P{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=T;this.sources=null;this._fn=t,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(r.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===ee&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===T)break}(this.state===T||!this._initialized)&&this.recompute(),this.state=Z}recompute(){if(this.sources){for(let c of this.sources)c.observers?.delete(this);this.sources.clear()}let t=r.consumer,o=r.untracked,s=$(this);r.consumer=this,r.untracked=!1;let i,u=!1,f;try{i=this._fn()}catch(c){u=!0,f=c,i=this._value}finally{r.consumer=t,r.untracked=o,s&&B()}let w=!this._initialized||this._threw!==u||(u?f!==this._error:!this._equals(this._value,i));if(this._initialized=!0,this._threw=u,this._error=f,this._value=i,X(this),w){if(this.version++,this.observers)for(let c of[...this.observers])c.markDirty(T);V(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===Z;if(this.state=t,o){if(this.observers)for(let s of[...this.observers])s.markDirty(ee);V(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function V(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var C=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function ne(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function De(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function M(e,n){let t=r.owner;r.owner=e;try{return n()}finally{r.owner=t}}function b(e){if(r.owner){if(r.owner.disposed){e();return}(r.owner.cleanups??=[]).push(e)}}function j(e,n=!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}n&&(e.disposed=!0)}}function te(e){r.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function Ne(e){e.queued||(e.queued=!0,r.queue.push(e),!r.scheduled&&r.batchDepth===0&&(r.scheduled=!0,r.hostSchedule(D)))}function D(){if(r.scheduled=!1,r.flushing)return;r.flushing=!0;let e=0;try{for(;r.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=r.queue;r.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{r.flushing=!1}}function re(){r.batchDepth===0&&D()}function oe(e){r.batchDepth++;try{return e()}finally{--r.batchDepth===0&&D()}}var H=class{constructor(n,t=!1){this.queued=!1;this.disposed=!1;this.owner=De(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new m(()=>{j(this.owner,!1),M(this.owner,()=>{let o=n();typeof o=="function"&&(this.owner.cleanups??=[]).push(o)})}),O({kind:"effect",node:this.computed,handle:this,internal:!t}),this.watcher=new C(()=>Ne(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&r.onSuspend){r.onSuspend(n,this.owner);return}if(r.onError&&r.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,_(this.computed),this.watcher.unwatch(this.computed),j(this.owner))}};function se(e,n=!1){let t=new H(e,n);return()=>t.dispose()}te(()=>{});var Ee=Symbol.for("signal");var Ie=Symbol.for("signal-node");function h(e,n){let t=new q(e,{equals:n?.equals}),o=(()=>t.get()),s=(i=>{let u=typeof i=="function"?i(t.peek()):i;return t.set(u),re(),u});return Object.defineProperty(o,Ee,{value:!0,enumerable:!0}),Object.defineProperty(o,Ie,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),O({kind:"signal",node:t,handle:o,name:n?.name,set:s}),Q()&&b(()=>_(t)),[o,s]}function ie(e,n){let t=n;return se(()=>{t=e(t)},!0)}function d(e){return oe(e)}function G(e){return ne(e)}var ue=null;function de(e){ue&&ue(e)}var ae=null;function fe(e){return ae?ae(e):void 0}var ce=null;function pe(){return ce?ce():void 0}var le=null;function ve(e,n){le&&le(e,n)}function Ve(e){return!!e&&typeof e.then=="function"}var W=Symbol();function he(e,n,t={}){let o,s;typeof n=="function"?(o=typeof e=="function"?e:()=>e,s=n):(o=()=>!0,s=e,n&&typeof n=="object"&&(t=n));let i=t.transport===!1?void 0:pe(),u=i!==void 0?fe(i):void 0,f=u!==void 0,[w,c]=h(u!==void 0?u.value:t.initialValue,{equals:!1}),[K,y]=h(void 0,{equals:!1}),[N,p]=h(u!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[we,v]=h(void 0,{equals:!1}),[Te,me]=h(void 0,{equals:!1}),g=W,A=!1;ie(()=>{let a=o();if(Te(),a===!1||a===null||a===void 0){g=W,d(()=>{p("unresolved"),v(void 0),y(void 0)});return}let R=A;if(A=!1,g!==W&&a===g&&!R)return;if(g=a,f){f=!1;return}let x=!1;b(()=>x=!0);let F=G(N),be=G(w),L=F==="ready"||F==="refreshing";d(()=>{p(L?"refreshing":"pending"),y(void 0)});try{let l=s(a,{value:be,refetching:L});Ve(l)?(v(l),de(l),l.then(S=>{x||(i!==void 0&&ve(i,S),d(()=>{c(()=>S),p("ready"),v(void 0)}))},S=>{x||d(()=>{y(S),p("errored"),v(void 0)})})):d(()=>{c(()=>l),p("ready"),v(void 0)})}catch(l){if(x)return;d(()=>{y(l),p("errored"),v(void 0)})}});let z=()=>{let a=N();return a==="pending"||a==="refreshing"},k=(()=>{let a=K();if(a)throw a;if(z()){let R=we();if(R)throw R}return w()});return Object.defineProperties(k,{state:{get:N},loading:{get:z},error:{get:K},latest:{get:w}}),Object.defineProperty(k,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(k,Symbol.for("signal"),{value:!0,enumerable:!0}),[k,{mutate:c,refetch:()=>{A=!0,me(void 0)}}]}function je(...e){let[n,t]=he(...e);return Object.assign(n,t)}
@@ -1 +1 @@
1
- var ce="__fluixi_signal_next_state__",le=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[ce]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:le,onSuspend:null,onError:null};var H=0,F=1,v=2,k=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(r.untracked)return;let t=r.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},R=class extends k{constructor(t,n){super(),this._value=t,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let n of[...this.observers])n.markDirty(v);A(this)}}peek(){return this._value}},T=class extends k{constructor(n,o){super();this._threw=!1;this._initialized=!1;this.state=v;this.sources=null;this._fn=n,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(r.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===F&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===v)break}(this.state===v||!this._initialized)&&this.recompute(),this.state=H}recompute(){if(this.sources){for(let c of this.sources)c.observers?.delete(this);this.sources.clear()}let n=r.consumer,o=r.untracked;r.consumer=this,r.untracked=!1;let i,s=!1,a;try{i=this._fn()}catch(c){s=!0,a=c,i=this._value}finally{r.consumer=n,r.untracked=o}let w=!this._initialized||this._threw!==s||(s?a!==this._error:!this._equals(this._value,i));if(this._initialized=!0,this._threw=s,this._error=a,this._value=i,w){if(this.version++,this.observers)for(let c of[...this.observers])c.markDirty(v);A(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===H;if(this.state=n,o){if(this.observers)for(let i of[...this.observers])i.markDirty(F);A(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function A(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var _=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let n of t)this._watched.add(n),(n.watchers??=new Set).add(this)}unwatch(...t){for(let n of t)this._watched.delete(n),n.watchers?.delete(this),this._pending.delete(n)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let n=this._pending.size===0;this._pending.add(t),n&&this._notifyFn()}};function K(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function de(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function I(e,t){let n=r.owner;r.owner=e;try{return t()}finally{r.owner=n}}function N(e){if(r.owner){if(r.owner.disposed){e();return}(r.owner.cleanups??=[]).push(e)}}function C(e,t=!0){if(!e.disposed){if(e.owned){for(let n=e.owned.length-1;n>=0;n--)C(e.owned[n]);e.owned=null}if(e.cleanups){for(let n=e.cleanups.length-1;n>=0;n--)e.cleanups[n]();e.cleanups=null}t&&(e.disposed=!0)}}function L(e){r.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function fe(e){e.queued||(e.queued=!0,r.queue.push(e),!r.scheduled&&r.batchDepth===0&&(r.scheduled=!0,r.hostSchedule(O)))}function O(){if(r.scheduled=!1,r.flushing)return;r.flushing=!0;let e=0;try{for(;r.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=r.queue;r.queue=[];for(let n of t)n.queued=!1,n.disposed||n.run()}}finally{r.flushing=!1}}function U(){r.batchDepth===0&&O()}function Y(e){r.batchDepth++;try{return e()}finally{--r.batchDepth===0&&O()}}var E=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=de(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new T(()=>{C(this.owner,!1),I(this.owner,()=>{let n=t();typeof n=="function"&&(this.owner.cleanups??=[]).push(n)})}),this.watcher=new _(()=>fe(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"&&r.onSuspend){r.onSuspend(t,this.owner);return}if(r.onError&&r.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),C(this.owner))}};function $(e){let t=new E(e);return()=>t.dispose()}L(()=>{});var he=Symbol.for("signal");var ve=Symbol.for("signal-node");function h(e,t){let n=new R(e,{equals:t?.equals}),o=(()=>n.get()),i=(s=>{let a=typeof s=="function"?s(n.peek()):s;return n.set(a),U(),a});return Object.defineProperty(o,he,{value:!0,enumerable:!0}),Object.defineProperty(o,ve,{value:{get value(){return n.peek()},get version(){return n.version}},enumerable:!1}),[o,i]}function B(e,t){let n=t;return $(()=>{n=e(n)})}function d(e){return Y(e)}function j(e){return K(e)}var J=null;function ee(e){J&&J(e)}var Q=null;function te(e){return Q?Q(e):void 0}var X=null;function ne(){return X?X():void 0}var Z=null;function re(e,t){Z&&Z(e,t)}function Te(e){return!!e&&typeof e.then=="function"}var V=Symbol();function oe(e,t,n={}){let o,i;typeof t=="function"?(o=typeof e=="function"?e:()=>e,i=t):(o=()=>!0,i=e,t&&typeof t=="object"&&(n=t));let s=n.transport===!1?void 0:ne(),a=s!==void 0?te(s):void 0,w=a!==void 0,[c,P]=h(a!==void 0?a.value:n.initialValue,{equals:!1}),[M,y]=h(void 0,{equals:!1}),[q,f]=h(a!==void 0||n.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[se,p]=h(void 0,{equals:!1}),[ie,ue]=h(void 0,{equals:!1}),m=V,D=!1;B(()=>{let u=o();if(ie(),u===!1||u===null||u===void 0){m=V,d(()=>{f("unresolved"),p(void 0),y(void 0)});return}let S=D;if(D=!1,m!==V&&u===m&&!S)return;if(m=u,w){w=!1;return}let g=!1;N(()=>g=!0);let W=j(q),ae=j(c),z=W==="ready"||W==="refreshing";d(()=>{f(z?"refreshing":"pending"),y(void 0)});try{let l=i(u,{value:ae,refetching:z});Te(l)?(p(l),ee(l),l.then(x=>{g||(s!==void 0&&re(s,x),d(()=>{P(()=>x),f("ready"),p(void 0)}))},x=>{g||d(()=>{y(x),f("errored"),p(void 0)})})):d(()=>{P(()=>l),f("ready"),p(void 0)})}catch(l){if(g)return;d(()=>{y(l),f("errored"),p(void 0)})}});let G=()=>{let u=q();return u==="pending"||u==="refreshing"},b=(()=>{let u=M();if(u)throw u;if(G()){let S=se();if(S)throw S}return c()});return Object.defineProperties(b,{state:{get:q},loading:{get:G},error:{get:M},latest:{get:c}}),Object.defineProperty(b,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(b,Symbol.for("signal"),{value:!0,enumerable:!0}),[b,{mutate:P,refetch:()=>{D=!0,ue(void 0)}}]}function Ne(...e){let[t,n]=oe(...e);return Object.assign(t,n)}export{Ne as resource};
1
+ var be="__fluixi_signal_next_state__",ye=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[be]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:ye,onSuspend:null,onError:null,observer:null};var L="1.0.0-alpha.83";function ge(e){return r.observer=e,()=>{r.observer===e&&(r.observer=null)}}var E=[],ke;function O(e){let n=r.observer;n&&n.created(e.parents===void 0?{...e,parents:E,origin:e.origin??ke}:e)}function Y(e){return r.observer?(E.push(e),!0):!1}function $(){E.pop()}function B(e){r.observer?.ran?.(e)}function X(e,n){r.observer?.wrote?.(e,n)}function _(e){r.observer?.disposed?.(e)}var Re="__FLUIXI_DEVTOOLS_HOOK__",U=globalThis[Re];if(typeof U?.inject=="function")try{U.inject({observeReactiveNodes:ge,version:L})}catch{}function J(){return r.observer!=null}var Q=0,Z=1,T=2,P=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(r.untracked)return;let n=r.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},q=class extends P{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,X(this,r.consumer),this.observers)for(let t of[...this.observers])t.markDirty(T);I(this)}}peek(){return this._value}},m=class extends P{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=T;this.sources=null;this._fn=t,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(r.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===Z&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===T)break}(this.state===T||!this._initialized)&&this.recompute(),this.state=Q}recompute(){if(this.sources){for(let c of this.sources)c.observers?.delete(this);this.sources.clear()}let t=r.consumer,o=r.untracked,a=Y(this);r.consumer=this,r.untracked=!1;let s,i=!1,f;try{s=this._fn()}catch(c){i=!0,f=c,s=this._value}finally{r.consumer=t,r.untracked=o,a&&$()}let w=!this._initialized||this._threw!==i||(i?f!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=i,this._error=f,this._value=s,B(this),w){if(this.version++,this.observers)for(let c of[...this.observers])c.markDirty(T);I(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===Q;if(this.state=t,o){if(this.observers)for(let a of[...this.observers])a.markDirty(Z);I(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function I(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var C=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function ee(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function xe(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function H(e,n){let t=r.owner;r.owner=e;try{return n()}finally{r.owner=t}}function b(e){if(r.owner){if(r.owner.disposed){e();return}(r.owner.cleanups??=[]).push(e)}}function V(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)V(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}n&&(e.disposed=!0)}}function ne(e){r.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function Se(e){e.queued||(e.queued=!0,r.queue.push(e),!r.scheduled&&r.batchDepth===0&&(r.scheduled=!0,r.hostSchedule(D)))}function D(){if(r.scheduled=!1,r.flushing)return;r.flushing=!0;let e=0;try{for(;r.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=r.queue;r.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{r.flushing=!1}}function te(){r.batchDepth===0&&D()}function re(e){r.batchDepth++;try{return e()}finally{--r.batchDepth===0&&D()}}var j=class{constructor(n,t=!1){this.queued=!1;this.disposed=!1;this.owner=xe(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new m(()=>{V(this.owner,!1),H(this.owner,()=>{let o=n();typeof o=="function"&&(this.owner.cleanups??=[]).push(o)})}),O({kind:"effect",node:this.computed,handle:this,internal:!t}),this.watcher=new C(()=>Se(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&r.onSuspend){r.onSuspend(n,this.owner);return}if(r.onError&&r.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,_(this.computed),this.watcher.unwatch(this.computed),V(this.owner))}};function oe(e,n=!1){let t=new j(e,n);return()=>t.dispose()}ne(()=>{});var _e=Symbol.for("signal");var Pe=Symbol.for("signal-node");function h(e,n){let t=new q(e,{equals:n?.equals}),o=(()=>t.get()),a=(s=>{let i=typeof s=="function"?s(t.peek()):s;return t.set(i),te(),i});return Object.defineProperty(o,_e,{value:!0,enumerable:!0}),Object.defineProperty(o,Pe,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),O({kind:"signal",node:t,handle:o,name:n?.name,set:a}),J()&&b(()=>_(t)),[o,a]}function se(e,n){let t=n;return oe(()=>{t=e(t)},!0)}function d(e){return re(e)}function M(e){return ee(e)}var ie=null;function le(e){ie&&ie(e)}var ue=null;function de(e){return ue?ue(e):void 0}var ae=null;function fe(){return ae?ae():void 0}var ce=null;function pe(e,n){ce&&ce(e,n)}function qe(e){return!!e&&typeof e.then=="function"}var G=Symbol();function ve(e,n,t={}){let o,a;typeof n=="function"?(o=typeof e=="function"?e:()=>e,a=n):(o=()=>!0,a=e,n&&typeof n=="object"&&(t=n));let s=t.transport===!1?void 0:fe(),i=s!==void 0?de(s):void 0,f=i!==void 0,[w,c]=h(i!==void 0?i.value:t.initialValue,{equals:!1}),[W,y]=h(void 0,{equals:!1}),[N,p]=h(i!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[he,v]=h(void 0,{equals:!1}),[we,Te]=h(void 0,{equals:!1}),g=G,A=!1;se(()=>{let u=o();if(we(),u===!1||u===null||u===void 0){g=G,d(()=>{p("unresolved"),v(void 0),y(void 0)});return}let R=A;if(A=!1,g!==G&&u===g&&!R)return;if(g=u,f){f=!1;return}let x=!1;b(()=>x=!0);let z=M(N),me=M(w),F=z==="ready"||z==="refreshing";d(()=>{p(F?"refreshing":"pending"),y(void 0)});try{let l=a(u,{value:me,refetching:F});qe(l)?(v(l),le(l),l.then(S=>{x||(s!==void 0&&pe(s,S),d(()=>{c(()=>S),p("ready"),v(void 0)}))},S=>{x||d(()=>{y(S),p("errored"),v(void 0)})})):d(()=>{c(()=>l),p("ready"),v(void 0)})}catch(l){if(x)return;d(()=>{y(l),p("errored"),v(void 0)})}});let K=()=>{let u=N();return u==="pending"||u==="refreshing"},k=(()=>{let u=W();if(u)throw u;if(K()){let R=he();if(R)throw R}return w()});return Object.defineProperties(k,{state:{get:N},loading:{get:K},error:{get:W},latest:{get:w}}),Object.defineProperty(k,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(k,Symbol.for("signal"),{value:!0,enumerable:!0}),[k,{mutate:c,refetch:()=>{A=!0,Te(void 0)}}]}function rn(...e){let[n,t]=ve(...e);return Object.assign(n,t)}export{rn as resource};
@@ -1 +1 @@
1
- "use strict";var Te=Object.defineProperty;var Wn=Object.getOwnPropertyDescriptor;var zn=Object.getOwnPropertyNames;var Hn=Object.prototype.hasOwnProperty;var Yn=(e,n)=>{for(var t in n)Te(e,t,{get:n[t],enumerable:!0})},Kn=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of zn(n))!Hn.call(e,r)&&r!==t&&Te(e,r,{get:()=>n[r],enumerable:!(o=Wn(n,r))||o.enumerable});return e};var Xn=e=>Kn(Te({},"__esModule",{value:!0}),e);var yt={};Yn(yt,{$MEMO:()=>bn,$PROXY:()=>Le,$RESOURCE:()=>yn,$SIGNAL:()=>de,__DEV__:()=>K,batch:()=>R,createComputed:()=>Un,createContext:()=>he,createDebounce:()=>cn,createDeferred:()=>ln,createEffect:()=>$,createMemo:()=>On,createProvider:()=>En,createRenderEffect:()=>We,createResource:()=>Rn,createRoot:()=>_n,createSelector:()=>Ae,createSignal:()=>N,default:()=>bt,flush:()=>Pn,getOwner:()=>An,getServerData:()=>Ue,getSharedConfig:()=>ht,getSuspenseContext:()=>Nn,getSuspenseListContext:()=>In,isComponent:()=>Qe,isMemo:()=>Xe,isProvider:()=>en,isResource:()=>Je,isSignal:()=>X,isSuspense:()=>Ze,makeArrayFlat:()=>me,nextResourceId:()=>Ne,on:()=>Dn,onCleanup:()=>fe,onResolve:()=>Ln,readChildren:()=>Fe,reportResourceData:()=>Ie,resumeEffects:()=>Mn,runWithOwner:()=>Fn,setOwner:()=>pt,setResourceDataSink:()=>hn,setResourceIdSource:()=>pn,setResourceTracker:()=>fn,setScheduler:()=>Bn,setServerDataGetter:()=>dn,sharedConfig:()=>ce,startTransition:()=>$e,trackPromise:()=>jn,trackResourcePromise:()=>qe,untrack:()=>V,useContext:()=>A,useTransition:()=>kn});module.exports=Xn(yt);function be(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function Ke(e){return e==null||Array.isArray(e)||typeof e=="function"||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error?!1:typeof e=="object"}function z(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}var H=class e{constructor(n){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;n&&(this._subscriptions=[n])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:n,_subscriptions:t}=this;if(n instanceof e)n.remove(this);else if(n!==null)for(let o of n)o.remove(this);if(t){for(let o of t)if(be(o)&&!(o instanceof e))try{o()}catch(r){console.error("Error in unsubscribe function:",r)}else if(Ke(o)&&typeof o.unsubscribe=="function")try{o.unsubscribe()}catch(r){console.error("Error unsubscribing child:",r)}this._subscriptions=null}}add(n){if(!n||n===this)return this;if(n.closed)return this;let{_closed:t,_subscriptions:o}=this;if(t){if(be(n))try{n()}catch(r){console.error("Error in unsubscribe function:",r)}else if(n.unsubscribe)try{n.unsubscribe()}catch(r){console.error("Error unsubscribing:",r)}return this}return o||(this._subscriptions=[]),this._subscriptions.push(n),n instanceof e&&n._addParent(this),this}remove(n){let{_subscriptions:t}=this;if(!t)return;let o=t.indexOf(n);o!==-1&&(t.splice(o,1),n._removeParent(this))}_addParent(n){let{_parentOrParents:t}=this;t?Array.isArray(t)?t.push(n):this._parentOrParents=[t,n]:this._parentOrParents=n}_removeParent(n){let{_parentOrParents:t}=this;if(t===n)this._parentOrParents=null;else if(Array.isArray(t)){let o=t.indexOf(n);o!==-1&&(t.splice(o,1),t.length===1&&(this._parentOrParents=t[0]))}}};var ne=class extends H{constructor(t,o,r){super();this.isStopped=!1;let s;t?typeof t=="object"?s=t:s={next:t,error:o,complete:r}:s={},this.destination=s}next(t){if(!this.isStopped&&this.destination.next)try{this.destination.next(t)}catch(o){this.error(o)}}error(t){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(t)}catch(o){throw o}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())}},ye=class extends ne{constructor(t,o,r,s){super(t,o,r);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(t){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(t)}catch(o){this.error(o)}}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)}};var Y=class extends H{constructor(n){if(super(),n)this._subscribe=n;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(n,t,o){let r;n instanceof ne?r=n:r=new ye(n,t,o);let{_subscribe:s}=this;try{let l=s.call(this,r);l&&(typeof l=="function"||typeof l.unsubscribe=="function")&&r.add(l)}catch(l){r.error(l)}return r}pipe(...n){return n.length===0?this:n.reduce((t,o)=>o(t),this)}toPromise(){return new Promise((n,t)=>{let o;this.subscribe({next:r=>o=r,error:t,complete:()=>n(o)})})}};var Jn=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,K=typeof process>"u"?Jn:!1,Qn=Symbol.for("signal"),Zn=Symbol.for("memo"),et=Symbol.for("resource");function X(e){return typeof e=="function"&&e[Qn]===!0}function Xe(e){return typeof e=="function"&&e[Zn]===!0}function Je(e){return typeof e=="function"&&e[et]===!0}function Qe(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Ze(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function en(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function me(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?me(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var nt="__fluixi_signal_next_state__",tt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[nt]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:tt,onSuspend:null,onError:null};var nn=0,tn=1,J=2,te=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let n=a.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},re=class extends te{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(J);we(this)}}peek(){return this._value}},j=class extends te{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=J;this.sources=null;this._fn=t,this._equals=o?.equals===!1?()=>!1:o?.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===tn&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===J)break}(this.state===J||!this._initialized)&&this.recompute(),this.state=nn}recompute(){if(this.sources){for(let f of this.sources)f.observers?.delete(this);this.sources.clear()}let t=a.consumer,o=a.untracked;a.consumer=this,a.untracked=!1;let r,s=!1,l;try{r=this._fn()}catch(f){s=!0,l=f,r=this._value}finally{a.consumer=t,a.untracked=o}let c=!this._initialized||this._threw!==s||(s?l!==this._error:!this._equals(this._value,r));if(this._initialized=!0,this._threw=s,this._error=l,this._value=r,c){if(this.version++,this.observers)for(let f of[...this.observers])f.markDirty(J);we(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===nn;if(this.state=t,o){if(this.observers)for(let r of[...this.observers])r.markDirty(tn);we(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function we(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var oe=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function rt(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function rn(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function Se(){return a.owner}function se(e,n){let t=a.owner;a.owner=e;try{return n()}finally{a.owner=t}}function Oe(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function xe(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)xe(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}n&&(e.disposed=!0)}}function on(e){a.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function ot(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(Ce)))}function Ce(){if(a.scheduled=!1,a.flushing)return;a.flushing=!0;let e=0;try{for(;a.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=a.queue;a.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{a.flushing=!1}}function sn(){a.batchDepth===0&&Ce()}var ge=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=rt(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new j(()=>{xe(this.owner,!1),se(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new oe(()=>ot(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&a.onSuspend){a.onSuspend(n,this.owner);return}if(a.onError&&a.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),xe(this.owner))}};function un(e){let n=new ge(e);return()=>n.dispose()}function st(e){return!!e&&typeof e.then=="function"}on(()=>{});var an=Symbol.for("signal"),it=Symbol.for("memo"),ut=Symbol.for("signal-node");function _e(e,n){let t=new re(e,{equals:n?.equals}),o=(()=>t.get()),r=(s=>{let l=typeof s=="function"?s(t.peek()):s;return t.set(l),sn(),l});return Object.defineProperty(o,an,{value:!0,enumerable:!0}),Object.defineProperty(o,ut,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[o,r]}function ie(e,n,t){let o=n,r=Se(),s=new j(()=>se(r,()=>{try{return o=e(o)}catch(c){if(st(c))return rn(c),o;throw c}}),{equals:t?.equals}),l=(()=>s.get());return Object.defineProperty(l,an,{value:!0,enumerable:!0}),Object.defineProperty(l,it,{value:!0,enumerable:!0}),l}function Re(e,n){let t=n;return un(()=>{t=e(t)})}function Ae(e,n=(t,o)=>t===o){let t=new Map;return Re(()=>{let o=e();for(let[r,s]of t){let[l,c]=s,f=n(r,o);l()!==f&&c(f)}}),o=>{let r=t.get(o);if(!r){let[s,l]=_e(!1);r=[s,l],t.set(o,r);let c=e();l(n(o,c))}return r[0]()}}function ln(e,n){let[t,o]=_e(e(),n);return Re(()=>{let r=e();n?.timeoutMs?setTimeout(()=>o(()=>r),n.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>o(()=>r)):Promise.resolve().then(()=>o(()=>r))}),t}function cn(e,n){let t,o=(...r)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e(...r)},n)};return Oe(()=>{t!==void 0&&clearTimeout(t)}),o}function ue(e){if(typeof e=="function"&&!e.length){let n=e();return X(n)?n:ue(n)}if(Array.isArray(e)){let n=[];for(let t=0;t<e.length;t++){let o=ue(e[t]);Array.isArray(o)?n.push.apply(n,o):n.push(o)}return n}return e}function Fe(e){let n=ie(e);return K?ie(()=>ue(n()),void 0,{name:"children"}):ie(()=>ue(n()))}var Ee=null;function fn(e){Ee=e}function qe(e){Ee&&Ee(e)}var Pe=null;function dn(e){Pe=e}function Ue(e){return Pe?Pe(e):void 0}var ke=null;function pn(e){ke=e}function Ne(){return ke?ke():void 0}var De=null;function hn(e){De=e}function Ie(e,n){De&&De(e,n)}var de=Symbol.for("signal"),bn=Symbol.for("memo"),yn=Symbol.for("resource"),Le=Symbol("fluixi-proxy"),mn=Symbol.for("signal-node"),F=0,Q=1,P=2,E=3,u=null,d=null,i=null,ae=null,le=0,at=!1,Me=!1,G=0,lt=1e6,m=new WeakMap,g=null;var ct=null,ft=new Map,dt=0,ce={context:null,owner:null,routeData:new Map,matchedRoute:new Map};function pt(e){u=e,ce.owner=e,ce.context=e}function ht(){return ce}function vt(){return`node_${++dt}_${Date.now()}`}function Tt(e){K&&ft.set(e.id,new WeakRef(e))}function wn(e,n,t){let o={id:vt(),type:e,value:n,version:0,equals:t?.equals,name:t?.name,created:Date.now(),updated:Date.now()};return Tt(o),o}function xn(e,n){return e===n}function Ge(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}var Be=null,je=null;function gn(){if(!Be){let[e,n]=N(!1);Be=e,je=n}}function Sn(e){if(i)i.indexOf(e)===-1&&i.push(e);else if(g&&g.running&&!e.pure)g.effects.indexOf(e)===-1&&g.effects.push(e);else if(!e.pure||e.computed)Z(e);else if(e.pure&&!e.computed&&e.accessor){let n=d,t=i;d=null,i=[],e.accessor(),d=n;let o=i;if(i=t,o.length>0){let r=i;pe(o),i=r}}}function vn(e,n){for(let t=0;t<e.length;t++)n(e[t])}function N(e,n){let t=e;typeof t=="object"&&t&&Le in t&&delete t[Le];let o=wn("signal",t,{equals:n?.equals===!1?void 0:n?.equals,name:n?.name}),r=[l,c];m.set(r,new Set);let s;function l(){let f=d;if(f){f.sources?f.sources.indexOf(r)===-1&&f.sources.push(r):f.sources=[r];let p=m.get(r);p&&!p.has(f)&&p.add(f)}return t}function c(f){let p=typeof f=="function"?f(t):f,b=o.equals||xn;if(n?.equals===!1||!b(t,p)){t=p,o.value=p,o.version++,o.updated=Date.now();let k=m.get(r);if(k&&k.size>0){let D=function(h,v=!1){let q=h.state;if(!(q===E&&h===d)){if(v&&!h.pure){q===F&&(h.state=Q,at&&(i!==null&&i.indexOf(h)===-1?i.push(h):C.push(h)));return}if(!w.has(h)&&(w.add(h),h.state=P,q===F||q===Q?C.push(h):!h.pure&&i!==null&&i.indexOf(h)===-1&&i.push(h),h.pure&&h.accessor)){let O=m.get(h.accessor);O&&vn(Array.from(O),_=>D(_,!0))}}};var x=D;let S=Array.from(k),C=[],w=new Set;vn(S,D);for(let h of C)Sn(h)}}}return l.toObservable=()=>new Y(f=>{let p=!0;return $(()=>{let x=l();p?p=!1:f.next(x)})}),Object.defineProperty(l,de,{value:!0,enumerable:!0}),Object.defineProperty(l,mn,{value:o,enumerable:!1}),r}function $(e,n,t){let o={fn:e,state:P,sources:null,sourceSlots:null,owned:null,cleanups:null,owner:u,contexts:null,pure:!1,updatedAt:null};u&&(u.owned?u.owned.push(o):u.owned=[o]);let r=T&&A(T);return r&&(o.suspense=r),Ve(o,n),()=>I(o)}function Ve(e,n){if(e.sources){for(let r of e.sources){let s=m.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.owned){for(let r=0;r<e.owned.length;r++)I(e.owned[r]);e.owned=null}let t=d,o=u;if(d=e,u=e,le++,le>lt)throw le=0,d=t,u=o,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=E;let r=e.fn(n);typeof r=="function"&&(e.cleanups?e.cleanups.push(r):e.cleanups=[r]),e.state===E&&(e.state=F)}catch(r){if(z(r)){let s=T&&A(T);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Ge(r)}finally{d=t,u=o}}function Z(e){if(!(e.disposed||!e.fn||e.state===F)&&(e.state===P||e.state===Q||e.state===E)){if(e.cleanups){for(let n=0;n<e.cleanups.length;n++)e.cleanups[n]();e.cleanups=null}if(e.owned){for(let n=0;n<e.owned.length;n++)I(e.owned[n]);e.owned=null}e.renderEffect?qn(e):Ve(e,e.value)}}function I(e){if(e.disposed=!0,e.sources)for(let n of e.sources){let t=m.get(n);t&&t.delete(e)}if(e.cleanups)for(let n=0;n<e.cleanups.length;n++)e.cleanups[n]();if(e.owned)for(let n=0;n<e.owned.length;n++)I(e.owned[n]);if(e.owner&&e.owner.owned){let n=e.owner.owned.indexOf(e);n!==-1&&e.owner.owned.splice(n,1)}}function On(e,n,t){let o=wn("memo",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),r={fn:e,state:P,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:u,contexts:null,pure:!0,updatedAt:null,node:o,accessor:void 0};u&&(u.owned?u.owned.push(r):u.owned=[r]);let s=()=>{if(d&&d!==r){d.sources?d.sources.indexOf(s)===-1&&d.sources.push(s):d.sources=[s];let c=s;m.has(c)||m.set(c,new Set);let f=m.get(c);f&&f.add(d)}if(r.state!==F){if(r.sources){for(let p of r.sources){let b=m.get(p);b&&b.delete(r)}r.sources=null,r.sourceSlots=null}if(r.cleanups){for(let p=0;p<r.cleanups.length;p++)r.cleanups[p]();r.cleanups=null}if(r.owned){for(let p=0;p<r.owned.length;p++)I(r.owned[p]);r.owned=null}let c=d,f=u;d=r,u=r,r.state=E;try{let p=r.fn(r.value),b=o.equals||xn;if(t?.equals===!1||!b(r.value,p)){r.value=p,o.value=p,o.version++,o.updated=Date.now();let k=s,S=m.get(k);if(S&&S.size>0){let h=function(v,q=!1){if(v===r)return;let O=v.state;if(O!==E){if(q&&!v.pure){O===F&&(v.state=Q,i!==null&&i.indexOf(v)===-1?i.push(v):w.push(v));return}if(!D.has(v)&&(D.add(v),v.state=P,O===F||O===Q?w.push(v):!v.pure&&i!==null&&i.indexOf(v)===-1&&i.push(v),v.pure&&v.accessor)){let _=m.get(v.accessor);if(_&&_.size>0)for(let W of Array.from(_))h(W,!0)}}};var l=h;let C=Array.from(S),w=[],D=new Set;for(let v=0;v<C.length;v++)h(C[v]);for(let v of w)Sn(v)}}r.state===E&&(r.state=F)}catch(p){if(z(p)){let b=T&&A(T);if(!b&&T){let x=f;for(;x;){if(x.contexts?.has(T.id)){b=x.contexts.get(T.id);break}x=x.owner}}return b&&(b.increment(),p.finally(()=>b.decrement())),r.value}Ge(p)}finally{d=c,u=f}}return r.value};return r.accessor=s,m.set(s,new Set),s.toObservable=()=>new Y(l=>{let c=!0;return $(()=>{let p=s();c?c=!1:l.next(p)})}),Object.defineProperty(s,de,{value:!0,enumerable:!0}),Object.defineProperty(s,bn,{value:!0,enumerable:!0}),Object.defineProperty(s,mn,{value:o,enumerable:!1}),s}function pe(e){let n=[],t=[];for(let r of e)r.pure&&!r.computed&&r.accessor?n.indexOf(r)===-1&&n.push(r):(r.computed||!r.pure)&&t.indexOf(r)===-1&&t.push(r);i=[];let o=0;for(;o<n.length;){let r=n[o++],s=m.get(r.accessor);if(s&&s.size>0){let c=d;d=null,r.accessor(),d=c}let l=i.splice(0);for(let c of l)c.pure&&!c.computed&&c.accessor?n.indexOf(c)===-1&&n.push(c):(c.computed||!c.pure)&&t.indexOf(c)===-1&&t.push(c)}i=null;for(let r of t)(r.computed||!r.pure)&&Z(r)}function R(e){if(i&&G>0)return e();if(i&&G===0){let n=i,t=[];i=t,G++;let o;try{o=e()}finally{G--,i=n}let r=i;return pe(t),i=r,o}G++,i=[],ae=[];try{return e()}finally{G--,Cn()}}function Cn(){if(!Me){Me=!0,le=0;try{for(;i&&i.length>0;){let e=i;i=null,pe(e)}if(i=null,ae){let e=ae;ae=null;for(let n=0;n<e.length;n++)Z(e[n])}}finally{Me=!1}}}function _n(e){let n={owned:null,cleanups:null,contexts:null,owner:u},t=d;d=null;let o=u;u=n;try{return e(()=>{if(n.owned)for(let r=0;r<n.owned.length;r++)I(n.owned[r]);if(n.cleanups)for(let r=0;r<n.cleanups.length;r++)n.cleanups[r]()})}finally{u=o,d=t}}function V(e){let n=d;d=null;try{return e()}finally{d=n}}function fe(e){u&&(u.cleanups?u.cleanups.push(e):u.cleanups=[e])}function Rn(e,n,t={}){let o,r;typeof n=="function"?(o=typeof e=="function"?e:()=>e,r=n):(o=()=>!0,r=e,n&&typeof n=="object"&&(t=n));let{initialValue:s,name:l}=t,c=t.transport===!1?void 0:Ne(),f=c!==void 0?Ue(c):void 0,p=f!==void 0,[b,x]=N(f!==void 0?f.value:t.initialValue,{equals:!1}),[k,S]=N(void 0,{equals:!1}),[C,w]=N(f!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[D,h]=N(void 0,{equals:!1}),[v,q]=N(void 0,{equals:!1}),O=Symbol(),_=O,W=!1,Gn=y=>{if(!(typeof localStorage>"u"))try{y&&localStorage.setItem("storage",JSON.stringify({data:y,timestamp:Date.now()}))}catch(L){console.error(`Failed to save resource to cache (${l}):`,L)}},Vn=$(()=>{let y=o?o():e;if(v(),y===!1||y===null||y===void 0){_=O,R(()=>{w("unresolved"),h(void 0),S(void 0)});return}let L=W;if(W=!1,_!==O&&y===_&&!L)return;if(_=y,p){p=!1;return}let B=!1;fe(()=>B=!0);let He=V(C),$n=V(b),Ye=He==="ready"||He==="refreshing";R(()=>{w(Ye?"refreshing":"pending"),S(void 0)});try{let U=r(y,{value:$n,refetching:Ye});if(z(U)){h(U),qe(U),U.then(M=>{B||(c!==void 0&&Ie(c,M),R(()=>{x(()=>M),Gn(M),w("ready"),h(void 0)}))},M=>{B||R(()=>{S(M),w("errored"),h(void 0)})}).catch(M=>{B||R(()=>{S(M),w("errored"),h(void 0)})});let ve=T&&A(T);ve&&(ve.increment(),U.finally(()=>ve.decrement()))}else{if(B)return;R(()=>{x(()=>U),w("ready"),h(void 0)})}}catch(U){if(B)return;R(()=>{S(U),w("errored"),h(void 0)})}});fe(Vn);let ze=()=>{let y=C();return y==="pending"||y==="refreshing"},ee=(()=>{let y=k();if(y)throw y;if(ze()){let L=D();if(L)throw L}return b()});return Object.defineProperty(ee,yn,{value:!0,enumerable:!0}),Object.defineProperty(ee,de,{value:!0,enumerable:!0}),Object.defineProperties(ee,{state:{get:C},loading:{get:()=>ze()},error:{get:k},latest:{get:b}}),[ee,{mutate:x,refetch:()=>{W=!0,q(void 0)}}]}function An(){return u}function Fn(e,n){let t=u,o=d;u=e,d=null;try{return n()}finally{u=t,d=o}}function he(e){let n=Symbol("context"),t=En(n);return{id:n,Provider:t,defaultValue:e}}function En(e){return n=>{let t=u;for(;t;)t.contexts||(t.contexts=new Map),t.contexts.has(e)||t.contexts.set(e,n.value),t=t.owner;let o;return We(()=>{o=V(()=>{let r=u;return r&&(r.contexts||(r.contexts=new Map),r.contexts.set(e,n.value)),Fe(()=>n.children)})}),o}}function A(e){let n=u;for(;n;){if(n.contexts&&n.contexts.has(e.id))return n.contexts.get(e.id);n=n.owner}if(e)return e.defaultValue}function Pn(){return new Promise(e=>{queueMicrotask(()=>{Cn(),e()})})}function $e(e){if(g&&g.running)return e(),g.done;gn();let n,t=new Promise(r=>n=r),o={running:!0,effects:[],resolve:n,done:t};g=o;try{e()}finally{o.running=!1}return o.effects.length?(je(!0),Promise.resolve().then(()=>{let r=o.effects.splice(0);g=null,je(!1),r.length&&R(()=>{for(let s of r)s.state=P,Z(s)}),n()}),t):(g=null,n(),t)}function kn(){return gn(),[Be,$e]}function Dn(e,n,t){let o=t?.defer??!1,r=!0;return s=>{let l=e();return o&&r?(r=!1,s):V(()=>n(l,s))}}function We(e,n,t){let o={fn:e,state:P,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:u,contexts:null,pure:!1,updatedAt:null,renderEffect:!0};u&&(u.owned?u.owned.push(o):u.owned=[o]);let r=T&&A(T);return r&&(o.suspense=r),qn(o),()=>I(o)}function qn(e){if(e.sources){for(let r of e.sources){let s=m.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.cleanups){for(let r=0;r<e.cleanups.length;r++)e.cleanups[r]();e.cleanups=null}if(e.owned){for(let r=0;r<e.owned.length;r++)I(e.owned[r]);e.owned=null}let n=d,t=u,o=i;d=e,u=e,i===null&&(i=[]),e.state=E;try{let r=e.fn(e.value);typeof r=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(r)),e.value=r,e.state===E&&(e.state=F)}catch(r){if(z(r)){let s=T&&A(T);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Ge(r)}finally{d=n,u=t;let r=i;if(i=o,r!==o&&r&&r.length>0){let s=i;pe(r),i=s}}}function Un(e,n,t){let o={fn:e,state:P,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:u,contexts:null,pure:!0,computed:!0,updatedAt:null};u&&(u.owned?u.owned.push(o):u.owned=[o]),g&&g.running?(i||(i=[]),i.indexOf(o)===-1&&i.push(o)):i?i.indexOf(o)===-1&&i.push(o):Ve(o,n)}var T;function Nn(){return T||(T=he())}var Tn;function In(){return Tn||(Tn=he())}function Mn(e){if(!e.length)return;let n=e.slice();e.length=0;for(let t of n)t.state=P,Z(t)}function Ln(e){let n=T&&A(T);n&&n.inFallback()?$(()=>{n.inFallback()||e()}):e()}function Bn(e){ct=e}function jn(e){let n=T&&A(T);return n&&(n.increment(),e.finally(()=>n.decrement())),e}var bt={createSignal:N,createEffect:$,createMemo:On,createComputed:Un,createRoot:_n,createSelector:Ae,createResource:Rn,batch:R,untrack:V,onCleanup:fe,getOwner:An,runWithOwner:Fn,createContext:he,useContext:A,flush:Pn,startTransition:$e,useTransition:kn,isSignal:X,on:Dn,createRenderEffect:We,getSuspenseContext:Nn,getSuspenseListContext:In,resumeEffects:Mn,onResolve:Ln,setScheduler:Bn,trackPromise:jn};
1
+ "use strict";var we=Object.defineProperty;var nt=Object.getOwnPropertyDescriptor;var tt=Object.getOwnPropertyNames;var rt=Object.prototype.hasOwnProperty;var ot=(e,n)=>{for(var t in n)we(e,t,{get:n[t],enumerable:!0})},st=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of tt(n))!rt.call(e,r)&&r!==t&&we(e,r,{get:()=>n[r],enumerable:!(o=nt(n,r))||o.enumerable});return e};var it=e=>st(we({},"__esModule",{value:!0}),e);var Et={};ot(Et,{$MEMO:()=>kn,$PROXY:()=>Ge,$RESOURCE:()=>_n,$SIGNAL:()=>he,__DEV__:()=>X,batch:()=>k,createComputed:()=>Wn,createContext:()=>Te,createDebounce:()=>mn,createDeferred:()=>wn,createEffect:()=>W,createMemo:()=>qn,createProvider:()=>Bn,createRenderEffect:()=>Ye,createResource:()=>Un,createRoot:()=>In,createSelector:()=>Pe,createSignal:()=>I,default:()=>Ft,flush:()=>jn,getOwner:()=>Mn,getServerData:()=>Le,getSharedConfig:()=>kt,getSuspenseContext:()=>$n,getSuspenseListContext:()=>zn,isComponent:()=>tn,isMemo:()=>en,isProvider:()=>on,isResource:()=>nn,isSignal:()=>J,isSuspense:()=>rn,makeArrayFlat:()=>ge,nextResourceId:()=>Be,on:()=>Gn,onCleanup:()=>ve,onResolve:()=>Yn,readChildren:()=>De,reportResourceData:()=>je,resumeEffects:()=>Kn,runWithOwner:()=>Ln,setOwner:()=>Ct,setResourceDataSink:()=>On,setResourceIdSource:()=>Sn,setResourceTracker:()=>xn,setScheduler:()=>Xn,setServerDataGetter:()=>gn,sharedConfig:()=>pe,startTransition:()=>Ke,trackPromise:()=>Jn,trackResourcePromise:()=>Me,untrack:()=>H,useContext:()=>_,useTransition:()=>Vn});module.exports=it(Et);function me(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function Ze(e){return e==null||Array.isArray(e)||typeof e=="function"||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error?!1:typeof e=="object"}function z(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}var K=class e{constructor(n){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;n&&(this._subscriptions=[n])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:n,_subscriptions:t}=this;if(n instanceof e)n.remove(this);else if(n!==null)for(let o of n)o.remove(this);if(t){for(let o of t)if(me(o)&&!(o instanceof e))try{o()}catch(r){console.error("Error in unsubscribe function:",r)}else if(Ze(o)&&typeof o.unsubscribe=="function")try{o.unsubscribe()}catch(r){console.error("Error unsubscribing child:",r)}this._subscriptions=null}}add(n){if(!n||n===this)return this;if(n.closed)return this;let{_closed:t,_subscriptions:o}=this;if(t){if(me(n))try{n()}catch(r){console.error("Error in unsubscribe function:",r)}else if(n.unsubscribe)try{n.unsubscribe()}catch(r){console.error("Error unsubscribing:",r)}return this}return o||(this._subscriptions=[]),this._subscriptions.push(n),n instanceof e&&n._addParent(this),this}remove(n){let{_subscriptions:t}=this;if(!t)return;let o=t.indexOf(n);o!==-1&&(t.splice(o,1),n._removeParent(this))}_addParent(n){let{_parentOrParents:t}=this;t?Array.isArray(t)?t.push(n):this._parentOrParents=[t,n]:this._parentOrParents=n}_removeParent(n){let{_parentOrParents:t}=this;if(t===n)this._parentOrParents=null;else if(Array.isArray(t)){let o=t.indexOf(n);o!==-1&&(t.splice(o,1),t.length===1&&(this._parentOrParents=t[0]))}}};var oe=class extends K{constructor(t,o,r){super();this.isStopped=!1;let s;t?typeof t=="object"?s=t:s={next:t,error:o,complete:r}:s={},this.destination=s}next(t){if(!this.isStopped&&this.destination.next)try{this.destination.next(t)}catch(o){this.error(o)}}error(t){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(t)}catch(o){throw o}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())}},xe=class extends oe{constructor(t,o,r,s){super(t,o,r);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(t){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(t)}catch(o){this.error(o)}}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)}};var Y=class extends K{constructor(n){if(super(),n)this._subscribe=n;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(n,t,o){let r;n instanceof oe?r=n:r=new xe(n,t,o);let{_subscribe:s}=this;try{let l=s.call(this,r);l&&(typeof l=="function"||typeof l.unsubscribe=="function")&&r.add(l)}catch(l){r.error(l)}return r}pipe(...n){return n.length===0?this:n.reduce((t,o)=>o(t),this)}toPromise(){return new Promise((n,t)=>{let o;this.subscribe({next:r=>o=r,error:t,complete:()=>n(o)})})}};var ut=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,X=typeof process>"u"?ut:!1,at=Symbol.for("signal"),lt=Symbol.for("memo"),ct=Symbol.for("resource");function J(e){return typeof e=="function"&&e[at]===!0}function en(e){return typeof e=="function"&&e[lt]===!0}function nn(e){return typeof e=="function"&&e[ct]===!0}function tn(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function rn(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function on(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function ge(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?ge(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var ft="__fluixi_signal_next_state__",dt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},i=globalThis[ft]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:dt,onSuspend:null,onError:null,observer:null};var sn="1.0.0-alpha.83";function pt(e){return i.observer=e,()=>{i.observer===e&&(i.observer=null)}}var Se=[],vt;function Q(e){let n=i.observer;n&&n.created(e.parents===void 0?{...e,parents:Se,origin:e.origin??vt}:e)}function an(e){return i.observer?(Se.push(e),!0):!1}function ln(){Se.pop()}function cn(e){i.observer?.ran?.(e)}function fn(e,n){i.observer?.wrote?.(e,n)}function Z(e){i.observer?.disposed?.(e)}var ht="__FLUIXI_DEVTOOLS_HOOK__",un=globalThis[ht];if(typeof un?.inject=="function")try{un.inject({observeReactiveNodes:pt,version:sn})}catch{}function Oe(){return i.observer!=null}var dn=0,pn=1,ee=2,se=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(i.untracked)return;let n=i.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},ie=class extends se{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,fn(this,i.consumer),this.observers)for(let t of[...this.observers])t.markDirty(ee);Re(this)}}peek(){return this._value}},j=class extends se{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=ee;this.sources=null;this._fn=t,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(i.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===pn&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===ee)break}(this.state===ee||!this._initialized)&&this.recompute(),this.state=dn}recompute(){if(this.sources){for(let f of this.sources)f.observers?.delete(this);this.sources.clear()}let t=i.consumer,o=i.untracked,r=an(this);i.consumer=this,i.untracked=!1;let s,l=!1,c;try{s=this._fn()}catch(f){l=!0,c=f,s=this._value}finally{i.consumer=t,i.untracked=o,r&&ln()}let v=!this._initialized||this._threw!==l||(l?c!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=l,this._error=c,this._value=s,cn(this),v){if(this.version++,this.observers)for(let f of[...this.observers])f.markDirty(ee);Re(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===dn;if(this.state=t,o){if(this.observers)for(let r of[...this.observers])r.markDirty(pn);Re(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Re(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var ue=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function bt(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function vn(e){return i.onSuspend?(i.onSuspend(e,i.owner),!0):!1}function _e(){return i.owner}function ae(e,n){let t=i.owner;i.owner=e;try{return n()}finally{i.owner=t}}function V(e){if(i.owner){if(i.owner.disposed){e();return}(i.owner.cleanups??=[]).push(e)}}function Ce(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)Ce(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}n&&(e.disposed=!0)}}function hn(e){i.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function Tt(e){e.queued||(e.queued=!0,i.queue.push(e),!i.scheduled&&i.batchDepth===0&&(i.scheduled=!0,i.hostSchedule(Ae)))}function Ae(){if(i.scheduled=!1,i.flushing)return;i.flushing=!0;let e=0;try{for(;i.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=i.queue;i.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{i.flushing=!1}}function bn(){i.batchDepth===0&&Ae()}var ke=class{constructor(n,t=!1){this.queued=!1;this.disposed=!1;this.owner=bt(i.owner),i.owner&&(i.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new j(()=>{Ce(this.owner,!1),ae(this.owner,()=>{let o=n();typeof o=="function"&&(this.owner.cleanups??=[]).push(o)})}),Q({kind:"effect",node:this.computed,handle:this,internal:!t}),this.watcher=new ue(()=>Tt(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&i.onSuspend){i.onSuspend(n,this.owner);return}if(i.onError&&i.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,Z(this.computed),this.watcher.unwatch(this.computed),Ce(this.owner))}};function Tn(e,n=!1){let t=new ke(e,n);return()=>t.dispose()}function yt(e){return!!e&&typeof e.then=="function"}hn(()=>{});var yn=Symbol.for("signal"),wt=Symbol.for("memo"),mt=Symbol.for("signal-node");function Fe(e,n){let t=new ie(e,{equals:n?.equals}),o=(()=>t.get()),r=(s=>{let l=typeof s=="function"?s(t.peek()):s;return t.set(l),bn(),l});return Object.defineProperty(o,yn,{value:!0,enumerable:!0}),Object.defineProperty(o,mt,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),Q({kind:"signal",node:t,handle:o,name:n?.name,set:r}),Oe()&&V(()=>Z(t)),[o,r]}function le(e,n,t){let o=n,r=_e(),s=new j(()=>ae(r,()=>{try{return o=e(o)}catch(c){if(yt(c))return vn(c),o;throw c}}),{equals:t?.equals}),l=(()=>s.get());return Object.defineProperty(l,yn,{value:!0,enumerable:!0}),Object.defineProperty(l,wt,{value:!0,enumerable:!0}),Q({kind:"memo",node:s,handle:l,name:t?.name}),Oe()&&V(()=>Z(s)),l}function Ee(e,n){let t=n;return Tn(()=>{t=e(t)},!0)}function Pe(e,n=(t,o)=>t===o){let t=new Map;return Ee(()=>{let o=e();for(let[r,s]of t){let[l,c]=s,v=n(r,o);l()!==v&&c(v)}}),o=>{let r=t.get(o);if(!r){let[s,l]=Fe(!1);r=[s,l],t.set(o,r);let c=e();l(n(o,c))}return r[0]()}}function wn(e,n){let[t,o]=Fe(e(),n);return Ee(()=>{let r=e();n?.timeoutMs?setTimeout(()=>o(()=>r),n.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>o(()=>r)):Promise.resolve().then(()=>o(()=>r))}),t}function mn(e,n){let t,o=(...r)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e(...r)},n)};return V(()=>{t!==void 0&&clearTimeout(t)}),o}function ce(e){if(typeof e=="function"&&!e.length){let n=e();return J(n)?n:ce(n)}if(Array.isArray(e)){let n=[];for(let t=0;t<e.length;t++){let o=ce(e[t]);Array.isArray(o)?n.push.apply(n,o):n.push(o)}return n}return e}function De(e){let n=le(e);return X?le(()=>ce(n()),void 0,{name:"children"}):le(()=>ce(n()))}var qe=null;function xn(e){qe=e}function Me(e){qe&&qe(e)}var Ne=null;function gn(e){Ne=e}function Le(e){return Ne?Ne(e):void 0}var Ie=null;function Sn(e){Ie=e}function Be(){return Ie?Ie():void 0}var Ue=null;function On(e){Ue=e}function je(e,n){Ue&&Ue(e,n)}var he=Symbol.for("signal"),kn=Symbol.for("memo"),_n=Symbol.for("resource"),Ge=Symbol("fluixi-proxy"),An=Symbol.for("signal-node"),A=0,ne=1,E=2,F=3,a=null,d=null,u=null,fe=null,de=0,xt=!1,Ve=!1,G=0,gt=1e6,w=new WeakMap,g=null;var St=null,Ot=new Map,Rt=0,pe={context:null,owner:null,routeData:new Map,matchedRoute:new Map};function Ct(e){a=e,pe.owner=e,pe.context=e}function kt(){return pe}function _t(){return`node_${++Rt}_${Date.now()}`}function At(e){X&&Ot.set(e.id,new WeakRef(e))}function Fn(e,n,t){let o={id:_t(),type:e,value:n,version:0,equals:t?.equals,name:t?.name,created:Date.now(),updated:Date.now()};return At(o),o}function En(e,n){return e===n}function $e(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}var He=null,We=null;function Pn(){if(!He){let[e,n]=I(!1);He=e,We=n}}function Dn(e){if(u)u.indexOf(e)===-1&&u.push(e);else if(g&&g.running&&!e.pure)g.effects.indexOf(e)===-1&&g.effects.push(e);else if(!e.pure||e.computed)te(e);else if(e.pure&&!e.computed&&e.accessor){let n=d,t=u;d=null,u=[],e.accessor(),d=n;let o=u;if(u=t,o.length>0){let r=u;be(o),u=r}}}function Rn(e,n){for(let t=0;t<e.length;t++)n(e[t])}function I(e,n){let t=e;typeof t=="object"&&t&&Ge in t&&delete t[Ge];let o=Fn("signal",t,{equals:n?.equals===!1?void 0:n?.equals,name:n?.name}),r=[l,c];w.set(r,new Set);let s;function l(){let v=d;if(v){v.sources?v.sources.indexOf(r)===-1&&v.sources.push(r):v.sources=[r];let f=w.get(r);f&&!f.has(v)&&f.add(v)}return t}function c(v){let f=typeof v=="function"?v(t):v,T=o.equals||En;if(n?.equals===!1||!T(t,f)){t=f,o.value=f,o.version++,o.updated=Date.now();let P=w.get(r);if(P&&P.size>0){let D=function(p,h=!1){let q=p.state;if(!(q===F&&p===d)){if(h&&!p.pure){q===A&&(p.state=ne,xt&&(u!==null&&u.indexOf(p)===-1?u.push(p):R.push(p)));return}if(!m.has(p)&&(m.add(p),p.state=E,q===A||q===ne?R.push(p):!p.pure&&u!==null&&u.indexOf(p)===-1&&u.push(p),p.pure&&p.accessor)){let O=w.get(p.accessor);O&&Rn(Array.from(O),C=>D(C,!0))}}};var x=D;let S=Array.from(P),R=[],m=new Set;Rn(S,D);for(let p of R)Dn(p)}}}return l.toObservable=()=>new Y(v=>{let f=!0;return W(()=>{let x=l();f?f=!1:v.next(x)})}),Object.defineProperty(l,he,{value:!0,enumerable:!0}),Object.defineProperty(l,An,{value:o,enumerable:!1}),r}function W(e,n,t){let o={fn:e,state:E,sources:null,sourceSlots:null,owned:null,cleanups:null,owner:a,contexts:null,pure:!1,updatedAt:null};a&&(a.owned?a.owned.push(o):a.owned=[o]);let r=b&&_(b);return r&&(o.suspense=r),ze(o,n),()=>U(o)}function ze(e,n){if(e.sources){for(let r of e.sources){let s=w.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.owned){for(let r=0;r<e.owned.length;r++)U(e.owned[r]);e.owned=null}let t=d,o=a;if(d=e,a=e,de++,de>gt)throw de=0,d=t,a=o,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=F;let r=e.fn(n);typeof r=="function"&&(e.cleanups?e.cleanups.push(r):e.cleanups=[r]),e.state===F&&(e.state=A)}catch(r){if(z(r)){let s=b&&_(b);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}$e(r)}finally{d=t,a=o}}function te(e){if(!(e.disposed||!e.fn||e.state===A)&&(e.state===E||e.state===ne||e.state===F)){if(e.cleanups){for(let n=0;n<e.cleanups.length;n++)e.cleanups[n]();e.cleanups=null}if(e.owned){for(let n=0;n<e.owned.length;n++)U(e.owned[n]);e.owned=null}e.renderEffect?Hn(e):ze(e,e.value)}}function U(e){if(e.disposed=!0,e.sources)for(let n of e.sources){let t=w.get(n);t&&t.delete(e)}if(e.cleanups)for(let n=0;n<e.cleanups.length;n++)e.cleanups[n]();if(e.owned)for(let n=0;n<e.owned.length;n++)U(e.owned[n]);if(e.owner&&e.owner.owned){let n=e.owner.owned.indexOf(e);n!==-1&&e.owner.owned.splice(n,1)}}function qn(e,n,t){let o=Fn("memo",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),r={fn:e,state:E,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:a,contexts:null,pure:!0,updatedAt:null,node:o,accessor:void 0};a&&(a.owned?a.owned.push(r):a.owned=[r]);let s=()=>{if(d&&d!==r){d.sources?d.sources.indexOf(s)===-1&&d.sources.push(s):d.sources=[s];let c=s;w.has(c)||w.set(c,new Set);let v=w.get(c);v&&v.add(d)}if(r.state!==A){if(r.sources){for(let f of r.sources){let T=w.get(f);T&&T.delete(r)}r.sources=null,r.sourceSlots=null}if(r.cleanups){for(let f=0;f<r.cleanups.length;f++)r.cleanups[f]();r.cleanups=null}if(r.owned){for(let f=0;f<r.owned.length;f++)U(r.owned[f]);r.owned=null}let c=d,v=a;d=r,a=r,r.state=F;try{let f=r.fn(r.value),T=o.equals||En;if(t?.equals===!1||!T(r.value,f)){r.value=f,o.value=f,o.version++,o.updated=Date.now();let P=s,S=w.get(P);if(S&&S.size>0){let p=function(h,q=!1){if(h===r)return;let O=h.state;if(O!==F){if(q&&!h.pure){O===A&&(h.state=ne,u!==null&&u.indexOf(h)===-1?u.push(h):m.push(h));return}if(!D.has(h)&&(D.add(h),h.state=E,O===A||O===ne?m.push(h):!h.pure&&u!==null&&u.indexOf(h)===-1&&u.push(h),h.pure&&h.accessor)){let C=w.get(h.accessor);if(C&&C.size>0)for(let $ of Array.from(C))p($,!0)}}};var l=p;let R=Array.from(S),m=[],D=new Set;for(let h=0;h<R.length;h++)p(R[h]);for(let h of m)Dn(h)}}r.state===F&&(r.state=A)}catch(f){if(z(f)){let T=b&&_(b);if(!T&&b){let x=v;for(;x;){if(x.contexts?.has(b.id)){T=x.contexts.get(b.id);break}x=x.owner}}return T&&(T.increment(),f.finally(()=>T.decrement())),r.value}$e(f)}finally{d=c,a=v}}return r.value};return r.accessor=s,w.set(s,new Set),s.toObservable=()=>new Y(l=>{let c=!0;return W(()=>{let f=s();c?c=!1:l.next(f)})}),Object.defineProperty(s,he,{value:!0,enumerable:!0}),Object.defineProperty(s,kn,{value:!0,enumerable:!0}),Object.defineProperty(s,An,{value:o,enumerable:!1}),s}function be(e){let n=[],t=[];for(let r of e)r.pure&&!r.computed&&r.accessor?n.indexOf(r)===-1&&n.push(r):(r.computed||!r.pure)&&t.indexOf(r)===-1&&t.push(r);u=[];let o=0;for(;o<n.length;){let r=n[o++],s=w.get(r.accessor);if(s&&s.size>0){let c=d;d=null,r.accessor(),d=c}let l=u.splice(0);for(let c of l)c.pure&&!c.computed&&c.accessor?n.indexOf(c)===-1&&n.push(c):(c.computed||!c.pure)&&t.indexOf(c)===-1&&t.push(c)}u=null;for(let r of t)(r.computed||!r.pure)&&te(r)}function k(e){if(u&&G>0)return e();if(u&&G===0){let n=u,t=[];u=t,G++;let o;try{o=e()}finally{G--,u=n}let r=u;return be(t),u=r,o}G++,u=[],fe=[];try{return e()}finally{G--,Nn()}}function Nn(){if(!Ve){Ve=!0,de=0;try{for(;u&&u.length>0;){let e=u;u=null,be(e)}if(u=null,fe){let e=fe;fe=null;for(let n=0;n<e.length;n++)te(e[n])}}finally{Ve=!1}}}function In(e){let n={owned:null,cleanups:null,contexts:null,owner:a},t=d;d=null;let o=a;a=n;try{return e(()=>{if(n.owned)for(let r=0;r<n.owned.length;r++)U(n.owned[r]);if(n.cleanups)for(let r=0;r<n.cleanups.length;r++)n.cleanups[r]()})}finally{a=o,d=t}}function H(e){let n=d;d=null;try{return e()}finally{d=n}}function ve(e){a&&(a.cleanups?a.cleanups.push(e):a.cleanups=[e])}function Un(e,n,t={}){let o,r;typeof n=="function"?(o=typeof e=="function"?e:()=>e,r=n):(o=()=>!0,r=e,n&&typeof n=="object"&&(t=n));let{initialValue:s,name:l}=t,c=t.transport===!1?void 0:Be(),v=c!==void 0?Le(c):void 0,f=v!==void 0,[T,x]=I(v!==void 0?v.value:t.initialValue,{equals:!1}),[P,S]=I(void 0,{equals:!1}),[R,m]=I(v!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[D,p]=I(void 0,{equals:!1}),[h,q]=I(void 0,{equals:!1}),O=Symbol(),C=O,$=!1,Qn=y=>{if(!(typeof localStorage>"u"))try{y&&localStorage.setItem("storage",JSON.stringify({data:y,timestamp:Date.now()}))}catch(L){console.error(`Failed to save resource to cache (${l}):`,L)}},Zn=W(()=>{let y=o?o():e;if(h(),y===!1||y===null||y===void 0){C=O,k(()=>{m("unresolved"),p(void 0),S(void 0)});return}let L=$;if($=!1,C!==O&&y===C&&!L)return;if(C=y,f){f=!1;return}let B=!1;ve(()=>B=!0);let Je=H(R),et=H(T),Qe=Je==="ready"||Je==="refreshing";k(()=>{m(Qe?"refreshing":"pending"),S(void 0)});try{let N=r(y,{value:et,refetching:Qe});if(z(N)){p(N),Me(N),N.then(M=>{B||(c!==void 0&&je(c,M),k(()=>{x(()=>M),Qn(M),m("ready"),p(void 0)}))},M=>{B||k(()=>{S(M),m("errored"),p(void 0)})}).catch(M=>{B||k(()=>{S(M),m("errored"),p(void 0)})});let ye=b&&_(b);ye&&(ye.increment(),N.finally(()=>ye.decrement()))}else{if(B)return;k(()=>{x(()=>N),m("ready"),p(void 0)})}}catch(N){if(B)return;k(()=>{S(N),m("errored"),p(void 0)})}});ve(Zn);let Xe=()=>{let y=R();return y==="pending"||y==="refreshing"},re=(()=>{let y=P();if(y)throw y;if(Xe()){let L=D();if(L)throw L}return T()});return Object.defineProperty(re,_n,{value:!0,enumerable:!0}),Object.defineProperty(re,he,{value:!0,enumerable:!0}),Object.defineProperties(re,{state:{get:R},loading:{get:()=>Xe()},error:{get:P},latest:{get:T}}),[re,{mutate:x,refetch:()=>{$=!0,q(void 0)}}]}function Mn(){return a}function Ln(e,n){let t=a,o=d;a=e,d=null;try{return n()}finally{a=t,d=o}}function Te(e){let n=Symbol("context"),t=Bn(n);return{id:n,Provider:t,defaultValue:e}}function Bn(e){return n=>{let t=a;for(;t;)t.contexts||(t.contexts=new Map),t.contexts.has(e)||t.contexts.set(e,n.value),t=t.owner;let o;return Ye(()=>{o=H(()=>{let r=a;return r&&(r.contexts||(r.contexts=new Map),r.contexts.set(e,n.value)),De(()=>n.children)})}),o}}function _(e){let n=a;for(;n;){if(n.contexts&&n.contexts.has(e.id))return n.contexts.get(e.id);n=n.owner}if(e)return e.defaultValue}function jn(){return new Promise(e=>{queueMicrotask(()=>{Nn(),e()})})}function Ke(e){if(g&&g.running)return e(),g.done;Pn();let n,t=new Promise(r=>n=r),o={running:!0,effects:[],resolve:n,done:t};g=o;try{e()}finally{o.running=!1}return o.effects.length?(We(!0),Promise.resolve().then(()=>{let r=o.effects.splice(0);g=null,We(!1),r.length&&k(()=>{for(let s of r)s.state=E,te(s)}),n()}),t):(g=null,n(),t)}function Vn(){return Pn(),[He,Ke]}function Gn(e,n,t){let o=t?.defer??!1,r=!0;return s=>{let l=e();return o&&r?(r=!1,s):H(()=>n(l,s))}}function Ye(e,n,t){let o={fn:e,state:E,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:a,contexts:null,pure:!1,updatedAt:null,renderEffect:!0};a&&(a.owned?a.owned.push(o):a.owned=[o]);let r=b&&_(b);return r&&(o.suspense=r),Hn(o),()=>U(o)}function Hn(e){if(e.sources){for(let r of e.sources){let s=w.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.cleanups){for(let r=0;r<e.cleanups.length;r++)e.cleanups[r]();e.cleanups=null}if(e.owned){for(let r=0;r<e.owned.length;r++)U(e.owned[r]);e.owned=null}let n=d,t=a,o=u;d=e,a=e,u===null&&(u=[]),e.state=F;try{let r=e.fn(e.value);typeof r=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(r)),e.value=r,e.state===F&&(e.state=A)}catch(r){if(z(r)){let s=b&&_(b);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}$e(r)}finally{d=n,a=t;let r=u;if(u=o,r!==o&&r&&r.length>0){let s=u;be(r),u=s}}}function Wn(e,n,t){let o={fn:e,state:E,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:a,contexts:null,pure:!0,computed:!0,updatedAt:null};a&&(a.owned?a.owned.push(o):a.owned=[o]),g&&g.running?(u||(u=[]),u.indexOf(o)===-1&&u.push(o)):u?u.indexOf(o)===-1&&u.push(o):ze(o,n)}var b;function $n(){return b||(b=Te())}var Cn;function zn(){return Cn||(Cn=Te())}function Kn(e){if(!e.length)return;let n=e.slice();e.length=0;for(let t of n)t.state=E,te(t)}function Yn(e){let n=b&&_(b);n&&n.inFallback()?W(()=>{n.inFallback()||e()}):e()}function Xn(e){St=e}function Jn(e){let n=b&&_(b);return n&&(n.increment(),e.finally(()=>n.decrement())),e}var Ft={createSignal:I,createEffect:W,createMemo:qn,createComputed:Wn,createRoot:In,createSelector:Pe,createResource:Un,batch:k,untrack:H,onCleanup:ve,getOwner:Mn,runWithOwner:Ln,createContext:Te,useContext:_,flush:jn,startTransition:Ke,useTransition:Vn,isSignal:J,on:Gn,createRenderEffect:Ye,getSuspenseContext:$n,getSuspenseListContext:zn,resumeEffects:Kn,onResolve:Yn,setScheduler:Xn,trackPromise:Jn};