@graphrefly/graphrefly 0.30.0 → 0.31.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.
Files changed (178) hide show
  1. package/dist/{cascading-dNCtjW8j.d.cts → cascading-BfQmSmjU.d.cts} +21 -2
  2. package/dist/{cascading-BszPheHD.d.ts → cascading-D3sapjue.d.ts} +21 -2
  3. package/dist/{chunk-T5SHIKJD.js → chunk-3JRKP4BH.js} +1 -1
  4. package/dist/{chunk-GJR3P6JG.js → chunk-3Q2WXM6X.js} +1 -1
  5. package/dist/chunk-4KAUNEKV.js +3 -0
  6. package/dist/{chunk-SLMYTGTU.js → chunk-4UUDNFYG.js} +1 -1
  7. package/dist/chunk-4VXL3UZK.js +1 -0
  8. package/dist/{chunk-AV3PIDFQ.js → chunk-4ZPO2EL5.js} +1 -1
  9. package/dist/{chunk-VWPRPPKR.js → chunk-5LJAQTSS.js} +1 -1
  10. package/dist/{chunk-W4TSQ6RJ.js → chunk-7AJKUA36.js} +1 -1
  11. package/dist/{chunk-RD52SNH2.js → chunk-7EJTWGKW.js} +1 -1
  12. package/dist/{chunk-GNCBXARM.js → chunk-7EQPXQ7H.js} +1 -1
  13. package/dist/chunk-7QMVU3IX.js +1 -0
  14. package/dist/{chunk-BA5URFYW.js → chunk-A4JT4SAD.js} +1 -1
  15. package/dist/chunk-ASDKRNOJ.js +60 -0
  16. package/dist/{chunk-Y32RJO24.js → chunk-CZVYLXFK.js} +1 -1
  17. package/dist/{chunk-567NWZ3T.js → chunk-DWIAG62L.js} +1 -1
  18. package/dist/{chunk-33FA6V4B.js → chunk-EBQ6FXKW.js} +1 -1
  19. package/dist/chunk-FTA5TB2A.js +1 -0
  20. package/dist/{chunk-P7JXGKDO.js → chunk-GF5T7PGC.js} +1 -1
  21. package/dist/{chunk-WANIEEKV.js → chunk-I4U3TPK2.js} +1 -1
  22. package/dist/{chunk-KA6MMXIY.js → chunk-JMGGCSIC.js} +1 -1
  23. package/dist/chunk-JXRZXP3N.js +1 -0
  24. package/dist/{chunk-5Z4HDCO6.js → chunk-K54OKWNY.js} +1 -1
  25. package/dist/{chunk-DDPYNMGG.js → chunk-KN4Q5MQO.js} +1 -1
  26. package/dist/chunk-LWGLBCMU.js +1 -0
  27. package/dist/{chunk-TWMEGG45.js → chunk-N2KKISCE.js} +1 -1
  28. package/dist/{chunk-4OFIQ66T.js → chunk-OKQUPJRY.js} +1 -1
  29. package/dist/chunk-PNTBXOQ6.js +5 -0
  30. package/dist/chunk-PSQNYY72.js +7 -0
  31. package/dist/{chunk-XHVB6G6M.js → chunk-PZP4MEXK.js} +1 -1
  32. package/dist/{chunk-7TDOES3L.js → chunk-Q2SY7M7K.js} +1 -1
  33. package/dist/{chunk-OL33ZI6R.js → chunk-RWGJQQLT.js} +1 -1
  34. package/dist/chunk-SGS4OJGS.js +1 -0
  35. package/dist/chunk-UMH3HSP7.js +1 -0
  36. package/dist/{chunk-BZP5T4X6.js → chunk-W6FQIFVE.js} +1 -1
  37. package/dist/{chunk-SHYH5SXV.js → chunk-WLPVGXQ6.js} +1 -1
  38. package/dist/chunk-WQ7I7JVU.js +1 -0
  39. package/dist/{chunk-XQAXYVXX.js → chunk-WYJTXYWX.js} +1 -1
  40. package/dist/{chunk-3NEPQO2E.js → chunk-X2VHDT26.js} +1 -1
  41. package/dist/{chunk-GLSM33ZM.js → chunk-XEFAMCEA.js} +1 -1
  42. package/dist/{chunk-AUY2YKCO.js → chunk-XRSHMHEG.js} +1 -1
  43. package/dist/chunk-Y26UN6J5.js +18 -0
  44. package/dist/{chunk-BKPLTBL5.js → chunk-YQJPYEAL.js} +1 -1
  45. package/dist/{chunk-73Z3W2RN.js → chunk-YZ6VYLFD.js} +1 -1
  46. package/dist/{chunk-4JJCCD5S.js → chunk-YZKGGMPT.js} +1 -1
  47. package/dist/chunk-Z3UWIJ3A.js +1 -0
  48. package/dist/{chunk-Y36UZ5VS.js → chunk-ZM7C2FUM.js} +1 -1
  49. package/dist/compat/index.cjs +1 -1
  50. package/dist/compat/index.js +1 -1
  51. package/dist/compat/jotai/index.cjs +1 -1
  52. package/dist/compat/jotai/index.js +1 -1
  53. package/dist/compat/nanostores/index.cjs +1 -1
  54. package/dist/compat/nanostores/index.js +1 -1
  55. package/dist/compat/nestjs/index.cjs +5 -5
  56. package/dist/compat/nestjs/index.js +1 -1
  57. package/dist/compat/zustand/index.cjs +1 -1
  58. package/dist/compat/zustand/index.js +1 -1
  59. package/dist/{composite-DGspwCqk.d.ts → composite-BY9hMxN7.d.ts} +1 -1
  60. package/dist/{composite-nrRumJ7l.d.cts → composite-CH0S8DFn.d.cts} +1 -1
  61. package/dist/content-addressed-storage-BUiREIuj.d.ts +124 -0
  62. package/dist/content-addressed-storage-DqIWCmZG.d.cts +124 -0
  63. package/dist/core/index.cjs +1 -1
  64. package/dist/core/index.js +1 -1
  65. package/dist/extra/browser.cjs +1 -1
  66. package/dist/extra/browser.js +1 -1
  67. package/dist/extra/index.cjs +18 -18
  68. package/dist/extra/index.d.cts +6 -5
  69. package/dist/extra/index.d.ts +6 -5
  70. package/dist/extra/index.js +1 -1
  71. package/dist/extra/node.cjs +2 -2
  72. package/dist/extra/node.js +1 -1
  73. package/dist/extra/operators.cjs +1 -1
  74. package/dist/extra/operators.d.cts +41 -1
  75. package/dist/extra/operators.d.ts +41 -1
  76. package/dist/extra/operators.js +1 -1
  77. package/dist/extra/reactive.cjs +1 -1
  78. package/dist/extra/reactive.d.cts +1 -1
  79. package/dist/extra/reactive.d.ts +1 -1
  80. package/dist/extra/reactive.js +1 -1
  81. package/dist/extra/sources.cjs +1 -1
  82. package/dist/extra/sources.d.cts +62 -2
  83. package/dist/extra/sources.d.ts +62 -2
  84. package/dist/extra/sources.js +1 -1
  85. package/dist/extra/storage-browser.cjs +1 -1
  86. package/dist/extra/storage-browser.js +1 -1
  87. package/dist/{fallback-BaTS7vVY.d.cts → fallback-Cb3GH1O7.d.cts} +6 -14
  88. package/dist/{fallback-eOm3LNxP.d.ts → fallback-DRjJ_ZM8.d.ts} +6 -14
  89. package/dist/graph/index.cjs +4 -4
  90. package/dist/graph/index.js +1 -1
  91. package/dist/{index-ClB7TCfL.d.cts → index-BMe3pCom.d.cts} +1 -1
  92. package/dist/{index-Dljd76bC.d.ts → index-BXzl1NDD.d.ts} +1 -1
  93. package/dist/{index-ClgKmOHe.d.ts → index-Bd6oFZqO.d.ts} +223 -115
  94. package/dist/{index-BJHQUCZx.d.ts → index-CJymKyzT.d.ts} +81 -6
  95. package/dist/{index-D6ajK8Mh.d.cts → index-CZChc85Q.d.cts} +223 -115
  96. package/dist/{index-BXbQUn4n.d.ts → index-CcS0t-l2.d.ts} +1 -1
  97. package/dist/{index-B2HBxvMb.d.ts → index-CwhcFzTA.d.ts} +1 -1
  98. package/dist/{index-B8Aj_z8S.d.cts → index-D-kHVedZ.d.cts} +1 -1
  99. package/dist/{index-ybtSyjWB.d.cts → index-DD7RhHNJ.d.cts} +1 -1
  100. package/dist/{index-BHu_Wba0.d.cts → index-Dm3_D5Ta.d.cts} +1 -1
  101. package/dist/{index-Cc8VQIgL.d.ts → index-DxMS0cHM.d.ts} +1 -1
  102. package/dist/{index-BS220yqj.d.cts → index-gJQqJTKx.d.cts} +81 -6
  103. package/dist/index.cjs +99 -121
  104. package/dist/index.d.cts +14 -13
  105. package/dist/index.d.ts +14 -13
  106. package/dist/index.js +1 -1
  107. package/dist/patterns/ai/browser.cjs +5 -22
  108. package/dist/patterns/ai/browser.d.cts +3 -3
  109. package/dist/patterns/ai/browser.d.ts +3 -3
  110. package/dist/patterns/ai/browser.js +1 -1
  111. package/dist/patterns/ai/index.cjs +27 -44
  112. package/dist/patterns/ai/index.d.cts +9 -7
  113. package/dist/patterns/ai/index.d.ts +9 -7
  114. package/dist/patterns/ai/index.js +1 -1
  115. package/dist/patterns/ai/node.cjs +2 -2
  116. package/dist/patterns/ai/node.d.cts +5 -4
  117. package/dist/patterns/ai/node.d.ts +5 -4
  118. package/dist/patterns/ai/node.js +1 -1
  119. package/dist/patterns/audit/index.cjs +3 -3
  120. package/dist/patterns/audit/index.js +1 -1
  121. package/dist/patterns/cqrs/index.cjs +6 -6
  122. package/dist/patterns/cqrs/index.js +1 -1
  123. package/dist/patterns/demo-shell/index.cjs +1 -1
  124. package/dist/patterns/demo-shell/index.js +1 -1
  125. package/dist/patterns/domain-templates/index.cjs +4 -4
  126. package/dist/patterns/domain-templates/index.js +1 -1
  127. package/dist/patterns/graphspec/index.cjs +6 -6
  128. package/dist/patterns/graphspec/index.d.cts +2 -2
  129. package/dist/patterns/graphspec/index.d.ts +2 -2
  130. package/dist/patterns/graphspec/index.js +1 -1
  131. package/dist/patterns/guarded-execution/index.cjs +7 -7
  132. package/dist/patterns/guarded-execution/index.js +1 -1
  133. package/dist/patterns/harness/index.cjs +11 -11
  134. package/dist/patterns/harness/index.d.cts +2 -2
  135. package/dist/patterns/harness/index.d.ts +2 -2
  136. package/dist/patterns/harness/index.js +1 -1
  137. package/dist/patterns/job-queue/index.cjs +5 -5
  138. package/dist/patterns/job-queue/index.js +1 -1
  139. package/dist/patterns/lens/index.cjs +5 -5
  140. package/dist/patterns/lens/index.d.cts +2 -2
  141. package/dist/patterns/lens/index.d.ts +2 -2
  142. package/dist/patterns/lens/index.js +1 -1
  143. package/dist/patterns/memory/index.cjs +4 -4
  144. package/dist/patterns/memory/index.js +1 -1
  145. package/dist/patterns/messaging/index.cjs +5 -5
  146. package/dist/patterns/messaging/index.js +1 -1
  147. package/dist/patterns/orchestration/index.cjs +1 -1
  148. package/dist/patterns/orchestration/index.js +1 -1
  149. package/dist/patterns/reactive-layout/index.cjs +1 -1
  150. package/dist/patterns/reactive-layout/index.js +1 -1
  151. package/dist/patterns/reduction/index.cjs +5 -5
  152. package/dist/patterns/reduction/index.js +1 -1
  153. package/dist/patterns/refine-loop/index.cjs +8 -8
  154. package/dist/patterns/refine-loop/index.js +1 -1
  155. package/dist/patterns/resilient-pipeline/index.cjs +1 -1
  156. package/dist/patterns/resilient-pipeline/index.js +1 -1
  157. package/dist/patterns/surface/index.cjs +7 -7
  158. package/dist/patterns/surface/index.d.cts +3 -3
  159. package/dist/patterns/surface/index.d.ts +3 -3
  160. package/dist/patterns/surface/index.js +1 -1
  161. package/dist/{reactive-map-BvDrRuwt.d.ts → reactive-map-CtRaCddO.d.ts} +59 -1
  162. package/dist/{reactive-map-CmlPPKHN.d.cts → reactive-map-IJIfZxoh.d.cts} +59 -1
  163. package/dist/{resilience-XRUF267O.js → resilience-IVNDYORD.js} +1 -1
  164. package/dist/{types-O3GzJY2U.d.cts → types-BgMqbc7N.d.cts} +41 -14
  165. package/dist/{types-u64Ose53.d.ts → types-CdfO2QTt.d.ts} +41 -14
  166. package/package.json +1 -1
  167. package/dist/chunk-2GQREQ6C.js +0 -1
  168. package/dist/chunk-4C2OR2GH.js +0 -18
  169. package/dist/chunk-5JDE5JHE.js +0 -1
  170. package/dist/chunk-7JDLFI6N.js +0 -1
  171. package/dist/chunk-AMBYCIOH.js +0 -3
  172. package/dist/chunk-ISCENNXS.js +0 -1
  173. package/dist/chunk-IUK4EFCE.js +0 -1
  174. package/dist/chunk-KASHOCF5.js +0 -1
  175. package/dist/chunk-LI3E75VE.js +0 -64
  176. package/dist/chunk-MGKAO4EK.js +0 -7
  177. package/dist/chunk-NSG4C6BF.js +0 -23
  178. package/dist/chunk-VIEUJSTT.js +0 -1
