@callbag-recharge/callbag-recharge 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-UMEIL4ZR.js → chunk-6USQMC44.js} +1 -1
- package/dist/{chunk-6EGOWDWF.js → chunk-EAA5FACQ.js} +1 -1
- package/dist/{chunk-H2YDDQLL.js → chunk-IHJUJPXW.js} +1 -1
- package/dist/{chunk-6HF3HFK2.js → chunk-INFS7CH5.js} +1 -1
- package/dist/chunk-L3GEFDZW.js +1 -0
- package/dist/{chunk-WGPBJVHE.js → chunk-L4ZOHVK7.js} +1 -1
- package/dist/{chunk-3AKMJ3CZ.js → chunk-M7JN332J.js} +1 -1
- package/dist/{chunk-ULBRGC4X.js → chunk-OUR2BSRO.js} +1 -1
- package/dist/{chunk-V347V3CS.js → chunk-SHLWOWJH.js} +1 -1
- package/dist/{chunk-JR7AWDIG.js → chunk-STLQE5J6.js} +1 -1
- package/dist/{chunk-R7KF4ZVM.js → chunk-WNWP65NI.js} +1 -1
- package/dist/chunk-X575NBLE.js +1 -0
- package/dist/chunk-YN4EYHXL.js +1 -0
- package/dist/{chunk-IVMTQFPB.js → chunk-Z5DNXBGI.js} +1 -1
- package/dist/{chunk-HMTVETW3.js → chunk-ZTR6P36Q.js} +1 -1
- package/dist/compat/jotai/index.cjs +4 -4
- package/dist/compat/jotai/index.js +1 -1
- package/dist/compat/nanostores/index.cjs +1 -1
- package/dist/compat/nanostores/index.js +1 -1
- package/dist/compat/signals/index.cjs +1 -1
- package/dist/compat/signals/index.js +1 -1
- package/dist/data/index.cjs +1 -1
- package/dist/data/index.js +1 -1
- package/dist/extra/combine.cjs +1 -1
- package/dist/extra/combine.js +1 -1
- package/dist/extra/distinctUntilChanged.cjs +1 -1
- package/dist/extra/distinctUntilChanged.js +1 -1
- package/dist/extra/index.cjs +1 -1
- package/dist/extra/index.js +1 -1
- package/dist/extra/map.cjs +1 -1
- package/dist/extra/map.js +1 -1
- package/dist/extra/startWith.cjs +1 -1
- package/dist/extra/startWith.js +1 -1
- package/dist/extra/streamParse.cjs +1 -1
- package/dist/extra/streamParse.js +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.js +1 -1
- package/dist/memory/index.cjs +1 -1
- package/dist/memory/index.js +1 -1
- package/dist/orchestrate/index.cjs +7 -5
- package/dist/orchestrate/index.d.cts +372 -15
- package/dist/orchestrate/index.d.ts +372 -15
- package/dist/orchestrate/index.js +5 -3
- package/dist/patterns/createStore/index.cjs +1 -1
- package/dist/patterns/createStore/index.js +1 -1
- package/dist/patterns/formField/index.cjs +1 -1
- package/dist/patterns/formField/index.js +1 -1
- package/dist/patterns/memoryStore/index.cjs +1 -1
- package/dist/patterns/memoryStore/index.js +1 -1
- package/dist/patterns/pagination/index.cjs +1 -1
- package/dist/patterns/pagination/index.js +1 -1
- package/dist/patterns/textBuffer/index.cjs +1 -1
- package/dist/patterns/textBuffer/index.js +1 -1
- package/dist/patterns/textEditor/index.cjs +1 -1
- package/dist/patterns/textEditor/index.js +1 -1
- package/dist/patterns/undoRedo/index.cjs +1 -1
- package/dist/patterns/undoRedo/index.js +1 -1
- package/dist/{retry-CzvIREKf.d.ts → retry-j7JsjK3g.d.ts} +1 -1
- package/dist/{retry-dPqizArs.d.cts → retry-tJUoBfAI.d.cts} +1 -1
- package/dist/utils/index.cjs +4 -4
- package/dist/utils/index.d.cts +2 -2
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-CXF5XC6M.js +0 -1
- package/dist/chunk-N67ZXLEF.js +0 -1
- package/dist/chunk-TTLPYOAV.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as n}from"./chunk-
|
|
1
|
+
import{a as n}from"./chunk-X575NBLE.js";function t(...e){return n(e,()=>e.map(o=>o.get()),{kind:"combine",name:"combine"})}export{t as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as E}from"./chunk-J3QF6BR6.js";import{a as y}from"./chunk-
|
|
1
|
+
import{a as E}from"./chunk-J3QF6BR6.js";import{a as y}from"./chunk-X575NBLE.js";import{a as m}from"./chunk-P5MXN4AF.js";function k(v,u){let T=u?.sync??[],S=u?.async??[],b=u?.debounceMs??300,s=u?.name??"validation",o=[],f=m(o,{name:`${s}.syncErrors`}),l=m(o,{name:`${s}.asyncErrors`}),t=m(!1,{name:`${s}.validating`}),a=y([f,l],()=>{let e=f.get(),n=l.get();return e.length>0&&n.length>0?[...e,...n]:e.length>0?e:n.length>0?n:o},{name:`${s}.errors`}),A=y([a],()=>{let e=a.get();return e.length>0?e[0]:""},{name:`${s}.error`}),P=y([a,t],()=>a.get().length===0&&!t.get(),{name:`${s}.valid`}),i=null,c=null;function p(){i&&(i.abort(),i=null),c!==null&&(clearTimeout(c),c=null),t.set(!1)}function $(e){if(T.length===0)return o;let n=[];for(let d of T){let r=d(e);r!==!0&&r!==void 0&&n.push(r)}return n.length===0?o:n}function x(e){if(p(),S.length===0){t.set(!1),l.set(o);return}if(f.get().length>0){t.set(!1),l.set(o);return}t.set(!0);function n(){i=new AbortController;let d=i.signal;Promise.all(S.map(r=>r(e,d))).then(r=>{if(d.aborted||g)return;let V=r.filter(O=>O!==void 0);l.set(V.length===0?o:V),t.set(!1),i=null}).catch(r=>{d.aborted||g||(l.set([String(r)]),t.set(!1),i=null)})}b===0?n():c=setTimeout(()=>{c=null,n()},b)}function h(){let e=v.get(),n=$(e);f.set(n),x(e)}let M=E([v],()=>(h(),()=>p()));function C(){h()}let g=!1;function R(){g||(g=!0,p(),M())}return{error:A,errors:a,valid:P,validating:t,validate:C,dispose:R}}export{k as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as c}from"./chunk-
|
|
1
|
+
import{a as c}from"./chunk-X575NBLE.js";function f(s){let n=[],r=!1,o=!1;for(let e=0;e<s.length;e++){let t=s[e];if(o){o=!1;continue}if(t==="\\"){o=!0;continue}if(t==='"'){r=!r;continue}r||(t==="{"?n.push("}"):t==="["?n.push("]"):(t==="}"||t==="]")&&n.pop())}let a=s;r&&(a+='"');for(let e=n.length-1;e>=0;e--)a+=n[e];return a}function u(s){try{return JSON.parse(s)}catch{}let n=s.trim();if(n.length===0)return;let r=[],o=!1,a=!1;for(let t=0;t<n.length;t++){let i=n[t];if(a){a=!1;continue}if(i==="\\"){a=!0;continue}if(i==='"'){o=!o;continue}o||(i==="{"?r.push("}"):i==="["?r.push("]"):(i==="}"||i==="]")&&r.pop())}let e=n;o&&(e+='"'),e=e.replace(/,\s*$/,"");for(let t=r.length-1;t>=0;t--)e+=r[t];try{return JSON.parse(e)}catch{let t=e.replace(/,\s*"[^"]*"?\s*:?\s*[^,}\]]*$/,"");if(t!==e)try{return JSON.parse(f(t))}catch{return}return}}function p(s){let n=s?.mode??"partial",r=s?.extract,o=s?.name;return a=>{let e;return c([a],()=>{let t=a.get();if(!t||t.trim().length===0)return e;let i;if(n==="complete")try{i=JSON.parse(t)}catch{return e}else i=u(t);if(i===void 0)return e;if(r)try{return e=r(i),e}catch{return e}return e=i,e},{name:o??"streamParse"})}}export{p as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o}from"./chunk-
|
|
1
|
+
import{a as o}from"./chunk-X575NBLE.js";function n(t,e){return r=>o([r],()=>t(r.get()),{kind:"map",name:e?.name??"map",equals:e?.equals})}export{n as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as T}from"./chunk-HK7DRUNM.js";import{a as D}from"./chunk-M76W372U.js";import{a as o,b as g,c as A,d as U,e as V,f as C,g as F,h as N,i as L,j as d,k as M,l as G,m as c,n as S,o as h,p as _,t as I,u as q}from"./chunk-CWP55MPE.js";var m=1,p=2,k=4,f=8,y=16,u=32,w=64,z=U<<d,E=V<<d,P=C<<d,v=F<<d,Y=N<<d,b=L<<d,a=M,O=class{_output=null;_upstreamTalkbacks=[];_cachedValue;_flags=0;_dirtyDeps;_eqFn;_deps=[];_trackingFn;_trackedDeps=[];_trackingSet=null;get _status(){return G(this._flags)}constructor(t,s){this._trackingFn=t,this._eqFn=s?.equals,this._dirtyDeps=new T(0),this.source=this.source.bind(this),D.register(this,{kind:"dynamicDerived",...s})}_trackGet(t){return this._trackingSet.has(t)||(this._trackingSet.add(t),this._trackedDeps.push(t)),t.get()}_dispatch(t,s){let e=this._output;if(e)if(this._flags&u)for(let i of e)i(t,s);else e(t,s)}_recompute(){if(this._flags&y)return;this._flags|=y,this._trackedDeps=[],this._trackingSet=new Set;let t;try{t=this._trackingFn(s=>this._trackGet(s))}catch(s){this._trackingSet=null,this._flags&=~y,this._handleEnd(s);return}if(this._trackingSet=null,this._flags&p&&this._maybeRewire(),this._flags&=~y,this._eqFn&&this._flags&m&&this._eqFn(this._cachedValue,t)){this._flags=this._flags&~a|v,this._dispatch(_,g);return}this._cachedValue=t,this._flags=(this._flags|m)&~a|P,this._dispatch(S,this._cachedValue)}_maybeRewire(){let t=this._trackedDeps,s=this._deps;if(t.length===s.length){let n=!0;for(let l=0;l<t.length;l++)if(t[l]!==s[l]){n=!1;break}if(n)return}this._flags|=w;let e=new Set(s),i=new Set(t);for(let n=0;n<s.length;n++)if(!i.has(s[n])){let l=this._upstreamTalkbacks[n];l&&l(h)}let r=[];for(let n=0;n<t.length;n++){let l=s.indexOf(t[n]);l!==-1?r.push(this._upstreamTalkbacks[l]):r.push(null)}this._deps=t,this._upstreamTalkbacks=r,this._dirtyDeps=new T(t.length);for(let n of t)e.has(n)||D.registerEdge(n,this);for(let n=0;n<t.length;n++)e.has(t[n])||this._connectOneDep(n);this._flags&=~w}_connectOneDep(t){this._deps[t].source(c,(s,e)=>{if(s===c){this._upstreamTalkbacks[t]=e;return}this._flags&f||this._flags&w||this._handleDepSignal(t,s,e)})}_handleDepSignal(t,s,e){if(s===_)if(e===o){let i=this._dirtyDeps.empty();this._dirtyDeps.set(t),i&&(this._flags&=~k,this._flags=this._flags&~a|E,this._dispatch(_,o))}else e===g?this._dirtyDeps.test(t)&&(this._dirtyDeps.clear(t),this._dirtyDeps.empty()&&(this._flags&k?this._recompute():(this._flags=this._flags&~a|v,this._dispatch(_,g)))):this._dispatch(_,e);else s===S?this._dirtyDeps.test(t)?(this._dirtyDeps.clear(t),this._flags|=k,this._dirtyDeps.empty()&&this._recompute()):this._dirtyDeps.empty()?(this._flags=this._flags&~a|E,this._dispatch(_,o),this._recompute()):this._flags|=k:s===h&&this._handleEnd(e)}_lazyConnect(){if(!(this._flags&(p|f))){this._trackedDeps=[],this._trackingSet=new Set;try{this._cachedValue=this._trackingFn(t=>this._trackGet(t))}catch(t){this._trackingSet=null,this._trackedDeps=[],this._handleEnd(t);return}this._trackingSet=null,this._flags=(this._flags|m)&~a|P,this._deps=this._trackedDeps,this._dirtyDeps=new T(this._deps.length);for(let t of this._deps)D.registerEdge(t,this);I(),this._connectUpstream(),this._flags&f||(this._flags|=p),q()}}_connectSingleDep(){let t=!1;this._deps[0].source(c,(s,e)=>{if(s===c){this._upstreamTalkbacks.push(e),e(_,A);return}if(!(this._flags&f))if(s===_)if(e===o){if(t)return;t=!0,this._flags=this._flags&~a|E,this._dispatch(_,o)}else e===g?t&&(t=!1,this._flags=this._flags&~a|v,this._dispatch(_,g)):this._dispatch(_,e);else s===S?t?(t=!1,this._recompute()):(this._flags=this._flags&~a|E,this._dispatch(_,o),this._recompute()):s===h&&this._handleEnd(e)})}_connectUpstream(){if(this._upstreamTalkbacks.length=0,this._deps.length===1)this._connectSingleDep();else for(let t=0;t<this._deps.length&&!(this._flags&f);t++)this._connectOneDep(t)}_handleEnd(t){this._flags|=f,this._flags=this._flags&~a|(t!==void 0?b:Y),t!==void 0&&(this._cachedValue=t);for(let i of this._upstreamTalkbacks)i&&i(h);this._upstreamTalkbacks=[],this._deps=[],this._trackedDeps=[],this._flags&=~p,this._dirtyDeps.reset();let s=this._output,e=this._flags&u;if(this._output=null,this._flags&=~u,s)if(e)for(let i of s)try{t!==void 0?i(h,t):i(h)}catch{}else t!==void 0?s(h,t):s(h)}_disconnectUpstream(){for(let t of this._upstreamTalkbacks)t(h);this._upstreamTalkbacks.length=0,this._deps=[],this._trackedDeps=[],this._flags&=~(p|k),this._flags=this._flags&~a|z,this._dirtyDeps.reset()}get(){if(this._flags&p)return this._cachedValue;if(this._flags&f){if((this._flags&a)===b)throw this._cachedValue;return this._cachedValue}this._trackedDeps=[],this._trackingSet=new Set;let t;try{t=this._trackingFn(s=>this._trackGet(s))}catch(s){throw this._trackingSet=null,this._trackedDeps=[],s}return this._trackingSet=null,this._cachedValue=t,this._flags|=m,t}source(t,s){if(t===c){let e=s;if(this._flags&f){let i=(this._flags&a)===b;e(c,r=>{}),i?e(h,this._cachedValue):e(h);return}if(!(this._flags&p)&&(this._lazyConnect(),this._flags&f)){let i=(this._flags&a)===b;e(c,r=>{}),i?e(h,this._cachedValue):e(h);return}if(this._output===null)this._output=e;else if(this._flags&u)this._output.add(e);else{let i=new Set;i.add(this._output),i.add(e),this._output=i,this._flags|=u}e(c,i=>{if(i===S&&e(S,this._cachedValue),i===h){if(this._output===null)return;if(this._flags&u){let r=this._output;r.delete(e),r.size===1?(this._output=r.values().next().value,this._flags&=~u):r.size===0&&(this._output=null,this._flags&=~u,this._disconnectUpstream())}else this._output===e&&(this._output=null,this._disconnectUpstream())}})}}};function W(R,t){return new O(R,t)}export{W as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as H}from"./chunk-
|
|
1
|
+
import{a as H}from"./chunk-OUR2BSRO.js";import{a as F}from"./chunk-M7JN332J.js";import{a as b}from"./chunk-X575NBLE.js";import{a as L}from"./chunk-P5MXN4AF.js";import{q as m}from"./chunk-CWP55MPE.js";function U(i){let c=i?.mode??"range",u=i?.name??"selection",g=i?.length,r=L(0,{name:`${u}.start`}),t=L(0,{name:`${u}.end`});function M(){return g==null?Number.MAX_SAFE_INTEGER:typeof g=="number"?g:g.get()}function p(o){let d=M();return o<0?0:o>d?d:o}let l=b([r,t],()=>r.get()===t.get(),{name:`${u}.collapsed`}),T=b([r,t],()=>Math.abs(t.get()-r.get()),{name:`${u}.size`}),k=b([r,t],()=>{let o=r.get(),d=t.get();return o===d?"none":d>o?"forward":"backward"},{name:`${u}.direction`}),f=!1;function w(o,d){if(f)return;let v=p(o),A=c==="single"?v:p(d);m(()=>{r.set(v),t.set(A)})}function y(o){if(f)return;let d=p(o);m(()=>{r.set(d),t.set(d)})}function S(){if(f)return;let o=p(Math.min(r.get(),t.get()));m(()=>{r.set(o),t.set(o)})}function R(){if(f)return;let o=p(Math.max(r.get(),t.get()));m(()=>{r.set(o),t.set(o)})}function C(o){f||c!=="single"&&t.set(p(t.get()+o))}function E(){if(f)return;if(c==="single"){y(0);return}let o=M();m(()=>{r.set(0),t.set(o===Number.MAX_SAFE_INTEGER?0:o)})}function B(o){if(f)return;let d=t.get(),v=p(d+o);m(()=>{r.set(v),t.set(v)})}function $(){f||(f=!0)}return{start:r,end:t,collapsed:l,size:T,direction:k,select:w,collapse:y,collapseToStart:S,collapseToEnd:R,extend:C,selectAll:E,moveCursor:B,dispose:$}}function P(i,c,u){return(u?u(i.text,c.text):i.text===c.text)&&i.start===c.start&&i.end===c.end}function G(i){let c=i.text.length,u=Math.max(0,Math.min(i.start,c)),g=Math.max(0,Math.min(i.end,c));return{start:u,end:g}}function te(i="",c){let u=c?.name??"textBuffer",g={text:i,start:i.length,end:i.length},r=H(g,{maxHistory:c?.maxHistory??100,equals:(e,n)=>P(e,n,c?.equals)}),t=b([r.current],()=>r.current.get().text,{name:`${u}.content`}),M=b([t],()=>t.get().length,{name:`${u}.charCount`}),p=b([t],()=>Math.max(1,t.get().split(`
|
|
2
2
|
`).length),{name:`${u}.lineCount`}),l=U({mode:"range",length:M,name:`${u}.cursor`});l.collapse(i.length);let T=F(t,i,{equals:c?.equals,name:`${u}.dirty`}),k=b([t,l.start,l.end],()=>{let e=t.get(),n=l.start.get(),s=l.end.get(),a=Math.min(n,s),x=Math.max(n,s);return e.slice(a,x)});function f(){let{start:e,end:n}=G(r.current.get());l.select(e,n)}let w={...r,undo:()=>{let e=!1;return m(()=>{e=r.undo(),e&&f()}),e},redo:()=>{let e=!1;return m(()=>{e=r.redo(),e&&f()}),e}};function y(){let e=l.start.get(),n=l.end.get();return{start:Math.min(e,n),end:Math.max(e,n)}}function S(e,n,s){let a=t.get(),x=a.slice(0,e)+s+a.slice(n),h=e+s.length;m(()=>{r.set({text:x,start:h,end:h}),l.collapse(h)})}function R(e){let{start:n,end:s}=y();S(n,s,e)}function C(e="backward"){let n=t.get(),{start:s,end:a}=y();if(s!==a){S(s,a,"");return}if(e==="forward"){if(a>=n.length)return;S(a,a+1,"");return}s<=0||S(s-1,s,"")}function E(e){R(e)}function B(e){let n=e.length;m(()=>{r.set({text:e,start:n,end:n}),l.collapse(n)})}function $(e,n,s,a,x){let h=t.get(),q=Math.max(0,Math.min(e,h.length)),X=Math.max(q,Math.min(n,h.length)),O=h.slice(0,q)+s+h.slice(X),N=a??q+s.length,j=x??N,{start:_,end:z}=G({text:O,start:N,end:j});m(()=>{r.set({text:O,start:_,end:z}),l.select(_,z)})}function o(e,n){let s=t.get(),a=Math.max(0,Math.min(e,s.length)),x=Math.max(0,Math.min(n,s.length));return s.slice(Math.min(a,x),Math.max(a,x))}function d(e){let n=t.get().split(`
|
|
3
3
|
`);return e<0||e>=n.length?"":n[e]}function v(e,n){let s=t.get().split(`
|
|
4
4
|
`),a=Math.max(0,Math.min(e,s.length));s.splice(a,0,n),B(s.join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-X575NBLE.js";import{a as s}from"./chunk-P5MXN4AF.js";function y(t,T,i){let l=i?.equals??Object.is,n=i?.name??"dirtyTracker",e=s(T,{name:`${n}.baseline`}),c=a([t,e],()=>!l(t.get(),e.get()),{name:`${n}.dirty`}),r=!1;function d(...o){r||e.set(o.length>0?o[0]:t.get())}function p(){r||(r=!0)}return{dirty:c,baseline:e,resetBaseline:d,dispose:p}}export{y as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as i}from"./chunk-
|
|
1
|
+
import{a as i}from"./chunk-X575NBLE.js";import{a as u}from"./chunk-P5MXN4AF.js";import{q as d}from"./chunk-CWP55MPE.js";function k(f,a){let l=Math.max(2,a?.maxHistory??50),g=a?.equals,n=u([f],{name:"undoRedo.history"}),e=u(0,{name:"undoRedo.index"}),y=i([n,e],()=>{let t=n.get(),o=e.get();return t[o]},{name:"undoRedo.current"}),m=i([e],()=>e.get()>0,{name:"undoRedo.canUndo"}),p=i([n,e],()=>{let t=n.get();return e.get()<t.length-1},{name:"undoRedo.canRedo"}),x=i([e],()=>e.get(),{name:"undoRedo.historySize"});function c(t,o=!1){let r=n.get(),h=e.get(),H=r[h];if(!o&&g?.(H,t))return;let s=r.slice(0,h+1);s.push(t),s.length>l&&s.splice(0,s.length-l),d(()=>{n.set(s),e.set(s.length-1)})}function R(t){c(t)}function T(t){let o=n.get(),r=e.get();c(t(o[r]))}function b(){let t=e.get();return t<=0?!1:(e.set(t-1),!0)}function v(){let t=n.get(),o=e.get();return o>=t.length-1?!1:(e.set(o+1),!0)}function S(){let t=n.get(),o=e.get();c(t[o],!0)}function U(){let t=n.get(),o=e.get(),r=t[o];d(()=>{n.set([r]),e.set(0)})}return{current:y,set:R,update:T,undo:b,redo:v,canUndo:m,canRedo:p,checkpoint:S,clearHistory:U,historySize:x}}export{k as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as t}from"./chunk-
|
|
1
|
+
import{a as t}from"./chunk-X575NBLE.js";function i(e){let r=e??Object.is;return n=>t.from(n,{kind:"distinctUntilChanged",name:"distinctUntilChanged",equals:r})}export{i as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as n}from"./chunk-
|
|
1
|
+
import{a as n}from"./chunk-X575NBLE.js";function a(o,e){return t=>n([t],()=>{let r=t.get();return r!==void 0?r:o},{kind:"startWith",name:e?.name??"startWith",equals:e?.equals})}export{a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as D}from"./chunk-GIXPYYX7.js";import{a as A}from"./chunk-
|
|
1
|
+
import{a as D}from"./chunk-GIXPYYX7.js";import{a as A}from"./chunk-ZTR6P36Q.js";import{a as b}from"./chunk-J3QF6BR6.js";import{a as S}from"./chunk-X575NBLE.js";import{a as N}from"./chunk-P5MXN4AF.js";import{q as h,w as v}from"./chunk-CWP55MPE.js";function O(i){let a=i?.halfLife??864e5,d=i?.recency??1,u=i?.importance??1,t=i?.frequency??.5,m=Math.LN2/a;return(o,f)=>{let y=(f??Date.now())-o.accessedAt,l=Math.exp(-m*y),s=1-1/(1+o.accessCount);return d*l+u*o.importance+t*s}}function M(i,a,d){let u=a?.halfLife??864e5,t=a?.recency??1,m=a?.importance??1,o=a?.frequency??.5,f=(d??Date.now())-i.accessedAt,y=Math.exp(-Math.LN2/u*f),l=1-1/(1+i.accessCount);return t*y+m*i.importance+o*l}var F=0;function W(){return`mem-${++F}`}function L(i,a){let d=a?.id??W(),u=Date.now(),t={id:d,createdAt:u,updatedAt:u,accessedAt:u,accessCount:0,importance:a?.importance??.5,tags:new Set(a?.tags)},m=N(i,{name:`mem:${d}:content`}),o=N(t,{name:`mem:${d}:meta`,equals:()=>!1}),f={},y=S([o],()=>M(o.get(),f),{name:`mem:${d}:score`});return{id:d,content:m,meta:o,scoreStore:y,touch(){let s=Date.now();o.update(c=>({...c,accessedAt:s,accessCount:c.accessCount+1}))},tag(...s){o.update(c=>{let p=new Set(c.tags);for(let T of s)p.add(T);return{...c,tags:p,updatedAt:Date.now()}})},untag(...s){o.update(c=>{let p=new Set(c.tags);for(let T of s)p.delete(T);return{...c,tags:p,updatedAt:Date.now()}})},setImportance(s){o.update(c=>({...c,importance:Math.max(0,Math.min(1,s)),updatedAt:Date.now()}))},update(s){h(()=>{m.set(s),o.update(c=>({...c,updatedAt:Date.now()}))})},score(s){return M(o.get(),s??f)},destroy(){v(m),v(o)}}}var z=0;function X(i){let a=++z,d=i?.maxSize??1/0,u=i?.weights??{},t=new Map,m=A(),o=new Map,f=d<1/0?D(e=>t.get(e).meta,e=>M(e,u)):null,y=N(0,{name:`collection-${a}:ver`}),l=S([y],()=>Array.from(t.values()),{name:`collection-${a}:nodes`}),s=S([y],()=>t.size,{name:`collection-${a}:size`}),c=!1;function p(){y.update(e=>e+1)}function T(e){let r=b([e.meta],()=>{let n=Array.from(e.meta.get().tags);m.update(e.id,n)});o.set(e.id,r)}function w(e){let r=o.get(e);r&&(r(),o.delete(e)),m.remove(e)}function x(){if(!f||t.size<=d)return;let e=f.evict(t.size-d);for(let r of e){let n=t.get(r);n&&(w(r),n.destroy(),t.delete(r))}}return{add(e,r){if(c)throw new Error("Collection is destroyed");let n=L(e,r);return t.set(n.id,n),T(n),f?.insert(n.id),x(),p(),n},remove(e){let r=typeof e=="string"?e:e.id,n=t.get(r);return n?(w(r),f?.delete(r),n.destroy(),t.delete(r),p(),!0):!1},get(e){return t.get(e)},has(e){return t.has(e)},nodes:l,size:s,tagIndex:m,query(e){let r=[];for(let n of t.values())e(n)&&r.push(n);return r},byTag(e){let r=m.get(e),n=[];for(let _ of r){let I=t.get(_);I&&n.push(I)}return n},topK(e,r){let n=r??u,_=Date.now(),I=Array.from(t.values()).map(g=>({node:g,score:M(g.meta.get(),n,_)}));return I.sort((g,C)=>C.score-g.score),I.slice(0,e).map(g=>g.node)},destroy(){if(!c){c=!0,f?.clear();for(let e of o.values())e();o.clear(),m.destroy(),h(()=>{for(let e of t.values())e.destroy();t.clear(),v(y)})}}}}export{O as a,M as b,L as c,X as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as V}from"./chunk-HK7DRUNM.js";import{a as k}from"./chunk-M76W372U.js";import{a as r,b as u,c as b,d as I,e as A,f as O,g as C,h as R,i as w,j as d,k as L,l as N,m as l,n as c,o as n,p as h,t as M,u as U}from"./chunk-CWP55MPE.js";var p=1,g=2,S=4,f=8,o=32,q=64,x=I<<d,T=A<<d,v=O<<d,m=C<<d,Y=R<<d,y=w<<d,_=L,D=class{_output=null;_upstreamTalkbacks=[];_cachedValue;_flags;_dirtyDeps;_eqFn;_deps;_fn;get _status(){return N(this._flags)}constructor(s,i,t,e){this._deps=s,this._fn=i,this._eqFn=t?.equals,this._flags=e?q:0,this._dirtyDeps=new V(s.length),this.source=this.source.bind(this),k.register(this,{kind:"derived",...t,deps:s});for(let a of s)k.registerEdge(a,this)}_dispatch(s,i){let t=this._output;if(t)if(this._flags&o)for(let e of t)e(s,i);else t(s,i)}_recompute(){let s;try{s=this._fn()}catch(i){this._handleEnd(i);return}if(this._eqFn&&this._flags&p&&this._eqFn(this._cachedValue,s)){this._flags=this._flags&~_|m,this._dispatch(h,u);return}this._cachedValue=s,this._flags=(this._flags|p)&~_|v,this._dispatch(c,this._cachedValue)}_recomputeIdentity(s){if(!(this._flags&f)){if(this._eqFn&&this._flags&p&&this._eqFn(this._cachedValue,s)){this._flags=this._flags&~_|m,this._dispatch(h,u);return}this._cachedValue=s,this._flags=(this._flags|p)&~_|v,this._dispatch(c,s)}}_lazyConnect(){if(!(this._flags&(g|f))){try{this._cachedValue=this._fn()}catch(s){this._handleEnd(s);return}this._flags=(this._flags|p)&~_|v,M(),this._connectUpstream(),this._flags&f||(this._flags|=g),U()}}_connectUpstream(){this._upstreamTalkbacks.length=0,this._deps.length===1?this._flags&q?this._connectSingleDepIdentity():this._connectSingleDep():this._connectMultiDep()}_connectSingleDep(){let s=!1;this._deps[0].source(l,(i,t)=>{if(i===l){this._upstreamTalkbacks.push(t),t(h,b);return}if(!(this._flags&f))if(i===h)if(t===r){if(s)return;s=!0,this._flags=this._flags&~_|T,this._dispatch(h,r)}else t===u?s&&(s=!1,this._flags=this._flags&~_|m,this._dispatch(h,u)):this._dispatch(h,t);else i===c?s?(s=!1,this._recompute()):(this._flags=this._flags&~_|T,this._dispatch(h,r),this._recompute()):i===n&&this._handleEnd(t)})}_connectSingleDepIdentity(){let s=!1;this._deps[0].source(l,(i,t)=>{if(i===l){this._upstreamTalkbacks.push(t),t(h,b);return}this._flags&f||(i===h?t===r?(s=!0,this._flags=this._flags&~_|T,this._dispatch(h,r)):t===u?s&&(s=!1,this._flags=this._flags&~_|m,this._dispatch(h,u)):this._dispatch(h,t):i===c?s?(s=!1,this._recomputeIdentity(t)):(this._flags=this._flags&~_|T,this._dispatch(h,r),this._recomputeIdentity(t)):i===n&&this._handleEnd(t))})}_connectMultiDep(){for(let s=0;s<this._deps.length&&!(this._flags&f);s++){let i=s;this._deps[i].source(l,(t,e)=>{if(t===l){this._upstreamTalkbacks.push(e);return}if(!(this._flags&f))if(t===h)if(e===r){let a=this._dirtyDeps.empty();this._dirtyDeps.set(i),a&&(this._flags&=~S,this._flags=this._flags&~_|T,this._dispatch(h,r))}else e===u?this._dirtyDeps.test(i)&&(this._dirtyDeps.clear(i),this._dirtyDeps.empty()&&(this._flags&S?this._recompute():(this._flags=this._flags&~_|m,this._dispatch(h,u)))):this._dispatch(h,e);else t===c?this._dirtyDeps.test(i)?(this._dirtyDeps.clear(i),this._flags|=S,this._dirtyDeps.empty()&&this._recompute()):this._dirtyDeps.empty()?(this._flags=this._flags&~_|T,this._dispatch(h,r),this._recompute()):this._flags|=S:t===n&&this._handleEnd(e)})}}_handleEnd(s){this._flags|=f,this._flags=this._flags&~_|(s!==void 0?y:Y),s!==void 0&&(this._cachedValue=s);for(let e of this._upstreamTalkbacks)e(n);this._upstreamTalkbacks=[],this._flags&=~g,this._dirtyDeps.reset();let i=this._output,t=this._flags&o;if(this._output=null,this._flags&=~o,i)if(t)for(let e of i)try{s!==void 0?e(n,s):e(n)}catch{}else s!==void 0?i(n,s):i(n)}_disconnectUpstream(){for(let s of this._upstreamTalkbacks)s(n);this._upstreamTalkbacks.length=0,this._flags&=~(g|S),this._flags=this._flags&~_|x,this._dirtyDeps.reset()}get(){if(this._flags&g)return this._cachedValue;if(this._flags&f){if((this._flags&_)===y)throw this._cachedValue;return this._cachedValue}let s=this._fn();return this._cachedValue=s,this._flags|=p,s}source(s,i){if(s===l){let t=i;if(this._flags&f){let e=(this._flags&_)===y;t(l,a=>{}),e?t(n,this._cachedValue):t(n);return}if(!(this._flags&g)&&(this._lazyConnect(),this._flags&f)){let e=(this._flags&_)===y;t(l,a=>{}),e?t(n,this._cachedValue):t(n);return}if(this._output===null)this._output=t;else if(this._flags&o)this._output.add(t);else{let e=new Set;e.add(this._output),e.add(t),this._output=e,this._flags|=o}t(l,e=>{if(e===c&&t(c,this._cachedValue),e===n){if(this._output===null)return;if(this._flags&o){let a=this._output;a.delete(t),a.size===1?(this._output=a.values().next().value,this._flags&=~o):a.size===0&&(this._output=null,this._flags&=~o,this._disconnectUpstream())}else this._output===t&&(this._output=null,this._disconnectUpstream())}})}}};function F(E,s,i){return new D(E,s,i)}(s=>{function E(i,t){return new D([i],()=>i.get(),t,!0)}s.from=E})(F||={});export{F as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as l}from"./chunk-P5MXN4AF.js";function E(e,t){let u=Math.max(1,t?.concurrency??1),i=t?.strategy??"fifo",n=t?.name??"asyncQueue",a=l(0,{name:`${n}.size`}),c=l(0,{name:`${n}.running`}),g=l(0,{name:`${n}.completed`}),x=l(0,{name:`${n}.failed`}),d=l(!1,{name:`${n}.paused`}),s=[],f=0,m=!1;function v(o,r){m||(f--,c.set(f),g.update(p=>p+1),o.resolve(r),y())}function S(o,r){m||(f--,c.set(f),x.update(p=>p+1),o.reject(r),y())}function y(){if(!(m||d.get()))for(;f<u&&s.length>0;){let o=i==="lifo"?s.pop():s.shift();a.set(s.length),f++,c.set(f);try{e(o.task).then(r=>v(o,r),r=>S(o,r))}catch(r){S(o,r)}}}function h(o){return m?Promise.reject(new Error("Queue is disposed")):new Promise((r,p)=>{s.push({task:o,resolve:r,reject:p}),a.set(s.length),y()})}function R(){d.set(!0)}function T(){d.set(!1),y()}function k(){let o=s.splice(0,s.length);a.set(0);for(let r of o)r.reject(new Error("Queue cleared"))}function Q(){m||(m=!0,k())}return{enqueue:h,size:a,running:c,completed:g,failed:x,pause:R,resume:T,paused:d,clear:k,dispose:Q}}function j(e){return()=>e}function q(e,t=e){return u=>e+t*u}function A(e){let t=e?.base??100,u=e?.factor??2,i=e?.maxDelay??3e4,n=e?.jitter??"none";return a=>{let c=Math.min(t*u**a,i);return w(c,n)}}function D(e=100,t=3e4){return u=>{let i=1,n=1;for(let a=0;a<u;a++){let c=i+n;i=n,n=c}return Math.min(i*e,t)}}function J(e=100,t=3e4){return(u,i,n)=>{let c=Math.min(t,(n??e)*3);return b(e,c)}}function P(e,t){return(u,i,n)=>u>=t?null:e(u,i,n)}function w(e,t){switch(t){case"none":return e;case"full":return b(0,e);case"equal":return e/2+b(0,e/2)}}function b(e,t){return e+Math.random()*(t-e)}export{E as a,j as b,q as c,A as d,D as e,J as f,P as g};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as p}from"./chunk-
|
|
1
|
+
import{a as p}from"./chunk-X575NBLE.js";import{a as E}from"./chunk-P5MXN4AF.js";import{q as V,w as S}from"./chunk-CWP55MPE.js";var A=0;O.from=function(f,a){let u=O({...a,id:f.id});for(let o of f.entries)u.append(o.value);return u};function O(h){let f=++A,a=h?.id??`rlog-${f}`,u=h?.maxSize??0,o=u>0,t=[],g=0,r=0,d=0,i=1,c=E(0,{name:`${a}:ver`}),l=E(void 0,{name:`${a}:events`,equals:()=>!1}),b=new Map,m=!1;function L(){if(!o)return t.slice();if(r===0)return[];let e=new Array(r);for(let n=0;n<r;n++)e[n]=t[(g+n)%u];return e}function w(e){if(!o)return t[e];if(!(e<0||e>=r))return t[(g+e)%u]}let q={get id(){return a},get version(){return c.get()},append(e){if(m)return-1;let n=++d,s={seq:n,value:e};return o?(r<u?(t[(g+r)%u]=s,r++):(t[g]=s,g=(g+1)%u),i=d-r+1):(t.push(s),i=t.length>0?t[0].seq:1),c.update(y=>y+1),l.set({type:"append",seq:n,value:e}),n},appendMany(e){if(m||e.length===0)return[];let n=[];return V(()=>{for(let s of e)n.push(q.append(s))}),n},get(e){if(o)return e<i||e>d||r===0?void 0:w(e-i);let n=e-i;if(!(n<0||n>=t.length))return t[n]},slice(e,n){let s=e??i,y=n??d;if((o?r:t.length)===0)return[];let _=Math.max(s,i),R=Math.min(y,d);if(_>R)return[];let $=_-i,x=R-i;if(!o)return t.slice($,x+1);let M=[];for(let v=$;v<=x;v++)M.push(t[(g+v)%u]);return M},toArray(){return L()},get length(){return o?r:t.length},get headSeq(){return(o?r:t.length)>0?i:0},get tailSeq(){return d},clear(){(o?r:t.length)!==0&&V(()=>{o?(r=0,g=0):t.length=0,i=d+1,c.update(n=>n+1),l.set({type:"clear"})})},lengthStore:p([c],()=>o?r:t.length,{name:`${a}:length`}),latest:p([c],()=>{if((o?r:t.length)!==0)return o?t[(g+r-1)%u]:t[t.length-1]},{name:`${a}:latest`}),tail(e){let n=b.get(e);return n||(n=p([c],()=>{let s=L();return e===void 0||e>=s.length?s:s.slice(-e)},{name:`${a}:tail${e??""}`}),b.set(e,n),n)},events:l,snapshot(){return{type:"reactiveLog",id:a,version:c.get(),entries:L().map(e=>({seq:e.seq,value:e.value})),headSeq:(o?r:t.length)>0?i:0,tailSeq:d}},destroy(){m||(m=!0,t.length=0,r=0,S(c),S(l))}};return q}export{O as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as w}from"./chunk-
|
|
1
|
+
import{a as w}from"./chunk-X575NBLE.js";import{a as x}from"./chunk-P5MXN4AF.js";import{q as l,w as m}from"./chunk-CWP55MPE.js";var R=0;_.from=function(S){let i=_({id:S.id});for(let[n,s]of Object.entries(S.index))for(let d of s)i.add(d,[n]);return i};function _(I){let S=++R,i=I?.id??`ridx-${S}`,n=new Map,s=new Map,d=new Map,v=new Map,a=x(0,{name:`${i}:ver`}),z=w([a],()=>Array.from(n.keys()),{name:`${i}:keys`}),k=w([a],()=>n.size,{name:`${i}:size`}),g=!1,$=Object.freeze(new Set);function C(e){let t=d.get(e);return t||(t=x(n.get(e)??new Set,{name:`${i}:${e}`,equals:()=>!1}),d.set(e,t)),t}function p(e){let t=d.get(e);if(t){let r=n.get(e);t.set(r?new Set(r):new Set)}}function b(e,t){let r=n.get(t),o=!r;return r||(r=new Set,n.set(t,r)),r.add(e),o}function h(e,t){let r=n.get(t);return r?(r.delete(e),r.size===0?(n.delete(t),!0):!1):!1}return{get id(){return i},get version(){return a.get()},get(e){let t=n.get(e);return t?Object.freeze(new Set(t)):$},has(e){let t=n.get(e);return t!==void 0&&t.size>0},keys(){return Array.from(n.keys())},get size(){return n.size},select(e){let t=v.get(e);if(t)return t;let r=C(e);return t=w([r],()=>r.get(),{name:`${i}:${e}:select`}),v.set(e,t),t},keysStore:z,sizeStore:k,add(e,t){if(g||t.length===0)return;let r=s.get(e);r||(r=new Set,s.set(e,r)),l(()=>{let o=!1;for(let c of t)r.add(c),b(e,c)&&(o=!0),p(c);o&&a.update(c=>c+1)})},remove(e){if(g)return;let t=s.get(e);t&&l(()=>{let r=!1;for(let o of t)h(e,o)&&(r=!0),p(o);s.delete(e),r&&a.update(o=>o+1)})},update(e,t){if(g)return;let r=s.get(e),o=new Set(t);l(()=>{let c=!1;if(r)for(let f of r)o.has(f)||(h(e,f)&&(c=!0),p(f));let u=s.get(e);u||(u=new Set,s.set(e,u)),u.clear();for(let f of t)u.add(f),b(e,f)&&(c=!0),p(f);c&&a.update(f=>f+1)})},clear(){n.size!==0&&l(()=>{n.clear(),s.clear();for(let e of d.values())e.set(new Set);a.update(e=>e+1)})},snapshot(){let e={};for(let[t,r]of n)e[t]=Array.from(r);return{type:"reactiveIndex",id:i,version:a.get(),index:e}},destroy(){if(!g){g=!0,n.clear(),s.clear();for(let e of d.values())m(e);d.clear();for(let e of v.values())m(e);v.clear(),m(a)}}}}export{_ as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`)}static _observe(t,s,n){let i=null,a=s??e.getName(t),r={values:[],signals:[],events:[],ended:!1,endError:void 0,dirtyCount:0,resolvedCount:0,name:a,dispose:()=>i?.(
|
|
3
|
-
`)}static toD2(t){let s=t?.direction??"down",n=e.snapshot(),i=[`direction: ${s}`,""],a={state:"rectangle",derived:"hexagon",effect:"oval",producer:"rectangle",operator:"parallelogram","pipeline-step":"rectangle","pipeline-status":"diamond",checkpoint:"cylinder"},r=new Map;function o(c){let u=c.replace(/[^a-zA-Z0-9_]/g,"_"),
|
|
4
|
-
`)}static annotate(t,s){if(!e.enabled)return;e._annotations.set(t,s);let n={node:e._resolveKey(t),reason:s,timestamp:Date.now()},i=e.maxTraceEntries;i<=0||(e._traceLog.length<i?e._traceLog.push(n):(e._traceLog[e._traceHead]=n,e._traceFull=!0),e._traceHead=(e._traceHead+1)%i)}static getAnnotation(t){return e._annotations.get(t)}static traceLog(){return e._traceFull?[...e._traceLog.slice(e._traceHead),...e._traceLog.slice(0,e._traceHead)]:e._traceLog.slice(0,e._traceHead||e._traceLog.length)}static clearTrace(){e._traceLog=[],e._traceHead=0,e._traceFull=!1}static _reset(){e._names=new WeakMap,e._kinds=new WeakMap,e._keys=new WeakMap,e._stores=new Set,e._edges=new Map,e._usedKeys=new Set,e._nextId=0,e._explicitEnabled=null,e._cachedDefault=null,e._annotations=new WeakMap,e._traceLog=[],e._traceHead=0,e._traceFull=!1,e.maxTraceEntries=1e3}};var B=1,w=2,L=4,R=8,J=16,x=32,nt=64,Rt=M<<p,ct=U<<p,ut=j<<p,dt=V<<p,xt=W<<p,Z=K<<p,y=$,it=class{_output=null;_upstreamTalkbacks=[];_cachedValue;_flags=0;_dirtyDeps;_eqFn;_deps=[];_trackingFn;_trackedDeps=[];_trackingSet=null;get _status(){return Y(this._flags)}constructor(t,s){this._trackingFn=t,this._eqFn=s?.equals,this._dirtyDeps=new O(0),this.source=this.source.bind(this),D.register(this,{kind:"dynamicDerived",...s})}_trackGet(t){return this._trackingSet.has(t)||(this._trackingSet.add(t),this._trackedDeps.push(t)),t.get()}_dispatch(t,s){let n=this._output;if(n)if(this._flags&x)for(let i of n)i(t,s);else n(t,s)}_recompute(){if(this._flags&J)return;this._flags|=J,this._trackedDeps=[],this._trackingSet=new Set;let t;try{t=this._trackingFn(s=>this._trackGet(s))}catch(s){this._trackingSet=null,this._flags&=~J,this._handleEnd(s);return}if(this._trackingSet=null,this._flags&w&&this._maybeRewire(),this._flags&=~J,this._eqFn&&this._flags&B&&this._eqFn(this._cachedValue,t)){this._flags=this._flags&~y|dt,this._dispatch(h,k);return}this._cachedValue=t,this._flags=(this._flags|B)&~y|ut,this._dispatch(T,this._cachedValue)}_maybeRewire(){let t=this._trackedDeps,s=this._deps;if(t.length===s.length){let r=!0;for(let o=0;o<t.length;o++)if(t[o]!==s[o]){r=!1;break}if(r)return}this._flags|=nt;let n=new Set(s),i=new Set(t);for(let r=0;r<s.length;r++)if(!i.has(s[r])){let o=this._upstreamTalkbacks[r];o&&o(d)}let a=[];for(let r=0;r<t.length;r++){let o=s.indexOf(t[r]);o!==-1?a.push(this._upstreamTalkbacks[o]):a.push(null)}this._deps=t,this._upstreamTalkbacks=a,this._dirtyDeps=new O(t.length);for(let r of t)n.has(r)||D.registerEdge(r,this);for(let r=0;r<t.length;r++)n.has(t[r])||this._connectOneDep(r);this._flags&=~nt}_connectOneDep(t){this._deps[t].source(f,(s,n)=>{if(s===f){this._upstreamTalkbacks[t]=n;return}this._flags&R||this._flags&nt||this._handleDepSignal(t,s,n)})}_handleDepSignal(t,s,n){if(s===h)if(n===m){let i=this._dirtyDeps.empty();this._dirtyDeps.set(t),i&&(this._flags&=~L,this._flags=this._flags&~y|ct,this._dispatch(h,m))}else n===k?this._dirtyDeps.test(t)&&(this._dirtyDeps.clear(t),this._dirtyDeps.empty()&&(this._flags&L?this._recompute():(this._flags=this._flags&~y|dt,this._dispatch(h,k)))):this._dispatch(h,n);else s===T?this._dirtyDeps.test(t)?(this._dirtyDeps.clear(t),this._flags|=L,this._dirtyDeps.empty()&&this._recompute()):this._dirtyDeps.empty()?(this._flags=this._flags&~y|ct,this._dispatch(h,m),this._recompute()):this._flags|=L:s===d&&this._handleEnd(n)}_lazyConnect(){if(!(this._flags&(w|R))){this._trackedDeps=[],this._trackingSet=new Set;try{this._cachedValue=this._trackingFn(t=>this._trackGet(t))}catch(t){this._trackingSet=null,this._trackedDeps=[],this._handleEnd(t);return}this._trackingSet=null,this._flags=(this._flags|B)&~y|ut,this._deps=this._trackedDeps,this._dirtyDeps=new O(this._deps.length);for(let t of this._deps)D.registerEdge(t,this);H(),this._connectUpstream(),this._flags&R||(this._flags|=w),z()}}_connectUpstream(){this._upstreamTalkbacks.length=0;for(let t=0;t<this._deps.length&&!(this._flags&R);t++)this._connectOneDep(t)}_handleEnd(t){this._flags|=R,this._flags=this._flags&~y|(t!==void 0?Z:xt),t!==void 0&&(this._cachedValue=t);for(let i of this._upstreamTalkbacks)i&&i(d);this._upstreamTalkbacks=[],this._deps=[],this._trackedDeps=[],this._flags&=~w,this._dirtyDeps.reset();let s=this._output,n=this._flags&x;if(this._output=null,this._flags&=~x,s)if(n)for(let i of s)try{t!==void 0?i(d,t):i(d)}catch{}else t!==void 0?s(d,t):s(d)}_disconnectUpstream(){for(let t of this._upstreamTalkbacks)t(d);this._upstreamTalkbacks.length=0,this._deps=[],this._trackedDeps=[],this._flags&=~(w|L),this._flags=this._flags&~y|Rt,this._dirtyDeps.reset()}get(){if(this._flags&w)return this._cachedValue;if(this._flags&R){if((this._flags&y)===Z)throw this._cachedValue;return this._cachedValue}this._trackedDeps=[],this._trackingSet=new Set;let t;try{t=this._trackingFn(s=>this._trackGet(s))}catch(s){throw this._trackingSet=null,this._trackedDeps=[],s}return this._trackingSet=null,this._cachedValue=t,this._flags|=B,t}source(t,s){if(t===f){let n=s;if(this._flags&R){let i=(this._flags&y)===Z;n(f,a=>{}),i?n(d,this._cachedValue):n(d);return}if(!(this._flags&w)&&(this._lazyConnect(),this._flags&R)){let i=(this._flags&y)===Z;n(f,a=>{}),i?n(d,this._cachedValue):n(d);return}if(this._output===null)this._output=n;else if(this._flags&x)this._output.add(n);else{let i=new Set;i.add(this._output),i.add(n),this._output=i,this._flags|=x}n(f,i=>{if(i===T&&n(T,this._cachedValue),i===d){if(this._output===null)return;if(this._flags&x){let a=this._output;a.delete(n),a.size===1?(this._output=a.values().next().value,this._flags&=~x):a.size===0&&(this._output=null,this._flags&=~x,this._disconnectUpstream())}else this._output===n&&(this._output=null,this._disconnectUpstream())}})}}};function ft(e,t){return new it(e,t)}var Q=1,b=64,v=2,I=4,ht=8,_t=16,A=32,E=1024,_=$,F=U<<p,N=j<<p,X=M<<p,wt=W<<p,At=K<<p,Ot=V<<p,tt=class{_value;_output=null;_flags;get _status(){return Y(this._flags)}_cleanup;_fn;_eqFn;_getterFn;_initial;_singleDepCount=0;constructor(t,s){this._value=s?.initial,this._fn=t,this._eqFn=s?.equals,this._getterFn=s?.getter,this._initial=s?.initial;let n=0;s?.autoDirty!==!1&&(n|=I),s?.resetOnTeardown&&(n|=ht),s?.resubscribable&&(n|=_t),this._flags=n,this.source=this.source.bind(this),this.emit=this.emit.bind(this),s?._skipInspect||D.register(this,{kind:"producer",...s})}get(){return this._getterFn?this._getterFn(this._value):this._value}_dispatch(t,s){let n=this._output;if(n)if(this._flags&b)for(let i of n)i(t,s);else n(t,s)}emit(t){this._flags&v||this._eqFn&&this._value!==void 0&&this._eqFn(this._value,t)||(this._value=t,this._output&&(G()?this._flags&A||(this._flags|=A,this._flags&I&&(this._flags=this._flags&~_|F,this._dispatch(h,m)),q(()=>{this._flags&=~A,this._flags=this._flags&~_|N,this._dispatch(T,this._value)})):(this._flags&I&&!(this._flags&E)&&(this._flags=this._flags&~_|F,this._dispatch(h,m)),this._flags=this._flags&~_|N,this._dispatch(T,this._value))))}signal(t){this._flags&v||!this._output||(t===m?this._flags=this._flags&~_|F:t===k&&(this._flags=this._flags&~_|Ot),this._dispatch(h,t))}complete(){if(this._flags&v)return;this._flags=(this._flags|v)&~_|wt;let t=this._output,s=this._flags&b;if(this._output=null,this._flags&=~(b|E),this._singleDepCount=0,this._stop(),t)if(s)for(let n of t)n(d);else t(d)}error(t){if(this._flags&v)return;this._flags=(this._flags|v)&~_|At;let s=this._output,n=this._flags&b;if(this._output=null,this._flags&=~(b|E),this._singleDepCount=0,this._stop(),s)if(n)for(let i of s)i(d,t);else s(d,t)}_start(){if(this._flags&Q||!this._fn)return;this._flags|=Q;let t=this._fn({emit:this.emit,signal:s=>this.signal(s),complete:()=>this.complete(),error:s=>this.error(s)});this._cleanup=typeof t=="function"?t:void 0}_stop(){this._flags&Q&&(this._flags&=~Q,this._cleanup&&this._cleanup(),this._cleanup=void 0,this._flags&ht&&(this._value=this._initial),this._flags&v||(this._flags=this._flags&~_|X))}source(t,s){if(t===f){let n=s;if(this._flags&v)if(this._flags&_t&&this._output===null)this._flags=this._flags&~(v|_)|X;else{n(f,a=>{}),n(d);return}if(this._output===null)this._output=n;else if(this._flags&b)this._output.add(n);else{let a=new Set;a.add(this._output),a.add(n),this._output=a,this._flags=(this._flags|b)&~E}let i=!1;n(f,(a,r)=>{if(a===T&&n(T,this._value),a===h&&r===ot&&!i&&(i=!0,this._singleDepCount++,this._flags&b||(this._flags|=E)),a===d){if(i&&(i=!1,this._singleDepCount--),this._output===null)return;if(this._flags&b){let o=this._output;o.delete(n),o.size===1?(this._output=o.values().next().value,this._flags&=~b,this._singleDepCount>0&&(this._flags|=E)):o.size===0&&(this._output=null,this._flags&=~(b|E),this._singleDepCount=0,this._flags=this._flags&~_|X,this._stop())}else this._output===n&&(this._output=null,this._flags&=~E,this._singleDepCount=0,this._flags=this._flags&~_|X,this._stop())}}),lt(()=>this._start())}}};var rt=class extends tt{constructor(t,s){super(void 0,{initial:t,autoDirty:!0,equals:s?.equals??Object.is,_skipInspect:!0}),this.set=this.set.bind(this),D.register(this,{kind:"state",...s})}get(){return this._value}set(t){this._flags&v||this._value!==void 0&&this._eqFn(this._value,t)||(this._value=t,this._output&&(G()?this._flags&A||(this._flags|=A,this._flags&I&&(this._flags=this._flags&~_|F,this._dispatch(h,m)),q(()=>{this._flags&=~A,this._flags=this._flags&~_|N,this._dispatch(T,this._value)})):(this._flags&I&&!(this._flags&E)&&(this._flags=this._flags&~_|F,this._dispatch(h,m)),this._flags=this._flags&~_|N,this._dispatch(T,this._value))))}update(t){this.set(t(this._value))}};function pt(e,t){return new rt(e,t)}function at(e,t,s){let n=null;H(),e.source(f,(a,r)=>{if(a===f&&(n=r),a===d){n=null,s?.onEnd?.(r);return}if(a===1){let o=r,l=i;i=o,t(o,l)}});let i;try{i=e.get()}catch{}return z(),()=>n?.(d)}function It(e,t){return typeof e=="function"?$t(e,t):Ft(e)}function Ft(e){let t=pt(e);return{get:()=>t.get(),set:s=>t.set(s),update:s=>t.update(s),subscribe:s=>at(t,n=>s(n)),_store:t,_kind:"primitive"}}function $t(e,t){let s=ft(i=>e(a=>i(a._store)),{equals:Object.is}),n={get:()=>s.get(),subscribe:i=>at(s,a=>i(a)),_store:s,_kind:t?"writable-derived":"derived"};if(t){let i=o=>o.get(),a=(o,l)=>o.set(l),r=n;return r.set=o=>t(i,a,o),r.update=o=>t(i,a,o(s.get())),r}return n}0&&(module.exports={atom});
|
|
1
|
+
"use strict";var it=Object.defineProperty;var Tt=Object.getOwnPropertyDescriptor;var St=Object.getOwnPropertyNames;var mt=Object.prototype.hasOwnProperty;var yt=(e,t)=>{for(var s in t)it(e,s,{get:t[s],enumerable:!0})},bt=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of St(t))!mt.call(e,i)&&i!==s&&it(e,i,{get:()=>t[i],enumerable:!(n=Tt(t,i))||n.enumerable});return e};var vt=e=>bt(it({},"__esModule",{value:!0}),e);var $t={};yt($t,{atom:()=>It});module.exports=vt($t);var O=class{_v;_w;constructor(t){this._v=0,this._w=t>32?new Uint32Array((t-1>>>5)+1):null}set(t){let s=this._w;if(s===null)this._v|=1<<t;else{let n=t>>>5,i=1<<(t&31);s[n]&i||(s[n]|=i,this._v++)}}clear(t){let s=this._w;if(s===null)this._v&=~(1<<t);else{let n=t>>>5,i=1<<(t&31);s[n]&i&&(s[n]&=~i,this._v--)}}test(t){let s=this._w;return s===null?(this._v&1<<t)!==0:(s[t>>>5]&1<<(t&31))!==0}empty(){return this._v===0}reset(){this._v=0,this._w?.fill(0)}};var p=Symbol("DIRTY"),D=Symbol("RESOLVED"),M=Symbol("SINGLE_DEP"),U=0,j=1,V=2,W=3,K=4,Y=5,g=7,L=7<<g,Dt=["DISCONNECTED","DIRTY","SETTLED","RESOLVED","COMPLETED","ERRORED"];function G(e){return Dt[(e&L)>>>g]}var h=0,T=1,f=2,d=3,Et=0,kt=[];function q(){return Et>0}function H(e){kt.push(e)}var C=0,P=[];function z(){C++}function B(){if(C--,C===0){for(let e=0;e<P.length;e++)P[e]();P.length=0}}function ut(e){C>0?P.push(e):e()}var E=class e{static _names=new WeakMap;static _kinds=new WeakMap;static _keys=new WeakMap;static _stores=new Set;static _edges=new Map;static _nextId=0;static _usedKeys=new Set;static _explicitEnabled=null;static _cachedDefault=null;static _annotations=new WeakMap;static _traceLog=[];static _traceHead=0;static _traceFull=!1;static maxTraceEntries=1e3;static get enabled(){if(e._explicitEnabled!==null)return e._explicitEnabled;if(e._cachedDefault!==null)return e._cachedDefault;try{e._cachedDefault=globalThis.process?.env?.NODE_ENV!=="production"}catch{e._cachedDefault=!0}return e._cachedDefault}static set enabled(t){e._explicitEnabled=t}static _depSuffix(t){if(!t?.length)return;let n=t.map(i=>e._names.get(i)??"?").join(",");return n.length>40?`${n.slice(0,37)}...`:n}static _resolveKey(t){let s=e._keys.get(t)??e._names.get(t);if(s)return s;let n=`anonymous_${e._nextId++}`;return e._keys.set(t,n),n}static register(t,s){if(!e.enabled)return;s?.name&&e._names.set(t,s.name),s?.kind&&e._kinds.set(t,s.kind);let n=e._nextId++,i=s?.name;if(!(i&&!e._usedKeys.has(i)))if(i){let a=e._depSuffix(s?.deps);i=a?`${i}(${a})`:`${i}_${n}`,e._usedKeys.has(i)&&(i=`${i}_${n}`)}else{let a=s?.kind??"store",r=e._depSuffix(s?.deps);i=r?`${a}(${r})`:`${a}_${n}`,e._usedKeys.has(i)&&(i=`${i}_${n}`)}e._usedKeys.add(i),e._keys.set(t,i),e._stores.add(new WeakRef(t))}static registerEdge(t,s){if(!e.enabled)return;let n=e._resolveKey(t),i=e._resolveKey(s),a=e._edges.get(n);a?a.includes(i)||a.push(i):e._edges.set(n,[i])}static getEdges(){return new Map(e._edges)}static getName(t){if(e.enabled)return e._names.get(t)}static getKind(t){return e._kinds.get(t)}static inspect(t){return{name:e._names.get(t),kind:e._kinds.get(t)??"unknown",value:typeof t.get=="function"?t.get():void 0,status:t._status}}static graph(){let t=new Map,s=new Set;for(let n of e._stores){let i=n.deref();if(!i){e._stores.delete(n);continue}let a=e._resolveKey(i);s.add(a),t.set(a,e.inspect(i))}for(let[n,i]of e._edges){if(!s.has(n)){e._edges.delete(n),e._usedKeys.delete(n);continue}let a=i.filter(r=>s.has(r));a.length===0?e._edges.delete(n):a.length!==i.length&&e._edges.set(n,a)}return t}static trace(t,s){let n=null,i=t.get();return t.source(h,(a,r)=>{if(a===h&&(n=r),a===f){n=null;return}if(a===1){let o=r;if(!Object.is(o,i)){let l=i;i=o,s(o,l)}}}),()=>n?.(f)}static dumpGraph(){let t=e.graph(),s=e.getEdges(),n=new Map;for(let[r,o]of s)for(let l of o){let y=n.get(l);y?y.includes(r)||y.push(r):n.set(l,[r])}let i=[];for(let[r,o]of t){let l=n.get(r),y=s.get(r),c=l?.length?` \u2190 [${l.join(", ")}]`:"",u=y?.length?` \u2192 [${y.join(", ")}]`:"";i.push(` ${r} (${o.kind}) = ${JSON.stringify(o.value)} [${o.status??"?"}]${c}${u}`)}return[`Store Graph (${t.size} nodes):`,...i].join(`
|
|
2
|
+
`)}static _observe(t,s,n){let i=null,a=s??e.getName(t),r={values:[],signals:[],events:[],ended:!1,endError:void 0,dirtyCount:0,resolvedCount:0,name:a,dispose:()=>i?.(f)};return t.source(h,(o,l)=>{if(o===h){i=l;return}o===T?(r.values.push(l),r.events.push({type:"data",data:l}),n&&n(`[${a}] DATA:`,l)):o===d?(r.signals.push(l),r.events.push({type:"signal",data:l}),l===p?r.dirtyCount++:l===D&&r.resolvedCount++,n&&n(`[${a}] STATE:`,l)):o===f&&(r.ended=!0,r.endError=l,r.events.push({type:"end",data:l}),n&&n(`[${a}] END`,l!==void 0?l:""),i=null)}),r}static observe(t){return e._observe(t)}static tap(t,s){let n=s??`tap(${e.getName(t)??"anon"})`,i={get:()=>t.get(),source:t.source};return e.register(i,{name:n,kind:"tap"}),e.registerEdge(t,i),i}static spy(t,s){let n=s?.name??e.getName(t)??"spy",i=s?.log??console.log;return e._observe(t,n,i)}static snapshot(){let t=e.graph(),s=e.getEdges(),n=new Map;for(let r of e._stores){let o=r.deref();if(!o)continue;let l=e._annotations.get(o);l!==void 0&&n.set(e._resolveKey(o),l)}let i=[];for(let[r,o]of t){let l={name:r,kind:o.kind,value:o.value,status:o.status},y=n.get(r);y!==void 0&&(l.annotation=y),i.push(l)}let a=[];for(let[r,o]of s)for(let l of o)a.push({from:r,to:l});return{nodes:i,edges:a,trace:e.traceLog()}}static toMermaid(t){let s=t?.direction??"TD",n=e.snapshot(),i=[`graph ${s}`],a={SETTLED:":::settled",DIRTY:":::dirty",ERRORED:":::errored",COMPLETED:":::completed"},r=new Map;function o(c){let u=c.replace(/[^a-zA-Z0-9_]/g,"_"),S=r.get(u);return S===void 0?(r.set(u,1),u):(r.set(u,S+1),`${u}__${S}`)}let l=new Map;function y(c){let u=JSON.stringify(c);return u&&u.length>30?`${u.slice(0,27)}...`:u??"undefined"}for(let c of n.nodes){let u=o(c.name);l.set(c.name,u);let S=`${c.name} (${c.kind}) = ${y(c.value)}`,nt=a[c.status??""]??"";i.push(` ${u}["${S}"]${nt}`)}for(let c of n.edges){let u=l.get(c.from)??o(c.from),S=l.get(c.to)??o(c.to);i.push(` ${u} --> ${S}`)}return i.push(""),i.push(" classDef settled fill:#d4edda,stroke:#28a745"),i.push(" classDef dirty fill:#fff3cd,stroke:#ffc107"),i.push(" classDef errored fill:#f8d7da,stroke:#dc3545"),i.push(" classDef completed fill:#cce5ff,stroke:#007bff"),i.join(`
|
|
3
|
+
`)}static toD2(t){let s=t?.direction??"down",n=e.snapshot(),i=[`direction: ${s}`,""],a={state:"rectangle",derived:"hexagon",effect:"oval",producer:"rectangle",operator:"parallelogram","pipeline-step":"rectangle","pipeline-status":"diamond",checkpoint:"cylinder"},r=new Map;function o(c){let u=c.replace(/[^a-zA-Z0-9_]/g,"_"),S=r.get(u);return S===void 0?(r.set(u,1),u):(r.set(u,S+1),`${u}__${S}`)}let l=new Map;function y(c){let u=JSON.stringify(c);return u&&u.length>30?`${u.slice(0,27)}...`:u??"undefined"}for(let c of n.nodes){let u=o(c.name);l.set(c.name,u);let S=a[c.kind]??"rectangle",nt=`${c.name} (${c.kind}) = ${y(c.value)}`,gt=c.status?` [${c.status}]`:"";i.push(`${u}: "${nt}${gt}" { shape: ${S} }`)}n.edges.length>0&&i.push("");for(let c of n.edges){let u=l.get(c.from)??o(c.from),S=l.get(c.to)??o(c.to);i.push(`${u} -> ${S}`)}return i.join(`
|
|
4
|
+
`)}static annotate(t,s){if(!e.enabled)return;e._annotations.set(t,s);let n={node:e._resolveKey(t),reason:s,timestamp:Date.now()},i=e.maxTraceEntries;i<=0||(e._traceLog.length<i?e._traceLog.push(n):(e._traceLog[e._traceHead]=n,e._traceFull=!0),e._traceHead=(e._traceHead+1)%i)}static getAnnotation(t){return e._annotations.get(t)}static traceLog(){return e._traceFull?[...e._traceLog.slice(e._traceHead),...e._traceLog.slice(0,e._traceHead)]:e._traceLog.slice(0,e._traceHead||e._traceLog.length)}static clearTrace(){e._traceLog=[],e._traceHead=0,e._traceFull=!1}static _reset(){e._names=new WeakMap,e._kinds=new WeakMap,e._keys=new WeakMap,e._stores=new Set,e._edges=new Map,e._usedKeys=new Set,e._nextId=0,e._explicitEnabled=null,e._cachedDefault=null,e._annotations=new WeakMap,e._traceLog=[],e._traceHead=0,e._traceFull=!1,e.maxTraceEntries=1e3}};var J=1,w=2,$=4,R=8,Z=16,x=32,rt=64,Rt=U<<g,Q=j<<g,ft=V<<g,at=W<<g,xt=K<<g,X=Y<<g,m=L,ot=class{_output=null;_upstreamTalkbacks=[];_cachedValue;_flags=0;_dirtyDeps;_eqFn;_deps=[];_trackingFn;_trackedDeps=[];_trackingSet=null;get _status(){return G(this._flags)}constructor(t,s){this._trackingFn=t,this._eqFn=s?.equals,this._dirtyDeps=new O(0),this.source=this.source.bind(this),E.register(this,{kind:"dynamicDerived",...s})}_trackGet(t){return this._trackingSet.has(t)||(this._trackingSet.add(t),this._trackedDeps.push(t)),t.get()}_dispatch(t,s){let n=this._output;if(n)if(this._flags&x)for(let i of n)i(t,s);else n(t,s)}_recompute(){if(this._flags&Z)return;this._flags|=Z,this._trackedDeps=[],this._trackingSet=new Set;let t;try{t=this._trackingFn(s=>this._trackGet(s))}catch(s){this._trackingSet=null,this._flags&=~Z,this._handleEnd(s);return}if(this._trackingSet=null,this._flags&w&&this._maybeRewire(),this._flags&=~Z,this._eqFn&&this._flags&J&&this._eqFn(this._cachedValue,t)){this._flags=this._flags&~m|at,this._dispatch(d,D);return}this._cachedValue=t,this._flags=(this._flags|J)&~m|ft,this._dispatch(T,this._cachedValue)}_maybeRewire(){let t=this._trackedDeps,s=this._deps;if(t.length===s.length){let r=!0;for(let o=0;o<t.length;o++)if(t[o]!==s[o]){r=!1;break}if(r)return}this._flags|=rt;let n=new Set(s),i=new Set(t);for(let r=0;r<s.length;r++)if(!i.has(s[r])){let o=this._upstreamTalkbacks[r];o&&o(f)}let a=[];for(let r=0;r<t.length;r++){let o=s.indexOf(t[r]);o!==-1?a.push(this._upstreamTalkbacks[o]):a.push(null)}this._deps=t,this._upstreamTalkbacks=a,this._dirtyDeps=new O(t.length);for(let r of t)n.has(r)||E.registerEdge(r,this);for(let r=0;r<t.length;r++)n.has(t[r])||this._connectOneDep(r);this._flags&=~rt}_connectOneDep(t){this._deps[t].source(h,(s,n)=>{if(s===h){this._upstreamTalkbacks[t]=n;return}this._flags&R||this._flags&rt||this._handleDepSignal(t,s,n)})}_handleDepSignal(t,s,n){if(s===d)if(n===p){let i=this._dirtyDeps.empty();this._dirtyDeps.set(t),i&&(this._flags&=~$,this._flags=this._flags&~m|Q,this._dispatch(d,p))}else n===D?this._dirtyDeps.test(t)&&(this._dirtyDeps.clear(t),this._dirtyDeps.empty()&&(this._flags&$?this._recompute():(this._flags=this._flags&~m|at,this._dispatch(d,D)))):this._dispatch(d,n);else s===T?this._dirtyDeps.test(t)?(this._dirtyDeps.clear(t),this._flags|=$,this._dirtyDeps.empty()&&this._recompute()):this._dirtyDeps.empty()?(this._flags=this._flags&~m|Q,this._dispatch(d,p),this._recompute()):this._flags|=$:s===f&&this._handleEnd(n)}_lazyConnect(){if(!(this._flags&(w|R))){this._trackedDeps=[],this._trackingSet=new Set;try{this._cachedValue=this._trackingFn(t=>this._trackGet(t))}catch(t){this._trackingSet=null,this._trackedDeps=[],this._handleEnd(t);return}this._trackingSet=null,this._flags=(this._flags|J)&~m|ft,this._deps=this._trackedDeps,this._dirtyDeps=new O(this._deps.length);for(let t of this._deps)E.registerEdge(t,this);z(),this._connectUpstream(),this._flags&R||(this._flags|=w),B()}}_connectSingleDep(){let t=!1;this._deps[0].source(h,(s,n)=>{if(s===h){this._upstreamTalkbacks.push(n),n(d,M);return}if(!(this._flags&R))if(s===d)if(n===p){if(t)return;t=!0,this._flags=this._flags&~m|Q,this._dispatch(d,p)}else n===D?t&&(t=!1,this._flags=this._flags&~m|at,this._dispatch(d,D)):this._dispatch(d,n);else s===T?t?(t=!1,this._recompute()):(this._flags=this._flags&~m|Q,this._dispatch(d,p),this._recompute()):s===f&&this._handleEnd(n)})}_connectUpstream(){if(this._upstreamTalkbacks.length=0,this._deps.length===1)this._connectSingleDep();else for(let t=0;t<this._deps.length&&!(this._flags&R);t++)this._connectOneDep(t)}_handleEnd(t){this._flags|=R,this._flags=this._flags&~m|(t!==void 0?X:xt),t!==void 0&&(this._cachedValue=t);for(let i of this._upstreamTalkbacks)i&&i(f);this._upstreamTalkbacks=[],this._deps=[],this._trackedDeps=[],this._flags&=~w,this._dirtyDeps.reset();let s=this._output,n=this._flags&x;if(this._output=null,this._flags&=~x,s)if(n)for(let i of s)try{t!==void 0?i(f,t):i(f)}catch{}else t!==void 0?s(f,t):s(f)}_disconnectUpstream(){for(let t of this._upstreamTalkbacks)t(f);this._upstreamTalkbacks.length=0,this._deps=[],this._trackedDeps=[],this._flags&=~(w|$),this._flags=this._flags&~m|Rt,this._dirtyDeps.reset()}get(){if(this._flags&w)return this._cachedValue;if(this._flags&R){if((this._flags&m)===X)throw this._cachedValue;return this._cachedValue}this._trackedDeps=[],this._trackingSet=new Set;let t;try{t=this._trackingFn(s=>this._trackGet(s))}catch(s){throw this._trackingSet=null,this._trackedDeps=[],s}return this._trackingSet=null,this._cachedValue=t,this._flags|=J,t}source(t,s){if(t===h){let n=s;if(this._flags&R){let i=(this._flags&m)===X;n(h,a=>{}),i?n(f,this._cachedValue):n(f);return}if(!(this._flags&w)&&(this._lazyConnect(),this._flags&R)){let i=(this._flags&m)===X;n(h,a=>{}),i?n(f,this._cachedValue):n(f);return}if(this._output===null)this._output=n;else if(this._flags&x)this._output.add(n);else{let i=new Set;i.add(this._output),i.add(n),this._output=i,this._flags|=x}n(h,i=>{if(i===T&&n(T,this._cachedValue),i===f){if(this._output===null)return;if(this._flags&x){let a=this._output;a.delete(n),a.size===1?(this._output=a.values().next().value,this._flags&=~x):a.size===0&&(this._output=null,this._flags&=~x,this._disconnectUpstream())}else this._output===n&&(this._output=null,this._disconnectUpstream())}})}}};function dt(e,t){return new ot(e,t)}var tt=1,b=64,v=2,I=4,ht=8,_t=16,A=32,k=1024,_=L,F=j<<g,N=V<<g,et=U<<g,wt=K<<g,At=Y<<g,Ot=W<<g,st=class{_value;_output=null;_flags;get _status(){return G(this._flags)}_cleanup;_fn;_eqFn;_getterFn;_initial;_singleDepCount=0;constructor(t,s){this._value=s?.initial,this._fn=t,this._eqFn=s?.equals,this._getterFn=s?.getter,this._initial=s?.initial;let n=0;s?.autoDirty!==!1&&(n|=I),s?.resetOnTeardown&&(n|=ht),s?.resubscribable&&(n|=_t),this._flags=n,this.source=this.source.bind(this),this.emit=this.emit.bind(this),s?._skipInspect||E.register(this,{kind:"producer",...s})}get(){return this._getterFn?this._getterFn(this._value):this._value}_dispatch(t,s){let n=this._output;if(n)if(this._flags&b)for(let i of n)i(t,s);else n(t,s)}emit(t){this._flags&v||this._eqFn&&this._value!==void 0&&this._eqFn(this._value,t)||(this._value=t,this._output&&(q()?this._flags&A||(this._flags|=A,this._flags&I&&(this._flags=this._flags&~_|F,this._dispatch(d,p)),H(()=>{this._flags&=~A,this._flags=this._flags&~_|N,this._dispatch(T,this._value)})):(this._flags&I&&!(this._flags&k)&&(this._flags=this._flags&~_|F,this._dispatch(d,p)),this._flags=this._flags&~_|N,this._dispatch(T,this._value))))}signal(t){this._flags&v||!this._output||(t===p?this._flags=this._flags&~_|F:t===D&&(this._flags=this._flags&~_|Ot),this._dispatch(d,t))}complete(){if(this._flags&v)return;this._flags=(this._flags|v)&~_|wt;let t=this._output,s=this._flags&b;if(this._output=null,this._flags&=~(b|k),this._singleDepCount=0,this._stop(),t)if(s)for(let n of t)n(f);else t(f)}error(t){if(this._flags&v)return;this._flags=(this._flags|v)&~_|At;let s=this._output,n=this._flags&b;if(this._output=null,this._flags&=~(b|k),this._singleDepCount=0,this._stop(),s)if(n)for(let i of s)i(f,t);else s(f,t)}_start(){if(this._flags&tt||!this._fn)return;this._flags|=tt;let t=this._fn({emit:this.emit,signal:s=>this.signal(s),complete:()=>this.complete(),error:s=>this.error(s)});this._cleanup=typeof t=="function"?t:void 0}_stop(){this._flags&tt&&(this._flags&=~tt,this._cleanup&&this._cleanup(),this._cleanup=void 0,this._flags&ht&&(this._value=this._initial),this._flags&v||(this._flags=this._flags&~_|et))}source(t,s){if(t===h){let n=s;if(this._flags&v)if(this._flags&_t&&this._output===null)this._flags=this._flags&~(v|_)|et;else{n(h,a=>{}),n(f);return}if(this._output===null)this._output=n;else if(this._flags&b)this._output.add(n);else{let a=new Set;a.add(this._output),a.add(n),this._output=a,this._flags=(this._flags|b)&~k}let i=!1;n(h,(a,r)=>{if(a===T&&n(T,this._value),a===d&&r===M&&!i&&(i=!0,this._singleDepCount++,this._flags&b||(this._flags|=k)),a===f){if(i&&(i=!1,this._singleDepCount--),this._output===null)return;if(this._flags&b){let o=this._output;o.delete(n),o.size===1?(this._output=o.values().next().value,this._flags&=~b,this._singleDepCount>0&&(this._flags|=k)):o.size===0&&(this._output=null,this._flags&=~(b|k),this._singleDepCount=0,this._flags=this._flags&~_|et,this._stop())}else this._output===n&&(this._output=null,this._flags&=~k,this._singleDepCount=0,this._flags=this._flags&~_|et,this._stop())}}),ut(()=>this._start())}}};var lt=class extends st{constructor(t,s){super(void 0,{initial:t,autoDirty:!0,equals:s?.equals??Object.is,_skipInspect:!0}),this.set=this.set.bind(this),E.register(this,{kind:"state",...s})}get(){return this._value}set(t){this._flags&v||this._value!==void 0&&this._eqFn(this._value,t)||(this._value=t,this._output&&(q()?this._flags&A||(this._flags|=A,this._flags&I&&(this._flags=this._flags&~_|F,this._dispatch(d,p)),H(()=>{this._flags&=~A,this._flags=this._flags&~_|N,this._dispatch(T,this._value)})):(this._flags&I&&!(this._flags&k)&&(this._flags=this._flags&~_|F,this._dispatch(d,p)),this._flags=this._flags&~_|N,this._dispatch(T,this._value))))}update(t){this.set(t(this._value))}};function pt(e,t){return new lt(e,t)}function ct(e,t,s){let n=null;z(),e.source(h,(a,r)=>{if(a===h&&(n=r),a===f){n=null,s?.onEnd?.(r);return}if(a===1){let o=r,l=i;i=o,t(o,l)}});let i;try{i=e.get()}catch{}return B(),()=>n?.(f)}function It(e,t){return typeof e=="function"?Lt(e,t):Ft(e)}function Ft(e){let t=pt(e);return{get:()=>t.get(),set:s=>t.set(s),update:s=>t.update(s),subscribe:s=>ct(t,n=>s(n)),_store:t,_kind:"primitive"}}function Lt(e,t){let s=dt(i=>e(a=>i(a._store)),{equals:Object.is}),n={get:()=>s.get(),subscribe:i=>ct(s,a=>i(a)),_store:s,_kind:t?"writable-derived":"derived"};if(t){let i=o=>o.get(),a=(o,l)=>o.set(l),r=n;return r.set=o=>t(i,a,o),r.update=o=>t(i,a,o(s.get())),r}return n}0&&(module.exports={atom});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s}from"../../chunk-
|
|
1
|
+
import{a as s}from"../../chunk-L3GEFDZW.js";import"../../chunk-HK7DRUNM.js";import{a as d}from"../../chunk-YJXCVG35.js";import{a as m}from"../../chunk-P5MXN4AF.js";import"../../chunk-YN4VWXAF.js";import"../../chunk-M76W372U.js";import"../../chunk-CWP55MPE.js";import"../../chunk-I7AUKTXE.js";function A(r,e){return typeof r=="function"?c(r,e):u(r)}function u(r){let e=m(r);return{get:()=>e.get(),set:t=>e.set(t),update:t=>e.update(t),subscribe:t=>d(e,i=>t(i)),_store:e,_kind:"primitive"}}function c(r,e){let t=s(a=>r(n=>a(n._store)),{equals:Object.is}),i={get:()=>t.get(),subscribe:a=>d(t,n=>a(n)),_store:t,_kind:e?"writable-derived":"derived"};if(e){let a=o=>o.get(),n=(o,b)=>o.set(b),T=i;return T.set=o=>e(a,n,o),T.update=o=>e(a,n,o(t.get())),T}return i}export{A as atom};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";var at=Object.defineProperty;var gt=Object.getOwnPropertyDescriptor;var Tt=Object.getOwnPropertyNames;var mt=Object.prototype.hasOwnProperty;var St=(n,t)=>{for(var s in t)at(n,s,{get:t[s],enumerable:!0})},vt=(n,t,s,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Tt(t))!mt.call(n,i)&&i!==s&&at(n,i,{get:()=>t[i],enumerable:!(e=gt(t,i))||e.enumerable});return n};var yt=n=>vt(at({},"__esModule",{value:!0}),n);var Ct={};St(Ct,{atom:()=>Nt,computed:()=>It,map:()=>Ot});module.exports=yt(Ct);var V=class{_v;_w;constructor(t){this._v=0,this._w=t>32?new Uint32Array((t-1>>>5)+1):null}set(t){let s=this._w;if(s===null)this._v|=1<<t;else{let e=t>>>5,i=1<<(t&31);s[e]&i||(s[e]|=i,this._v++)}}clear(t){let s=this._w;if(s===null)this._v&=~(1<<t);else{let e=t>>>5,i=1<<(t&31);s[e]&i&&(s[e]&=~i,this._v--)}}test(t){let s=this._w;return s===null?(this._v&1<<t)!==0:(s[t>>>5]&1<<(t&31))!==0}empty(){return this._v===0}reset(){this._v=0,this._w?.fill(0)}};var _=Symbol("DIRTY"),y=Symbol("RESOLVED"),$=Symbol("SINGLE_DEP"),Y=0,q=1,W=2,B=3,H=4,z=5,m=7,M=7<<m,bt=["DISCONNECTED","DIRTY","SETTLED","RESOLVED","COMPLETED","ERRORED"];function G(n){return bt[(n&M)>>>m]}var h=0,g=1,f=2,d=3,Et=0,Dt=[];function J(){return Et>0}function Z(n){Dt.push(n)}var U=0,F=[];function Q(){U++}function X(){if(U--,U===0){for(let n=0;n<F.length;n++)F[n]();F.length=0}}function ft(n){U>0?F.push(n):n()}var x=class n{static _names=new WeakMap;static _kinds=new WeakMap;static _keys=new WeakMap;static _stores=new Set;static _edges=new Map;static _nextId=0;static _usedKeys=new Set;static _explicitEnabled=null;static _cachedDefault=null;static _annotations=new WeakMap;static _traceLog=[];static _traceHead=0;static _traceFull=!1;static maxTraceEntries=1e3;static get enabled(){if(n._explicitEnabled!==null)return n._explicitEnabled;if(n._cachedDefault!==null)return n._cachedDefault;try{n._cachedDefault=globalThis.process?.env?.NODE_ENV!=="production"}catch{n._cachedDefault=!0}return n._cachedDefault}static set enabled(t){n._explicitEnabled=t}static _depSuffix(t){if(!t?.length)return;let e=t.map(i=>n._names.get(i)??"?").join(",");return e.length>40?`${e.slice(0,37)}...`:e}static _resolveKey(t){let s=n._keys.get(t)??n._names.get(t);if(s)return s;let e=`anonymous_${n._nextId++}`;return n._keys.set(t,e),e}static register(t,s){if(!n.enabled)return;s?.name&&n._names.set(t,s.name),s?.kind&&n._kinds.set(t,s.kind);let e=n._nextId++,i=s?.name;if(!(i&&!n._usedKeys.has(i)))if(i){let r=n._depSuffix(s?.deps);i=r?`${i}(${r})`:`${i}_${e}`,n._usedKeys.has(i)&&(i=`${i}_${e}`)}else{let r=s?.kind??"store",o=n._depSuffix(s?.deps);i=o?`${r}(${o})`:`${r}_${e}`,n._usedKeys.has(i)&&(i=`${i}_${e}`)}n._usedKeys.add(i),n._keys.set(t,i),n._stores.add(new WeakRef(t))}static registerEdge(t,s){if(!n.enabled)return;let e=n._resolveKey(t),i=n._resolveKey(s),r=n._edges.get(e);r?r.includes(i)||r.push(i):n._edges.set(e,[i])}static getEdges(){return new Map(n._edges)}static getName(t){if(n.enabled)return n._names.get(t)}static getKind(t){return n._kinds.get(t)}static inspect(t){return{name:n._names.get(t),kind:n._kinds.get(t)??"unknown",value:typeof t.get=="function"?t.get():void 0,status:t._status}}static graph(){let t=new Map,s=new Set;for(let e of n._stores){let i=e.deref();if(!i){n._stores.delete(e);continue}let r=n._resolveKey(i);s.add(r),t.set(r,n.inspect(i))}for(let[e,i]of n._edges){if(!s.has(e)){n._edges.delete(e),n._usedKeys.delete(e);continue}let r=i.filter(o=>s.has(o));r.length===0?n._edges.delete(e):r.length!==i.length&&n._edges.set(e,r)}return t}static trace(t,s){let e=null,i=t.get();return t.source(h,(r,o)=>{if(r===h&&(e=o),r===f){e=null;return}if(r===1){let a=o;if(!Object.is(a,i)){let u=i;i=a,s(a,u)}}}),()=>e?.(f)}static dumpGraph(){let t=n.graph(),s=n.getEdges(),e=new Map;for(let[o,a]of s)for(let u of a){let v=e.get(u);v?v.includes(o)||v.push(o):e.set(u,[o])}let i=[];for(let[o,a]of t){let u=e.get(o),v=s.get(o),l=u?.length?` \u2190 [${u.join(", ")}]`:"",c=v?.length?` \u2192 [${v.join(", ")}]`:"";i.push(` ${o} (${a.kind}) = ${JSON.stringify(a.value)} [${a.status??"?"}]${l}${c}`)}return[`Store Graph (${t.size} nodes):`,...i].join(`
|
|
2
2
|
`)}static _observe(t,s,e){let i=null,r=s??n.getName(t),o={values:[],signals:[],events:[],ended:!1,endError:void 0,dirtyCount:0,resolvedCount:0,name:r,dispose:()=>i?.(f)};return t.source(h,(a,u)=>{if(a===h){i=u;return}a===g?(o.values.push(u),o.events.push({type:"data",data:u}),e&&e(`[${r}] DATA:`,u)):a===d?(o.signals.push(u),o.events.push({type:"signal",data:u}),u===_?o.dirtyCount++:u===y&&o.resolvedCount++,e&&e(`[${r}] STATE:`,u)):a===f&&(o.ended=!0,o.endError=u,o.events.push({type:"end",data:u}),e&&e(`[${r}] END`,u!==void 0?u:""),i=null)}),o}static observe(t){return n._observe(t)}static tap(t,s){let e=s??`tap(${n.getName(t)??"anon"})`,i={get:()=>t.get(),source:t.source};return n.register(i,{name:e,kind:"tap"}),n.registerEdge(t,i),i}static spy(t,s){let e=s?.name??n.getName(t)??"spy",i=s?.log??console.log;return n._observe(t,e,i)}static snapshot(){let t=n.graph(),s=n.getEdges(),e=new Map;for(let o of n._stores){let a=o.deref();if(!a)continue;let u=n._annotations.get(a);u!==void 0&&e.set(n._resolveKey(a),u)}let i=[];for(let[o,a]of t){let u={name:o,kind:a.kind,value:a.value,status:a.status},v=e.get(o);v!==void 0&&(u.annotation=v),i.push(u)}let r=[];for(let[o,a]of s)for(let u of a)r.push({from:o,to:u});return{nodes:i,edges:r,trace:n.traceLog()}}static toMermaid(t){let s=t?.direction??"TD",e=n.snapshot(),i=[`graph ${s}`],r={SETTLED:":::settled",DIRTY:":::dirty",ERRORED:":::errored",COMPLETED:":::completed"},o=new Map;function a(l){let c=l.replace(/[^a-zA-Z0-9_]/g,"_"),S=o.get(c);return S===void 0?(o.set(c,1),c):(o.set(c,S+1),`${c}__${S}`)}let u=new Map;function v(l){let c=JSON.stringify(l);return c&&c.length>30?`${c.slice(0,27)}...`:c??"undefined"}for(let l of e.nodes){let c=a(l.name);u.set(l.name,c);let S=`${l.name} (${l.kind}) = ${v(l.value)}`,ot=r[l.status??""]??"";i.push(` ${c}["${S}"]${ot}`)}for(let l of e.edges){let c=u.get(l.from)??a(l.from),S=u.get(l.to)??a(l.to);i.push(` ${c} --> ${S}`)}return i.push(""),i.push(" classDef settled fill:#d4edda,stroke:#28a745"),i.push(" classDef dirty fill:#fff3cd,stroke:#ffc107"),i.push(" classDef errored fill:#f8d7da,stroke:#dc3545"),i.push(" classDef completed fill:#cce5ff,stroke:#007bff"),i.join(`
|
|
3
3
|
`)}static toD2(t){let s=t?.direction??"down",e=n.snapshot(),i=[`direction: ${s}`,""],r={state:"rectangle",derived:"hexagon",effect:"oval",producer:"rectangle",operator:"parallelogram","pipeline-step":"rectangle","pipeline-status":"diamond",checkpoint:"cylinder"},o=new Map;function a(l){let c=l.replace(/[^a-zA-Z0-9_]/g,"_"),S=o.get(c);return S===void 0?(o.set(c,1),c):(o.set(c,S+1),`${c}__${S}`)}let u=new Map;function v(l){let c=JSON.stringify(l);return c&&c.length>30?`${c.slice(0,27)}...`:c??"undefined"}for(let l of e.nodes){let c=a(l.name);u.set(l.name,c);let S=r[l.kind]??"rectangle",ot=`${l.name} (${l.kind}) = ${v(l.value)}`,pt=l.status?` [${l.status}]`:"";i.push(`${c}: "${ot}${pt}" { shape: ${S} }`)}e.edges.length>0&&i.push("");for(let l of e.edges){let c=u.get(l.from)??a(l.from),S=u.get(l.to)??a(l.to);i.push(`${c} -> ${S}`)}return i.join(`
|
|
4
|
-
`)}static annotate(t,s){if(!n.enabled)return;n._annotations.set(t,s);let e={node:n._resolveKey(t),reason:s,timestamp:Date.now()},i=n.maxTraceEntries;i<=0||(n._traceLog.length<i?n._traceLog.push(e):(n._traceLog[n._traceHead]=e,n._traceFull=!0),n._traceHead=(n._traceHead+1)%i)}static getAnnotation(t){return n._annotations.get(t)}static traceLog(){return n._traceFull?[...n._traceLog.slice(n._traceHead),...n._traceLog.slice(0,n._traceHead)]:n._traceLog.slice(0,n._traceHead||n._traceLog.length)}static clearTrace(){n._traceLog=[],n._traceHead=0,n._traceFull=!1}static _reset(){n._names=new WeakMap,n._kinds=new WeakMap,n._keys=new WeakMap,n._stores=new Set,n._edges=new Map,n._usedKeys=new Set,n._nextId=0,n._explicitEnabled=null,n._cachedDefault=null,n._annotations=new WeakMap,n._traceLog=[],n._traceHead=0,n._traceFull=!1,n.maxTraceEntries=1e3}};var N=1,I=2,P=4,b=8,A=32,dt=64,kt=Y<<m,O=q<<m,ut=W<<m,K=B<<m,xt=H<<m,tt=z<<m,p=M,et=class{_output=null;_upstreamTalkbacks=[];_cachedValue;_flags;_dirtyDeps;_eqFn;_deps;_fn;get _status(){return G(this._flags)}constructor(t,s,e,i){this._deps=t,this._fn=s,this._eqFn=e?.equals,this._flags=i?dt:0,this._dirtyDeps=new V(t.length),this.source=this.source.bind(this),x.register(this,{kind:"derived",...e,deps:t});for(let r of t)x.registerEdge(r,this)}_dispatch(t,s){let e=this._output;if(e)if(this._flags&A)for(let i of e)i(t,s);else e(t,s)}_recompute(){let t;try{t=this._fn()}catch(s){this._handleEnd(s);return}if(this._eqFn&&this._flags&N&&this._eqFn(this._cachedValue,t)){this._flags=this._flags&~p|K,this._dispatch(d,y);return}this._cachedValue=t,this._flags=(this._flags|N)&~p|ut,this._dispatch(g,this._cachedValue)}_recomputeIdentity(t){if(!(this._flags&b)){if(this._eqFn&&this._flags&N&&this._eqFn(this._cachedValue,t)){this._flags=this._flags&~p|K,this._dispatch(d,y);return}this._cachedValue=t,this._flags=(this._flags|N)&~p|ut,this._dispatch(g,t)}}_lazyConnect(){if(!(this._flags&(I|b))){try{this._cachedValue=this._fn()}catch(t){this._handleEnd(t);return}this._flags=(this._flags|N)&~p|ut,Q(),this._connectUpstream(),this._flags&b||(this._flags|=I),X()}}_connectUpstream(){this._upstreamTalkbacks.length=0,this._deps.length===1?this._flags&dt?this._connectSingleDepIdentity():this._connectSingleDep():this._connectMultiDep()}_connectSingleDep(){let t=!1;this._deps[0].source(h,(s,e)=>{if(s===h){this._upstreamTalkbacks.push(e),e(d,$);return}this._flags&b||(s===d?e===_?(t=!0,this._flags=this._flags&~p|O,this._dispatch(d,_)):e===y?t&&(t=!1,this._flags=this._flags&~p|K,this._dispatch(d,y)):this._dispatch(d,e):s===g?t?(t=!1,this._recompute()):(this._flags=this._flags&~p|O,this._dispatch(d,_),this._recompute()):s===f&&this._handleEnd(e))})}_connectSingleDepIdentity(){let t=!1;this._deps[0].source(h,(s,e)=>{if(s===h){this._upstreamTalkbacks.push(e),e(d,$);return}this._flags&b||(s===d?e===_?(t=!0,this._flags=this._flags&~p|O,this._dispatch(d,_)):e===y?t&&(t=!1,this._flags=this._flags&~p|K,this._dispatch(d,y)):this._dispatch(d,e):s===g?t?(t=!1,this._recomputeIdentity(e)):(this._flags=this._flags&~p|O,this._dispatch(d,_),this._recomputeIdentity(e)):s===f&&this._handleEnd(e))})}_connectMultiDep(){for(let t=0;t<this._deps.length&&!(this._flags&b);t++){let s=t;this._deps[s].source(h,(e,i)=>{if(e===h){this._upstreamTalkbacks.push(i);return}if(!(this._flags&b))if(e===d)if(i===_){let r=this._dirtyDeps.empty();this._dirtyDeps.set(s),r&&(this._flags&=~P,this._flags=this._flags&~p|O,this._dispatch(d,_))}else i===y?this._dirtyDeps.test(s)&&(this._dirtyDeps.clear(s),this._dirtyDeps.empty()&&(this._flags&P?this._recompute():(this._flags=this._flags&~p|K,this._dispatch(d,y)))):this._dispatch(d,i);else e===g?this._dirtyDeps.test(s)?(this._dirtyDeps.clear(s),this._flags|=P,this._dirtyDeps.empty()&&this._recompute()):this._dirtyDeps.empty()?(this._flags=this._flags&~p|O,this._dispatch(d,_),this._recompute()):this._flags|=P:e===f&&this._handleEnd(i)})}}_handleEnd(t){this._flags|=b,this._flags=this._flags&~p|(t!==void 0?tt:xt),t!==void 0&&(this._cachedValue=t);for(let i of this._upstreamTalkbacks)i(f);this._upstreamTalkbacks=[],this._flags&=~I,this._dirtyDeps.reset();let s=this._output,e=this._flags&A;if(this._output=null,this._flags&=~A,s)if(e)for(let i of s)try{t!==void 0?i(f,t):i(f)}catch{}else t!==void 0?s(f,t):s(f)}_disconnectUpstream(){for(let t of this._upstreamTalkbacks)t(f);this._upstreamTalkbacks.length=0,this._flags&=~(I|P),this._flags=this._flags&~p|kt,this._dirtyDeps.reset()}get(){if(this._flags&I)return this._cachedValue;if(this._flags&b){if((this._flags&p)===tt)throw this._cachedValue;return this._cachedValue}let t=this._fn();return this._cachedValue=t,this._flags|=N,t}source(t,s){if(t===h){let e=s;if(this._flags&b){let i=(this._flags&p)===tt;e(h,r=>{}),i?e(f,this._cachedValue):e(f);return}if(!(this._flags&I)&&(this._lazyConnect(),this._flags&b)){let i=(this._flags&p)===tt;e(h,r=>{}),i?e(f,this._cachedValue):e(f);return}if(this._output===null)this._output=e;else if(this._flags&A)this._output.add(e);else{let i=new Set;i.add(this._output),i.add(e),this._output=i,this._flags|=A}e(h,i=>{if(i===g&&e(g,this._cachedValue),i===f){if(this._output===null)return;if(this._flags&A){let r=this._output;r.delete(e),r.size===1?(this._output=r.values().next().value,this._flags&=~A):r.size===0&&(this._output=null,this._flags&=~A,this._disconnectUpstream())}else this._output===e&&(this._output=null,this._disconnectUpstream())}})}}};function st(n,t,s){return new et(n,t,s)}(t=>{function n(s,e){return new et([s],()=>s.get(),e,!0)}t.from=n})(st||={});var nt=1,E=64,D=2,C=4,ht=8,_t=16,R=32,k=1024,T=M,L=q<<m,j=W<<m,it=Y<<m,At=H<<m,Rt=z<<m,wt=B<<m,rt=class{_value;_output=null;_flags;get _status(){return G(this._flags)}_cleanup;_fn;_eqFn;_getterFn;_initial;_singleDepCount=0;constructor(t,s){this._value=s?.initial,this._fn=t,this._eqFn=s?.equals,this._getterFn=s?.getter,this._initial=s?.initial;let e=0;s?.autoDirty!==!1&&(e|=C),s?.resetOnTeardown&&(e|=ht),s?.resubscribable&&(e|=_t),this._flags=e,this.source=this.source.bind(this),this.emit=this.emit.bind(this),s?._skipInspect||x.register(this,{kind:"producer",...s})}get(){return this._getterFn?this._getterFn(this._value):this._value}_dispatch(t,s){let e=this._output;if(e)if(this._flags&E)for(let i of e)i(t,s);else e(t,s)}emit(t){this._flags&D||this._eqFn&&this._value!==void 0&&this._eqFn(this._value,t)||(this._value=t,this._output&&(J()?this._flags&R||(this._flags|=R,this._flags&C&&(this._flags=this._flags&~T|L,this._dispatch(d,_)),Z(()=>{this._flags&=~R,this._flags=this._flags&~T|j,this._dispatch(g,this._value)})):(this._flags&C&&!(this._flags&k)&&(this._flags=this._flags&~T|L,this._dispatch(d,_)),this._flags=this._flags&~T|j,this._dispatch(g,this._value))))}signal(t){this._flags&D||!this._output||(t===_?this._flags=this._flags&~T|L:t===y&&(this._flags=this._flags&~T|wt),this._dispatch(d,t))}complete(){if(this._flags&D)return;this._flags=(this._flags|D)&~T|At;let t=this._output,s=this._flags&E;if(this._output=null,this._flags&=~(E|k),this._singleDepCount=0,this._stop(),t)if(s)for(let e of t)e(f);else t(f)}error(t){if(this._flags&D)return;this._flags=(this._flags|D)&~T|Rt;let s=this._output,e=this._flags&E;if(this._output=null,this._flags&=~(E|k),this._singleDepCount=0,this._stop(),s)if(e)for(let i of s)i(f,t);else s(f,t)}_start(){if(this._flags&nt||!this._fn)return;this._flags|=nt;let t=this._fn({emit:this.emit,signal:s=>this.signal(s),complete:()=>this.complete(),error:s=>this.error(s)});this._cleanup=typeof t=="function"?t:void 0}_stop(){this._flags&nt&&(this._flags&=~nt,this._cleanup&&this._cleanup(),this._cleanup=void 0,this._flags&ht&&(this._value=this._initial),this._flags&D||(this._flags=this._flags&~T|it))}source(t,s){if(t===h){let e=s;if(this._flags&D)if(this._flags&_t&&this._output===null)this._flags=this._flags&~(D|T)|it;else{e(h,r=>{}),e(f);return}if(this._output===null)this._output=e;else if(this._flags&E)this._output.add(e);else{let r=new Set;r.add(this._output),r.add(e),this._output=r,this._flags=(this._flags|E)&~k}let i=!1;e(h,(r,o)=>{if(r===g&&e(g,this._value),r===d&&o===$&&!i&&(i=!0,this._singleDepCount++,this._flags&E||(this._flags|=k)),r===f){if(i&&(i=!1,this._singleDepCount--),this._output===null)return;if(this._flags&E){let a=this._output;a.delete(e),a.size===1?(this._output=a.values().next().value,this._flags&=~E,this._singleDepCount>0&&(this._flags|=k)):a.size===0&&(this._output=null,this._flags&=~(E|k),this._singleDepCount=0,this._flags=this._flags&~T|it,this._stop())}else this._output===e&&(this._output=null,this._flags&=~k,this._singleDepCount=0,this._flags=this._flags&~T|it,this._stop())}}),ft(()=>this._start())}}};var lt=class extends rt{constructor(t,s){super(void 0,{initial:t,autoDirty:!0,equals:s?.equals??Object.is,_skipInspect:!0}),this.set=this.set.bind(this),x.register(this,{kind:"state",...s})}get(){return this._value}set(t){this._flags&D||this._value!==void 0&&this._eqFn(this._value,t)||(this._value=t,this._output&&(J()?this._flags&R||(this._flags|=R,this._flags&C&&(this._flags=this._flags&~T|L,this._dispatch(d,_)),Z(()=>{this._flags&=~R,this._flags=this._flags&~T|j,this._dispatch(g,this._value)})):(this._flags&C&&!(this._flags&k)&&(this._flags=this._flags&~T|L,this._dispatch(d,_)),this._flags=this._flags&~T|j,this._dispatch(g,this._value))))}update(t){this.set(t(this._value))}};function ct(n,t){return new lt(n,t)}function w(n,t,s){let e=null;Q(),n.source(h,(r,o)=>{if(r===h&&(e=o),r===f){e=null,s?.onEnd?.(o);return}if(r===1){let a=o,u=i;i=a,t(a,u)}});let i;try{i=n.get()}catch{}return X(),()=>e?.(f)}function Nt(n){let t=ct(n);return{get:()=>t.get(),set:s=>t.set(s),subscribe:s=>{let e=w(t,i=>s(i));return s(t.get()),e},listen:s=>w(t,e=>s(e)),store:t}}function It(n,t){let s=Array.isArray(n)?n:[n],e=s.map(r=>r.store),i=st(e,()=>t(...s.map(r=>r.get())),{equals:Object.is});return{get:()=>i.get(),subscribe:r=>{let o=w(i,a=>r(a));return r(i.get()),o},listen:r=>w(i,o=>r(o)),store:i}}function Ot(n){let t=ct(n,{equals:()=>!1});return{get:()=>t.get(),set:s=>t.set(s),setKey:(s,e)=>{t.set({...t.get(),[s]:e})},subscribe:s=>{let e=w(t,i=>s(i));return s(t.get()),e},listen:s=>w(t,e=>s(e)),store:t}}0&&(module.exports={atom,computed,map});
|
|
4
|
+
`)}static annotate(t,s){if(!n.enabled)return;n._annotations.set(t,s);let e={node:n._resolveKey(t),reason:s,timestamp:Date.now()},i=n.maxTraceEntries;i<=0||(n._traceLog.length<i?n._traceLog.push(e):(n._traceLog[n._traceHead]=e,n._traceFull=!0),n._traceHead=(n._traceHead+1)%i)}static getAnnotation(t){return n._annotations.get(t)}static traceLog(){return n._traceFull?[...n._traceLog.slice(n._traceHead),...n._traceLog.slice(0,n._traceHead)]:n._traceLog.slice(0,n._traceHead||n._traceLog.length)}static clearTrace(){n._traceLog=[],n._traceHead=0,n._traceFull=!1}static _reset(){n._names=new WeakMap,n._kinds=new WeakMap,n._keys=new WeakMap,n._stores=new Set,n._edges=new Map,n._usedKeys=new Set,n._nextId=0,n._explicitEnabled=null,n._cachedDefault=null,n._annotations=new WeakMap,n._traceLog=[],n._traceHead=0,n._traceFull=!1,n.maxTraceEntries=1e3}};var N=1,I=2,P=4,b=8,A=32,dt=64,kt=Y<<m,O=q<<m,ut=W<<m,K=B<<m,xt=H<<m,tt=z<<m,p=M,et=class{_output=null;_upstreamTalkbacks=[];_cachedValue;_flags;_dirtyDeps;_eqFn;_deps;_fn;get _status(){return G(this._flags)}constructor(t,s,e,i){this._deps=t,this._fn=s,this._eqFn=e?.equals,this._flags=i?dt:0,this._dirtyDeps=new V(t.length),this.source=this.source.bind(this),x.register(this,{kind:"derived",...e,deps:t});for(let r of t)x.registerEdge(r,this)}_dispatch(t,s){let e=this._output;if(e)if(this._flags&A)for(let i of e)i(t,s);else e(t,s)}_recompute(){let t;try{t=this._fn()}catch(s){this._handleEnd(s);return}if(this._eqFn&&this._flags&N&&this._eqFn(this._cachedValue,t)){this._flags=this._flags&~p|K,this._dispatch(d,y);return}this._cachedValue=t,this._flags=(this._flags|N)&~p|ut,this._dispatch(g,this._cachedValue)}_recomputeIdentity(t){if(!(this._flags&b)){if(this._eqFn&&this._flags&N&&this._eqFn(this._cachedValue,t)){this._flags=this._flags&~p|K,this._dispatch(d,y);return}this._cachedValue=t,this._flags=(this._flags|N)&~p|ut,this._dispatch(g,t)}}_lazyConnect(){if(!(this._flags&(I|b))){try{this._cachedValue=this._fn()}catch(t){this._handleEnd(t);return}this._flags=(this._flags|N)&~p|ut,Q(),this._connectUpstream(),this._flags&b||(this._flags|=I),X()}}_connectUpstream(){this._upstreamTalkbacks.length=0,this._deps.length===1?this._flags&dt?this._connectSingleDepIdentity():this._connectSingleDep():this._connectMultiDep()}_connectSingleDep(){let t=!1;this._deps[0].source(h,(s,e)=>{if(s===h){this._upstreamTalkbacks.push(e),e(d,$);return}if(!(this._flags&b))if(s===d)if(e===_){if(t)return;t=!0,this._flags=this._flags&~p|O,this._dispatch(d,_)}else e===y?t&&(t=!1,this._flags=this._flags&~p|K,this._dispatch(d,y)):this._dispatch(d,e);else s===g?t?(t=!1,this._recompute()):(this._flags=this._flags&~p|O,this._dispatch(d,_),this._recompute()):s===f&&this._handleEnd(e)})}_connectSingleDepIdentity(){let t=!1;this._deps[0].source(h,(s,e)=>{if(s===h){this._upstreamTalkbacks.push(e),e(d,$);return}this._flags&b||(s===d?e===_?(t=!0,this._flags=this._flags&~p|O,this._dispatch(d,_)):e===y?t&&(t=!1,this._flags=this._flags&~p|K,this._dispatch(d,y)):this._dispatch(d,e):s===g?t?(t=!1,this._recomputeIdentity(e)):(this._flags=this._flags&~p|O,this._dispatch(d,_),this._recomputeIdentity(e)):s===f&&this._handleEnd(e))})}_connectMultiDep(){for(let t=0;t<this._deps.length&&!(this._flags&b);t++){let s=t;this._deps[s].source(h,(e,i)=>{if(e===h){this._upstreamTalkbacks.push(i);return}if(!(this._flags&b))if(e===d)if(i===_){let r=this._dirtyDeps.empty();this._dirtyDeps.set(s),r&&(this._flags&=~P,this._flags=this._flags&~p|O,this._dispatch(d,_))}else i===y?this._dirtyDeps.test(s)&&(this._dirtyDeps.clear(s),this._dirtyDeps.empty()&&(this._flags&P?this._recompute():(this._flags=this._flags&~p|K,this._dispatch(d,y)))):this._dispatch(d,i);else e===g?this._dirtyDeps.test(s)?(this._dirtyDeps.clear(s),this._flags|=P,this._dirtyDeps.empty()&&this._recompute()):this._dirtyDeps.empty()?(this._flags=this._flags&~p|O,this._dispatch(d,_),this._recompute()):this._flags|=P:e===f&&this._handleEnd(i)})}}_handleEnd(t){this._flags|=b,this._flags=this._flags&~p|(t!==void 0?tt:xt),t!==void 0&&(this._cachedValue=t);for(let i of this._upstreamTalkbacks)i(f);this._upstreamTalkbacks=[],this._flags&=~I,this._dirtyDeps.reset();let s=this._output,e=this._flags&A;if(this._output=null,this._flags&=~A,s)if(e)for(let i of s)try{t!==void 0?i(f,t):i(f)}catch{}else t!==void 0?s(f,t):s(f)}_disconnectUpstream(){for(let t of this._upstreamTalkbacks)t(f);this._upstreamTalkbacks.length=0,this._flags&=~(I|P),this._flags=this._flags&~p|kt,this._dirtyDeps.reset()}get(){if(this._flags&I)return this._cachedValue;if(this._flags&b){if((this._flags&p)===tt)throw this._cachedValue;return this._cachedValue}let t=this._fn();return this._cachedValue=t,this._flags|=N,t}source(t,s){if(t===h){let e=s;if(this._flags&b){let i=(this._flags&p)===tt;e(h,r=>{}),i?e(f,this._cachedValue):e(f);return}if(!(this._flags&I)&&(this._lazyConnect(),this._flags&b)){let i=(this._flags&p)===tt;e(h,r=>{}),i?e(f,this._cachedValue):e(f);return}if(this._output===null)this._output=e;else if(this._flags&A)this._output.add(e);else{let i=new Set;i.add(this._output),i.add(e),this._output=i,this._flags|=A}e(h,i=>{if(i===g&&e(g,this._cachedValue),i===f){if(this._output===null)return;if(this._flags&A){let r=this._output;r.delete(e),r.size===1?(this._output=r.values().next().value,this._flags&=~A):r.size===0&&(this._output=null,this._flags&=~A,this._disconnectUpstream())}else this._output===e&&(this._output=null,this._disconnectUpstream())}})}}};function st(n,t,s){return new et(n,t,s)}(t=>{function n(s,e){return new et([s],()=>s.get(),e,!0)}t.from=n})(st||={});var nt=1,E=64,D=2,C=4,ht=8,_t=16,R=32,k=1024,T=M,L=q<<m,j=W<<m,it=Y<<m,At=H<<m,Rt=z<<m,wt=B<<m,rt=class{_value;_output=null;_flags;get _status(){return G(this._flags)}_cleanup;_fn;_eqFn;_getterFn;_initial;_singleDepCount=0;constructor(t,s){this._value=s?.initial,this._fn=t,this._eqFn=s?.equals,this._getterFn=s?.getter,this._initial=s?.initial;let e=0;s?.autoDirty!==!1&&(e|=C),s?.resetOnTeardown&&(e|=ht),s?.resubscribable&&(e|=_t),this._flags=e,this.source=this.source.bind(this),this.emit=this.emit.bind(this),s?._skipInspect||x.register(this,{kind:"producer",...s})}get(){return this._getterFn?this._getterFn(this._value):this._value}_dispatch(t,s){let e=this._output;if(e)if(this._flags&E)for(let i of e)i(t,s);else e(t,s)}emit(t){this._flags&D||this._eqFn&&this._value!==void 0&&this._eqFn(this._value,t)||(this._value=t,this._output&&(J()?this._flags&R||(this._flags|=R,this._flags&C&&(this._flags=this._flags&~T|L,this._dispatch(d,_)),Z(()=>{this._flags&=~R,this._flags=this._flags&~T|j,this._dispatch(g,this._value)})):(this._flags&C&&!(this._flags&k)&&(this._flags=this._flags&~T|L,this._dispatch(d,_)),this._flags=this._flags&~T|j,this._dispatch(g,this._value))))}signal(t){this._flags&D||!this._output||(t===_?this._flags=this._flags&~T|L:t===y&&(this._flags=this._flags&~T|wt),this._dispatch(d,t))}complete(){if(this._flags&D)return;this._flags=(this._flags|D)&~T|At;let t=this._output,s=this._flags&E;if(this._output=null,this._flags&=~(E|k),this._singleDepCount=0,this._stop(),t)if(s)for(let e of t)e(f);else t(f)}error(t){if(this._flags&D)return;this._flags=(this._flags|D)&~T|Rt;let s=this._output,e=this._flags&E;if(this._output=null,this._flags&=~(E|k),this._singleDepCount=0,this._stop(),s)if(e)for(let i of s)i(f,t);else s(f,t)}_start(){if(this._flags&nt||!this._fn)return;this._flags|=nt;let t=this._fn({emit:this.emit,signal:s=>this.signal(s),complete:()=>this.complete(),error:s=>this.error(s)});this._cleanup=typeof t=="function"?t:void 0}_stop(){this._flags&nt&&(this._flags&=~nt,this._cleanup&&this._cleanup(),this._cleanup=void 0,this._flags&ht&&(this._value=this._initial),this._flags&D||(this._flags=this._flags&~T|it))}source(t,s){if(t===h){let e=s;if(this._flags&D)if(this._flags&_t&&this._output===null)this._flags=this._flags&~(D|T)|it;else{e(h,r=>{}),e(f);return}if(this._output===null)this._output=e;else if(this._flags&E)this._output.add(e);else{let r=new Set;r.add(this._output),r.add(e),this._output=r,this._flags=(this._flags|E)&~k}let i=!1;e(h,(r,o)=>{if(r===g&&e(g,this._value),r===d&&o===$&&!i&&(i=!0,this._singleDepCount++,this._flags&E||(this._flags|=k)),r===f){if(i&&(i=!1,this._singleDepCount--),this._output===null)return;if(this._flags&E){let a=this._output;a.delete(e),a.size===1?(this._output=a.values().next().value,this._flags&=~E,this._singleDepCount>0&&(this._flags|=k)):a.size===0&&(this._output=null,this._flags&=~(E|k),this._singleDepCount=0,this._flags=this._flags&~T|it,this._stop())}else this._output===e&&(this._output=null,this._flags&=~k,this._singleDepCount=0,this._flags=this._flags&~T|it,this._stop())}}),ft(()=>this._start())}}};var lt=class extends rt{constructor(t,s){super(void 0,{initial:t,autoDirty:!0,equals:s?.equals??Object.is,_skipInspect:!0}),this.set=this.set.bind(this),x.register(this,{kind:"state",...s})}get(){return this._value}set(t){this._flags&D||this._value!==void 0&&this._eqFn(this._value,t)||(this._value=t,this._output&&(J()?this._flags&R||(this._flags|=R,this._flags&C&&(this._flags=this._flags&~T|L,this._dispatch(d,_)),Z(()=>{this._flags&=~R,this._flags=this._flags&~T|j,this._dispatch(g,this._value)})):(this._flags&C&&!(this._flags&k)&&(this._flags=this._flags&~T|L,this._dispatch(d,_)),this._flags=this._flags&~T|j,this._dispatch(g,this._value))))}update(t){this.set(t(this._value))}};function ct(n,t){return new lt(n,t)}function w(n,t,s){let e=null;Q(),n.source(h,(r,o)=>{if(r===h&&(e=o),r===f){e=null,s?.onEnd?.(o);return}if(r===1){let a=o,u=i;i=a,t(a,u)}});let i;try{i=n.get()}catch{}return X(),()=>e?.(f)}function Nt(n){let t=ct(n);return{get:()=>t.get(),set:s=>t.set(s),subscribe:s=>{let e=w(t,i=>s(i));return s(t.get()),e},listen:s=>w(t,e=>s(e)),store:t}}function It(n,t){let s=Array.isArray(n)?n:[n],e=s.map(r=>r.store),i=st(e,()=>t(...s.map(r=>r.get())),{equals:Object.is});return{get:()=>i.get(),subscribe:r=>{let o=w(i,a=>r(a));return r(i.get()),o},listen:r=>w(i,o=>r(o)),store:i}}function Ot(n){let t=ct(n,{equals:()=>!1});return{get:()=>t.get(),set:s=>t.set(s),setKey:(s,e)=>{t.set({...t.get(),[s]:e})},subscribe:s=>{let e=w(t,i=>s(i));return s(t.get()),e},listen:s=>w(t,e=>s(e)),store:t}}0&&(module.exports={atom,computed,map});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as T}from"../../chunk-
|
|
1
|
+
import{a as T}from"../../chunk-X575NBLE.js";import"../../chunk-HK7DRUNM.js";import{a as s}from"../../chunk-YJXCVG35.js";import{a as i}from"../../chunk-P5MXN4AF.js";import"../../chunk-YN4VWXAF.js";import"../../chunk-M76W372U.js";import"../../chunk-CWP55MPE.js";import"../../chunk-I7AUKTXE.js";function v(a){let o=i(a);return{get:()=>o.get(),set:e=>o.set(e),subscribe:e=>{let t=s(o,n=>e(n));return e(o.get()),t},listen:e=>s(o,t=>e(t)),store:o}}function b(a,o){let e=Array.isArray(a)?a:[a],t=e.map(r=>r.store),n=T(t,()=>o(...e.map(r=>r.get())),{equals:Object.is});return{get:()=>n.get(),subscribe:r=>{let u=s(n,d=>r(d));return r(n.get()),u},listen:r=>s(n,u=>r(u)),store:n}}function l(a){let o=i(a,{equals:()=>!1});return{get:()=>o.get(),set:e=>o.set(e),setKey:(e,t)=>{o.set({...o.get(),[e]:t})},subscribe:e=>{let t=s(o,n=>e(n));return e(o.get()),t},listen:e=>s(o,t=>e(t)),store:o}}export{v as atom,b as computed,l as map};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";var ut=Object.defineProperty;var Dt=Object.getOwnPropertyDescriptor;var kt=Object.getOwnPropertyNames;var xt=Object.prototype.hasOwnProperty;var Rt=(s,t)=>{for(var n in t)ut(s,n,{get:t[n],enumerable:!0})},wt=(s,t,n,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of kt(t))!xt.call(s,i)&&i!==n&&ut(s,i,{get:()=>t[i],enumerable:!(e=Dt(t,i))||e.enumerable});return s};var It=s=>wt(ut({},"__esModule",{value:!0}),s);var Vt={};Rt(Vt,{Signal:()=>Mt,batch:()=>gt,signalEffect:()=>Pt});module.exports=It(Vt);var O=class{_v;_w;constructor(t){this._v=0,this._w=t>32?new Uint32Array((t-1>>>5)+1):null}set(t){let n=this._w;if(n===null)this._v|=1<<t;else{let e=t>>>5,i=1<<(t&31);n[e]&i||(n[e]|=i,this._v++)}}clear(t){let n=this._w;if(n===null)this._v&=~(1<<t);else{let e=t>>>5,i=1<<(t&31);n[e]&i&&(n[e]&=~i,this._v--)}}test(t){let n=this._w;return n===null?(this._v&1<<t)!==0:(n[t>>>5]&1<<(t&31))!==0}empty(){return this._v===0}reset(){this._v=0,this._w?.fill(0)}};var _=Symbol("DIRTY"),v=Symbol("RESOLVED"),I=Symbol("SINGLE_DEP"),z=0,G=1,B=2,J=3,Z=4,Q=5,y=7,j=7<<y,At=["DISCONNECTED","DIRTY","SETTLED","RESOLVED","COMPLETED","ERRORED"];function X(s){return At[(s&j)>>>y]}var h=0,g=1,c=2,d=3,U=0,q=[],ft=!1;function gt(s){U++;try{return s()}finally{if(U--,U===0&&!ft){ft=!0;for(let t=0;t<q.length;t++)q[t]();q.length=0,ft=!1}}}function tt(){return U>0}function et(s){q.push(s)}var H=0,W=[];function L(){H++}function C(){if(H--,H===0){for(let s=0;s<W.length;s++)W[s]();W.length=0}}function Tt(s){H>0?W.push(s):s()}var E=class s{static _names=new WeakMap;static _kinds=new WeakMap;static _keys=new WeakMap;static _stores=new Set;static _edges=new Map;static _nextId=0;static _usedKeys=new Set;static _explicitEnabled=null;static _cachedDefault=null;static _annotations=new WeakMap;static _traceLog=[];static _traceHead=0;static _traceFull=!1;static maxTraceEntries=1e3;static get enabled(){if(s._explicitEnabled!==null)return s._explicitEnabled;if(s._cachedDefault!==null)return s._cachedDefault;try{s._cachedDefault=globalThis.process?.env?.NODE_ENV!=="production"}catch{s._cachedDefault=!0}return s._cachedDefault}static set enabled(t){s._explicitEnabled=t}static _depSuffix(t){if(!t?.length)return;let e=t.map(i=>s._names.get(i)??"?").join(",");return e.length>40?`${e.slice(0,37)}...`:e}static _resolveKey(t){let n=s._keys.get(t)??s._names.get(t);if(n)return n;let e=`anonymous_${s._nextId++}`;return s._keys.set(t,e),e}static register(t,n){if(!s.enabled)return;n?.name&&s._names.set(t,n.name),n?.kind&&s._kinds.set(t,n.kind);let e=s._nextId++,i=n?.name;if(!(i&&!s._usedKeys.has(i)))if(i){let r=s._depSuffix(n?.deps);i=r?`${i}(${r})`:`${i}_${e}`,s._usedKeys.has(i)&&(i=`${i}_${e}`)}else{let r=n?.kind??"store",o=s._depSuffix(n?.deps);i=o?`${r}(${o})`:`${r}_${e}`,s._usedKeys.has(i)&&(i=`${i}_${e}`)}s._usedKeys.add(i),s._keys.set(t,i),s._stores.add(new WeakRef(t))}static registerEdge(t,n){if(!s.enabled)return;let e=s._resolveKey(t),i=s._resolveKey(n),r=s._edges.get(e);r?r.includes(i)||r.push(i):s._edges.set(e,[i])}static getEdges(){return new Map(s._edges)}static getName(t){if(s.enabled)return s._names.get(t)}static getKind(t){return s._kinds.get(t)}static inspect(t){return{name:s._names.get(t),kind:s._kinds.get(t)??"unknown",value:typeof t.get=="function"?t.get():void 0,status:t._status}}static graph(){let t=new Map,n=new Set;for(let e of s._stores){let i=e.deref();if(!i){s._stores.delete(e);continue}let r=s._resolveKey(i);n.add(r),t.set(r,s.inspect(i))}for(let[e,i]of s._edges){if(!n.has(e)){s._edges.delete(e),s._usedKeys.delete(e);continue}let r=i.filter(o=>n.has(o));r.length===0?s._edges.delete(e):r.length!==i.length&&s._edges.set(e,r)}return t}static trace(t,n){let e=null,i=t.get();return t.source(h,(r,o)=>{if(r===h&&(e=o),r===c){e=null;return}if(r===1){let a=o;if(!Object.is(a,i)){let l=i;i=a,n(a,l)}}}),()=>e?.(c)}static dumpGraph(){let t=s.graph(),n=s.getEdges(),e=new Map;for(let[o,a]of n)for(let l of a){let S=e.get(l);S?S.includes(o)||S.push(o):e.set(l,[o])}let i=[];for(let[o,a]of t){let l=e.get(o),S=n.get(o),u=l?.length?` \u2190 [${l.join(", ")}]`:"",f=S?.length?` \u2192 [${S.join(", ")}]`:"";i.push(` ${o} (${a.kind}) = ${JSON.stringify(a.value)} [${a.status??"?"}]${u}${f}`)}return[`Store Graph (${t.size} nodes):`,...i].join(`
|
|
2
2
|
`)}static _observe(t,n,e){let i=null,r=n??s.getName(t),o={values:[],signals:[],events:[],ended:!1,endError:void 0,dirtyCount:0,resolvedCount:0,name:r,dispose:()=>i?.(c)};return t.source(h,(a,l)=>{if(a===h){i=l;return}a===g?(o.values.push(l),o.events.push({type:"data",data:l}),e&&e(`[${r}] DATA:`,l)):a===d?(o.signals.push(l),o.events.push({type:"signal",data:l}),l===_?o.dirtyCount++:l===v&&o.resolvedCount++,e&&e(`[${r}] STATE:`,l)):a===c&&(o.ended=!0,o.endError=l,o.events.push({type:"end",data:l}),e&&e(`[${r}] END`,l!==void 0?l:""),i=null)}),o}static observe(t){return s._observe(t)}static tap(t,n){let e=n??`tap(${s.getName(t)??"anon"})`,i={get:()=>t.get(),source:t.source};return s.register(i,{name:e,kind:"tap"}),s.registerEdge(t,i),i}static spy(t,n){let e=n?.name??s.getName(t)??"spy",i=n?.log??console.log;return s._observe(t,e,i)}static snapshot(){let t=s.graph(),n=s.getEdges(),e=new Map;for(let o of s._stores){let a=o.deref();if(!a)continue;let l=s._annotations.get(a);l!==void 0&&e.set(s._resolveKey(a),l)}let i=[];for(let[o,a]of t){let l={name:o,kind:a.kind,value:a.value,status:a.status},S=e.get(o);S!==void 0&&(l.annotation=S),i.push(l)}let r=[];for(let[o,a]of n)for(let l of a)r.push({from:o,to:l});return{nodes:i,edges:r,trace:s.traceLog()}}static toMermaid(t){let n=t?.direction??"TD",e=s.snapshot(),i=[`graph ${n}`],r={SETTLED:":::settled",DIRTY:":::dirty",ERRORED:":::errored",COMPLETED:":::completed"},o=new Map;function a(u){let f=u.replace(/[^a-zA-Z0-9_]/g,"_"),p=o.get(f);return p===void 0?(o.set(f,1),f):(o.set(f,p+1),`${f}__${p}`)}let l=new Map;function S(u){let f=JSON.stringify(u);return f&&f.length>30?`${f.slice(0,27)}...`:f??"undefined"}for(let u of e.nodes){let f=a(u.name);l.set(u.name,f);let p=`${u.name} (${u.kind}) = ${S(u.value)}`,R=r[u.status??""]??"";i.push(` ${f}["${p}"]${R}`)}for(let u of e.edges){let f=l.get(u.from)??a(u.from),p=l.get(u.to)??a(u.to);i.push(` ${f} --> ${p}`)}return i.push(""),i.push(" classDef settled fill:#d4edda,stroke:#28a745"),i.push(" classDef dirty fill:#fff3cd,stroke:#ffc107"),i.push(" classDef errored fill:#f8d7da,stroke:#dc3545"),i.push(" classDef completed fill:#cce5ff,stroke:#007bff"),i.join(`
|
|
3
3
|
`)}static toD2(t){let n=t?.direction??"down",e=s.snapshot(),i=[`direction: ${n}`,""],r={state:"rectangle",derived:"hexagon",effect:"oval",producer:"rectangle",operator:"parallelogram","pipeline-step":"rectangle","pipeline-status":"diamond",checkpoint:"cylinder"},o=new Map;function a(u){let f=u.replace(/[^a-zA-Z0-9_]/g,"_"),p=o.get(f);return p===void 0?(o.set(f,1),f):(o.set(f,p+1),`${f}__${p}`)}let l=new Map;function S(u){let f=JSON.stringify(u);return f&&f.length>30?`${f.slice(0,27)}...`:f??"undefined"}for(let u of e.nodes){let f=a(u.name);l.set(u.name,f);let p=r[u.kind]??"rectangle",R=`${u.name} (${u.kind}) = ${S(u.value)}`,lt=u.status?` [${u.status}]`:"";i.push(`${f}: "${R}${lt}" { shape: ${p} }`)}e.edges.length>0&&i.push("");for(let u of e.edges){let f=l.get(u.from)??a(u.from),p=l.get(u.to)??a(u.to);i.push(`${f} -> ${p}`)}return i.join(`
|
|
4
|
-
`)}static annotate(t,n){if(!s.enabled)return;s._annotations.set(t,n);let e={node:s._resolveKey(t),reason:n,timestamp:Date.now()},i=s.maxTraceEntries;i<=0||(s._traceLog.length<i?s._traceLog.push(e):(s._traceLog[s._traceHead]=e,s._traceFull=!0),s._traceHead=(s._traceHead+1)%i)}static getAnnotation(t){return s._annotations.get(t)}static traceLog(){return s._traceFull?[...s._traceLog.slice(s._traceHead),...s._traceLog.slice(0,s._traceHead)]:s._traceLog.slice(0,s._traceHead||s._traceLog.length)}static clearTrace(){s._traceLog=[],s._traceHead=0,s._traceFull=!1}static _reset(){s._names=new WeakMap,s._kinds=new WeakMap,s._keys=new WeakMap,s._stores=new Set,s._edges=new Map,s._usedKeys=new Set,s._nextId=0,s._explicitEnabled=null,s._cachedDefault=null,s._annotations=new WeakMap,s._traceLog=[],s._traceHead=0,s._traceFull=!1,s.maxTraceEntries=1e3}};var $=1,N=2,F=4,b=8,w=32,St=64,Ot=z<<y,M=G<<y,ct=B<<y,K=J<<y,Lt=Z<<y,st=Q<<y,T=j,nt=class{_output=null;_upstreamTalkbacks=[];_cachedValue;_flags;_dirtyDeps;_eqFn;_deps;_fn;get _status(){return X(this._flags)}constructor(t,n,e,i){this._deps=t,this._fn=n,this._eqFn=e?.equals,this._flags=i?St:0,this._dirtyDeps=new O(t.length),this.source=this.source.bind(this),E.register(this,{kind:"derived",...e,deps:t});for(let r of t)E.registerEdge(r,this)}_dispatch(t,n){let e=this._output;if(e)if(this._flags&w)for(let i of e)i(t,n);else e(t,n)}_recompute(){let t;try{t=this._fn()}catch(n){this._handleEnd(n);return}if(this._eqFn&&this._flags&$&&this._eqFn(this._cachedValue,t)){this._flags=this._flags&~T|K,this._dispatch(d,v);return}this._cachedValue=t,this._flags=(this._flags|$)&~T|ct,this._dispatch(g,this._cachedValue)}_recomputeIdentity(t){if(!(this._flags&b)){if(this._eqFn&&this._flags&$&&this._eqFn(this._cachedValue,t)){this._flags=this._flags&~T|K,this._dispatch(d,v);return}this._cachedValue=t,this._flags=(this._flags|$)&~T|ct,this._dispatch(g,t)}}_lazyConnect(){if(!(this._flags&(N|b))){try{this._cachedValue=this._fn()}catch(t){this._handleEnd(t);return}this._flags=(this._flags|$)&~T|ct,L(),this._connectUpstream(),this._flags&b||(this._flags|=N),C()}}_connectUpstream(){this._upstreamTalkbacks.length=0,this._deps.length===1?this._flags&St?this._connectSingleDepIdentity():this._connectSingleDep():this._connectMultiDep()}_connectSingleDep(){let t=!1;this._deps[0].source(h,(n,e)=>{if(n===h){this._upstreamTalkbacks.push(e),e(d,I);return}this._flags&b||(n===d?e===_?(t=!0,this._flags=this._flags&~T|M,this._dispatch(d,_)):e===v?t&&(t=!1,this._flags=this._flags&~T|K,this._dispatch(d,v)):this._dispatch(d,e):n===g?t?(t=!1,this._recompute()):(this._flags=this._flags&~T|M,this._dispatch(d,_),this._recompute()):n===c&&this._handleEnd(e))})}_connectSingleDepIdentity(){let t=!1;this._deps[0].source(h,(n,e)=>{if(n===h){this._upstreamTalkbacks.push(e),e(d,I);return}this._flags&b||(n===d?e===_?(t=!0,this._flags=this._flags&~T|M,this._dispatch(d,_)):e===v?t&&(t=!1,this._flags=this._flags&~T|K,this._dispatch(d,v)):this._dispatch(d,e):n===g?t?(t=!1,this._recomputeIdentity(e)):(this._flags=this._flags&~T|M,this._dispatch(d,_),this._recomputeIdentity(e)):n===c&&this._handleEnd(e))})}_connectMultiDep(){for(let t=0;t<this._deps.length&&!(this._flags&b);t++){let n=t;this._deps[n].source(h,(e,i)=>{if(e===h){this._upstreamTalkbacks.push(i);return}if(!(this._flags&b))if(e===d)if(i===_){let r=this._dirtyDeps.empty();this._dirtyDeps.set(n),r&&(this._flags&=~F,this._flags=this._flags&~T|M,this._dispatch(d,_))}else i===v?this._dirtyDeps.test(n)&&(this._dirtyDeps.clear(n),this._dirtyDeps.empty()&&(this._flags&F?this._recompute():(this._flags=this._flags&~T|K,this._dispatch(d,v)))):this._dispatch(d,i);else e===g?this._dirtyDeps.test(n)?(this._dirtyDeps.clear(n),this._flags|=F,this._dirtyDeps.empty()&&this._recompute()):this._dirtyDeps.empty()?(this._flags=this._flags&~T|M,this._dispatch(d,_),this._recompute()):this._flags|=F:e===c&&this._handleEnd(i)})}}_handleEnd(t){this._flags|=b,this._flags=this._flags&~T|(t!==void 0?st:Lt),t!==void 0&&(this._cachedValue=t);for(let i of this._upstreamTalkbacks)i(c);this._upstreamTalkbacks=[],this._flags&=~N,this._dirtyDeps.reset();let n=this._output,e=this._flags&w;if(this._output=null,this._flags&=~w,n)if(e)for(let i of n)try{t!==void 0?i(c,t):i(c)}catch{}else t!==void 0?n(c,t):n(c)}_disconnectUpstream(){for(let t of this._upstreamTalkbacks)t(c);this._upstreamTalkbacks.length=0,this._flags&=~(N|F),this._flags=this._flags&~T|Ot,this._dirtyDeps.reset()}get(){if(this._flags&N)return this._cachedValue;if(this._flags&b){if((this._flags&T)===st)throw this._cachedValue;return this._cachedValue}let t=this._fn();return this._cachedValue=t,this._flags|=$,t}source(t,n){if(t===h){let e=n;if(this._flags&b){let i=(this._flags&T)===st;e(h,r=>{}),i?e(c,this._cachedValue):e(c);return}if(!(this._flags&N)&&(this._lazyConnect(),this._flags&b)){let i=(this._flags&T)===st;e(h,r=>{}),i?e(c,this._cachedValue):e(c);return}if(this._output===null)this._output=e;else if(this._flags&w)this._output.add(e);else{let i=new Set;i.add(this._output),i.add(e),this._output=i,this._flags|=w}e(h,i=>{if(i===g&&e(g,this._cachedValue),i===c){if(this._output===null)return;if(this._flags&w){let r=this._output;r.delete(e),r.size===1?(this._output=r.values().next().value,this._flags&=~w):r.size===0&&(this._output=null,this._flags&=~w,this._disconnectUpstream())}else this._output===e&&(this._output=null,this._disconnectUpstream())}})}}};function it(s,t,n){return new nt(s,t,n)}(t=>{function s(n,e){return new nt([n],()=>n.get(),e,!0)}t.from=s})(it||={});function mt(s,t,n){let e,i=[],r=!1,o=new O(s.length),a=!1;function l(){r||(e&&e(),e=t())}L(),l();for(let u=0;u<s.length&&!r;u++){let f=u;s[f].source(h,(p,R)=>{if(p===h){i.push(R),s.length===1&&R(d,I);return}if(!r&&(p===d&&(R===_?(o.empty()&&(a=!1),o.set(f)):R===v&&o.test(f)&&(o.clear(f),o.empty()&&a&&l())),p===g&&(o.test(f)?(o.clear(f),a=!0,o.empty()&&l()):o.empty()?l():a=!0),p===c)){r=!0,e&&e(),e=void 0;for(let lt of i)lt(c);i.length=0}})}C();let S=()=>{if(!r){r=!0,e&&e(),e=void 0;for(let u of i)u(c);i.length=0}};E.register(S,{kind:"effect",...n,deps:s});for(let u of s)E.registerEdge(u,S);return S}var rt=1,D=64,k=2,P=4,yt=8,vt=16,A=32,x=1024,m=j,V=G<<y,Y=B<<y,ot=z<<y,Ct=Z<<y,$t=Q<<y,Nt=J<<y,at=class{_value;_output=null;_flags;get _status(){return X(this._flags)}_cleanup;_fn;_eqFn;_getterFn;_initial;_singleDepCount=0;constructor(t,n){this._value=n?.initial,this._fn=t,this._eqFn=n?.equals,this._getterFn=n?.getter,this._initial=n?.initial;let e=0;n?.autoDirty!==!1&&(e|=P),n?.resetOnTeardown&&(e|=yt),n?.resubscribable&&(e|=vt),this._flags=e,this.source=this.source.bind(this),this.emit=this.emit.bind(this),n?._skipInspect||E.register(this,{kind:"producer",...n})}get(){return this._getterFn?this._getterFn(this._value):this._value}_dispatch(t,n){let e=this._output;if(e)if(this._flags&D)for(let i of e)i(t,n);else e(t,n)}emit(t){this._flags&k||this._eqFn&&this._value!==void 0&&this._eqFn(this._value,t)||(this._value=t,this._output&&(tt()?this._flags&A||(this._flags|=A,this._flags&P&&(this._flags=this._flags&~m|V,this._dispatch(d,_)),et(()=>{this._flags&=~A,this._flags=this._flags&~m|Y,this._dispatch(g,this._value)})):(this._flags&P&&!(this._flags&x)&&(this._flags=this._flags&~m|V,this._dispatch(d,_)),this._flags=this._flags&~m|Y,this._dispatch(g,this._value))))}signal(t){this._flags&k||!this._output||(t===_?this._flags=this._flags&~m|V:t===v&&(this._flags=this._flags&~m|Nt),this._dispatch(d,t))}complete(){if(this._flags&k)return;this._flags=(this._flags|k)&~m|Ct;let t=this._output,n=this._flags&D;if(this._output=null,this._flags&=~(D|x),this._singleDepCount=0,this._stop(),t)if(n)for(let e of t)e(c);else t(c)}error(t){if(this._flags&k)return;this._flags=(this._flags|k)&~m|$t;let n=this._output,e=this._flags&D;if(this._output=null,this._flags&=~(D|x),this._singleDepCount=0,this._stop(),n)if(e)for(let i of n)i(c,t);else n(c,t)}_start(){if(this._flags&rt||!this._fn)return;this._flags|=rt;let t=this._fn({emit:this.emit,signal:n=>this.signal(n),complete:()=>this.complete(),error:n=>this.error(n)});this._cleanup=typeof t=="function"?t:void 0}_stop(){this._flags&rt&&(this._flags&=~rt,this._cleanup&&this._cleanup(),this._cleanup=void 0,this._flags&yt&&(this._value=this._initial),this._flags&k||(this._flags=this._flags&~m|ot))}source(t,n){if(t===h){let e=n;if(this._flags&k)if(this._flags&vt&&this._output===null)this._flags=this._flags&~(k|m)|ot;else{e(h,r=>{}),e(c);return}if(this._output===null)this._output=e;else if(this._flags&D)this._output.add(e);else{let r=new Set;r.add(this._output),r.add(e),this._output=r,this._flags=(this._flags|D)&~x}let i=!1;e(h,(r,o)=>{if(r===g&&e(g,this._value),r===d&&o===I&&!i&&(i=!0,this._singleDepCount++,this._flags&D||(this._flags|=x)),r===c){if(i&&(i=!1,this._singleDepCount--),this._output===null)return;if(this._flags&D){let a=this._output;a.delete(e),a.size===1?(this._output=a.values().next().value,this._flags&=~D,this._singleDepCount>0&&(this._flags|=x)):a.size===0&&(this._output=null,this._flags&=~(D|x),this._singleDepCount=0,this._flags=this._flags&~m|ot,this._stop())}else this._output===e&&(this._output=null,this._flags&=~x,this._singleDepCount=0,this._flags=this._flags&~m|ot,this._stop())}}),Tt(()=>this._start())}}};var dt=class extends at{constructor(t,n){super(void 0,{initial:t,autoDirty:!0,equals:n?.equals??Object.is,_skipInspect:!0}),this.set=this.set.bind(this),E.register(this,{kind:"state",...n})}get(){return this._value}set(t){this._flags&k||this._value!==void 0&&this._eqFn(this._value,t)||(this._value=t,this._output&&(tt()?this._flags&A||(this._flags|=A,this._flags&P&&(this._flags=this._flags&~m|V,this._dispatch(d,_)),et(()=>{this._flags&=~A,this._flags=this._flags&~m|Y,this._dispatch(g,this._value)})):(this._flags&P&&!(this._flags&x)&&(this._flags=this._flags&~m|V,this._dispatch(d,_)),this._flags=this._flags&~m|Y,this._dispatch(g,this._value))))}update(t){this.set(t(this._value))}};function Et(s,t){return new dt(s,t)}function bt(s,t,n){let e=null;L(),s.source(h,(r,o)=>{if(r===h&&(e=o),r===c){e=null,n?.onEnd?.(o);return}if(r===1){let a=o,l=i;i=a,t(a,l)}});let i;try{i=s.get()}catch{}return C(),()=>e?.(c)}var ht=class{_store;constructor(t,n){this._store=Et(t,{equals:n?.equals})}get(){return this._store.get()}set(t){this._store.set(t)}},_t=class{_store;constructor(t,n,e){let i=n.map(r=>r._store);this._store=it(i,t,{equals:e?.equals})}get(){return this._store.get()}},pt=class{_notify;_unsubs=new Map;_pending=new Set;constructor(t){this._notify=t}watch(...t){for(let n of t){if(this._unsubs.has(n))continue;let e=bt(n._store,()=>{this._pending.add(n),this._notify()},{onEnd:()=>{this._unsubs.delete(n),this._pending.delete(n)}});this._unsubs.set(n,e)}}unwatch(...t){for(let n of t){let e=this._unsubs.get(n);e&&(e(),this._unsubs.delete(n),this._pending.delete(n))}}getPending(){let t=[...this._pending];return this._pending.clear(),t}},Mt={State:ht,Computed:_t,subtle:{Watcher:pt,untrack:s=>s()}};function Pt(s,t){return mt(s.map(n=>n._store),t)}0&&(module.exports={Signal,batch,signalEffect});
|
|
4
|
+
`)}static annotate(t,n){if(!s.enabled)return;s._annotations.set(t,n);let e={node:s._resolveKey(t),reason:n,timestamp:Date.now()},i=s.maxTraceEntries;i<=0||(s._traceLog.length<i?s._traceLog.push(e):(s._traceLog[s._traceHead]=e,s._traceFull=!0),s._traceHead=(s._traceHead+1)%i)}static getAnnotation(t){return s._annotations.get(t)}static traceLog(){return s._traceFull?[...s._traceLog.slice(s._traceHead),...s._traceLog.slice(0,s._traceHead)]:s._traceLog.slice(0,s._traceHead||s._traceLog.length)}static clearTrace(){s._traceLog=[],s._traceHead=0,s._traceFull=!1}static _reset(){s._names=new WeakMap,s._kinds=new WeakMap,s._keys=new WeakMap,s._stores=new Set,s._edges=new Map,s._usedKeys=new Set,s._nextId=0,s._explicitEnabled=null,s._cachedDefault=null,s._annotations=new WeakMap,s._traceLog=[],s._traceHead=0,s._traceFull=!1,s.maxTraceEntries=1e3}};var $=1,N=2,F=4,b=8,w=32,St=64,Ot=z<<y,M=G<<y,ct=B<<y,K=J<<y,Lt=Z<<y,st=Q<<y,T=j,nt=class{_output=null;_upstreamTalkbacks=[];_cachedValue;_flags;_dirtyDeps;_eqFn;_deps;_fn;get _status(){return X(this._flags)}constructor(t,n,e,i){this._deps=t,this._fn=n,this._eqFn=e?.equals,this._flags=i?St:0,this._dirtyDeps=new O(t.length),this.source=this.source.bind(this),E.register(this,{kind:"derived",...e,deps:t});for(let r of t)E.registerEdge(r,this)}_dispatch(t,n){let e=this._output;if(e)if(this._flags&w)for(let i of e)i(t,n);else e(t,n)}_recompute(){let t;try{t=this._fn()}catch(n){this._handleEnd(n);return}if(this._eqFn&&this._flags&$&&this._eqFn(this._cachedValue,t)){this._flags=this._flags&~T|K,this._dispatch(d,v);return}this._cachedValue=t,this._flags=(this._flags|$)&~T|ct,this._dispatch(g,this._cachedValue)}_recomputeIdentity(t){if(!(this._flags&b)){if(this._eqFn&&this._flags&$&&this._eqFn(this._cachedValue,t)){this._flags=this._flags&~T|K,this._dispatch(d,v);return}this._cachedValue=t,this._flags=(this._flags|$)&~T|ct,this._dispatch(g,t)}}_lazyConnect(){if(!(this._flags&(N|b))){try{this._cachedValue=this._fn()}catch(t){this._handleEnd(t);return}this._flags=(this._flags|$)&~T|ct,L(),this._connectUpstream(),this._flags&b||(this._flags|=N),C()}}_connectUpstream(){this._upstreamTalkbacks.length=0,this._deps.length===1?this._flags&St?this._connectSingleDepIdentity():this._connectSingleDep():this._connectMultiDep()}_connectSingleDep(){let t=!1;this._deps[0].source(h,(n,e)=>{if(n===h){this._upstreamTalkbacks.push(e),e(d,I);return}if(!(this._flags&b))if(n===d)if(e===_){if(t)return;t=!0,this._flags=this._flags&~T|M,this._dispatch(d,_)}else e===v?t&&(t=!1,this._flags=this._flags&~T|K,this._dispatch(d,v)):this._dispatch(d,e);else n===g?t?(t=!1,this._recompute()):(this._flags=this._flags&~T|M,this._dispatch(d,_),this._recompute()):n===c&&this._handleEnd(e)})}_connectSingleDepIdentity(){let t=!1;this._deps[0].source(h,(n,e)=>{if(n===h){this._upstreamTalkbacks.push(e),e(d,I);return}this._flags&b||(n===d?e===_?(t=!0,this._flags=this._flags&~T|M,this._dispatch(d,_)):e===v?t&&(t=!1,this._flags=this._flags&~T|K,this._dispatch(d,v)):this._dispatch(d,e):n===g?t?(t=!1,this._recomputeIdentity(e)):(this._flags=this._flags&~T|M,this._dispatch(d,_),this._recomputeIdentity(e)):n===c&&this._handleEnd(e))})}_connectMultiDep(){for(let t=0;t<this._deps.length&&!(this._flags&b);t++){let n=t;this._deps[n].source(h,(e,i)=>{if(e===h){this._upstreamTalkbacks.push(i);return}if(!(this._flags&b))if(e===d)if(i===_){let r=this._dirtyDeps.empty();this._dirtyDeps.set(n),r&&(this._flags&=~F,this._flags=this._flags&~T|M,this._dispatch(d,_))}else i===v?this._dirtyDeps.test(n)&&(this._dirtyDeps.clear(n),this._dirtyDeps.empty()&&(this._flags&F?this._recompute():(this._flags=this._flags&~T|K,this._dispatch(d,v)))):this._dispatch(d,i);else e===g?this._dirtyDeps.test(n)?(this._dirtyDeps.clear(n),this._flags|=F,this._dirtyDeps.empty()&&this._recompute()):this._dirtyDeps.empty()?(this._flags=this._flags&~T|M,this._dispatch(d,_),this._recompute()):this._flags|=F:e===c&&this._handleEnd(i)})}}_handleEnd(t){this._flags|=b,this._flags=this._flags&~T|(t!==void 0?st:Lt),t!==void 0&&(this._cachedValue=t);for(let i of this._upstreamTalkbacks)i(c);this._upstreamTalkbacks=[],this._flags&=~N,this._dirtyDeps.reset();let n=this._output,e=this._flags&w;if(this._output=null,this._flags&=~w,n)if(e)for(let i of n)try{t!==void 0?i(c,t):i(c)}catch{}else t!==void 0?n(c,t):n(c)}_disconnectUpstream(){for(let t of this._upstreamTalkbacks)t(c);this._upstreamTalkbacks.length=0,this._flags&=~(N|F),this._flags=this._flags&~T|Ot,this._dirtyDeps.reset()}get(){if(this._flags&N)return this._cachedValue;if(this._flags&b){if((this._flags&T)===st)throw this._cachedValue;return this._cachedValue}let t=this._fn();return this._cachedValue=t,this._flags|=$,t}source(t,n){if(t===h){let e=n;if(this._flags&b){let i=(this._flags&T)===st;e(h,r=>{}),i?e(c,this._cachedValue):e(c);return}if(!(this._flags&N)&&(this._lazyConnect(),this._flags&b)){let i=(this._flags&T)===st;e(h,r=>{}),i?e(c,this._cachedValue):e(c);return}if(this._output===null)this._output=e;else if(this._flags&w)this._output.add(e);else{let i=new Set;i.add(this._output),i.add(e),this._output=i,this._flags|=w}e(h,i=>{if(i===g&&e(g,this._cachedValue),i===c){if(this._output===null)return;if(this._flags&w){let r=this._output;r.delete(e),r.size===1?(this._output=r.values().next().value,this._flags&=~w):r.size===0&&(this._output=null,this._flags&=~w,this._disconnectUpstream())}else this._output===e&&(this._output=null,this._disconnectUpstream())}})}}};function it(s,t,n){return new nt(s,t,n)}(t=>{function s(n,e){return new nt([n],()=>n.get(),e,!0)}t.from=s})(it||={});function mt(s,t,n){let e,i=[],r=!1,o=new O(s.length),a=!1;function l(){r||(e&&e(),e=t())}L(),l();for(let u=0;u<s.length&&!r;u++){let f=u;s[f].source(h,(p,R)=>{if(p===h){i.push(R),s.length===1&&R(d,I);return}if(!r&&(p===d&&(R===_?(o.empty()&&(a=!1),o.set(f)):R===v&&o.test(f)&&(o.clear(f),o.empty()&&a&&l())),p===g&&(o.test(f)?(o.clear(f),a=!0,o.empty()&&l()):o.empty()?l():a=!0),p===c)){r=!0,e&&e(),e=void 0;for(let lt of i)lt(c);i.length=0}})}C();let S=()=>{if(!r){r=!0,e&&e(),e=void 0;for(let u of i)u(c);i.length=0}};E.register(S,{kind:"effect",...n,deps:s});for(let u of s)E.registerEdge(u,S);return S}var rt=1,D=64,k=2,P=4,yt=8,vt=16,A=32,x=1024,m=j,V=G<<y,Y=B<<y,ot=z<<y,Ct=Z<<y,$t=Q<<y,Nt=J<<y,at=class{_value;_output=null;_flags;get _status(){return X(this._flags)}_cleanup;_fn;_eqFn;_getterFn;_initial;_singleDepCount=0;constructor(t,n){this._value=n?.initial,this._fn=t,this._eqFn=n?.equals,this._getterFn=n?.getter,this._initial=n?.initial;let e=0;n?.autoDirty!==!1&&(e|=P),n?.resetOnTeardown&&(e|=yt),n?.resubscribable&&(e|=vt),this._flags=e,this.source=this.source.bind(this),this.emit=this.emit.bind(this),n?._skipInspect||E.register(this,{kind:"producer",...n})}get(){return this._getterFn?this._getterFn(this._value):this._value}_dispatch(t,n){let e=this._output;if(e)if(this._flags&D)for(let i of e)i(t,n);else e(t,n)}emit(t){this._flags&k||this._eqFn&&this._value!==void 0&&this._eqFn(this._value,t)||(this._value=t,this._output&&(tt()?this._flags&A||(this._flags|=A,this._flags&P&&(this._flags=this._flags&~m|V,this._dispatch(d,_)),et(()=>{this._flags&=~A,this._flags=this._flags&~m|Y,this._dispatch(g,this._value)})):(this._flags&P&&!(this._flags&x)&&(this._flags=this._flags&~m|V,this._dispatch(d,_)),this._flags=this._flags&~m|Y,this._dispatch(g,this._value))))}signal(t){this._flags&k||!this._output||(t===_?this._flags=this._flags&~m|V:t===v&&(this._flags=this._flags&~m|Nt),this._dispatch(d,t))}complete(){if(this._flags&k)return;this._flags=(this._flags|k)&~m|Ct;let t=this._output,n=this._flags&D;if(this._output=null,this._flags&=~(D|x),this._singleDepCount=0,this._stop(),t)if(n)for(let e of t)e(c);else t(c)}error(t){if(this._flags&k)return;this._flags=(this._flags|k)&~m|$t;let n=this._output,e=this._flags&D;if(this._output=null,this._flags&=~(D|x),this._singleDepCount=0,this._stop(),n)if(e)for(let i of n)i(c,t);else n(c,t)}_start(){if(this._flags&rt||!this._fn)return;this._flags|=rt;let t=this._fn({emit:this.emit,signal:n=>this.signal(n),complete:()=>this.complete(),error:n=>this.error(n)});this._cleanup=typeof t=="function"?t:void 0}_stop(){this._flags&rt&&(this._flags&=~rt,this._cleanup&&this._cleanup(),this._cleanup=void 0,this._flags&yt&&(this._value=this._initial),this._flags&k||(this._flags=this._flags&~m|ot))}source(t,n){if(t===h){let e=n;if(this._flags&k)if(this._flags&vt&&this._output===null)this._flags=this._flags&~(k|m)|ot;else{e(h,r=>{}),e(c);return}if(this._output===null)this._output=e;else if(this._flags&D)this._output.add(e);else{let r=new Set;r.add(this._output),r.add(e),this._output=r,this._flags=(this._flags|D)&~x}let i=!1;e(h,(r,o)=>{if(r===g&&e(g,this._value),r===d&&o===I&&!i&&(i=!0,this._singleDepCount++,this._flags&D||(this._flags|=x)),r===c){if(i&&(i=!1,this._singleDepCount--),this._output===null)return;if(this._flags&D){let a=this._output;a.delete(e),a.size===1?(this._output=a.values().next().value,this._flags&=~D,this._singleDepCount>0&&(this._flags|=x)):a.size===0&&(this._output=null,this._flags&=~(D|x),this._singleDepCount=0,this._flags=this._flags&~m|ot,this._stop())}else this._output===e&&(this._output=null,this._flags&=~x,this._singleDepCount=0,this._flags=this._flags&~m|ot,this._stop())}}),Tt(()=>this._start())}}};var dt=class extends at{constructor(t,n){super(void 0,{initial:t,autoDirty:!0,equals:n?.equals??Object.is,_skipInspect:!0}),this.set=this.set.bind(this),E.register(this,{kind:"state",...n})}get(){return this._value}set(t){this._flags&k||this._value!==void 0&&this._eqFn(this._value,t)||(this._value=t,this._output&&(tt()?this._flags&A||(this._flags|=A,this._flags&P&&(this._flags=this._flags&~m|V,this._dispatch(d,_)),et(()=>{this._flags&=~A,this._flags=this._flags&~m|Y,this._dispatch(g,this._value)})):(this._flags&P&&!(this._flags&x)&&(this._flags=this._flags&~m|V,this._dispatch(d,_)),this._flags=this._flags&~m|Y,this._dispatch(g,this._value))))}update(t){this.set(t(this._value))}};function Et(s,t){return new dt(s,t)}function bt(s,t,n){let e=null;L(),s.source(h,(r,o)=>{if(r===h&&(e=o),r===c){e=null,n?.onEnd?.(o);return}if(r===1){let a=o,l=i;i=a,t(a,l)}});let i;try{i=s.get()}catch{}return C(),()=>e?.(c)}var ht=class{_store;constructor(t,n){this._store=Et(t,{equals:n?.equals})}get(){return this._store.get()}set(t){this._store.set(t)}},_t=class{_store;constructor(t,n,e){let i=n.map(r=>r._store);this._store=it(i,t,{equals:e?.equals})}get(){return this._store.get()}},pt=class{_notify;_unsubs=new Map;_pending=new Set;constructor(t){this._notify=t}watch(...t){for(let n of t){if(this._unsubs.has(n))continue;let e=bt(n._store,()=>{this._pending.add(n),this._notify()},{onEnd:()=>{this._unsubs.delete(n),this._pending.delete(n)}});this._unsubs.set(n,e)}}unwatch(...t){for(let n of t){let e=this._unsubs.get(n);e&&(e(),this._unsubs.delete(n),this._pending.delete(n))}}getPending(){let t=[...this._pending];return this._pending.clear(),t}},Mt={State:ht,Computed:_t,subtle:{Watcher:pt,untrack:s=>s()}};function Pt(s,t){return mt(s.map(n=>n._store),t)}0&&(module.exports={Signal,batch,signalEffect});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as u}from"../../chunk-J3QF6BR6.js";import{a as r}from"../../chunk-
|
|
1
|
+
import{a as u}from"../../chunk-J3QF6BR6.js";import{a as r}from"../../chunk-X575NBLE.js";import"../../chunk-HK7DRUNM.js";import{a as d}from"../../chunk-YJXCVG35.js";import{a as l}from"../../chunk-P5MXN4AF.js";import"../../chunk-YN4VWXAF.js";import"../../chunk-M76W372U.js";import{q as g}from"../../chunk-CWP55MPE.js";import"../../chunk-I7AUKTXE.js";var o=class{_store;constructor(e,t){this._store=l(e,{equals:t?.equals})}get(){return this._store.get()}set(e){this._store.set(e)}},a=class{_store;constructor(e,t,s){let p=t.map(c=>c._store);this._store=r(p,e,{equals:s?.equals})}get(){return this._store.get()}},i=class{_notify;_unsubs=new Map;_pending=new Set;constructor(e){this._notify=e}watch(...e){for(let t of e){if(this._unsubs.has(t))continue;let s=d(t._store,()=>{this._pending.add(t),this._notify()},{onEnd:()=>{this._unsubs.delete(t),this._pending.delete(t)}});this._unsubs.set(t,s)}}unwatch(...e){for(let t of e){let s=this._unsubs.get(t);s&&(s(),this._unsubs.delete(t),this._pending.delete(t))}}getPending(){let e=[...this._pending];return this._pending.clear(),e}},f={State:o,Computed:a,subtle:{Watcher:i,untrack:n=>n()}};function b(n,e){return u(n.map(t=>t._store),e)}export{f as Signal,g as batch,b as signalEffect};
|
package/dist/data/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";var Oe=Object.defineProperty;var Ue=Object.getOwnPropertyDescriptor;var qe=Object.getOwnPropertyNames;var je=Object.prototype.hasOwnProperty;var We=(i,e)=>{for(var n in e)Oe(i,n,{get:e[n],enumerable:!0})},Be=(i,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of qe(e))!je.call(i,s)&&s!==n&&Oe(i,s,{get:()=>e[s],enumerable:!(t=Ue(e,s))||t.enumerable});return i};var Ye=i=>Be(Oe({},"__esModule",{value:!0}),i);var rt={};We(rt,{pubsub:()=>Le,reactiveIndex:()=>xe,reactiveList:()=>Re,reactiveLog:()=>we,reactiveMap:()=>Ve});module.exports=Ye(rt);var ae=class{_v;_w;constructor(e){this._v=0,this._w=e>32?new Uint32Array((e-1>>>5)+1):null}set(e){let n=this._w;if(n===null)this._v|=1<<e;else{let t=e>>>5,s=1<<(e&31);n[t]&s||(n[t]|=s,this._v++)}}clear(e){let n=this._w;if(n===null)this._v&=~(1<<e);else{let t=e>>>5,s=1<<(e&31);n[t]&s&&(n[t]&=~s,this._v--)}}test(e){let n=this._w;return n===null?(this._v&1<<e)!==0:(n[e>>>5]&1<<(e&31))!==0}empty(){return this._v===0}reset(){this._v=0,this._w?.fill(0)}};var w=Symbol("DIRTY"),C=Symbol("RESOLVED"),ne=Symbol("SINGLE_DEP"),de=0,he=1,ge=2,pe=3,_e=4,me=5,K=7,se=7<<K,He=["DISCONNECTED","DIRTY","SETTLED","RESOLVED","COMPLETED","ERRORED"];function ve(i){return He[(i&se)>>>K]}var R=0,O=1,E=2,b=3,ue=0,ce=[],$e=!1;function P(i){ue++;try{return i()}finally{if(ue--,ue===0&&!$e){$e=!0;for(let e=0;e<ce.length;e++)ce[e]();ce.length=0,$e=!1}}}function Se(){return ue>0}function Te(i){ce.push(i)}var fe=0,le=[];function Ae(){fe++}function Ke(){if(fe--,fe===0){for(let i=0;i<le.length;i++)le[i]();le.length=0}}function Pe(i){fe>0?le.push(i):i()}function L(i){let e=i;typeof e.complete=="function"?e.complete():typeof e._handleEnd=="function"&&e._handleEnd(void 0)}var H=class i{static _names=new WeakMap;static _kinds=new WeakMap;static _keys=new WeakMap;static _stores=new Set;static _edges=new Map;static _nextId=0;static _usedKeys=new Set;static _explicitEnabled=null;static _cachedDefault=null;static _annotations=new WeakMap;static _traceLog=[];static _traceHead=0;static _traceFull=!1;static maxTraceEntries=1e3;static get enabled(){if(i._explicitEnabled!==null)return i._explicitEnabled;if(i._cachedDefault!==null)return i._cachedDefault;try{i._cachedDefault=globalThis.process?.env?.NODE_ENV!=="production"}catch{i._cachedDefault=!0}return i._cachedDefault}static set enabled(e){i._explicitEnabled=e}static _depSuffix(e){if(!e?.length)return;let t=e.map(s=>i._names.get(s)??"?").join(",");return t.length>40?`${t.slice(0,37)}...`:t}static _resolveKey(e){let n=i._keys.get(e)??i._names.get(e);if(n)return n;let t=`anonymous_${i._nextId++}`;return i._keys.set(e,t),t}static register(e,n){if(!i.enabled)return;n?.name&&i._names.set(e,n.name),n?.kind&&i._kinds.set(e,n.kind);let t=i._nextId++,s=n?.name;if(!(s&&!i._usedKeys.has(s)))if(s){let r=i._depSuffix(n?.deps);s=r?`${s}(${r})`:`${s}_${t}`,i._usedKeys.has(s)&&(s=`${s}_${t}`)}else{let r=n?.kind??"store",c=i._depSuffix(n?.deps);s=c?`${r}(${c})`:`${r}_${t}`,i._usedKeys.has(s)&&(s=`${s}_${t}`)}i._usedKeys.add(s),i._keys.set(e,s),i._stores.add(new WeakRef(e))}static registerEdge(e,n){if(!i.enabled)return;let t=i._resolveKey(e),s=i._resolveKey(n),r=i._edges.get(t);r?r.includes(s)||r.push(s):i._edges.set(t,[s])}static getEdges(){return new Map(i._edges)}static getName(e){if(i.enabled)return i._names.get(e)}static getKind(e){return i._kinds.get(e)}static inspect(e){return{name:i._names.get(e),kind:i._kinds.get(e)??"unknown",value:typeof e.get=="function"?e.get():void 0,status:e._status}}static graph(){let e=new Map,n=new Set;for(let t of i._stores){let s=t.deref();if(!s){i._stores.delete(t);continue}let r=i._resolveKey(s);n.add(r),e.set(r,i.inspect(s))}for(let[t,s]of i._edges){if(!n.has(t)){i._edges.delete(t),i._usedKeys.delete(t);continue}let r=s.filter(c=>n.has(c));r.length===0?i._edges.delete(t):r.length!==s.length&&i._edges.set(t,r)}return e}static trace(e,n){let t=null,s=e.get();return e.source(R,(r,c)=>{if(r===R&&(t=c),r===E){t=null;return}if(r===1){let a=c;if(!Object.is(a,s)){let d=s;s=a,n(a,d)}}}),()=>t?.(E)}static dumpGraph(){let e=i.graph(),n=i.getEdges(),t=new Map;for(let[c,a]of n)for(let d of a){let p=t.get(d);p?p.includes(c)||p.push(c):t.set(d,[c])}let s=[];for(let[c,a]of e){let d=t.get(c),p=n.get(c),f=d?.length?` \u2190 [${d.join(", ")}]`:"",g=p?.length?` \u2192 [${p.join(", ")}]`:"";s.push(` ${c} (${a.kind}) = ${JSON.stringify(a.value)} [${a.status??"?"}]${f}${g}`)}return[`Store Graph (${e.size} nodes):`,...s].join(`
|
|
2
2
|
`)}static _observe(e,n,t){let s=null,r=n??i.getName(e),c={values:[],signals:[],events:[],ended:!1,endError:void 0,dirtyCount:0,resolvedCount:0,name:r,dispose:()=>s?.(E)};return e.source(R,(a,d)=>{if(a===R){s=d;return}a===O?(c.values.push(d),c.events.push({type:"data",data:d}),t&&t(`[${r}] DATA:`,d)):a===b?(c.signals.push(d),c.events.push({type:"signal",data:d}),d===w?c.dirtyCount++:d===C&&c.resolvedCount++,t&&t(`[${r}] STATE:`,d)):a===E&&(c.ended=!0,c.endError=d,c.events.push({type:"end",data:d}),t&&t(`[${r}] END`,d!==void 0?d:""),s=null)}),c}static observe(e){return i._observe(e)}static tap(e,n){let t=n??`tap(${i.getName(e)??"anon"})`,s={get:()=>e.get(),source:e.source};return i.register(s,{name:t,kind:"tap"}),i.registerEdge(e,s),s}static spy(e,n){let t=n?.name??i.getName(e)??"spy",s=n?.log??console.log;return i._observe(e,t,s)}static snapshot(){let e=i.graph(),n=i.getEdges(),t=new Map;for(let c of i._stores){let a=c.deref();if(!a)continue;let d=i._annotations.get(a);d!==void 0&&t.set(i._resolveKey(a),d)}let s=[];for(let[c,a]of e){let d={name:c,kind:a.kind,value:a.value,status:a.status},p=t.get(c);p!==void 0&&(d.annotation=p),s.push(d)}let r=[];for(let[c,a]of n)for(let d of a)r.push({from:c,to:d});return{nodes:s,edges:r,trace:i.traceLog()}}static toMermaid(e){let n=e?.direction??"TD",t=i.snapshot(),s=[`graph ${n}`],r={SETTLED:":::settled",DIRTY:":::dirty",ERRORED:":::errored",COMPLETED:":::completed"},c=new Map;function a(f){let g=f.replace(/[^a-zA-Z0-9_]/g,"_"),y=c.get(g);return y===void 0?(c.set(g,1),g):(c.set(g,y+1),`${g}__${y}`)}let d=new Map;function p(f){let g=JSON.stringify(f);return g&&g.length>30?`${g.slice(0,27)}...`:g??"undefined"}for(let f of t.nodes){let g=a(f.name);d.set(f.name,g);let y=`${f.name} (${f.kind}) = ${p(f.value)}`,$=r[f.status??""]??"";s.push(` ${g}["${y}"]${$}`)}for(let f of t.edges){let g=d.get(f.from)??a(f.from),y=d.get(f.to)??a(f.to);s.push(` ${g} --> ${y}`)}return s.push(""),s.push(" classDef settled fill:#d4edda,stroke:#28a745"),s.push(" classDef dirty fill:#fff3cd,stroke:#ffc107"),s.push(" classDef errored fill:#f8d7da,stroke:#dc3545"),s.push(" classDef completed fill:#cce5ff,stroke:#007bff"),s.join(`
|
|
3
3
|
`)}static toD2(e){let n=e?.direction??"down",t=i.snapshot(),s=[`direction: ${n}`,""],r={state:"rectangle",derived:"hexagon",effect:"oval",producer:"rectangle",operator:"parallelogram","pipeline-step":"rectangle","pipeline-status":"diamond",checkpoint:"cylinder"},c=new Map;function a(f){let g=f.replace(/[^a-zA-Z0-9_]/g,"_"),y=c.get(g);return y===void 0?(c.set(g,1),g):(c.set(g,y+1),`${g}__${y}`)}let d=new Map;function p(f){let g=JSON.stringify(f);return g&&g.length>30?`${g.slice(0,27)}...`:g??"undefined"}for(let f of t.nodes){let g=a(f.name);d.set(f.name,g);let y=r[f.kind]??"rectangle",$=`${f.name} (${f.kind}) = ${p(f.value)}`,M=f.status?` [${f.status}]`:"";s.push(`${g}: "${$}${M}" { shape: ${y} }`)}t.edges.length>0&&s.push("");for(let f of t.edges){let g=d.get(f.from)??a(f.from),y=d.get(f.to)??a(f.to);s.push(`${g} -> ${y}`)}return s.join(`
|
|
4
|
-
`)}static annotate(e,n){if(!i.enabled)return;i._annotations.set(e,n);let t={node:i._resolveKey(e),reason:n,timestamp:Date.now()},s=i.maxTraceEntries;s<=0||(i._traceLog.length<s?i._traceLog.push(t):(i._traceLog[i._traceHead]=t,i._traceFull=!0),i._traceHead=(i._traceHead+1)%s)}static getAnnotation(e){return i._annotations.get(e)}static traceLog(){return i._traceFull?[...i._traceLog.slice(i._traceHead),...i._traceLog.slice(0,i._traceHead)]:i._traceLog.slice(0,i._traceHead||i._traceLog.length)}static clearTrace(){i._traceLog=[],i._traceHead=0,i._traceFull=!1}static _reset(){i._names=new WeakMap,i._kinds=new WeakMap,i._keys=new WeakMap,i._stores=new Set,i._edges=new Map,i._usedKeys=new Set,i._nextId=0,i._explicitEnabled=null,i._cachedDefault=null,i._annotations=new WeakMap,i._traceLog=[],i._traceHead=0,i._traceFull=!1,i.maxTraceEntries=1e3}};var Z=1,Q=2,ie=4,U=8,G=32,Ne=64,Ge=de<<K,X=he<<K,Ie=ge<<K,re=pe<<K,Je=_e<<K,ye=me<<K,V=se,be=class{_output=null;_upstreamTalkbacks=[];_cachedValue;_flags;_dirtyDeps;_eqFn;_deps;_fn;get _status(){return ve(this._flags)}constructor(e,n,t,s){this._deps=e,this._fn=n,this._eqFn=t?.equals,this._flags=s?Ne:0,this._dirtyDeps=new ae(e.length),this.source=this.source.bind(this),H.register(this,{kind:"derived",...t,deps:e});for(let r of e)H.registerEdge(r,this)}_dispatch(e,n){let t=this._output;if(t)if(this._flags&G)for(let s of t)s(e,n);else t(e,n)}_recompute(){let e;try{e=this._fn()}catch(n){this._handleEnd(n);return}if(this._eqFn&&this._flags&Z&&this._eqFn(this._cachedValue,e)){this._flags=this._flags&~V|re,this._dispatch(b,C);return}this._cachedValue=e,this._flags=(this._flags|Z)&~V|Ie,this._dispatch(O,this._cachedValue)}_recomputeIdentity(e){if(!(this._flags&U)){if(this._eqFn&&this._flags&Z&&this._eqFn(this._cachedValue,e)){this._flags=this._flags&~V|re,this._dispatch(b,C);return}this._cachedValue=e,this._flags=(this._flags|Z)&~V|Ie,this._dispatch(O,e)}}_lazyConnect(){if(!(this._flags&(Q|U))){try{this._cachedValue=this._fn()}catch(e){this._handleEnd(e);return}this._flags=(this._flags|Z)&~V|Ie,Ae(),this._connectUpstream(),this._flags&U||(this._flags|=Q),Ke()}}_connectUpstream(){this._upstreamTalkbacks.length=0,this._deps.length===1?this._flags&Ne?this._connectSingleDepIdentity():this._connectSingleDep():this._connectMultiDep()}_connectSingleDep(){let e=!1;this._deps[0].source(R,(n,t)=>{if(n===R){this._upstreamTalkbacks.push(t),t(b,ne);return}this._flags&U||(n===b?t===w?(e=!0,this._flags=this._flags&~V|X,this._dispatch(b,w)):t===C?e&&(e=!1,this._flags=this._flags&~V|re,this._dispatch(b,C)):this._dispatch(b,t):n===O?e?(e=!1,this._recompute()):(this._flags=this._flags&~V|X,this._dispatch(b,w),this._recompute()):n===E&&this._handleEnd(t))})}_connectSingleDepIdentity(){let e=!1;this._deps[0].source(R,(n,t)=>{if(n===R){this._upstreamTalkbacks.push(t),t(b,ne);return}this._flags&U||(n===b?t===w?(e=!0,this._flags=this._flags&~V|X,this._dispatch(b,w)):t===C?e&&(e=!1,this._flags=this._flags&~V|re,this._dispatch(b,C)):this._dispatch(b,t):n===O?e?(e=!1,this._recomputeIdentity(t)):(this._flags=this._flags&~V|X,this._dispatch(b,w),this._recomputeIdentity(t)):n===E&&this._handleEnd(t))})}_connectMultiDep(){for(let e=0;e<this._deps.length&&!(this._flags&U);e++){let n=e;this._deps[n].source(R,(t,s)=>{if(t===R){this._upstreamTalkbacks.push(s);return}if(!(this._flags&U))if(t===b)if(s===w){let r=this._dirtyDeps.empty();this._dirtyDeps.set(n),r&&(this._flags&=~ie,this._flags=this._flags&~V|X,this._dispatch(b,w))}else s===C?this._dirtyDeps.test(n)&&(this._dirtyDeps.clear(n),this._dirtyDeps.empty()&&(this._flags&ie?this._recompute():(this._flags=this._flags&~V|re,this._dispatch(b,C)))):this._dispatch(b,s);else t===O?this._dirtyDeps.test(n)?(this._dirtyDeps.clear(n),this._flags|=ie,this._dirtyDeps.empty()&&this._recompute()):this._dirtyDeps.empty()?(this._flags=this._flags&~V|X,this._dispatch(b,w),this._recompute()):this._flags|=ie:t===E&&this._handleEnd(s)})}}_handleEnd(e){this._flags|=U,this._flags=this._flags&~V|(e!==void 0?ye:Je),e!==void 0&&(this._cachedValue=e);for(let s of this._upstreamTalkbacks)s(E);this._upstreamTalkbacks=[],this._flags&=~Q,this._dirtyDeps.reset();let n=this._output,t=this._flags&G;if(this._output=null,this._flags&=~G,n)if(t)for(let s of n)try{e!==void 0?s(E,e):s(E)}catch{}else e!==void 0?n(E,e):n(E)}_disconnectUpstream(){for(let e of this._upstreamTalkbacks)e(E);this._upstreamTalkbacks.length=0,this._flags&=~(Q|ie),this._flags=this._flags&~V|Ge,this._dirtyDeps.reset()}get(){if(this._flags&Q)return this._cachedValue;if(this._flags&U){if((this._flags&V)===ye)throw this._cachedValue;return this._cachedValue}let e=this._fn();return this._cachedValue=e,this._flags|=Z,e}source(e,n){if(e===R){let t=n;if(this._flags&U){let s=(this._flags&V)===ye;t(R,r=>{}),s?t(E,this._cachedValue):t(E);return}if(!(this._flags&Q)&&(this._lazyConnect(),this._flags&U)){let s=(this._flags&V)===ye;t(R,r=>{}),s?t(E,this._cachedValue):t(E);return}if(this._output===null)this._output=t;else if(this._flags&G)this._output.add(t);else{let s=new Set;s.add(this._output),s.add(t),this._output=s,this._flags|=G}t(R,s=>{if(s===O&&t(O,this._cachedValue),s===E){if(this._output===null)return;if(this._flags&G){let r=this._output;r.delete(t),r.size===1?(this._output=r.values().next().value,this._flags&=~G):r.size===0&&(this._output=null,this._flags&=~G,this._disconnectUpstream())}else this._output===t&&(this._output=null,this._disconnectUpstream())}})}}};function D(i,e,n){return new be(i,e,n)}(e=>{function i(n,t){return new be([n],()=>n.get(),t,!0)}e.from=i})(D||={});var Ee=1,q=64,j=2,ee=4,Ce=8,ze=16,J=32,Y=1024,I=se,te=he<<K,oe=ge<<K,De=de<<K,Ze=_e<<K,Qe=me<<K,Xe=pe<<K,ke=class{_value;_output=null;_flags;get _status(){return ve(this._flags)}_cleanup;_fn;_eqFn;_getterFn;_initial;_singleDepCount=0;constructor(e,n){this._value=n?.initial,this._fn=e,this._eqFn=n?.equals,this._getterFn=n?.getter,this._initial=n?.initial;let t=0;n?.autoDirty!==!1&&(t|=ee),n?.resetOnTeardown&&(t|=Ce),n?.resubscribable&&(t|=ze),this._flags=t,this.source=this.source.bind(this),this.emit=this.emit.bind(this),n?._skipInspect||H.register(this,{kind:"producer",...n})}get(){return this._getterFn?this._getterFn(this._value):this._value}_dispatch(e,n){let t=this._output;if(t)if(this._flags&q)for(let s of t)s(e,n);else t(e,n)}emit(e){this._flags&j||this._eqFn&&this._value!==void 0&&this._eqFn(this._value,e)||(this._value=e,this._output&&(Se()?this._flags&J||(this._flags|=J,this._flags&ee&&(this._flags=this._flags&~I|te,this._dispatch(b,w)),Te(()=>{this._flags&=~J,this._flags=this._flags&~I|oe,this._dispatch(O,this._value)})):(this._flags&ee&&!(this._flags&Y)&&(this._flags=this._flags&~I|te,this._dispatch(b,w)),this._flags=this._flags&~I|oe,this._dispatch(O,this._value))))}signal(e){this._flags&j||!this._output||(e===w?this._flags=this._flags&~I|te:e===C&&(this._flags=this._flags&~I|Xe),this._dispatch(b,e))}complete(){if(this._flags&j)return;this._flags=(this._flags|j)&~I|Ze;let e=this._output,n=this._flags&q;if(this._output=null,this._flags&=~(q|Y),this._singleDepCount=0,this._stop(),e)if(n)for(let t of e)t(E);else e(E)}error(e){if(this._flags&j)return;this._flags=(this._flags|j)&~I|Qe;let n=this._output,t=this._flags&q;if(this._output=null,this._flags&=~(q|Y),this._singleDepCount=0,this._stop(),n)if(t)for(let s of n)s(E,e);else n(E,e)}_start(){if(this._flags&Ee||!this._fn)return;this._flags|=Ee;let e=this._fn({emit:this.emit,signal:n=>this.signal(n),complete:()=>this.complete(),error:n=>this.error(n)});this._cleanup=typeof e=="function"?e:void 0}_stop(){this._flags&Ee&&(this._flags&=~Ee,this._cleanup&&this._cleanup(),this._cleanup=void 0,this._flags&Ce&&(this._value=this._initial),this._flags&j||(this._flags=this._flags&~I|De))}source(e,n){if(e===R){let t=n;if(this._flags&j)if(this._flags&ze&&this._output===null)this._flags=this._flags&~(j|I)|De;else{t(R,r=>{}),t(E);return}if(this._output===null)this._output=t;else if(this._flags&q)this._output.add(t);else{let r=new Set;r.add(this._output),r.add(t),this._output=r,this._flags=(this._flags|q)&~Y}let s=!1;t(R,(r,c)=>{if(r===O&&t(O,this._value),r===b&&c===ne&&!s&&(s=!0,this._singleDepCount++,this._flags&q||(this._flags|=Y)),r===E){if(s&&(s=!1,this._singleDepCount--),this._output===null)return;if(this._flags&q){let a=this._output;a.delete(t),a.size===1?(this._output=a.values().next().value,this._flags&=~q,this._singleDepCount>0&&(this._flags|=Y)):a.size===0&&(this._output=null,this._flags&=~(q|Y),this._singleDepCount=0,this._flags=this._flags&~I|De,this._stop())}else this._output===t&&(this._output=null,this._flags&=~Y,this._singleDepCount=0,this._flags=this._flags&~I|De,this._stop())}}),Pe(()=>this._start())}}};var Me=class extends ke{constructor(e,n){super(void 0,{initial:e,autoDirty:!0,equals:n?.equals??Object.is,_skipInspect:!0}),this.set=this.set.bind(this),H.register(this,{kind:"state",...n})}get(){return this._value}set(e){this._flags&j||this._value!==void 0&&this._eqFn(this._value,e)||(this._value=e,this._output&&(Se()?this._flags&J||(this._flags|=J,this._flags&ee&&(this._flags=this._flags&~I|te,this._dispatch(b,w)),Te(()=>{this._flags&=~J,this._flags=this._flags&~I|oe,this._dispatch(O,this._value)})):(this._flags&ee&&!(this._flags&Y)&&(this._flags=this._flags&~I|te,this._dispatch(b,w)),this._flags=this._flags&~I|oe,this._dispatch(O,this._value))))}update(e){this.set(e(this._value))}};function N(i,e){return new Me(i,e)}var et=0;Le.from=function(e){let n=Le({id:e.id});for(let[t,s]of Object.entries(e.channels))s!==void 0&&n.publish(t,s);return n};function Le(i){let e=++et,n=i?.id??`pubsub-${e}`,t=new Map,s=new Map,r=N(0,{name:`${n}:ver`}),c=!1;function a(p){let f=t.get(p);return f||(f=N(void 0,{name:`${n}:${p}`,equals:()=>!1}),t.set(p,f),r.update(g=>g+1)),f}function d(p){let f=s.get(p);if(!f){let g=a(p);f=D([g],()=>g.get(),{name:`${n}:${p}:view`,equals:()=>!1}),s.set(p,f)}return f}return{get id(){return n},get version(){return r.get()},publish(p,f){c||a(p).set(f)},subscribe(p){if(c)throw new Error("PubSub is destroyed");return d(p)},topics(){return Array.from(t.keys())},snapshot(){let p={};for(let[f,g]of t)p[f]=g.get();return{type:"pubsub",id:n,version:r.get(),channels:p}},destroy(){c||(c=!0,P(()=>{for(let p of s.values())L(p);s.clear();for(let p of t.values())L(p);t.clear(),L(r)}))}}}var tt=0;xe.from=function(e){let n=xe({id:e.id});for(let[t,s]of Object.entries(e.index))for(let r of s)n.add(r,[t]);return n};function xe(i){let e=++tt,n=i?.id??`ridx-${e}`,t=new Map,s=new Map,r=new Map,c=new Map,a=N(0,{name:`${n}:ver`}),d=D([a],()=>Array.from(t.keys()),{name:`${n}:keys`}),p=D([a],()=>t.size,{name:`${n}:size`}),f=!1,g=Object.freeze(new Set);function y(l){let h=r.get(l);return h||(h=N(t.get(l)??new Set,{name:`${n}:${l}`,equals:()=>!1}),r.set(l,h)),h}function $(l){let h=r.get(l);if(h){let v=t.get(l);h.set(v?new Set(v):new Set)}}function M(l,h){let v=t.get(h),x=!v;return v||(v=new Set,t.set(h,v)),v.add(l),x}function F(l,h){let v=t.get(h);return v?(v.delete(l),v.size===0?(t.delete(h),!0):!1):!1}return{get id(){return n},get version(){return a.get()},get(l){let h=t.get(l);return h?Object.freeze(new Set(h)):g},has(l){let h=t.get(l);return h!==void 0&&h.size>0},keys(){return Array.from(t.keys())},get size(){return t.size},select(l){let h=c.get(l);if(h)return h;let v=y(l);return h=D([v],()=>v.get(),{name:`${n}:${l}:select`}),c.set(l,h),h},keysStore:d,sizeStore:p,add(l,h){if(f||h.length===0)return;let v=s.get(l);v||(v=new Set,s.set(l,v)),P(()=>{let x=!1;for(let A of h)v.add(A),M(l,A)&&(x=!0),$(A);x&&a.update(A=>A+1)})},remove(l){if(f)return;let h=s.get(l);h&&P(()=>{let v=!1;for(let x of h)F(l,x)&&(v=!0),$(x);s.delete(l),v&&a.update(x=>x+1)})},update(l,h){if(f)return;let v=s.get(l),x=new Set(h);P(()=>{let A=!1;if(v)for(let S of v)x.has(S)||(F(l,S)&&(A=!0),$(S));let z=s.get(l);z||(z=new Set,s.set(l,z)),z.clear();for(let S of h)z.add(S),M(l,S)&&(A=!0),$(S);A&&a.update(S=>S+1)})},clear(){t.size!==0&&P(()=>{t.clear(),s.clear();for(let l of r.values())l.set(new Set);a.update(l=>l+1)})},snapshot(){let l={};for(let[h,v]of t)l[h]=Array.from(v);return{type:"reactiveIndex",id:n,version:a.get(),index:l}},destroy(){if(!f){f=!0,t.clear(),s.clear();for(let l of r.values())L(l);r.clear();for(let l of c.values())L(l);c.clear(),L(a)}}}}var nt=0;function Re(i=[],e){let n=++nt,t=e?.id??`rlist-${n}`,s=e?.name??t,r=!1,c=[...i],a=N(0,{name:`${s}:ver`});function d(){a.update(u=>u+1)}let p=D([a],()=>[...c],{name:`${s}:items`}),f=D([a],()=>c.length,{name:`${s}:length`}),g=new Map,y=new Map;function $(u){return c[u]}function M(u,m){r||u<0||u>=c.length||(c[u]=m,d())}function F(...u){r||u.length!==0&&(c.push(...u),d())}function W(){if(r||c.length===0)return;let u=c.pop();return d(),u}function l(u,...m){if(r||m.length===0||u<0)return;let k=Math.min(u,c.length);c.splice(k,0,...m),d()}function h(u,m=1){if(r)return[];if(u<0||u>=c.length||m<=0)return[];let k=c.splice(u,m);return d(),k}function v(u,m){if(r||u<0||u>=c.length||m<0||m>=c.length||u===m)return;let[k]=c.splice(u,1);c.splice(m,0,k),d()}function x(u,m){if(r||u<0||u>=c.length||m<0||m>=c.length||u===m)return;let k=c[u];c[u]=c[m],c[m]=k,d()}function A(){r||c.length!==0&&(c.length=0,d())}function z(u){let m=g.get(u);return m||(m=D([a],()=>c[u],{name:`${s}:at(${u})`}),g.set(u,m),m)}function S(u,m){let k=`${u},${m??""}`,B=y.get(k);return B||(B=D([a],()=>c.slice(u,m),{name:`${s}:slice(${k})`}),y.set(k,B),B)}function o(u){return D([a],()=>c.find(u),{name:`${s}:find`})}function _(){return{type:"reactiveList",id:t,version:a.get(),items:[...c]}}function T(){if(!r){r=!0,c.length=0;for(let u of g.values())L(u);g.clear();for(let u of y.values())L(u);y.clear(),L(p),L(f),L(a)}}return{get id(){return t},get version(){return a.get()},items:p,length:f,versionStore:a,get:$,set:M,push:F,pop:W,insert:l,remove:h,move:v,swap:x,clear:A,at:z,slice:S,find:o,snapshot:_,destroy:T}}Re.from=function(e,n){let t=Re([],{...n,id:e.id});return e.items.length>0&&t.push(...e.items),t};var st=0;we.from=function(e,n){let t=we({...n,id:e.id});for(let s of e.entries)t.append(s.value);return t};function we(i){let e=++st,n=i?.id??`rlog-${e}`,t=i?.maxSize??0,s=t>0,r=[],c=0,a=0,d=0,p=1,f=N(0,{name:`${n}:ver`}),g=N(void 0,{name:`${n}:events`,equals:()=>!1}),y=new Map,$=!1;function M(){if(!s)return r.slice();if(a===0)return[];let l=new Array(a);for(let h=0;h<a;h++)l[h]=r[(c+h)%t];return l}function F(l){if(!s)return r[l];if(!(l<0||l>=a))return r[(c+l)%t]}let W={get id(){return n},get version(){return f.get()},append(l){if($)return-1;let h=++d,v={seq:h,value:l};return s?(a<t?(r[(c+a)%t]=v,a++):(r[c]=v,c=(c+1)%t),p=d-a+1):(r.push(v),p=r.length>0?r[0].seq:1),f.update(x=>x+1),g.set({type:"append",seq:h,value:l}),h},appendMany(l){if($||l.length===0)return[];let h=[];return P(()=>{for(let v of l)h.push(W.append(v))}),h},get(l){if(s)return l<p||l>d||a===0?void 0:F(l-p);let h=l-p;if(!(h<0||h>=r.length))return r[h]},slice(l,h){let v=l??p,x=h??d;if((s?a:r.length)===0)return[];let z=Math.max(v,p),S=Math.min(x,d);if(z>S)return[];let o=z-p,_=S-p;if(!s)return r.slice(o,_+1);let T=[];for(let u=o;u<=_;u++)T.push(r[(c+u)%t]);return T},toArray(){return M()},get length(){return s?a:r.length},get headSeq(){return(s?a:r.length)>0?p:0},get tailSeq(){return d},clear(){(s?a:r.length)!==0&&P(()=>{s?(a=0,c=0):r.length=0,p=d+1,f.update(h=>h+1),g.set({type:"clear"})})},lengthStore:D([f],()=>s?a:r.length,{name:`${n}:length`}),latest:D([f],()=>{if((s?a:r.length)!==0)return s?r[(c+a-1)%t]:r[r.length-1]},{name:`${n}:latest`}),tail(l){let h=y.get(l);return h||(h=D([f],()=>{let v=M();return l===void 0||l>=v.length?v:v.slice(-l)},{name:`${n}:tail${l??""}`}),y.set(l,h),h)},events:g,snapshot(){return{type:"reactiveLog",id:n,version:f.get(),entries:M().map(l=>({seq:l.seq,value:l.value})),headSeq:(s?a:r.length)>0?p:0,tailSeq:d}},destroy(){$||($=!0,r.length=0,a=0,L(f),L(g))}};return W}function Fe(){let i=[],e=new Set,n=0;return{touch(){},insert(t){e.has(t)||(i.push(t),e.add(t))},delete(t){e.delete(t)},evict(t=1){let s=[];for(;s.length<t&&n<i.length;){let r=i[n++];e.delete(r)&&s.push(r)}return n>1e3&&n>i.length/2&&(i.splice(0,n),n=0),s},size:()=>e.size,clear(){i.length=0,e.clear(),n=0}}}var it=0;Ve.from=function(e,n){let t=Ve({...n,id:e.id});for(let[s,r]of e.entries)t.set(s,r);return t};function Ve(i){let e=++it,n=i?.id??`rmap-${e}`,t=i?.defaultTTL??0,s=i?.equals??Object.is,r=i?.maxSize??0,c=r>0?i?.eviction??Fe():null,a=new Map,d=new Map,p=new Map,f=new Map,g=N(0,{name:`${n}:ver`}),y=D([g],()=>Array.from(a.keys()),{name:`${n}:keys`}),$=D([g],()=>a.size,{name:`${n}:size`}),M=N(void 0,{name:`${n}:events`,equals:()=>!1}),F=new Map,W=!1,l=(o,_)=>o===void 0||_===void 0?o===_:s(o,_);function h(o){let _=d.get(o);return _||(_=N(a.get(o),{name:`${n}:${o}`,equals:l}),d.set(o,_)),_}function v(o){let _=p.get(o);_!==void 0&&(clearTimeout(_),p.delete(o)),f.delete(o)}function x(o,_){v(o),_>0&&(f.set(o,Date.now()+_),p.set(o,setTimeout(()=>{p.delete(o),f.delete(o),S.delete(o)},_)))}function A(o,_,T){M.set({type:o,key:_,value:T})}function z(){if(!c||a.size<=r)return;let o=c.evict(a.size-r);for(let _ of o)a.has(_)&&S.delete(_)}let S={get id(){return n},get version(){return g.get()},get(o){return c?.touch(o),a.get(o)},set(o,_){if(W)return;let T=!a.has(o);a.set(o,_);let u=d.get(o);u&&u.set(_),T?(z(),c?.insert(o),g.update(m=>m+1)):c?.touch(o),T&&t>0&&x(o,t),A("set",o,_)},delete(o){if(!a.has(o))return!1;a.delete(o),v(o),c?.delete(o);let _=d.get(o);return _&&_.set(void 0),g.update(T=>T+1),A("delete",o),!0},has(o){return a.has(o)},update(o,_){S.set(o,_(a.get(o)))},getOrSet(o,_){let T=a.get(o);if(T!==void 0||a.has(o))return T;let u=_();return S.set(o,u),u},keys(){return Array.from(a.keys())},values(){return Array.from(a.values())},entries(){return Array.from(a.entries())},size(){return a.size},clear(){a.size!==0&&P(()=>{for(let o of p.values())clearTimeout(o);p.clear(),f.clear(),c?.clear();for(let o of d.values())o.set(void 0);a.clear(),g.update(o=>o+1),A("clear")})},setMany(o){if(W)return;let _=Array.isArray(o)?o:Object.entries(o);P(()=>{for(let[T,u]of _)S.set(T,u)})},select(o){let _=F.get(o);if(_)return _;let T=h(o);return _=D([T],()=>T.get(),{name:`${n}:${o}:select`,equals:l}),F.set(o,_),_},keysStore:y,sizeStore:$,where(o){return D([g,M],()=>{let _=[];for(let[T,u]of a)o(u,T)&&_.push([T,u]);return _},{name:`${n}:where`})},setWithTTL(o,_,T){S.set(o,_),x(o,T)},ttl(o){let _=f.get(o);if(_===void 0)return;let T=_-Date.now();return T>0?T:0},persist(o){v(o)},events:M,namespace(o){let _=`${n}:ns:${o}`,T={get id(){return _},get version(){return g.get()},get:u=>S.get(o+u),set:(u,m)=>S.set(o+u,m),delete:u=>S.delete(o+u),has:u=>S.has(o+u),update:(u,m)=>S.update(o+u,m),getOrSet:(u,m)=>S.getOrSet(o+u,m),keys:()=>S.keys().filter(u=>u.startsWith(o)).map(u=>u.slice(o.length)),values:()=>{let u=[];for(let[m,k]of a)m.startsWith(o)&&u.push(k);return u},entries:()=>{let u=[];for(let[m,k]of a)m.startsWith(o)&&u.push([m.slice(o.length),k]);return u},size:()=>{let u=0;for(let m of a.keys())m.startsWith(o)&&u++;return u},clear:()=>{P(()=>{for(let u of S.keys())u.startsWith(o)&&S.delete(u)})},setMany:u=>{let m=Array.isArray(u)?u:Object.entries(u);P(()=>{for(let[k,B]of m)S.set(o+k,B)})},select:u=>S.select(o+u),keysStore:D([y],()=>y.get().filter(u=>u.startsWith(o)).map(u=>u.slice(o.length))),sizeStore:D([y],()=>{let u=0;for(let m of y.get())m.startsWith(o)&&u++;return u}),where:u=>D([g,M],()=>{let m=[];for(let[k,B]of a)k.startsWith(o)&&u(B,k.slice(o.length))&&m.push([k.slice(o.length),B]);return m}),setWithTTL:(u,m,k)=>S.setWithTTL(o+u,m,k),ttl:u=>S.ttl(o+u),persist:u=>S.persist(o+u),events:S.events,namespace:u=>S.namespace(o+u),snapshot:()=>({type:"reactiveMap",id:_,version:g.get(),entries:T.entries()}),destroy:()=>T.clear()};return T},snapshot(){return{type:"reactiveMap",id:n,version:g.get(),entries:Array.from(a.entries())}},destroy(){if(!W){W=!0;for(let o of p.values())clearTimeout(o);p.clear(),f.clear(),c?.clear();for(let o of d.values())L(o);d.clear();for(let o of F.values())L(o);F.clear(),L(g),L(M),a.clear()}}};return S}0&&(module.exports={pubsub,reactiveIndex,reactiveList,reactiveLog,reactiveMap});
|
|
4
|
+
`)}static annotate(e,n){if(!i.enabled)return;i._annotations.set(e,n);let t={node:i._resolveKey(e),reason:n,timestamp:Date.now()},s=i.maxTraceEntries;s<=0||(i._traceLog.length<s?i._traceLog.push(t):(i._traceLog[i._traceHead]=t,i._traceFull=!0),i._traceHead=(i._traceHead+1)%s)}static getAnnotation(e){return i._annotations.get(e)}static traceLog(){return i._traceFull?[...i._traceLog.slice(i._traceHead),...i._traceLog.slice(0,i._traceHead)]:i._traceLog.slice(0,i._traceHead||i._traceLog.length)}static clearTrace(){i._traceLog=[],i._traceHead=0,i._traceFull=!1}static _reset(){i._names=new WeakMap,i._kinds=new WeakMap,i._keys=new WeakMap,i._stores=new Set,i._edges=new Map,i._usedKeys=new Set,i._nextId=0,i._explicitEnabled=null,i._cachedDefault=null,i._annotations=new WeakMap,i._traceLog=[],i._traceHead=0,i._traceFull=!1,i.maxTraceEntries=1e3}};var Z=1,Q=2,ie=4,U=8,G=32,Ne=64,Ge=de<<K,X=he<<K,Ie=ge<<K,re=pe<<K,Je=_e<<K,ye=me<<K,V=se,be=class{_output=null;_upstreamTalkbacks=[];_cachedValue;_flags;_dirtyDeps;_eqFn;_deps;_fn;get _status(){return ve(this._flags)}constructor(e,n,t,s){this._deps=e,this._fn=n,this._eqFn=t?.equals,this._flags=s?Ne:0,this._dirtyDeps=new ae(e.length),this.source=this.source.bind(this),H.register(this,{kind:"derived",...t,deps:e});for(let r of e)H.registerEdge(r,this)}_dispatch(e,n){let t=this._output;if(t)if(this._flags&G)for(let s of t)s(e,n);else t(e,n)}_recompute(){let e;try{e=this._fn()}catch(n){this._handleEnd(n);return}if(this._eqFn&&this._flags&Z&&this._eqFn(this._cachedValue,e)){this._flags=this._flags&~V|re,this._dispatch(b,C);return}this._cachedValue=e,this._flags=(this._flags|Z)&~V|Ie,this._dispatch(O,this._cachedValue)}_recomputeIdentity(e){if(!(this._flags&U)){if(this._eqFn&&this._flags&Z&&this._eqFn(this._cachedValue,e)){this._flags=this._flags&~V|re,this._dispatch(b,C);return}this._cachedValue=e,this._flags=(this._flags|Z)&~V|Ie,this._dispatch(O,e)}}_lazyConnect(){if(!(this._flags&(Q|U))){try{this._cachedValue=this._fn()}catch(e){this._handleEnd(e);return}this._flags=(this._flags|Z)&~V|Ie,Ae(),this._connectUpstream(),this._flags&U||(this._flags|=Q),Ke()}}_connectUpstream(){this._upstreamTalkbacks.length=0,this._deps.length===1?this._flags&Ne?this._connectSingleDepIdentity():this._connectSingleDep():this._connectMultiDep()}_connectSingleDep(){let e=!1;this._deps[0].source(R,(n,t)=>{if(n===R){this._upstreamTalkbacks.push(t),t(b,ne);return}if(!(this._flags&U))if(n===b)if(t===w){if(e)return;e=!0,this._flags=this._flags&~V|X,this._dispatch(b,w)}else t===C?e&&(e=!1,this._flags=this._flags&~V|re,this._dispatch(b,C)):this._dispatch(b,t);else n===O?e?(e=!1,this._recompute()):(this._flags=this._flags&~V|X,this._dispatch(b,w),this._recompute()):n===E&&this._handleEnd(t)})}_connectSingleDepIdentity(){let e=!1;this._deps[0].source(R,(n,t)=>{if(n===R){this._upstreamTalkbacks.push(t),t(b,ne);return}this._flags&U||(n===b?t===w?(e=!0,this._flags=this._flags&~V|X,this._dispatch(b,w)):t===C?e&&(e=!1,this._flags=this._flags&~V|re,this._dispatch(b,C)):this._dispatch(b,t):n===O?e?(e=!1,this._recomputeIdentity(t)):(this._flags=this._flags&~V|X,this._dispatch(b,w),this._recomputeIdentity(t)):n===E&&this._handleEnd(t))})}_connectMultiDep(){for(let e=0;e<this._deps.length&&!(this._flags&U);e++){let n=e;this._deps[n].source(R,(t,s)=>{if(t===R){this._upstreamTalkbacks.push(s);return}if(!(this._flags&U))if(t===b)if(s===w){let r=this._dirtyDeps.empty();this._dirtyDeps.set(n),r&&(this._flags&=~ie,this._flags=this._flags&~V|X,this._dispatch(b,w))}else s===C?this._dirtyDeps.test(n)&&(this._dirtyDeps.clear(n),this._dirtyDeps.empty()&&(this._flags&ie?this._recompute():(this._flags=this._flags&~V|re,this._dispatch(b,C)))):this._dispatch(b,s);else t===O?this._dirtyDeps.test(n)?(this._dirtyDeps.clear(n),this._flags|=ie,this._dirtyDeps.empty()&&this._recompute()):this._dirtyDeps.empty()?(this._flags=this._flags&~V|X,this._dispatch(b,w),this._recompute()):this._flags|=ie:t===E&&this._handleEnd(s)})}}_handleEnd(e){this._flags|=U,this._flags=this._flags&~V|(e!==void 0?ye:Je),e!==void 0&&(this._cachedValue=e);for(let s of this._upstreamTalkbacks)s(E);this._upstreamTalkbacks=[],this._flags&=~Q,this._dirtyDeps.reset();let n=this._output,t=this._flags&G;if(this._output=null,this._flags&=~G,n)if(t)for(let s of n)try{e!==void 0?s(E,e):s(E)}catch{}else e!==void 0?n(E,e):n(E)}_disconnectUpstream(){for(let e of this._upstreamTalkbacks)e(E);this._upstreamTalkbacks.length=0,this._flags&=~(Q|ie),this._flags=this._flags&~V|Ge,this._dirtyDeps.reset()}get(){if(this._flags&Q)return this._cachedValue;if(this._flags&U){if((this._flags&V)===ye)throw this._cachedValue;return this._cachedValue}let e=this._fn();return this._cachedValue=e,this._flags|=Z,e}source(e,n){if(e===R){let t=n;if(this._flags&U){let s=(this._flags&V)===ye;t(R,r=>{}),s?t(E,this._cachedValue):t(E);return}if(!(this._flags&Q)&&(this._lazyConnect(),this._flags&U)){let s=(this._flags&V)===ye;t(R,r=>{}),s?t(E,this._cachedValue):t(E);return}if(this._output===null)this._output=t;else if(this._flags&G)this._output.add(t);else{let s=new Set;s.add(this._output),s.add(t),this._output=s,this._flags|=G}t(R,s=>{if(s===O&&t(O,this._cachedValue),s===E){if(this._output===null)return;if(this._flags&G){let r=this._output;r.delete(t),r.size===1?(this._output=r.values().next().value,this._flags&=~G):r.size===0&&(this._output=null,this._flags&=~G,this._disconnectUpstream())}else this._output===t&&(this._output=null,this._disconnectUpstream())}})}}};function D(i,e,n){return new be(i,e,n)}(e=>{function i(n,t){return new be([n],()=>n.get(),t,!0)}e.from=i})(D||={});var Ee=1,q=64,j=2,ee=4,Ce=8,ze=16,J=32,Y=1024,I=se,te=he<<K,oe=ge<<K,De=de<<K,Ze=_e<<K,Qe=me<<K,Xe=pe<<K,ke=class{_value;_output=null;_flags;get _status(){return ve(this._flags)}_cleanup;_fn;_eqFn;_getterFn;_initial;_singleDepCount=0;constructor(e,n){this._value=n?.initial,this._fn=e,this._eqFn=n?.equals,this._getterFn=n?.getter,this._initial=n?.initial;let t=0;n?.autoDirty!==!1&&(t|=ee),n?.resetOnTeardown&&(t|=Ce),n?.resubscribable&&(t|=ze),this._flags=t,this.source=this.source.bind(this),this.emit=this.emit.bind(this),n?._skipInspect||H.register(this,{kind:"producer",...n})}get(){return this._getterFn?this._getterFn(this._value):this._value}_dispatch(e,n){let t=this._output;if(t)if(this._flags&q)for(let s of t)s(e,n);else t(e,n)}emit(e){this._flags&j||this._eqFn&&this._value!==void 0&&this._eqFn(this._value,e)||(this._value=e,this._output&&(Se()?this._flags&J||(this._flags|=J,this._flags&ee&&(this._flags=this._flags&~I|te,this._dispatch(b,w)),Te(()=>{this._flags&=~J,this._flags=this._flags&~I|oe,this._dispatch(O,this._value)})):(this._flags&ee&&!(this._flags&Y)&&(this._flags=this._flags&~I|te,this._dispatch(b,w)),this._flags=this._flags&~I|oe,this._dispatch(O,this._value))))}signal(e){this._flags&j||!this._output||(e===w?this._flags=this._flags&~I|te:e===C&&(this._flags=this._flags&~I|Xe),this._dispatch(b,e))}complete(){if(this._flags&j)return;this._flags=(this._flags|j)&~I|Ze;let e=this._output,n=this._flags&q;if(this._output=null,this._flags&=~(q|Y),this._singleDepCount=0,this._stop(),e)if(n)for(let t of e)t(E);else e(E)}error(e){if(this._flags&j)return;this._flags=(this._flags|j)&~I|Qe;let n=this._output,t=this._flags&q;if(this._output=null,this._flags&=~(q|Y),this._singleDepCount=0,this._stop(),n)if(t)for(let s of n)s(E,e);else n(E,e)}_start(){if(this._flags&Ee||!this._fn)return;this._flags|=Ee;let e=this._fn({emit:this.emit,signal:n=>this.signal(n),complete:()=>this.complete(),error:n=>this.error(n)});this._cleanup=typeof e=="function"?e:void 0}_stop(){this._flags&Ee&&(this._flags&=~Ee,this._cleanup&&this._cleanup(),this._cleanup=void 0,this._flags&Ce&&(this._value=this._initial),this._flags&j||(this._flags=this._flags&~I|De))}source(e,n){if(e===R){let t=n;if(this._flags&j)if(this._flags&ze&&this._output===null)this._flags=this._flags&~(j|I)|De;else{t(R,r=>{}),t(E);return}if(this._output===null)this._output=t;else if(this._flags&q)this._output.add(t);else{let r=new Set;r.add(this._output),r.add(t),this._output=r,this._flags=(this._flags|q)&~Y}let s=!1;t(R,(r,c)=>{if(r===O&&t(O,this._value),r===b&&c===ne&&!s&&(s=!0,this._singleDepCount++,this._flags&q||(this._flags|=Y)),r===E){if(s&&(s=!1,this._singleDepCount--),this._output===null)return;if(this._flags&q){let a=this._output;a.delete(t),a.size===1?(this._output=a.values().next().value,this._flags&=~q,this._singleDepCount>0&&(this._flags|=Y)):a.size===0&&(this._output=null,this._flags&=~(q|Y),this._singleDepCount=0,this._flags=this._flags&~I|De,this._stop())}else this._output===t&&(this._output=null,this._flags&=~Y,this._singleDepCount=0,this._flags=this._flags&~I|De,this._stop())}}),Pe(()=>this._start())}}};var Me=class extends ke{constructor(e,n){super(void 0,{initial:e,autoDirty:!0,equals:n?.equals??Object.is,_skipInspect:!0}),this.set=this.set.bind(this),H.register(this,{kind:"state",...n})}get(){return this._value}set(e){this._flags&j||this._value!==void 0&&this._eqFn(this._value,e)||(this._value=e,this._output&&(Se()?this._flags&J||(this._flags|=J,this._flags&ee&&(this._flags=this._flags&~I|te,this._dispatch(b,w)),Te(()=>{this._flags&=~J,this._flags=this._flags&~I|oe,this._dispatch(O,this._value)})):(this._flags&ee&&!(this._flags&Y)&&(this._flags=this._flags&~I|te,this._dispatch(b,w)),this._flags=this._flags&~I|oe,this._dispatch(O,this._value))))}update(e){this.set(e(this._value))}};function N(i,e){return new Me(i,e)}var et=0;Le.from=function(e){let n=Le({id:e.id});for(let[t,s]of Object.entries(e.channels))s!==void 0&&n.publish(t,s);return n};function Le(i){let e=++et,n=i?.id??`pubsub-${e}`,t=new Map,s=new Map,r=N(0,{name:`${n}:ver`}),c=!1;function a(p){let f=t.get(p);return f||(f=N(void 0,{name:`${n}:${p}`,equals:()=>!1}),t.set(p,f),r.update(g=>g+1)),f}function d(p){let f=s.get(p);if(!f){let g=a(p);f=D([g],()=>g.get(),{name:`${n}:${p}:view`,equals:()=>!1}),s.set(p,f)}return f}return{get id(){return n},get version(){return r.get()},publish(p,f){c||a(p).set(f)},subscribe(p){if(c)throw new Error("PubSub is destroyed");return d(p)},topics(){return Array.from(t.keys())},snapshot(){let p={};for(let[f,g]of t)p[f]=g.get();return{type:"pubsub",id:n,version:r.get(),channels:p}},destroy(){c||(c=!0,P(()=>{for(let p of s.values())L(p);s.clear();for(let p of t.values())L(p);t.clear(),L(r)}))}}}var tt=0;xe.from=function(e){let n=xe({id:e.id});for(let[t,s]of Object.entries(e.index))for(let r of s)n.add(r,[t]);return n};function xe(i){let e=++tt,n=i?.id??`ridx-${e}`,t=new Map,s=new Map,r=new Map,c=new Map,a=N(0,{name:`${n}:ver`}),d=D([a],()=>Array.from(t.keys()),{name:`${n}:keys`}),p=D([a],()=>t.size,{name:`${n}:size`}),f=!1,g=Object.freeze(new Set);function y(l){let h=r.get(l);return h||(h=N(t.get(l)??new Set,{name:`${n}:${l}`,equals:()=>!1}),r.set(l,h)),h}function $(l){let h=r.get(l);if(h){let v=t.get(l);h.set(v?new Set(v):new Set)}}function M(l,h){let v=t.get(h),x=!v;return v||(v=new Set,t.set(h,v)),v.add(l),x}function F(l,h){let v=t.get(h);return v?(v.delete(l),v.size===0?(t.delete(h),!0):!1):!1}return{get id(){return n},get version(){return a.get()},get(l){let h=t.get(l);return h?Object.freeze(new Set(h)):g},has(l){let h=t.get(l);return h!==void 0&&h.size>0},keys(){return Array.from(t.keys())},get size(){return t.size},select(l){let h=c.get(l);if(h)return h;let v=y(l);return h=D([v],()=>v.get(),{name:`${n}:${l}:select`}),c.set(l,h),h},keysStore:d,sizeStore:p,add(l,h){if(f||h.length===0)return;let v=s.get(l);v||(v=new Set,s.set(l,v)),P(()=>{let x=!1;for(let A of h)v.add(A),M(l,A)&&(x=!0),$(A);x&&a.update(A=>A+1)})},remove(l){if(f)return;let h=s.get(l);h&&P(()=>{let v=!1;for(let x of h)F(l,x)&&(v=!0),$(x);s.delete(l),v&&a.update(x=>x+1)})},update(l,h){if(f)return;let v=s.get(l),x=new Set(h);P(()=>{let A=!1;if(v)for(let S of v)x.has(S)||(F(l,S)&&(A=!0),$(S));let z=s.get(l);z||(z=new Set,s.set(l,z)),z.clear();for(let S of h)z.add(S),M(l,S)&&(A=!0),$(S);A&&a.update(S=>S+1)})},clear(){t.size!==0&&P(()=>{t.clear(),s.clear();for(let l of r.values())l.set(new Set);a.update(l=>l+1)})},snapshot(){let l={};for(let[h,v]of t)l[h]=Array.from(v);return{type:"reactiveIndex",id:n,version:a.get(),index:l}},destroy(){if(!f){f=!0,t.clear(),s.clear();for(let l of r.values())L(l);r.clear();for(let l of c.values())L(l);c.clear(),L(a)}}}}var nt=0;function Re(i=[],e){let n=++nt,t=e?.id??`rlist-${n}`,s=e?.name??t,r=!1,c=[...i],a=N(0,{name:`${s}:ver`});function d(){a.update(u=>u+1)}let p=D([a],()=>[...c],{name:`${s}:items`}),f=D([a],()=>c.length,{name:`${s}:length`}),g=new Map,y=new Map;function $(u){return c[u]}function M(u,m){r||u<0||u>=c.length||(c[u]=m,d())}function F(...u){r||u.length!==0&&(c.push(...u),d())}function W(){if(r||c.length===0)return;let u=c.pop();return d(),u}function l(u,...m){if(r||m.length===0||u<0)return;let k=Math.min(u,c.length);c.splice(k,0,...m),d()}function h(u,m=1){if(r)return[];if(u<0||u>=c.length||m<=0)return[];let k=c.splice(u,m);return d(),k}function v(u,m){if(r||u<0||u>=c.length||m<0||m>=c.length||u===m)return;let[k]=c.splice(u,1);c.splice(m,0,k),d()}function x(u,m){if(r||u<0||u>=c.length||m<0||m>=c.length||u===m)return;let k=c[u];c[u]=c[m],c[m]=k,d()}function A(){r||c.length!==0&&(c.length=0,d())}function z(u){let m=g.get(u);return m||(m=D([a],()=>c[u],{name:`${s}:at(${u})`}),g.set(u,m),m)}function S(u,m){let k=`${u},${m??""}`,B=y.get(k);return B||(B=D([a],()=>c.slice(u,m),{name:`${s}:slice(${k})`}),y.set(k,B),B)}function o(u){return D([a],()=>c.find(u),{name:`${s}:find`})}function _(){return{type:"reactiveList",id:t,version:a.get(),items:[...c]}}function T(){if(!r){r=!0,c.length=0;for(let u of g.values())L(u);g.clear();for(let u of y.values())L(u);y.clear(),L(p),L(f),L(a)}}return{get id(){return t},get version(){return a.get()},items:p,length:f,versionStore:a,get:$,set:M,push:F,pop:W,insert:l,remove:h,move:v,swap:x,clear:A,at:z,slice:S,find:o,snapshot:_,destroy:T}}Re.from=function(e,n){let t=Re([],{...n,id:e.id});return e.items.length>0&&t.push(...e.items),t};var st=0;we.from=function(e,n){let t=we({...n,id:e.id});for(let s of e.entries)t.append(s.value);return t};function we(i){let e=++st,n=i?.id??`rlog-${e}`,t=i?.maxSize??0,s=t>0,r=[],c=0,a=0,d=0,p=1,f=N(0,{name:`${n}:ver`}),g=N(void 0,{name:`${n}:events`,equals:()=>!1}),y=new Map,$=!1;function M(){if(!s)return r.slice();if(a===0)return[];let l=new Array(a);for(let h=0;h<a;h++)l[h]=r[(c+h)%t];return l}function F(l){if(!s)return r[l];if(!(l<0||l>=a))return r[(c+l)%t]}let W={get id(){return n},get version(){return f.get()},append(l){if($)return-1;let h=++d,v={seq:h,value:l};return s?(a<t?(r[(c+a)%t]=v,a++):(r[c]=v,c=(c+1)%t),p=d-a+1):(r.push(v),p=r.length>0?r[0].seq:1),f.update(x=>x+1),g.set({type:"append",seq:h,value:l}),h},appendMany(l){if($||l.length===0)return[];let h=[];return P(()=>{for(let v of l)h.push(W.append(v))}),h},get(l){if(s)return l<p||l>d||a===0?void 0:F(l-p);let h=l-p;if(!(h<0||h>=r.length))return r[h]},slice(l,h){let v=l??p,x=h??d;if((s?a:r.length)===0)return[];let z=Math.max(v,p),S=Math.min(x,d);if(z>S)return[];let o=z-p,_=S-p;if(!s)return r.slice(o,_+1);let T=[];for(let u=o;u<=_;u++)T.push(r[(c+u)%t]);return T},toArray(){return M()},get length(){return s?a:r.length},get headSeq(){return(s?a:r.length)>0?p:0},get tailSeq(){return d},clear(){(s?a:r.length)!==0&&P(()=>{s?(a=0,c=0):r.length=0,p=d+1,f.update(h=>h+1),g.set({type:"clear"})})},lengthStore:D([f],()=>s?a:r.length,{name:`${n}:length`}),latest:D([f],()=>{if((s?a:r.length)!==0)return s?r[(c+a-1)%t]:r[r.length-1]},{name:`${n}:latest`}),tail(l){let h=y.get(l);return h||(h=D([f],()=>{let v=M();return l===void 0||l>=v.length?v:v.slice(-l)},{name:`${n}:tail${l??""}`}),y.set(l,h),h)},events:g,snapshot(){return{type:"reactiveLog",id:n,version:f.get(),entries:M().map(l=>({seq:l.seq,value:l.value})),headSeq:(s?a:r.length)>0?p:0,tailSeq:d}},destroy(){$||($=!0,r.length=0,a=0,L(f),L(g))}};return W}function Fe(){let i=[],e=new Set,n=0;return{touch(){},insert(t){e.has(t)||(i.push(t),e.add(t))},delete(t){e.delete(t)},evict(t=1){let s=[];for(;s.length<t&&n<i.length;){let r=i[n++];e.delete(r)&&s.push(r)}return n>1e3&&n>i.length/2&&(i.splice(0,n),n=0),s},size:()=>e.size,clear(){i.length=0,e.clear(),n=0}}}var it=0;Ve.from=function(e,n){let t=Ve({...n,id:e.id});for(let[s,r]of e.entries)t.set(s,r);return t};function Ve(i){let e=++it,n=i?.id??`rmap-${e}`,t=i?.defaultTTL??0,s=i?.equals??Object.is,r=i?.maxSize??0,c=r>0?i?.eviction??Fe():null,a=new Map,d=new Map,p=new Map,f=new Map,g=N(0,{name:`${n}:ver`}),y=D([g],()=>Array.from(a.keys()),{name:`${n}:keys`}),$=D([g],()=>a.size,{name:`${n}:size`}),M=N(void 0,{name:`${n}:events`,equals:()=>!1}),F=new Map,W=!1,l=(o,_)=>o===void 0||_===void 0?o===_:s(o,_);function h(o){let _=d.get(o);return _||(_=N(a.get(o),{name:`${n}:${o}`,equals:l}),d.set(o,_)),_}function v(o){let _=p.get(o);_!==void 0&&(clearTimeout(_),p.delete(o)),f.delete(o)}function x(o,_){v(o),_>0&&(f.set(o,Date.now()+_),p.set(o,setTimeout(()=>{p.delete(o),f.delete(o),S.delete(o)},_)))}function A(o,_,T){M.set({type:o,key:_,value:T})}function z(){if(!c||a.size<=r)return;let o=c.evict(a.size-r);for(let _ of o)a.has(_)&&S.delete(_)}let S={get id(){return n},get version(){return g.get()},get(o){return c?.touch(o),a.get(o)},set(o,_){if(W)return;let T=!a.has(o);a.set(o,_);let u=d.get(o);u&&u.set(_),T?(z(),c?.insert(o),g.update(m=>m+1)):c?.touch(o),T&&t>0&&x(o,t),A("set",o,_)},delete(o){if(!a.has(o))return!1;a.delete(o),v(o),c?.delete(o);let _=d.get(o);return _&&_.set(void 0),g.update(T=>T+1),A("delete",o),!0},has(o){return a.has(o)},update(o,_){S.set(o,_(a.get(o)))},getOrSet(o,_){let T=a.get(o);if(T!==void 0||a.has(o))return T;let u=_();return S.set(o,u),u},keys(){return Array.from(a.keys())},values(){return Array.from(a.values())},entries(){return Array.from(a.entries())},size(){return a.size},clear(){a.size!==0&&P(()=>{for(let o of p.values())clearTimeout(o);p.clear(),f.clear(),c?.clear();for(let o of d.values())o.set(void 0);a.clear(),g.update(o=>o+1),A("clear")})},setMany(o){if(W)return;let _=Array.isArray(o)?o:Object.entries(o);P(()=>{for(let[T,u]of _)S.set(T,u)})},select(o){let _=F.get(o);if(_)return _;let T=h(o);return _=D([T],()=>T.get(),{name:`${n}:${o}:select`,equals:l}),F.set(o,_),_},keysStore:y,sizeStore:$,where(o){return D([g,M],()=>{let _=[];for(let[T,u]of a)o(u,T)&&_.push([T,u]);return _},{name:`${n}:where`})},setWithTTL(o,_,T){S.set(o,_),x(o,T)},ttl(o){let _=f.get(o);if(_===void 0)return;let T=_-Date.now();return T>0?T:0},persist(o){v(o)},events:M,namespace(o){let _=`${n}:ns:${o}`,T={get id(){return _},get version(){return g.get()},get:u=>S.get(o+u),set:(u,m)=>S.set(o+u,m),delete:u=>S.delete(o+u),has:u=>S.has(o+u),update:(u,m)=>S.update(o+u,m),getOrSet:(u,m)=>S.getOrSet(o+u,m),keys:()=>S.keys().filter(u=>u.startsWith(o)).map(u=>u.slice(o.length)),values:()=>{let u=[];for(let[m,k]of a)m.startsWith(o)&&u.push(k);return u},entries:()=>{let u=[];for(let[m,k]of a)m.startsWith(o)&&u.push([m.slice(o.length),k]);return u},size:()=>{let u=0;for(let m of a.keys())m.startsWith(o)&&u++;return u},clear:()=>{P(()=>{for(let u of S.keys())u.startsWith(o)&&S.delete(u)})},setMany:u=>{let m=Array.isArray(u)?u:Object.entries(u);P(()=>{for(let[k,B]of m)S.set(o+k,B)})},select:u=>S.select(o+u),keysStore:D([y],()=>y.get().filter(u=>u.startsWith(o)).map(u=>u.slice(o.length))),sizeStore:D([y],()=>{let u=0;for(let m of y.get())m.startsWith(o)&&u++;return u}),where:u=>D([g,M],()=>{let m=[];for(let[k,B]of a)k.startsWith(o)&&u(B,k.slice(o.length))&&m.push([k.slice(o.length),B]);return m}),setWithTTL:(u,m,k)=>S.setWithTTL(o+u,m,k),ttl:u=>S.ttl(o+u),persist:u=>S.persist(o+u),events:S.events,namespace:u=>S.namespace(o+u),snapshot:()=>({type:"reactiveMap",id:_,version:g.get(),entries:T.entries()}),destroy:()=>T.clear()};return T},snapshot(){return{type:"reactiveMap",id:n,version:g.get(),entries:Array.from(a.entries())}},destroy(){if(!W){W=!0;for(let o of p.values())clearTimeout(o);p.clear(),f.clear(),c?.clear();for(let o of d.values())L(o);d.clear();for(let o of F.values())L(o);F.clear(),L(g),L(M),a.clear()}}};return S}0&&(module.exports={pubsub,reactiveIndex,reactiveList,reactiveLog,reactiveMap});
|