@@ -1 +1 @@
1
- "use strict";var fe=Object.defineProperty;var mt=Object.getOwnPropertyDescriptor;var bt=Object.getOwnPropertyNames;var gt=Object.prototype.hasOwnProperty;var N=(n,e)=>()=>(n&&(e=n(n=0)),e);var yt=(n,e)=>{for(var t in e)fe(n,t,{get:e[t],enumerable:!0})},_t=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of bt(e))!gt.call(n,o)&&o!==t&&fe(n,o,{get:()=>e[o],enumerable:!(r=mt(e,o))||r.enumerable});return n};var wt=n=>_t(fe({},"__esModule",{value:!0}),n);function D(n){return n<0?0:n}function vt(n,e){return e==="none"?n:e==="full"?Math.random()*n:n/2+Math.random()*(n/2)}function Tt(n,e){return n+Math.random()*(e-n)}function xt(n){let e=D(n);return()=>e}function Nt(n,e){let t=D(n),r=e===void 0?t:D(e);return o=>t+r*Math.max(0,o)}function kt(n){let e=D(n?.baseNs??1e8),t=n?.factor!==void 0&&n.factor<1?1:n?.factor??2,r=D(n?.maxDelayNs??30*1e9),o=n?.jitter??"none";return a=>{let s;if(e===0)s=0;else if(t===1)s=e;else{let i=r/e,u=1;for(let d=0;d<Math.max(0,a);d++){if(u>=i){u=i;break}u*=t}s=e*u,s>r&&(s=r)}return vt(s,o)}}function Et(n=100*1e6,e=30*1e9){let t=D(n),r=D(e);function o(a){if(a<=0)return 1;let s=1,i=2;for(let u=1;u<a;u++){let d=s+i;s=i,i=d}return i}return a=>{let s=o(a)*t;return s<=r?s:r}}function St(n=100*1e6,e=30*1e9){return(t,r,o)=>{let s=Math.min(e,(o??n)*3);return Tt(n,s)}}function De(n){if(n==="constant")return xt(1*1e9);if(n==="linear")return Nt(1*1e9);if(n==="exponential")return kt();if(n==="fibonacci")return Et();if(n==="decorrelatedJitter")return St();throw new Error(`Unknown backoff preset: "${String(n)}". Use one of: constant, linear, exponential, fibonacci, decorrelatedJitter`)}var M,F,pe=N(()=>{"use strict";M=1e6,F=1e9});function Fe(){return G>0||X}function Ie(){return G>0}function Le(n){G>0?Z.push(n):n()}function he(n){G+=1;let e=!1;try{n()}catch(t){throw e=!0,t}finally{if(G-=1,G===0)if(e){if(!X){let t=Z.splice(0);for(let r of t)try{r()}catch{}I.length=0,L.length=0,V.length=0}}else Ot()}}function Ot(){let n=!X;n&&(X=!0);let e=[],t=0;try{for(;I.length>0||L.length>0||V.length>0||n&&Z.length>0;){if(n&&Z.length>0){let a=Z.splice(0);for(let s of a)try{s()}catch(i){e.push(i)}continue}if(t+=1,t>1e3)throw I.length=0,L.length=0,V.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let o=(I.length>0?I:L.length>0?L:V).splice(0);for(let a of o)try{a()}catch(s){e.push(s)}}}finally{n&&(X=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function re(n,e,t){if(e.length===0)return;if(e.length===1){let d=t(e[0][0]);if(d<3||!Fe()){n(e);return}(d>=5?V:d===4?L:I).push(()=>n(e));return}let r=e.length,o=r,a=r,s=r,i=0;for(;i<r&&t(e[i][0])<3;)i++;for(o=i;i<r&&t(e[i][0])===3;)i++;for(a=i;i<r&&t(e[i][0])===4;)i++;s=i;let u=Fe();if(o>0){let d=e.slice(0,o);n(d)}if(a>o){let d=e.slice(o,a);u?I.push(()=>n(d)):n(d)}if(s>a){let d=e.slice(a,s);u?L.push(()=>n(d)):n(d)}if(r>s){let d=e.slice(s,r);u?V.push(()=>n(d)):n(d)}}var G,X,I,L,V,Z,me=N(()=>{"use strict";G=0,X=!1,I=[],L=[],V=[],Z=[]});function H(){return Math.trunc(performance.now()*1e6)}function Pe(){return Date.now()*1e6}var be=N(()=>{"use strict"});var Q,b,v,w,P,O,C,S,_,m,U,ge,At,ye,Rt,Mt,_e,Be,Ge,Ve,we,W=N(()=>{"use strict";Q=Symbol.for("graphrefly/START"),b=Symbol.for("graphrefly/DATA"),v=Symbol.for("graphrefly/DIRTY"),w=Symbol.for("graphrefly/RESOLVED"),P=Symbol.for("graphrefly/INVALIDATE"),O=Symbol.for("graphrefly/PAUSE"),C=Symbol.for("graphrefly/RESUME"),S=Symbol.for("graphrefly/TEARDOWN"),_=Symbol.for("graphrefly/COMPLETE"),m=Symbol.for("graphrefly/ERROR"),U=Object.freeze([v]),ge=Object.freeze([w]),At=Object.freeze([P]),ye=Object.freeze([Q]),Rt=Object.freeze([_]),Mt=Object.freeze([S]),_e=Object.freeze([U]),Be=Object.freeze([ge]),Ge=Object.freeze([At]),Ve=Object.freeze([Rt]),we=Object.freeze([Mt])});function He(n){n.registerCodec(Ct)}var Ct,Ue=N(()=>{"use strict";Ct={name:"json",version:1,contentType:"application/json",encode(n){let e=JSON.stringify(n);return new TextEncoder().encode(e)},decode(n,e){let t=new TextDecoder().decode(n);return JSON.parse(t)}}});function oe(n){if(n==null)return Dt;let{type:e,id:t,...r}=n;return{type:e??"system",id:t??"",...r}}var Dt,We=N(()=>{"use strict";Dt={type:"system",id:""}});function $e(n){n.registerMessageType(Q,{tier:0,wireCrossing:!1}),n.registerMessageType(v,{tier:1,wireCrossing:!1}),n.registerMessageType(P,{tier:1,wireCrossing:!1,metaPassthrough:!1}),n.registerMessageType(O,{tier:2,wireCrossing:!1}),n.registerMessageType(C,{tier:2,wireCrossing:!1}),n.registerMessageType(b,{tier:3,wireCrossing:!0}),n.registerMessageType(w,{tier:3,wireCrossing:!0}),n.registerMessageType(_,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(m,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(S,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var se,je=N(()=>{"use strict";W();se=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=t=>{let r=this._messageTypes.get(t);return r!=null?r.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}registerMessageType(e,t){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:t.tier,wireCrossing:t.wireCrossing??t.tier>=3,metaPassthrough:t.metaPassthrough??!0}),this}messageTier(e){let t=this._messageTypes.get(e);return t!=null?t.tier:1}isWireCrossing(e){let t=this._messageTypes.get(e);return t!=null?t.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let t=this._messageTypes.get(e);return t!=null?t.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}}});var $,ze=N(()=>{"use strict";$=class extends Error{actor;action;nodeName;constructor(e,t){super(t??`GuardDenied: action "${String(e.action)}" denied for actor type "${String(e.actor.type)}"`),this.name="GuardDenied",this.actor=e.actor,this.action=e.action,this.nodeName=e.nodeName}get node(){return this.nodeName}}});function ve(n){if(n===void 0)return null;if(typeof n=="number"){if(!Number.isFinite(n))throw new TypeError(`Cannot hash non-finite number: ${n}`);if(Number.isInteger(n)&&!Number.isSafeInteger(n))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${n}. Cross-language cid parity is not guaranteed for unsafe integers.`);return n}if(typeof n=="string"||typeof n=="boolean"||n===null)return n;if(Array.isArray(n))return n.map(ve);if(typeof n=="object"&&n!==null){let e={};for(let t of Object.keys(n).sort())e[t]=ve(n[t]);return e}return null}function Lt(n){let e=It.encode(n),t=e.length,r=t*8,o=t+9+63&-64,a=new Uint8Array(o);a.set(e),a[t]=128;let s=new DataView(a.buffer);s.setUint32(o-4,r>>>0,!1),s.setUint32(o-8,Math.floor(r/4294967296)>>>0,!1);let i=1779033703,u=3144134277,d=1013904242,c=2773480762,f=1359893119,y=2600822924,p=528734635,T=1541459225,h=new Uint32Array(64),l=(E,k)=>E>>>k|E<<32-k;for(let E=0;E<o;E+=64){for(let x=0;x<16;x++)h[x]=s.getUint32(E+x*4,!1);for(let x=16;x<64;x++){let Y=h[x-15],J=h[x-2],ne=l(Y,7)^l(Y,18)^Y>>>3,le=l(J,17)^l(J,19)^J>>>10;h[x]=h[x-16]+ne+h[x-7]+le>>>0}let k=i,q=u,K=d,de=c,R=f,ee=y,te=p,ce=T;for(let x=0;x<64;x++){let Y=l(R,6)^l(R,11)^l(R,25),J=R&ee^~R&te,ne=ce+Y+J+Ft[x]+h[x]>>>0,le=l(k,2)^l(k,13)^l(k,22),pt=k&q^k&K^q&K,ht=le+pt>>>0;ce=te,te=ee,ee=R,R=de+ne>>>0,de=K,K=q,q=k,k=ne+ht>>>0}i=i+k>>>0,u=u+q>>>0,d=d+K>>>0,c=c+de>>>0,f=f+R>>>0,y=y+ee>>>0,p=p+te>>>0,T=T+ce>>>0}let g=E=>E.toString(16).padStart(8,"0");return g(i)+g(u)+g(d)+g(c)+g(f)+g(y)+g(p)+g(T)}function Te(n){let e=ve(n??null),t=JSON.stringify(e);return Lt(t).slice(0,16)}function Pt(){let n=globalThis.crypto;if(n?.randomUUID)return n.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),t=e()+e()+e()+e();return`${t.slice(0,8)}-${t.slice(8,12)}-4${t.slice(13,16)}-${(parseInt(t.slice(16,17),16)&3|8).toString(16)}${t.slice(17,20)}-${t.slice(20,32)}`}function xe(n,e,t){let r=t?.id??Pt();if(n===0)return{id:r,version:0};let a=(t?.hash??Te)(e);return{id:r,version:0,cid:a,prev:null}}function qe(n,e,t){n.version+=1,"cid"in n&&(n.prev=n.cid,n.cid=t(e))}var Ft,It,Ke=N(()=>{"use strict";Ft=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),It=new TextEncoder});function Xe(n){return{node:n,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function Ne(n){n.prevData=void 0,n.dirty=!1,n.involvedThisWave=!1,n.dataBatch.length=0,n.terminal=void 0}function ie(n){return n.length===0?n:typeof n[0]=="symbol"?[n]:n}function B(n,e,t){let r=Ze(n)?n:[],o=typeof n=="function"?n:typeof e=="function"?e:void 0,a={};return Ze(n)?a=(ke(e)?e:t)??{}:ke(n)?a=n:a=(ke(e)?e:t)??{},new ae(r,o,a)}var Ye,Je,Bt,Gt,Ee,ae,Ze,ke,ue=N(()=>{"use strict";Ue();We();me();be();je();ze();W();Ke();Ye=()=>{},Je=100;Bt=(n,e,t,r)=>{t.direction==="down-in"&&n._onDepMessage(t.depIndex,e)},Gt=(n,e,t,r)=>{let o=n;if(o._status==="completed"||o._status==="errored")return;let a=o._cached,s=a===void 0?[ye]:[ye,[b,a]];o._status==="dirty"&&s.push(U),re(e,s,o._config.tierOf)},Ee=new se({onMessage:Bt,onSubscribe:Gt});$e(Ee);He(Ee);ae=class n{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,t,r){this._config=r.config??Ee,this._config.onMessage,this._optsName=r.name,this._describeKind=r.describeKind,this._equals=r.equals??Object.is,this._resubscribable=r.resubscribable??!1,this._resetOnTeardown=r.resetOnTeardown??!1,this._autoComplete=r.completeWhenDepsComplete??!0,this._autoError=r.errorWhenDepsError??!0,this._pausable=r.pausable??!0,this._guard=r.guard,this._fn=t,this._partial=r.partial??!1,this._cached=r.initial!==void 0?r.initial:void 0,this._status=e.length===0&&t==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=r.versioningHash??this._config.defaultHashFn??Te;let o=r.versioning??this._config.defaultVersioning;this._versioningLevel=o,this._versioning=o!=null?xe(o,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Xe);let a={};for(let[i,u]of Object.entries(r.meta??{})){let d={initial:u,name:`${r.name??"node"}:meta:${i}`,describeKind:"state",config:this._config};r.guard!=null&&(d.guard=r.guard),a[i]=new n([],void 0,d)}Object.freeze(a),this.meta=a,this._hasMeta=Object.keys(a).length>0;let s=this;this._actions={emit(i){s._emit([[b,i]])},down(i){s._emit(ie(i))},up(i){s._emitUp(ie(i))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,t){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let r=this._versioningLevel;if(r!=null&&e<=r)return;let o=t?.hash??this._hashFn;o!==this._hashFn&&(this._hashFn=o);let a=this._cached===void 0?void 0:this._cached,s=this._versioning,i=s?.id??t?.id,u=s?.version??0,d=xe(e,a,{id:i,hash:o});d.version=u,this._versioning=d,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let t=oe(e);if(this._guard!=null&&!this._guard(t,"observe"))return!1;if(this._extraGuards!=null){for(let r of this._extraGuards)if(!r(t,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let t=this._guard!=null||this._extraGuards!=null,r=e?.actor!=null;if(!t&&!r)return;let o=oe(e?.actor),a=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(o,a))throw new $({actor:o,action:a,nodeName:this.name});if(this._extraGuards!=null){for(let s of this._extraGuards)if(!s(o,a))throw new $({actor:o,action:a,nodeName:this.name})}this._lastMutation={actor:o,timestamp_ns:Pe()}}down(e,t){let r=ie(e);r.length!==0&&(this._checkGuard(t),this._emit(r))}emit(e,t){this._checkGuard(t),this._emit([[b,e]])}up(e,t){if(this._deps.length===0)return;let r=ie(e);if(r.length===0)return;this._checkGuard(t);let o=t??{internal:!0};this._validateUpTiers(r);for(let a of this._deps)a.node.up?.(r,o)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let t of this._deps)t.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let t=this._config.tierOf;for(let r of e){let o=t(r[0]);if(o===3||o===4)throw new Error(`Node "${this.name}": tier-${o} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,t){if(t!=null&&this._guard!=null){let u=oe(t);if(!this._guard(u,"observe"))throw new $({actor:u,action:"observe",nodeName:this.name})}let o=this._isTerminal&&this._resubscribable;if(o){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let u of this._deps)Ne(u);if(this._partial===!1){for(let u of this._deps)if(u.prevData!==void 0||u.dataBatch.length!==0||u.terminal!==void 0||u.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let a;try{a=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:o},this._actions)}catch(u){throw this._sinkCount-=1,u}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let s=this._isTerminal;if(this._sinkCount===1&&!s)try{this._activate()}catch(u){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof a=="function")try{a()}catch{}throw u}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let i=!1;return()=>{i||(i=!0,this._sinkCount-=1,this._removeSink(e),typeof a=="function"&&a(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[t]=this._sinks;this._sinks=t}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,t=0;try{for(let r=0;r<e;r++){let o=r,a=this._deps[r];a.unsub=Ye,a.unsub=a.node.subscribe(s=>{if(a.unsub===null)return;let i=this._config.tierOf,u=!1;for(let d of s)i(d[0])>=3&&(u=!0),this._config.onMessage(this,d,{direction:"down-in",depIndex:o},this._actions);u&&this._maybeRunFnOnSettlement()}),t++}}catch(r){this._deps[t].unsub=null;for(let o=0;o<t;o++){let a=this._deps[o];if(a.unsub!=null){let s=a.unsub;a.unsub=null;try{s()}catch{}Ne(a)}}throw this._dirtyDepCount=0,r}}_addDep(e){for(let o=0;o<this._deps.length;o++)if(this._deps[o].node===e)return o;let t=this._deps.length,r=Xe(e);if(this._deps.push(r),this._sinks==null)return t;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(_e),r.unsub=Ye;try{r.unsub=e.subscribe(o=>{if(r.unsub===null)return;let a=this._config.tierOf,s=!1;for(let i of o)a(i[0])>=3&&(s=!0),this._config.onMessage(this,i,{direction:"down-in",depIndex:t},this._actions);s&&this._maybeRunFnOnSettlement()})}catch(o){throw r.unsub=null,this._deps.pop(),this._dirtyDepCount--,o}return t}_deactivate(e=!1){let t=this._cleanup;if(this._cleanup=void 0,typeof t=="function")try{t()}catch(r){this._emit([[m,this._wrapFnError("cleanup threw",r)]])}else if(t!=null&&typeof t=="object"){let r=t.deactivate;if(typeof r=="function")try{r()}catch(o){this._emit([[m,this._wrapFnError("cleanup.deactivate threw",o)]])}}for(let r of this._deps){if(r.unsub!=null){let o=r.unsub;r.unsub=null;try{o()}catch{}}Ne(r)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,t){let r=this._deps[e],o=t[0];if(this._inspectorHooks!=null){let a={kind:"dep_message",depIndex:e,message:t};for(let s of this._inspectorHooks)s(a)}if(o!==Q){if(o===v){this._depDirtied(r);return}if(o===P){this._depInvalidated(r),this._emit(Ge);return}if(o===O||o===C){this._emit([t]);return}if(o===S){this._emit(we);return}if(o===b)this._depSettledAsData(r,t[1]);else if(o===w)this._depSettledAsResolved(r);else if(o===_)this._depSettledAsTerminal(r,!0);else if(o===m)this._depSettledAsTerminal(r,t[1]);else{this._emit([t]);return}if(!this._fn){(o===b||o===w)&&this._emit([t]),(o===_||o===m)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(_e))}_depSettledAsData(e,t){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(t),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,t){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=t,e.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(e){e.prevData=void 0,e.terminal=void 0,e.dataBatch.length=0,e.dirty?e.involvedThisWave=!1:(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(!this._partial&&!this._hasCalledFnOnce)for(let e=0;e<this._deps.length;e++){let t=this._deps[e];if(t.dataBatch.length===0&&t.prevData===void 0&&t.terminal===void 0){this._maybeAutoTerminalAfterWave();return}}if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(Be),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(t=>t.terminal!==void 0&&t.terminal!==!0);if(e!=null){this._autoError&&this._emit([[m,e.terminal]]);return}this._autoComplete&&this._deps.every(t=>t.terminal!==void 0)&&this._emit(Ve)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(s){this._emit([[m,this._wrapFnError("cleanup threw",s)]]);return}}else if(e!=null&&typeof e=="object"){let s=e.beforeRun;if(typeof s=="function"){e.beforeRun=void 0;try{s()}catch(i){this._emit([[m,this._wrapFnError("cleanup.beforeRun threw",i)]]);return}}}let t=this._deps.map(s=>s.involvedThisWave?s.dataBatch.length>0?[...s.dataBatch]:[]:void 0),r=this._deps.map(s=>s.prevData);for(let s=0;s<this._deps.length;s++){let i=t[s];i!=null&&i.length>0&&(this._deps[s].prevData=i[i.length-1])}let o=this._deps.map(s=>s.terminal),a={prevData:r,terminalDeps:o,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let s={kind:"run",batchData:t,prevData:r};for(let i of this._inspectorHooks)i(s)}this._isExecutingFn=!0;try{let s=this._fn(t,this._actions,a);if(typeof s=="function")this._cleanup=s;else if(s!=null&&typeof s=="object"){let i=s;(typeof i.beforeRun=="function"||typeof i.deactivate=="function"||typeof i.invalidate=="function")&&(this._cleanup=s)}}catch(s){this._emit([[m,this._wrapFnError("fn threw",s)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>Je?(this._rerunDepth=0,this._emit([[m,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${Je} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,t){let r=t instanceof Error?t.message:String(t);return new Error(`Node "${this.name}": ${e}: ${r}`,{cause:t})}_frameBatch(e){let t=this._config.tierOf;if(e.length===1)return t(e[0][0])===3&&this._status!=="dirty"?[U,e[0]]:e;let r=!0,o=!1,a=!1,s=-1;for(let u of e){let d=t(u[0]);d<s&&(r=!1),d===3&&(o=!0),u[0]===v&&(a=!0),s=d}let i=e;if(!r){let u=e.map((d,c)=>({m:d,i:c,tier:t(d[0])}));u.sort((d,c)=>d.tier-c.tier||d.i-c.i),i=u.map(d=>d.m)}if(o&&!a&&this._status!=="dirty"){let u=0;for(;u<i.length&&t(i[u][0])===0;)u++;return u===0?[U,...i]:[...i.slice(0,u),U,...i.slice(u)]}return i}_emit(e){if(e.length===0)return;for(let i=0;i<e.length;i++){let u=e[i];if(u[0]===m&&u[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let t=e;if(this._isTerminal&&!this._resubscribable){let i=e.filter(u=>u[0]===S||u[0]===P);if(i.length===0)return;t=i}t=this._frameBatch(t);let o=null;for(let i=0;i<t.length;i++){let u=t[i],d=u[0];if(d!==O&&d!==C){o?.push(u);continue}if(u.length<2)throw new Error(`Node "${this.name}": [[${d===O?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let c=!0;if(this._pausable!==!1){let f=u[1];if(d===O)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(f),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(f))c=!1;else if(this._pauseLocks.delete(f),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let y=this._pauseBuffer;this._pauseBuffer=[],this._emit(y)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}c?o?.push(u):o==null&&(o=t.slice(0,i))}if(o!=null){if(o.length===0)return;t=o}if(this._hasMeta&&t.some(i=>i[0]===S))for(let i of Object.keys(this.meta))try{this.meta[i]._emit(we)}catch{}let{finalMessages:a,equalsError:s}=this._updateState(t);if(a.length>0&&this._config.inspectorEnabled){let i=this._config.globalInspector;if(i!=null)try{i({kind:"emit",node:this,messages:a})}catch{}}if(a.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let i=this._config.tierOf,u=[];for(let d of a)i(d[0])===3?this._pauseBuffer.push(d):u.push(d);u.length>0&&this._dispatchOrAccumulate(u)}else this._dispatchOrAccumulate(a);s!=null&&this._emit([[m,s]])}_updateState(e){let t=this._config.tierOf,r,o,a=-1,s=0;for(let c of e)t(c[0])===3&&s++;let i=s<=1,u=-1;if(this._versioning!=null&&s>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===b){u=c;break}}for(let c=0;c<e.length;c++){let f=e[c],y=f[0];if(y===b){if(f.length>=2){let p=!1;if(i&&this._cached!==void 0)try{p=this._equals(this._cached,f[1])}catch(T){o=this._wrapFnError("equals threw",T),a=c;break}if(p){r==null&&(r=e.slice(0,c)),r.push(ge),this._status="resolved";continue}this._cached=f[1],this._versioning!=null&&(u<0||c===u)&&qe(this._versioning,f[1],this._hashFn)}this._status="settled",r?.push(f)}else if(r?.push(f),y===v)this._status="dirty";else if(y===w)this._status="resolved";else if(y===_)this._status="completed";else if(y===m)this._status="errored";else if(y===P){this._cached=void 0,this._status="dirty";let p=this._cleanup;if(typeof p=="function"){this._cleanup=void 0;try{p()}catch{}}else if(p!=null&&typeof p=="object"){let T=p.invalidate;if(typeof T=="function")try{T()}catch{}}}else y===S&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let d=a>=0?r??e.slice(0,a):r??e;return o!=null?{finalMessages:d,equalsError:o}:{finalMessages:d}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let t=[...this._sinks];for(let r of t)r(e)};_dispatchOrAccumulate(e){if(Ie()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],Le(()=>this._flushBatchPending()));for(let t of e)this._batchPendingMessages.push(t);return}re(this._deliverToSinks,e,this._config.tierOf)}_flushBatchPending(){let e=this._batchPendingMessages;if(e===null||(this._batchPendingMessages=null,e.length===0))return;let t=this._frameBatch(e);re(this._deliverToSinks,t,this._config.tierOf)}},Ze=n=>Array.isArray(n),ke=n=>typeof n=="object"&&n!=null&&!Array.isArray(n)});function A(n,e){return B((r,o,a)=>n(o,a)??void 0,{describeKind:"producer",...e})}var Se=N(()=>{"use strict";ue()});function Oe(n){return{describeKind:"producer",...n}}function Qe(n,e){return A(t=>{let r=!1;try{for(let o of n){if(r)return;t.emit(o)}r||t.down([[_]])}catch(o){r||t.down([[m,o]])}return()=>{r=!0}},Oe(e))}function Vt(n){return n!=null&&typeof n.then=="function"}function Ht(n,e){let{signal:t,...r}=e??{};return A(o=>{let a=!1,s=()=>{a||(a=!0,o.down([[m,t.reason]]))};if(t?.aborted){s();return}return t?.addEventListener("abort",s,{once:!0}),Promise.resolve(n).then(i=>{a||(a=!0,t?.removeEventListener("abort",s),o.emit(i),o.down([[_]]))},i=>{a||(a=!0,t?.removeEventListener("abort",s),o.down([[m,i]]))}),()=>{a=!0,t?.removeEventListener("abort",s)}},Oe(r))}function Ut(n,e){let{signal:t,...r}=e??{};return A(o=>{let a=new AbortController,s=()=>a.abort(t?.reason);t?.aborted?a.abort(t.reason):t?.addEventListener("abort",s,{once:!0});let i=t??a.signal,u=!1,d=n[Symbol.asyncIterator](),c=()=>{u||i.aborted||Promise.resolve(d.next()).then(f=>{if(!(u||i.aborted)){if(f.done){o.down([[_]]);return}o.emit(f.value),c()}},f=>{!u&&!i.aborted&&o.down([[m,f]])})};return c(),()=>{u=!0,t?.removeEventListener("abort",s),a.abort(),Promise.resolve(d.return?.()).catch(()=>{})}},Oe(r))}function Wt(n){return n!=null&&typeof n=="object"&&"cache"in n&&typeof n.subscribe=="function"}function et(n,e){if(Wt(n))return n;if(Vt(n))return Ht(n,e);if(n!=null){let t=n;if(typeof t[Symbol.asyncIterator]=="function")return Ut(n,e);if(typeof t[Symbol.iterator]=="function")return Qe(n,e)}return $t(n)}function $t(...n){return Qe(n,void 0)}var tt=N(()=>{"use strict";W();Se()});var j,nt=N(()=>{"use strict";j=class{_timer;_gen=0;start(e,t){this.cancel(),this._gen+=1;let r=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,r===this._gen&&t()},e)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});function z(n){return{describeKind:"derived",...n}}function jt(n){return n<0?0:n}function Ce(n){return n[1]}function zt(n){if(typeof n!="number"||!Number.isFinite(n))throw new TypeError("backoff strategy must return a finite number");return n<0?0:n}function rt(n,e){let t=e?.count,r=e?.backoff,o=t!==void 0?t:r===void 0?0:2147483647;if(o<0)throw new RangeError("retry count must be >= 0");let a=r===void 0?null:typeof r=="string"?De(r):r;return A(s=>{let i=0,u=!1,d=null,c,f=new j;function y(){c?.(),c=void 0}function p(h){if(u)return;if(i>=o){y(),s.down([[m,h]]);return}let l=a===null?0:a(i,h,d);if(l==null){y(),s.down([[m,h]]);return}let g;try{g=zt(l)}catch{y(),s.down([[m,h]]);return}d=g,i+=1,y();let E=g>0?g/1e6:1;f.start(E,()=>{u||T()})}function T(){f.cancel(),y(),c=n.subscribe(h=>{if(!u)for(let l of h){let g=l[0];if(g===v)s.down([[v]]);else if(g===b)i=0,d=null,s.emit(l[1]);else if(g===w)s.down([[w]]);else if(g===_)y(),s.down([[_]]);else if(g===m){p(Ce(l));return}else s.down([l])}})}return T(),()=>{u=!0,f.cancel(),y()}},{...z(),initial:n.cache})}function ot(n){let e=Math.max(1,n?.failureThreshold??5),t=jt(n?.cooldownNs??30*1e9),r=n?.cooldown??null,o=Math.max(1,n?.halfOpenMax??1),a=n?.now??H,s="closed",i=0,u=0,d=0,c=t,f=0;function y(){if(!r)return t;let h=r(u);return h!==null?h:t}function p(){s="open",c=y(),d=a(),f=0}return{canExecute(){return s==="closed"?!0:s==="open"?a()-d>=c?(s="half-open",f=1,!0):!1:f<o?(f++,!0):!1},recordSuccess(){s==="half-open"?(s="closed",i=0,u=0):s==="closed"&&(i=0)},recordFailure(h){if(s==="half-open"){u++,p();return}s==="closed"&&(i++,i>=e&&p())},get state(){return s},get failureCount(){return i},reset(){s="closed",i=0,u=0,f=0}}}function st(n,e){let t=e?.onOpen??"skip";return r=>{let o=B([],(a,s)=>{function i(){o.meta.breakerState.down([[b,n.state]])}let u=r.subscribe(d=>{for(let c of d){let f=c[0];f===v?s.down([[v]]):f===b?n.canExecute()?(i(),s.emit(c[1])):(i(),t==="error"?s.down([[m,new Ae]]):s.down([[w]])):f===w?s.down([[w]]):f===_?(n.recordSuccess(),i(),s.down([[_]])):f===m?(n.recordFailure(Ce(c)),i(),s.down([c])):s.down([c])}});return i(),u},{...z(),meta:{breakerState:n.state},completeWhenDepsComplete:!1,initial:r.cache});return{node:o,breakerState:o.meta.breakerState}}}function qt(n,e){if(n<=0)throw new RangeError("capacity must be > 0");if(e<0)throw new RangeError("refillPerSecond must be >= 0");let t=n,r=H();function o(a){if(e>0){let s=a-r;t=Math.min(n,t+s/1e9*e)}r=a}return{available(){return o(H()),t},tryConsume(a=1){if(a<=0)return!0;let s=H();return o(s),t>=a?(t-=a,!0):!1},putBack(a=1){a<=0||(o(H()),t=Math.min(n,t+a))}}}function it(n,e){let{maxEvents:t,windowNs:r}=e;if(t<=0)throw new RangeError("maxEvents must be > 0");if(r<=0)throw new RangeError("windowNs must be > 0");let o=e.maxBuffer;if(o!==void 0&&o<1)throw new RangeError("maxBuffer must be >= 1");let a=e.onOverflow??"drop-newest",s=t*1e9/r;return A(i=>{let u=qt(t,s),d=[],c=new j,f=!1,y=1e9/s;function p(){for(;d.length>0;)if(u.tryConsume(1))i.emit(d.shift());else{c.start(Math.max(1,y/1e6),p);return}}let T=n.subscribe(h=>{for(let l of h){if(f)return;let g=l[0];if(g===v)i.down([[v]]);else if(g===b){if(o!==void 0&&d.length>=o){if(a!=="drop-newest")if(a==="drop-oldest")d.shift(),d.push(l[1]);else{f=!0,c.cancel(),d.length=0,i.down([[m,new Re(o)]]);return}}else d.push(l[1]);p()}else if(g===w)i.down([[w]]);else if(g===_)f=!0,c.cancel(),d.length=0,i.down([[_]]);else if(g===m)f=!0,c.cancel(),d.length=0,i.down([l]);else if(g===S){f=!0,c.cancel(),d.length=0,i.down([l]);return}else i.down([l])}});return()=>{f=!0,c.cancel(),T()}},{...z(),initial:n.cache})}function at(n,e){let t=e?.initialStatus??"pending",r=B([],(o,a)=>{let s=t;return r.meta.status.down([[b,t]]),r.meta.error.down([[b,null]]),n.subscribe(u=>{for(let d of u){let c=d[0];if(c===v)a.down([[v]]);else if(c===b)s==="errored"?he(()=>{r.meta.error.down([[b,null]]),r.meta.status.down([[b,"active"]])}):r.meta.status.down([[b,"active"]]),s="active",a.emit(d[1]);else if(c===w)a.down([[w]]);else if(c===_)r.meta.status.down([[b,"completed"]]),s="completed",a.down([[_]]);else if(c===m){let f=Ce(d);he(()=>{r.meta.error.down([[b,f]]),r.meta.status.down([[b,"errored"]])}),s="errored",a.down([d])}else a.down([d])}})},{...z(),meta:{status:t,error:null},completeWhenDepsComplete:!1,resubscribable:!0,initial:n.cache});return{node:r,status:r.meta.status,error:r.meta.error}}function Kt(n){return n!=null&&typeof n=="object"&&"cache"in n&&typeof n.subscribe=="function"}function Yt(n){return n!=null&&typeof n.then=="function"}function Jt(n){return n!=null&&typeof n=="object"&&typeof n[Symbol.asyncIterator]=="function"}function ut(n,e){return A(t=>{let r,o;function a(){o?.(),o=void 0,Kt(e)||Yt(e)||Jt(e)?r=et(e).subscribe(i=>{t.down(i)}):(t.emit(e),t.down([[_]]))}return o=n.subscribe(s=>{for(let i of s){let u=i[0];if(u===v)t.down([[v]]);else if(u===b)t.emit(i[1]);else if(u===w)t.down([[w]]);else if(u===_)t.down([[_]]);else if(u===m){a();return}else if(u===S){r?.(),t.down([i]);return}else t.down([i])}}),()=>{o?.(),r?.()}},{...z(),initial:n.cache})}function dt(n,e){if(e<=0)throw new RangeError("timeoutNs must be > 0");return A(t=>{let r=!1,o=new j;function a(){let i=e/1e6;o.start(i,()=>{r||(r=!0,s(),t.down([[m,new Me(e)]]))})}let s=n.subscribe(i=>{for(let u of i){if(r)return;let d=u[0];if(d===v)t.down([[v]]);else if(d===b)a(),t.emit(u[1]);else if(d===w)t.down([[w]]);else if(d===_){o.cancel(),r=!0,t.down([[_]]);return}else if(d===m){o.cancel(),r=!0,t.down([u]);return}else if(d===S){o.cancel(),r=!0,t.down([u]);return}else t.down([u])}});return a(),()=>{r=!0,o.cancel(),s()}},{...z(),initial:n.cache})}var Ae,Re,Me,ct=N(()=>{"use strict";me();be();W();ue();Se();pe();tt();nt();Ae=class extends Error{name="CircuitOpenError";constructor(){super("Circuit breaker is open")}};Re=class extends Error{name="RateLimiterOverflowError";constructor(e){super(`rateLimiter buffer overflow (maxBuffer=${e})`)}};Me=class extends Error{name="TimeoutError";constructor(e){super(`Timed out after ${e/1e6}ms`)}}});var Qt={};yt(Qt,{NS_PER_MS:()=>M,NS_PER_SEC:()=>F,resilientPipeline:()=>Zt});module.exports=wt(Qt);pe();ct();W();ue();function lt(n,e,t){return{[n]:!0,[`${n}_type`]:e,...t??{}}}function Xt(n,e){return lt("reduction",n,e)}function ft(n,e,t){if(e.length===0)throw new RangeError("budgetGate requires at least one constraint");let r=e.map(p=>p.node),o=[n,...r],a=[],s=!1,i=!1,u=Symbol("budget-gate"),d=new Array(e.length);function c(){return e.every((p,T)=>p.check(d[T]))}function f(p){for(;a.length>0&&c();){let T=a[0];a=a.slice(1),p.emit(T)}a.length===0&&i&&(i=!1,p.down([[w]]))}return B([],(p,T)=>{for(let l=0;l<e.length;l++)d[l]=e[l].node.cache;let h=[];for(let l=0;l<o.length;l++){let g=o[l];h.push(g.subscribe(E=>{for(let k of E)y(k,l,T)}))}return()=>{for(let l of h)l()}},{...t,describeKind:"derived",meta:Xt("budget_gate",t?.meta)});function y(p,T,h){let l=p[0];if(T===0){if(l===b)return c()&&a.length===0?h.emit(p[1]):(a.push(p[1]),s||(s=!0,h.up([[O,u]]))),!0;if(l===v)return h.down([[v]]),!0;if(l===w)return a.length===0?h.down([[w]]):i=!0,!0;if(l===_||l===m){for(let g of a)h.emit(g);return a=[],i=!1,s&&(s=!1,h.up([[C,u]])),h.down([p]),!0}return!1}return l===b&&(d[T-1]=p[1]),l===b||l===w?(c()&&a.length>0?(f(h),a.length===0&&s&&(s=!1,h.up([[C,u]]))):!c()&&!s&&a.length>0&&(s=!0,h.up([[O,u]])),!0):l===v?!0:l===m?(h.down([p]),!0):l===_}}function Zt(n,e={}){let t=n;e.rateLimit!=null&&(t=it(t,e.rateLimit)),e.budget!=null&&e.budget.length>0&&(t=ft(t,e.budget));let r;if(e.breaker!=null){let a=ot(e.breaker),s=e.breakerOnOpen??"skip",i=st(a,{onOpen:s})(t);t=i.node,r=i.breakerState}if(e.timeoutMs!=null){if(e.timeoutMs<=0)throw new RangeError("timeoutMs must be > 0");if(e.timeoutMs>9e6)throw new RangeError("timeoutMs must be <= 9_000_000 (\u22482.5h) to stay within safe ns arithmetic");t=dt(t,e.timeoutMs*1e6)}e.retry!=null&&(t=rt(t,e.retry)),e.fallback!==void 0&&(t=ut(t,e.fallback));let o=at(t,{initialStatus:e.initialStatus??"pending"});return{node:o.node,status:o.status,error:o.error,breakerState:r}}0&&(module.exports={NS_PER_MS,NS_PER_SEC,resilientPipeline});
1
+ "use strict";var fe=Object.defineProperty;var mt=Object.getOwnPropertyDescriptor;var bt=Object.getOwnPropertyNames;var gt=Object.prototype.hasOwnProperty;var N=(n,e)=>()=>(n&&(e=n(n=0)),e);var yt=(n,e)=>{for(var t in e)fe(n,t,{get:e[t],enumerable:!0})},_t=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of bt(e))!gt.call(n,o)&&o!==t&&fe(n,o,{get:()=>e[o],enumerable:!(r=mt(e,o))||r.enumerable});return n};var wt=n=>_t(fe({},"__esModule",{value:!0}),n);function D(n){return n<0?0:n}function vt(n,e){return e==="none"?n:e==="full"?Math.random()*n:n/2+Math.random()*(n/2)}function Tt(n,e){return n+Math.random()*(e-n)}function xt(n){let e=D(n);return()=>e}function Nt(n,e){let t=D(n),r=e===void 0?t:D(e);return o=>t+r*Math.max(0,o)}function kt(n){let e=D(n?.baseNs??1e8),t=n?.factor!==void 0&&n.factor<1?1:n?.factor??2,r=D(n?.maxDelayNs??30*1e9),o=n?.jitter??"none";return a=>{let s;if(e===0)s=0;else if(t===1)s=e;else{let i=r/e,u=1;for(let d=0;d<Math.max(0,a);d++){if(u>=i){u=i;break}u*=t}s=e*u,s>r&&(s=r)}return vt(s,o)}}function Et(n=100*1e6,e=30*1e9){let t=D(n),r=D(e);function o(a){if(a<=0)return 1;let s=1,i=2;for(let u=1;u<a;u++){let d=s+i;s=i,i=d}return i}return a=>{let s=o(a)*t;return s<=r?s:r}}function St(n=100*1e6,e=30*1e9){return(t,r,o)=>{let s=Math.min(e,(o??n)*3);return Tt(n,s)}}function De(n){if(n==="constant")return xt(1*1e9);if(n==="linear")return Nt(1*1e9);if(n==="exponential")return kt();if(n==="fibonacci")return Et();if(n==="decorrelatedJitter")return St();throw new Error(`Unknown backoff preset: "${String(n)}". Use one of: constant, linear, exponential, fibonacci, decorrelatedJitter`)}var M,F,pe=N(()=>{"use strict";M=1e6,F=1e9});function Fe(){return G>0||X}function Ie(){return G>0}function Le(n){G>0?Z.push(n):n()}function he(n){G+=1;let e=!1;try{n()}catch(t){throw e=!0,t}finally{if(G-=1,G===0)if(e){if(!X){let t=Z.splice(0);for(let r of t)try{r()}catch{}I.length=0,L.length=0,V.length=0}}else Ot()}}function Ot(){let n=!X;n&&(X=!0);let e=[],t=0;try{for(;I.length>0||L.length>0||V.length>0||n&&Z.length>0;){if(n&&Z.length>0){let a=Z.splice(0);for(let s of a)try{s()}catch(i){e.push(i)}continue}if(t+=1,t>1e3)throw I.length=0,L.length=0,V.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let o=(I.length>0?I:L.length>0?L:V).splice(0);for(let a of o)try{a()}catch(s){e.push(s)}}}finally{n&&(X=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function re(n,e,t){if(e.length===0)return;if(e.length===1){let d=t(e[0][0]);if(d<3||!Fe()){n(e);return}(d>=5?V:d===4?L:I).push(()=>n(e));return}let r=e.length,o=r,a=r,s=r,i=0;for(;i<r&&t(e[i][0])<3;)i++;for(o=i;i<r&&t(e[i][0])===3;)i++;for(a=i;i<r&&t(e[i][0])===4;)i++;s=i;let u=Fe();if(o>0){let d=e.slice(0,o);n(d)}if(a>o){let d=e.slice(o,a);u?I.push(()=>n(d)):n(d)}if(s>a){let d=e.slice(a,s);u?L.push(()=>n(d)):n(d)}if(r>s){let d=e.slice(s,r);u?V.push(()=>n(d)):n(d)}}var G,X,I,L,V,Z,me=N(()=>{"use strict";G=0,X=!1,I=[],L=[],V=[],Z=[]});function H(){return Math.trunc(performance.now()*1e6)}function Pe(){return Date.now()*1e6}var be=N(()=>{"use strict"});var Q,b,v,w,P,O,C,S,_,m,U,ge,At,ye,Rt,Mt,_e,Be,Ge,Ve,we,W=N(()=>{"use strict";Q=Symbol.for("graphrefly/START"),b=Symbol.for("graphrefly/DATA"),v=Symbol.for("graphrefly/DIRTY"),w=Symbol.for("graphrefly/RESOLVED"),P=Symbol.for("graphrefly/INVALIDATE"),O=Symbol.for("graphrefly/PAUSE"),C=Symbol.for("graphrefly/RESUME"),S=Symbol.for("graphrefly/TEARDOWN"),_=Symbol.for("graphrefly/COMPLETE"),m=Symbol.for("graphrefly/ERROR"),U=Object.freeze([v]),ge=Object.freeze([w]),At=Object.freeze([P]),ye=Object.freeze([Q]),Rt=Object.freeze([_]),Mt=Object.freeze([S]),_e=Object.freeze([U]),Be=Object.freeze([ge]),Ge=Object.freeze([At]),Ve=Object.freeze([Rt]),we=Object.freeze([Mt])});function He(n){n.registerCodec(Ct)}var Ct,Ue=N(()=>{"use strict";Ct={name:"json",version:1,contentType:"application/json",encode(n){let e=JSON.stringify(n);return new TextEncoder().encode(e)},decode(n,e){let t=new TextDecoder().decode(n);return JSON.parse(t)}}});function oe(n){if(n==null)return Dt;let{type:e,id:t,...r}=n;return{type:e??"system",id:t??"",...r}}var Dt,We=N(()=>{"use strict";Dt={type:"system",id:""}});function $e(n){n.registerMessageType(Q,{tier:0,wireCrossing:!1}),n.registerMessageType(v,{tier:1,wireCrossing:!1}),n.registerMessageType(P,{tier:1,wireCrossing:!1,metaPassthrough:!1}),n.registerMessageType(O,{tier:2,wireCrossing:!1}),n.registerMessageType(C,{tier:2,wireCrossing:!1}),n.registerMessageType(b,{tier:3,wireCrossing:!0}),n.registerMessageType(w,{tier:3,wireCrossing:!0}),n.registerMessageType(_,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(m,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(S,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var se,je=N(()=>{"use strict";W();se=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=t=>{let r=this._messageTypes.get(t);return r!=null?r.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}registerMessageType(e,t){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:t.tier,wireCrossing:t.wireCrossing??t.tier>=3,metaPassthrough:t.metaPassthrough??!0}),this}messageTier(e){let t=this._messageTypes.get(e);return t!=null?t.tier:1}isWireCrossing(e){let t=this._messageTypes.get(e);return t!=null?t.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let t=this._messageTypes.get(e);return t!=null?t.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}}});var $,ze=N(()=>{"use strict";$=class extends Error{actor;action;nodeName;constructor(e,t){super(t??`GuardDenied: action "${String(e.action)}" denied for actor type "${String(e.actor.type)}"`),this.name="GuardDenied",this.actor=e.actor,this.action=e.action,this.nodeName=e.nodeName}get node(){return this.nodeName}}});function ve(n){if(n===void 0)return null;if(typeof n=="number"){if(!Number.isFinite(n))throw new TypeError(`Cannot hash non-finite number: ${n}`);if(Number.isInteger(n)&&!Number.isSafeInteger(n))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${n}. Cross-language cid parity is not guaranteed for unsafe integers.`);return n}if(typeof n=="string"||typeof n=="boolean"||n===null)return n;if(Array.isArray(n))return n.map(ve);if(typeof n=="object"&&n!==null){let e={};for(let t of Object.keys(n).sort())e[t]=ve(n[t]);return e}return null}function Lt(n){let e=It.encode(n),t=e.length,r=t*8,o=t+9+63&-64,a=new Uint8Array(o);a.set(e),a[t]=128;let s=new DataView(a.buffer);s.setUint32(o-4,r>>>0,!1),s.setUint32(o-8,Math.floor(r/4294967296)>>>0,!1);let i=1779033703,u=3144134277,d=1013904242,c=2773480762,f=1359893119,y=2600822924,p=528734635,T=1541459225,h=new Uint32Array(64),l=(E,k)=>E>>>k|E<<32-k;for(let E=0;E<o;E+=64){for(let x=0;x<16;x++)h[x]=s.getUint32(E+x*4,!1);for(let x=16;x<64;x++){let Y=h[x-15],J=h[x-2],ne=l(Y,7)^l(Y,18)^Y>>>3,le=l(J,17)^l(J,19)^J>>>10;h[x]=h[x-16]+ne+h[x-7]+le>>>0}let k=i,q=u,K=d,de=c,R=f,ee=y,te=p,ce=T;for(let x=0;x<64;x++){let Y=l(R,6)^l(R,11)^l(R,25),J=R&ee^~R&te,ne=ce+Y+J+Ft[x]+h[x]>>>0,le=l(k,2)^l(k,13)^l(k,22),pt=k&q^k&K^q&K,ht=le+pt>>>0;ce=te,te=ee,ee=R,R=de+ne>>>0,de=K,K=q,q=k,k=ne+ht>>>0}i=i+k>>>0,u=u+q>>>0,d=d+K>>>0,c=c+de>>>0,f=f+R>>>0,y=y+ee>>>0,p=p+te>>>0,T=T+ce>>>0}let g=E=>E.toString(16).padStart(8,"0");return g(i)+g(u)+g(d)+g(c)+g(f)+g(y)+g(p)+g(T)}function Te(n){let e=ve(n??null),t=JSON.stringify(e);return Lt(t).slice(0,16)}function Pt(){let n=globalThis.crypto;if(n?.randomUUID)return n.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),t=e()+e()+e()+e();return`${t.slice(0,8)}-${t.slice(8,12)}-4${t.slice(13,16)}-${(parseInt(t.slice(16,17),16)&3|8).toString(16)}${t.slice(17,20)}-${t.slice(20,32)}`}function xe(n,e,t){let r=t?.id??Pt();if(n===0)return{id:r,version:0};let a=(t?.hash??Te)(e);return{id:r,version:0,cid:a,prev:null}}function qe(n,e,t){n.version+=1,"cid"in n&&(n.prev=n.cid,n.cid=t(e))}var Ft,It,Ke=N(()=>{"use strict";Ft=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),It=new TextEncoder});function Xe(n){return{node:n,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function Ne(n){n.prevData=void 0,n.dirty=!1,n.involvedThisWave=!1,n.dataBatch.length=0,n.terminal=void 0}function ie(n){return n.length===0?n:typeof n[0]=="symbol"?[n]:n}function B(n,e,t){let r=Ze(n)?n:[],o=typeof n=="function"?n:typeof e=="function"?e:void 0,a={};return Ze(n)?a=(ke(e)?e:t)??{}:ke(n)?a=n:a=(ke(e)?e:t)??{},new ae(r,o,a)}var Ye,Je,Bt,Gt,Ee,ae,Ze,ke,ue=N(()=>{"use strict";Ue();We();me();be();je();ze();W();Ke();Ye=()=>{},Je=100;Bt=(n,e,t,r)=>{t.direction==="down-in"&&n._onDepMessage(t.depIndex,e)},Gt=(n,e,t,r)=>{let o=n;if(o._status==="completed"||o._status==="errored")return;let a=o._cached,s=a===void 0?[ye]:[ye,[b,a]];o._status==="dirty"&&s.push(U),re(e,s,o._config.tierOf)},Ee=new se({onMessage:Bt,onSubscribe:Gt});$e(Ee);He(Ee);ae=class n{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,t,r){this._config=r.config??Ee,this._config.onMessage,this._optsName=r.name,this._describeKind=r.describeKind,this._equals=r.equals??Object.is,this._resubscribable=r.resubscribable??!1,this._resetOnTeardown=r.resetOnTeardown??!1,this._autoComplete=r.completeWhenDepsComplete??!0,this._autoError=r.errorWhenDepsError??!0,this._pausable=r.pausable??!0,this._guard=r.guard,this._fn=t,this._partial=r.partial??!1,this._cached=r.initial!==void 0?r.initial:void 0,this._status=e.length===0&&t==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=r.versioningHash??this._config.defaultHashFn??Te;let o=r.versioning??this._config.defaultVersioning;this._versioningLevel=o,this._versioning=o!=null?xe(o,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Xe);let a={};for(let[i,u]of Object.entries(r.meta??{})){let d={initial:u,name:`${r.name??"node"}:meta:${i}`,describeKind:"state",config:this._config};r.guard!=null&&(d.guard=r.guard),a[i]=new n([],void 0,d)}Object.freeze(a),this.meta=a,this._hasMeta=Object.keys(a).length>0;let s=this;this._actions={emit(i){s._emit([[b,i]])},down(i){s._emit(ie(i))},up(i){s._emitUp(ie(i))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,t){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let r=this._versioningLevel;if(r!=null&&e<=r)return;let o=t?.hash??this._hashFn;o!==this._hashFn&&(this._hashFn=o);let a=this._cached===void 0?void 0:this._cached,s=this._versioning,i=s?.id??t?.id,u=s?.version??0,d=xe(e,a,{id:i,hash:o});d.version=u,this._versioning=d,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let t=oe(e);if(this._guard!=null&&!this._guard(t,"observe"))return!1;if(this._extraGuards!=null){for(let r of this._extraGuards)if(!r(t,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let t=this._guard!=null||this._extraGuards!=null,r=e?.actor!=null;if(!t&&!r)return;let o=oe(e?.actor),a=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(o,a))throw new $({actor:o,action:a,nodeName:this.name});if(this._extraGuards!=null){for(let s of this._extraGuards)if(!s(o,a))throw new $({actor:o,action:a,nodeName:this.name})}this._lastMutation={actor:o,timestamp_ns:Pe()}}down(e,t){let r=ie(e);r.length!==0&&(this._checkGuard(t),this._emit(r))}emit(e,t){this._checkGuard(t),this._emit([[b,e]])}up(e,t){if(this._deps.length===0)return;let r=ie(e);if(r.length===0)return;this._checkGuard(t);let o=t??{internal:!0};this._validateUpTiers(r);for(let a of this._deps)a.node.up?.(r,o)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let t of this._deps)t.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let t=this._config.tierOf;for(let r of e){let o=t(r[0]);if(o===3||o===4)throw new Error(`Node "${this.name}": tier-${o} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,t){if(t!=null&&this._guard!=null){let u=oe(t);if(!this._guard(u,"observe"))throw new $({actor:u,action:"observe",nodeName:this.name})}let o=this._isTerminal&&this._resubscribable;if(o){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let u of this._deps)Ne(u);if(this._partial===!1){for(let u of this._deps)if(u.prevData!==void 0||u.dataBatch.length!==0||u.terminal!==void 0||u.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let a;try{a=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:o},this._actions)}catch(u){throw this._sinkCount-=1,u}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let s=this._isTerminal;if(this._sinkCount===1&&!s)try{this._activate()}catch(u){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof a=="function")try{a()}catch{}throw u}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let i=!1;return()=>{i||(i=!0,this._sinkCount-=1,this._removeSink(e),typeof a=="function"&&a(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[t]=this._sinks;this._sinks=t}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,t=0;try{for(let r=0;r<e;r++){let o=r,a=this._deps[r];a.unsub=Ye,a.unsub=a.node.subscribe(s=>{if(a.unsub===null)return;let i=this._config.tierOf,u=!1;for(let d of s)i(d[0])>=3&&(u=!0),this._config.onMessage(this,d,{direction:"down-in",depIndex:o},this._actions);u&&this._maybeRunFnOnSettlement()}),t++}}catch(r){this._deps[t].unsub=null;for(let o=0;o<t;o++){let a=this._deps[o];if(a.unsub!=null){let s=a.unsub;a.unsub=null;try{s()}catch{}Ne(a)}}throw this._dirtyDepCount=0,r}}_addDep(e){for(let o=0;o<this._deps.length;o++)if(this._deps[o].node===e)return o;let t=this._deps.length,r=Xe(e);if(this._deps.push(r),this._sinks==null)return t;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(_e),r.unsub=Ye;try{r.unsub=e.subscribe(o=>{if(r.unsub===null)return;let a=this._config.tierOf,s=!1;for(let i of o)a(i[0])>=3&&(s=!0),this._config.onMessage(this,i,{direction:"down-in",depIndex:t},this._actions);s&&this._maybeRunFnOnSettlement()})}catch(o){throw r.unsub=null,this._deps.pop(),this._dirtyDepCount--,o}return t}_deactivate(e=!1){let t=this._cleanup;if(this._cleanup=void 0,typeof t=="function")try{t()}catch(r){this._emit([[m,this._wrapFnError("cleanup threw",r)]])}else if(t!=null&&typeof t=="object"){let r=t.deactivate;if(typeof r=="function")try{r()}catch(o){this._emit([[m,this._wrapFnError("cleanup.deactivate threw",o)]])}}for(let r of this._deps){if(r.unsub!=null){let o=r.unsub;r.unsub=null;try{o()}catch{}}Ne(r)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,t){let r=this._deps[e],o=t[0];if(this._inspectorHooks!=null){let a={kind:"dep_message",depIndex:e,message:t};for(let s of this._inspectorHooks)s(a)}if(o!==Q){if(o===v){this._depDirtied(r);return}if(o===P){if(this._depInvalidated(r),this._cached===void 0)return;this._emit(Ge);return}if(o===O||o===C){this._emit([t]);return}if(o===S){this._emit(we);return}if(o===b)this._depSettledAsData(r,t[1]);else if(o===w)this._depSettledAsResolved(r);else if(o===_)this._depSettledAsTerminal(r,!0);else if(o===m)this._depSettledAsTerminal(r,t[1]);else{this._emit([t]);return}if(!this._fn){(o===b||o===w)&&this._emit([t]),(o===_||o===m)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(_e))}_depSettledAsData(e,t){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(t),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,t){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=t,e.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(e){e.prevData=void 0,e.terminal=void 0,e.dataBatch.length=0,e.dirty?e.involvedThisWave=!1:(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(!this._partial&&!this._hasCalledFnOnce)for(let e=0;e<this._deps.length;e++){let t=this._deps[e];if(t.dataBatch.length===0&&t.prevData===void 0&&t.terminal===void 0){this._maybeAutoTerminalAfterWave();return}}if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(Be),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(t=>t.terminal!==void 0&&t.terminal!==!0);if(e!=null){this._autoError&&this._emit([[m,e.terminal]]);return}this._autoComplete&&this._deps.every(t=>t.terminal!==void 0)&&this._emit(Ve)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(s){this._emit([[m,this._wrapFnError("cleanup threw",s)]]);return}}else if(e!=null&&typeof e=="object"){let s=e.beforeRun;if(typeof s=="function"){e.beforeRun=void 0;try{s()}catch(i){this._emit([[m,this._wrapFnError("cleanup.beforeRun threw",i)]]);return}}}let t=this._deps.map(s=>s.involvedThisWave?s.dataBatch.length>0?[...s.dataBatch]:[]:void 0),r=this._deps.map(s=>s.prevData);for(let s=0;s<this._deps.length;s++){let i=t[s];i!=null&&i.length>0&&(this._deps[s].prevData=i[i.length-1])}let o=this._deps.map(s=>s.terminal),a={prevData:r,terminalDeps:o,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let s={kind:"run",batchData:t,prevData:r};for(let i of this._inspectorHooks)i(s)}this._isExecutingFn=!0;try{let s=this._fn(t,this._actions,a);if(typeof s=="function")this._cleanup=s;else if(s!=null&&typeof s=="object"){let i=s;(typeof i.beforeRun=="function"||typeof i.deactivate=="function"||typeof i.invalidate=="function")&&(this._cleanup=s)}}catch(s){this._emit([[m,this._wrapFnError("fn threw",s)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>Je?(this._rerunDepth=0,this._emit([[m,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${Je} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,t){let r=t instanceof Error?t.message:String(t);return new Error(`Node "${this.name}": ${e}: ${r}`,{cause:t})}_frameBatch(e){let t=this._config.tierOf;if(e.length===1)return t(e[0][0])===3&&this._status!=="dirty"?[U,e[0]]:e;let r=!0,o=!1,a=!1,s=-1;for(let u of e){let d=t(u[0]);d<s&&(r=!1),d===3&&(o=!0),u[0]===v&&(a=!0),s=d}let i=e;if(!r){let u=e.map((d,c)=>({m:d,i:c,tier:t(d[0])}));u.sort((d,c)=>d.tier-c.tier||d.i-c.i),i=u.map(d=>d.m)}if(o&&!a&&this._status!=="dirty"){let u=0;for(;u<i.length&&t(i[u][0])===0;)u++;return u===0?[U,...i]:[...i.slice(0,u),U,...i.slice(u)]}return i}_emit(e){if(e.length===0)return;for(let i=0;i<e.length;i++){let u=e[i];if(u[0]===m&&u[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let t=e;if(this._isTerminal&&!this._resubscribable){let i=e.filter(u=>u[0]===S||u[0]===P);if(i.length===0)return;t=i}t=this._frameBatch(t);let o=null;for(let i=0;i<t.length;i++){let u=t[i],d=u[0];if(d!==O&&d!==C){o?.push(u);continue}if(u.length<2)throw new Error(`Node "${this.name}": [[${d===O?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let c=!0;if(this._pausable!==!1){let f=u[1];if(d===O)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(f),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(f))c=!1;else if(this._pauseLocks.delete(f),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let y=this._pauseBuffer;this._pauseBuffer=[],this._emit(y)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}c?o?.push(u):o==null&&(o=t.slice(0,i))}if(o!=null){if(o.length===0)return;t=o}if(this._hasMeta&&t.some(i=>i[0]===S))for(let i of Object.keys(this.meta))try{this.meta[i]._emit(we)}catch{}let{finalMessages:a,equalsError:s}=this._updateState(t);if(a.length>0&&this._config.inspectorEnabled){let i=this._config.globalInspector;if(i!=null)try{i({kind:"emit",node:this,messages:a})}catch{}}if(a.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let i=this._config.tierOf,u=[];for(let d of a)i(d[0])===3?this._pauseBuffer.push(d):u.push(d);u.length>0&&this._dispatchOrAccumulate(u)}else this._dispatchOrAccumulate(a);s!=null&&this._emit([[m,s]])}_updateState(e){let t=this._config.tierOf,r,o,a=-1,s=0;for(let c of e)t(c[0])===3&&s++;let i=s<=1,u=-1;if(this._versioning!=null&&s>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===b){u=c;break}}for(let c=0;c<e.length;c++){let f=e[c],y=f[0];if(y===b){if(f.length>=2){let p=!1;if(i&&this._cached!==void 0)try{p=this._equals(this._cached,f[1])}catch(T){o=this._wrapFnError("equals threw",T),a=c;break}if(p){r==null&&(r=e.slice(0,c)),r.push(ge),this._status="resolved";continue}this._cached=f[1],this._versioning!=null&&(u<0||c===u)&&qe(this._versioning,f[1],this._hashFn)}this._status="settled",r?.push(f)}else if(r?.push(f),y===v)this._status="dirty";else if(y===w)this._status="resolved";else if(y===_)this._status="completed";else if(y===m)this._status="errored";else if(y===P){this._cached=void 0,this._status="dirty";let p=this._cleanup;if(typeof p=="function"){this._cleanup=void 0;try{p()}catch{}}else if(p!=null&&typeof p=="object"){let T=p.invalidate;if(typeof T=="function")try{T()}catch{}}}else y===S&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let d=a>=0?r??e.slice(0,a):r??e;return o!=null?{finalMessages:d,equalsError:o}:{finalMessages:d}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let t=[...this._sinks];for(let r of t)r(e)};_dispatchOrAccumulate(e){if(Ie()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],Le(()=>this._flushBatchPending()));for(let t of e)this._batchPendingMessages.push(t);return}re(this._deliverToSinks,e,this._config.tierOf)}_flushBatchPending(){let e=this._batchPendingMessages;if(e===null||(this._batchPendingMessages=null,e.length===0))return;let t=this._frameBatch(e);re(this._deliverToSinks,t,this._config.tierOf)}},Ze=n=>Array.isArray(n),ke=n=>typeof n=="object"&&n!=null&&!Array.isArray(n)});function A(n,e){return B((r,o,a)=>n(o,a)??void 0,{describeKind:"producer",...e})}var Se=N(()=>{"use strict";ue()});function Oe(n){return{describeKind:"producer",...n}}function Qe(n,e){return A(t=>{let r=!1;try{for(let o of n){if(r)return;t.emit(o)}r||t.down([[_]])}catch(o){r||t.down([[m,o]])}return()=>{r=!0}},Oe(e))}function Vt(n){return n!=null&&typeof n.then=="function"}function Ht(n,e){let{signal:t,...r}=e??{};return A(o=>{let a=!1,s=()=>{a||(a=!0,o.down([[m,t.reason]]))};if(t?.aborted){s();return}return t?.addEventListener("abort",s,{once:!0}),Promise.resolve(n).then(i=>{a||(a=!0,t?.removeEventListener("abort",s),o.emit(i),o.down([[_]]))},i=>{a||(a=!0,t?.removeEventListener("abort",s),o.down([[m,i]]))}),()=>{a=!0,t?.removeEventListener("abort",s)}},Oe(r))}function Ut(n,e){let{signal:t,...r}=e??{};return A(o=>{let a=new AbortController,s=()=>a.abort(t?.reason);t?.aborted?a.abort(t.reason):t?.addEventListener("abort",s,{once:!0});let i=t??a.signal,u=!1,d=n[Symbol.asyncIterator](),c=()=>{u||i.aborted||Promise.resolve(d.next()).then(f=>{if(!(u||i.aborted)){if(f.done){o.down([[_]]);return}o.emit(f.value),c()}},f=>{!u&&!i.aborted&&o.down([[m,f]])})};return c(),()=>{u=!0,t?.removeEventListener("abort",s),a.abort(),Promise.resolve(d.return?.()).catch(()=>{})}},Oe(r))}function Wt(n){return n!=null&&typeof n=="object"&&"cache"in n&&typeof n.subscribe=="function"}function et(n,e){if(Wt(n))return n;if(Vt(n))return Ht(n,e);if(n!=null){let t=n;if(typeof t[Symbol.asyncIterator]=="function")return Ut(n,e);if(typeof t[Symbol.iterator]=="function")return Qe(n,e)}return $t(n)}function $t(...n){return Qe(n,void 0)}var tt=N(()=>{"use strict";W();Se()});var j,nt=N(()=>{"use strict";j=class{_timer;_gen=0;start(e,t){this.cancel(),this._gen+=1;let r=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,r===this._gen&&t()},e)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});function z(n){return{describeKind:"derived",...n}}function jt(n){return n<0?0:n}function Ce(n){return n[1]}function zt(n){if(typeof n!="number"||!Number.isFinite(n))throw new TypeError("backoff strategy must return a finite number");return n<0?0:n}function rt(n,e){let t=e?.count,r=e?.backoff,o=t!==void 0?t:r===void 0?0:2147483647;if(o<0)throw new RangeError("retry count must be >= 0");let a=r===void 0?null:typeof r=="string"?De(r):r;return A(s=>{let i=0,u=!1,d=null,c,f=new j;function y(){c?.(),c=void 0}function p(h){if(u)return;if(i>=o){y(),s.down([[m,h]]);return}let l=a===null?0:a(i,h,d);if(l==null){y(),s.down([[m,h]]);return}let g;try{g=zt(l)}catch{y(),s.down([[m,h]]);return}d=g,i+=1,y();let E=g>0?g/1e6:1;f.start(E,()=>{u||T()})}function T(){f.cancel(),y(),c=n.subscribe(h=>{if(!u)for(let l of h){let g=l[0];if(g===v)s.down([[v]]);else if(g===b)i=0,d=null,s.emit(l[1]);else if(g===w)s.down([[w]]);else if(g===_)y(),s.down([[_]]);else if(g===m){p(Ce(l));return}else s.down([l])}})}return T(),()=>{u=!0,f.cancel(),y()}},{...z(),initial:n.cache})}function ot(n){let e=Math.max(1,n?.failureThreshold??5),t=jt(n?.cooldownNs??30*1e9),r=n?.cooldown??null,o=Math.max(1,n?.halfOpenMax??1),a=n?.now??H,s="closed",i=0,u=0,d=0,c=t,f=0;function y(){if(!r)return t;let h=r(u);return h!==null?h:t}function p(){s="open",c=y(),d=a(),f=0}return{canExecute(){return s==="closed"?!0:s==="open"?a()-d>=c?(s="half-open",f=1,!0):!1:f<o?(f++,!0):!1},recordSuccess(){s==="half-open"?(s="closed",i=0,u=0):s==="closed"&&(i=0)},recordFailure(h){if(s==="half-open"){u++,p();return}s==="closed"&&(i++,i>=e&&p())},get state(){return s},get failureCount(){return i},reset(){s="closed",i=0,u=0,f=0}}}function st(n,e){let t=e?.onOpen??"skip";return r=>{let o=B([],(a,s)=>{function i(){o.meta.breakerState.down([[b,n.state]])}let u=r.subscribe(d=>{for(let c of d){let f=c[0];f===v?s.down([[v]]):f===b?n.canExecute()?(i(),s.emit(c[1])):(i(),t==="error"?s.down([[m,new Ae]]):s.down([[w]])):f===w?s.down([[w]]):f===_?(n.recordSuccess(),i(),s.down([[_]])):f===m?(n.recordFailure(Ce(c)),i(),s.down([c])):s.down([c])}});return i(),u},{...z(),meta:{breakerState:n.state},completeWhenDepsComplete:!1,initial:r.cache});return{node:o,breakerState:o.meta.breakerState}}}function qt(n,e){if(n<=0)throw new RangeError("capacity must be > 0");if(e<0)throw new RangeError("refillPerSecond must be >= 0");let t=n,r=H();function o(a){if(e>0){let s=a-r;t=Math.min(n,t+s/1e9*e)}r=a}return{available(){return o(H()),t},tryConsume(a=1){if(a<=0)return!0;let s=H();return o(s),t>=a?(t-=a,!0):!1},putBack(a=1){a<=0||(o(H()),t=Math.min(n,t+a))}}}function it(n,e){let{maxEvents:t,windowNs:r}=e;if(t<=0)throw new RangeError("maxEvents must be > 0");if(r<=0)throw new RangeError("windowNs must be > 0");let o=e.maxBuffer;if(o!==void 0&&o<1)throw new RangeError("maxBuffer must be >= 1");let a=e.onOverflow??"drop-newest",s=t*1e9/r;return A(i=>{let u=qt(t,s),d=[],c=new j,f=!1,y=1e9/s;function p(){for(;d.length>0;)if(u.tryConsume(1))i.emit(d.shift());else{c.start(Math.max(1,y/1e6),p);return}}let T=n.subscribe(h=>{for(let l of h){if(f)return;let g=l[0];if(g===v)i.down([[v]]);else if(g===b){if(o!==void 0&&d.length>=o){if(a!=="drop-newest")if(a==="drop-oldest")d.shift(),d.push(l[1]);else{f=!0,c.cancel(),d.length=0,i.down([[m,new Re(o)]]);return}}else d.push(l[1]);p()}else if(g===w)i.down([[w]]);else if(g===_)f=!0,c.cancel(),d.length=0,i.down([[_]]);else if(g===m)f=!0,c.cancel(),d.length=0,i.down([l]);else if(g===S){f=!0,c.cancel(),d.length=0,i.down([l]);return}else i.down([l])}});return()=>{f=!0,c.cancel(),T()}},{...z(),initial:n.cache})}function at(n,e){let t=e?.initialStatus??"pending",r=B([],(o,a)=>{let s=t;return r.meta.status.down([[b,t]]),r.meta.error.down([[b,null]]),n.subscribe(u=>{for(let d of u){let c=d[0];if(c===v)a.down([[v]]);else if(c===b)s==="errored"?he(()=>{r.meta.error.down([[b,null]]),r.meta.status.down([[b,"active"]])}):r.meta.status.down([[b,"active"]]),s="active",a.emit(d[1]);else if(c===w)a.down([[w]]);else if(c===_)r.meta.status.down([[b,"completed"]]),s="completed",a.down([[_]]);else if(c===m){let f=Ce(d);he(()=>{r.meta.error.down([[b,f]]),r.meta.status.down([[b,"errored"]])}),s="errored",a.down([d])}else a.down([d])}})},{...z(),meta:{status:t,error:null},completeWhenDepsComplete:!1,resubscribable:!0,initial:n.cache});return{node:r,status:r.meta.status,error:r.meta.error}}function Kt(n){return n!=null&&typeof n=="object"&&"cache"in n&&typeof n.subscribe=="function"}function Yt(n){return n!=null&&typeof n.then=="function"}function Jt(n){return n!=null&&typeof n=="object"&&typeof n[Symbol.asyncIterator]=="function"}function ut(n,e){return A(t=>{let r,o;function a(){o?.(),o=void 0,Kt(e)||Yt(e)||Jt(e)?r=et(e).subscribe(i=>{t.down(i)}):(t.emit(e),t.down([[_]]))}return o=n.subscribe(s=>{for(let i of s){let u=i[0];if(u===v)t.down([[v]]);else if(u===b)t.emit(i[1]);else if(u===w)t.down([[w]]);else if(u===_)t.down([[_]]);else if(u===m){a();return}else if(u===S){r?.(),t.down([i]);return}else t.down([i])}}),()=>{o?.(),r?.()}},{...z(),initial:n.cache})}function dt(n,e){if(e<=0)throw new RangeError("timeoutNs must be > 0");return A(t=>{let r=!1,o=new j;function a(){let i=e/1e6;o.start(i,()=>{r||(r=!0,s(),t.down([[m,new Me(e)]]))})}let s=n.subscribe(i=>{for(let u of i){if(r)return;let d=u[0];if(d===v)t.down([[v]]);else if(d===b)a(),t.emit(u[1]);else if(d===w)t.down([[w]]);else if(d===_){o.cancel(),r=!0,t.down([[_]]);return}else if(d===m){o.cancel(),r=!0,t.down([u]);return}else if(d===S){o.cancel(),r=!0,t.down([u]);return}else t.down([u])}});return a(),()=>{r=!0,o.cancel(),s()}},{...z(),initial:n.cache})}var Ae,Re,Me,ct=N(()=>{"use strict";me();be();W();ue();Se();pe();tt();nt();Ae=class extends Error{name="CircuitOpenError";constructor(){super("Circuit breaker is open")}};Re=class extends Error{name="RateLimiterOverflowError";constructor(e){super(`rateLimiter buffer overflow (maxBuffer=${e})`)}};Me=class extends Error{name="TimeoutError";constructor(e){super(`Timed out after ${e/1e6}ms`)}}});var Qt={};yt(Qt,{NS_PER_MS:()=>M,NS_PER_SEC:()=>F,resilientPipeline:()=>Zt});module.exports=wt(Qt);pe();ct();W();ue();function lt(n,e,t){return{[n]:!0,[`${n}_type`]:e,...t??{}}}function Xt(n,e){return lt("reduction",n,e)}function ft(n,e,t){if(e.length===0)throw new RangeError("budgetGate requires at least one constraint");let r=e.map(p=>p.node),o=[n,...r],a=[],s=!1,i=!1,u=Symbol("budget-gate"),d=new Array(e.length);function c(){return e.every((p,T)=>p.check(d[T]))}function f(p){for(;a.length>0&&c();){let T=a[0];a=a.slice(1),p.emit(T)}a.length===0&&i&&(i=!1,p.down([[w]]))}return B([],(p,T)=>{for(let l=0;l<e.length;l++)d[l]=e[l].node.cache;let h=[];for(let l=0;l<o.length;l++){let g=o[l];h.push(g.subscribe(E=>{for(let k of E)y(k,l,T)}))}return()=>{for(let l of h)l()}},{...t,describeKind:"derived",meta:Xt("budget_gate",t?.meta)});function y(p,T,h){let l=p[0];if(T===0){if(l===b)return c()&&a.length===0?h.emit(p[1]):(a.push(p[1]),s||(s=!0,h.up([[O,u]]))),!0;if(l===v)return h.down([[v]]),!0;if(l===w)return a.length===0?h.down([[w]]):i=!0,!0;if(l===_||l===m){for(let g of a)h.emit(g);return a=[],i=!1,s&&(s=!1,h.up([[C,u]])),h.down([p]),!0}return!1}return l===b&&(d[T-1]=p[1]),l===b||l===w?(c()&&a.length>0?(f(h),a.length===0&&s&&(s=!1,h.up([[C,u]]))):!c()&&!s&&a.length>0&&(s=!0,h.up([[O,u]])),!0):l===v?!0:l===m?(h.down([p]),!0):l===_}}function Zt(n,e={}){let t=n;e.rateLimit!=null&&(t=it(t,e.rateLimit)),e.budget!=null&&e.budget.length>0&&(t=ft(t,e.budget));let r;if(e.breaker!=null){let a=ot(e.breaker),s=e.breakerOnOpen??"skip",i=st(a,{onOpen:s})(t);t=i.node,r=i.breakerState}if(e.timeoutMs!=null){if(e.timeoutMs<=0)throw new RangeError("timeoutMs must be > 0");if(e.timeoutMs>9e6)throw new RangeError("timeoutMs must be <= 9_000_000 (\u22482.5h) to stay within safe ns arithmetic");t=dt(t,e.timeoutMs*1e6)}e.retry!=null&&(t=rt(t,e.retry)),e.fallback!==void 0&&(t=ut(t,e.fallback));let o=at(t,{initialStatus:e.initialStatus??"pending"});return{node:o.node,status:o.status,error:o.error,breakerState:r}}0&&(module.exports={NS_PER_MS,NS_PER_SEC,resilientPipeline});
@@ -1 +1 @@
1
- import{a as c}from"../../chunk-Y36UZ5VS.js";import"../../chunk-KA6MMXIY.js";import"../../chunk-5Z4HDCO6.js";import"../../chunk-OL33ZI6R.js";import"../../chunk-MGKAO4EK.js";import"../../chunk-ESMPEKEV.js";import"../../chunk-TWMEGG45.js";import"../../chunk-5JDE5JHE.js";import{a,b}from"../../chunk-4VVTGLXJ.js";import"../../chunk-2GQREQ6C.js";import"../../chunk-KASHOCF5.js";import"../../chunk-W4TSQ6RJ.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{a as NS_PER_MS,b as NS_PER_SEC,c as resilientPipeline};
1
+ import{a as c}from"../../chunk-ZM7C2FUM.js";import"../../chunk-JMGGCSIC.js";import"../../chunk-K54OKWNY.js";import"../../chunk-RWGJQQLT.js";import"../../chunk-LWGLBCMU.js";import"../../chunk-PSQNYY72.js";import"../../chunk-SGS4OJGS.js";import"../../chunk-ESMPEKEV.js";import"../../chunk-N2KKISCE.js";import"../../chunk-WQ7I7JVU.js";import{a,b}from"../../chunk-4VVTGLXJ.js";import"../../chunk-UMH3HSP7.js";import"../../chunk-7AJKUA36.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{a as NS_PER_MS,b as NS_PER_SEC,c as resilientPipeline};