@graphrefly/graphrefly 0.39.0 → 0.41.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 (218) hide show
  1. package/dist/{cascading-g2_rhhaM.d.ts → cascading-BNfxffgc.d.ts} +1 -1
  2. package/dist/{cascading-BzuxW0_w.d.cts → cascading-Cxs1eztH.d.cts} +1 -1
  3. package/dist/chunk-2W553JJC.js +1 -0
  4. package/dist/{chunk-5LK7XMEV.js → chunk-33N4TU3X.js} +1 -1
  5. package/dist/chunk-4MKL6Q3K.js +1 -0
  6. package/dist/chunk-5B3JDG5F.js +1 -0
  7. package/dist/chunk-5QSXEMXG.js +1 -0
  8. package/dist/{chunk-R75BMDLA.js → chunk-5TEFC2ZX.js} +1 -1
  9. package/dist/chunk-5TOPVRN6.js +1 -0
  10. package/dist/{chunk-INHC33EH.js → chunk-5VEZLQFN.js} +1 -1
  11. package/dist/{chunk-NQI2C36M.js → chunk-7PQLZMOG.js} +1 -1
  12. package/dist/{chunk-7NZMZJMW.js → chunk-AI7QC7J6.js} +1 -1
  13. package/dist/{chunk-L7WY6TZS.js → chunk-AK5RHMC5.js} +1 -1
  14. package/dist/{chunk-ZOX3LBRV.js → chunk-CGNOWGV6.js} +1 -1
  15. package/dist/{chunk-INH6FS2G.js → chunk-CYOSWFT2.js} +1 -1
  16. package/dist/{chunk-GX5LSSRE.js → chunk-EC2WNSZ7.js} +1 -1
  17. package/dist/{chunk-HAWKGIXM.js → chunk-ELAASRBT.js} +1 -1
  18. package/dist/{chunk-7QFRK3N3.js → chunk-F7VUYPP6.js} +1 -1
  19. package/dist/{chunk-LQNOXGET.js → chunk-G3M3IMEV.js} +1 -1
  20. package/dist/{chunk-HX3EGQ5Z.js → chunk-GI4Q7PNY.js} +1 -1
  21. package/dist/{chunk-XQ55HO5N.js → chunk-H5SCWHWP.js} +1 -1
  22. package/dist/{chunk-CGDMTXSY.js → chunk-KNVCCBIU.js} +1 -1
  23. package/dist/{chunk-IA7DUNGB.js → chunk-L77I47VU.js} +1 -1
  24. package/dist/{chunk-JNMC2WJ6.js → chunk-M3FQSXEW.js} +1 -1
  25. package/dist/{chunk-D47YVDR5.js → chunk-OLIKJUKI.js} +1 -1
  26. package/dist/{chunk-SC7BQDNP.js → chunk-OV5AA6HJ.js} +1 -1
  27. package/dist/{chunk-7JRF5YEK.js → chunk-POXANAJ6.js} +1 -1
  28. package/dist/chunk-RSMEXK53.js +43 -0
  29. package/dist/{chunk-KD4NHLMU.js → chunk-SC27WTSG.js} +1 -1
  30. package/dist/chunk-TSOYJ743.js +1 -0
  31. package/dist/{chunk-AU7YTQX7.js → chunk-TT4C7DXW.js} +1 -1
  32. package/dist/{chunk-TFPZLQ5H.js → chunk-UISPDFJ3.js} +1 -1
  33. package/dist/{chunk-N7UIBZCW.js → chunk-URJ2VFNC.js} +1 -1
  34. package/dist/{chunk-GEAO3TL3.js → chunk-VV62MIG4.js} +1 -1
  35. package/dist/{chunk-VJJLIEAL.js → chunk-VXPLLA4P.js} +1 -1
  36. package/dist/{chunk-WHIZM6JV.js → chunk-WZYB3JQS.js} +1 -1
  37. package/dist/{chunk-S2U57TFC.js → chunk-X7QKTXXC.js} +1 -1
  38. package/dist/{chunk-7SD73DS6.js → chunk-YQRN4CIV.js} +1 -1
  39. package/dist/chunk-Z6X7B6A4.js +61 -0
  40. package/dist/{chunk-RF3QZP6D.js → chunk-ZAJ7J7TO.js} +1 -1
  41. package/dist/compat/index.d.cts +6 -6
  42. package/dist/compat/index.d.ts +6 -6
  43. package/dist/compat/index.js +1 -1
  44. package/dist/compat/nestjs/index.d.cts +4 -4
  45. package/dist/compat/nestjs/index.d.ts +4 -4
  46. package/dist/compat/nestjs/index.js +1 -1
  47. package/dist/compat/zustand/index.d.cts +2 -2
  48. package/dist/compat/zustand/index.d.ts +2 -2
  49. package/dist/compat/zustand/index.js +1 -1
  50. package/dist/{composite-DGatA-JK.d.ts → decay-BnrlbxSv.d.ts} +38 -2
  51. package/dist/{composite-CKd0e2vz.d.cts → decay-C25AyNAj.d.cts} +38 -2
  52. package/dist/extra/index.cjs +15 -15
  53. package/dist/extra/index.d.cts +6 -6
  54. package/dist/extra/index.d.ts +6 -6
  55. package/dist/extra/index.js +1 -1
  56. package/dist/extra/node.js +1 -1
  57. package/dist/extra/operators.js +1 -1
  58. package/dist/extra/reactive.d.cts +1 -1
  59. package/dist/extra/reactive.d.ts +1 -1
  60. package/dist/extra/reactive.js +1 -1
  61. package/dist/extra/render/index.d.cts +1 -1
  62. package/dist/extra/render/index.d.ts +1 -1
  63. package/dist/extra/sources.cjs +1 -1
  64. package/dist/extra/sources.js +1 -1
  65. package/dist/graph/index.d.cts +3 -3
  66. package/dist/graph/index.d.ts +3 -3
  67. package/dist/graph/index.js +1 -1
  68. package/dist/{graph-30XSgtVX.d.ts → graph-BkIkog4h.d.ts} +1 -1
  69. package/dist/{graph-BUwMAxJI.d.cts → graph-E6likq7w.d.cts} +1 -1
  70. package/dist/{index-BXd6OMEy.d.ts → index-3k4Gg6-n.d.ts} +2 -2
  71. package/dist/{index-DszPlZzK.d.ts → index-40ZT4MHj.d.ts} +1 -1
  72. package/dist/index-8s-Qm-gz.d.ts +218 -0
  73. package/dist/{index-K-vl_c6A.d.cts → index-A3U3CSve.d.cts} +1 -1
  74. package/dist/{index-jKLph6cu.d.ts → index-B6iTqKtJ.d.ts} +1 -1
  75. package/dist/{index-WyFKER-c.d.ts → index-B72TQQHd.d.cts} +3 -3
  76. package/dist/{index-CmqiJZKM.d.ts → index-BAQrjuZF.d.ts} +64 -6
  77. package/dist/{index-CusEP3Sv.d.ts → index-BQ1fR4li.d.ts} +1 -1
  78. package/dist/{index-jr6PuSBt.d.ts → index-BaA-xpSw.d.ts} +2 -2
  79. package/dist/{index-FVoPvhAu.d.cts → index-Bd91Nmf4.d.cts} +2 -2
  80. package/dist/{index-PqbnoScQ.d.ts → index-BgjS2b8N.d.ts} +2 -2
  81. package/dist/{index-DCbE8fFM.d.cts → index-BiHUBEKq.d.cts} +2 -2
  82. package/dist/{index-DlgHqQxW.d.cts → index-BilOa6AE.d.cts} +6 -32
  83. package/dist/{index-DoYc8BWK.d.cts → index-BmSQLAZo.d.cts} +2 -2
  84. package/dist/{index-DlrWu9Hs.d.cts → index-C-dkXOpB.d.cts} +1 -1
  85. package/dist/{index-C7VV_qOs.d.ts → index-C5cQ7Gfx.d.ts} +2 -2
  86. package/dist/{index-CPhBvRJU.d.ts → index-C6ZUaos7.d.ts} +1 -1
  87. package/dist/{index-PlJ3MraE.d.ts → index-CAP3UGsq.d.ts} +1 -1
  88. package/dist/{index-B41Asm7D.d.ts → index-CD2dBMet.d.ts} +2 -2
  89. package/dist/{index-C19qqa38.d.ts → index-CG33HeBW.d.ts} +19 -4
  90. package/dist/index-CGhMJNHb.d.cts +128 -0
  91. package/dist/{index-BAlaVimV.d.ts → index-CQtWm7jS.d.ts} +2 -2
  92. package/dist/{index-8R1vzNOx.d.cts → index-CRm0YIzC.d.cts} +2 -2
  93. package/dist/index-CUIkE1l9.d.cts +230 -0
  94. package/dist/{index-KlZ_ZUip.d.cts → index-Cczxgd2D.d.ts} +3 -3
  95. package/dist/{index-DIHcMLr6.d.cts → index-CgnCFhr2.d.cts} +1 -1
  96. package/dist/{index-BC9VybQs.d.ts → index-Ck35nA-T.d.ts} +2 -2
  97. package/dist/{index-BndG0cpK.d.cts → index-Cnr1WrlX.d.cts} +1 -1
  98. package/dist/{index-H_I66pav.d.cts → index-CtFNGe-m.d.cts} +2 -2
  99. package/dist/index-CuPUehFa.d.cts +218 -0
  100. package/dist/index-D1Gc7wV5.d.ts +230 -0
  101. package/dist/{index-CWHtYmSh.d.cts → index-D4uimgee.d.cts} +1 -1
  102. package/dist/{index-xZYcDqFH.d.cts → index-DGD4_fj6.d.cts} +19 -4
  103. package/dist/{index-CwP_KAMS.d.cts → index-DGTo1yka.d.cts} +64 -6
  104. package/dist/{index-BUPVld1w.d.ts → index-DH4fm2Ck.d.ts} +2 -2
  105. package/dist/{index-DyM4tFAe.d.cts → index-DQQCOIt8.d.cts} +2 -2
  106. package/dist/{index-BJ26eEjs.d.cts → index-DVAlsmEU.d.cts} +2 -2
  107. package/dist/{index-DINuaZlJ.d.cts → index-DVDapw2k.d.cts} +1 -1
  108. package/dist/{index-iTX5IqSP.d.ts → index-DfOK_oL5.d.ts} +208 -203
  109. package/dist/{index-DTtBpuQy.d.cts → index-DgJc8Zgc.d.cts} +5 -3
  110. package/dist/{index-BKMdnYnk.d.ts → index-DhLyOHYZ.d.ts} +1 -1
  111. package/dist/{index-89FczVZ_.d.ts → index-DhnsQfa3.d.ts} +77 -51
  112. package/dist/{index-L8XI8Zql.d.cts → index-DktLSZOc.d.cts} +2 -2
  113. package/dist/{index-pVDQcbar.d.cts → index-DpiGqtrs.d.cts} +77 -51
  114. package/dist/{index-mNwgxC21.d.cts → index-DuRsN9ae.d.cts} +208 -203
  115. package/dist/{index-B9fmw5n2.d.ts → index-I1cCY3ZI.d.ts} +5 -3
  116. package/dist/index-N2MAxt7_.d.ts +128 -0
  117. package/dist/{index-Br3WnqEn.d.ts → index-WSlcjhQF.d.ts} +6 -32
  118. package/dist/{index-DQUVq1_d.d.ts → index-bXXLSvor.d.ts} +2 -2
  119. package/dist/{index-BhUaMYm_.d.ts → index-da2V5vPy.d.ts} +1 -1
  120. package/dist/{index-PsVHpPwP.d.cts → index-t6L2qpHh.d.cts} +2 -2
  121. package/dist/{index-IwFqHxCs.d.cts → index-tV3AA9hI.d.cts} +1 -1
  122. package/dist/index.cjs +48 -48
  123. package/dist/index.d.cts +33 -33
  124. package/dist/index.d.ts +33 -33
  125. package/dist/index.js +1 -1
  126. package/dist/patterns/ai/browser.cjs +5 -5
  127. package/dist/patterns/ai/browser.d.cts +2 -2
  128. package/dist/patterns/ai/browser.d.ts +2 -2
  129. package/dist/patterns/ai/browser.js +1 -1
  130. package/dist/patterns/ai/index.cjs +14 -14
  131. package/dist/patterns/ai/index.d.cts +11 -11
  132. package/dist/patterns/ai/index.d.ts +11 -11
  133. package/dist/patterns/ai/index.js +1 -1
  134. package/dist/patterns/ai/node.js +1 -1
  135. package/dist/patterns/audit/index.d.cts +3 -3
  136. package/dist/patterns/audit/index.d.ts +3 -3
  137. package/dist/patterns/audit/index.js +1 -1
  138. package/dist/patterns/cqrs/index.d.cts +3 -3
  139. package/dist/patterns/cqrs/index.d.ts +3 -3
  140. package/dist/patterns/cqrs/index.js +1 -1
  141. package/dist/patterns/demo-shell/index.d.cts +3 -3
  142. package/dist/patterns/demo-shell/index.d.ts +3 -3
  143. package/dist/patterns/demo-shell/index.js +1 -1
  144. package/dist/patterns/domain-templates/index.d.cts +2 -2
  145. package/dist/patterns/domain-templates/index.d.ts +2 -2
  146. package/dist/patterns/domain-templates/index.js +1 -1
  147. package/dist/patterns/graphspec/index.d.cts +2 -2
  148. package/dist/patterns/graphspec/index.d.ts +2 -2
  149. package/dist/patterns/graphspec/index.js +1 -1
  150. package/dist/patterns/guarded-execution/index.cjs +3 -3
  151. package/dist/patterns/guarded-execution/index.d.cts +4 -4
  152. package/dist/patterns/guarded-execution/index.d.ts +4 -4
  153. package/dist/patterns/guarded-execution/index.js +1 -1
  154. package/dist/patterns/harness/index.cjs +8 -8
  155. package/dist/patterns/harness/index.d.cts +7 -7
  156. package/dist/patterns/harness/index.d.ts +7 -7
  157. package/dist/patterns/harness/index.js +1 -1
  158. package/dist/patterns/job-queue/index.cjs +3 -3
  159. package/dist/patterns/job-queue/index.d.cts +3 -3
  160. package/dist/patterns/job-queue/index.d.ts +3 -3
  161. package/dist/patterns/job-queue/index.js +1 -1
  162. package/dist/patterns/lens/index.cjs +3 -3
  163. package/dist/patterns/lens/index.d.cts +3 -4
  164. package/dist/patterns/lens/index.d.ts +3 -4
  165. package/dist/patterns/lens/index.js +1 -1
  166. package/dist/patterns/memory/index.cjs +1 -1
  167. package/dist/patterns/memory/index.d.cts +3 -3
  168. package/dist/patterns/memory/index.d.ts +3 -3
  169. package/dist/patterns/memory/index.js +1 -1
  170. package/dist/patterns/messaging/index.d.cts +2 -2
  171. package/dist/patterns/messaging/index.d.ts +2 -2
  172. package/dist/patterns/messaging/index.js +1 -1
  173. package/dist/patterns/orchestration/index.d.cts +3 -3
  174. package/dist/patterns/orchestration/index.d.ts +3 -3
  175. package/dist/patterns/orchestration/index.js +1 -1
  176. package/dist/patterns/process/index.d.cts +4 -4
  177. package/dist/patterns/process/index.d.ts +4 -4
  178. package/dist/patterns/process/index.js +1 -1
  179. package/dist/patterns/reactive-layout/index.d.cts +3 -3
  180. package/dist/patterns/reactive-layout/index.d.ts +3 -3
  181. package/dist/patterns/reactive-layout/index.js +1 -1
  182. package/dist/patterns/reduction/index.d.cts +2 -2
  183. package/dist/patterns/reduction/index.d.ts +2 -2
  184. package/dist/patterns/reduction/index.js +1 -1
  185. package/dist/patterns/refine-loop/index.d.cts +3 -3
  186. package/dist/patterns/refine-loop/index.d.ts +3 -3
  187. package/dist/patterns/refine-loop/index.js +1 -1
  188. package/dist/patterns/resilient-pipeline/index.cjs +3 -1
  189. package/dist/patterns/resilient-pipeline/index.d.cts +7 -3
  190. package/dist/patterns/resilient-pipeline/index.d.ts +7 -3
  191. package/dist/patterns/resilient-pipeline/index.js +1 -1
  192. package/dist/patterns/surface/index.d.cts +3 -3
  193. package/dist/patterns/surface/index.d.ts +3 -3
  194. package/dist/patterns/surface/index.js +1 -1
  195. package/dist/{pipeline-graph-D8vKcO_p.d.ts → pipeline-graph-CB4La-UW.d.ts} +2 -2
  196. package/dist/{pipeline-graph-BQPr2Lqs.d.cts → pipeline-graph-MWrQZXCq.d.cts} +2 -2
  197. package/dist/{reactive-layout-8CSc0tiA.d.cts → reactive-layout-BtZfUKuL.d.cts} +1 -1
  198. package/dist/{reactive-layout-DkTXxtSy.d.ts → reactive-layout-KJj4E2dT.d.ts} +1 -1
  199. package/dist/{reactive-map-B2qfD3hb.d.cts → reactive-map-6P_k3AQM.d.cts} +1 -1
  200. package/dist/{reactive-map-jFIsE6Kt.d.ts → reactive-map-CjXByDV-.d.ts} +1 -1
  201. package/dist/{resilience-HTF2LBRS.js → resilience-JISHQD2F.js} +1 -1
  202. package/dist/{topology-tree-B5Ngw3j0.d.cts → topology-tree-3LBKFsUo.d.cts} +1 -1
  203. package/dist/{topology-tree-BtvbgMXJ.d.ts → topology-tree-mF7Emqzm.d.ts} +1 -1
  204. package/package.json +1 -1
  205. package/dist/chunk-5XRI6RM3.js +0 -1
  206. package/dist/chunk-73PBQNST.js +0 -1
  207. package/dist/chunk-A6ZSKGUG.js +0 -1
  208. package/dist/chunk-EWF7KCDJ.js +0 -61
  209. package/dist/chunk-IUB4NYI2.js +0 -1
  210. package/dist/chunk-MC4UYY2X.js +0 -1
  211. package/dist/chunk-XEUANKBO.js +0 -43
  212. package/dist/chunk-ZJ7SM3G2.js +0 -1
  213. package/dist/index-BEHmxORq.d.ts +0 -135
  214. package/dist/index-BM9szD8n.d.cts +0 -113
  215. package/dist/index-BskfDoZ_.d.ts +0 -113
  216. package/dist/index-CIRG8Hxp.d.cts +0 -135
  217. package/dist/index-Cey6VTnX.d.ts +0 -166
  218. package/dist/index-CpLpJb6A.d.cts +0 -166
@@ -1,20 +1,20 @@
1
- "use strict";var ln=Object.defineProperty;var Go=Object.getOwnPropertyDescriptor;var Ko=Object.getOwnPropertyNames;var zo=Object.prototype.hasOwnProperty;var ne=(n,e)=>()=>(n&&(e=n(n=0)),e);var fn=(n,e)=>{for(var t in e)ln(n,t,{get:e[t],enumerable:!0})},$o=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Ko(e))!zo.call(n,s)&&s!==t&&ln(n,s,{get:()=>e[s],enumerable:!(r=Go(e,s))||r.enumerable});return n};var jo=n=>$o(ln({},"__esModule",{value:!0}),n);function It(){return tt>0||vt}function mr(){return tt>0}function rt(n){tt>0?Tt.push(n):n()}function $(n){tt+=1;let e=!1;try{n()}catch(t){throw e=!0,t}finally{if(tt-=1,tt===0)if(e){if(!vt){let t=Tt.splice(0);for(let r of t)try{r()}catch{}je.length=0,Ue.length=0,nt.length=0}}else Uo()}}function Uo(){let n=!vt;n&&(vt=!0);let e=[],t=0;try{for(;je.length>0||Ue.length>0||nt.length>0||n&&Tt.length>0;){if(n&&Tt.length>0){let o=Tt.splice(0);for(let i of o)try{i()}catch(a){e.push(a)}continue}if(t+=1,t>1e3)throw je.length=0,Ue.length=0,nt.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let s=(je.length>0?je:Ue.length>0?Ue:nt).splice(0);for(let o of s)try{o()}catch(i){e.push(i)}}}finally{n&&(vt=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function Lt(n,e,t){if(e.length===0)return;if(e.length===1){let d=t(e[0][0]);if(d<3||!It()){n(e);return}(d>=5?nt:d===4?Ue:je).push(()=>n(e));return}let r=e.length,s=r,o=r,i=r,a=0;for(;a<r&&t(e[a][0])<3;)a++;for(s=a;a<r&&t(e[a][0])===3;)a++;for(o=a;a<r&&t(e[a][0])===4;)a++;i=a;let u=It();if(s>0){let d=e.slice(0,s);n(d)}if(o>s){let d=e.slice(s,o);u?je.push(()=>n(d)):n(d)}if(i>o){let d=e.slice(o,i);u?Ue.push(()=>n(d)):n(d)}if(r>i){let d=e.slice(i,r);u?nt.push(()=>n(d)):n(d)}}var tt,vt,je,Ue,nt,Tt,ye=ne(()=>{"use strict";tt=0,vt=!1,je=[],Ue=[],nt=[],Tt=[]});function re(){return Math.trunc(performance.now()*1e6)}function te(){return Date.now()*1e6}var Ae=ne(()=>{"use strict"});var Ie,x,V,C,ke,le,pe,z,N,S,ot,pn,Wo,hn,Ho,qo,mn,gr,br,yr,gn,X=ne(()=>{"use strict";Ie=Symbol.for("graphrefly/START"),x=Symbol.for("graphrefly/DATA"),V=Symbol.for("graphrefly/DIRTY"),C=Symbol.for("graphrefly/RESOLVED"),ke=Symbol.for("graphrefly/INVALIDATE"),le=Symbol.for("graphrefly/PAUSE"),pe=Symbol.for("graphrefly/RESUME"),z=Symbol.for("graphrefly/TEARDOWN"),N=Symbol.for("graphrefly/COMPLETE"),S=Symbol.for("graphrefly/ERROR"),ot=Object.freeze([V]),pn=Object.freeze([C]),Wo=Object.freeze([ke]),hn=Object.freeze([Ie]),Ho=Object.freeze([N]),qo=Object.freeze([z]),mn=Object.freeze([ot]),gr=Object.freeze([pn]),br=Object.freeze([Wo]),yr=Object.freeze([Ho]),gn=Object.freeze([qo])});function Tr(n,e){let t=new TextEncoder().encode(n.name);if(t.length===0||t.length>255)throw new Error(`encodeEnvelope: codec name "${n.name}" encodes to ${t.length} bytes (must be 1\u2013255)`);let r=n.version;if(!Number.isInteger(r)||r<0||r>65535)throw new Error(`encodeEnvelope: codec.version ${r} out of u16 range (expected integer 0\u201365535)`);let s=2+t.length+2+e.length;if(s>4294967295)throw new Error(`encodeEnvelope: total envelope size ${s} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let o=new Uint8Array(s),i=0;return o[i++]=bn,o[i++]=t.length,o.set(t,i),i+=t.length,o[i++]=r>>>8&255,o[i++]=r&255,o.set(e,i),o}function wr(n,e){if(n.length<vr)throw new Error(`decodeEnvelope: bytes too short (${n.length} < ${vr})`);let t=0,r=n[t++];if(r!==bn)throw new Error(`decodeEnvelope: unsupported envelope version ${r} (expected ${bn})`);let s=n[t++];if(s===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(t+s+2>n.length)throw new Error(`decodeEnvelope: envelope truncated (need ${t+s+2} bytes, have ${n.length})`);let o=new TextDecoder().decode(n.subarray(t,t+s));t+=s;let i=(n[t]<<8|n[t+1])>>>0;t+=2;let a=n.subarray(t),u=e.lookupCodec(o);if(u==null)throw new Error(`decodeEnvelope: codec "${o}" not registered (envelope codec_v=${i})`);return{codec:u,codecVersion:i,payload:a}}function kr(n){n.registerCodec(Jo)}var Jo,bn,vr,yn=ne(()=>{"use strict";Jo={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)}},bn=1,vr=4});function Bt(n){if(n==null)return st;let{type:e,id:t,...r}=n;return{type:e??"system",id:t??"",...r}}var st,vn=ne(()=>{"use strict";st={type:"system",id:""}});function xr(n){n.registerMessageType(Ie,{tier:0,wireCrossing:!1}),n.registerMessageType(V,{tier:1,wireCrossing:!1}),n.registerMessageType(ke,{tier:1,wireCrossing:!1,metaPassthrough:!1}),n.registerMessageType(le,{tier:2,wireCrossing:!1}),n.registerMessageType(pe,{tier:2,wireCrossing:!1}),n.registerMessageType(x,{tier:3,wireCrossing:!0}),n.registerMessageType(C,{tier:3,wireCrossing:!0}),n.registerMessageType(N,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(S,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(z,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var Vt,Nr=ne(()=>{"use strict";X();Vt=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_rigorRecorder;_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}get rigorRecorder(){return this._rigorRecorder}set rigorRecorder(e){this._rigorRecorder=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.")}}});function _r(n){return Array.isArray(n)?[...n]:[n]}function Yo(n,e){return n.has(e)||n.has("*")}function Sr(n){let e=[];return n((s,o)=>{e.push({kind:"allow",actions:new Set(_r(s)),where:o?.where??(()=>!0)})},(s,o)=>{e.push({kind:"deny",actions:new Set(_r(s)),where:o?.where??(()=>!0)})}),(s,o)=>{let i=!1,a=!1;for(let u of e)Yo(u.actions,o)&&u.where(s)&&(u.kind==="deny"?i=!0:a=!0);return i?!1:a}}function Tn(n){let e=Qo.filter(t=>n({type:t,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(t=>t==="human"||t==="llm"||t==="system")?"both":e.length===1?e[0]:e.join("+")}var Ee,Qo,wt=ne(()=>{"use strict";Ee=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}};Qo=["human","llm","wallet","system"]});function wn(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(wn);if(typeof n=="object"&&n!==null){let e={};for(let t of Object.keys(n).sort())e[t]=wn(n[t]);return e}return null}function es(n){let e=Zo.encode(n),t=e.length,r=t*8,s=t+9+63&-64,o=new Uint8Array(s);o.set(e),o[t]=128;let i=new DataView(o.buffer);i.setUint32(s-4,r>>>0,!1),i.setUint32(s-8,Math.floor(r/4294967296)>>>0,!1);let a=1779033703,u=3144134277,d=1013904242,c=2773480762,l=1359893119,p=2600822924,f=528734635,h=1541459225,g=new Uint32Array(64),m=(b,v)=>b>>>v|b<<32-v;for(let b=0;b<s;b+=64){for(let O=0;O<16;O++)g[O]=i.getUint32(b+O*4,!1);for(let O=16;O<64;O++){let G=g[O-15],P=g[O-2],L=m(G,7)^m(G,18)^G>>>3,ue=m(P,17)^m(P,19)^P>>>10;g[O]=g[O-16]+L+g[O-7]+ue>>>0}let v=a,T=u,k=d,_=c,w=l,E=p,R=f,M=h;for(let O=0;O<64;O++){let G=m(w,6)^m(w,11)^m(w,25),P=w&E^~w&R,L=M+G+P+Xo[O]+g[O]>>>0,ue=m(v,2)^m(v,13)^m(v,22),U=v&T^v&k^T&k,de=ue+U>>>0;M=R,R=E,E=w,w=_+L>>>0,_=k,k=T,T=v,v=L+de>>>0}a=a+v>>>0,u=u+T>>>0,d=d+k>>>0,c=c+_>>>0,l=l+w>>>0,p=p+E>>>0,f=f+R>>>0,h=h+M>>>0}let y=b=>b.toString(16).padStart(8,"0");return y(a)+y(u)+y(d)+y(c)+y(l)+y(p)+y(f)+y(h)}function kn(n){let e=wn(n??null),t=JSON.stringify(e);return es(t).slice(0,16)}function ts(){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 xn(n,e,t){let r=t?.id??ts();if(n===0)return{id:r,version:0};let o=(t?.hash??kn)(e);return{id:r,version:0,cid:o,prev:null}}function Er(n,e,t){n.version+=1,"cid"in n&&(n.prev=n.cid,n.cid=t(e))}var Xo,Zo,Or=ne(()=>{"use strict";Xo=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]),Zo=new TextEncoder});function Ar(n){return{node:n,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function Nn(n){n.prevData=void 0,n.dirty=!1,n.involvedThisWave=!1,n.dataBatch.length=0,n.terminal=void 0}function Ft(n){return n.length===0?n:typeof n[0]=="symbol"?[n]:n}function B(n,e,t){let r=Cr(n)?n:[],s=typeof n=="function"?n:typeof e=="function"?e:void 0,o={};return Cr(n)?o=(_n(e)?e:t)??{}:_n(n)?o=n:o=(_n(e)?e:t)??{},new oe(r,s,o)}var Rr,Mr,ns,rs,me,oe,Cr,_n,ge=ne(()=>{"use strict";yn();vn();ye();Ae();Nr();wt();X();Or();Rr=()=>{},Mr=100;ns=(n,e,t,r)=>{t.direction==="down-in"&&n._onDepMessage(t.depIndex,e)},rs=(n,e,t,r)=>{let s=n;if(s._status==="completed"||s._status==="errored")return;let o=s._cached,i=o===void 0?[hn]:[hn,[x,o]];s._status==="dirty"&&i.push(ot),Lt(e,i,s._config.tierOf)},me=new Vt({onMessage:ns,onSubscribe:rs});xr(me);kr(me);oe=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??me,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??kn;let s=r.versioning??this._config.defaultVersioning;this._versioningLevel=s,this._versioning=s!=null?xn(s,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Ar);let o={};for(let[a,u]of Object.entries(r.meta??{})){let d={initial:u,name:`${r.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};r.guard!=null&&(d.guard=r.guard),o[a]=new n([],void 0,d)}Object.freeze(o),this.meta=o,this._hasMeta=Object.keys(o).length>0;let i=this;this._actions={emit(a){i._emit([[x,a]])},down(a){i._emit(Ft(a))},up(a){i._emitUp(Ft(a))}},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 s=t?.hash??this._hashFn;s!==this._hashFn&&(this._hashFn=s);let o=this._cached===void 0?void 0:this._cached,i=this._versioning,a=i?.id??t?.id,u=i?.version??0,d=xn(e,o,{id:a,hash:s});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=Bt(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 s=Bt(e?.actor),o=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(s,o))throw new Ee({actor:s,action:o,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(s,o))throw new Ee({actor:s,action:o,nodeName:this.name})}this._lastMutation={actor:s,timestamp_ns:te()}}down(e,t){let r=Ft(e);r.length!==0&&(this._checkGuard(t),this._emit(r))}emit(e,t){this._checkGuard(t),this._emit([[x,e]])}up(e,t){if(this._deps.length===0)return;let r=Ft(e);if(r.length===0)return;this._checkGuard(t);let s=t??{internal:!0};this._validateUpTiers(r);for(let o of this._deps)o.node.up?.(r,s)}_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 s=t(r[0]);if(s===3||s===4)throw new Error(`Node "${this.name}": tier-${s} 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=Bt(t);if(!this._guard(u,"observe"))throw new Ee({actor:u,action:"observe",nodeName:this.name})}let s=this._isTerminal&&this._resubscribable;if(s){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)Nn(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 o;try{o=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:s},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 i=this._isTerminal;if(this._sinkCount===1&&!i)try{this._activate()}catch(u){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof o=="function")try{o()}catch{}throw u}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let a=!1;return()=>{a||(a=!0,this._sinkCount-=1,this._removeSink(e),typeof o=="function"&&o(),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 s=r,o=this._deps[r];o.unsub=Rr,o.unsub=o.node.subscribe(i=>{if(o.unsub===null)return;let a=this._config.tierOf,u=!1;for(let d of i)a(d[0])>=3&&(u=!0),this._config.onMessage(this,d,{direction:"down-in",depIndex:s},this._actions);u&&this._maybeRunFnOnSettlement()}),t++}}catch(r){this._deps[t].unsub=null;for(let s=0;s<t;s++){let o=this._deps[s];if(o.unsub!=null){let i=o.unsub;o.unsub=null;try{i()}catch{}Nn(o)}}throw this._dirtyDepCount=0,r}}_addDep(e){for(let s=0;s<this._deps.length;s++)if(this._deps[s].node===e)return s;let t=this._deps.length,r=Ar(e);if(this._deps.push(r),this._sinks==null)return t;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(mn),r.unsub=Rr;try{r.unsub=e.subscribe(s=>{if(r.unsub===null)return;let o=this._config.tierOf,i=!1;for(let a of s)o(a[0])>=3&&(i=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:t},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(s){throw r.unsub=null,this._deps.pop(),this._dirtyDepCount--,s}return t}_deactivate(e=!1){let t=this._cleanup;if(this._cleanup=void 0,typeof t=="function")try{t()}catch(r){this._emit([[S,this._wrapFnError("cleanup threw",r)]])}else if(t!=null&&typeof t=="object"){let r=t.deactivate;if(typeof r=="function")try{r()}catch(s){this._emit([[S,this._wrapFnError("cleanup.deactivate threw",s)]])}}for(let r of this._deps){if(r.unsub!=null){let s=r.unsub;r.unsub=null;try{s()}catch{}}Nn(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],s=t[0];if(this._inspectorHooks!=null){let o={kind:"dep_message",depIndex:e,message:t};for(let i of this._inspectorHooks)i(o)}if(s!==Ie){if(s===V){this._depDirtied(r);return}if(s===ke){if(this._depInvalidated(r),this._cached===void 0)return;this._emit(br);return}if(s===le||s===pe){this._emit([t]);return}if(s===z){this._emit(gn);return}if(s===x)this._depSettledAsData(r,t[1]);else if(s===C)this._depSettledAsResolved(r);else if(s===N)this._depSettledAsTerminal(r,!0);else if(s===S)this._depSettledAsTerminal(r,t[1]);else{this._emit([t]);return}if(!this._fn){(s===x||s===C)&&this._emit([t]),(s===N||s===S)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(mn))}_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(gr),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([[S,e.terminal]]);return}this._autoComplete&&this._deps.every(t=>t.terminal!==void 0)&&this._emit(yr)}_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(i){this._emit([[S,this._wrapFnError("cleanup threw",i)]]);return}}else if(e!=null&&typeof e=="object"){let i=e.beforeRun;if(typeof i=="function"){e.beforeRun=void 0;try{i()}catch(a){this._emit([[S,this._wrapFnError("cleanup.beforeRun threw",a)]]);return}}}let t=this._deps.map(i=>i.involvedThisWave?i.dataBatch.length>0?[...i.dataBatch]:[]:void 0),r=this._deps.map(i=>i.prevData);for(let i=0;i<this._deps.length;i++){let a=t[i];a!=null&&a.length>0&&(this._deps[i].prevData=a[a.length-1])}let s=this._deps.map(i=>i.terminal),o={prevData:r,terminalDeps:s,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let i={kind:"run",batchData:t,prevData:r};for(let a of this._inspectorHooks)a(i)}this._isExecutingFn=!0;try{let i=this._fn(t,this._actions,o);if(typeof i=="function")this._cleanup=i;else if(i!=null&&typeof i=="object"){let a=i;(typeof a.beforeRun=="function"||typeof a.deactivate=="function"||typeof a.invalidate=="function")&&(this._cleanup=i)}}catch(i){this._emit([[S,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>Mr?(this._rerunDepth=0,this._emit([[S,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${Mr} \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"?[ot,e[0]]:e;let r=!0,s=!1,o=!1,i=-1;for(let u of e){let d=t(u[0]);d<i&&(r=!1),d===3&&(s=!0),u[0]===V&&(o=!0),i=d}let a=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),a=u.map(d=>d.m)}if(s&&!o&&this._status!=="dirty"){let u=0;for(;u<a.length&&t(a[u][0])===0;)u++;return u===0?[ot,...a]:[...a.slice(0,u),ot,...a.slice(u)]}return a}_emit(e){if(e.length===0)return;for(let a=0;a<e.length;a++){let u=e[a];if(u[0]===S&&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 a=e.filter(u=>u[0]===z||u[0]===ke);if(a.length===0)return;t=a}t=this._frameBatch(t);let s=null;for(let a=0;a<t.length;a++){let u=t[a],d=u[0];if(d!==le&&d!==pe){s?.push(u);continue}if(u.length<2)throw new Error(`Node "${this.name}": [[${d===le?"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 l=u[1];if(d===le)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(l),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(l))c=!1;else if(this._pauseLocks.delete(l),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let p=this._pauseBuffer;this._pauseBuffer=[],this._emit(p)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}c?s?.push(u):s==null&&(s=t.slice(0,a))}if(s!=null){if(s.length===0)return;t=s}if(this._hasMeta&&t.some(a=>a[0]===z))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(gn)}catch{}let{finalMessages:o,equalsError:i}=this._updateState(t);if(o.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:o})}catch{}}if(o.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,u=[];for(let d of o)a(d[0])===3?this._pauseBuffer.push(d):u.push(d);u.length>0&&this._dispatchOrAccumulate(u)}else this._dispatchOrAccumulate(o);i!=null&&this._emit([[S,i]])}_updateState(e){let t=this._config.tierOf,r,s,o=-1,i=0;for(let c of e)t(c[0])===3&&i++;let a=i<=1,u=-1;if(this._versioning!=null&&i>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===x){u=c;break}}for(let c=0;c<e.length;c++){let l=e[c],p=l[0];if(p===x){if(l.length>=2){let f=!1;if(a&&this._cached!==void 0)try{f=this._equals(this._cached,l[1])}catch(h){s=this._wrapFnError("equals threw",h),o=c;break}if(f){r==null&&(r=e.slice(0,c)),r.push(pn),this._status="resolved";continue}this._cached=l[1],this._versioning!=null&&(u<0||c===u)&&Er(this._versioning,l[1],this._hashFn)}this._status="settled",r?.push(l)}else if(r?.push(l),p===V)this._status="dirty";else if(p===C)this._status="resolved";else if(p===N){this._status="completed";{let f=this._config.rigorRecorder;if(f!=null)try{f.onTerminalTransition(this,"completed",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(p===S){this._status="errored";{let f=this._config.rigorRecorder;if(f!=null)try{f.onTerminalTransition(this,"errored",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(p===ke){if(this._cached!==void 0){let h=this._config.rigorRecorder;if(h!=null)try{h.onNonVacuousInvalidate(this,this._cached)}catch{}}this._cached=void 0,this._status="dirty";let f=this._cleanup;if(typeof f=="function"){this._cleanup=void 0;try{f()}catch{}}else if(f!=null&&typeof f=="object"){let h=f.invalidate;if(typeof h=="function")try{h()}catch{}}}else p===z&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let d=o>=0?r??e.slice(0,o):r??e;return s!=null?{finalMessages:d,equalsError:s}:{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(mr()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],rt(()=>this._flushBatchPending()));for(let t of e)this._batchPendingMessages.push(t);return}Lt(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);Lt(this._deliverToSinks,t,this._config.tierOf)}},Cr=n=>Array.isArray(n),_n=n=>typeof n=="object"&&n!=null&&!Array.isArray(n)});function F(n,e){return B([],{...e,initial:n})}function A(n,e){return B((r,s,o)=>n(s,o)??void 0,{describeKind:"producer",...e})}function be(n,e,t){return B(n,(s,o,i)=>{let a=s.map((u,d)=>u!=null&&u.length>0?u.at(-1):i.prevData[d]);o.emit(e(a,i))},{describeKind:"derived",...t})}function Gt(n,e,t){return B(n,(s,o,i)=>{let a=s.map((u,d)=>u!=null&&u.length>0?u.at(-1):i.prevData[d]);return e(a,o,i)??void 0},{describeKind:"effect",...t})}var fe=ne(()=>{"use strict";ge()});var Dr={};fn(Dr,{NS_PER_MS:()=>ve,NS_PER_SEC:()=>Ce,constant:()=>Sn,decorrelatedJitter:()=>Mn,exponential:()=>On,fibonacci:()=>Rn,linear:()=>En,resolveBackoffPreset:()=>it,withMaxAttempts:()=>Pr});function We(n){return n<0?0:n}function os(n,e){return e==="none"?n:e==="full"?Math.random()*n:n/2+Math.random()*(n/2)}function ss(n,e){return n+Math.random()*(e-n)}function Sn(n){let e=We(n);return()=>e}function En(n,e){let t=We(n),r=e===void 0?t:We(e);return s=>t+r*Math.max(0,s)}function On(n){let e=We(n?.baseNs??1e8),t=n?.factor!==void 0&&n.factor<1?1:n?.factor??2,r=We(n?.maxDelayNs??30*1e9),s=n?.jitter??"none";return o=>{let i;if(e===0)i=0;else if(t===1)i=e;else{let a=r/e,u=1;for(let d=0;d<Math.max(0,o);d++){if(u>=a){u=a;break}u*=t}i=e*u,i>r&&(i=r)}return os(i,s)}}function Rn(n=100*1e6,e=30*1e9){let t=We(n),r=We(e);function s(o){if(o<=0)return 1;let i=1,a=2;for(let u=1;u<o;u++){let d=i+a;i=a,a=d}return a}return o=>{let i=s(o)*t;return i<=r?i:r}}function Mn(n=100*1e6,e=30*1e9){return(t,r,s)=>{let i=Math.min(e,(s??n)*3);return ss(n,i)}}function Pr(n,e){return(t,r,s)=>t>=e?null:n(t,r,s)}function it(n){if(n==="constant")return Sn(1*1e9);if(n==="linear")return En(1*1e9);if(n==="exponential")return On();if(n==="fibonacci")return Rn();if(n==="decorrelatedJitter")return Mn();throw new Error(`Unknown backoff preset: "${String(n)}". Use one of: constant, linear, exponential, fibonacci, decorrelatedJitter`)}var ve,Ce,kt=ne(()=>{"use strict";ve=1e6,Ce=1e9});function Cn(n,e){if(e!=null&&e.length>0)return new Set(e);switch(n){case"standard":return new Set(["type","status","value","deps","meta","v"]);case"full":return null;case"spec":return new Set(["type","deps","meta","value"]);default:return new Set(["type","deps"])}}function is(n){return n._describeKind!=null?n._describeKind:n._deps.length>0?"derived":n._fn!=null?"producer":"state"}function q(n,e){let t={factory:n};return e!==void 0&&(t.factoryArgs=e),t}function as(n){let e={};for(let[t,r]of Object.entries(n.meta))try{e[t]=r.cache}catch{}return e}function Pn(n,e,t){let r=e==null,s=!r&&e!=null?[...e].filter(c=>c.startsWith("meta.")).map(c=>c.slice(5)):null,o=r||e.has("meta")||s!=null&&s.length>0,i="state",a=[];n instanceof oe&&(i=is(n),a=n._deps.map(c=>c.node.name??""));let u={type:i,deps:a};(r||e.has("status"))&&(u.status=n.status);let d=n instanceof oe?n._guard:void 0;if(o){let c={...as(n)};if(d!=null&&c.access===void 0&&(c.access=Tn(d)),s!=null&&s.length>0&&!e.has("meta")){let l={};for(let p of s)p in c&&(l[p]=c[p]);u.meta=l}else u.meta=c}if(n.name!=null&&(u.name=n.name),(r||e.has("value"))&&(!t||i==="state")){n.status==="sentinel"&&(u.sentinel=!0);try{u.value=n.cache}catch{}}if((r||e.has("v"))&&n.v!=null){let c={id:n.v.id,version:n.v.version};"cid"in n.v&&(c.cid=n.v.cid,c.prev=n.v.prev),u.v=c}return(r||e.has("guard"))&&d!=null&&(u.guard=Tn(d)),(r||e.has("lastMutation"))&&n.lastMutation!=null&&(u.lastMutation=n.lastMutation),u}var xt=ne(()=>{"use strict";wt();ge()});function Nt(n,e,t){let r=new Set;for(let s of n.split(",")){let[o,i]=s.split("/"),a=i?Number.parseInt(i,10):1;if(Number.isNaN(a)||a<1)throw new Error(`Invalid cron step: ${s}`);let u,d;if(o==="*")u=e,d=t;else if(o.includes("-")){let[c,l]=o.split("-");u=Number.parseInt(c,10),d=Number.parseInt(l,10)}else u=Number.parseInt(o,10),d=u;if(Number.isNaN(u)||Number.isNaN(d))throw new Error(`Invalid cron field: ${n}`);if(u<e||d>t)throw new Error(`Cron field out of range: ${n} (${e}-${t})`);if(u>d)throw new Error(`Invalid cron range: ${u}-${d} in ${n}`);for(let c=u;c<=d;c+=a)r.add(c)}return r}function Dn(n){let e=n.trim().split(/\s+/);if(e.length!==5)throw new Error(`Invalid cron: expected 5 fields, got ${e.length}`);return{minutes:Nt(e[0],0,59),hours:Nt(e[1],0,23),daysOfMonth:Nt(e[2],1,31),months:Nt(e[3],1,12),daysOfWeek:Nt(e[4],0,6)}}function In(n,e){return n.minutes.has(e.getMinutes())&&n.hours.has(e.getHours())&&n.daysOfMonth.has(e.getDate())&&n.months.has(e.getMonth()+1)&&n.daysOfWeek.has(e.getDay())}var Ln=ne(()=>{"use strict"});function Bn(n,e,t){return{[n]:!0,[`${n}_type`]:e,...t??{}}}var Vn=ne(()=>{"use strict"});function Kt(n,e,t){if(e.length===0)throw new RangeError("budgetGate requires at least one constraint");let r=e.map(f=>f.node),s=[n,...r],o=new Fn,i=!1,a=!1,u=Symbol("budget-gate"),d=new Array(e.length);function c(){return e.every((f,h)=>f.check(d[h]))}function l(f){for(;o.size>0&&c();){let h=o.shift();f.emit(h)}o.size===0&&a&&(a=!1,f.down([[C]]))}return B([],(f,h)=>{for(let m=0;m<e.length;m++)d[m]=e[m].node.cache;let g=[];for(let m=0;m<s.length;m++){let y=s[m];g.push(y.subscribe(b=>{for(let v of b)p(v,m,h)}))}return()=>{for(let m of g)m()}},{...t,describeKind:"derived",meta:Bn("resilience","budget_gate",t?.meta)});function p(f,h,g){let m=f[0];if(h===0){if(m===x)return c()&&o.size===0?g.emit(f[1]):(o.push(f[1]),i||(i=!0,g.up([[le,u]]))),!0;if(m===V)return g.down([[V]]),!0;if(m===C)return o.size===0?g.down([[C]]):a=!0,!0;if(m===N||m===S){for(;o.size>0;)g.emit(o.shift());return a=!1,i&&(i=!1,g.up([[pe,u]])),g.down([f]),!0}return!1}if(m===x&&(d[h-1]=f[1]),m===x||m===C){let y=c();return y&&o.size>0?(l(g),o.size===0&&i&&(i=!1,g.up([[pe,u]]))):!y&&!i&&o.size>0&&(i=!0,g.up([[le,u]])),!0}return m===V?!0:m===S?(g.down([f]),!0):m===N}}var Fn,Lr=ne(()=>{"use strict";X();ge();Vn();Fn=class{buf=[];head=0;get size(){return this.buf.length-this.head}push(e){this.buf.push(e)}shift(){if(this.head>=this.buf.length)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head++,this.head>32&&this.head*2>this.buf.length&&(this.buf=this.buf.slice(this.head),this.head=0),e}clear(){this.buf=[],this.head=0}}});var Pe,zt=ne(()=>{"use strict";Pe=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}}});var Le,$t=ne(()=>{"use strict";Le=class{constructor(e){this.capacity=e;if(!Number.isInteger(e)||e<=0)throw new Error(`RingBuffer capacity must be a positive integer (got ${e})`);this.buf=new Array(e)}buf;head=0;_size=0;get size(){return this._size}get maxSize(){return this.capacity}push(e){let t=(this.head+this._size)%this.capacity;this.buf[t]=e,this._size<this.capacity?this._size++:this.head=(this.head+1)%this.capacity}shift(){if(this._size===0)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head=(this.head+1)%this.capacity,this._size--,e}at(e){if(this._size===0)return;let t=e<0?this._size+e:e;if(!(t<0||t>=this._size))return this.buf[(this.head+t)%this.capacity]}toArray(){let e=new Array(this._size);for(let t=0;t<this._size;t++)e[t]=this.buf[(this.head+t)%this.capacity];return e}clear(){for(let e=0;e<this._size;e++)this.buf[(this.head+e)%this.capacity]=void 0;this.head=0,this._size=0}}});function He(n){return{describeKind:"derived",...n}}function us(n){return n<0?0:n}function Gn(n){return n[1]}function ds(n){if(typeof n!="number"||!Number.isFinite(n))throw new TypeError("backoff strategy must return a finite number");return n<0?0:n}function Br(n){let e=n?.count,t=n?.backoff;if(t!==void 0&&e===void 0)throw new RangeError("retry({ backoff }) requires explicit count to prevent unbounded retries; pass { count: <n>, backoff: ... }");let r=e!==void 0?e:0;if(r<0)throw new RangeError("retry count must be >= 0");let s=t===void 0?null:typeof t=="string"?it(t):t;return{maxRetries:r,strategy:s}}function Vr(n){let e={};return n?.count!==void 0&&(e.count=n.count),typeof n?.backoff=="string"&&(e.backoff=n.backoff),Object.keys(e).length>0?e:void 0}function Fr(n,e,t){let r=0,s=!1,o=null,i,a=new Pe;function u(){i?.(),i=void 0}function d(l){if(s)return;if(r>=n.maxRetries){u(),t.down([[S,l]]);return}let p=n.strategy===null?0:n.strategy(r,l,o);if(p==null){u(),t.down([[S,l]]);return}let f;try{f=ds(p)}catch{u(),t.down([[S,l]]);return}o=f,r+=1,u();let h=f>0?f/1e6:1;a.start(h,()=>{s||c()})}function c(){a.cancel(),u();let l;try{l=e()}catch(p){d(p);return}i=l.subscribe(p=>{if(!s)for(let f of p){let h=f[0];if(h===V)t.down([[V]]);else if(h===x)r=0,o=null,t.emit(f[1]);else if(h===C)t.down([[C]]);else if(h===N)u(),t.down([[N]]);else if(h===S){d(Gn(f));return}else t.down([f])}})}return c(),()=>{s=!0,a.cancel(),u()}}function _t(n,e){return typeof n=="function"?ls(n,e):cs(n,e)}function cs(n,e){let t=Br(e);return A(r=>Fr(t,()=>n,r),{...He(),initial:n.cache,meta:{...q("retry",Vr(e))}})}function ls(n,e){let t=Br(e);return A(r=>Fr(t,n,r),{...He(),initial:e?.initial,meta:{...q("retry",Vr(e))}})}function Kn(n){let e=Math.max(1,n?.failureThreshold??5),t=us(n?.cooldownNs??30*1e9),r=n?.cooldown??null,s=Math.max(1,n?.halfOpenMax??1),o=n?.now??re,i="closed",a=0,u=0,d=0,c=t,l=0;function p(){if(!r)return t;let g=r(u);return g!==null?g:t}function f(){i="open",c=p(),d=o(),l=0}return{canExecute(){return i==="closed"?!0:i==="open"?o()-d>=c?(i="half-open",l=1,!0):!1:l<s?(l++,!0):!1},recordSuccess(){i==="half-open"?(i="closed",a=0,u=0):i==="closed"&&(a=0)},recordFailure(g){if(i==="half-open"){u++,f();return}i==="closed"&&(a++,a>=e&&f())},get state(){return i},get failureCount(){return a},reset(){i="closed",a=0,u=0,l=0}}}function zn(n,e){let t=e?.onOpen??"skip";return r=>{let s=B([],(o,i)=>{function a(){s.meta.breakerState.down([[x,n.state]])}let u=r.subscribe(d=>{for(let c of d){let l=c[0];l===V?i.down([[V]]):l===x?n.canExecute()?(a(),i.emit(c[1])):(a(),t==="error"?i.down([[S,new ut]]):i.down([[C]])):l===C?i.down([[C]]):l===N?(n.recordSuccess(),a(),i.down([[N]])):l===S?(n.recordFailure(Gn(c)),a(),i.down([c])):i.down([c])}});return a(),u},{...He(),meta:{breakerState:n.state,...q("withBreaker",{onOpen:t})},completeWhenDepsComplete:!1,initial:r.cache});return{node:s,breakerState:s.meta.breakerState}}}function jt(n,e,t){if(n<=0)throw new RangeError("capacity must be > 0");if(e<0)throw new RangeError("refillPerSecond must be >= 0");let r=t?.clock??re,s=n,o=r();function i(a){if(e>0){let u=a-o;s=Math.min(n,s+u/1e9*e)}o=a}return{available(){return i(r()),s},tryConsume(a=1){if(a<=0)return!0;let u=r();return i(u),s>=a?(s-=a,!0):!1},putBack(a=1){a<=0||(i(r()),s=Math.min(n,s+a))}}}function $n(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 s=e.maxBuffer;if(s===void 0)throw new RangeError("rateLimiter requires explicit maxBuffer (use Infinity to opt in to unbounded)");let o=s===1/0;if(!o&&(!Number.isInteger(s)||s<1))throw new RangeError("maxBuffer must be a positive integer (or Infinity for unbounded)");let i=e.onOverflow??"drop-newest",a=t*1e9/r,u=A(d=>{let c=jt(t,a),l=o?ps():fs(s),p=new Pe,f=!1,h=0,g=1e9/a,m=u.meta.droppedCount;function y(){m.emit(h)}m.cache!==0&&y();function b(){for(;l.size>0;)if(c.tryConsume(1))d.emit(l.shift());else{p.start(Math.max(1,g/1e6),b);return}}function v(){h+=1,y()}function T(){for(f=!0,p.cancel();l.size>0;)l.shift();h=0}let k=n.subscribe(_=>{for(let w of _){if(f)return;let E=w[0];if(E===V)d.down([[V]]);else if(E===x){if(!o&&l.size>=s)if(i==="drop-newest")v();else if(i==="drop-oldest")l.shift(),l.push(w[1]),v();else{v(),T(),d.down([[S,new dt(s)]]);return}else l.push(w[1]);b()}else if(E===C)d.down([[C]]);else if(E===N)T(),d.down([[N]]);else if(E===S)T(),d.down([w]);else if(E===z){T(),d.down([w]);return}else d.down([w])}});return()=>{f=!0,p.cancel(),k()}},{...He(),initial:n.cache,meta:{droppedCount:0,...q("rateLimiter",e)}});return{node:u,droppedCount:u.meta.droppedCount}}function fs(n){let e=new Le(n);return{push:t=>e.push(t),shift:()=>e.shift(),get size(){return e.size}}}function ps(){let n=[];return{push:e=>{n.push(e)},shift:()=>n.shift(),get size(){return n.length}}}function St(n,e){let t=e?.initialStatus??"pending",r=B([],(s,o)=>{let i=t;return r.meta.status.down([[x,t]]),r.meta.error.down([[x,null]]),n.subscribe(u=>{for(let d of u){let c=d[0];if(c===V)o.down([[V]]);else if(c===x)i==="errored"?$(()=>{r.meta.error.down([[x,null]]),r.meta.status.down([[x,"running"]])}):r.meta.status.down([[x,"running"]]),i="running",o.emit(d[1]);else if(c===C)o.down([[C]]);else if(c===N)r.meta.status.down([[x,"completed"]]),i="completed",o.down([[N]]);else if(c===S){let l=Gn(d);$(()=>{r.meta.error.down([[x,l]]),r.meta.status.down([[x,"errored"]])}),i="errored",o.down([d])}else o.down([d])}})},{...He(),meta:{status:t,error:null,...q("withStatus",{initialStatus:t})},completeWhenDepsComplete:!1,resubscribable:!0,initial:n.cache});return{node:r,status:r.meta.status,error:r.meta.error}}function hs(n){return n!=null&&typeof n=="object"&&"cache"in n&&typeof n.subscribe=="function"}function ms(n){return n!=null&&typeof n.then=="function"}function gs(n){return n!=null&&typeof n=="object"&&typeof n[Symbol.asyncIterator]=="function"}function jn(n,e){return A(t=>{let r,s;function o(){s?.(),s=void 0,hs(e)||ms(e)||gs(e)?r=ie(e).subscribe(a=>{t.down(a);for(let u of a){let d=u[0];if(d===N||d===S||d===z){r=void 0;return}}}):(t.emit(e),t.down([[N]]))}return s=n.subscribe(i=>{for(let a of i){let u=a[0];if(u===V)t.down([[V]]);else if(u===x)t.emit(a[1]);else if(u===C)t.down([[C]]);else if(u===N)t.down([[N]]);else if(u===S){o();return}else if(u===z){r?.(),t.down([a]);return}else t.down([a])}}),()=>{s?.(),r?.()}},{...He(),initial:n.cache,meta:{...q("fallback")}})}function Un(n,e){if(e<=0)throw new RangeError("timeoutNs must be > 0");return A(t=>{let r=!1,s=new Pe;function o(){let a=e/1e6;s.start(a,()=>{r||(r=!0,i(),t.down([[S,new ct(e)]]))})}let i=n.subscribe(a=>{for(let u of a){if(r)return;let d=u[0];if(d===V)t.down([[V]]);else if(d===x)o(),t.emit(u[1]);else if(d===C)t.down([[C]]);else if(d===N){s.cancel(),r=!0,t.down([[N]]);return}else if(d===S){s.cancel(),r=!0,t.down([u]);return}else if(d===z){s.cancel(),r=!0,t.down([u]);return}else t.down([u])}});return o(),()=>{r=!0,s.cancel(),i()}},{...He(),initial:n.cache,meta:{...q("timeout",{timeoutNs:e})}})}var ut,dt,ct,Gr=ne(()=>{"use strict";Lr();ye();Ae();X();xt();ge();fe();kt();De();zt();$t();ut=class extends Error{name="CircuitOpenError";constructor(){super("Circuit breaker is open")}};dt=class extends Error{name="RateLimiterOverflowError";constructor(e){super(`rateLimiter buffer overflow (maxBuffer=${e})`)}};ct=class extends Error{name="TimeoutError";constructor(e){super(`Timed out after ${e/1e6}ms`)}}});var Kr={};fn(Kr,{CircuitOpenError:()=>ut,RateLimiterOverflowError:()=>dt,TimeoutError:()=>ct,budgetGate:()=>Kt,circuitBreaker:()=>Kn,fallback:()=>jn,rateLimiter:()=>$n,retry:()=>_t,timeout:()=>Un,tokenBucket:()=>jt,withBreaker:()=>zn,withStatus:()=>St});var Ut=ne(()=>{"use strict";Gr()});function Ne(n){return{describeKind:"producer",...n}}function $r(n){return/[\\^$+?.()|[\]{}]/.test(n)?`\\${n}`:n}function bs(n){let e="^";for(let t=0;t<n.length;t+=1){let r=n[t];if(r==="*"){n[t+1]==="*"?(e+=".*",t+=1):e+="[^/]*";continue}e+=$r(r)}return e+="$",new RegExp(e)}function ys(n,e){for(let t of e)if(t.test(n))return!0;return!1}function vs(n,e){let t=B([n],(s,o)=>{let i=s[0];if(i==null||i.length===0){o.down([[C]]);return}for(let a of i)o.emit(a)},{describeKind:"derived",initial:n.cache}),r=t.subscribe.bind(t);return t.subscribe=(s,o)=>(e(s),r(s,o)),t}function qe(n,e){let{signal:t,period:r,...s}=e??{};return A(o=>{let i=!1,a=0,u,d,c=()=>{i=!0,u!==void 0&&clearTimeout(u),d!==void 0&&clearInterval(d),t?.removeEventListener("abort",p)},l=()=>{i||(r!=null?(o.emit(a++),d=setInterval(()=>{i||o.emit(a++)},r)):(i=!0,t?.removeEventListener("abort",p),o.emit(a++),o.down([[N]])))},p=()=>{i||(c(),o.down([[S,t.reason]]))};if(t?.aborted){p();return}return u=setTimeout(l,n),t?.addEventListener("abort",p,{once:!0}),c},Ne(s))}function Ts(n){let{signal:e,...t}=n??{};return A(r=>{let s=!1,o,i,a=!1,u=!1,d=typeof requestAnimationFrame=="function"?requestAnimationFrame:void 0,c=typeof cancelAnimationFrame=="function"?cancelAnimationFrame:void 0,l=typeof document<"u"?document:void 0,p=()=>{o!==void 0&&c&&c(o),i!==void 0&&clearTimeout(i),o=void 0,i=void 0},f=()=>{s=!0,p(),a&&(e?.removeEventListener("abort",h),a=!1),u&&l&&(l.removeEventListener("visibilitychange",y),u=!1)},h=()=>{s||(f(),r.down([[S,e.reason]]))},g=b=>{s||(r.emit(b),m())},m=()=>{s||(d&&(!l||l.visibilityState!=="hidden")?o=d(g):i=setTimeout(()=>g(performance.now()),16))},y=()=>{s||(p(),m())};return e?.aborted?(h(),f):(e?.addEventListener("abort",h,{once:!0}),a=e!==void 0,l&&d&&(l.addEventListener("visibilitychange",y),u=!0),m(),f)},Ne(t))}function ws(n,e){let t=Dn(n),{tickMs:r,output:s,...o}=e??{},i=r??6e4,a=s==="date";return A(u=>{let d=-1,c=()=>{let p=new Date,f=p.getFullYear()*1e8+(p.getMonth()+1)*1e6+p.getDate()*1e4+p.getHours()*100+p.getMinutes();f!==d&&In(t,p)&&(d=f,u.emit(a?p:te()))};c();let l=setInterval(c,i);return()=>clearInterval(l)},{...Ne(o),name:o.name??`cron:${n}`})}function ks(n,e,t){let{capture:r,passive:s,once:o,...i}=t??{};return A(a=>{let u=c=>{a.emit(c)},d={capture:r,passive:s,once:o};return n.addEventListener(e,u,d),()=>n.removeEventListener(e,u,d)},Ne(i))}function qn(n,e){return A(t=>{let r=!1;try{for(let s of n){if(r)return;t.emit(s)}r||t.down([[N]])}catch(s){r||t.down([[S,s]])}return()=>{r=!0}},Ne(e))}function xs(n){return n!=null&&typeof n.then=="function"}function jr(n,e){let{signal:t,...r}=e??{};return A(s=>{let o=!1,i=()=>{o||(o=!0,s.down([[S,t.reason]]))};if(t?.aborted){i();return}return t?.addEventListener("abort",i,{once:!0}),Promise.resolve(n).then(a=>{o||(o=!0,t?.removeEventListener("abort",i),s.emit(a),s.down([[N]]))},a=>{o||(o=!0,t?.removeEventListener("abort",i),s.down([[S,a]]))}),()=>{o=!0,t?.removeEventListener("abort",i)}},Ne(r))}function Ur(n,e){let{signal:t,...r}=e??{};return A(s=>{let o=new AbortController,i=()=>o.abort(t?.reason);t?.aborted?o.abort(t.reason):t?.addEventListener("abort",i,{once:!0});let a=t??o.signal,u=!1,d=n[Symbol.asyncIterator](),c=()=>{u||a.aborted||Promise.resolve(d.next()).then(l=>{if(!(u||a.aborted)){if(l.done){s.down([[N]]);return}s.emit(l.value),c()}},l=>{!u&&!a.aborted&&s.down([[S,l]])})};return c(),()=>{u=!0,t?.removeEventListener("abort",i),o.abort(),Promise.resolve(d.return?.()).catch(()=>{})}},Ne(r))}function Ns(n){return n!=null&&typeof n=="object"&&"cache"in n&&typeof n.subscribe=="function"}function ie(n,e){if(Ns(n))return n;if(xs(n))return jr(n,e);if(n!=null){let t=n;if(typeof t[Symbol.asyncIterator]=="function")return Ur(n,e);if(typeof t[Symbol.iterator]=="function")return qn(n,e)}return Wr(n)}function Wr(...n){return qn(n,void 0)}function _s(n){return A(e=>{e.down([[N]])},Ne(n))}function Ss(n){return A(()=>{},Ne(n))}function Es(n,e){return A(t=>{t.down([[S,n]])},Ne(e))}function Os(n,e){let{signal:t,...r}=e??{},s=Ne(r),o=s.resubscribable===void 0?{...s,resubscribable:!0}:s;return A(i=>{let a,u=!1;try{let d=n();a=ie(d,e).subscribe(l=>{if(!u)for(let p of l){let f=p[0];if(f!==Ie)if(f===x)i.emit(p[1]);else if(f===N){u=!0,i.down([[N]]);break}else if(f===S){u=!0,i.down([[S,p[1]]]);break}else i.down([p])}})}catch(d){let c=d===void 0?new Error("defer: thunk threw undefined"):d;i.down([[S,c]])}return()=>{u=!0,a?.()}},o)}function Je(n,e,t){return B([n],(s,o)=>{let i=s[0];if(i!=null&&i.length>0)for(let a of i)e(a)},{describeKind:"effect",...t}).subscribe(()=>{})}function Rs(n,e){return B([n],(t,r,s)=>{s.store.buf||(s.store.buf=[]);let o=s.store.buf,i=t[0];if(i!=null&&i.length>0)for(let a of i)o.push(a);if(s.terminalDeps[0]===!0){r.emit([...o]),r.down([[N]]);return}(i==null||i.length===0)&&r.down([[C]])},{describeKind:"derived",completeWhenDepsComplete:!1,...e})}function Ms(n,e){return A(t=>n.subscribe(r=>{t.down(r)}),{...Ne(e),initial:n.cache})}function Jn(n,e,t){if(e<1)throw new RangeError("replay expects bufferSize >= 1");let r=[],s=A(o=>n.subscribe(i=>{for(let a of i)a[0]===x&&(r.push(a[1]),r.length>e&&r.shift());o.down(i)}),{...Ne(t),initial:n.cache});return vs(s,o=>{for(let i of r)o([[x,i]])})}function As(n,e){return Jn(n,1,e)}function Yn(n){return new Promise((e,t)=>{let r=!1,s=!1,o;o=n.subscribe(i=>{for(let a of i){if(r)return;if(a[0]===x){r=!0,e(a[1]),o?(o(),o=void 0):s=!0;return}if(a[0]===S){r=!0,t(a[1]),o?(o(),o=void 0):s=!0;return}if(a[0]===N){r=!0,t(new Error("completed without DATA")),o?(o(),o=void 0):s=!0;return}}}),s&&(o?.(),o=void 0)})}function Hn(n,e,t){return new Promise((r,s)=>{let o=!1,i=!1,a,u=t?.skipCurrent===!0;a=n.subscribe(d=>{for(let c of d){if(o)return;if(!(u&&c[0]===x)){if(c[0]===x){let l=c[1];if(e(l)){o=!0,r(l),a?(a(),a=void 0):i=!0;return}}if(c[0]===S){o=!0,s(c[1]),a?(a(),a=void 0):i=!0;return}if(c[0]===N){o=!0,s(new Error("completed without matching value")),a?(a(),a=void 0):i=!0;return}}}}),u=!1,i&&(a?.(),a=void 0)})}async function Cs(n,e){let t=e?.predicate??(o=>o!=null),r=e?.skipCurrent;if(e?.timeoutMs==null||e.timeoutMs<=0)return await Hn(n,t,{skipCurrent:r});if(Wn===void 0){let[o,i]=await Promise.all([Promise.resolve().then(()=>(Ut(),Kr)),Promise.resolve().then(()=>(kt(),Dr))]);Wn=o.timeout,zr=i.NS_PER_MS}let s=Wn(n,e.timeoutMs*zr);return await Hn(s,t,{skipCurrent:r})}function Ps(n,e){let t=new AbortController,r=e?.reason??new Error("cancelled via nodeSignal"),s,o=!1,i=()=>{s?(s(),s=void 0):o=!0};return s=n.subscribe(a=>{if(!t.signal.aborted)for(let u of a){if(u[0]===x&&u[1]===!0){t.abort(r),i();return}if(u[0]===S){t.abort(u[1]),i();return}if(u[0]===N){i();return}}}),o&&(s?.(),s=void 0),{signal:t.signal,dispose:()=>{s&&(s(),s=void 0)}}}function Ye(n){return n.subscribe(()=>{})}function Is(n){let e=F(0);return{node:e,increment(){let t=e.cache??0;return t>=n?!1:(e.down([[V],[x,t+1]]),!0)},get(){return e.cache??0},atCap(){return(e.cache??0)>=n}}}var Wn,zr,Ds,Hr=ne(()=>{"use strict";Ae();X();ge();fe();Ln();Ds=Jn});var De=ne(()=>{"use strict";Hr()});var mu={};fn(mu,{CircuitOpenError:()=>ut,ContentAddressedMissError:()=>Qt,DEFAULT_AUDIT_GUARD:()=>Po,NS_PER_MS:()=>ve,NS_PER_SEC:()=>Ce,NativeIndexBackend:()=>on,NativeListBackend:()=>sn,NativeLogBackend:()=>nn,NativeMapBackend:()=>Yt,NativePubSubBackend:()=>rn,RateLimiterOverflowError:()=>dt,ResettableTimer:()=>Pe,TimeoutError:()=>ct,appendAudit:()=>Ct,appendLogStorage:()=>Lo,audit:()=>ni,awaitSettled:()=>Cs,budgetGate:()=>Kt,buffer:()=>ri,bufferCount:()=>oi,bufferTime:()=>ii,bumpCursor:()=>ar,cached:()=>As,canonicalJson:()=>yo,cascadingCache:()=>ma,catchError:()=>gi,checkpointToRedis:()=>ia,checkpointToS3:()=>sa,circuitBreaker:()=>Kn,combine:()=>Qr,combineLatest:()=>pi,concat:()=>Js,concatMap:()=>Xs,constant:()=>Sn,contentAddressedStorage:()=>va,createAuditLog:()=>za,createTransport:()=>et,createWatermarkController:()=>ha,csvRows:()=>zi,debounce:()=>Zr,debounceTime:()=>hi,decay:()=>Bo,decorrelatedJitter:()=>Mn,defer:()=>Os,delay:()=>ei,deserializeError:()=>bt,dictKv:()=>au,dictSnapshot:()=>uu,distill:()=>ya,distinctUntilChanged:()=>Us,domainMeta:()=>Bn,elementAt:()=>zs,empty:()=>_s,escapeRegexChar:()=>$r,exhaustMap:()=>Qs,exponential:()=>On,externalBundle:()=>An,externalProducer:()=>at,fallback:()=>jn,fibonacci:()=>Rn,filter:()=>Ht,find:()=>Ks,first:()=>Qn,firstValueFrom:()=>Yn,firstWhere:()=>Hn,flatMap:()=>Zs,forEach:()=>Je,fromAny:()=>ie,fromAsyncIter:()=>Ur,fromCSV:()=>Ki,fromClickHouseWatch:()=>Ui,fromCron:()=>ws,fromDrizzle:()=>la,fromEvent:()=>ks,fromHTTP:()=>ro,fromHTTPPoll:()=>_i,fromHTTPStream:()=>Ni,fromIter:()=>qn,fromKafka:()=>Bi,fromKysely:()=>fa,fromMCP:()=>Oi,fromNATS:()=>qi,fromNDJSON:()=>ji,fromOTel:()=>Ri,fromPrisma:()=>ca,fromPrometheus:()=>Ii,fromPromise:()=>jr,fromPulsar:()=>Wi,fromRabbitMQ:()=>Yi,fromRaf:()=>Ts,fromRedisStream:()=>Fi,fromSSE:()=>xi,fromSqlite:()=>aa,fromSqliteCursor:()=>ua,fromStatsD:()=>Ci,fromSyslog:()=>Mi,fromTimer:()=>qe,fromWebSocket:()=>no,fromWebSocketReconnect:()=>Ei,fromWebhook:()=>yi,globToRegExp:()=>bs,interval:()=>di,jsonCodec:()=>Pt,jsonCodecFor:()=>ru,keepalive:()=>Ye,kvStorage:()=>lr,last:()=>Gs,lightMutation:()=>$a,linear:()=>En,lru:()=>lo,makeHttpError:()=>Ta,map:()=>Wt,matchesAnyPattern:()=>ys,matchesCron:()=>In,memoryAppendLog:()=>su,memoryBackend:()=>un,memoryKv:()=>iu,memorySnapshot:()=>ou,merge:()=>Et,mergeMap:()=>Xr,mergeReactiveLogs:()=>Ga,nameToSignal:()=>mt,ndjsonRows:()=>$i,never:()=>Ss,nodeSignal:()=>Ps,of:()=>Wr,onFirstData:()=>Yr,pairwise:()=>Ws,parseCron:()=>Dn,parsePrometheusText:()=>ao,parseSSEStream:()=>io,parseStatsD:()=>Di,parseSyslog:()=>Ai,pausable:()=>li,pubsub:()=>qa,race:()=>Ys,rateLimiter:()=>$n,reactiveCounter:()=>Is,reactiveIndex:()=>Qa,reactiveList:()=>Xa,reactiveLog:()=>sr,reactiveMap:()=>er,reactiveSink:()=>ae,reduce:()=>Bs,registerCursor:()=>Ua,registerCursorMap:()=>Wa,repeat:()=>ci,replay:()=>Jn,rescue:()=>to,resolveBackoffPreset:()=>it,retry:()=>_t,sample:()=>ti,scan:()=>Ls,serializeError:()=>gt,share:()=>Ms,shareReplay:()=>Ds,signalToName:()=>Ze,singleFromAny:()=>Za,singleNodeFromAny:()=>eu,skip:()=>Jr,snapshotStorage:()=>cr,sortJsonValue:()=>an,stableJsonString:()=>dr,stratify:()=>du,switchMap:()=>Be,take:()=>qt,takeUntil:()=>Fs,takeWhile:()=>Vs,tap:()=>$s,tapFirst:()=>js,throttle:()=>eo,throttleTime:()=>mi,throwError:()=>Es,timeout:()=>Un,toArray:()=>Rs,toCSV:()=>Xi,toClickHouse:()=>Zi,toFile:()=>co,toHTTP:()=>vi,toKafka:()=>Vi,toLoki:()=>ra,toMongo:()=>na,toNATS:()=>Ji,toObservable:()=>Ha,toPostgres:()=>ta,toPulsar:()=>Hi,toRabbitMQ:()=>Qi,toReadableStream:()=>ki,toRedisStream:()=>Gi,toS3:()=>ea,toSSE:()=>Ti,toSSEBytes:()=>wi,toSqlite:()=>da,toTempo:()=>oa,toWebSocket:()=>Si,tokenBucket:()=>jt,topologyDiff:()=>Mt,tryIncrementBounded:()=>Ka,valve:()=>fi,verifiable:()=>ba,window:()=>ui,windowCount:()=>si,windowTime:()=>ai,withBreaker:()=>zn,withLatestFrom:()=>Hs,withMaxAttempts:()=>Pr,withStatus:()=>St,workerBridge:()=>Vo,workerSelf:()=>Fo,wrapMutation:()=>ja,zip:()=>qs});module.exports=jo(mu);ye();Ae();X();ge();fe();ye();X();fe();function Ir(n){return{describeKind:"producer",...n}}function at(n,e){return A(t=>{let r=!0,s={emit(i){r&&t.emit(i)},error(i){r&&(r=!1,t.down([[S,i]]))},complete(){r&&(r=!1,t.down([[N]]))}},o;try{let i=n(s);o=typeof i=="function"?i:void 0}catch(i){return s.error(i),()=>{r=!1}}return()=>{r=!1;try{o?.()}catch{}}},Ir(e))}function An(n,e,t){let r=!0,s,o=0,i=0,a={},u=[],d=()=>{let f=s;s=void 0;try{f?.()}catch{}};for(let f of e){let h=t?.name?`${t.name}::${f}`:f,g=t?.channelOpts?.[f],m=A(y=>(o++,()=>{i++,o>0&&i>=o&&i>=e.length&&d()}),Ir({...g,name:h}));a[f]=m,u.push(m)}let c={};for(let f of e)c[f]=h=>{r&&a[f].down([[x,h]])};c.error=f=>{r&&(r=!1,$(()=>{for(let h of u)h.down([[S,f]])}),d())},c.complete=()=>{r&&(r=!1,$(()=>{for(let f of u)f.down([[N]])}),d())};let l=n(c);return s=typeof l=="function"?l:void 0,Object.assign(a,{dispose:()=>{r&&(r=!1,$(()=>{for(let f of u)try{f.down([[N]])}catch{}}),d())}})}Ae();X();xt();ge();fe();De();function K(n){return{describeKind:"derived",...n}}function qr(n){return{describeKind:"derived",partial:!0,...n}}function Wt(n,e,t){return B([n],(r,s)=>{let o=r[0];if(o==null||o.length===0){s.down([[C]]);return}for(let i of o)s.emit(e(i))},{...K(t),meta:{...q("map"),...t?.meta??{}}})}function Ht(n,e,t){return B([n],(r,s)=>{let o=r[0];if(o==null||o.length===0){s.down([[C]]);return}let i=!1;for(let a of o)e(a)&&(s.emit(a),i=!0);i||s.down([[C]])},{...K(t),meta:{...q("filter"),...t?.meta??{}}})}function Ls(n,e,t,r){return B([n],(s,o,i)=>{"acc"in i.store||(i.store.acc=t);let a=s[0];if(a==null||a.length===0){o.down([[C]]);return}for(let u of a)i.store.acc=e(i.store.acc,u),o.emit(i.store.acc)},{...K(r),initial:t,resetOnTeardown:!0,meta:{...q("scan",{initial:t}),...r?.meta??{}}})}function Bs(n,e,t,r){return B([n],(s,o,i)=>{if("acc"in i.store||(i.store.acc=t),i.terminalDeps[0]===!0){o.emit(i.store.acc),o.down([[N]]);return}let a=s[0];if(a==null||a.length===0){o.down([[C]]);return}for(let u of a)i.store.acc=e(i.store.acc,u)},{...K(r),completeWhenDepsComplete:!1,meta:{...q("reduce",{initial:t}),...r?.meta??{}}})}function qt(n,e,t){return e<=0?B([n],(r,s,o)=>{o.store.completed||(o.store.completed=!0,s.down([[N]]))},{...K(t),completeWhenDepsComplete:!1,meta:{...q("take",{count:e}),...t?.meta??{}}}):B([n],(r,s,o)=>{if("taken"in o.store||(o.store.taken=0),o.store.done){s.down([[C]]);return}if(o.terminalDeps[0]===!0){o.store.done=!0,s.down([[N]]);return}let i=r[0];if(i==null||i.length===0){s.down([[C]]);return}for(let a of i)if(o.store.taken++,s.emit(a),o.store.taken>=e){o.store.done=!0,s.down([[N]]);return}},{...K(t),completeWhenDepsComplete:!1,meta:{...q("take",{count:e}),...t?.meta??{}}})}function Jr(n,e,t){return B([n],(r,s,o)=>{"skipped"in o.store||(o.store.skipped=0);let i=r[0];if(i==null||i.length===0){s.down([[C]]);return}let a=!1;for(let u of i)o.store.skipped++,o.store.skipped<=e||(s.emit(u),a=!0);a||s.down([[C]])},K(t))}function Vs(n,e,t){return B([n],(r,s,o)=>{if(o.store.done){s.down([[C]]);return}let i=r[0];if(i==null||i.length===0){s.down([[C]]);return}for(let a of i){if(!e(a)){o.store.done=!0,s.down([[N]]);return}s.emit(a)}},{...K(t),completeWhenDepsComplete:!1})}function Fs(n,e,t){let r=t?.predicate??(i=>i[0]===x),{predicate:s,...o}=t??{};return A(i=>{let a=!1,u=n.subscribe(c=>{if(!a)for(let l of c){if(a)return;l[0]===x?i.emit(l[1]):(l[0]===N||l[0]===S)&&(a=!0,i.down([l]))}}),d=e.subscribe(c=>{if(!a)for(let l of c){if(a)return;if(r(l)){a=!0,i.down([[N]]);return}}});return()=>{u(),d()}},K(o))}function Qn(n,e){return qt(n,1,e)}function Gs(n,e){let{defaultValue:t,...r}=e??{},s=e!=null&&Object.hasOwn(e,"defaultValue");return B([n],(o,i,a)=>{if(a.terminalDeps[0]===!0){a.store.has?i.emit(a.store.latest):s&&i.emit(t),i.down([[N]]);return}let u=o[0];if(u==null||u.length===0){i.down([[C]]);return}a.store.latest=u.at(-1),a.store.has=!0},{...K(r),completeWhenDepsComplete:!1})}function Ks(n,e,t){return qt(Ht(n,e,t),1,t)}function zs(n,e,t){return qt(Jr(n,e,t),1,t)}function $s(n,e,t){if(typeof e=="function")return B([n],(s,o)=>{let i=s[0];if(i==null||i.length===0){o.down([[C]]);return}for(let a of i)e(a),o.emit(a)},{...K(t),meta:{...q("tap"),...t?.meta??{}}});let r=e;return B([n],(s,o,i)=>{if(i.terminalDeps[0]!==void 0){i.terminalDeps[0]===!0?(r.complete?.(),o.down([[N]])):(r.error?.(i.terminalDeps[0]),o.down([[S,i.terminalDeps[0]]]));return}let a=s[0];if(a==null||a.length===0){o.down([[C]]);return}for(let u of a)r.data?.(u),o.emit(u)},{...K(t),completeWhenDepsComplete:!1,meta:{...q("tap"),...t?.meta??{}}})}function Yr(n,e,t){let r=t?.where??(o=>o!=null),s=!1;return B([n],(o,i)=>{let a=o[0];if(a==null||a.length===0){i.down([[C]]);return}for(let u of a)!s&&r(u)&&(s=!0,e(u)),i.emit(u)},K(t))}var js=Yr;function Us(n,e=Object.is,t){return B([n],(r,s,o)=>{let i=r[0];if(i==null||i.length===0){s.down([[C]]);return}let a=!1;for(let u of i)o.store.hasPrev&&e(o.store.prev,u)||(o.store.prev=u,o.store.hasPrev=!0,s.emit(u),a=!0);a||s.down([[C]])},{...K(t),meta:{...q("distinctUntilChanged"),...t?.meta??{}}})}function Ws(n,e){return B([n],(t,r,s)=>{let o=t[0];if(o==null||o.length===0){r.down([[C]]);return}let i=!1;for(let a of o)if(!s.store.hasPrev)s.store.prev=a,s.store.hasPrev=!0;else{let u=[s.store.prev,a];s.store.prev=a,r.emit(u),i=!0}i||r.down([[C]])},K(e))}function Qr(...n){let e=[...n];return be(e,t=>t,{...K(),equals:(t,r)=>{if(t.length!==r.length)return!1;for(let s=0;s<t.length;s++)if(!Object.is(t[s],r[s]))return!1;return!0}})}function Hs(n,e,t){return B([n,e],(r,s,o)=>{let i=r[0],a=r[1],u=a!=null&&a.length>0?a.at(-1):o.prevData[1];if(i!=null&&i.length>0){if(!(a!=null&&a.length>0)&&o.prevData[1]===void 0){s.down([[C]]);return}for(let d of i)s.emit([d,u])}else s.down([[C]])},{...qr(t),meta:{...q("withLatestFrom"),...t?.meta??{}}})}function Et(...n){return n.length===0?A(e=>{e.down([[N]])},{...K(),meta:{...q("merge")}}):A(e=>{let t=n.length,r=0,s=[];for(let o of n){let i=o.subscribe(a=>{for(let u of a)u[0]===x?e.emit(u[1]):u[0]===N?(r+=1,r>=t&&e.down([[N]])):u[0]===S&&e.down([u])});s.push(i)}return()=>{for(let o of s)o()}},{...K(),meta:{...q("merge")}})}function qs(...n){let e=n.length;return e===0?A(t=>{t.emit([]),t.down([[N]])},K()):A(t=>{let r=Array.from({length:e},()=>[]),s=e;function o(){for(;r.every(a=>a.length>0);){let a=r.map(u=>u.shift());t.emit(a)}}let i=[];for(let a=0;a<e;a++){let u=a,d=n[a].subscribe(c=>{for(let l of c)l[0]===x?(r[u].push(l[1]),o()):l[0]===N?(s-=1,(s===0||r[u].length===0)&&t.down([[N]])):l[0]===S&&t.down([l])});i.push(d)}return()=>{for(let a of i)a()}},K())}function Js(n,e,t){return A(r=>{let s=0,o=[],i,a;return a=e.subscribe(u=>{for(let d of u)s===0?d[0]===x?o.push(d[1]):d[0]===S&&r.down([d]):d[0]===x?r.emit(d[1]):(d[0]===N||d[0]===S)&&r.down([d])}),i=n.subscribe(u=>{for(let d of u)if(s===0)if(d[0]===x)r.emit(d[1]);else if(d[0]===N){s=1;for(let c of o)r.emit(c);o.length=0}else d[0]===S&&r.down([d])}),()=>{i?.(),a?.()}},K(t))}function Ys(...n){return n.length===0?A(e=>{e.down([[N]])},K()):n.length===1?B([n[0]],(e,t)=>{let r=e[0];if(r==null||r.length===0){t.down([[C]]);return}for(let s of r)t.emit(s)},K()):A(e=>{let t=null,r=[];for(let s=0;s<n.length;s++){let o=s,i=n[s].subscribe(a=>{for(let u of a){if(t!==null&&o!==t)return;u[0]===x?(t===null&&(t=o),e.emit(u[1])):(u[0]===N||u[0]===S)&&(t===null||o===t)&&e.down([u])}});r.push(i)}return()=>{for(let s of r)s()}},K())}function Jt(n,e,t){let r,s=!1,o=()=>{s||(s=!0,t())};return r=n.subscribe(i=>{let a=!1,u=!1;for(let d of i)d[0]!==Ie&&(d[0]===x?e.emit(d[1]):d[0]===N?a=!0:d[0]===S?(u=!0,e.down([d])):(d[0]===V||d[0]===C)&&e.down([d]));u?(r?.(),r=void 0,o()):a&&o()}),()=>{r?.(),r=void 0}}function Be(n,e,t){let r,s=!1;function o(){r?.(),r=void 0}return B([n],(i,a,u)=>{if(u.terminalDeps[0]!=null&&u.terminalDeps[0]!==!0){o();return}if(u.terminalDeps[0]===!0){s=!0,r||a.down([[N]]);return}let d=i[0];if(!(d==null||d.length===0))return o(),r=Jt(ie(e(d[d.length-1])),a,()=>{o(),s&&a.down([[N]])}),{deactivate:()=>{o(),s=!1}}},{...K(t),completeWhenDepsComplete:!1,meta:{...q("switchMap"),...t?.meta??{}}})}function Qs(n,e,t){let r,s=!1;function o(){r?.(),r=void 0}return B([n],(i,a,u)=>{if(u.terminalDeps[0]!=null&&u.terminalDeps[0]!==!0){o();return}if(u.terminalDeps[0]===!0){s=!0,r||a.down([[N]]);return}let d=i[0];if(!(d==null||d.length===0))return r===void 0?r=Jt(ie(e(d[0])),a,()=>{o(),s&&a.down([[N]])}):a.down([[C]]),{deactivate:()=>{o(),s=!1}}},{...K(t),completeWhenDepsComplete:!1})}function Xs(n,e,t){let{maxBuffer:r,...s}=t??{},o=[],i,a=!1,u;function d(){i?.(),i=void 0}function c(){if(!u||i!==void 0)return;if(o.length===0){a&&u.down([[N]]);return}let p=o.shift();i=Jt(ie(e(p)),u,()=>{d(),c()})}function l(p){r&&r>0&&o.length>=r&&o.shift(),o.push(p),c()}return B([n],(p,f,h)=>{if(u=f,h.terminalDeps[0]!=null&&h.terminalDeps[0]!==!0){d(),o.length=0;return}if(h.terminalDeps[0]===!0){a=!0,c();return}let g=p[0];if(!(g==null||g.length===0)){for(let m of g)l(m);return{deactivate:()=>{d(),o.length=0,a=!1}}}},{...K(s),completeWhenDepsComplete:!1})}function Xr(n,e,t){let{concurrent:r,...s}=t??{},o=r!=null&&r>0?r:Number.POSITIVE_INFINITY,i=0,a=!1,u=new Set,d=[],c;function l(){a&&i===0&&d.length===0&&c&&c.down([[N]])}function p(m){if(!c)return;i++;let y;y=Jt(ie(e(m)),c,()=>{y&&u.delete(y),i--,f(),l()}),u.add(y)}function f(){for(;d.length>0&&i<o;)p(d.shift())}function h(m){i<o?p(m):d.push(m)}function g(){for(let m of u)m();u.clear(),i=0,d.length=0}return B([n],(m,y,b)=>{if(c=y,b.terminalDeps[0]!=null&&b.terminalDeps[0]!==!0){g();return}if(b.terminalDeps[0]===!0){a=!0,l();return}let v=m[0];if(!(v==null||v.length===0)){for(let T of v)h(T);return{deactivate:()=>{g(),a=!1}}}},{...K(s),completeWhenDepsComplete:!1})}var Zs=Xr;function ei(n,e,t){return A(r=>{let s=new Set;function o(){for(let a of s)clearTimeout(a);s.clear()}let i=n.subscribe(a=>{for(let u of a)if(u[0]===x){let d=setTimeout(()=>{s.delete(d),r.emit(u[1])},e);s.add(d)}else if(u[0]===N){let d=setTimeout(()=>{s.delete(d),r.down([[N]])},e);s.add(d)}else u[0]===S&&(o(),r.down([u]))});return()=>{i(),o()}},K(t))}function Zr(n,e,t){return A(r=>{let s,o;function i(){s!==void 0&&(clearTimeout(s),s=void 0)}let a=n.subscribe(u=>{for(let d of u)d[0]===x?(i(),o=d[1],s=setTimeout(()=>{s=void 0,r.emit(o)},e)):d[0]===N?(s!==void 0&&(i(),r.emit(o)),r.down([[N]])):d[0]===S&&(i(),r.down([d]))});return()=>{a(),i()}},{...K(t),meta:{...q("debounce",{ms:e}),...t?.meta??{}}})}function eo(n,e,t){let{leading:r,trailing:s,...o}=t??{},i=r!==!1,a=s===!0,u=e*1e6;return A(d=>{let c,l=-1/0,p,f=!1;function h(){c!==void 0&&(clearTimeout(c),c=void 0)}let g=n.subscribe(m=>{for(let y of m)if(y[0]===x){let b=y[1],v=re();if(i&&v-l>=u)l=v,d.emit(b),h(),a&&(c=setTimeout(()=>{c=void 0,f&&(l=re(),d.emit(p),f=!1)},e));else if(a&&(p=b,f=!0,c===void 0)){let T=(v-l)/1e6;c=setTimeout(()=>{c=void 0,f&&(l=re(),d.emit(p),f=!1)},Math.max(0,e-T))}}else(y[0]===N||y[0]===S)&&(h(),d.down([y]))});return()=>{g(),h()}},{...K(o),meta:{...q("throttle",{ms:e,leading:i,trailing:a}),...o.meta??{}}})}function ti(n,e,t){return A(r=>{let s,o=!1,i=!1,a=n.subscribe(d=>{if(!o)for(let c of d){if(o)return;c[0]===x?s={v:c[1]}:c[0]===S?(o=!0,r.down([c])):c[0]===N&&(i=!0,s=void 0)}}),u=e.subscribe(d=>{if(!o)for(let c of d){if(o)return;c[0]===x?s!==void 0&&!i&&r.emit(s.v):c[0]===S?(o=!0,r.down([c])):c[0]===N&&(o=!0,r.down([[N]]))}});return()=>{a(),u()}},K(t))}function ni(n,e,t){return A(r=>{let s,o,i=!1;function a(){s!==void 0&&(clearTimeout(s),s=void 0)}let u=n.subscribe(d=>{for(let c of d)c[0]===x?(o=c[1],i=!0,a(),s=setTimeout(()=>{s=void 0,i&&(i=!1,r.emit(o))},e)):(c[0]===N||c[0]===S)&&(a(),r.down([c]))});return()=>{u(),a()}},K(t))}function ri(n,e,t){return A(r=>{let s=[],o=n.subscribe(a=>{for(let u of a)u[0]===x?s.push(u[1]):u[0]===N?(s.length>0&&r.emit([...s]),s.length=0,r.down([[N]])):u[0]===S&&r.down([u])}),i=e.subscribe(a=>{for(let u of a)u[0]===x?s.length>0&&(r.emit([...s]),s.length=0):u[0]===N?r.down([[N]]):u[0]===S&&r.down([u])});return()=>{o(),i(),s.length=0}},K(t))}function oi(n,e,t){if(e<=0)throw new RangeError("bufferCount expects count > 0");return A(r=>{let s=[],o=n.subscribe(i=>{for(let a of i)a[0]===x?(s.push(a[1]),s.length>=e&&r.emit(s.splice(0,s.length))):a[0]===N?(s.length>0&&r.emit([...s]),s.length=0,r.down([[N]])):a[0]===S&&r.down([a])});return()=>{o(),s.length=0}},K(t))}function si(n,e,t){if(e<=0)throw new RangeError("windowCount expects count > 0");return A(r=>{let s,o=0;function i(){let u=A(d=>(s=d.down.bind(d),()=>{s=void 0}),K());o=0,r.emit(u)}let a=n.subscribe(u=>{for(let d of u)d[0]===x?(s||i(),s?.([[x,d[1]]]),o+=1,o>=e&&(s?.([[N]]),s=void 0)):d[0]===N?(s?.([[N]]),s=void 0,r.down([[N]])):d[0]===S&&(s?.([d]),s=void 0,r.down([d]))});return()=>{a(),s?.([[N]]),s=void 0}},K(t))}function ii(n,e,t){return A(r=>{let s=[],o=setInterval(()=>{s.length>0&&(r.emit([...s]),s.length=0)},e),i=n.subscribe(a=>{for(let u of a)u[0]===x?s.push(u[1]):u[0]===N?(clearInterval(o),s.length>0&&r.emit([...s]),s.length=0,r.down([[N]])):u[0]===S&&(clearInterval(o),r.down([u]))});return()=>{i(),clearInterval(o),s.length=0}},{...K(t),meta:{...q("bufferTime",{ms:e}),...t?.meta??{}}})}function ai(n,e,t){return A(r=>{let s;function o(){s?.([[N]]),s=void 0}function i(){let d=A(c=>(s=c.down.bind(c),()=>{s=void 0}),K());r.emit(d)}i();let a=setInterval(()=>{o(),i()},e),u=n.subscribe(d=>{for(let c of d)c[0]===x?s?.([[x,c[1]]]):c[0]===N?(clearInterval(a),o(),r.down([[N]])):c[0]===S&&(clearInterval(a),s?.([c]),o(),r.down([c]))});return()=>{u(),clearInterval(a),o()}},K(t))}function ui(n,e,t){return A(r=>{let s;function o(){s?.([[N]]),s=void 0}function i(){let d=A(c=>(s=c.down.bind(c),()=>{s=void 0}),K());r.emit(d)}let a=n.subscribe(d=>{for(let c of d)c[0]===x?(s||i(),s?.([[x,c[1]]])):c[0]===N?(o(),r.down([[N]])):c[0]===S&&(s?.([c]),s=void 0,r.down([c]))}),u=e.subscribe(d=>{for(let c of d)c[0]===x&&(o(),i())});return()=>{a(),u(),o()}},K(t))}function di(n,e){return A((t,r)=>{"n"in r.store||(r.store.n=0);let s=setInterval(()=>{t.emit(r.store.n),r.store.n=r.store.n+1},n);return()=>clearInterval(s)},K(e))}function ci(n,e,t){if(e<=0)throw new RangeError("repeat expects count > 0");return A(r=>{let s=e,o,i=()=>{o?.(),o=n.subscribe(a=>{let u=!1,d=[];for(let c of a)c[0]===N?u=!0:d.push(c);d.length>0&&r.down(d),u&&(o?.(),o=void 0,s-=1,s>0?i():r.down([[N]]))})};return i(),()=>{o?.()}},K(t))}function li(n,e){return B([n],(t,r)=>{let s=t[0];if(s==null||s.length===0){r.down([[C]]);return}for(let o of s)r.emit(o)},K(e))}function to(n,e,t){return A(r=>{let s=n.subscribe(o=>{for(let i of o)if(i[0]===x)r.emit(i[1]);else if(i[0]===S)try{r.emit(e(i[1]))}catch(a){r.down([[S,a]])}else i[0]===N&&r.down([[N]])});return()=>{s()}},K(t))}function fi(n,e,t){return B([n,e],(r,s,o)=>{let i=r[1];if(!(i!=null&&i.length>0?i.at(-1):o.prevData[1])){s.down([[C]]);return}let u=r[0];if(u!=null&&u.length>0){for(let d of u)s.emit(d);return}if(i!=null&&i.length>0&&o.prevData[0]!==void 0){s.emit(o.prevData[0]);return}s.down([[C]])},qr(t))}var pi=Qr,hi=Zr,mi=eo,gi=to;X();ge();fe();kt();$t();var Xn=class{ring;arr;constructor(e){e===Number.POSITIVE_INFINITY||e<=0?(this.arr=[],this.ring=null):(this.ring=new Le(e),this.arr=null)}get length(){return this.ring!=null?this.ring.size:this.arr.length}push(e){this.ring!=null?this.ring.push(e):this.arr.push(e)}shift(){return this.ring!=null?this.ring.shift():this.arr.shift()}drain(){if(this.ring!=null){let t=this.ring.toArray();return this.ring.clear(),t}let e=this.arr;return this.arr=[],e}};function Ot(n){return n instanceof Error?n:new Error(String(n))}function bi(n){return n===void 0?null:typeof n=="string"?it(n):n}function ae(n,e){let{name:t,onTransportError:r,retry:s,backpressure:o,batchSize:i=Number.POSITIVE_INFINITY,flushIntervalMs:a=0,serialize:u,stopOn:d,onUpstreamMessage:c,onDispose:l,send:p,sendBatch:f,ctx:h}=e;if(!p&&!f)throw new Error("reactiveSink: `send` or `sendBatch` must be provided");let g=h,m=Math.max(1,s?.maxAttempts??1),y=bi(s?.backoff??(m>1?"exponential":void 0)),b=s?.shouldRetry??(()=>!0),v=f!==void 0||i<Number.POSITIVE_INFINITY||a>0,T=D=>t?`${t}::${D}`:void 0,k=F(void 0,{equals:()=>!1,name:T("sent")}),_=F(null,{name:T("failed")}),w=F(0,{name:T("inFlight")}),E=F(null,{name:T("errors")}),R=v?F(0,{name:T("buffered")}):void 0,M=o?F(!1,{name:T("paused")}):void 0,O=0,G=D=>{O+=D,w.down([[x,O]])},P=D=>{try{r?.(D)}catch{}try{E.down([[x,D]])}catch{}},L=new Set,ue=D=>{L.add(D);let W=()=>L.delete(D);D.then(W,W)},U=(D,W,J)=>{let Z=y?y(W-1,J,null):0,ce=Z==null?0:typeof Z=="number"&&Z>0?Z:0,Oe=Math.max(1,Math.ceil(ce/1e6));return new Promise(Y=>{setTimeout(()=>Y(D()),Oe)})},de=D=>D!=null&&typeof D=="object"&&typeof D.then=="function",_e=D=>{let W;try{W=u?u(D):D}catch(Y){let H=Ot(Y);return P({stage:"serialize",error:H,value:D}),_.down([[x,{value:D,error:H,attempts:0}]]),Promise.resolve()}let J=0,Z=Y=>{G(-1);let H=Ot(Y);if(P({stage:"send",error:H,value:D,attempt:J}),!(J<m&&b(H,J))){_.down([[x,{value:D,error:H,attempts:J}]]);return}return U(Oe,J,H)},ce=()=>{G(-1),k.down([[x,D]])};function Oe(){J+=1,G(1);let Y;try{Y=p(W,g)}catch(H){return Z(H)??Promise.resolve()}return de(Y)?Y.then(ce,H=>Z(H)):(ce(),Promise.resolve())}return Oe()},Ve=o?.maxBuffer??Number.POSITIVE_INFINITY,Se=new Xn(Ve),xe,Fe=!1,Ge=()=>{R?.down([[x,Se.length]])},ze=D=>{M&&M.down([[x,D]])},I=o?.strategy??"drop-oldest",Q=(D,W)=>{let J={value:D,payload:W};if(Se.length<Ve)return Se.push(J),Ge(),!0;if(I==="drop-oldest"){let ce=Se.shift();return Se.push(J),Ge(),ze(!0),_.down([[x,{value:ce.value,error:new Error("backpressure: buffer overflow \u2014 dropped oldest"),attempts:0}]]),!0}if(I==="drop-newest")return ze(!0),_.down([[x,{value:D,error:new Error("backpressure: buffer overflow \u2014 dropped newest"),attempts:0}]]),!1;let Z=new Error("backpressure: buffer overflow");return P({stage:"send",error:Z,value:D}),_.down([[x,{value:D,error:Z,attempts:0}]]),ze(!0),!1},Te=D=>{let W=0,J=D.map(Y=>Y.payload),Z=Y=>{G(-1);let H=Ot(Y);if(P({stage:"send",error:H,value:D.map(cn=>cn.value),attempt:W}),!(W<m&&b(H,W))){for(let{value:cn}of D)_.down([[x,{value:cn,error:H,attempts:W}]]);return}return U(Oe,W,H)},ce=()=>{G(-1);for(let{value:Y}of D)k.down([[x,Y]])};function Oe(){W+=1,G(1);let Y;try{Y=f(J,g)}catch(H){return Z(H)??Promise.resolve()}return de(Y)?Y.then(ce,H=>Z(H)):(ce(),Promise.resolve())}return Oe()},$e=async D=>{for(let W of D)await we(W.value,W.payload)},we=(D,W)=>{let J=0,Z=Y=>{G(-1);let H=Ot(Y);if(P({stage:"send",error:H,value:D,attempt:J}),!(J<m&&b(H,J))){_.down([[x,{value:D,error:H,attempts:J}]]);return}return U(Oe,J,H)},ce=()=>{G(-1),k.down([[x,D]])};function Oe(){J+=1,G(1);let Y;try{Y=p(W,g)}catch(H){return Z(H)??Promise.resolve()}return de(Y)?Y.then(ce,H=>Z(H)):(ce(),Promise.resolve())}return Oe()},j=()=>{if(Fe||Se.length===0)return Promise.resolve();let D=Se.drain();if(Ge(),ze(!1),f!==void 0){let J=Te(D);return ue(J),J}let W=$e(D);return ue(W),W},he=()=>{xe!==void 0||Fe||a<=0||(xe=setTimeout(()=>{xe=void 0,j()},a))},yt=n.subscribe(D=>{for(let W of D){let J=W[0];if(J!==x)try{c?.(W)}catch{}if(J===x){let Z=W[1];if(v){let ce;if(u)try{ce=u(Z)}catch(Y){let H=Ot(Y);P({stage:"serialize",error:H,value:Z}),_.down([[x,{value:Z,error:H,attempts:0}]]);continue}else ce=Z;if(!Q(Z,ce))continue;Se.length>=i?j():he()}else{let ce=_e(Z);ue(ce)}}else me.messageTier(J)>=3&&v&&(xe!==void 0&&(clearTimeout(xe),xe=void 0),j())}}),fr;if(d){let D=!1;fr=d.subscribe(W=>{if(!D){D=!0;return}W.length>0&&!dn&&pr()})}let dn=!1,pr=()=>{if(dn)return;dn=!0,xe!==void 0&&(clearTimeout(xe),xe=void 0),v&&j(),Fe=!0,fr?.(),yt();let D=W=>{try{W.down([[z]])}catch{}};D(E),D(_),D(k),D(w),R&&D(R),M&&D(M);try{l?.()}catch{}},Dt={dispose:pr,sent:k,failed:_,inFlight:w,errors:E};return v&&(Dt.buffered=R,Dt.flush=async()=>{Fe||(await j(),await Promise.all(L))}),M&&(Dt.paused=M),Dt}Ut();De();function Re(n){return{describeKind:"producer",...n}}function no(n,e){let{parse:t,closeOnTeardown:r=!1,...s}=e??{};return A(o=>{let i=!0,a,u=()=>{let y=a;a=void 0,y?.()},d=y=>{i&&(i=!1,o.down([y]),u())},c=(y,b=y)=>{if(i)try{let v=y!==null&&typeof y=="object"&&"data"in y?y.data:y,T=t?t(v,b):v;o.emit(T)}catch(v){d([S,v])}},l=y=>{d([S,y])},p=()=>{d([N])};if(typeof n=="function"){try{if(a=n(c,l,p),typeof a!="function")throw new Error("fromWebSocket register contract violation: register must return cleanup callable")}catch(y){d([S,y])}return()=>{i=!1,u()}}let f=n,h=y=>c(y,y),g=y=>l(y),m=()=>p();return f.addEventListener("message",h),f.addEventListener("error",g),f.addEventListener("close",m),a=()=>{f.removeEventListener("message",h),f.removeEventListener("error",g),f.removeEventListener("close",m),r&&f.close()},()=>{i=!1,u()}},Re(s))}function yi(n,e){return at(n,e)}function ro(n,e){let{method:t="GET",headers:r,body:s,transform:o=v=>v.json(),timeoutNs:i=30*1e9,signal:a,completeAfterFetch:u=!1,refetchOnSubscribe:d=!1,...c}=e??{},l=F(0,{name:`${c.name??"http"}/fetchCount`}),p=F(0,{name:`${c.name??"http"}/lastUpdated`}),f=F(!1,{name:`${c.name??"http"}/fetched`}),h=0,g=s!==void 0?typeof s=="string"?s:JSON.stringify(s):void 0,m=v=>{let T=new AbortController,k=!0;if(a?.aborted)return k=!1,v.down([[S,a.reason??new Error("Aborted")]]),()=>{};a?.addEventListener("abort",()=>T.abort(a.reason),{once:!0});let _=setTimeout(()=>T.abort(new Error("Request timeout")),Math.ceil(i/1e6));return fetch(n,{method:t,headers:r,body:g,signal:T.signal}).then(async w=>{if(clearTimeout(_),!k)return;if(!w.ok)throw new Error(`HTTP ${w.status}: ${w.statusText}`);let E=await o(w);k&&($(()=>{h+=1,l.down([[x,h]]),p.down([[x,te()]]),f.down([[x,!0]]),v.emit(E)}),u&&v.down([[N]]))}).catch(w=>{clearTimeout(_),k&&(w&&w.name==="AbortError"||v.down([[S,w]]))}),()=>{k=!1,T.abort()}},y=A(v=>m({emit:T=>v.emit(T),down:T=>v.down(T)}),{...Re(c),resubscribable:d});return{...St(y),fetchCount:l,lastUpdated:p,fetched:f}}function vi(n,e,t){let{method:r="POST",headers:s={"Content-Type":"application/json"},serialize:o=h=>JSON.stringify(h),timeoutNs:i,batchFormat:a="json-array",batchSize:u,flushIntervalMs:d,retry:c,onTransportError:l}=t??{},p=async h=>{let g=i!==void 0?new AbortController:void 0,m;g&&i!==void 0&&(m=setTimeout(()=>g.abort(new Error("Request timeout")),Math.ceil(i/1e6)));try{let y=await fetch(e,{method:r,headers:s,body:h,signal:g?.signal}),b=async()=>{try{await y.arrayBuffer?.()}catch{}};if(!y.ok)throw await b(),new Error(`HTTP ${y.status}: ${y.statusText}`);await b()}finally{m!==void 0&&clearTimeout(m)}};return u!==void 0||d!==void 0?ae(n,{onTransportError:l,retry:c,batchSize:u,flushIntervalMs:d,sendBatch:async h=>{let g;a==="ndjson"?g=h.map(m=>{let y=o(m);return typeof y=="string"?y:new TextDecoder().decode(y)}).join(`
2
- `):g=JSON.stringify(h),await p(g)}}):ae(n,{onTransportError:l,retry:c,serialize:o,send:async h=>{await p(h)}})}function oo(n){return Symbol.keyFor(n)??n.description??"message"}function lt(n,e){return typeof n=="string"?n:e(n)}function so(n,e){let t=`event: ${n}
3
- `;if(e!==void 0){let r=e.split(/\r?\n/);for(let s of r)t+=`data: ${s}
1
+ "use strict";var fn=Object.defineProperty;var zo=Object.getOwnPropertyDescriptor;var Ko=Object.getOwnPropertyNames;var $o=Object.prototype.hasOwnProperty;var ne=(n,e)=>()=>(n&&(e=n(n=0)),e);var pn=(n,e)=>{for(var t in e)fn(n,t,{get:e[t],enumerable:!0})},jo=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ko(e))!$o.call(n,o)&&o!==t&&fn(n,o,{get:()=>e[o],enumerable:!(r=zo(e,o))||r.enumerable});return n};var Uo=n=>jo(fn({},"__esModule",{value:!0}),n);function It(){return tt>0||vt}function gr(){return tt>0}function rt(n){tt>0?Tt.push(n):n()}function $(n){tt+=1;let e=!1;try{n()}catch(t){throw e=!0,t}finally{if(tt-=1,tt===0)if(e){if(!vt){let t=Tt.splice(0);for(let r of t)try{r()}catch{}je.length=0,Ue.length=0,nt.length=0}}else Wo()}}function Wo(){let n=!vt;n&&(vt=!0);let e=[],t=0;try{for(;je.length>0||Ue.length>0||nt.length>0||n&&Tt.length>0;){if(n&&Tt.length>0){let s=Tt.splice(0);for(let i of s)try{i()}catch(a){e.push(a)}continue}if(t+=1,t>1e3)throw je.length=0,Ue.length=0,nt.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let o=(je.length>0?je:Ue.length>0?Ue:nt).splice(0);for(let s of o)try{s()}catch(i){e.push(i)}}}finally{n&&(vt=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function Lt(n,e,t){if(e.length===0)return;if(e.length===1){let d=t(e[0][0]);if(d<3||!It()){n(e);return}(d>=5?nt:d===4?Ue:je).push(()=>n(e));return}let r=e.length,o=r,s=r,i=r,a=0;for(;a<r&&t(e[a][0])<3;)a++;for(o=a;a<r&&t(e[a][0])===3;)a++;for(s=a;a<r&&t(e[a][0])===4;)a++;i=a;let u=It();if(o>0){let d=e.slice(0,o);n(d)}if(s>o){let d=e.slice(o,s);u?je.push(()=>n(d)):n(d)}if(i>s){let d=e.slice(s,i);u?Ue.push(()=>n(d)):n(d)}if(r>i){let d=e.slice(i,r);u?nt.push(()=>n(d)):n(d)}}var tt,vt,je,Ue,nt,Tt,ye=ne(()=>{"use strict";tt=0,vt=!1,je=[],Ue=[],nt=[],Tt=[]});function re(){return Math.trunc(performance.now()*1e6)}function te(){return Date.now()*1e6}var Ae=ne(()=>{"use strict"});var Ie,x,V,C,ke,le,pe,K,N,S,ot,hn,Ho,mn,qo,Jo,gn,br,yr,vr,bn,X=ne(()=>{"use strict";Ie=Symbol.for("graphrefly/START"),x=Symbol.for("graphrefly/DATA"),V=Symbol.for("graphrefly/DIRTY"),C=Symbol.for("graphrefly/RESOLVED"),ke=Symbol.for("graphrefly/INVALIDATE"),le=Symbol.for("graphrefly/PAUSE"),pe=Symbol.for("graphrefly/RESUME"),K=Symbol.for("graphrefly/TEARDOWN"),N=Symbol.for("graphrefly/COMPLETE"),S=Symbol.for("graphrefly/ERROR"),ot=Object.freeze([V]),hn=Object.freeze([C]),Ho=Object.freeze([ke]),mn=Object.freeze([Ie]),qo=Object.freeze([N]),Jo=Object.freeze([K]),gn=Object.freeze([ot]),br=Object.freeze([hn]),yr=Object.freeze([Ho]),vr=Object.freeze([qo]),bn=Object.freeze([Jo])});function wr(n,e){let t=new TextEncoder().encode(n.name);if(t.length===0||t.length>255)throw new Error(`encodeEnvelope: codec name "${n.name}" encodes to ${t.length} bytes (must be 1\u2013255)`);let r=n.version;if(!Number.isInteger(r)||r<0||r>65535)throw new Error(`encodeEnvelope: codec.version ${r} out of u16 range (expected integer 0\u201365535)`);let o=2+t.length+2+e.length;if(o>4294967295)throw new Error(`encodeEnvelope: total envelope size ${o} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let s=new Uint8Array(o),i=0;return s[i++]=yn,s[i++]=t.length,s.set(t,i),i+=t.length,s[i++]=r>>>8&255,s[i++]=r&255,s.set(e,i),s}function kr(n,e){if(n.length<Tr)throw new Error(`decodeEnvelope: bytes too short (${n.length} < ${Tr})`);let t=0,r=n[t++];if(r!==yn)throw new Error(`decodeEnvelope: unsupported envelope version ${r} (expected ${yn})`);let o=n[t++];if(o===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(t+o+2>n.length)throw new Error(`decodeEnvelope: envelope truncated (need ${t+o+2} bytes, have ${n.length})`);let s=new TextDecoder().decode(n.subarray(t,t+o));t+=o;let i=(n[t]<<8|n[t+1])>>>0;t+=2;let a=n.subarray(t),u=e.lookupCodec(s);if(u==null)throw new Error(`decodeEnvelope: codec "${s}" not registered (envelope codec_v=${i})`);return{codec:u,codecVersion:i,payload:a}}function xr(n){n.registerCodec(Yo)}var Yo,yn,Tr,vn=ne(()=>{"use strict";Yo={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)}},yn=1,Tr=4});function Bt(n){if(n==null)return st;let{type:e,id:t,...r}=n;return{type:e??"system",id:t??"",...r}}var st,Tn=ne(()=>{"use strict";st={type:"system",id:""}});function Nr(n){n.registerMessageType(Ie,{tier:0,wireCrossing:!1}),n.registerMessageType(V,{tier:1,wireCrossing:!1}),n.registerMessageType(ke,{tier:1,wireCrossing:!1,metaPassthrough:!1}),n.registerMessageType(le,{tier:2,wireCrossing:!1}),n.registerMessageType(pe,{tier:2,wireCrossing:!1}),n.registerMessageType(x,{tier:3,wireCrossing:!0}),n.registerMessageType(C,{tier:3,wireCrossing:!0}),n.registerMessageType(N,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(S,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(K,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var Vt,_r=ne(()=>{"use strict";X();Vt=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_rigorRecorder;_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}get rigorRecorder(){return this._rigorRecorder}set rigorRecorder(e){this._rigorRecorder=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.")}}});function Sr(n){return Array.isArray(n)?[...n]:[n]}function Qo(n,e){return n.has(e)||n.has("*")}function Er(n){let e=[];return n((o,s)=>{e.push({kind:"allow",actions:new Set(Sr(o)),where:s?.where??(()=>!0)})},(o,s)=>{e.push({kind:"deny",actions:new Set(Sr(o)),where:s?.where??(()=>!0)})}),(o,s)=>{let i=!1,a=!1;for(let u of e)Qo(u.actions,s)&&u.where(o)&&(u.kind==="deny"?i=!0:a=!0);return i?!1:a}}function wn(n){let e=Xo.filter(t=>n({type:t,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(t=>t==="human"||t==="llm"||t==="system")?"both":e.length===1?e[0]:e.join("+")}var Ee,Xo,wt=ne(()=>{"use strict";Ee=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}};Xo=["human","llm","wallet","system"]});function kn(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(kn);if(typeof n=="object"&&n!==null){let e={};for(let t of Object.keys(n).sort())e[t]=kn(n[t]);return e}return null}function ts(n){let e=es.encode(n),t=e.length,r=t*8,o=t+9+63&-64,s=new Uint8Array(o);s.set(e),s[t]=128;let i=new DataView(s.buffer);i.setUint32(o-4,r>>>0,!1),i.setUint32(o-8,Math.floor(r/4294967296)>>>0,!1);let a=1779033703,u=3144134277,d=1013904242,c=2773480762,l=1359893119,f=2600822924,p=528734635,h=1541459225,g=new Uint32Array(64),m=(b,v)=>b>>>v|b<<32-v;for(let b=0;b<o;b+=64){for(let M=0;M<16;M++)g[M]=i.getUint32(b+M*4,!1);for(let M=16;M<64;M++){let G=g[M-15],P=g[M-2],L=m(G,7)^m(G,18)^G>>>3,ue=m(P,17)^m(P,19)^P>>>10;g[M]=g[M-16]+L+g[M-7]+ue>>>0}let v=a,T=u,w=d,_=c,k=l,E=f,O=p,R=h;for(let M=0;M<64;M++){let G=m(k,6)^m(k,11)^m(k,25),P=k&E^~k&O,L=R+G+P+Zo[M]+g[M]>>>0,ue=m(v,2)^m(v,13)^m(v,22),U=v&T^v&w^T&w,de=ue+U>>>0;R=O,O=E,E=k,k=_+L>>>0,_=w,w=T,T=v,v=L+de>>>0}a=a+v>>>0,u=u+T>>>0,d=d+w>>>0,c=c+_>>>0,l=l+k>>>0,f=f+E>>>0,p=p+O>>>0,h=h+R>>>0}let y=b=>b.toString(16).padStart(8,"0");return y(a)+y(u)+y(d)+y(c)+y(l)+y(f)+y(p)+y(h)}function xn(n){let e=kn(n??null),t=JSON.stringify(e);return ts(t).slice(0,16)}function ns(){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 Nn(n,e,t){let r=t?.id??ns();if(n===0)return{id:r,version:0};let s=(t?.hash??xn)(e);return{id:r,version:0,cid:s,prev:null}}function Or(n,e,t){n.version+=1,"cid"in n&&(n.prev=n.cid,n.cid=t(e))}var Zo,es,Rr=ne(()=>{"use strict";Zo=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]),es=new TextEncoder});function Cr(n){return{node:n,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function _n(n){n.prevData=void 0,n.dirty=!1,n.involvedThisWave=!1,n.dataBatch.length=0,n.terminal=void 0}function Ft(n){return n.length===0?n:typeof n[0]=="symbol"?[n]:n}function B(n,e,t){let r=Pr(n)?n:[],o=typeof n=="function"?n:typeof e=="function"?e:void 0,s={};return Pr(n)?s=(Sn(e)?e:t)??{}:Sn(n)?s=n:s=(Sn(e)?e:t)??{},new oe(r,o,s)}var Mr,Ar,rs,os,me,oe,Pr,Sn,ge=ne(()=>{"use strict";vn();Tn();ye();Ae();_r();wt();X();Rr();Mr=()=>{},Ar=100;rs=(n,e,t,r)=>{t.direction==="down-in"&&n._onDepMessage(t.depIndex,e)},os=(n,e,t,r)=>{let o=n;if(o._status==="completed"||o._status==="errored")return;let s=o._cached,i=s===void 0?[mn]:[mn,[x,s]];o._status==="dirty"&&i.push(ot),Lt(e,i,o._config.tierOf)},me=new Vt({onMessage:rs,onSubscribe:os});Nr(me);xr(me);oe=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??me,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??xn;let o=r.versioning??this._config.defaultVersioning;this._versioningLevel=o,this._versioning=o!=null?Nn(o,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Cr);let s={};for(let[a,u]of Object.entries(r.meta??{})){let d={initial:u,name:`${r.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};r.guard!=null&&(d.guard=r.guard),s[a]=new n([],void 0,d)}Object.freeze(s),this.meta=s,this._hasMeta=Object.keys(s).length>0;let i=this;this._actions={emit(a){i._emit([[x,a]])},down(a){i._emit(Ft(a))},up(a){i._emitUp(Ft(a))}},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 s=this._cached===void 0?void 0:this._cached,i=this._versioning,a=i?.id??t?.id,u=i?.version??0,d=Nn(e,s,{id:a,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=Bt(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=Bt(e?.actor),s=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(o,s))throw new Ee({actor:o,action:s,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(o,s))throw new Ee({actor:o,action:s,nodeName:this.name})}this._lastMutation={actor:o,timestamp_ns:te()}}down(e,t){let r=Ft(e);r.length!==0&&(this._checkGuard(t),this._emit(r))}emit(e,t){this._checkGuard(t),this._emit([[x,e]])}up(e,t){if(this._deps.length===0)return;let r=Ft(e);if(r.length===0)return;this._checkGuard(t);let o=t??{internal:!0};this._validateUpTiers(r);for(let s of this._deps)s.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=Bt(t);if(!this._guard(u,"observe"))throw new Ee({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)_n(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 s;try{s=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 i=this._isTerminal;if(this._sinkCount===1&&!i)try{this._activate()}catch(u){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof s=="function")try{s()}catch{}throw u}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let a=!1;return()=>{a||(a=!0,this._sinkCount-=1,this._removeSink(e),typeof s=="function"&&s(),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,s=this._deps[r];s.unsub=Mr,s.unsub=s.node.subscribe(i=>{if(s.unsub===null)return;let a=this._config.tierOf,u=!1;for(let d of i)a(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 s=this._deps[o];if(s.unsub!=null){let i=s.unsub;s.unsub=null;try{i()}catch{}_n(s)}}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=Cr(e);if(this._deps.push(r),this._sinks==null)return t;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(gn),r.unsub=Mr;try{r.unsub=e.subscribe(o=>{if(r.unsub===null)return;let s=this._config.tierOf,i=!1;for(let a of o)s(a[0])>=3&&(i=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:t},this._actions);i&&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([[S,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([[S,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{}}_n(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 s={kind:"dep_message",depIndex:e,message:t};for(let i of this._inspectorHooks)i(s)}if(o!==Ie){if(o===V){this._depDirtied(r);return}if(o===ke){if(this._depInvalidated(r),this._cached===void 0)return;this._emit(yr);return}if(o===le||o===pe){this._emit([t]);return}if(o===K){this._emit(bn);return}if(o===x)this._depSettledAsData(r,t[1]);else if(o===C)this._depSettledAsResolved(r);else if(o===N)this._depSettledAsTerminal(r,!0);else if(o===S)this._depSettledAsTerminal(r,t[1]);else{this._emit([t]);return}if(!this._fn){(o===x||o===C)&&this._emit([t]),(o===N||o===S)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(gn))}_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(br),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([[S,e.terminal]]);return}this._autoComplete&&this._deps.every(t=>t.terminal!==void 0)&&this._emit(vr)}_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(i){this._emit([[S,this._wrapFnError("cleanup threw",i)]]);return}}else if(e!=null&&typeof e=="object"){let i=e.beforeRun;if(typeof i=="function"){e.beforeRun=void 0;try{i()}catch(a){this._emit([[S,this._wrapFnError("cleanup.beforeRun threw",a)]]);return}}}let t=this._deps.map(i=>i.involvedThisWave?i.dataBatch.length>0?[...i.dataBatch]:[]:void 0),r=this._deps.map(i=>i.prevData);for(let i=0;i<this._deps.length;i++){let a=t[i];a!=null&&a.length>0&&(this._deps[i].prevData=a[a.length-1])}let o=this._deps.map(i=>i.terminal),s={prevData:r,terminalDeps:o,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let i={kind:"run",batchData:t,prevData:r};for(let a of this._inspectorHooks)a(i)}this._isExecutingFn=!0;try{let i=this._fn(t,this._actions,s);if(typeof i=="function")this._cleanup=i;else if(i!=null&&typeof i=="object"){let a=i;(typeof a.beforeRun=="function"||typeof a.deactivate=="function"||typeof a.invalidate=="function")&&(this._cleanup=i)}}catch(i){this._emit([[S,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>Ar?(this._rerunDepth=0,this._emit([[S,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${Ar} \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"?[ot,e[0]]:e;let r=!0,o=!1,s=!1,i=-1;for(let u of e){let d=t(u[0]);d<i&&(r=!1),d===3&&(o=!0),u[0]===V&&(s=!0),i=d}let a=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),a=u.map(d=>d.m)}if(o&&!s&&this._status!=="dirty"){let u=0;for(;u<a.length&&t(a[u][0])===0;)u++;return u===0?[ot,...a]:[...a.slice(0,u),ot,...a.slice(u)]}return a}_emit(e){if(e.length===0)return;for(let a=0;a<e.length;a++){let u=e[a];if(u[0]===S&&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 a=e.filter(u=>u[0]===K||u[0]===ke);if(a.length===0)return;t=a}t=this._frameBatch(t);let o=null;for(let a=0;a<t.length;a++){let u=t[a],d=u[0];if(d!==le&&d!==pe){o?.push(u);continue}if(u.length<2)throw new Error(`Node "${this.name}": [[${d===le?"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 l=u[1];if(d===le)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(l),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(l))c=!1;else if(this._pauseLocks.delete(l),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let f=this._pauseBuffer;this._pauseBuffer=[],this._emit(f)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}c?o?.push(u):o==null&&(o=t.slice(0,a))}if(o!=null){if(o.length===0)return;t=o}if(this._hasMeta&&t.some(a=>a[0]===K))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(bn)}catch{}let{finalMessages:s,equalsError:i}=this._updateState(t);if(s.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:s})}catch{}}if(s.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,u=[];for(let d of s)a(d[0])===3?this._pauseBuffer.push(d):u.push(d);u.length>0&&this._dispatchOrAccumulate(u)}else this._dispatchOrAccumulate(s);i!=null&&this._emit([[S,i]])}_updateState(e){let t=this._config.tierOf,r,o,s=-1,i=0;for(let c of e)t(c[0])===3&&i++;let a=i<=1,u=-1;if(this._versioning!=null&&i>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===x){u=c;break}}for(let c=0;c<e.length;c++){let l=e[c],f=l[0];if(f===x){if(l.length>=2){let p=!1;if(a&&this._cached!==void 0)try{p=this._equals(this._cached,l[1])}catch(h){o=this._wrapFnError("equals threw",h),s=c;break}if(p){r==null&&(r=e.slice(0,c)),r.push(hn),this._status="resolved";continue}this._cached=l[1],this._versioning!=null&&(u<0||c===u)&&Or(this._versioning,l[1],this._hashFn)}this._status="settled",r?.push(l)}else if(r?.push(l),f===V)this._status="dirty";else if(f===C)this._status="resolved";else if(f===N){this._status="completed";{let p=this._config.rigorRecorder;if(p!=null)try{p.onTerminalTransition(this,"completed",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(f===S){this._status="errored";{let p=this._config.rigorRecorder;if(p!=null)try{p.onTerminalTransition(this,"errored",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(f===ke){if(this._cached!==void 0){let h=this._config.rigorRecorder;if(h!=null)try{h.onNonVacuousInvalidate(this,this._cached)}catch{}}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 h=p.invalidate;if(typeof h=="function")try{h()}catch{}}}else f===K&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let d=s>=0?r??e.slice(0,s):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(gr()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],rt(()=>this._flushBatchPending()));for(let t of e)this._batchPendingMessages.push(t);return}Lt(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);Lt(this._deliverToSinks,t,this._config.tierOf)}},Pr=n=>Array.isArray(n),Sn=n=>typeof n=="object"&&n!=null&&!Array.isArray(n)});function F(n,e){return B([],{...e,initial:n})}function A(n,e){return B((r,o,s)=>n(o,s)??void 0,{describeKind:"producer",...e})}function be(n,e,t){return B(n,(o,s,i)=>{let a=o.map((u,d)=>u!=null&&u.length>0?u.at(-1):i.prevData[d]);s.emit(e(a,i))},{describeKind:"derived",...t})}function Gt(n,e,t){return B(n,(o,s,i)=>{let a=o.map((u,d)=>u!=null&&u.length>0?u.at(-1):i.prevData[d]);return e(a,s,i)??void 0},{describeKind:"effect",...t})}var fe=ne(()=>{"use strict";ge()});var Ir={};pn(Ir,{NS_PER_MS:()=>ve,NS_PER_SEC:()=>Ce,constant:()=>En,decorrelatedJitter:()=>An,exponential:()=>Rn,fibonacci:()=>Mn,linear:()=>On,resolveBackoffPreset:()=>it,withMaxAttempts:()=>Dr});function We(n){return n<0?0:n}function ss(n,e){return e==="none"?n:e==="full"?Math.random()*n:n/2+Math.random()*(n/2)}function is(n,e){return n+Math.random()*(e-n)}function En(n){let e=We(n);return()=>e}function On(n,e){let t=We(n),r=e===void 0?t:We(e);return o=>t+r*Math.max(0,o)}function Rn(n){let e=We(n?.baseNs??1e8),t=n?.factor!==void 0&&n.factor<1?1:n?.factor??2,r=We(n?.maxDelayNs??30*1e9),o=n?.jitter??"none";return s=>{let i;if(e===0)i=0;else if(t===1)i=e;else{let a=r/e,u=1;for(let d=0;d<Math.max(0,s);d++){if(u>=a){u=a;break}u*=t}i=e*u,i>r&&(i=r)}return ss(i,o)}}function Mn(n=100*1e6,e=30*1e9){let t=We(n),r=We(e);function o(s){if(s<=0)return 1;let i=1,a=2;for(let u=1;u<s;u++){let d=i+a;i=a,a=d}return a}return s=>{let i=o(s)*t;return i<=r?i:r}}function An(n=100*1e6,e=30*1e9){return(t,r,o)=>{let i=Math.min(e,(o??n)*3);return is(n,i)}}function Dr(n,e){return(t,r,o)=>t>=e?null:n(t,r,o)}function it(n){if(n==="constant")return En(1*1e9);if(n==="linear")return On(1*1e9);if(n==="exponential")return Rn();if(n==="fibonacci")return Mn();if(n==="decorrelatedJitter")return An();throw new Error(`Unknown backoff preset: "${String(n)}". Use one of: constant, linear, exponential, fibonacci, decorrelatedJitter`)}var ve,Ce,kt=ne(()=>{"use strict";ve=1e6,Ce=1e9});function Pn(n,e){if(e!=null&&e.length>0)return new Set(e);switch(n){case"standard":return new Set(["type","status","value","deps","meta","v"]);case"full":return null;case"spec":return new Set(["type","deps","meta","value"]);default:return new Set(["type","deps"])}}function as(n){return n._describeKind!=null?n._describeKind:n._deps.length>0?"derived":n._fn!=null?"producer":"state"}function q(n,e){let t={factory:n};return e!==void 0&&(t.factoryArgs=e),t}function us(n){let e={};for(let[t,r]of Object.entries(n.meta))try{e[t]=r.cache}catch{}return e}function Dn(n,e,t){let r=e==null,o=!r&&e!=null?[...e].filter(c=>c.startsWith("meta.")).map(c=>c.slice(5)):null,s=r||e.has("meta")||o!=null&&o.length>0,i="state",a=[];n instanceof oe&&(i=as(n),a=n._deps.map(c=>c.node.name??""));let u={type:i,deps:a};(r||e.has("status"))&&(u.status=n.status);let d=n instanceof oe?n._guard:void 0;if(s){let c={...us(n)};if(d!=null&&c.access===void 0&&(c.access=wn(d)),o!=null&&o.length>0&&!e.has("meta")){let l={};for(let f of o)f in c&&(l[f]=c[f]);u.meta=l}else u.meta=c}if(n.name!=null&&(u.name=n.name),(r||e.has("value"))&&(!t||i==="state")){n.status==="sentinel"&&(u.sentinel=!0);try{u.value=n.cache}catch{}}if((r||e.has("v"))&&n.v!=null){let c={id:n.v.id,version:n.v.version};"cid"in n.v&&(c.cid=n.v.cid,c.prev=n.v.prev),u.v=c}return(r||e.has("guard"))&&d!=null&&(u.guard=wn(d)),(r||e.has("lastMutation"))&&n.lastMutation!=null&&(u.lastMutation=n.lastMutation),u}var xt=ne(()=>{"use strict";wt();ge()});function Nt(n,e,t){let r=new Set;for(let o of n.split(",")){let[s,i]=o.split("/"),a=i?Number.parseInt(i,10):1;if(Number.isNaN(a)||a<1)throw new Error(`Invalid cron step: ${o}`);let u,d;if(s==="*")u=e,d=t;else if(s.includes("-")){let[c,l]=s.split("-");u=Number.parseInt(c,10),d=Number.parseInt(l,10)}else u=Number.parseInt(s,10),d=u;if(Number.isNaN(u)||Number.isNaN(d))throw new Error(`Invalid cron field: ${n}`);if(u<e||d>t)throw new Error(`Cron field out of range: ${n} (${e}-${t})`);if(u>d)throw new Error(`Invalid cron range: ${u}-${d} in ${n}`);for(let c=u;c<=d;c+=a)r.add(c)}return r}function In(n){let e=n.trim().split(/\s+/);if(e.length!==5)throw new Error(`Invalid cron: expected 5 fields, got ${e.length}`);return{minutes:Nt(e[0],0,59),hours:Nt(e[1],0,23),daysOfMonth:Nt(e[2],1,31),months:Nt(e[3],1,12),daysOfWeek:Nt(e[4],0,6)}}function Ln(n,e){return n.minutes.has(e.getMinutes())&&n.hours.has(e.getHours())&&n.daysOfMonth.has(e.getDate())&&n.months.has(e.getMonth()+1)&&n.daysOfWeek.has(e.getDay())}var Bn=ne(()=>{"use strict"});function Vn(n,e,t){return{[n]:!0,[`${n}_type`]:e,...t??{}}}var Fn=ne(()=>{"use strict"});function zt(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],s=new Gn,i=!1,a=!1,u=Symbol("budget-gate"),d=new Array(e.length);function c(){return e.every((p,h)=>p.check(d[h]))}function l(p){for(;s.size>0&&c();){let h=s.shift();p.emit(h)}s.size===0&&a&&(a=!1,p.down([[C]]))}return B([],(p,h)=>{for(let m=0;m<e.length;m++)d[m]=e[m].node.cache;let g=[];for(let m=0;m<o.length;m++){let y=o[m];g.push(y.subscribe(b=>{for(let v of b)f(v,m,h)}))}return()=>{for(let m of g)m()}},{...t,describeKind:"derived",meta:Vn("resilience","budget_gate",t?.meta)});function f(p,h,g){let m=p[0];if(h===0){if(m===x)return c()&&s.size===0?g.emit(p[1]):(s.push(p[1]),i||(i=!0,g.up([[le,u]]))),!0;if(m===V)return g.down([[V]]),!0;if(m===C)return s.size===0?g.down([[C]]):a=!0,!0;if(m===N||m===S){for(;s.size>0;)g.emit(s.shift());return a=!1,i&&(i=!1,g.up([[pe,u]])),g.down([p]),!0}return!1}if(m===x&&(d[h-1]=p[1]),m===x||m===C){let y=c();return y&&s.size>0?(l(g),s.size===0&&i&&(i=!1,g.up([[pe,u]]))):!y&&!i&&s.size>0&&(i=!0,g.up([[le,u]])),!0}return m===V?!0:m===S?(g.down([p]),!0):m===N}}var Gn,Br=ne(()=>{"use strict";X();ge();Fn();Gn=class{buf=[];head=0;get size(){return this.buf.length-this.head}push(e){this.buf.push(e)}shift(){if(this.head>=this.buf.length)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head++,this.head>32&&this.head*2>this.buf.length&&(this.buf=this.buf.slice(this.head),this.head=0),e}clear(){this.buf=[],this.head=0}}});var Pe,Kt=ne(()=>{"use strict";Pe=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}}});var Le,$t=ne(()=>{"use strict";Le=class{constructor(e){this.capacity=e;if(!Number.isInteger(e)||e<=0)throw new Error(`RingBuffer capacity must be a positive integer (got ${e})`);this.buf=new Array(e)}buf;head=0;_size=0;get size(){return this._size}get maxSize(){return this.capacity}push(e){let t=(this.head+this._size)%this.capacity;this.buf[t]=e,this._size<this.capacity?this._size++:this.head=(this.head+1)%this.capacity}shift(){if(this._size===0)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head=(this.head+1)%this.capacity,this._size--,e}at(e){if(this._size===0)return;let t=e<0?this._size+e:e;if(!(t<0||t>=this._size))return this.buf[(this.head+t)%this.capacity]}toArray(){let e=new Array(this._size);for(let t=0;t<this._size;t++)e[t]=this.buf[(this.head+t)%this.capacity];return e}clear(){for(let e=0;e<this._size;e++)this.buf[(this.head+e)%this.capacity]=void 0;this.head=0,this._size=0}}});function He(n){return{describeKind:"derived",...n}}function ds(n){return n<0?0:n}function zn(n){return n[1]}function cs(n){if(typeof n!="number"||!Number.isFinite(n))throw new TypeError("backoff strategy must return a finite number");return n<0?0:n}function Vr(n){let e=n?.count,t=n?.backoff;if(t!==void 0&&e===void 0)throw new RangeError("retry({ backoff }) requires explicit count to prevent unbounded retries; pass { count: <n>, backoff: ... }");let r=e!==void 0?e:0;if(r<0)throw new RangeError("retry count must be >= 0");let o=t===void 0?null:typeof t=="string"?it(t):t;return{maxRetries:r,strategy:o}}function Fr(n){let e={};return n?.count!==void 0&&(e.count=n.count),typeof n?.backoff=="string"&&(e.backoff=n.backoff),Object.keys(e).length>0?e:void 0}function Gr(n,e,t){let r=0,o=!1,s=null,i,a=new Pe;function u(){i?.(),i=void 0}function d(l){if(o)return;if(r>=n.maxRetries){u(),t.down([[S,l]]);return}let f=n.strategy===null?0:n.strategy(r,l,s);if(f==null){u(),t.down([[S,l]]);return}let p;try{p=cs(f)}catch{u(),t.down([[S,l]]);return}s=p,r+=1,u();let h=p>0?p/1e6:1;a.start(h,()=>{o||c()})}function c(){a.cancel(),u();let l;try{l=e()}catch(f){d(f);return}i=l.subscribe(f=>{if(!o)for(let p of f){let h=p[0];if(h===V)t.down([[V]]);else if(h===x)r=0,s=null,t.emit(p[1]);else if(h===C)t.down([[C]]);else if(h===N)u(),t.down([[N]]);else if(h===S){d(zn(p));return}else t.down([p])}})}return c(),()=>{o=!0,a.cancel(),u()}}function _t(n,e){return typeof n=="function"?fs(n,e):ls(n,e)}function ls(n,e){let t=Vr(e);return A(r=>Gr(t,()=>n,r),{...He(),initial:n.cache,meta:{...e?.meta??{},...q("retry",Fr(e))}})}function fs(n,e){let t=Vr(e);return A(r=>Gr(t,n,r),{...He(),initial:e?.initial,meta:{...e?.meta??{},...q("retry",Fr(e))}})}function Kn(n){let e=Math.max(1,n?.failureThreshold??5),t=ds(n?.cooldownNs??30*1e9),r=n?.cooldown??null,o=Math.max(1,n?.halfOpenMax??1),s=n?.now??re,i="closed",a=0,u=0,d=0,c=t,l=0;function f(){if(!r)return t;let g=r(u);return g!==null?g:t}function p(){i="open",c=f(),d=s(),l=0}return{canExecute(){return i==="closed"?!0:i==="open"?s()-d>=c?(i="half-open",l=1,!0):!1:l<o?(l++,!0):!1},recordSuccess(){i==="half-open"?(i="closed",a=0,u=0):i==="closed"&&(a=0)},recordFailure(g){if(i==="half-open"){u++,p();return}i==="closed"&&(a++,a>=e&&p())},get state(){return i},get failureCount(){return a},reset(){i="closed",a=0,u=0,l=0}}}function $n(n,e){let t=e?.onOpen??"skip",r=e?.meta;return o=>{let s=B([],(i,a)=>{function u(){s.meta.breakerState.down([[x,n.state]])}let d=o.subscribe(c=>{for(let l of c){let f=l[0];f===V?a.down([[V]]):f===x?n.canExecute()?(u(),a.emit(l[1])):(u(),t==="error"?a.down([[S,new ut]]):a.down([[C]])):f===C?a.down([[C]]):f===N?(n.recordSuccess(),u(),a.down([[N]])):f===S?(n.recordFailure(zn(l)),u(),a.down([l])):a.down([l])}});return u(),d},{...He(),meta:{...r??{},breakerState:n.state,...q("withBreaker",{onOpen:t})},completeWhenDepsComplete:!1,initial:o.cache});return{node:s,breakerState:s.meta.breakerState}}}function Ut(n,e,t){if(n<=0)throw new RangeError("capacity must be > 0");if(e<0)throw new RangeError("refillPerSecond must be >= 0");let r=t?.clock??re,o=n,s=r();function i(a){if(e>0){let u=a-s;o=Math.min(n,o+u/1e9*e)}s=a}return{available(){return i(r()),o},tryConsume(a=1){if(a<=0)return!0;let u=r();return i(u),o>=a?(o-=a,!0):!1},putBack(a=1){a<=0||(i(r()),o=Math.min(n,o+a))}}}function ps(n,e){return n.droppedCount===e.droppedCount&&n.pendingCount===e.pendingCount&&n.paused===e.paused}function jn(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)throw new RangeError("rateLimiter requires explicit maxBuffer (use Infinity to opt in to unbounded)");let s=o===1/0;if(!s&&(!Number.isInteger(o)||o<1))throw new RangeError("maxBuffer must be a positive integer (or Infinity for unbounded)");let i=e.onOverflow??"drop-newest",a=t*1e9/r,u=A(d=>{let c=Ut(t,a),l=s?ms():hs(o),f=new Pe,p=!1,h=0,g=1e9/a,m=u.meta.droppedCount,y=u.meta.rateLimitState,b=jt;function v(){m.emit(h);let E={droppedCount:h,pendingCount:l.size,paused:l.size>0};ps(b,E)||(b=E,y.emit(E))}b=jt,m.emit(0),y.emit(jt);function T(){for(;l.size>0;)if(c.tryConsume(1))d.emit(l.shift()),v();else{f.start(Math.max(1,g/1e6),T);return}}function w(){h+=1,v()}function _(){for(p=!0,f.cancel();l.size>0;)l.shift();h=0}let k=n.subscribe(E=>{for(let O of E){if(p)return;let R=O[0];if(R===V)d.down([[V]]);else if(R===x){if(!s&&l.size>=o)if(i==="drop-newest")w();else if(i==="drop-oldest")l.shift(),l.push(O[1]),w();else{w(),_(),d.down([[S,new dt(o)]]);return}else l.push(O[1]),v();T()}else if(R===C)d.down([[C]]);else if(R===N)_(),d.down([[N]]);else if(R===S)_(),d.down([O]);else if(R===K){_(),d.down([O]);return}else d.down([O])}});return()=>{p=!0,f.cancel(),k()}},{...He(),initial:n.cache,meta:{...e.meta??{},droppedCount:0,rateLimitState:jt,...q("rateLimiter",e)}});return{node:u,droppedCount:u.meta.droppedCount,rateLimitState:u.meta.rateLimitState}}function hs(n){let e=new Le(n);return{push:t=>e.push(t),shift:()=>e.shift(),get size(){return e.size}}}function ms(){let n=[];return{push:e=>{n.push(e)},shift:()=>n.shift(),get size(){return n.length}}}function St(n,e){let t=e?.initialStatus??"pending",r=e?.meta,o=B([],(s,i)=>{let a=t;return o.meta.status.down([[x,t]]),o.meta.error.down([[x,null]]),n.subscribe(d=>{for(let c of d){let l=c[0];if(l===V)i.down([[V]]);else if(l===x)a==="errored"?$(()=>{o.meta.error.down([[x,null]]),o.meta.status.down([[x,"running"]])}):o.meta.status.down([[x,"running"]]),a="running",i.emit(c[1]);else if(l===C)i.down([[C]]);else if(l===N)o.meta.status.down([[x,"completed"]]),a="completed",i.down([[N]]);else if(l===S){let f=zn(c);$(()=>{o.meta.error.down([[x,f]]),o.meta.status.down([[x,"errored"]])}),a="errored",i.down([c])}else i.down([c])}})},{...He(),meta:{...r??{},status:t,error:null,...q("withStatus",{initialStatus:t})},completeWhenDepsComplete:!1,resubscribable:!0,initial:n.cache});return{node:o,status:o.meta.status,error:o.meta.error}}function gs(n){return n!=null&&typeof n=="object"&&"cache"in n&&typeof n.subscribe=="function"}function bs(n){return n!=null&&typeof n.then=="function"}function ys(n){return n!=null&&typeof n=="object"&&typeof n[Symbol.asyncIterator]=="function"}function Un(n,e,t){let r=t?.meta;return A(o=>{let s,i;function a(){i?.(),i=void 0,gs(e)||bs(e)||ys(e)?s=ie(e).subscribe(d=>{o.down(d);for(let c of d){let l=c[0];if(l===N||l===S||l===K){s=void 0;return}}}):(o.emit(e),o.down([[N]]))}return i=n.subscribe(u=>{for(let d of u){let c=d[0];if(c===V)o.down([[V]]);else if(c===x)o.emit(d[1]);else if(c===C)o.down([[C]]);else if(c===N)o.down([[N]]);else if(c===S){a();return}else if(c===K){s?.(),o.down([d]);return}else o.down([d])}}),()=>{i?.(),s?.()}},{...He(),initial:n.cache,meta:{...r??{},...q("fallback")}})}function Wn(n,e,t){if(e<=0)throw new RangeError("timeoutNs must be > 0");let r=t?.meta;return A(o=>{let s=!1,i=new Pe;function a(){let d=e/1e6;i.start(d,()=>{s||(s=!0,u(),o.down([[S,new ct(e)]]))})}let u=n.subscribe(d=>{for(let c of d){if(s)return;let l=c[0];if(l===V)o.down([[V]]);else if(l===x)a(),o.emit(c[1]);else if(l===C)o.down([[C]]);else if(l===N){i.cancel(),s=!0,o.down([[N]]);return}else if(l===S){i.cancel(),s=!0,o.down([c]);return}else if(l===K){i.cancel(),s=!0,o.down([c]);return}else o.down([c])}});return a(),()=>{s=!0,i.cancel(),u()}},{...He(),initial:n.cache,meta:{...r??{},...q("timeout",{timeoutNs:e})}})}var ut,dt,jt,ct,zr=ne(()=>{"use strict";Br();ye();Ae();X();xt();ge();fe();kt();De();Kt();$t();ut=class extends Error{name="CircuitOpenError";constructor(){super("Circuit breaker is open")}};dt=class extends Error{name="RateLimiterOverflowError";constructor(e){super(`rateLimiter buffer overflow (maxBuffer=${e})`)}};jt=Object.freeze({droppedCount:0,pendingCount:0,paused:!1});ct=class extends Error{name="TimeoutError";constructor(e){super(`Timed out after ${e/1e6}ms`)}}});var Kr={};pn(Kr,{CircuitOpenError:()=>ut,RateLimiterOverflowError:()=>dt,TimeoutError:()=>ct,budgetGate:()=>zt,circuitBreaker:()=>Kn,fallback:()=>Un,rateLimiter:()=>jn,retry:()=>_t,timeout:()=>Wn,tokenBucket:()=>Ut,withBreaker:()=>$n,withStatus:()=>St});var Wt=ne(()=>{"use strict";zr()});function Ne(n){return{describeKind:"producer",...n}}function jr(n){return/[\\^$+?.()|[\]{}]/.test(n)?`\\${n}`:n}function vs(n){let e="^";for(let t=0;t<n.length;t+=1){let r=n[t];if(r==="*"){n[t+1]==="*"?(e+=".*",t+=1):e+="[^/]*";continue}e+=jr(r)}return e+="$",new RegExp(e)}function Ts(n,e){for(let t of e)if(t.test(n))return!0;return!1}function ws(n,e){let t=B([n],(o,s)=>{let i=o[0];if(i==null||i.length===0){s.down([[C]]);return}for(let a of i)s.emit(a)},{describeKind:"derived",initial:n.cache}),r=t.subscribe.bind(t);return t.subscribe=(o,s)=>(e(o),r(o,s)),t}function qe(n,e){let{signal:t,period:r,...o}=e??{};return A(s=>{let i=!1,a=0,u,d,c=()=>{i=!0,u!==void 0&&clearTimeout(u),d!==void 0&&clearInterval(d),t?.removeEventListener("abort",f)},l=()=>{i||(r!=null?(s.emit(a++),d=setInterval(()=>{i||s.emit(a++)},r)):(i=!0,t?.removeEventListener("abort",f),s.emit(a++),s.down([[N]])))},f=()=>{i||(c(),s.down([[S,t.reason]]))};if(t?.aborted){f();return}return u=setTimeout(l,n),t?.addEventListener("abort",f,{once:!0}),c},Ne(o))}function ks(n){let{signal:e,...t}=n??{};return A(r=>{let o=!1,s,i,a=!1,u=!1,d=typeof requestAnimationFrame=="function"?requestAnimationFrame:void 0,c=typeof cancelAnimationFrame=="function"?cancelAnimationFrame:void 0,l=typeof document<"u"?document:void 0,f=()=>{s!==void 0&&c&&c(s),i!==void 0&&clearTimeout(i),s=void 0,i=void 0},p=()=>{o=!0,f(),a&&(e?.removeEventListener("abort",h),a=!1),u&&l&&(l.removeEventListener("visibilitychange",y),u=!1)},h=()=>{o||(p(),r.down([[S,e.reason]]))},g=b=>{o||(r.emit(b),m())},m=()=>{o||(d&&(!l||l.visibilityState!=="hidden")?s=d(g):i=setTimeout(()=>g(performance.now()),16))},y=()=>{o||(f(),m())};return e?.aborted?(h(),p):(e?.addEventListener("abort",h,{once:!0}),a=e!==void 0,l&&d&&(l.addEventListener("visibilitychange",y),u=!0),m(),p)},Ne(t))}function xs(n,e){let t=In(n),{tickMs:r,output:o,...s}=e??{},i=r??6e4,a=o==="date";return A(u=>{let d=-1,c=()=>{let f=new Date,p=f.getFullYear()*1e8+(f.getMonth()+1)*1e6+f.getDate()*1e4+f.getHours()*100+f.getMinutes();p!==d&&Ln(t,f)&&(d=p,u.emit(a?f:te()))};c();let l=setInterval(c,i);return()=>clearInterval(l)},{...Ne(s),name:s.name??`cron:${n}`})}function Ns(n,e,t){let{capture:r,passive:o,once:s,...i}=t??{};return A(a=>{let u=c=>{a.emit(c)},d={capture:r,passive:o,once:s};return n.addEventListener(e,u,d),()=>n.removeEventListener(e,u,d)},Ne(i))}function Jn(n,e){return A(t=>{let r=!1;try{for(let o of n){if(r)return;t.emit(o)}r||t.down([[N]])}catch(o){r||t.down([[S,o]])}return()=>{r=!0}},Ne(e))}function _s(n){return n!=null&&typeof n.then=="function"}function Ur(n,e){let{signal:t,...r}=e??{};return A(o=>{let s=!1,i=()=>{s||(s=!0,o.down([[S,t.reason]]))};if(t?.aborted){i();return}return t?.addEventListener("abort",i,{once:!0}),Promise.resolve(n).then(a=>{s||(s=!0,t?.removeEventListener("abort",i),o.emit(a),o.down([[N]]))},a=>{s||(s=!0,t?.removeEventListener("abort",i),o.down([[S,a]]))}),()=>{s=!0,t?.removeEventListener("abort",i)}},Ne(r))}function Wr(n,e){let{signal:t,...r}=e??{};return A(o=>{let s=new AbortController,i=()=>s.abort(t?.reason);t?.aborted?s.abort(t.reason):t?.addEventListener("abort",i,{once:!0});let a=t??s.signal,u=!1,d=n[Symbol.asyncIterator](),c=()=>{u||a.aborted||Promise.resolve(d.next()).then(l=>{if(!(u||a.aborted)){if(l.done){o.down([[N]]);return}o.emit(l.value),c()}},l=>{!u&&!a.aborted&&o.down([[S,l]])})};return c(),()=>{u=!0,t?.removeEventListener("abort",i),s.abort(),Promise.resolve(d.return?.()).catch(()=>{})}},Ne(r))}function Ss(n){return n!=null&&typeof n=="object"&&"cache"in n&&typeof n.subscribe=="function"}function ie(n,e){if(Ss(n))return n;if(_s(n))return Ur(n,e);if(n!=null){let t=n;if(typeof t[Symbol.asyncIterator]=="function")return Wr(n,e);if(typeof t[Symbol.iterator]=="function")return Jn(n,e)}return Hr(n)}function Hr(...n){return Jn(n,void 0)}function Es(n){return A(e=>{e.down([[N]])},Ne(n))}function Os(n){return A(()=>{},Ne(n))}function Rs(n,e){return A(t=>{t.down([[S,n]])},Ne(e))}function Ms(n,e){let{signal:t,...r}=e??{},o=Ne(r),s=o.resubscribable===void 0?{...o,resubscribable:!0}:o;return A(i=>{let a,u=!1;try{let d=n();a=ie(d,e).subscribe(l=>{if(!u)for(let f of l){let p=f[0];if(p!==Ie)if(p===x)i.emit(f[1]);else if(p===N){u=!0,i.down([[N]]);break}else if(p===S){u=!0,i.down([[S,f[1]]]);break}else i.down([f])}})}catch(d){let c=d===void 0?new Error("defer: thunk threw undefined"):d;i.down([[S,c]])}return()=>{u=!0,a?.()}},s)}function Je(n,e,t){return B([n],(o,s)=>{let i=o[0];if(i!=null&&i.length>0)for(let a of i)e(a)},{describeKind:"effect",...t}).subscribe(()=>{})}function As(n,e){return B([n],(t,r,o)=>{o.store.buf||(o.store.buf=[]);let s=o.store.buf,i=t[0];if(i!=null&&i.length>0)for(let a of i)s.push(a);if(o.terminalDeps[0]===!0){r.emit([...s]),r.down([[N]]);return}(i==null||i.length===0)&&r.down([[C]])},{describeKind:"derived",completeWhenDepsComplete:!1,...e})}function Cs(n,e){return A(t=>n.subscribe(r=>{t.down(r)}),{...Ne(e),initial:n.cache})}function Yn(n,e,t){if(e<1)throw new RangeError("replay expects bufferSize >= 1");let r=[],o=A(s=>n.subscribe(i=>{for(let a of i)a[0]===x&&(r.push(a[1]),r.length>e&&r.shift());s.down(i)}),{...Ne(t),initial:n.cache});return ws(o,s=>{for(let i of r)s([[x,i]])})}function Ps(n,e){return Yn(n,1,e)}function Qn(n){return new Promise((e,t)=>{let r=!1,o=!1,s;s=n.subscribe(i=>{for(let a of i){if(r)return;if(a[0]===x){r=!0,e(a[1]),s?(s(),s=void 0):o=!0;return}if(a[0]===S){r=!0,t(a[1]),s?(s(),s=void 0):o=!0;return}if(a[0]===N){r=!0,t(new Error("completed without DATA")),s?(s(),s=void 0):o=!0;return}}}),o&&(s?.(),s=void 0)})}function qn(n,e,t){return new Promise((r,o)=>{let s=!1,i=!1,a,u=t?.skipCurrent===!0;a=n.subscribe(d=>{for(let c of d){if(s)return;if(!(u&&c[0]===x)){if(c[0]===x){let l=c[1];if(e(l)){s=!0,r(l),a?(a(),a=void 0):i=!0;return}}if(c[0]===S){s=!0,o(c[1]),a?(a(),a=void 0):i=!0;return}if(c[0]===N){s=!0,o(new Error("completed without matching value")),a?(a(),a=void 0):i=!0;return}}}}),u=!1,i&&(a?.(),a=void 0)})}async function Ds(n,e){let t=e?.predicate??(s=>s!=null),r=e?.skipCurrent;if(e?.timeoutMs==null||e.timeoutMs<=0)return await qn(n,t,{skipCurrent:r});if(Hn===void 0){let[s,i]=await Promise.all([Promise.resolve().then(()=>(Wt(),Kr)),Promise.resolve().then(()=>(kt(),Ir))]);Hn=s.timeout,$r=i.NS_PER_MS}let o=Hn(n,e.timeoutMs*$r);return await qn(o,t,{skipCurrent:r})}function Is(n,e){let t=new AbortController,r=e?.reason??new Error("cancelled via nodeSignal"),o,s=!1,i=()=>{o?(o(),o=void 0):s=!0};return o=n.subscribe(a=>{if(!t.signal.aborted)for(let u of a){if(u[0]===x&&u[1]===!0){t.abort(r),i();return}if(u[0]===S){t.abort(u[1]),i();return}if(u[0]===N){i();return}}}),s&&(o?.(),o=void 0),{signal:t.signal,dispose:()=>{o&&(o(),o=void 0)}}}function Ye(n){return n.subscribe(()=>{})}function Bs(n){let e=F(0);return{node:e,increment(){let t=e.cache??0;return t>=n?!1:(e.down([[V],[x,t+1]]),!0)},get(){return e.cache??0},atCap(){return(e.cache??0)>=n}}}var Hn,$r,Ls,qr=ne(()=>{"use strict";Ae();X();ge();fe();Bn();Ls=Yn});var De=ne(()=>{"use strict";qr()});var bu={};pn(bu,{CircuitOpenError:()=>ut,ContentAddressedMissError:()=>Xt,DEFAULT_AUDIT_GUARD:()=>Do,NS_PER_MS:()=>ve,NS_PER_SEC:()=>Ce,NativeIndexBackend:()=>sn,NativeListBackend:()=>an,NativeLogBackend:()=>rn,NativeMapBackend:()=>Qt,NativePubSubBackend:()=>on,RateLimiterOverflowError:()=>dt,ResettableTimer:()=>Pe,TimeoutError:()=>ct,appendAudit:()=>Ct,appendLogStorage:()=>Bo,audit:()=>oi,awaitSettled:()=>Ds,budgetGate:()=>zt,buffer:()=>si,bufferCount:()=>ii,bufferTime:()=>ui,bumpCursor:()=>ur,cached:()=>Ps,canonicalJson:()=>vo,cascadingCache:()=>ba,catchError:()=>yi,checkpointToRedis:()=>ua,checkpointToS3:()=>aa,circuitBreaker:()=>Kn,combine:()=>Xr,combineLatest:()=>mi,concat:()=>Qs,concatMap:()=>ei,constant:()=>En,contentAddressedStorage:()=>wa,createAuditLog:()=>ja,createTransport:()=>et,createWatermarkController:()=>ga,csvRows:()=>ji,debounce:()=>eo,debounceTime:()=>gi,decay:()=>Vo,decorrelatedJitter:()=>An,defer:()=>Ms,delay:()=>ni,deserializeError:()=>bt,dictKv:()=>du,dictSnapshot:()=>cu,distill:()=>Ta,distinctUntilChanged:()=>Hs,domainMeta:()=>Vn,elementAt:()=>js,empty:()=>Es,escapeRegexChar:()=>jr,exhaustMap:()=>Zs,exponential:()=>Rn,externalBundle:()=>Cn,externalProducer:()=>at,fallback:()=>Un,fibonacci:()=>Mn,filter:()=>qt,find:()=>$s,first:()=>Xn,firstValueFrom:()=>Qn,firstWhere:()=>qn,flatMap:()=>ti,forEach:()=>Je,fromAny:()=>ie,fromAsyncIter:()=>Wr,fromCSV:()=>$i,fromClickHouseWatch:()=>Hi,fromCron:()=>xs,fromDrizzle:()=>pa,fromEvent:()=>Ns,fromHTTP:()=>oo,fromHTTPPoll:()=>Ei,fromHTTPStream:()=>Si,fromIter:()=>Jn,fromKafka:()=>Fi,fromKysely:()=>ha,fromMCP:()=>Mi,fromNATS:()=>Yi,fromNDJSON:()=>Wi,fromOTel:()=>Ai,fromPrisma:()=>fa,fromPrometheus:()=>Bi,fromPromise:()=>Ur,fromPulsar:()=>qi,fromRabbitMQ:()=>Xi,fromRaf:()=>ks,fromRedisStream:()=>zi,fromSSE:()=>_i,fromSqlite:()=>da,fromSqliteCursor:()=>ca,fromStatsD:()=>Di,fromSyslog:()=>Ci,fromTimer:()=>qe,fromWebSocket:()=>ro,fromWebSocketReconnect:()=>Ri,fromWebhook:()=>Ti,globToRegExp:()=>vs,interval:()=>li,jsonCodec:()=>Pt,jsonCodecFor:()=>su,keepalive:()=>Ye,kvStorage:()=>fr,last:()=>Ks,lightMutation:()=>Ua,linear:()=>On,lru:()=>fo,makeHttpError:()=>ka,map:()=>Ht,matchesAnyPattern:()=>Ts,matchesCron:()=>Ln,memoryAppendLog:()=>au,memoryBackend:()=>dn,memoryKv:()=>uu,memorySnapshot:()=>iu,merge:()=>Et,mergeMap:()=>Zr,mergeReactiveLogs:()=>Ka,nameToSignal:()=>mt,ndjsonRows:()=>Ui,never:()=>Os,nodeSignal:()=>Is,of:()=>Hr,onFirstData:()=>Qr,pairwise:()=>qs,parseCron:()=>In,parsePrometheusText:()=>uo,parseSSEStream:()=>ao,parseStatsD:()=>Li,parseSyslog:()=>Pi,pausable:()=>pi,pubsub:()=>Ya,race:()=>Xs,rateLimiter:()=>jn,reactiveCounter:()=>Bs,reactiveIndex:()=>Za,reactiveList:()=>eu,reactiveLog:()=>ir,reactiveMap:()=>tr,reactiveSink:()=>ae,reduce:()=>Fs,registerCursor:()=>Ha,registerCursorMap:()=>qa,repeat:()=>fi,replay:()=>Yn,rescue:()=>no,resolveBackoffPreset:()=>it,retry:()=>_t,sample:()=>ri,scan:()=>Vs,serializeError:()=>gt,share:()=>Cs,shareReplay:()=>Ls,signalToName:()=>Ze,singleFromAny:()=>tu,singleNodeFromAny:()=>nu,skip:()=>Yr,snapshotStorage:()=>lr,sortJsonValue:()=>un,stableJsonString:()=>cr,stratify:()=>lu,switchMap:()=>Be,take:()=>Jt,takeUntil:()=>zs,takeWhile:()=>Gs,tap:()=>Us,tapFirst:()=>Ws,throttle:()=>to,throttleTime:()=>bi,throwError:()=>Rs,timeout:()=>Wn,toArray:()=>As,toCSV:()=>ea,toClickHouse:()=>ta,toFile:()=>lo,toHTTP:()=>wi,toKafka:()=>Gi,toLoki:()=>sa,toMongo:()=>oa,toNATS:()=>Qi,toObservable:()=>Ja,toPostgres:()=>ra,toPulsar:()=>Ji,toRabbitMQ:()=>Zi,toReadableStream:()=>Ni,toRedisStream:()=>Ki,toS3:()=>na,toSSE:()=>ki,toSSEBytes:()=>xi,toSqlite:()=>la,toTempo:()=>ia,toWebSocket:()=>Oi,tokenBucket:()=>Ut,topologyDiff:()=>Mt,tryIncrementBounded:()=>$a,valve:()=>hi,verifiable:()=>va,window:()=>ci,windowCount:()=>ai,windowTime:()=>di,withBreaker:()=>$n,withLatestFrom:()=>Js,withMaxAttempts:()=>Dr,withStatus:()=>St,workerBridge:()=>Fo,workerSelf:()=>Go,wrapMutation:()=>Wa,zip:()=>Ys});module.exports=Uo(bu);ye();Ae();X();ge();fe();ye();X();fe();function Lr(n){return{describeKind:"producer",...n}}function at(n,e){return A(t=>{let r=!0,o={emit(i){r&&t.emit(i)},error(i){r&&(r=!1,t.down([[S,i]]))},complete(){r&&(r=!1,t.down([[N]]))}},s;try{let i=n(o);s=typeof i=="function"?i:void 0}catch(i){return o.error(i),()=>{r=!1}}return()=>{r=!1;try{s?.()}catch{}}},Lr(e))}function Cn(n,e,t){let r=!0,o,s=0,i=0,a={},u=[],d=()=>{let p=o;o=void 0;try{p?.()}catch{}};for(let p of e){let h=t?.name?`${t.name}::${p}`:p,g=t?.channelOpts?.[p],m=A(y=>(s++,()=>{i++,s>0&&i>=s&&i>=e.length&&d()}),Lr({...g,name:h}));a[p]=m,u.push(m)}let c={};for(let p of e)c[p]=h=>{r&&a[p].down([[x,h]])};c.error=p=>{r&&(r=!1,$(()=>{for(let h of u)h.down([[S,p]])}),d())},c.complete=()=>{r&&(r=!1,$(()=>{for(let p of u)p.down([[N]])}),d())};let l=n(c);return o=typeof l=="function"?l:void 0,Object.assign(a,{dispose:()=>{r&&(r=!1,$(()=>{for(let p of u)try{p.down([[N]])}catch{}}),d())}})}Ae();X();xt();ge();fe();De();function z(n){return{describeKind:"derived",...n}}function Jr(n){return{describeKind:"derived",partial:!0,...n}}function Ht(n,e,t){return B([n],(r,o)=>{let s=r[0];if(s==null||s.length===0){o.down([[C]]);return}for(let i of s)o.emit(e(i))},{...z(t),meta:{...q("map"),...t?.meta??{}}})}function qt(n,e,t){return B([n],(r,o)=>{let s=r[0];if(s==null||s.length===0){o.down([[C]]);return}let i=!1;for(let a of s)e(a)&&(o.emit(a),i=!0);i||o.down([[C]])},{...z(t),meta:{...q("filter"),...t?.meta??{}}})}function Vs(n,e,t,r){return B([n],(o,s,i)=>{"acc"in i.store||(i.store.acc=t);let a=o[0];if(a==null||a.length===0){s.down([[C]]);return}for(let u of a)i.store.acc=e(i.store.acc,u),s.emit(i.store.acc)},{...z(r),initial:t,resetOnTeardown:!0,meta:{...q("scan",{initial:t}),...r?.meta??{}}})}function Fs(n,e,t,r){return B([n],(o,s,i)=>{if("acc"in i.store||(i.store.acc=t),i.terminalDeps[0]===!0){s.emit(i.store.acc),s.down([[N]]);return}let a=o[0];if(a==null||a.length===0){s.down([[C]]);return}for(let u of a)i.store.acc=e(i.store.acc,u)},{...z(r),completeWhenDepsComplete:!1,meta:{...q("reduce",{initial:t}),...r?.meta??{}}})}function Jt(n,e,t){return e<=0?B([n],(r,o,s)=>{s.store.completed||(s.store.completed=!0,o.down([[N]]))},{...z(t),completeWhenDepsComplete:!1,meta:{...q("take",{count:e}),...t?.meta??{}}}):B([n],(r,o,s)=>{if("taken"in s.store||(s.store.taken=0),s.store.done){o.down([[C]]);return}if(s.terminalDeps[0]===!0){s.store.done=!0,o.down([[N]]);return}let i=r[0];if(i==null||i.length===0){o.down([[C]]);return}for(let a of i)if(s.store.taken++,o.emit(a),s.store.taken>=e){s.store.done=!0,o.down([[N]]);return}},{...z(t),completeWhenDepsComplete:!1,meta:{...q("take",{count:e}),...t?.meta??{}}})}function Yr(n,e,t){return B([n],(r,o,s)=>{"skipped"in s.store||(s.store.skipped=0);let i=r[0];if(i==null||i.length===0){o.down([[C]]);return}let a=!1;for(let u of i)s.store.skipped++,s.store.skipped<=e||(o.emit(u),a=!0);a||o.down([[C]])},z(t))}function Gs(n,e,t){return B([n],(r,o,s)=>{if(s.store.done){o.down([[C]]);return}let i=r[0];if(i==null||i.length===0){o.down([[C]]);return}for(let a of i){if(!e(a)){s.store.done=!0,o.down([[N]]);return}o.emit(a)}},{...z(t),completeWhenDepsComplete:!1})}function zs(n,e,t){let r=t?.predicate??(i=>i[0]===x),{predicate:o,...s}=t??{};return A(i=>{let a=!1,u=n.subscribe(c=>{if(!a)for(let l of c){if(a)return;l[0]===x?i.emit(l[1]):(l[0]===N||l[0]===S)&&(a=!0,i.down([l]))}}),d=e.subscribe(c=>{if(!a)for(let l of c){if(a)return;if(r(l)){a=!0,i.down([[N]]);return}}});return()=>{u(),d()}},z(s))}function Xn(n,e){return Jt(n,1,e)}function Ks(n,e){let{defaultValue:t,...r}=e??{},o=e!=null&&Object.hasOwn(e,"defaultValue");return B([n],(s,i,a)=>{if(a.terminalDeps[0]===!0){a.store.has?i.emit(a.store.latest):o&&i.emit(t),i.down([[N]]);return}let u=s[0];if(u==null||u.length===0){i.down([[C]]);return}a.store.latest=u.at(-1),a.store.has=!0},{...z(r),completeWhenDepsComplete:!1})}function $s(n,e,t){return Jt(qt(n,e,t),1,t)}function js(n,e,t){return Jt(Yr(n,e,t),1,t)}function Us(n,e,t){if(typeof e=="function")return B([n],(o,s)=>{let i=o[0];if(i==null||i.length===0){s.down([[C]]);return}for(let a of i)e(a),s.emit(a)},{...z(t),meta:{...q("tap"),...t?.meta??{}}});let r=e;return B([n],(o,s,i)=>{if(i.terminalDeps[0]!==void 0){i.terminalDeps[0]===!0?(r.complete?.(),s.down([[N]])):(r.error?.(i.terminalDeps[0]),s.down([[S,i.terminalDeps[0]]]));return}let a=o[0];if(a==null||a.length===0){s.down([[C]]);return}for(let u of a)r.data?.(u),s.emit(u)},{...z(t),completeWhenDepsComplete:!1,meta:{...q("tap"),...t?.meta??{}}})}function Qr(n,e,t){let r=t?.where??(s=>s!=null),o=!1;return B([n],(s,i)=>{let a=s[0];if(a==null||a.length===0){i.down([[C]]);return}for(let u of a)!o&&r(u)&&(o=!0,e(u)),i.emit(u)},z(t))}var Ws=Qr;function Hs(n,e=Object.is,t){return B([n],(r,o,s)=>{let i=r[0];if(i==null||i.length===0){o.down([[C]]);return}let a=!1;for(let u of i)s.store.hasPrev&&e(s.store.prev,u)||(s.store.prev=u,s.store.hasPrev=!0,o.emit(u),a=!0);a||o.down([[C]])},{...z(t),meta:{...q("distinctUntilChanged"),...t?.meta??{}}})}function qs(n,e){return B([n],(t,r,o)=>{let s=t[0];if(s==null||s.length===0){r.down([[C]]);return}let i=!1;for(let a of s)if(!o.store.hasPrev)o.store.prev=a,o.store.hasPrev=!0;else{let u=[o.store.prev,a];o.store.prev=a,r.emit(u),i=!0}i||r.down([[C]])},z(e))}function Xr(...n){let e=[...n];return be(e,t=>t,{...z(),equals:(t,r)=>{if(t.length!==r.length)return!1;for(let o=0;o<t.length;o++)if(!Object.is(t[o],r[o]))return!1;return!0}})}function Js(n,e,t){return B([n,e],(r,o,s)=>{let i=r[0],a=r[1],u=a!=null&&a.length>0?a.at(-1):s.prevData[1];if(i!=null&&i.length>0){if(!(a!=null&&a.length>0)&&s.prevData[1]===void 0){o.down([[C]]);return}for(let d of i)o.emit([d,u])}else o.down([[C]])},{...Jr(t),meta:{...q("withLatestFrom"),...t?.meta??{}}})}function Et(...n){return n.length===0?A(e=>{e.down([[N]])},{...z(),meta:{...q("merge")}}):A(e=>{let t=n.length,r=0,o=[];for(let s of n){let i=s.subscribe(a=>{for(let u of a)u[0]===x?e.emit(u[1]):u[0]===N?(r+=1,r>=t&&e.down([[N]])):u[0]===S&&e.down([u])});o.push(i)}return()=>{for(let s of o)s()}},{...z(),meta:{...q("merge")}})}function Ys(...n){let e=n.length;return e===0?A(t=>{t.emit([]),t.down([[N]])},z()):A(t=>{let r=Array.from({length:e},()=>[]),o=e;function s(){for(;r.every(a=>a.length>0);){let a=r.map(u=>u.shift());t.emit(a)}}let i=[];for(let a=0;a<e;a++){let u=a,d=n[a].subscribe(c=>{for(let l of c)l[0]===x?(r[u].push(l[1]),s()):l[0]===N?(o-=1,(o===0||r[u].length===0)&&t.down([[N]])):l[0]===S&&t.down([l])});i.push(d)}return()=>{for(let a of i)a()}},z())}function Qs(n,e,t){return A(r=>{let o=0,s=[],i,a;return a=e.subscribe(u=>{for(let d of u)o===0?d[0]===x?s.push(d[1]):d[0]===S&&r.down([d]):d[0]===x?r.emit(d[1]):(d[0]===N||d[0]===S)&&r.down([d])}),i=n.subscribe(u=>{for(let d of u)if(o===0)if(d[0]===x)r.emit(d[1]);else if(d[0]===N){o=1;for(let c of s)r.emit(c);s.length=0}else d[0]===S&&r.down([d])}),()=>{i?.(),a?.()}},z(t))}function Xs(...n){return n.length===0?A(e=>{e.down([[N]])},z()):n.length===1?B([n[0]],(e,t)=>{let r=e[0];if(r==null||r.length===0){t.down([[C]]);return}for(let o of r)t.emit(o)},z()):A(e=>{let t=null,r=[];for(let o=0;o<n.length;o++){let s=o,i=n[o].subscribe(a=>{for(let u of a){if(t!==null&&s!==t)return;u[0]===x?(t===null&&(t=s),e.emit(u[1])):(u[0]===N||u[0]===S)&&(t===null||s===t)&&e.down([u])}});r.push(i)}return()=>{for(let o of r)o()}},z())}function Yt(n,e,t){let r,o=!1,s=()=>{o||(o=!0,t())};return r=n.subscribe(i=>{let a=!1,u=!1;for(let d of i)d[0]!==Ie&&(d[0]===x?e.emit(d[1]):d[0]===N?a=!0:d[0]===S?(u=!0,e.down([d])):(d[0]===V||d[0]===C)&&e.down([d]));u?(r?.(),r=void 0,s()):a&&s()}),()=>{r?.(),r=void 0}}function Be(n,e,t){let r,o=!1;function s(){r?.(),r=void 0}return B([n],(i,a,u)=>{if(u.terminalDeps[0]!=null&&u.terminalDeps[0]!==!0){s();return}if(u.terminalDeps[0]===!0){o=!0,r||a.down([[N]]);return}let d=i[0];if(!(d==null||d.length===0))return s(),r=Yt(ie(e(d[d.length-1])),a,()=>{s(),o&&a.down([[N]])}),{deactivate:()=>{s(),o=!1}}},{...z(t),completeWhenDepsComplete:!1,meta:{...q("switchMap"),...t?.meta??{}}})}function Zs(n,e,t){let r,o=!1;function s(){r?.(),r=void 0}return B([n],(i,a,u)=>{if(u.terminalDeps[0]!=null&&u.terminalDeps[0]!==!0){s();return}if(u.terminalDeps[0]===!0){o=!0,r||a.down([[N]]);return}let d=i[0];if(!(d==null||d.length===0))return r===void 0?r=Yt(ie(e(d[0])),a,()=>{s(),o&&a.down([[N]])}):a.down([[C]]),{deactivate:()=>{s(),o=!1}}},{...z(t),completeWhenDepsComplete:!1})}function ei(n,e,t){let{maxBuffer:r,...o}=t??{},s=[],i,a=!1,u;function d(){i?.(),i=void 0}function c(){if(!u||i!==void 0)return;if(s.length===0){a&&u.down([[N]]);return}let f=s.shift();i=Yt(ie(e(f)),u,()=>{d(),c()})}function l(f){r&&r>0&&s.length>=r&&s.shift(),s.push(f),c()}return B([n],(f,p,h)=>{if(u=p,h.terminalDeps[0]!=null&&h.terminalDeps[0]!==!0){d(),s.length=0;return}if(h.terminalDeps[0]===!0){a=!0,c();return}let g=f[0];if(!(g==null||g.length===0)){for(let m of g)l(m);return{deactivate:()=>{d(),s.length=0,a=!1}}}},{...z(o),completeWhenDepsComplete:!1})}function Zr(n,e,t){let{concurrent:r,...o}=t??{},s=r!=null&&r>0?r:Number.POSITIVE_INFINITY,i=0,a=!1,u=new Set,d=[],c;function l(){a&&i===0&&d.length===0&&c&&c.down([[N]])}function f(m){if(!c)return;i++;let y;y=Yt(ie(e(m)),c,()=>{y&&u.delete(y),i--,p(),l()}),u.add(y)}function p(){for(;d.length>0&&i<s;)f(d.shift())}function h(m){i<s?f(m):d.push(m)}function g(){for(let m of u)m();u.clear(),i=0,d.length=0}return B([n],(m,y,b)=>{if(c=y,b.terminalDeps[0]!=null&&b.terminalDeps[0]!==!0){g();return}if(b.terminalDeps[0]===!0){a=!0,l();return}let v=m[0];if(!(v==null||v.length===0)){for(let T of v)h(T);return{deactivate:()=>{g(),a=!1}}}},{...z(o),completeWhenDepsComplete:!1})}var ti=Zr;function ni(n,e,t){return A(r=>{let o=new Set;function s(){for(let a of o)clearTimeout(a);o.clear()}let i=n.subscribe(a=>{for(let u of a)if(u[0]===x){let d=setTimeout(()=>{o.delete(d),r.emit(u[1])},e);o.add(d)}else if(u[0]===N){let d=setTimeout(()=>{o.delete(d),r.down([[N]])},e);o.add(d)}else u[0]===S&&(s(),r.down([u]))});return()=>{i(),s()}},z(t))}function eo(n,e,t){return A(r=>{let o,s;function i(){o!==void 0&&(clearTimeout(o),o=void 0)}let a=n.subscribe(u=>{for(let d of u)d[0]===x?(i(),s=d[1],o=setTimeout(()=>{o=void 0,r.emit(s)},e)):d[0]===N?(o!==void 0&&(i(),r.emit(s)),r.down([[N]])):d[0]===S&&(i(),r.down([d]))});return()=>{a(),i()}},{...z(t),meta:{...q("debounce",{ms:e}),...t?.meta??{}}})}function to(n,e,t){let{leading:r,trailing:o,...s}=t??{},i=r!==!1,a=o===!0,u=e*1e6;return A(d=>{let c,l=-1/0,f,p=!1;function h(){c!==void 0&&(clearTimeout(c),c=void 0)}let g=n.subscribe(m=>{for(let y of m)if(y[0]===x){let b=y[1],v=re();if(i&&v-l>=u)l=v,d.emit(b),h(),a&&(c=setTimeout(()=>{c=void 0,p&&(l=re(),d.emit(f),p=!1)},e));else if(a&&(f=b,p=!0,c===void 0)){let T=(v-l)/1e6;c=setTimeout(()=>{c=void 0,p&&(l=re(),d.emit(f),p=!1)},Math.max(0,e-T))}}else(y[0]===N||y[0]===S)&&(h(),d.down([y]))});return()=>{g(),h()}},{...z(s),meta:{...q("throttle",{ms:e,leading:i,trailing:a}),...s.meta??{}}})}function ri(n,e,t){return A(r=>{let o,s=!1,i=!1,a=n.subscribe(d=>{if(!s)for(let c of d){if(s)return;c[0]===x?o={v:c[1]}:c[0]===S?(s=!0,r.down([c])):c[0]===N&&(i=!0,o=void 0)}}),u=e.subscribe(d=>{if(!s)for(let c of d){if(s)return;c[0]===x?o!==void 0&&!i&&r.emit(o.v):c[0]===S?(s=!0,r.down([c])):c[0]===N&&(s=!0,r.down([[N]]))}});return()=>{a(),u()}},z(t))}function oi(n,e,t){return A(r=>{let o,s,i=!1;function a(){o!==void 0&&(clearTimeout(o),o=void 0)}let u=n.subscribe(d=>{for(let c of d)c[0]===x?(s=c[1],i=!0,a(),o=setTimeout(()=>{o=void 0,i&&(i=!1,r.emit(s))},e)):(c[0]===N||c[0]===S)&&(a(),r.down([c]))});return()=>{u(),a()}},z(t))}function si(n,e,t){return A(r=>{let o=[],s=n.subscribe(a=>{for(let u of a)u[0]===x?o.push(u[1]):u[0]===N?(o.length>0&&r.emit([...o]),o.length=0,r.down([[N]])):u[0]===S&&r.down([u])}),i=e.subscribe(a=>{for(let u of a)u[0]===x?o.length>0&&(r.emit([...o]),o.length=0):u[0]===N?r.down([[N]]):u[0]===S&&r.down([u])});return()=>{s(),i(),o.length=0}},z(t))}function ii(n,e,t){if(e<=0)throw new RangeError("bufferCount expects count > 0");return A(r=>{let o=[],s=n.subscribe(i=>{for(let a of i)a[0]===x?(o.push(a[1]),o.length>=e&&r.emit(o.splice(0,o.length))):a[0]===N?(o.length>0&&r.emit([...o]),o.length=0,r.down([[N]])):a[0]===S&&r.down([a])});return()=>{s(),o.length=0}},z(t))}function ai(n,e,t){if(e<=0)throw new RangeError("windowCount expects count > 0");return A(r=>{let o,s=0;function i(){let u=A(d=>(o=d.down.bind(d),()=>{o=void 0}),z());s=0,r.emit(u)}let a=n.subscribe(u=>{for(let d of u)d[0]===x?(o||i(),o?.([[x,d[1]]]),s+=1,s>=e&&(o?.([[N]]),o=void 0)):d[0]===N?(o?.([[N]]),o=void 0,r.down([[N]])):d[0]===S&&(o?.([d]),o=void 0,r.down([d]))});return()=>{a(),o?.([[N]]),o=void 0}},z(t))}function ui(n,e,t){return A(r=>{let o=[],s=setInterval(()=>{o.length>0&&(r.emit([...o]),o.length=0)},e),i=n.subscribe(a=>{for(let u of a)u[0]===x?o.push(u[1]):u[0]===N?(clearInterval(s),o.length>0&&r.emit([...o]),o.length=0,r.down([[N]])):u[0]===S&&(clearInterval(s),r.down([u]))});return()=>{i(),clearInterval(s),o.length=0}},{...z(t),meta:{...q("bufferTime",{ms:e}),...t?.meta??{}}})}function di(n,e,t){return A(r=>{let o;function s(){o?.([[N]]),o=void 0}function i(){let d=A(c=>(o=c.down.bind(c),()=>{o=void 0}),z());r.emit(d)}i();let a=setInterval(()=>{s(),i()},e),u=n.subscribe(d=>{for(let c of d)c[0]===x?o?.([[x,c[1]]]):c[0]===N?(clearInterval(a),s(),r.down([[N]])):c[0]===S&&(clearInterval(a),o?.([c]),s(),r.down([c]))});return()=>{u(),clearInterval(a),s()}},z(t))}function ci(n,e,t){return A(r=>{let o;function s(){o?.([[N]]),o=void 0}function i(){let d=A(c=>(o=c.down.bind(c),()=>{o=void 0}),z());r.emit(d)}let a=n.subscribe(d=>{for(let c of d)c[0]===x?(o||i(),o?.([[x,c[1]]])):c[0]===N?(s(),r.down([[N]])):c[0]===S&&(o?.([c]),o=void 0,r.down([c]))}),u=e.subscribe(d=>{for(let c of d)c[0]===x&&(s(),i())});return()=>{a(),u(),s()}},z(t))}function li(n,e){return A((t,r)=>{"n"in r.store||(r.store.n=0);let o=setInterval(()=>{t.emit(r.store.n),r.store.n=r.store.n+1},n);return()=>clearInterval(o)},z(e))}function fi(n,e,t){if(e<=0)throw new RangeError("repeat expects count > 0");return A(r=>{let o=e,s,i=()=>{s?.(),s=n.subscribe(a=>{let u=!1,d=[];for(let c of a)c[0]===N?u=!0:d.push(c);d.length>0&&r.down(d),u&&(s?.(),s=void 0,o-=1,o>0?i():r.down([[N]]))})};return i(),()=>{s?.()}},z(t))}function pi(n,e){return B([n],(t,r)=>{let o=t[0];if(o==null||o.length===0){r.down([[C]]);return}for(let s of o)r.emit(s)},z(e))}function no(n,e,t){return A(r=>{let o=n.subscribe(s=>{for(let i of s)if(i[0]===x)r.emit(i[1]);else if(i[0]===S)try{r.emit(e(i[1]))}catch(a){r.down([[S,a]])}else i[0]===N&&r.down([[N]])});return()=>{o()}},z(t))}function hi(n,e,t){return B([n,e],(r,o,s)=>{let i=r[1];if(!(i!=null&&i.length>0?i.at(-1):s.prevData[1])){o.down([[C]]);return}let u=r[0];if(u!=null&&u.length>0){for(let d of u)o.emit(d);return}if(i!=null&&i.length>0&&s.prevData[0]!==void 0){o.emit(s.prevData[0]);return}o.down([[C]])},Jr(t))}var mi=Xr,gi=eo,bi=to,yi=no;X();ge();fe();kt();$t();var Zn=class{ring;arr;constructor(e){e===Number.POSITIVE_INFINITY||e<=0?(this.arr=[],this.ring=null):(this.ring=new Le(e),this.arr=null)}get length(){return this.ring!=null?this.ring.size:this.arr.length}push(e){this.ring!=null?this.ring.push(e):this.arr.push(e)}shift(){return this.ring!=null?this.ring.shift():this.arr.shift()}drain(){if(this.ring!=null){let t=this.ring.toArray();return this.ring.clear(),t}let e=this.arr;return this.arr=[],e}};function Ot(n){return n instanceof Error?n:new Error(String(n))}function vi(n){return n===void 0?null:typeof n=="string"?it(n):n}function ae(n,e){let{name:t,onTransportError:r,retry:o,backpressure:s,batchSize:i=Number.POSITIVE_INFINITY,flushIntervalMs:a=0,serialize:u,stopOn:d,onUpstreamMessage:c,onDispose:l,send:f,sendBatch:p,ctx:h}=e;if(!f&&!p)throw new Error("reactiveSink: `send` or `sendBatch` must be provided");let g=h,m=Math.max(1,o?.maxAttempts??1),y=vi(o?.backoff??(m>1?"exponential":void 0)),b=o?.shouldRetry??(()=>!0),v=p!==void 0||i<Number.POSITIVE_INFINITY||a>0,T=D=>t?`${t}::${D}`:void 0,w=F(void 0,{equals:()=>!1,name:T("sent")}),_=F(null,{name:T("failed")}),k=F(0,{name:T("inFlight")}),E=F(null,{name:T("errors")}),O=v?F(0,{name:T("buffered")}):void 0,R=s?F(!1,{name:T("paused")}):void 0,M=0,G=D=>{M+=D,k.down([[x,M]])},P=D=>{try{r?.(D)}catch{}try{E.down([[x,D]])}catch{}},L=new Set,ue=D=>{L.add(D);let W=()=>L.delete(D);D.then(W,W)},U=(D,W,J)=>{let Z=y?y(W-1,J,null):0,ce=Z==null?0:typeof Z=="number"&&Z>0?Z:0,Oe=Math.max(1,Math.ceil(ce/1e6));return new Promise(Y=>{setTimeout(()=>Y(D()),Oe)})},de=D=>D!=null&&typeof D=="object"&&typeof D.then=="function",_e=D=>{let W;try{W=u?u(D):D}catch(Y){let H=Ot(Y);return P({stage:"serialize",error:H,value:D}),_.down([[x,{value:D,error:H,attempts:0}]]),Promise.resolve()}let J=0,Z=Y=>{G(-1);let H=Ot(Y);if(P({stage:"send",error:H,value:D,attempt:J}),!(J<m&&b(H,J))){_.down([[x,{value:D,error:H,attempts:J}]]);return}return U(Oe,J,H)},ce=()=>{G(-1),w.down([[x,D]])};function Oe(){J+=1,G(1);let Y;try{Y=f(W,g)}catch(H){return Z(H)??Promise.resolve()}return de(Y)?Y.then(ce,H=>Z(H)):(ce(),Promise.resolve())}return Oe()},Ve=s?.maxBuffer??Number.POSITIVE_INFINITY,Se=new Zn(Ve),xe,Fe=!1,Ge=()=>{O?.down([[x,Se.length]])},Ke=D=>{R&&R.down([[x,D]])},I=s?.strategy??"drop-oldest",Q=(D,W)=>{let J={value:D,payload:W};if(Se.length<Ve)return Se.push(J),Ge(),!0;if(I==="drop-oldest"){let ce=Se.shift();return Se.push(J),Ge(),Ke(!0),_.down([[x,{value:ce.value,error:new Error("backpressure: buffer overflow \u2014 dropped oldest"),attempts:0}]]),!0}if(I==="drop-newest")return Ke(!0),_.down([[x,{value:D,error:new Error("backpressure: buffer overflow \u2014 dropped newest"),attempts:0}]]),!1;let Z=new Error("backpressure: buffer overflow");return P({stage:"send",error:Z,value:D}),_.down([[x,{value:D,error:Z,attempts:0}]]),Ke(!0),!1},Te=D=>{let W=0,J=D.map(Y=>Y.payload),Z=Y=>{G(-1);let H=Ot(Y);if(P({stage:"send",error:H,value:D.map(ln=>ln.value),attempt:W}),!(W<m&&b(H,W))){for(let{value:ln}of D)_.down([[x,{value:ln,error:H,attempts:W}]]);return}return U(Oe,W,H)},ce=()=>{G(-1);for(let{value:Y}of D)w.down([[x,Y]])};function Oe(){W+=1,G(1);let Y;try{Y=p(J,g)}catch(H){return Z(H)??Promise.resolve()}return de(Y)?Y.then(ce,H=>Z(H)):(ce(),Promise.resolve())}return Oe()},$e=async D=>{for(let W of D)await we(W.value,W.payload)},we=(D,W)=>{let J=0,Z=Y=>{G(-1);let H=Ot(Y);if(P({stage:"send",error:H,value:D,attempt:J}),!(J<m&&b(H,J))){_.down([[x,{value:D,error:H,attempts:J}]]);return}return U(Oe,J,H)},ce=()=>{G(-1),w.down([[x,D]])};function Oe(){J+=1,G(1);let Y;try{Y=f(W,g)}catch(H){return Z(H)??Promise.resolve()}return de(Y)?Y.then(ce,H=>Z(H)):(ce(),Promise.resolve())}return Oe()},j=()=>{if(Fe||Se.length===0)return Promise.resolve();let D=Se.drain();if(Ge(),Ke(!1),p!==void 0){let J=Te(D);return ue(J),J}let W=$e(D);return ue(W),W},he=()=>{xe!==void 0||Fe||a<=0||(xe=setTimeout(()=>{xe=void 0,j()},a))},yt=n.subscribe(D=>{for(let W of D){let J=W[0];if(J!==x)try{c?.(W)}catch{}if(J===x){let Z=W[1];if(v){let ce;if(u)try{ce=u(Z)}catch(Y){let H=Ot(Y);P({stage:"serialize",error:H,value:Z}),_.down([[x,{value:Z,error:H,attempts:0}]]);continue}else ce=Z;if(!Q(Z,ce))continue;Se.length>=i?j():he()}else{let ce=_e(Z);ue(ce)}}else me.messageTier(J)>=3&&v&&(xe!==void 0&&(clearTimeout(xe),xe=void 0),j())}}),pr;if(d){let D=!1;pr=d.subscribe(W=>{if(!D){D=!0;return}W.length>0&&!cn&&hr()})}let cn=!1,hr=()=>{if(cn)return;cn=!0,xe!==void 0&&(clearTimeout(xe),xe=void 0),v&&j(),Fe=!0,pr?.(),yt();let D=W=>{try{W.down([[K]])}catch{}};D(E),D(_),D(w),D(k),O&&D(O),R&&D(R);try{l?.()}catch{}},Dt={dispose:hr,sent:w,failed:_,inFlight:k,errors:E};return v&&(Dt.buffered=O,Dt.flush=async()=>{Fe||(await j(),await Promise.all(L))}),R&&(Dt.paused=R),Dt}Wt();De();function Re(n){return{describeKind:"producer",...n}}function ro(n,e){let{parse:t,closeOnTeardown:r=!1,...o}=e??{};return A(s=>{let i=!0,a,u=()=>{let y=a;a=void 0,y?.()},d=y=>{i&&(i=!1,s.down([y]),u())},c=(y,b=y)=>{if(i)try{let v=y!==null&&typeof y=="object"&&"data"in y?y.data:y,T=t?t(v,b):v;s.emit(T)}catch(v){d([S,v])}},l=y=>{d([S,y])},f=()=>{d([N])};if(typeof n=="function"){try{if(a=n(c,l,f),typeof a!="function")throw new Error("fromWebSocket register contract violation: register must return cleanup callable")}catch(y){d([S,y])}return()=>{i=!1,u()}}let p=n,h=y=>c(y,y),g=y=>l(y),m=()=>f();return p.addEventListener("message",h),p.addEventListener("error",g),p.addEventListener("close",m),a=()=>{p.removeEventListener("message",h),p.removeEventListener("error",g),p.removeEventListener("close",m),r&&p.close()},()=>{i=!1,u()}},Re(o))}function Ti(n,e){return at(n,e)}function oo(n,e){let{method:t="GET",headers:r,body:o,transform:s=v=>v.json(),timeoutNs:i=30*1e9,signal:a,completeAfterFetch:u=!1,refetchOnSubscribe:d=!1,...c}=e??{},l=F(0,{name:`${c.name??"http"}/fetchCount`}),f=F(0,{name:`${c.name??"http"}/lastUpdated`}),p=F(!1,{name:`${c.name??"http"}/fetched`}),h=0,g=o!==void 0?typeof o=="string"?o:JSON.stringify(o):void 0,m=v=>{let T=new AbortController,w=!0;if(a?.aborted)return w=!1,v.down([[S,a.reason??new Error("Aborted")]]),()=>{};a?.addEventListener("abort",()=>T.abort(a.reason),{once:!0});let _=setTimeout(()=>T.abort(new Error("Request timeout")),Math.ceil(i/1e6));return fetch(n,{method:t,headers:r,body:g,signal:T.signal}).then(async k=>{if(clearTimeout(_),!w)return;if(!k.ok)throw new Error(`HTTP ${k.status}: ${k.statusText}`);let E=await s(k);w&&($(()=>{h+=1,l.down([[x,h]]),f.down([[x,te()]]),p.down([[x,!0]]),v.emit(E)}),u&&v.down([[N]]))}).catch(k=>{clearTimeout(_),w&&(k&&k.name==="AbortError"||v.down([[S,k]]))}),()=>{w=!1,T.abort()}},y=A(v=>m({emit:T=>v.emit(T),down:T=>v.down(T)}),{...Re(c),resubscribable:d});return{...St(y),fetchCount:l,lastUpdated:f,fetched:p}}function wi(n,e,t){let{method:r="POST",headers:o={"Content-Type":"application/json"},serialize:s=h=>JSON.stringify(h),timeoutNs:i,batchFormat:a="json-array",batchSize:u,flushIntervalMs:d,retry:c,onTransportError:l}=t??{},f=async h=>{let g=i!==void 0?new AbortController:void 0,m;g&&i!==void 0&&(m=setTimeout(()=>g.abort(new Error("Request timeout")),Math.ceil(i/1e6)));try{let y=await fetch(e,{method:r,headers:o,body:h,signal:g?.signal}),b=async()=>{try{await y.arrayBuffer?.()}catch{}};if(!y.ok)throw await b(),new Error(`HTTP ${y.status}: ${y.statusText}`);await b()}finally{m!==void 0&&clearTimeout(m)}};return u!==void 0||d!==void 0?ae(n,{onTransportError:l,retry:c,batchSize:u,flushIntervalMs:d,sendBatch:async h=>{let g;a==="ndjson"?g=h.map(m=>{let y=s(m);return typeof y=="string"?y:new TextDecoder().decode(y)}).join(`
2
+ `):g=JSON.stringify(h),await f(g)}}):ae(n,{onTransportError:l,retry:c,serialize:s,send:async h=>{await f(h)}})}function so(n){return Symbol.keyFor(n)??n.description??"message"}function lt(n,e){return typeof n=="string"?n:e(n)}function io(n,e){let t=`event: ${n}
3
+ `;if(e!==void 0){let r=e.split(/\r?\n/);for(let o of r)t+=`data: ${o}
4
4
  `}return`${t}
5
- `}function Ti(n,e){let{serialize:t=f=>{if(f instanceof Error)return f.message;try{return JSON.stringify(f)}catch{return String(f)}},dataEvent:r="data",errorEvent:s="error",completeEvent:o="complete",includeResolved:i=!1,includeDirty:a=!1,keepAliveMs:u,signal:d,eventNameResolver:c=oo}=e??{},l=new TextEncoder,p;return new ReadableStream({start(f){let h=!1,g,m=()=>{},y=()=>{h||(h=!0,g!==void 0&&clearInterval(g),d?.removeEventListener("abort",v),m(),f.close())};p=y;let b=(T,k)=>{h||f.enqueue(l.encode(so(T,k)))},v=()=>{h||y()};m=n.subscribe(T=>{for(let k of T){let _=k[0];if(!(me.isLocalOnly(_)&&!(_===V&&a))){if(_===x){b(r,lt(k[1],t));continue}if(_===S){b(s,lt(k[1],t)),y();return}if(_===N){b(o),y();return}!i&&_===C||b(c(_),k.length>1?lt(k[1],t):void 0)}}}),u!==void 0&&u>0&&(g=setInterval(()=>{h||f.enqueue(l.encode(`: keepalive
5
+ `}function ki(n,e){let{serialize:t=p=>{if(p instanceof Error)return p.message;try{return JSON.stringify(p)}catch{return String(p)}},dataEvent:r="data",errorEvent:o="error",completeEvent:s="complete",includeResolved:i=!1,includeDirty:a=!1,keepAliveMs:u,signal:d,eventNameResolver:c=so}=e??{},l=new TextEncoder,f;return new ReadableStream({start(p){let h=!1,g,m=()=>{},y=()=>{h||(h=!0,g!==void 0&&clearInterval(g),d?.removeEventListener("abort",v),m(),p.close())};f=y;let b=(T,w)=>{h||p.enqueue(l.encode(io(T,w)))},v=()=>{h||y()};m=n.subscribe(T=>{for(let w of T){let _=w[0];if(!(me.isLocalOnly(_)&&!(_===V&&a))){if(_===x){b(r,lt(w[1],t));continue}if(_===S){b(o,lt(w[1],t)),y();return}if(_===N){b(s),y();return}!i&&_===C||b(c(_),w.length>1?lt(w[1],t):void 0)}}}),u!==void 0&&u>0&&(g=setInterval(()=>{h||p.enqueue(l.encode(`: keepalive
6
6
 
7
- `))},u)),d?.aborted?v():d?.addEventListener("abort",v,{once:!0})},cancel(){p?.()}})}function wi(n,e){let{serialize:t=p=>{if(p instanceof Error)return p.message;try{return JSON.stringify(p)}catch{return String(p)}},dataEvent:r="data",errorEvent:s="error",completeEvent:o="complete",includeResolved:i=!1,includeDirty:a=!1,keepAliveMs:u,signal:d,eventNameResolver:c=oo}=e??{},l=new TextEncoder;return A(p=>{let f=!0,h,g=(b,v)=>{f&&p.emit(l.encode(so(b,v)))},m=()=>{f&&(f=!1,p.down([[N]]))},y=n.subscribe(b=>{if(f)for(let v of b){let T=v[0];if(!(me.isLocalOnly(T)&&!(T===V&&a))){if(T===x){g(r,lt(v[1],t));continue}if(T===S){g(s,lt(v[1],t)),f=!1,p.down([[N]]);return}if(T===N){g(o),f=!1,p.down([[N]]);return}!i&&T===C||g(c(T),v.length>1?lt(v[1],t):void 0)}}});return u!==void 0&&u>0&&(h=setInterval(()=>{f&&p.emit(l.encode(`: keepalive
7
+ `))},u)),d?.aborted?v():d?.addEventListener("abort",v,{once:!0})},cancel(){f?.()}})}function xi(n,e){let{serialize:t=f=>{if(f instanceof Error)return f.message;try{return JSON.stringify(f)}catch{return String(f)}},dataEvent:r="data",errorEvent:o="error",completeEvent:s="complete",includeResolved:i=!1,includeDirty:a=!1,keepAliveMs:u,signal:d,eventNameResolver:c=so}=e??{},l=new TextEncoder;return A(f=>{let p=!0,h,g=(b,v)=>{p&&f.emit(l.encode(io(b,v)))},m=()=>{p&&(p=!1,f.down([[N]]))},y=n.subscribe(b=>{if(p)for(let v of b){let T=v[0];if(!(me.isLocalOnly(T)&&!(T===V&&a))){if(T===x){g(r,lt(v[1],t));continue}if(T===S){g(o,lt(v[1],t)),p=!1,f.down([[N]]);return}if(T===N){g(s),p=!1,f.down([[N]]);return}!i&&T===C||g(c(T),v.length>1?lt(v[1],t):void 0)}}});return u!==void 0&&u>0&&(h=setInterval(()=>{p&&f.emit(l.encode(`: keepalive
8
8
 
9
- `))},u)),d?.aborted?m():d?.addEventListener("abort",m,{once:!0}),()=>{f=!1,h!==void 0&&clearInterval(h),d?.removeEventListener("abort",m),y()}})}function ki(n){let e,t=!1;return new ReadableStream({start(r){e=n.subscribe(s=>{for(let o of s){let i=o[0];if(t)return;if(i===x)try{r.enqueue(o[1])}catch{t=!0,e?.()}else if(i===S){t=!0;try{r.error(o[1])}catch{}return}else if(i===N){t=!0;try{r.close()}catch{}return}}})},cancel(){t=!0,e?.()}})}async function*io(n,e){let t=e?.parse??(k=>k),r=e?.signal,s=new TextDecoder,o="",i="message",a=[],u,d,c=[],l=()=>{if(a.length===0&&i==="message"&&u===void 0){a=[];return}let k=a.join(`
10
- `);c.push({event:i,data:t(k),id:u,retry:d}),i="message",a=[],u=void 0,d=void 0},p=k=>{if(k===""){l();return}if(k.startsWith(":"))return;let _=k.indexOf(":"),w=_<0?k:k.slice(0,_),E=_<0?"":k.slice(_+1);switch(E.startsWith(" ")&&(E=E.slice(1)),w){case"event":i=E;break;case"data":a.push(E);break;case"id":E.includes("\0")||(u=E);break;case"retry":{let R=Number(E);Number.isFinite(R)&&(d=R);break}}},f=(k,_)=>{o+=s.decode(k,{stream:!_});let w=o.split(/\r?\n/);o=w.pop()??"";for(let E of w)p(E)},h=n,g=n instanceof ReadableStream?n:h&&typeof h=="object"&&h.body instanceof ReadableStream?h.body:null,m,y,b=!1,v=()=>{b||(b=!0,m&&m.cancel().catch(()=>{}),y&&typeof y.return=="function"&&Promise.resolve(y.return()).catch(()=>{}))},T=()=>{v()};if(r){if(r.aborted)return;r.addEventListener("abort",T,{once:!0})}try{if(g){for(m=g.getReader();!r?.aborted;){let{value:k,done:_}=await m.read();if(_)break;for(f(k,!1);c.length>0;)yield c.shift()}f(new Uint8Array,!0)}else{for(y=n[Symbol.asyncIterator]();!r?.aborted;){let _=await y.next();if(_.done)break;for(f(_.value,!1);c.length>0;)yield c.shift()}f(new Uint8Array,!0)}if(o.trim()){for(let k of o.split(/\r?\n/))p(k);l()}for(;c.length>0;)yield c.shift()}finally{r&&r.removeEventListener("abort",T),v()}}function xi(n,e){let{parse:t,...r}=e??{};return A(s=>{let o=!0,i=new AbortController;return(async()=>{try{for await(let u of io(n,{parse:t,signal:i.signal})){if(!o)return;s.emit(u)}o&&s.down([[N]])}catch(u){o&&s.down([[S,u]])}})(),()=>{o=!1,i.abort()}},Re(r))}function Ni(n,e){let{method:t="GET",headers:r,body:s,signal:o,...i}=e??{};return A(a=>{let u=!0,d=new AbortController;if(o?.aborted)return a.down([[S,o.reason??new Error("Aborted")]]),()=>{};o?.addEventListener("abort",()=>d.abort(o.reason),{once:!0});let c=s!==void 0?typeof s=="string"?s:JSON.stringify(s):void 0;return(async()=>{try{let p=await fetch(n,{method:t,headers:r,body:c,signal:d.signal});if(!u)return;if(!p.ok)throw new Error(`HTTP ${p.status}: ${p.statusText}`);if(!p.body)throw new Error("HTTP response has no body");let f=p.body.getReader();for(;u;){let{value:h,done:g}=await f.read();if(g)break;h&&a.emit(h)}u&&a.down([[N]])}catch(p){if(!u||p&&p.name==="AbortError")return;a.down([[S,p]])}})(),()=>{u=!1,d.abort()}},Re(i))}function _i(n,e){let{intervalMs:t=5e3,...r}=e??{};return Be(qe(t,{period:t}),()=>ro(n,{...r,completeAfterFetch:!0}).node)}function Si(n,e,t){let{serialize:r=y=>{if(typeof y=="string"||y instanceof Blob||y instanceof ArrayBuffer||ArrayBuffer.isView(y))return y;try{return JSON.stringify(y)}catch{return String(y)}},closeOnComplete:s=!0,closeOnError:o=!0,closeCode:i,closeReason:a,onTransportError:u,retry:d,backpressure:c,stopOn:l}=t??{},p=!1,f=y=>{if(!p){p=!0;try{e.close(i,a)}catch(b){let v=b instanceof Error?b:new Error(String(b));try{u?.({stage:"close",error:v,value:void 0,message:y})}catch{}}}},h=null,m=ae(n,{onTransportError:u,serialize:y=>{let b=r(y);if(b===void 0)throw new Error("serialize returned undefined");return b},retry:d,backpressure:c,stopOn:l,onDispose:()=>{if(h){try{e.removeEventListener("close",h)}catch{}h=null}},send:y=>{e.send(y)},onUpstreamMessage:y=>{(y[0]===N&&s||y[0]===S&&o)&&f(y)}});return h=()=>{p=!0,m.dispose()},e.addEventListener("close",h),m}function Ei(n,e){let{parse:t,maxRetries:r,backoff:s="exponential",closeOnTeardown:o=!0,...i}=e??{};return _t(()=>no(n(),{parse:t,closeOnTeardown:o,...i}),{count:r,backoff:s})}function Oi(n,e){let{method:t="notifications/message",onDisconnect:r,...s}=e??{};return at(({emit:o,error:i})=>(n.setNotificationHandler(t,a=>o(a)),r?.(a=>i(a??new Error("MCP client disconnected"))),()=>n.setNotificationHandler(t,()=>{})),s)}function Ri(n,e){return An(({traces:r,metrics:s,logs:o,error:i})=>n({onTraces:a=>{$(()=>{for(let u of a)r(u)})},onMetrics:a=>{$(()=>{for(let u of a)s(u)})},onLogs:a=>{$(()=>{for(let u of a)o(u)})},onError:i})??void 0,["traces","metrics","logs"],e?.name?{name:e.name}:void 0)}function Mi(n,e){return at(n,e)}function Ai(n){let e=n.match(/^<(\d{1,3})>\d?\s*(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s*(.*)/s);if(!e){let r=te();return{facility:1,severity:6,timestamp:new Date(Math.floor(r/1e6)).toISOString(),hostname:"-",appName:"-",procId:"-",msgId:"-",message:n.trim(),timestampNs:r}}let t=Number(e[1]);return{facility:t>>3,severity:t&7,timestamp:e[2],hostname:e[3],appName:e[4],procId:e[5],msgId:e[6],message:(e[7]??"").trim(),timestampNs:te()}}function Ci(n,e){return at(n,e)}var Pi={c:"counter",g:"gauge",ms:"timer",h:"histogram",s:"set",d:"distribution"};function Di(n){let e=n.split("|"),[t,r]=(e[0]??"").split(":");if(!t||r===void 0)throw new Error(`Invalid StatsD line: ${n}`);let s=e[1]?.trim()??"c",o=Pi[s]??"counter",i=o==="set"?0:Number(r),a,u={};for(let d=2;d<e.length;d++){let c=e[d].trim();if(c.startsWith("@"))a=Number(c.slice(1));else if(c.startsWith("#"))for(let l of c.slice(1).split(",")){let[p,f]=l.split(":");p&&(u[p]=f??"")}}return{name:t.trim(),value:i,type:o,sampleRate:a,tags:u,timestampNs:te()}}function Ii(n,e){let{intervalNs:t=15*1e9,headers:r,timeoutNs:s=10*1e9,signal:o,maxConsecutiveErrors:i=1}=e??{},a=Math.ceil(t/1e6),u=0;return Be(qe(0,{period:a,signal:o}),()=>A(d=>{let c=!0,l=new AbortController,p=setTimeout(()=>l.abort(new Error("Scrape timeout")),Math.ceil(s/1e6));return(async()=>{try{let h=await fetch(n,{headers:{Accept:"text/plain",...r},signal:l.signal});if(clearTimeout(p),!c)return;if(!h.ok)throw new Error(`Prometheus scrape ${h.status}: ${h.statusText}`);let g=await h.text();if(!c)return;let m=ao(g);for(let y of m)d.emit(y);u=0,d.down([[N]])}catch(h){if(clearTimeout(p),!c||h instanceof Error&&h.name==="AbortError")return;u+=1,u>=i&&d.down([[S,h]])}})(),()=>{c=!1,clearTimeout(p),l.abort()}}))}function ao(n){let e=[],t=new Map,r=new Map;for(let s of n.split(`
11
- `)){let o=s.trim();if(!o)continue;if(o.startsWith("# TYPE ")){let p=o.slice(7),f=p.indexOf(" ");f>0&&t.set(p.slice(0,f),p.slice(f+1).trim());continue}if(o.startsWith("# HELP ")){let p=o.slice(7),f=p.indexOf(" ");f>0&&r.set(p.slice(0,f),p.slice(f+1).trim());continue}if(o.startsWith("#"))continue;let i,a={},u,d,c=o.indexOf("{");if(c>=0){i=o.slice(0,c);let p=o.indexOf("}",c);if(p<0)continue;let f=o.slice(c+1,p);a=Li(f);let h=o.slice(p+1).trim().split(/\s+/);u=h[0]??"",d=h[1]}else{let p=o.split(/\s+/);i=p[0]??"",u=p[1]??"",d=p[2]}if(!i||!u)continue;let l=i.replace(/(_total|_count|_sum|_bucket|_created|_info)$/,"");e.push({name:i,labels:a,value:Number(u),timestampMs:d?Number(d):void 0,type:t.get(l)??t.get(i),help:r.get(l)??r.get(i),timestampNs:te()})}return e}function Li(n){let e={},t=/(\w+)="((?:[^"\\]|\\.)*)"/g,r=t.exec(n);for(;r!==null;)e[r[1]]=r[2].replace(/\\(.)/g,"$1"),r=t.exec(n);return e}function Bi(n,e,t){let{fromBeginning:r=!1,deserialize:s=i=>{if(i===null)return null;try{return JSON.parse(i.toString())}catch{return i.toString()}},...o}=t??{};return A(i=>{let a=!0;return(async()=>{try{await n.subscribe({topic:e,fromBeginning:r}),await n.run({eachMessage:async({topic:d,partition:c,message:l})=>{if(!a)return;let p={};if(l.headers)for(let[f,h]of Object.entries(l.headers))h!==void 0&&(p[f]=typeof h=="string"?h:h.toString());i.emit({topic:d,partition:c,key:l.key?.toString()??null,value:s(l.value),headers:p,offset:l.offset,timestamp:l.timestamp,timestampNs:te()})}})}catch(d){a&&i.down([[S,d]])}})(),()=>{a=!1}},Re(o))}function Vi(n,e,t,r){let{serialize:s=a=>JSON.stringify(a),keyExtractor:o,onTransportError:i}=r??{};return ae(n,{onTransportError:i,send:async a=>{let u=o?.(a)??null,d=s(a);await e.send({topic:t,messages:[{key:u,value:Buffer.from(d)}]})}})}function Fi(n,e,t){let{blockMs:r=5e3,startId:s="$",parse:o=a=>{for(let d=0;d<a.length;d+=2)if(a[d]==="data")try{return JSON.parse(a[d+1])}catch{return a[d+1]}let u={};for(let d=0;d<a.length;d+=2)u[a[d]]=a[d+1];return u},...i}=t??{};return A(a=>{let u=!0,d=s;return(async()=>{for(;u;)try{let l=await n.xread("BLOCK",r,"STREAMS",e,d);if(!u)return;if(l)for(let[p,f]of l)for(let[h,g]of f)d=h,a.emit({id:h,key:e,data:o(g),timestampNs:te()})}catch(l){if(!u)return;a.down([[S,l]]);return}})(),()=>{u=!1}},Re(i))}function Gi(n,e,t,r){let{serialize:s=a=>["data",JSON.stringify(a)],maxLen:o,onTransportError:i}=r??{};return ae(n,{onTransportError:i,send:async a=>{let u=s(a);await(o!==void 0?e.xadd(t,"MAXLEN","~",String(o),"*",...u):e.xadd(t,"*",...u))}})}function Ki(n,e){let{delimiter:t=",",hasHeader:r=!0,columns:s,parseLine:o,...i}=e??{},a=o??(u=>uo(u,t));return A(u=>{let d=!1;return(async()=>{try{let l=s,p="";for await(let f of n){if(d)return;p+=f;let h=p.split(/\r?\n/);p=h.pop()??"";for(let g of h){if(d)return;if(!g.trim())continue;let m=a(g);if(!l&&r){l=m;continue}l||(l=m.map((b,v)=>`col${v}`));let y={};for(let b=0;b<l.length;b++)y[l[b]]=m[b]??"";u.emit(y)}}if(!d&&p.trim()){let f=a(p);if(l){let h={};for(let g=0;g<l.length;g++)h[l[g]]=f[g]??"";u.emit(h)}}d||u.down([[N]])}catch(l){d||u.down([[S,l]])}})(),()=>{d=!0}},Re(i))}function zi(n,e){let{delimiter:t=",",hasHeader:r=!0,columns:s,parseLine:o,...i}=e??{},a=o??(u=>uo(u,t));return B([n],(u,d,c)=>{let l=u[0];if(l==null||l.length===0)return;let p=c.store;typeof p.buffer!="string"&&(p.buffer=""),p.headers===void 0&&s&&(p.headers=s.slice());for(let f of l){p.buffer=p.buffer+f;let h=p.buffer.split(/\r?\n/);p.buffer=h.pop()??"";for(let g of h){if(!g.trim())continue;let m=a(g);if(!p.headers&&r){p.headers=m;continue}p.headers||(p.headers=m.map((b,v)=>`col${v}`));let y={};for(let b=0;b<p.headers.length;b++)y[p.headers[b]]=m[b]??"";d.emit(y)}}},{describeKind:"derived",...i})}function $i(n,e){return B([n],(t,r,s)=>{let o=t[0];if(o==null||o.length===0)return;let i=s.store;typeof i.buffer!="string"&&(i.buffer="");for(let a of o){i.buffer=i.buffer+a;let u=i.buffer.split(/\r?\n/);i.buffer=u.pop()??"";for(let d of u)if(d.trim())try{r.emit(JSON.parse(d))}catch(c){r.down([[S,c]]);return}}},{describeKind:"derived",...e??{}})}function uo(n,e){let t=[],r="",s=!1;for(let o=0;o<n.length;o++){let i=n[o];s?i==='"'?n[o+1]==='"'?(r+='"',o++):s=!1:r+=i:i==='"'?s=!0:i===e?(t.push(r),r=""):r+=i}return t.push(r),t}function ji(n,e){return A(t=>{let r=!1;return(async()=>{try{let o="";for await(let i of n){if(r)return;o+=i;let a=o.split(/\r?\n/);o=a.pop()??"";for(let u of a){if(r)return;let d=u.trim();d&&t.emit(JSON.parse(d))}}!r&&o.trim()&&t.emit(JSON.parse(o.trim())),r||t.down([[N]])}catch(o){r||t.down([[S,o]])}})(),()=>{r=!0}},Re(e))}function Ui(n,e,t){let{intervalNs:r=5*1e9,format:s="JSONEachRow",signal:o,maxConsecutiveErrors:i=1}=t??{},a=Math.ceil(r/1e6),u=0;return Be(qe(0,{period:a,signal:o}),()=>A(d=>{let c=!0;return(async()=>{try{let p=await n.query({query:e,format:s});if(!c)return;let f=await p.json();if(!c)return;for(let h of f)d.emit(h);u=0,d.down([[N]])}catch(p){if(!c)return;u+=1,u>=i&&d.down([[S,p]])}})(),()=>{c=!1}}))}function Wi(n,e){let{autoAck:t=!0,deserialize:r=a=>{try{return JSON.parse(a.toString())}catch{return a.toString()}},onAckError:s,...o}=e??{},i=a=>{if(s)try{s(a instanceof Error?a:new Error(String(a)))}catch{}};return A(a=>{let u=!0;return(async()=>{for(;u;)try{let c=await n.receive();if(!u)return;let l={topic:c.getTopicName(),messageId:c.getMessageId().toString(),key:c.getPartitionKey(),value:r(c.getData()),properties:c.getProperties(),publishTime:c.getPublishTimestamp(),eventTime:c.getEventTimestamp(),timestampNs:te()};if(t)a.emit(l),n.acknowledge(c).catch(i);else{let p=!1,f={value:l,ack(){p||(p=!0,n.acknowledge(c).catch(i))},nack(h){if(p)return;p=!0;let g=n;try{let m=g.negativeAcknowledge?.(c);m&&typeof m.then=="function"&&m.catch(i)}catch(m){i(m)}}};a.emit(f)}}catch(c){u&&a.down([[S,c]]);return}})(),()=>{u=!1}},Re(o))}function Hi(n,e,t){let{serialize:r=a=>Buffer.from(JSON.stringify(a)),keyExtractor:s,propertiesExtractor:o,onTransportError:i}=t??{};return ae(n,{onTransportError:i,send:async a=>{await e.send({data:r(a),partitionKey:s?.(a),properties:o?.(a)})}})}function qi(n,e,t){let r=new TextDecoder,{queue:s,deserialize:o=a=>{let u=r.decode(a);try{return JSON.parse(u)}catch{return u}},...i}=t??{};return A(a=>{let u=!0,d=n.subscribe(e,s?{queue:s}:void 0);return(async()=>{try{for await(let l of d){if(!u)return;let p={};if(l.headers)for(let f of l.headers.keys())p[f]=l.headers.get(f);a.emit({subject:l.subject,data:o(l.data),headers:p,reply:l.reply,sid:l.sid,timestampNs:te()})}u&&a.down([[N]])}catch(l){u&&a.down([[S,l]])}})(),()=>{u=!1}},Re(i))}function Ji(n,e,t,r){let s=new TextEncoder,{serialize:o=a=>s.encode(JSON.stringify(a)),onTransportError:i}=r??{};return ae(n,{onTransportError:i,send:a=>{e.publish(t,o(a))}})}function Yi(n,e,t){let{autoAck:r=!0,deserialize:s=u=>{try{return JSON.parse(u.toString())}catch{return u.toString()}},onAckError:o,...i}=t??{},a=u=>{if(o)try{o(u instanceof Error?u:new Error(String(u)))}catch{}};return A(u=>{let d=!0,c;return(async()=>{try{c=(await n.consume(e,f=>{if(!d)return;if(f===null){d&&u.down([[S,new Error("Consumer cancelled by broker")]]);return}let h={queue:e,routingKey:f.fields.routingKey,exchange:f.fields.exchange,content:s(f.content),properties:f.properties,deliveryTag:f.fields.deliveryTag,redelivered:f.fields.redelivered,timestampNs:te()};if(r){u.emit(h);try{n.ack(f)}catch(g){a(g)}}else{let g=!1,m=n,y={value:h,ack(){if(!g){g=!0;try{n.ack(f)}catch(b){a(b)}}},nack(b){if(g)return;g=!0;let v=b?.requeue;if(!m.nack){a(new Error("RabbitMQ channel does not expose `nack`; cannot negative-ack"));return}try{m.nack(f,!1,v)}catch(T){a(T)}}};u.emit(y)}},{noAck:!1})).consumerTag}catch(p){d&&u.down([[S,p]])}})(),()=>{d=!1,c!==void 0&&n.cancel(c)}},Re(i))}function Qi(n,e,t,r){let{serialize:s=a=>Buffer.from(JSON.stringify(a)),routingKeyExtractor:o=()=>"",onTransportError:i}=r??{};return ae(n,{onTransportError:i,send:a=>{let u=o(a),d=s(a);e.publish(t,u,d)}})}function co(n,e,t){let{serialize:r=l=>`${JSON.stringify(l)}
12
- `,flushIntervalMs:s=0,batchSize:o=Number.POSITIVE_INFINITY,onTransportError:i,mode:a}=t??{},d=s>0||o<Number.POSITIVE_INFINITY?ae(n,{onTransportError:i,batchSize:o,flushIntervalMs:s,serialize:r,sendBatch:l=>{e.write(l.join(""))}}):ae(n,{onTransportError:i,serialize:r,send:l=>{e.write(l)}}),c=d.dispose;return d.dispose=()=>{c();try{e.end()}catch{}},d}function Zn(n,e){return n.includes(e)||n.includes('"')||n.includes(`
13
- `)?`"${n.replace(/"/g,'""')}"`:n}function Xi(n,e,t){let{columns:r,delimiter:s=",",writeHeader:o=!0,cellExtractor:i=(f,h)=>String(f[h]??""),flushIntervalMs:a=0,batchSize:u=Number.POSITIVE_INFINITY,onTransportError:d,...c}=t,l=!1;return co(n,e,{serialize:f=>{if(!l&&o){l=!0;let h=r.map(m=>Zn(m,s)).join(s),g=r.map(m=>Zn(i(f,m),s)).join(s);return`${h}
9
+ `))},u)),d?.aborted?m():d?.addEventListener("abort",m,{once:!0}),()=>{p=!1,h!==void 0&&clearInterval(h),d?.removeEventListener("abort",m),y()}})}function Ni(n){let e,t=!1;return new ReadableStream({start(r){e=n.subscribe(o=>{for(let s of o){let i=s[0];if(t)return;if(i===x)try{r.enqueue(s[1])}catch{t=!0,e?.()}else if(i===S){t=!0;try{r.error(s[1])}catch{}return}else if(i===N){t=!0;try{r.close()}catch{}return}}})},cancel(){t=!0,e?.()}})}async function*ao(n,e){let t=e?.parse??(w=>w),r=e?.signal,o=new TextDecoder,s="",i="message",a=[],u,d,c=[],l=()=>{if(a.length===0&&i==="message"&&u===void 0){a=[];return}let w=a.join(`
10
+ `);c.push({event:i,data:t(w),id:u,retry:d}),i="message",a=[],u=void 0,d=void 0},f=w=>{if(w===""){l();return}if(w.startsWith(":"))return;let _=w.indexOf(":"),k=_<0?w:w.slice(0,_),E=_<0?"":w.slice(_+1);switch(E.startsWith(" ")&&(E=E.slice(1)),k){case"event":i=E;break;case"data":a.push(E);break;case"id":E.includes("\0")||(u=E);break;case"retry":{let O=Number(E);Number.isFinite(O)&&(d=O);break}}},p=(w,_)=>{s+=o.decode(w,{stream:!_});let k=s.split(/\r?\n/);s=k.pop()??"";for(let E of k)f(E)},h=n,g=n instanceof ReadableStream?n:h&&typeof h=="object"&&h.body instanceof ReadableStream?h.body:null,m,y,b=!1,v=()=>{b||(b=!0,m&&m.cancel().catch(()=>{}),y&&typeof y.return=="function"&&Promise.resolve(y.return()).catch(()=>{}))},T=()=>{v()};if(r){if(r.aborted)return;r.addEventListener("abort",T,{once:!0})}try{if(g){for(m=g.getReader();!r?.aborted;){let{value:w,done:_}=await m.read();if(_)break;for(p(w,!1);c.length>0;)yield c.shift()}p(new Uint8Array,!0)}else{for(y=n[Symbol.asyncIterator]();!r?.aborted;){let _=await y.next();if(_.done)break;for(p(_.value,!1);c.length>0;)yield c.shift()}p(new Uint8Array,!0)}if(s.trim()){for(let w of s.split(/\r?\n/))f(w);l()}for(;c.length>0;)yield c.shift()}finally{r&&r.removeEventListener("abort",T),v()}}function _i(n,e){let{parse:t,...r}=e??{};return A(o=>{let s=!0,i=new AbortController;return(async()=>{try{for await(let u of ao(n,{parse:t,signal:i.signal})){if(!s)return;o.emit(u)}s&&o.down([[N]])}catch(u){s&&o.down([[S,u]])}})(),()=>{s=!1,i.abort()}},Re(r))}function Si(n,e){let{method:t="GET",headers:r,body:o,signal:s,...i}=e??{};return A(a=>{let u=!0,d=new AbortController;if(s?.aborted)return a.down([[S,s.reason??new Error("Aborted")]]),()=>{};s?.addEventListener("abort",()=>d.abort(s.reason),{once:!0});let c=o!==void 0?typeof o=="string"?o:JSON.stringify(o):void 0;return(async()=>{try{let f=await fetch(n,{method:t,headers:r,body:c,signal:d.signal});if(!u)return;if(!f.ok)throw new Error(`HTTP ${f.status}: ${f.statusText}`);if(!f.body)throw new Error("HTTP response has no body");let p=f.body.getReader();for(;u;){let{value:h,done:g}=await p.read();if(g)break;h&&a.emit(h)}u&&a.down([[N]])}catch(f){if(!u||f&&f.name==="AbortError")return;a.down([[S,f]])}})(),()=>{u=!1,d.abort()}},Re(i))}function Ei(n,e){let{intervalMs:t=5e3,...r}=e??{};return Be(qe(t,{period:t}),()=>oo(n,{...r,completeAfterFetch:!0}).node)}function Oi(n,e,t){let{serialize:r=y=>{if(typeof y=="string"||y instanceof Blob||y instanceof ArrayBuffer||ArrayBuffer.isView(y))return y;try{return JSON.stringify(y)}catch{return String(y)}},closeOnComplete:o=!0,closeOnError:s=!0,closeCode:i,closeReason:a,onTransportError:u,retry:d,backpressure:c,stopOn:l}=t??{},f=!1,p=y=>{if(!f){f=!0;try{e.close(i,a)}catch(b){let v=b instanceof Error?b:new Error(String(b));try{u?.({stage:"close",error:v,value:void 0,message:y})}catch{}}}},h=null,m=ae(n,{onTransportError:u,serialize:y=>{let b=r(y);if(b===void 0)throw new Error("serialize returned undefined");return b},retry:d,backpressure:c,stopOn:l,onDispose:()=>{if(h){try{e.removeEventListener("close",h)}catch{}h=null}},send:y=>{e.send(y)},onUpstreamMessage:y=>{(y[0]===N&&o||y[0]===S&&s)&&p(y)}});return h=()=>{f=!0,m.dispose()},e.addEventListener("close",h),m}function Ri(n,e){let{parse:t,maxRetries:r,backoff:o="exponential",closeOnTeardown:s=!0,...i}=e??{};return _t(()=>ro(n(),{parse:t,closeOnTeardown:s,...i}),{count:r,backoff:o})}function Mi(n,e){let{method:t="notifications/message",onDisconnect:r,...o}=e??{};return at(({emit:s,error:i})=>(n.setNotificationHandler(t,a=>s(a)),r?.(a=>i(a??new Error("MCP client disconnected"))),()=>n.setNotificationHandler(t,()=>{})),o)}function Ai(n,e){return Cn(({traces:r,metrics:o,logs:s,error:i})=>n({onTraces:a=>{$(()=>{for(let u of a)r(u)})},onMetrics:a=>{$(()=>{for(let u of a)o(u)})},onLogs:a=>{$(()=>{for(let u of a)s(u)})},onError:i})??void 0,["traces","metrics","logs"],e?.name?{name:e.name}:void 0)}function Ci(n,e){return at(n,e)}function Pi(n){let e=n.match(/^<(\d{1,3})>\d?\s*(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s*(.*)/s);if(!e){let r=te();return{facility:1,severity:6,timestamp:new Date(Math.floor(r/1e6)).toISOString(),hostname:"-",appName:"-",procId:"-",msgId:"-",message:n.trim(),timestampNs:r}}let t=Number(e[1]);return{facility:t>>3,severity:t&7,timestamp:e[2],hostname:e[3],appName:e[4],procId:e[5],msgId:e[6],message:(e[7]??"").trim(),timestampNs:te()}}function Di(n,e){return at(n,e)}var Ii={c:"counter",g:"gauge",ms:"timer",h:"histogram",s:"set",d:"distribution"};function Li(n){let e=n.split("|"),[t,r]=(e[0]??"").split(":");if(!t||r===void 0)throw new Error(`Invalid StatsD line: ${n}`);let o=e[1]?.trim()??"c",s=Ii[o]??"counter",i=s==="set"?0:Number(r),a,u={};for(let d=2;d<e.length;d++){let c=e[d].trim();if(c.startsWith("@"))a=Number(c.slice(1));else if(c.startsWith("#"))for(let l of c.slice(1).split(",")){let[f,p]=l.split(":");f&&(u[f]=p??"")}}return{name:t.trim(),value:i,type:s,sampleRate:a,tags:u,timestampNs:te()}}function Bi(n,e){let{intervalNs:t=15*1e9,headers:r,timeoutNs:o=10*1e9,signal:s,maxConsecutiveErrors:i=1}=e??{},a=Math.ceil(t/1e6),u=0;return Be(qe(0,{period:a,signal:s}),()=>A(d=>{let c=!0,l=new AbortController,f=setTimeout(()=>l.abort(new Error("Scrape timeout")),Math.ceil(o/1e6));return(async()=>{try{let h=await fetch(n,{headers:{Accept:"text/plain",...r},signal:l.signal});if(clearTimeout(f),!c)return;if(!h.ok)throw new Error(`Prometheus scrape ${h.status}: ${h.statusText}`);let g=await h.text();if(!c)return;let m=uo(g);for(let y of m)d.emit(y);u=0,d.down([[N]])}catch(h){if(clearTimeout(f),!c||h instanceof Error&&h.name==="AbortError")return;u+=1,u>=i&&d.down([[S,h]])}})(),()=>{c=!1,clearTimeout(f),l.abort()}}))}function uo(n){let e=[],t=new Map,r=new Map;for(let o of n.split(`
11
+ `)){let s=o.trim();if(!s)continue;if(s.startsWith("# TYPE ")){let f=s.slice(7),p=f.indexOf(" ");p>0&&t.set(f.slice(0,p),f.slice(p+1).trim());continue}if(s.startsWith("# HELP ")){let f=s.slice(7),p=f.indexOf(" ");p>0&&r.set(f.slice(0,p),f.slice(p+1).trim());continue}if(s.startsWith("#"))continue;let i,a={},u,d,c=s.indexOf("{");if(c>=0){i=s.slice(0,c);let f=s.indexOf("}",c);if(f<0)continue;let p=s.slice(c+1,f);a=Vi(p);let h=s.slice(f+1).trim().split(/\s+/);u=h[0]??"",d=h[1]}else{let f=s.split(/\s+/);i=f[0]??"",u=f[1]??"",d=f[2]}if(!i||!u)continue;let l=i.replace(/(_total|_count|_sum|_bucket|_created|_info)$/,"");e.push({name:i,labels:a,value:Number(u),timestampMs:d?Number(d):void 0,type:t.get(l)??t.get(i),help:r.get(l)??r.get(i),timestampNs:te()})}return e}function Vi(n){let e={},t=/(\w+)="((?:[^"\\]|\\.)*)"/g,r=t.exec(n);for(;r!==null;)e[r[1]]=r[2].replace(/\\(.)/g,"$1"),r=t.exec(n);return e}function Fi(n,e,t){let{fromBeginning:r=!1,deserialize:o=i=>{if(i===null)return null;try{return JSON.parse(i.toString())}catch{return i.toString()}},...s}=t??{};return A(i=>{let a=!0;return(async()=>{try{await n.subscribe({topic:e,fromBeginning:r}),await n.run({eachMessage:async({topic:d,partition:c,message:l})=>{if(!a)return;let f={};if(l.headers)for(let[p,h]of Object.entries(l.headers))h!==void 0&&(f[p]=typeof h=="string"?h:h.toString());i.emit({topic:d,partition:c,key:l.key?.toString()??null,value:o(l.value),headers:f,offset:l.offset,timestamp:l.timestamp,timestampNs:te()})}})}catch(d){a&&i.down([[S,d]])}})(),()=>{a=!1}},Re(s))}function Gi(n,e,t,r){let{serialize:o=a=>JSON.stringify(a),keyExtractor:s,onTransportError:i}=r??{};return ae(n,{onTransportError:i,send:async a=>{let u=s?.(a)??null,d=o(a);await e.send({topic:t,messages:[{key:u,value:Buffer.from(d)}]})}})}function zi(n,e,t){let{blockMs:r=5e3,startId:o="$",parse:s=a=>{for(let d=0;d<a.length;d+=2)if(a[d]==="data")try{return JSON.parse(a[d+1])}catch{return a[d+1]}let u={};for(let d=0;d<a.length;d+=2)u[a[d]]=a[d+1];return u},...i}=t??{};return A(a=>{let u=!0,d=o;return(async()=>{for(;u;)try{let l=await n.xread("BLOCK",r,"STREAMS",e,d);if(!u)return;if(l)for(let[f,p]of l)for(let[h,g]of p)d=h,a.emit({id:h,key:e,data:s(g),timestampNs:te()})}catch(l){if(!u)return;a.down([[S,l]]);return}})(),()=>{u=!1}},Re(i))}function Ki(n,e,t,r){let{serialize:o=a=>["data",JSON.stringify(a)],maxLen:s,onTransportError:i}=r??{};return ae(n,{onTransportError:i,send:async a=>{let u=o(a);await(s!==void 0?e.xadd(t,"MAXLEN","~",String(s),"*",...u):e.xadd(t,"*",...u))}})}function $i(n,e){let{delimiter:t=",",hasHeader:r=!0,columns:o,parseLine:s,...i}=e??{},a=s??(u=>co(u,t));return A(u=>{let d=!1;return(async()=>{try{let l=o,f="";for await(let p of n){if(d)return;f+=p;let h=f.split(/\r?\n/);f=h.pop()??"";for(let g of h){if(d)return;if(!g.trim())continue;let m=a(g);if(!l&&r){l=m;continue}l||(l=m.map((b,v)=>`col${v}`));let y={};for(let b=0;b<l.length;b++)y[l[b]]=m[b]??"";u.emit(y)}}if(!d&&f.trim()){let p=a(f);if(l){let h={};for(let g=0;g<l.length;g++)h[l[g]]=p[g]??"";u.emit(h)}}d||u.down([[N]])}catch(l){d||u.down([[S,l]])}})(),()=>{d=!0}},Re(i))}function ji(n,e){let{delimiter:t=",",hasHeader:r=!0,columns:o,parseLine:s,...i}=e??{},a=s??(u=>co(u,t));return B([n],(u,d,c)=>{let l=u[0];if(l==null||l.length===0)return;let f=c.store;typeof f.buffer!="string"&&(f.buffer=""),f.headers===void 0&&o&&(f.headers=o.slice());for(let p of l){f.buffer=f.buffer+p;let h=f.buffer.split(/\r?\n/);f.buffer=h.pop()??"";for(let g of h){if(!g.trim())continue;let m=a(g);if(!f.headers&&r){f.headers=m;continue}f.headers||(f.headers=m.map((b,v)=>`col${v}`));let y={};for(let b=0;b<f.headers.length;b++)y[f.headers[b]]=m[b]??"";d.emit(y)}}},{describeKind:"derived",...i})}function Ui(n,e){return B([n],(t,r,o)=>{let s=t[0];if(s==null||s.length===0)return;let i=o.store;typeof i.buffer!="string"&&(i.buffer="");for(let a of s){i.buffer=i.buffer+a;let u=i.buffer.split(/\r?\n/);i.buffer=u.pop()??"";for(let d of u)if(d.trim())try{r.emit(JSON.parse(d))}catch(c){r.down([[S,c]]);return}}},{describeKind:"derived",...e??{}})}function co(n,e){let t=[],r="",o=!1;for(let s=0;s<n.length;s++){let i=n[s];o?i==='"'?n[s+1]==='"'?(r+='"',s++):o=!1:r+=i:i==='"'?o=!0:i===e?(t.push(r),r=""):r+=i}return t.push(r),t}function Wi(n,e){return A(t=>{let r=!1;return(async()=>{try{let s="";for await(let i of n){if(r)return;s+=i;let a=s.split(/\r?\n/);s=a.pop()??"";for(let u of a){if(r)return;let d=u.trim();d&&t.emit(JSON.parse(d))}}!r&&s.trim()&&t.emit(JSON.parse(s.trim())),r||t.down([[N]])}catch(s){r||t.down([[S,s]])}})(),()=>{r=!0}},Re(e))}function Hi(n,e,t){let{intervalNs:r=5*1e9,format:o="JSONEachRow",signal:s,maxConsecutiveErrors:i=1}=t??{},a=Math.ceil(r/1e6),u=0;return Be(qe(0,{period:a,signal:s}),()=>A(d=>{let c=!0;return(async()=>{try{let f=await n.query({query:e,format:o});if(!c)return;let p=await f.json();if(!c)return;for(let h of p)d.emit(h);u=0,d.down([[N]])}catch(f){if(!c)return;u+=1,u>=i&&d.down([[S,f]])}})(),()=>{c=!1}}))}function qi(n,e){let{autoAck:t=!0,deserialize:r=a=>{try{return JSON.parse(a.toString())}catch{return a.toString()}},onAckError:o,...s}=e??{},i=a=>{if(o)try{o(a instanceof Error?a:new Error(String(a)))}catch{}};return A(a=>{let u=!0;return(async()=>{for(;u;)try{let c=await n.receive();if(!u)return;let l={topic:c.getTopicName(),messageId:c.getMessageId().toString(),key:c.getPartitionKey(),value:r(c.getData()),properties:c.getProperties(),publishTime:c.getPublishTimestamp(),eventTime:c.getEventTimestamp(),timestampNs:te()};if(t)a.emit(l),n.acknowledge(c).catch(i);else{let f=!1,p={value:l,ack(){f||(f=!0,n.acknowledge(c).catch(i))},nack(h){if(f)return;f=!0;let g=n;try{let m=g.negativeAcknowledge?.(c);m&&typeof m.then=="function"&&m.catch(i)}catch(m){i(m)}}};a.emit(p)}}catch(c){u&&a.down([[S,c]]);return}})(),()=>{u=!1}},Re(s))}function Ji(n,e,t){let{serialize:r=a=>Buffer.from(JSON.stringify(a)),keyExtractor:o,propertiesExtractor:s,onTransportError:i}=t??{};return ae(n,{onTransportError:i,send:async a=>{await e.send({data:r(a),partitionKey:o?.(a),properties:s?.(a)})}})}function Yi(n,e,t){let r=new TextDecoder,{queue:o,deserialize:s=a=>{let u=r.decode(a);try{return JSON.parse(u)}catch{return u}},...i}=t??{};return A(a=>{let u=!0,d=n.subscribe(e,o?{queue:o}:void 0);return(async()=>{try{for await(let l of d){if(!u)return;let f={};if(l.headers)for(let p of l.headers.keys())f[p]=l.headers.get(p);a.emit({subject:l.subject,data:s(l.data),headers:f,reply:l.reply,sid:l.sid,timestampNs:te()})}u&&a.down([[N]])}catch(l){u&&a.down([[S,l]])}})(),()=>{u=!1}},Re(i))}function Qi(n,e,t,r){let o=new TextEncoder,{serialize:s=a=>o.encode(JSON.stringify(a)),onTransportError:i}=r??{};return ae(n,{onTransportError:i,send:a=>{e.publish(t,s(a))}})}function Xi(n,e,t){let{autoAck:r=!0,deserialize:o=u=>{try{return JSON.parse(u.toString())}catch{return u.toString()}},onAckError:s,...i}=t??{},a=u=>{if(s)try{s(u instanceof Error?u:new Error(String(u)))}catch{}};return A(u=>{let d=!0,c;return(async()=>{try{c=(await n.consume(e,p=>{if(!d)return;if(p===null){d&&u.down([[S,new Error("Consumer cancelled by broker")]]);return}let h={queue:e,routingKey:p.fields.routingKey,exchange:p.fields.exchange,content:o(p.content),properties:p.properties,deliveryTag:p.fields.deliveryTag,redelivered:p.fields.redelivered,timestampNs:te()};if(r){u.emit(h);try{n.ack(p)}catch(g){a(g)}}else{let g=!1,m=n,y={value:h,ack(){if(!g){g=!0;try{n.ack(p)}catch(b){a(b)}}},nack(b){if(g)return;g=!0;let v=b?.requeue;if(!m.nack){a(new Error("RabbitMQ channel does not expose `nack`; cannot negative-ack"));return}try{m.nack(p,!1,v)}catch(T){a(T)}}};u.emit(y)}},{noAck:!1})).consumerTag}catch(f){d&&u.down([[S,f]])}})(),()=>{d=!1,c!==void 0&&n.cancel(c)}},Re(i))}function Zi(n,e,t,r){let{serialize:o=a=>Buffer.from(JSON.stringify(a)),routingKeyExtractor:s=()=>"",onTransportError:i}=r??{};return ae(n,{onTransportError:i,send:a=>{let u=s(a),d=o(a);e.publish(t,u,d)}})}function lo(n,e,t){let{serialize:r=l=>`${JSON.stringify(l)}
12
+ `,flushIntervalMs:o=0,batchSize:s=Number.POSITIVE_INFINITY,onTransportError:i,mode:a}=t??{},d=o>0||s<Number.POSITIVE_INFINITY?ae(n,{onTransportError:i,batchSize:s,flushIntervalMs:o,serialize:r,sendBatch:l=>{e.write(l.join(""))}}):ae(n,{onTransportError:i,serialize:r,send:l=>{e.write(l)}}),c=d.dispose;return d.dispose=()=>{c();try{e.end()}catch{}},d}function er(n,e){return n.includes(e)||n.includes('"')||n.includes(`
13
+ `)?`"${n.replace(/"/g,'""')}"`:n}function ea(n,e,t){let{columns:r,delimiter:o=",",writeHeader:s=!0,cellExtractor:i=(p,h)=>String(p[h]??""),flushIntervalMs:a=0,batchSize:u=Number.POSITIVE_INFINITY,onTransportError:d,...c}=t,l=!1;return lo(n,e,{serialize:p=>{if(!l&&s){l=!0;let h=r.map(m=>er(m,o)).join(o),g=r.map(m=>er(i(p,m),o)).join(o);return`${h}
14
14
  ${g}
15
- `}return`${r.map(h=>Zn(i(f,h),s)).join(s)}
16
- `},flushIntervalMs:a,batchSize:u,onTransportError:d,...c})}function Zi(n,e,t,r){let{batchSize:s=1e3,flushIntervalMs:o=5e3,format:i="JSONEachRow",transform:a=d=>d,onTransportError:u}=r??{};return ae(n,{onTransportError:u,batchSize:s,flushIntervalMs:o,serialize:a,sendBatch:async d=>{await e.insert({table:t,values:d,format:i})}})}function ea(n,e,t,r){let{format:s="ndjson",keyGenerator:o=(p,f)=>{let h=Math.floor(f/1e6);return`data/${new Date(h).toISOString().replace(/[:.]/g,"-")}-${p}.${s==="ndjson"?"ndjson":"json"}`},batchSize:i=1e3,flushIntervalMs:a=1e4,transform:u=p=>p,onTransportError:d}=r??{},c=s==="ndjson"?"application/x-ndjson":"application/json",l=0;return ae(n,{onTransportError:d,batchSize:i,flushIntervalMs:a,serialize:u,sendBatch:async p=>{l+=1;let f=s==="ndjson"?`${p.map(g=>JSON.stringify(g)).join(`
15
+ `}return`${r.map(h=>er(i(p,h),o)).join(o)}
16
+ `},flushIntervalMs:a,batchSize:u,onTransportError:d,...c})}function ta(n,e,t,r){let{batchSize:o=1e3,flushIntervalMs:s=5e3,format:i="JSONEachRow",transform:a=d=>d,onTransportError:u}=r??{};return ae(n,{onTransportError:u,batchSize:o,flushIntervalMs:s,serialize:a,sendBatch:async d=>{await e.insert({table:t,values:d,format:i})}})}function na(n,e,t,r){let{format:o="ndjson",keyGenerator:s=(f,p)=>{let h=Math.floor(p/1e6);return`data/${new Date(h).toISOString().replace(/[:.]/g,"-")}-${f}.${o==="ndjson"?"ndjson":"json"}`},batchSize:i=1e3,flushIntervalMs:a=1e4,transform:u=f=>f,onTransportError:d}=r??{},c=o==="ndjson"?"application/x-ndjson":"application/json",l=0;return ae(n,{onTransportError:d,batchSize:i,flushIntervalMs:a,serialize:u,sendBatch:async f=>{l+=1;let p=o==="ndjson"?`${f.map(g=>JSON.stringify(g)).join(`
17
17
  `)}
18
- `:JSON.stringify(p),h=o(l,te());await e.putObject({Bucket:t,Key:h,Body:f,ContentType:c})}})}function ta(n,e,t,r){let{toSQL:s=(i,a)=>({sql:`INSERT INTO "${a.replace(/"/g,'""')}" (data) VALUES ($1)`,params:[JSON.stringify(i)]}),onTransportError:o}=r??{};return ae(n,{onTransportError:o,serialize:i=>s(i,t),send:async i=>{let a=i;await e.query(a.sql,a.params)}})}function na(n,e,t){let{toDocument:r=o=>o,onTransportError:s}=t??{};return ae(n,{onTransportError:s,serialize:r,send:async o=>{await e.insertOne(o)}})}function ra(n,e,t){let{labels:r={},toLine:s=a=>JSON.stringify(a),toLabels:o,onTransportError:i}=t??{};return ae(n,{onTransportError:i,serialize:a=>({line:s(a),labels:o?{...r,...o(a)}:r}),send:async a=>{let{line:u,labels:d}=a,c=`${te()}`;await e.push({streams:[{stream:d,values:[[c,u]]}]})}})}function oa(n,e,t){let{toResourceSpans:r=o=>[o],onTransportError:s}=t??{};return ae(n,{onTransportError:s,serialize:r,send:async o=>{await e.push({resourceSpans:o})}})}function sa(n,e,t,r){let{prefix:s="checkpoints/",debounceMs:o=500,compactEvery:i=10,onError:a}=r??{},u={name:`s3:${t}`,debounceMs:o,compactEvery:i,save(d){let c=Math.floor(te()/1e6),l=`${s}${n.name}/checkpoint-${c}.json`,p;try{p=JSON.stringify(d)}catch(f){a?.(f);return}e.putObject({Bucket:t,Key:l,Body:p,ContentType:"application/json"}).catch(f=>a?.(f))}};return n.attachSnapshotStorage([u],{onError:d=>a?.(d)})}function ia(n,e,t){let{prefix:r="graphrefly:checkpoint:",debounceMs:s=500,compactEvery:o=10,onError:i}=t??{},a=`${r}${n.name}`,u={name:`redis:${a}`,debounceMs:s,compactEvery:o,save(d){let c;try{c=JSON.stringify(d)}catch(l){i?.(l);return}e.set(a,c).catch(l=>i?.(l))},async load(){let d=await e.get(a);if(d!=null)try{return JSON.parse(d)}catch{return}}};return n.attachSnapshotStorage([u],{onError:d=>i?.(d)})}function aa(n,e,t){let{mapRow:r=i=>i,params:s,...o}=t??{};return A(i=>{try{let u=n.query(e,s).map(r);i.emit(u),i.down([[N]])}catch(a){i.down([[S,a instanceof Error?a:new Error(String(a))]])}},{describeKind:"producer",completeWhenDepsComplete:!1,...o})}function ua(n,e,t){let{mapRow:r=i=>i,params:s,...o}=t??{};return A(i=>{try{let a=n.iterate(e,s);$(()=>{for(let u of a)i.emit(r(u));i.down([[N]])})}catch(a){i.down([[S,a instanceof Error?a:new Error(String(a))]])}},{describeKind:"producer",completeWhenDepsComplete:!1,...o})}function da(n,e,t,r){if(t.includes("\0")||t.length===0)throw new Error(`toSqlite: invalid table name: ${JSON.stringify(t)}`);let{toSQL:s=(P,L)=>({sql:`INSERT INTO "${L.replace(/"/g,'""')}" (data) VALUES (?)`,params:[JSON.stringify(P)]}),onTransportError:o,batchInsert:i=!1,maxBatchSize:a=1e3,flushIntervalMs:u=0}=r??{},d=P=>s(P,t);if(!i)return ae(n,{onTransportError:o,serialize:d,send:P=>{let L=P;e.query(L.sql,L.params)}});let c=F(null),l=F(void 0,{equals:()=>!1}),p=F(null),f=F(0),h=F(0),g=P=>{try{o?.(P)}catch{}try{c.down([[x,P]])}catch{}},m=[],y=!1,b,v=!1,T=()=>h.down([[x,m.length]]),k=P=>{v||l.down([[x,P]])},_=P=>{v||p.down([[x,P]])},w=P=>{v||f.down([[x,P]])},E=P=>{v||g(P)},R=()=>{if(m.length===0||y)return;y=!0,w(1);try{e.query("BEGIN",[])}catch(U){y=!1,w(0),E({stage:"send",error:U instanceof Error?U:new Error(String(U)),value:void 0});return}let P=m;m=[],T();let L,ue=0;for(let U of P)try{e.query(U.query.sql,U.query.params),ue+=1}catch(de){L=de instanceof Error?de:new Error(String(de));break}if(L){try{e.query("ROLLBACK",[])}catch{}E({stage:"send",error:L,value:void 0});for(let U of P)_({value:U.value,error:L,attempts:1})}else try{e.query("COMMIT",[]);for(let U of P)k(U.value)}catch(U){let de=U instanceof Error?U:new Error(String(U));E({stage:"send",error:de,value:void 0});for(let _e=0;_e<ue;_e++)_({value:P[_e].value,error:de,attempts:1})}y=!1,w(0)},M=()=>{u>0&&b===void 0&&!v&&(b=setTimeout(()=>{b=void 0,R()},u))},O=n.subscribe(P=>{for(let L of P){let ue=L[0];if(ue===x){let U=L[1],de;try{de=d(U)}catch(_e){let Ve=_e instanceof Error?_e:new Error(String(_e));g({stage:"serialize",error:Ve,value:U}),p.down([[x,{value:U,error:Ve,attempts:0}]]);continue}m.push({value:U,query:de}),T(),m.length>=a?R():M()}else me.messageTier(ue)>=3&&R()}});return{dispose:()=>{if(!v){b!==void 0&&(clearTimeout(b),b=void 0),R(),v=!0,O();for(let P of[c,l,p,f,h])try{P.down([[z]])}catch{}}},sent:l,failed:p,inFlight:f,errors:c,buffered:h,flush:async()=>{v||R()}}}function ca(n,e){let{args:t,mapRow:r=o=>o,...s}=e??{};return A(o=>{let i=!0;return n.findMany(t).then(a=>{i&&(o.emit(a.map(r)),o.down([[N]]))}).catch(a=>{if(i)try{o.down([[S,a instanceof Error?a:new Error(String(a))]])}catch{}}),()=>{i=!1}},{...s,describeKind:"producer",completeWhenDepsComplete:!1})}function la(n,e){let{mapRow:t=s=>s,...r}=e??{};return A(s=>{let o=!0;return n.execute().then(i=>{o&&(s.emit(i.map(t)),s.down([[N]]))}).catch(i=>{if(o)try{s.down([[S,i instanceof Error?i:new Error(String(i))]])}catch{}}),()=>{o=!1}},{...r,describeKind:"producer",completeWhenDepsComplete:!1})}function fa(n,e){let{mapRow:t=s=>s,...r}=e??{};return A(s=>{let o=!0;return n.execute().then(i=>{o&&(s.emit(i.map(t)),s.down([[N]]))}).catch(i=>{if(o)try{s.down([[S,i instanceof Error?i:new Error(String(i))]])}catch{}}),()=>{o=!1}},{...r,describeKind:"producer",completeWhenDepsComplete:!1})}kt();X();var pa=0;function ha(n,e){if(e.highWaterMark<1)throw new RangeError("highWaterMark must be >= 1");if(e.lowWaterMark<0)throw new RangeError("lowWaterMark must be >= 0");if(e.lowWaterMark>=e.highWaterMark)throw new RangeError("lowWaterMark must be < highWaterMark");let t=Symbol(`bp-${++pa}`),r=0,s=!1;return{onEnqueue(){return r+=1,!s&&r>=e.highWaterMark?(s=!0,n([[le,t]]),!0):!1},onDequeue(){return r>0&&(r-=1),s&&r<=e.lowWaterMark?(s=!1,n([[pe,t]]),!0):!1},get pending(){return r},get paused(){return s},dispose(){s&&(s=!1,n([[pe,t]]))}}}X();fe();function lo(){let n=new Map,e=null,t=null;function r(o){o.prev?o.prev.next=o.next:e=o.next,o.next?o.next.prev=o.prev:t=o.prev,o.prev=null,o.next=null}function s(o){o.next=e,o.prev=null,e&&(e.prev=o),e=o,t===null&&(t=o)}return{insert(o){if(n.has(o)){this.touch(o);return}let i={key:o,prev:null,next:null};n.set(o,i),s(i)},touch(o){let i=n.get(o);i&&(r(i),s(i))},delete(o){let i=n.get(o);i&&(r(i),n.delete(o))},evict(o){let i=[];for(let a=0;a<o&&t!==null;a++){let u=t;i.push(u.key),r(u),n.delete(u.key)}return i},size(){return n.size}}}function fo(n){return n!=null&&typeof n.then=="function"}function ft(n){fo(n)&&n.catch(()=>{})}function ma(n,e){let t=new Map,r=e?.maxSize??0,s=r>0?e?.eviction??lo():null,o=e?.writeThrough??!1;function i(d,c,l){for(let p=0;p<l;p++)try{ft(n[p].save(d,c))}catch{}}function a(d,c,l=0){for(let p=l;p<n.length;p++){let f;try{f=n[p].load(d)}catch{continue}if(fo(f)){let h=p;f.then(g=>{g!==void 0?(c.down([[x,g]]),i(d,g,h)):a(d,c,h+1)},()=>{a(d,c,h+1)});return}if(f!==void 0){c.down([[x,f]]),i(d,f,p);return}}}function u(){if(!(!s||r<=0))for(;s.size()>=r;){let d=s.evict(1);if(d.length===0)break;for(let c of d){let l=t.get(c);if(l){let p=l.cache;if(l.status!=="sentinel"&&n.length>0){let f=n.length-1;try{ft(n[f].save(c,p))}catch{}for(let h=0;h<f;h++)try{let g=n[h].delete;g&&ft(g.call(n[h],c))}catch{}}l.down([[z]])}t.delete(c)}}}return{load(d){let c=t.get(d);if(c)return s?.touch(d),c;s&&r>0&&s.size()>=r&&u();let l=F(void 0);return t.set(d,l),s?.insert(d),a(d,l),l},save(d,c){if(o)for(let p of n)try{ft(p.save(d,c))}catch{}else if(n[0])try{ft(n[0].save(d,c))}catch{}let l=t.get(d);if(l)l.down([[x,c]]),s?.touch(d);else{s&&r>0&&s.size()>=r&&u();let p=F(c);t.set(d,p),s?.insert(d)}},invalidate(d){let c=t.get(d);c&&a(d,c)},delete(d){s?.delete(d);let c=t.get(d);c&&c.down([[z]]),t.delete(d);for(let l of n)try{let p=l.delete;p&&ft(p.call(l,d))}catch{}},has(d){return t.has(d)},get size(){return t.size}}}ye();X();xt();fe();ye();Ae();X();fe();var Yt=class{_version=0;_store=new Map;_maxSize;_defaultTtl;constructor(e={}){let{maxSize:t,defaultTtl:r}=e;if(t!==void 0&&t<1)throw new RangeError("maxSize must be >= 1");if(r!==void 0&&r<=0)throw new RangeError("defaultTtl must be positive");this._maxSize=t,this._defaultTtl=r}get version(){return this._version}get size(){return this._store.size}has(e){let t=this._store.get(e);return t===void 0?!1:this._isExpired(t)?(this._store.delete(e),this._version+=1,!1):(this._touchLru(e,t),!0)}get(e){let t=this._store.get(e);if(t!==void 0){if(this._isExpired(t)){this._store.delete(e),this._version+=1;return}return this._touchLru(e,t),t.value}}set(e,t,r){let s=this._resolveExpiresAt(r);this._store.has(e)&&this._store.delete(e),this._store.set(e,{value:t,expiresAt:s}),this._evictLruWhileOver(),this._version+=1}setMany(e,t){let r=this._resolveExpiresAt(t),s=0;try{for(let[o,i]of e)this._store.has(o)&&this._store.delete(o),this._store.set(o,{value:i,expiresAt:r}),s+=1}finally{s>0&&(this._evictLruWhileOver(),this._version+=1)}}delete(e){let t=this._store.delete(e);return t&&(this._version+=1),t}deleteMany(e){let t=0;try{for(let r of e)this._store.delete(r)&&(t+=1)}finally{t>0&&(this._version+=1)}return t}clear(){let e=this._store.size;return e===0?0:(this._store.clear(),this._version+=1,e)}pruneExpired(){let e=re(),t=0;for(let[r,s]of this._store)this._isExpired(s,e)&&(this._store.delete(r),t+=1);return t>0&&(this._version+=1),t}toMap(){let e=re(),t=new Map;for(let[r,s]of this._store)this._isExpired(s,e)||t.set(r,s.value);return t}_resolveExpiresAt(e){let t=e??this._defaultTtl;if(t!==void 0){if(!Number.isFinite(t)||t<=0)throw new RangeError(`MapBackend: ttl must be a positive finite number (got ${t})`);return re()+t*1e9}}_isExpired(e,t){return e.expiresAt===void 0?!1:(t??re())>=e.expiresAt}_touchLru(e,t){this._store.delete(e),this._store.set(e,t)}_evictLruWhileOver(){if(this._maxSize!==void 0)for(;this._store.size>this._maxSize;){let e=this._store.keys().next().value;if(e===void 0)break;this._store.delete(e)}}};function er(n={}){let{name:e,maxSize:t,defaultTtl:r,versioning:s,backend:o,retention:i}=n;if(i&&t!==void 0)throw new RangeError("reactiveMap: `maxSize` (LRU) and `retention` (score-based) are mutually exclusive. Pick one eviction policy.");if(i&&i.archiveThreshold===void 0&&i.maxSize===void 0)throw new RangeError("reactiveMap: `retention` requires at least one of `archiveThreshold` or `maxSize` to trigger archival.");let a=o??new Yt({maxSize:t,defaultTtl:r}),u=F(a.toMap(),{name:e,describeKind:"state",equals:(p,f)=>p===f,...s!=null?{versioning:s}:{}});function d(){let p=a.toMap();$(()=>{u.down([[V]]),u.down([[x,p]])})}function c(){if(!i)return;let p=a.toMap(),f=i.archiveThreshold,h=i.maxSize,g=[];for(let[y,b]of p)g.push({key:y,value:b,score:i.score(y,b)});g.sort((y,b)=>y.score-b.score);let m=new Set;if(f!==void 0)for(let y of g)if(y.score<f)m.add(y.key);else break;if(h!==void 0&&g.length-m.size>h)for(let y of g){if(g.length-m.size<=h)break;m.has(y.key)||m.add(y.key)}if(m.size!==0)for(let y of g)m.has(y.key)&&(i.onArchive?.(y.key,y.value,y.score),a.delete(y.key))}function l(p,f="mutation"){let h=a.version;try{return p()}finally{a.version!==h&&(f==="mutation"&&c(),d())}}return{entries:u,has(p){return l(()=>a.has(p),"read")},get(p){return l(()=>a.get(p),"read")},set(p,f,h){l(()=>a.set(p,f,h?.ttl))},setMany(p,f){l(()=>a.setMany(p,f?.ttl))},delete(p){l(()=>a.delete(p))},deleteMany(p){l(()=>a.deleteMany(p))},clear(){l(()=>a.clear())},pruneExpired(){l(()=>a.pruneExpired())},get size(){return a.size},dispose(){}}}De();function ga(n){return typeof n=="object"&&n!==null&&"cache"in n&&typeof n.subscribe=="function"}function ba(n,e,t){let r=ie(n),s=r.v!=null,o=F(t?.initialVerified??null,{meta:{...q("verifiable"),...s?{sourceVersion:null}:{}}}),i=t?.trigger!==void 0&&t.trigger!==null,a=null;if(i&&t?.autoVerify?a=Et(ie(t.trigger),r):i?a=ie(t.trigger):t?.autoVerify&&(a=r),a!==null){let u;if(a===r)u=Be(r,d=>e(d));else{let d=r.cache;r.subscribe(c=>{for(let l of c)l[0]===x&&(d=l[1])}),u=Be(a,()=>e(d))}Je(u,d=>{$(()=>{if(o.down([[x,d]]),s){let c=r.v;c!=null&&o.meta.sourceVersion.down([[x,{id:c.id,version:c.version}]])}})})}return{node:r,verified:o,trigger:a}}function po(n){n.subscribe(()=>{})}function Rt(n){return n instanceof Map?n:new Map}function ho(n,e){if(!Array.isArray(e.upsert))throw new TypeError("distill extraction requires upsert: Array<{ key, value }>");$(()=>{for(let{key:t,value:r}of e.upsert)n.set(t,r);for(let t of e.remove??[])n.delete(t)})}function ya(n,e,t){let r=ie(n),s=er(t.mapOptions??{}),o=t.budget??2e3,a=t.context!==void 0&&t.context!==null?ie(t.context):F(null),u=Rt(s.entries.cache);s.entries.subscribe(f=>{for(let h of f)h[0]===x&&(u=Rt(h[1]))});let d=ie(e(r,s.entries));if(Je(d,f=>{ho(s,f)}),t.evict){let f=new Map,h=be([s.entries],([g])=>{let m=[],y=Rt(g);for(let b of f.keys())y.has(b)||(f.get(b)(),f.delete(b));for(let[b,v]of y){let T=t.evict(b,v);if(ga(T)){if(!f.has(b)){let k=Je(T,_=>{_===!0&&s.has(b)&&s.delete(b)});f.set(b,k)}continue}if(typeof T=="boolean"){T&&m.push(b);continue}throw new TypeError("distill evict() must return boolean or Node<boolean>")}return m});Je(h,g=>{for(let m of g)s.delete(m)})}let c=t.consolidateTrigger!==void 0&&t.consolidateTrigger!==null;if(t.consolidate&&c){let f=ie(t.consolidateTrigger),h=Be(f,()=>t.consolidate(u));Je(h,g=>{ho(s,g)})}let l=be([s.entries,a],([f,h])=>{let g=[...Rt(f).entries()].map(([b,v])=>({key:b,value:v,score:t.score(v,h),cost:t.cost(v)}));g.sort((b,v)=>v.score-b.score);let m=[],y=o;for(let b of g)b.cost<=y&&(m.push({key:b.key,value:b.value,score:b.score}),y-=b.cost);return m},{meta:{...q("distill",{budget:o})}}),p=be([s.entries],([f])=>Rt(f).size);return po(l),po(p),{store:s,compact:l,size:p}}Ae();function tr(n,e){if(Object.is(n,e))return!0;if(n==null||e==null||typeof n!="object"||typeof e!="object")return!1;if(Array.isArray(n)){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let o=0;o<n.length;o++)if(!tr(n[o],e[o]))return!1;return!0}if(Array.isArray(e))return!1;let t=Object.keys(n),r=Object.keys(e);if(t.length!==r.length)return!1;let s=new Set(r);for(let o of t)if(!s.has(o)||!tr(n[o],e[o]))return!1;return!0}function mo(n,e){return`${n}\0${e}`}function Mt(n,e){let t=[],r=new Set(n.subgraphs),s=new Set(e.subgraphs),o=[];for(let m of s)r.has(m)||o.push(m);o.sort();for(let m of o)t.push({type:"subgraph-mounted",path:m});let i=new Set(Object.keys(n.nodes)),a=new Set(Object.keys(e.nodes)),u=[];for(let m of a)i.has(m)||u.push(m);u.sort();for(let m of u)t.push({type:"node-added",path:m,node:{...e.nodes[m]}});let d=[];for(let m of a){if(!i.has(m))continue;let y=n.nodes[m]?.meta,b=e.nodes[m]?.meta;y==null&&b==null||tr(y??{},b??{})||d.push(m)}d.sort();for(let m of d)t.push({type:"node-meta-changed",path:m,prevMeta:n.nodes[m]?.meta??{},nextMeta:e.nodes[m]?.meta??{}});let c=new Map;for(let m of n.edges)c.set(mo(m.from,m.to),m);let l=new Map;for(let m of e.edges)l.set(mo(m.from,m.to),m);let p=[];for(let[m,y]of l)c.has(m)||p.push(y);p.sort((m,y)=>m.from<y.from?-1:m.from>y.from?1:m.to<y.to?-1:m.to>y.to?1:0);for(let m of p)t.push({type:"edge-added",from:m.from,to:m.to});let f=[];for(let[m,y]of c)l.has(m)||f.push(y);f.sort((m,y)=>m.from<y.from?-1:m.from>y.from?1:m.to<y.to?-1:m.to>y.to?1:0);for(let m of f)t.push({type:"edge-removed",from:m.from,to:m.to});let h=[];for(let m of i)a.has(m)||h.push(m);h.sort();for(let m of h)t.push({type:"node-removed",path:m});let g=[];for(let m of r)s.has(m)||g.push(m);g.sort();for(let m of g)t.push({type:"subgraph-unmounted",path:m});return{events:t,flushedAt_ns:re()}}async function go(n){let e=typeof n=="string"?new TextEncoder().encode(n):n,t=await globalThis.crypto.subtle.digest("SHA-256",e),r=new Uint8Array(t),s="";for(let o=0;o<r.length;o++)s+=bo[r[o]];return s}var bo=new Array(256);for(let n=0;n<256;n++)bo[n]=n.toString(16).padStart(2,"0");var Qt=class extends Error{constructor(t,r){super(`content-addressed lookup miss in read-strict mode: ${t}`);this.key=t;this.context=r;this.name="ContentAddressedMissError"}};function yo(n){let e=new Set,t=r=>{if(r===null||typeof r!="object")return r;let s=r;if(e.has(s))return{__cycle:!0};e.add(s);try{if(Array.isArray(r))return r.map(t);let o={};for(let i of Object.keys(r).sort())o[i]=t(r[i]);return o}finally{e.delete(s)}};return JSON.stringify(t(n))}function va(n){let{storage:e,keyContext:t,keyPrefix:r,mode:s="read-write"}=n,o=t??(a=>a);async function i(a){let u=yo(o(a)),d=await go(u);return r?`${r}:${d}`:d}return{keyFor:i,async lookup(a){if(s==="write")return;let u=await i(a),d=await e.load(u);if(d===void 0){if(s==="read-strict")throw new Qt(u,a);return}return d},async store(a,u){if(s==="read")return;let d=await i(a);await e.save(d,u)},async forget(a){if(s==="read"||s==="write"||!e.delete)return;let u=await i(a);await e.delete(u)}}}Ln();async function Ta(n,e){let t;try{t=await n.text()}catch{t=""}let r=e??"HTTP",s=new Error(`${r} API ${n.status}: ${n.statusText}${t?` \u2014 ${t}`:""}`);return s.status=n.status,s.headers=n.headers,s}Vn();ye();Ae();wt();X();fe();vn();ye();Ae();wt();X();xt();ge();fe();De();zt();$t();yn();function vo(n,e,t,r={}){let s=e in n.nodes,o=t in n.nodes;if(!s)return Xt(e,t,"no-such-from");if(!o)return Xt(e,t,"no-such-to");let i=r.maxDepth;if(i!=null&&(!Number.isInteger(i)||i<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(e===t){if(r.findCycle===!0){let d=wa(n,e,r);if(d!=null)return d}let u=Zt(e,n.nodes[e],0,r);return en(e,t,[u])}if(i===0)return Xt(e,t,"no-path");let a=To(n,e,t,i);return a.found?en(e,t,wo(n,a.pathOrder,r)):Xt(e,t,a.truncated?"max-depth-exceeded":"no-path")}function To(n,e,t,r){let s=new Map,o=[{path:t,depth:0}],i=new Set([t]),a=0,u=!1;for(;a<o.length;){let l=o[a++];if(l.path===e)break;if(r!=null&&l.depth>=r){let g=n.nodes[l.path];g?.deps&&g.deps.length>0&&(u=!0);continue}let p=n.nodes[l.path];if(p==null)continue;let f=p.deps??[],h=new Map;for(let g=0;g<f.length;g++){let m=f[g];if(!m)continue;let y=h.get(m);y==null&&(y=[],h.set(m,y)),y.push(g)}for(let[g,m]of h)i.has(g)||(i.add(g),s.set(g,{from:l.path,depIndices:m}),o.push({path:g,depth:l.depth+1}))}if(!s.has(e))return{found:!1,pathOrder:[],truncated:u};let d=[{path:e}],c=e;for(;c!==t;){let l=s.get(c);if(l==null)return{found:!1,pathOrder:[],truncated:!1};d[d.length-1].depIndices=l.depIndices,d.push({path:l.from}),c=l.from}return{found:!0,pathOrder:d,truncated:!1}}function wa(n,e,t){let r=n.nodes[e];if(r==null)return null;let s=r.deps??[],o=[];for(let a=0;a<s.length;a++)s[a]===e&&o.push(a);if(o.length>0){let a=Zt(e,r,0,t);a.dep_index=o[0];let u=Zt(e,r,1,t);return en(e,e,[a,u])}let i=null;for(let a=0;a<s.length;a++){let u=s[a];if(!u||u===e)continue;let d=To(n,u,e,t.maxDepth);d.found&&(i==null||d.pathOrder.length<i.pathOrder.length)&&(i=d,i={found:!0,pathOrder:[{path:e,depIndices:[a]},...d.pathOrder],truncated:!1})}return i==null?null:en(e,e,wo(n,i.pathOrder,t))}function wo(n,e,t){return e.map((r,s)=>{let o=n.nodes[r.path],i=Zt(r.path,o,s,t);return r.depIndices!=null&&r.depIndices.length>0&&(i.dep_index=r.depIndices[0],r.depIndices.length>1&&(i.dep_indices=[...r.depIndices])),i})}function Zt(n,e,t,r){let s={path:n,type:e.type,hop:t};e.status!==void 0&&(s.status=e.status),"value"in e&&(s.value=e.value),e.v!=null&&(s.v=e.v);let o=r.annotations?.get(n)??e.annotation;o!=null&&(s.annotation=o);let i=r.lastMutations?.get(n)??e.lastMutation;return i!=null&&(s.lastMutation=i),s}function en(n,e,t){return ko(n,e,!0,"ok",t)}function Xt(n,e,t){return ko(n,e,!1,t,[])}function ko(n,e,t,r,s){let o=ka(n,e,t,r,s);return{from:n,to:e,found:t,reason:r,steps:s,text:o,toJSON(){return{from:n,to:e,found:t,reason:r,steps:s}}}}function ka(n,e,t,r,s){if(!t)switch(r){case"no-such-from":return`explainPath: no node named "${n}"`;case"no-such-to":return`explainPath: no node named "${e}"`;case"max-depth-exceeded":return`explainPath: no path from "${n}" to "${e}" within maxDepth`;default:return`explainPath: no path from "${n}" to "${e}"`}let o=[`Causal path: ${n} \u2192 ${e} (${s.length} step(s))`];for(let i of s){let u=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(o.push(u),"value"in i&&o.push(` value: ${xa(i.value)}`),i.annotation!=null&&o.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let d=i.lastMutation.actor;o.push(` actor: ${d.type}${d.id?`:${d.id}`:""}`)}}return o.join(`
19
- `)}function xa(n){if(n===void 0)return"<sentinel>";if(n===null)return"null";if(typeof n=="string")return JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean"||typeof n=="bigint")return String(n);try{let e=JSON.stringify(n);return e.length>80?`${e.slice(0,77)}...`:e}catch{return String(n)}}ge();var se={object:56,array:64,string:40,number:8,boolean:4,null:0,undefined:0,symbol:40,bigint:16,function:120,map:72,set:72,mapEntry:40,setEntry:24,date:24,regexp:48,error:64,url:80,promise:48,weakmap:40,weakset:40},Na=Symbol.for("sizeof");function xo(n){let e=new WeakSet,t=new WeakSet,r=[n],s=0;for(;r.length>0;){let o=r.pop();s+=_a(o,e,t,r)}return s}function _a(n,e,t,r){if(n==null)return 0;switch(typeof n){case"number":return se.number;case"boolean":return se.boolean;case"string":return se.string+n.length*2;case"bigint":return se.bigint+Sa(n);case"symbol":return se.symbol;case"function":return e.has(n)?0:(e.add(n),se.function);case"undefined":return 0}let o=n;if(e.has(o))return 0;e.add(o);let i=o[Na];if(typeof i=="function")try{let d=i.call(o);if(typeof d=="number"&&Number.isFinite(d))return d}catch{}if(o instanceof Date)return se.date;if(o instanceof RegExp)return se.regexp+o.source.length*2;if(o instanceof Error){let d=o.message?o.message.length*2:0,c=o.stack?o.stack.length*2:0;return se.error+d+c}if(typeof URL<"u"&&o instanceof URL)return se.url+o.href.length*2;if(typeof Promise<"u"&&o instanceof Promise)return se.promise;if(o instanceof WeakMap)return se.weakmap;if(o instanceof WeakSet)return se.weakset;if(o instanceof Map){let d=se.map;for(let[c,l]of o)d+=se.mapEntry,r.push(c),r.push(l);return d}if(o instanceof Set){let d=se.set;for(let c of o)d+=se.setEntry,r.push(c);return d}if(Array.isArray(o)){let d=se.array+o.length*8;for(let c of o)r.push(c);return d}if(o instanceof ArrayBuffer)return t.has(o)?0:(t.add(o),o.byteLength);if(ArrayBuffer.isView(o)){let d=o;return t.has(d.buffer)?48:(t.add(d.buffer),d.buffer.byteLength+48)}let a=se.object,u=Object.keys(o);for(let d of u){a+=se.string+d.length*2;try{r.push(o[d])}catch{}}return a}function Sa(n){let e=n<0n?-n:n;if(e===0n)return 0;let t=e.toString(2).length;return Math.ceil(t/32)*8}function No(n,e){let t=e?.topN??10,r=n.describe({detail:"standard"}),s=[],o=n._collectObserveTargets;typeof o=="function"&&o.call(n,"",s);let i=new Map;for(let[p,f]of s)i.set(p,f);let a=[];for(let[p,f]of Object.entries(r.nodes)){let h=i.get(p),g=h instanceof oe?h:null,m=g?xo(g.cache):0,y=g?g._sinkCount:0,b=f.deps?.length??0,v=f.type==="effect"&&y===0,T=y===0?f.type==="effect"?"orphan-effect":f.type==="derived"?"idle-derived":f.type==="producer"?"idle-producer":null:null;a.push({path:p,type:f.type,status:f.status??"unknown",valueSizeBytes:m,subscriberCount:y,depCount:b,isOrphanEffect:v,orphanKind:T})}let u=a.reduce((p,f)=>p+f.valueSizeBytes,0),d=(p,f)=>[...a].sort(f??((h,g)=>g[p]-h[p])).slice(0,t),c=a.filter(p=>p.orphanKind!=null),l=a.filter(p=>p.isOrphanEffect);return{nodeCount:a.length,edgeCount:r.edges.length,subgraphCount:r.subgraphs.length,nodes:a,totalValueSizeBytes:u,hotspots:{byValueSize:d("valueSizeBytes"),bySubscriberCount:d("subscriberCount"),byDepCount:d("depCount")},orphans:c,orphanEffects:l}}var ee="::",Me="__meta__",pt=1;function _o(n,e){let t=Math.max(16,n.size*4),r=0;for(;n.size>0;){if(r++>=t){console.error(`[Graph "${e}".destroy] disposer drain exceeded cap (${t}); ${n.size} disposer(s) discarded`),n.clear();return}let s=n.values().next();if(s.done)return;let o=s.value;n.delete(o);try{o()}catch(i){console.error(`[Graph "${e}".destroy] disposer threw:`,i)}}}function Ao(n){return n!=null&&typeof n=="object"&&"cache"in n&&typeof n.subscribe=="function"&&typeof n.down=="function"}function Ea(n){if(n!=null)return Ao(n)?n.cache:n}function Qe(n){return n!=null&&typeof n=="object"&&"cache"in n&&typeof n.subscribe=="function"&&typeof n.down=="function"}function Ke(n){return Qe(n)?n.cache??"":n}function So(n){return Qe(n)?n.cache??0:n}function Eo(n){return Qe(n)?n.cache??!1:n}function Oa(n){let e=[];for(let t of Object.keys(n).sort()){let r=n[t].v;r!=null&&e.push(`${t} ${r.id} ${r.version}`)}return e.join(`
20
- `)}function Oo(n){if(n.version!==pt)throw new Error(`unsupported snapshot version ${String(n.version)} (expected ${pt})`);for(let e of["name","nodes","edges","subgraphs"])if(!(e in n))throw new Error(`snapshot missing required key "${e}"`);if(typeof n.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof n.nodes!="object"||n.nodes===null||Array.isArray(n.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(n.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(n.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function Ra(n,e){let t=new WeakMap,r=(s,o)=>{if(Object.is(s,o))return!0;if(s==null||o==null||typeof s!="object"||typeof o!="object")return!1;let i=t.get(s);if(i==null&&(i=new WeakSet,t.set(s,i)),i.has(o))return!0;i.add(o);let a=s.constructor,u=o.constructor;if(a!==u)return!1;if(s instanceof Date)return s.getTime()===o.getTime();if(s instanceof RegExp)return s.source===o.source&&s.flags===o.flags;if(Array.isArray(s)){let p=o;if(s.length!==p.length)return!1;for(let f=0;f<s.length;f++)if(!r(s[f],p[f]))return!1;return!0}if(s instanceof Map){let p=o;if(s.size!==p.size)return!1;for(let[f,h]of s)if(!p.has(f)||!r(h,p.get(f)))return!1;return!0}if(s instanceof Set){let p=o;if(s.size!==p.size)return!1;for(let f of s){let h=!1;for(let g of p)if(r(f,g)){h=!0;break}if(!h)return!1}return!0}if(ArrayBuffer.isView(s)){let p=s,f=o;if(p.length!==f.length)return!1;for(let h=0;h<p.length;h++)if(p[h]!==f[h])return!1;return!0}let d=Object.keys(s),c=Object.keys(o);if(d.length!==c.length)return!1;let l=new Set(c);for(let p of d)if(!l.has(p)||!r(s[p],o[p]))return!1;return!0};return r(n,e)}function Ma(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function tn(n){let e="^";for(let t=0;t<n.length;t+=1){let r=n[t];if(r==="*"){e+=".*";continue}if(r==="?"){e+=".";continue}if(r==="["){let s=n.indexOf("]",t+1);if(s<=t+1){e+="\\[";continue}let o=n.slice(t+1,s);o.startsWith("!")&&(o=`^${o.slice(1)}`),o=o.replace(/\\/g,"\\\\"),e+=`[${o}]`,t=s;continue}e+=Ma(r)}return e+="$",new RegExp(e)}var Aa={data:"\x1B[32m",dirty:"\x1B[33m",resolved:"\x1B[36m",invalidate:"\x1B[93m",pause:"\x1B[90m",resume:"\x1B[96m",complete:"\x1B[34m",error:"\x1B[31m",teardown:"\x1B[91m",derived:"\x1B[35m",path:"\x1B[90m",reset:"\x1B[0m"},Ca={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function nr(n){if(typeof n=="string")return JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean"||n==null)return String(n);try{return JSON.stringify(n)}catch{return"[unserializable]"}}function Pa(n){return n==="none"?Ca:n==="ansi"||n==null?Aa:{data:n.data??"",dirty:n.dirty??"",resolved:n.resolved??"",invalidate:n.invalidate??"",pause:n.pause??"",resume:n.resume??"",complete:n.complete??"",error:n.error??"",teardown:n.teardown??"",derived:n.derived??"",path:n.path??"",reset:n.reset??""}}function Ro(n){if(n==null)return{};let e=n.detail;return e==="full"?{...n,structured:n.structured??!0,timeline:n.timeline??!0,causal:n.causal??!0,derived:n.derived??!0}:e==="minimal"?{...n,structured:n.structured??!0}:n.format==="stage-log"?{...n,structured:n.structured??!0,timeline:n.timeline??!0}:n}function Da(n,e,t){for(let r=0;r<n.length;r++){let s=n.charCodeAt(r);if(s<32||s===127)throw new Error(`Graph "${e}": ${t} "${n}" must not contain control character (U+${s.toString(16).padStart(4,"0").toUpperCase()} at index ${r})`)}}function rr(n,e,t){if(n==="")throw new Error(`Graph "${e}": ${t} name must be non-empty`);if(n.includes(ee))throw new Error(`Graph "${e}": ${t} "${n}" must not contain '${ee}' (path separator)`);if(n===Me)throw new Error(`Graph "${e}": ${t} name "${Me}" is reserved for meta companion paths`);Da(n,e,t)}function Ia(n,e){if(n==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let t=n.split(ee);for(let r of t)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return t}function La(n,e){let t=!1;for(let s of n)if(!e.isMetaPassthrough(s[0])){t=!0;break}return t?n.filter(s=>e.isMetaPassthrough(s[0])):n}function Co(n){for(let e of n._mounts.values())Co(e);for(let e of n._nodes.values())try{e.down([[z]],{internal:!0})}catch{}}var Xe=class n{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_destroyed=!1;_topology;_topologyEmitters=new Set;_factory;_factoryArgs;constructor(e,t){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(ee))throw new Error(`Graph name must not contain '${ee}' (got "${e}")`);if(e===Me)throw new Error(`Graph name "${Me}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...t??{}}),this.config=t?.config??me,this._traceRing=new Le(t?.traceCapacity??1e3),t?.versioning!=null&&this.setVersioning(t.versioning),typeof t?.factory=="string"&&(this._factory=t.factory,t.factoryArgs!==void 0&&(this._factoryArgs=t.factoryArgs))}tagFactory(e,t){return this._factory=e,this._factoryArgs=t,this}ancestors(e=!0){let t=[],r=e?this:this._parent;for(;r!=null;)t.push(r),r=r._parent;return t}get topology(){return this._topology==null&&(this._topology=A(e=>{let t=r=>{e.emit(r)};return this._topologyEmitters.add(t),()=>{this._topologyEmitters.delete(t)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let t of this._topologyEmitters)t(e)}nameOf(e){return this._nodeToName.get(e)}add(e,t){let r=e.name,s=t?.name??r;if(s==null||s==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let o=s,i=t?.annotation;if(rr(o,this.name,"add"),this._mounts.has(o))throw new Error(`Graph "${this.name}": name "${o}" is already a mount point`);if(this._nodes.has(o))throw new Error(`Graph "${this.name}": node "${o}" already exists`);let a=this._nodeToName.get(e);if(a!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${a}"`);return this._nodes.set(o,e),this._nodeToName.set(e,o),this._emitTopology({kind:"added",name:o,nodeKind:"node"}),i!=null&&(this._annotations.set(o,i),this.config.inspectorEnabled&&this._traceRing.push({path:o,annotation:i,timestamp_ns:re()})),e}setVersioning(e){if(e!=null)for(let t of this._nodes.values())t instanceof oe&&t._applyVersioning(e)}remove(e){rr(e,this.name,"remove");let t=this._mounts.get(e);if(t){let o={kind:"mount",nodes:[],mounts:[]},i=[];t._collectObserveTargets("",i);for(let[a,u]of i)a.includes(`${ee}${Me}${ee}`)||o.nodes.push(a);return o.nodes.sort(),o.mounts.push(e),o.mounts.push(...t._collectSubgraphs(`${e}${ee}`)),this._mounts.delete(e),t._parent=void 0,Co(t),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:o}),o}let r=this._nodes.get(e);if(!r)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(r),r.down([[z]],{internal:!0});let s={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:s}),s}removeAll(e){let t=typeof e=="function"?e:(()=>{let o=tn(e);return i=>o.test(i)})(),r={kind:"mount",nodes:[],mounts:[]},s=[...this._nodes.keys(),...this._mounts.keys()].filter(o=>t(o));for(let o of s){let i=this.remove(o);r.nodes.push(...i.nodes),r.mounts.push(...i.mounts)}return r.nodes.sort(),r.mounts.sort(),r}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),t=this._nodes,r=0;return{[Symbol.iterator](){return this},next(){if(r>=e.length)return{value:void 0,done:!0};let s=e[r++];return{value:[s,t.get(s)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(ee))return this.resolve(e);let t=this._nodes.get(e);if(!t)throw new Error(`Graph "${this.name}": unknown node "${e}"`);return t}get(e){return this.node(e).cache}set(e,t,r){let s=r?.internal===!0;this.node(e).down([[x,t]],{actor:r?.actor,internal:s,delivery:"write"})}setAll(e,t){let r=Symbol.iterator in e?e:Object.entries(e);$(()=>{for(let[s,o]of r)this.set(s,o,t)})}invalidate(e,t){let r=t?.internal===!0;this.node(e).down([[ke]],{actor:t?.actor,internal:r,delivery:"write"})}error(e,t,r){let s=r?.internal===!0;this.node(e).down([[S,t]],{actor:r?.actor,internal:s,delivery:"write"})}complete(e,t){let r=t?.internal===!0;this.node(e).down([[N]],{actor:t?.actor,internal:r,delivery:"write"})}edges(e){let t=e?.recursive===!0,r=new Map;if(!t){for(let[u,d]of this._nodes)r.set(d,u);let a=[];for(let[u,d]of this._nodes)if(d instanceof oe)for(let c of d._deps){let l=r.get(c.node);l!=null&&a.push([l,u])}return a.sort((u,d)=>u[0]<d[0]?-1:u[0]>d[0]?1:u[1]<d[1]?-1:u[1]>d[1]?1:0),a}let s=[];this._collectObserveTargets("",s);let o=new Map;for(let[a,u]of s)o.set(u,a);let i=[];for(let[a,u]of s)if(u instanceof oe)for(let d of u._deps){let c=o.get(d.node);c!=null&&i.push([c,a])}return i.sort((a,u)=>a[0]<u[0]?-1:a[0]>u[0]?1:a[1]<u[1]?-1:a[1]>u[1]?1:0),i}mount(e,t){if(t===void 0){let s=new n(e);return this.mount(e,s)}if(typeof t=="function"){let s=new n(e);return t(s),this.mount(e,s)}let r=t;if(rr(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(r===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(r._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${r._parent.name}"`);for(let s=this;s!=null;s=s._parent)if(s===r)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,r),r._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),r}resolve(e){let t=Ia(e,this.name);return this._resolveFromSegments(t)}tryResolve(e){try{return this.resolve(e)}catch{return}}_resolveFromSegments(e){let t=e;if(t[0]===this.name&&(t=t.slice(1),t.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let r=t[0],s=t.slice(1);if(s.length===0){let a=this._nodes.get(r);if(a)return a;throw this._mounts.has(r)?new Error(`Graph "${this.name}": path ends at subgraph "${r}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${r}"`)}let o=this._nodes.get(r);if(o&&s.length>0&&s[0]===Me)return this._resolveMetaChainFromNode(o,s,t.join(ee));let i=this._mounts.get(r);if(!i)throw this._nodes.has(r)?new Error(`Graph "${this.name}": "${r}" is a node; trailing path "${s.join(ee)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(s.join(ee))}_resolveMetaChainFromNode(e,t,r){let s=e,o=0,i=[...t];for(;o<i.length;){if(i[o]!==Me)throw new Error(`Graph "${this.name}": expected ${Me} segment in meta path "${r}"`);if(o+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${Me} in "${r}"`);let a=i[o+1],u=s.meta[a];if(!u)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);s=u,o+=2}return s}signal(e,t){if(t?.internal!==!0){for(let s of e)if(this.config.messageTier(s[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let r=[];if(this._signalDeliver(e,t??{},new Set,r),r.length>0)throw r[0]}_signalDeliver(e,t,r,s){for(let u of this._mounts.values())u._signalDeliver(e,t,r,s);let i=t.internal===!0?{internal:!0}:{actor:t.actor,delivery:"signal"},a=La(e,this.config);for(let u of[...this._nodes.keys()].sort()){let d=this._nodes.get(u);if(!r.has(d)){r.add(d);try{d.down(e,i)}catch(c){if(c instanceof Ee)throw c;s.push(c)}a.length!==0&&this._signalMetaSubtree(d,a,r,i,s)}}}_signalMetaSubtree(e,t,r,s,o){for(let i of Object.keys(e.meta).sort()){let a=e.meta[i];if(!r.has(a)){r.add(a);try{a.down(t,s)}catch(u){if(u instanceof Ee)throw u;o.push(u)}this._signalMetaSubtree(a,t,r,s,o)}}}describe(e){if(e?.reactive==="diff")return this._describeReactiveDiff(e);if(e?.reactive===!0)return this._describeReactive(e);let t=Ea(e?.actor),r=e?.filter;if(e?.detail!=null&&e?.fields!=null)throw new TypeError("Graph.describe(): pass either `detail` or `fields`, not both. `detail: 'spec'` is the canonical spec projection; use `fields` only when you need a custom subset.");let s=Cn(e?.detail,e?.fields),o=e?.detail==="spec",i=s,a=[];this._collectObserveTargets("",a);let u=new Map;for(let[T,k]of a)u.set(k,T);let d=[];{let T=a.map(([,w])=>w),k=new Set(u.values()),_=0;for(;T.length>0;){let w=T.shift();if(w instanceof oe)for(let E of w._deps){let R=E.node;if(u.has(R))continue;let M=R.name??"",O=M;if(!O||k.has(O))if(M){let G=2;for(;k.has(`${M}#${G}`);)G++;O=`${M}#${G}`}else for(O=`__internal__/${_++}`;k.has(O);)O=`__internal__/${_++}`;u.set(R,O),k.add(O),d.push([O,R]),T.push(R)}}}let c=[...a,...d],l={};for(let[T,k]of c){if(t!=null&&!k.allowsObserve(t))continue;let _=Pn(k,i,o),w=k instanceof oe?k._deps.map(O=>u.get(O.node)??O.node.name??""):[],{name:E,...R}=_,M={...R,deps:w};if(!o){let O=this._annotations.get(T);O!=null&&(M.annotation=O)}if(r!=null)if(typeof r=="function"){let O=r;if(!(O.length>=2?O(T,M):O(M)))continue}else{let O=!0;for(let[G,P]of Object.entries(r)){let L=G==="deps_includes"?"depsIncludes":G==="meta_has"?"metaHas":G;if(L==="depsIncludes"){if(!M.deps.includes(String(P))){O=!1;break}continue}if(L==="metaHas"){if(!Object.hasOwn(M.meta??{},String(P))){O=!1;break}continue}if(M[L]!==P){O=!1;break}}if(!O)continue}l[T]=M}let p=new Set(Object.keys(l)),f=[];for(let[T,k]of c)if(k instanceof oe)for(let _ of k._deps){let w=u.get(_.node);w!=null&&f.push([w,T])}f.sort((T,k)=>T[0]<k[0]?-1:T[0]>k[0]?1:T[1]<k[1]?-1:T[1]>k[1]?1:0);let h=f.map(([T,k])=>({from:T,to:k}));(t!=null||r!=null)&&(h=h.filter(T=>p.has(T.from)&&p.has(T.to)));let g=this._collectSubgraphs(""),m=t!=null||r!=null?g.filter(T=>{let k=`${T}${ee}`;return[...p].some(_=>_===T||_.startsWith(k))}):g,y=this,b=e;return{name:this.name,nodes:l,edges:h,subgraphs:m,...this._factory!==void 0?{factory:this._factory}:{},...this._factoryArgs!==void 0?{factoryArgs:this._factoryArgs}:{},expand(T){let k={...b};return Array.isArray(T)?(k.fields=T,k.detail=void 0):(k.detail=T,k.fields=void 0),y.describe(k)}}}_collectSubgraphs(e){let t=[];for(let r of[...this._mounts.keys()].sort()){let s=e===""?r:`${e}${r}`;t.push(s),t.push(...this._mounts.get(r)._collectSubgraphs(`${s}${ee}`))}return t}resourceProfile(e){return No(this,e)}reachable(e,t,r={}){return r.withDetail===!0?Mo(this.describe(),e,t,{...r,withDetail:!0}):Mo(this.describe(),e,t,r)}explain(e,t,r){return r?.reactive===!0?this._explainReactive(e,t,r):this._explainStatic(Ke(e),Ke(t),{...r?.maxDepth!==void 0?{maxDepth:So(r.maxDepth)}:{},...r?.findCycle!==void 0?{findCycle:Eo(r.findCycle)}:{}})}_explainStatic(e,t,r){let s=this.describe({detail:"full"}),o=new Map(this._annotations),i=new Map;for(let[a,u]of Object.entries(s.nodes))u.lastMutation!=null&&i.set(a,u.lastMutation);return vo(s,e,t,{...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{},annotations:o,lastMutations:i})}_describeReactive(e){let t={...e,reactive:!1},r=e.reactiveName??"describe",s=0,o=F(s,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,u=!1,d=()=>{a||u||(a=!0,rt(()=>{a=!1,!u&&(s+=1,o.emit(s))}))},c=i.onEvent(b=>{let v=b.type;v!=="data"&&v!=="error"&&v!=="complete"&&v!=="teardown"||d()}),l=[],p=new WeakSet,f=b=>{if(p.has(b)||u)return;p.add(b);let v=b.topology.subscribe(T=>{for(let k of T){if(k[0]!==x)continue;let _=k[1];if(d(),_.kind==="added"&&_.nodeKind==="mount"){let w=b._mounts.get(_.name);w!=null&&f(w)}}});l.push(v);for(let T of b._mounts.keys()){let k=b._mounts.get(T);k!=null&&f(k)}};f(this);let h,g=e.actor;Ao(g)&&(h=g.subscribe(b=>{let v=!1,T=!1;for(let k of b){let _=k[0];_===x?v=!0:(_===N||_===S||_===z)&&(T=!0)}v&&d(),T&&(h?.(),h=void 0,d())}));let m;try{m=be([o],()=>this.describe(t),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(b,v)=>b===v})}catch(b){c(),h?.();for(let v of l)v();throw i.dispose(),b}let y=Ye(m);return{node:m,dispose(){u=!0,c(),h?.();for(let b of l)b();l.length=0,i.dispose(),y()}}}_describeReactiveDiff(e){let t={...e,reactive:!1},r=e.reactiveName??"describe-diff",s={name:this.name,nodes:{},edges:[],subgraphs:[]},o=this.describe(t),i=Mt(s,o),a=F(i,{name:r,meta:{domain:"audit",kind:"describe-diff"},equals:(p,f)=>p===f}),u=this._describeReactive({...e,reactiveName:void 0}),d=!1,c=u.node.subscribe(p=>{if(!d)for(let f of p){if(f[0]!==x)continue;let h=f[1],g=Mt(o,h);o=h,g.events.length!==0&&a.emit(g)}}),l=Ye(a);return{node:a,dispose(){d=!0,c(),u.dispose(),a.down([[z,"describe-diff disposed"]]),l()}}}_explainReactive(e,t,r){let s=0,o=F(s,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,u=!1,d=()=>{a||u||(a=!0,rt(()=>{a=!1,!u&&(s+=1,o.emit(s))}))},c=i.onEvent(b=>{let v=b.type;v!=="data"&&v!=="error"&&v!=="complete"&&v!=="teardown"||d()}),l=[];e!=null&&Qe(e)&&l.push(e),t!=null&&Qe(t)&&l.push(t),r?.maxDepth!=null&&Qe(r.maxDepth)&&l.push(r.maxDepth),r?.findCycle!=null&&Qe(r.findCycle)&&l.push(r.findCycle);let p=()=>{for(let b of l)if(b.cache===void 0)return!1;return!0},f=()=>{let b=Ke(e),v=Ke(t);return{from:b,to:v,found:!1,reason:"pending",steps:[],text:"(awaiting reactive args)",toJSON:()=>({from:b,to:v,found:!1,reason:"pending",steps:[]})}},h;try{h=be([o],()=>{if(!p())return f();let b=Ke(e),v=Ke(t),T={...r?.maxDepth!==void 0?{maxDepth:So(r.maxDepth)}:{},...r?.findCycle!==void 0?{findCycle:Eo(r.findCycle)}:{}};return this._explainStatic(b,v,T)},{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:Ke(e),to:Ke(t)},equals:(b,v)=>b.found===v.found&&b.reason===v.reason&&b.steps.length===v.steps.length&&Va(b.steps,v.steps)})}catch(b){throw c(),i.dispose(),b}let g=Ye(h),m=[],y=b=>{let v;return v=b.subscribe(T=>{let k=!1,_=!1;for(let w of T){let E=w[0];E===x?k=!0:(E===N||E===S||E===z)&&(_=!0)}(k||_)&&d(),_&&v&&(v(),v=void 0)}),()=>{v&&(v(),v=void 0)}};for(let b of l)m.push(y(b));return{node:h,dispose(){u=!0,c();for(let b of m)b?.();m.length=0,i.dispose(),g()}}}_pathsMatching(e){let t=tn(e),r=[];return this._collectObserveTargets("",r),r.map(([s])=>s).filter(s=>t.test(s))}_collectObserveTargets(e,t){for(let r of[...this._mounts.keys()].sort()){let s=e===""?r:`${e}${ee}${r}`;this._mounts.get(r)._collectObserveTargets(s,t)}for(let r of[...this._nodes.keys()].sort()){let s=this._nodes.get(r),o=e===""?r:`${e}${ee}${r}`;t.push([o,s]),this._appendMetaObserveTargets(o,s,t)}}_appendMetaObserveTargets(e,t,r){for(let s of Object.keys(t.meta).sort()){let o=t.meta[s],i=`${e}${ee}${Me}${ee}${s}`;r.push([i,o]),this._appendMetaObserveTargets(i,o,r)}}observe(e,t){let r=typeof e=="string",o=Ro(r?t:e);if(o.reactive===!0)return this._observeReactive(r?e:void 0,o);let i=o.structured===!0||o.timeline===!0||o.causal===!0||o.derived===!0||o.detail==="minimal"||o.detail==="full"||o.format!=null,a=o.actor;if(r){let c=e,l=this.resolve(c);if(a!=null&&!l.allowsObserve(a))throw new Ee({actor:a,action:"observe",nodeName:c});return i?this._buildStructuredObserver([[c,l]],o,"one"):{subscribe(p){return l.subscribe(p)},up(p){try{l.up?.(p)}catch(f){if(f instanceof Ee)return;throw f}}}}let u=[];this._collectObserveTargets("",u),u.sort((c,l)=>c[0]<l[0]?-1:c[0]>l[0]?1:0);let d=a==null?u:u.filter(([,c])=>c.allowsObserve(a));return i?this._buildStructuredObserver(d,o,"all"):{subscribe:c=>{let l=d.map(([p,f])=>f.subscribe(h=>{c(p,h)}));return()=>{for(let p of l)p()}},up:(c,l)=>{try{this.resolve(c).up?.(l)}catch(p){if(p instanceof Ee)return;throw p}}}}_observeReactive(e,t){let r=t.tiers,s=r!=null?new Set(r):null,o=t.reactiveName??"observe";return A(i=>{let a=[],u=!1,d=!1,c=()=>{if(a.length===0||d)return;let g={events:a.slice(),flushedAt_ns:re()};a.length=0,i.emit(g)},l={...t,reactive:!1,structured:!0,timeline:!0},p=e!=null?this.observe(e,l):this.observe(l),f=g=>{d||(a.push(g),!u&&(u=!0,rt(()=>{u=!1,c()})))};for(let g of p.events)f(g);let h=p.onEvent(f);return()=>{d=!0,h(),p.dispose()}},{name:o,meta:{domain:"audit",kind:"observe-reactive"}})}_buildStructuredObserver(e,t,r){let s=r==="one"?e[0]?.[0]:void 0,o=i=>{if(r==="one"&&s!=null){let c=this.resolve(s);return this._buildStructuredObserver([[s,c]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((c,l)=>c[0]<l[0]?-1:c[0]>l[0]?1:0);let u=i.actor,d=u==null?a:a.filter(([,c])=>c.allowsObserve(u));return this._buildStructuredObserver(d,i,"all")};return this._createObserveResult(e,t,o)}_createObserveResult(e,t,r){let s=t.timeline===!0,o=t.causal===!0,i=t.derived===!0,a=t.detail==="minimal",u=this.config.inspectorEnabled,d=(o||i)&&u,c=t.maxEvents,l=c!=null&&c>0?new Le(c):null,p=[],f=new Set,h=t.tiers!=null?new Set(t.tiers):null,g={},m=new Set,y=0,b=0,v=0,T=0,k=0,_=0,w=!1,E=!1,R=0,M=new Map,O=new Map,G=new Map,P=I=>{if(!(h!=null&&!h.has(I.type))){l?l.push(I):p.push(I);for(let Q of f)Q(I)}},L=I=>h==null||h.has(I),ue=()=>s?{timestamp_ns:re(),in_batch:It(),batch_id:R}:{},U=(I,Q)=>{if(!(!d||!(I instanceof oe)))return I._setInspectorHook(Te=>{if(Te.kind==="dep_message")M.set(I,Te.depIndex);else if(Te.kind==="run"){let $e=Te.batchData.map((j,he)=>j!=null&&j.length>0?j.at(-1):Te.prevData[he]);O.set(I,$e);let we=Te.batchData.map(j=>j!=null?[...j]:void 0);G.set(I,we),i&&P({type:"derived",path:Q,dep_values:$e,dep_batches:we,...ue()})}})},de=I=>{let Q=M.get(I),Te=O.get(I);if(!o||Te==null)return{};let we=(Q!=null&&Q>=0&&I instanceof oe?I._deps[Q]:void 0)?.node,j=we?.v,he=G.get(I);return{trigger_dep_index:Q,trigger_dep_name:we?.name,...j!=null?{trigger_version:{id:j.id,version:j.version}}:{},dep_values:[...Te],...he!=null?{dep_batches:he}:{}}},_e=[],Ve=[];for(let[I,Q]of e){let Te=U(Q,I);Te&&_e.push(Te),Ve.push(Q.subscribe($e=>{R++;for(let we of $e){let j=we[0],he=ue();if(j===x){g[I]=we[1];let yt=Q instanceof oe?Q.lastMutation?.actor??st:st;P({type:"data",path:I,data:we[1],actor:yt,...he,...de(Q)})}else if(a)j===V?L("dirty")&&y++:j===C?L("resolved")&&b++:j===ke?L("invalidate")&&v++:j===le?L("pause")&&T++:j===pe?L("resume")&&k++:j===z?L("teardown")&&_++:j===N&&!m.has(I)?L("complete")&&(w=!0):j===S&&L("error")&&(E=!0,m.add(I));else if(j===V)L("dirty")&&y++,P({type:"dirty",path:I,...he});else if(j===C)L("resolved")&&b++,P({type:"resolved",path:I,...he,...de(Q)});else if(j===ke)L("invalidate")&&v++,P({type:"invalidate",path:I,...he});else if(j===le)L("pause")&&T++,P({type:"pause",path:I,lockId:we[1],...he});else if(j===pe)L("resume")&&k++,P({type:"resume",path:I,lockId:we[1],...he});else if(j===N)L("complete")&&!m.has(I)&&(w=!0),P({type:"complete",path:I,...he});else if(j===S){L("error")&&(E=!0,m.add(I));let yt=Q instanceof oe?Q.lastMutation?.actor??st:st;P({type:"error",path:I,data:we[1],actor:yt,...he})}else j===z&&(L("teardown")&&_++,P({type:"teardown",path:I,...he}))}}))}let Se=!1,xe=()=>{if(!Se){Se=!0;for(let I of Ve)I();for(let I of _e)I();for(let I of Ge)I({value:void 0,done:!0});Ge.length=0}},Fe=[],Ge=[];f.add(I=>{let Q=Ge.shift();Q?Q({value:I,done:!1}):Fe.push(I)});let ze={get values(){return g},get dirtyCount(){return y},get resolvedCount(){return b},get invalidateCount(){return v},get pauseCount(){return T},get resumeCount(){return k},get teardownCount(){return _},get events(){return l?l.toArray():[...p]},get anyCompletedCleanly(){return w},get anyErrored(){return E},get completedWithoutErrors(){return w&&!E},onEvent(I){return f.add(I),()=>f.delete(I)},dispose:xe,expand(I){xe();let Q={...t};return typeof I=="string"?Q.detail=I:Object.assign(Q,I),r(Ro(Q))},[Symbol.asyncIterator](){return{next(){return Fe.length>0?Promise.resolve({value:Fe.shift(),done:!1}):Se?Promise.resolve({value:void 0,done:!0}):new Promise(I=>Ge.push(I))},return(){return xe(),Promise.resolve({value:void 0,done:!0})}}}};return t.format!=null&&this._attachFormatLogger(ze,t),ze}_attachFormatLogger(e,t){let r=t.format;if(r==null)return;let s=t.logger??(h=>console.log(h)),o=t.includeTypes?new Set(t.includeTypes):null,i=t.excludeTypes?new Set(t.excludeTypes):null,a=o==null&&i==null?()=>!0:h=>(o==null||o.has(h))&&(i==null||!i.has(h)),u=Pa(t.theme),d=r==="stage-log"?re():0,c=h=>h==null?"":t.stageLabels?.[h]??h,l=(h,g)=>h.length>g?`${h.slice(0,g-1)}\u2026`:h,p=h=>h.type==="data"||h.type==="error"?l(nr(h.data),120):"",f=h=>{if(r==="stage-log"){let w=(re()-d)/1e9,E=c(h.path).padEnd(9);if(h.type==="data"){let R=p(h);return`[${w.toFixed(3)}s] ${E} \u2190${R?` ${R}`:""}`}if(h.type==="error"){let R=p(h);return`[${w.toFixed(3)}s] ${E} \u2717${R?` ${R}`:""}`}return h.type==="complete"?`[${w.toFixed(3)}s] ${E} \u25A0 complete`:`[${w.toFixed(3)}s] ${E} ${h.type}`}if(r==="json")try{return JSON.stringify(h)}catch{return JSON.stringify({type:h.type,path:h.path,data:"[unserializable]"})}let g=u[h.type]??"",m=h.path?`${u.path}${h.path}${u.reset} `:"",y=h.type==="data"||h.type==="error",b=h.type==="pause"||h.type==="resume",v=y?` ${nr(h.data)}`:b?` ${nr(h.lockId)}`:"",T=h.type==="data"||h.type==="resolved"||h.type==="derived"?h:void 0,k=T?.trigger_dep_name!=null?` <- ${T.trigger_dep_name}`:T?.trigger_dep_index!=null?` <- #${T.trigger_dep_index}`:"",_=h.in_batch?" [batch]":"";return`${m}${g}${h.type.toUpperCase()}${u.reset}${v}${k}${_}`};e.onEvent(h=>{a(h.type)&&s(f(h),h)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){_o(this._disposers,this.name),this.signal([[z]],{internal:!0}),_o(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}get destroyed(){return this._destroyed}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}snapshot(e){let{expand:t,...r}=this.describe({detail:"full"}),s={};for(let a of Object.keys(r.nodes).sort()){let{lastMutation:u,guard:d,...c}=r.nodes[a];s[a]=c}let o=[...r.subgraphs].sort(),i={...r,version:1,nodes:s,subgraphs:o};if(e?.format==null)return i;if(e.format==="json-string")return JSON.stringify(i);if(e.format==="bytes"){if(e.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let a=this.config.lookupCodec(e.codec);if(a==null)throw new Error(`snapshot: codec "${e.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return Tr(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,t){let r=t?.config??me,{codec:s,codecVersion:o,payload:i}=wr(e,r);return s.decode(i,o)}restore(e,t){if(Oo(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let r=t?.only==null?null:(Array.isArray(t.only)?t.only:[t.only]).map(o=>tn(o)),s=t?.includeProducers===!0;for(let o of Object.keys(e.nodes).sort()){if(r!==null&&!r.some(a=>a.test(o)))continue;let i=e.nodes[o];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&t?.onError?.(o,new Error(`restore: slice.value is undefined for "${o}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!s)){if(i.v!=null){let u=this.tryResolve(o)?.v;if(u!=null&&u.id===i.v.id&&u.version===i.v.version)continue}try{this.set(o,i.value)}catch(a){t?.onError?.(o,a)}}}}}static fromSnapshot(e,t){Oo(e);let r=typeof t=="function"?t:t?.build,s=typeof t=="function"?void 0:t?.factories,o=new n(e.name);if(r)return r(o),o.restore(e),o;for(let f of[...e.subgraphs].sort((h,g)=>{let m=h.split(ee).length,y=g.split(ee).length;return m!==y?m-y:h<g?-1:h>g?1:0})){let h=f.split(ee),g=o;for(let m of h)g._mounts.has(m)||g.mount(m,new n(m)),g=g._mounts.get(m)}let i=s?Object.entries(s).map(([f,h])=>({re:tn(f),factory:h})):[],a=f=>{for(let h of i)if(h.re.test(f))return h.factory},u=f=>{let h=f.split(ee),g=h.pop();if(g==null||g.length===0)throw new Error(`invalid snapshot path "${f}"`);let m=o;for(let y of h){let b=m._mounts.get(y);if(!b)throw new Error(`unknown mount "${y}" in path "${f}"`);m=b}return[m,g]},d=Object.entries(e.nodes).filter(([f])=>!f.includes(`${ee}${Me}${ee}`)).sort((f,h)=>f[0]<h[0]?-1:f[0]>h[0]?1:0),c=new Map(d),l=new Map,p=!0;for(;c.size>0&&p;){p=!1;for(let[f,h]of[...c.entries()]){let g=h?.deps??[];if(!g.every(k=>l.has(k)))continue;let[m,y]=u(f),b={...h?.meta??{}},v=a(f),T;if(h?.type==="state")T=F(h.value,{meta:b});else{if(v==null)continue;T=v(y,{path:f,type:h.type,value:h.value,meta:b,deps:g,resolvedDeps:g.map(k=>l.get(k))})}m.add(T,{name:y}),l.set(f,T),c.delete(f),p=!0}}if(c.size>0){let f=[...c.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${f}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return o.restore(e),o}toJSON(){return this.snapshot()}attachSnapshotStorage(e,t={}){let r=e.map(d=>({tier:d,debounceMs:Math.max(0,d.debounceMs??0),compactEvery:Math.max(1,d.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));t.autoRestore===!0&&this._cascadeRestore(e,t.onError);let s=(d,c)=>{if(d.disposed)return;let l=Oa(c.nodes);if(d.lastSnapshot!=null&&l!==""&&l===d.lastFingerprint)return;let p=d.seq+1,f=te(),m=d.lastSnapshot==null||p%d.compactEvery===0?{name:this.name,mode:"full",snapshot:c,seq:p,timestamp_ns:f,format_version:pt}:{name:this.name,mode:"diff",diff:Ba(d.lastSnapshot,c),seq:p,timestamp_ns:f,format_version:pt};if(d.tier.filter&&!d.tier.filter(m))return;let y;try{y=d.tier.save(m)}catch(b){t.onError?.(b,d.tier);return}if(y&&typeof y.then=="function"){let T=(d.savePending??Promise.resolve()).then(()=>y,()=>y).then(()=>{d.disposed||(d.seq=p,d.lastSnapshot=c,d.lastFingerprint=l)},k=>{t.onError?.(k,d.tier)});d.savePending=T.finally(()=>{d.savePending===T&&(d.savePending=void 0)})}else d.seq=p,d.lastSnapshot=c,d.lastFingerprint=l},o=(d,c)=>{try{s(d,c)}catch(l){t.onError?.(l,d.tier)}},i=(d,c)=>{if(!c.some(h=>{let g=this.config.messageTier(h[0]);return g>=3&&g<5}))return;if(t.filter){let h=this.tryResolve(d);if(h==null)return;let g=Pn(h,Cn("standard"));if(!t.filter(d,g))return}let p,f=()=>(p==null&&(p=this.snapshot()),p);for(let h of r)h.disposed||(h.debounceMs===0?o(h,f()):(h.timer==null&&(h.timer=new Pe),h.timer.start(h.debounceMs,()=>{h.disposed||o(h,this.snapshot())})))},a;if(t.paths!=null){let c=(typeof t.paths=="string"?this._pathsMatching(t.paths):t.paths).map(l=>{let p=this.tryResolve(l);return p==null?()=>{}:p.subscribe(f=>i(l,f))});a=()=>{for(let l of c)l()}}else a=this.observe().subscribe((d,c)=>i(d,c));let u=()=>{a();for(let d of r)d.disposed=!0,d.timer?.cancel();this._storageDisposers.delete(u)};return this._storageDisposers.add(u),{dispose:u}}async _cascadeRestore(e,t){for(let r of e){let s;try{s=await r.load?.()}catch(i){t?.(i,r);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let o=s;try{if(o.mode==="full"&&o.snapshot!=null)return this.restore(o.snapshot),!0;if(o.version===pt&&o.nodes!=null)return this.restore(o),!0}catch(i){t?.(i,r)}}return!1}static async fromStorage(e,t,r){for(let s of t){let o;try{o=await s.load?.()}catch(u){r?.onError?.(u,s);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let i=o,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===pt&&i.nodes!=null?i:void 0;if(a!=null)try{return n.fromSnapshot(a,r)}catch(u){r?.onError?.(u,s)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${e}" across ${t.length} tier(s)`)}_annotations=new Map;_traceRing;trace(e,t,r){if(e!=null&&t!=null){if(this.tryResolve(e)==null)return;if(this._annotations.set(e,t),this.config.inspectorEnabled){let s={path:e,annotation:t,timestamp_ns:re(),...r?.actor!=null?{actor:r.actor}:{}};this._traceRing.push(s)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let t=this._traceRing.toArray().filter(s=>!e(s)),r=this._traceRing.size-t.length;this._traceRing.clear();for(let s of t)this._traceRing.push(s);return r}static diff(e,t){let r=new Set(Object.keys(e.nodes)),s=new Set(Object.keys(t.nodes)),o=[...s].filter(b=>!r.has(b)).sort(),i=[...r].filter(b=>!s.has(b)).sort(),a=[],u=[];for(let b of r){if(!s.has(b))continue;let v=e.nodes[b],T=t.nodes[b],k=v.v,_=T.v;k!=null&&_!=null&&k.id===_.id&&k.version!==_.version&&u.push({path:b,id:k.id,from:k.version,to:_.version});let w=k!=null&&_!=null&&k.id===_.id&&k.version===_.version;for(let E of["type","status","sentinel"]){let R=v[E],M=T[E];R!==M&&a.push({path:b,field:E,from:R,to:M})}if(!w)for(let E of["value","meta"]){let R=v[E],M=T[E];Ra(R,M)||a.push({path:b,field:E,from:R,to:M})}}let d=b=>`${b.from} ${b.to}`,c=new Set(e.edges.map(d)),l=new Set(t.edges.map(d)),p=t.edges.filter(b=>!c.has(d(b))),f=e.edges.filter(b=>!l.has(d(b))),h=new Set(e.subgraphs),g=new Set(t.subgraphs),m=[...g].filter(b=>!h.has(b)).sort(),y=[...h].filter(b=>!g.has(b)).sort();return{nodesAdded:o,nodesRemoved:i,nodesChanged:a,versionChanges:u,edgesAdded:p,edgesRemoved:f,subgraphsAdded:m,subgraphsRemoved:y}}};function Ba(n,e){let t=Xe.diff(n,e),r={};for(let s of t.nodesAdded){let o=e.nodes[s];o!=null&&(r[s]=o)}return{...t,nodesAddedFull:r}}function Mo(n,e,t,r={}){let s={paths:[],depths:new Map,truncated:!1};if(!e)return r.withDetail?s:[];if(!r.both&&t!=="upstream"&&t!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let o=r.maxDepth;if(o!=null&&(!Number.isInteger(o)||o<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(o===0)return r.withDetail?s:[];let i=new Map,a=new Map,u=new Map,d=new Map,c=new Set;for(let[v,T]of Object.entries(n.nodes)){if(!v)continue;c.add(v);let k=T.deps??[];i.set(v,k);for(let _ of k)_&&(c.add(_),a.has(_)||a.set(_,new Set),a.get(_).add(v))}for(let v of n.edges){if(v==null||typeof v!="object")continue;let T=typeof v.from=="string"?v.from:"",k=typeof v.to=="string"?v.to:"";!T||!k||(c.add(T),c.add(k),d.has(T)||d.set(T,new Set),d.get(T).add(k),u.has(k)||u.set(k,new Set),u.get(k).add(T))}if(!c.has(e))return r.withDetail?s:[];let l=r.both===!0,p=v=>{if(l){let w=i.get(v)??[],E=u.get(v),R=a.get(v),M=d.get(v),O=[...w];return E&&O.push(...E),R&&O.push(...R),M&&O.push(...M),O}if(t==="upstream"){let w=i.get(v)??[],E=u.get(v);return E?[...w,...E]:w}let T=a.get(v),k=d.get(v),_=T?[...T]:[];return k&&_.push(...k),_},f=new Set([e]),h=new Map,g=[{path:e,depth:0}],m=0,y=!1;for(;m<g.length;){let v=g[m++];if(o!=null&&v.depth>=o){p(v.path).length>0&&(y=!0);continue}for(let T of p(v.path))!T||f.has(T)||(f.add(T),h.set(T,v.depth+1),g.push({path:T,depth:v.depth+1}))}let b=[...h.keys()].sort((v,T)=>v<T?-1:v>T?1:0);return r.withDetail?{paths:b,depths:h,truncated:y}:b}function Va(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++){let r=n[t],s=e[t];if(r.path!==s.path||r.type!==s.type||r.status!==s.status||r.hop!==s.hop||r.dep_index!==s.dep_index||r.annotation!==s.annotation||r.value!==s.value||r.lastMutation!==s.lastMutation)return!1;let o=r.v,i=s.v;if(o!==i&&(o==null||i==null||o.id!==i.id||o.version!==i.version))return!1}return!0}ye();X();ge();fe();De();var nn=class{_version=0;_maxSize;_buf;_head=0;_size=0;constructor(e,t){if(t!==void 0&&t<1)throw new RangeError("maxSize must be >= 1");if(this._maxSize=t,t!==void 0){if(this._buf=new Array(t),e&&e.length>0){let r=Math.min(e.length,t),s=e.length-r;for(let o=0;o<r;o++)this._buf[o]=e[s+o];this._size=r}}else this._buf=e?[...e]:[],this._size=this._buf.length}get version(){return this._version}get size(){return this._size}at(e){if(!Number.isInteger(e))return;let t=e>=0?e:this._size+e;if(!(t<0||t>=this._size))return this._maxSize!==void 0?this._buf[(this._head+t)%this._maxSize]:this._buf[t]}append(e){this._rawAppend(e),this._version+=1}appendMany(e){if(e.length===0)return;let t=this._maxSize!==void 0&&e.length>this._maxSize?e.length-this._maxSize:0;for(let r=t;r<e.length;r++)this._rawAppend(e[r]);this._version+=1}clear(){if(this._size===0)return 0;let e=this._size;if(this._maxSize===void 0)this._buf.length=0;else for(let t=0;t<e;t++)this._buf[(this._head+t)%this._maxSize]=void 0;return this._head=0,this._size=0,this._version+=1,e}trimHead(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`trimHead: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return 0;let t=Math.min(e,this._size);if(this._maxSize===void 0)this._buf.splice(0,t);else{for(let r=0;r<t;r++)this._buf[(this._head+r)%this._maxSize]=void 0;this._head=(this._head+t)%this._maxSize}return this._size-=t,this._version+=1,t}slice(e,t){if(!Number.isInteger(e)||e<0)throw new RangeError(`slice: start must be a non-negative integer (got ${e})`);if(t!==void 0&&(!Number.isInteger(t)||t<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${t})`);let r=t===void 0?this._size:Math.min(Math.max(t,0),this._size),s=Math.min(e,this._size);if(s>=r)return[];let o=r-s;if(this._maxSize===void 0)return this._buf.slice(s,r);let i=new Array(o);for(let a=0;a<o;a++)i[a]=this._buf[(this._head+s+a)%this._maxSize];return i}tail(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`tail: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return[];let t=Math.min(e,this._size);return this.slice(this._size-t,this._size)}toArray(){if(this._maxSize===void 0)return[...this._buf];let e=new Array(this._size);for(let t=0;t<this._size;t++)e[t]=this._buf[(this._head+t)%this._maxSize];return e}snapshot(){return this.toArray()}restore(e){if(this._maxSize===void 0){this._buf.length=0;for(let t=0;t<e.length;t++)this._buf.push(e[t]);this._size=this._buf.length}else{let t=this._maxSize;for(let o=0;o<t;o++)this._buf[o]=void 0;this._head=0;let r=Math.min(e.length,t),s=e.length-r;for(let o=0;o<r;o++)this._buf[o]=e[s+o];this._size=r}this._version+=1}_rawAppend(e){if(this._maxSize===void 0){this._buf.push(e),this._size=this._buf.length;return}this._size<this._maxSize?(this._buf[(this._head+this._size)%this._maxSize]=e,this._size+=1):(this._buf[this._head]=e,this._head=(this._head+1)%this._maxSize)}};function At(n){return n.subscribe(()=>{})}var Fa=64;function sr(n,e={}){let{name:t,maxSize:r,versioning:s,guard:o,backend:i}=e,a=i??new nn(n,r),u=F(a.toArray(),{name:t,describeKind:"state",equals:(w,E)=>w===E,...s!=null?{versioning:s}:{},...o!=null?{guard:o}:{}});function d(){let w=a.toArray();$(()=>{u.down([[V]],{internal:!0}),u.down([[x,w]],{internal:!0})})}let c=new Map,l=new Map,p=new Map;function f(w,E){return`${w}:${E===void 0?"END":E}`}function h(w){if(w.size<Fa)return;let E=w.keys().next();if(E.done)return;let R=w.get(E.value);R!==void 0&&R.dispose(),w.delete(E.value)}function g(w){let E=a.version;try{return w()}finally{a.version!==E&&d()}}function m(w){if(!Number.isInteger(w)||w<0)throw new RangeError(`tail: n must be a non-negative integer (got ${w})`);let E=c.get(w);if(E!==void 0)return c.delete(w),c.set(w,E),E.node;h(c);let R=be([u],([O])=>{let G=O;return w===0||G.length===0?[]:G.slice(Math.max(0,G.length-w))},{initial:a.tail(w),describeKind:"derived"}),M=At(R);return c.set(w,{node:R,dispose:M}),R}function y(w,E){if(!Number.isInteger(w)||w<0)throw new RangeError(`slice: start must be a non-negative integer (got ${w})`);if(E!==void 0&&(!Number.isInteger(E)||E<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${E})`);let R=f(w,E),M=l.get(R);if(M!==void 0)return l.delete(R),l.set(R,M),M.node;h(l);let O=be([u],([P])=>{let L=P;return E===void 0?L.slice(w):L.slice(w,E)},{initial:a.slice(w,E),describeKind:"derived"}),G=At(O);return l.set(R,{node:O,dispose:G}),O}function b(w){let E=p.get(w);if(E!==void 0)return E.node;let R=be([u,w],([O,G])=>{let P=O,L=Math.max(0,Math.trunc(G??0));return P.slice(L)},{initial:[],describeKind:"derived"}),M=At(R);return p.set(w,{node:R,dispose:M}),R}let v,T;function k(){v===void 0&&(v=B([u],(w,E,R)=>{let M=w[0],G=M!=null&&M.length>0?M.at(-1):R.prevData[0];if(G==null||G.length===0){E.down([[C]]);return}E.emit(G[G.length-1])},{name:t!=null?`${t}::lastValue`:"lastValue",describeKind:"derived",initial:a.size===0?void 0:a.at(a.size-1)}),T=be([u],([w])=>w.length>0,{name:t!=null?`${t}::hasLatest`:"hasLatest",describeKind:"derived",initial:a.size>0}),At(v),At(T))}let _={entries:u,get size(){return a.size},at(w){return a.at(w)},append(w){g(()=>a.append(w))},appendMany(w){w.length!==0&&g(()=>a.appendMany(w))},clear(){g(()=>a.clear())},trimHead(w){g(()=>a.trimHead(w))},withLatest(){return k(),u},get lastValue(){return k(),v},get hasLatest(){return k(),T},view(w){switch(w.kind){case"tail":return m(w.n);case"slice":return y(w.start,w.stop);case"fromCursor":return b(w.cursor)}},attach(w){let E=w.subscribe(R=>{for(let M of R)M[0]===x&&_.append(M[1])});return()=>E()},attachStorage(w){if(w.length===0)return()=>{};let E=new Map;for(let M of w)E.set(M,a.size);(async()=>{for(let M of w)if(typeof M.loadEntries=="function")try{let O=await Promise.resolve(M.loadEntries());O.entries.length>0&&a.size===0&&(a.restore(O.entries),E.set(M,O.entries.length),d());break}catch{}})();let R=u.subscribe(M=>{for(let O of M){if(O[0]!==x)continue;let G=O[1];for(let P of w){let L=E.get(P)??0;if(G.length<L){try{let U=P.appendEntries(G);U instanceof Promise&&U.catch(()=>{})}catch{}E.set(P,G.length);continue}if(G.length===L)continue;let ue=G.slice(L);E.set(P,G.length);try{let U=P.appendEntries(ue);U instanceof Promise&&U.catch(()=>{})}catch{}}}});return()=>R()},disposeAllViews(){for(let w of c.values())w.dispose();c.clear();for(let w of l.values())w.dispose();l.clear();for(let w of p.values())w.dispose();p.clear()},dispose(){for(let w of c.values())w.dispose();c.clear();for(let w of l.values())w.dispose();l.clear();for(let w of p.values())w.dispose();p.clear()}};return _}var or=new WeakMap;function Ga(n){let e=or.get(n);if(e)return e;let t=n.map(c=>c.cache??[]),r=t.flat(),s=F(r,{name:"mergeReactiveLogs",describeKind:"state",equals:(c,l)=>c===l}),o=n.map((c,l)=>[...t[l]??[]]),i=[];for(let c=0;c<n.length;c++){let l=c,p=n[l].subscribe(f=>{for(let h of f)if(h[0]===x)o[l]=[...h[1]],s.emit(o.flat());else if(h[0]===N){o[l]=[];let g=i[l];g!==void 0&&(i[l]=void 0,g())}else h[0]===S&&s.down([[S,h[1]]])});i.push(p)}let a=Ye(s),u=!1,d={node:s,dispose(){if(!u){u=!0;for(let c of i)c?.();i.length=0,a(),or.delete(n)}}};return or.set(n,d),d}function Ka(n,e){let t=n.cache??0;return t>=e?!1:(n.down([[V],[x,t+1]]),!0)}var Po=Sr((n,e)=>{n("observe"),n("signal"),e("write")});function za(n){let e=sr([],{name:n.name,maxSize:n.retainedLimit??1024,guard:n.guard??Po,...n.versioning!=null?{versioning:n.versioning}:{}});return e.withLatest(),n.graph&&n.graph.add(e.entries,{name:n.name}),e}function ir(n){if(n===null||typeof n!="object"||Object.isFrozen(n))return n;for(let e of Object.keys(n))ir(n[e]);return Object.freeze(n)}function ar(n){let e=n.cache,r=(typeof e=="number"&&Number.isFinite(e)?e:0)+1;return n.down([[V],[x,r]]),r}function Ct(n,e,t,r,s,o){let i=e(t,r,s);if(i===void 0)return;let a=o!=null?{...i,handlerVersion:o}:i;n.append(a)}function $a(n,e){let t=e.freeze??!0;return function(...s){let o=t?s.map(ir):s,i=te(),a=e.seq?ar(e.seq):void 0;try{let u=n(...o);return e.onSuccess&&Ct(e.audit,e.onSuccess,o,u,{t_ns:i,seq:a},e.handlerVersion),u}catch(u){if(e.onFailure){let d=u instanceof Error?u.name:typeof u;Ct(e.audit,e.onFailure,o,u,{t_ns:i,seq:a,errorType:d},e.handlerVersion)}throw u}}}function ja(n,e){let t=e.freeze??!0;return function(...s){let o=t?s.map(ir):s,i=te(),a,u,d=!1,c;try{$(()=>{e.seq&&(c=ar(e.seq));try{a=n(...o),e.onSuccess&&Ct(e.audit,e.onSuccess,o,a,{t_ns:i,seq:c},e.handlerVersion)}catch(l){throw u=l,d=!0,l}})}catch(l){if(d&&e.onFailure){let p=u instanceof Error?u.name:typeof u;Ct(e.audit,e.onFailure,o,u,{t_ns:i,seq:c,errorType:p},e.handlerVersion)}throw d?u:l}return a}}function Ua(n,e,t=0){let r=F(t,{name:e,describeKind:"state"});return n.add(r,{name:e}),r}function Wa(n,e,t,r=0){let s={},o=new Xe(e);for(let i of t){let a=F(r,{name:i,describeKind:"state"});o.add(a,{name:i}),s[i]=a}return n.mount(e,o),s}var ur=require("rxjs");X();function Ha(n,e){return e?.raw?new ur.Observable(t=>n.subscribe(s=>{if(!t.closed){t.next(s);for(let o of s){if(o[0]===S){t.error(o[1]);return}if(o[0]===N){t.complete();return}}}})):new ur.Observable(t=>n.subscribe(s=>{for(let o of s){if(t.closed)return;if(o[0]===x)t.next(o[1]);else if(o[0]===S){t.error(o[1]);return}else if(o[0]===N){t.complete();return}}}))}ye();X();ge();var rn=class{_version=0;_topics=new Set;get version(){return this._version}get topicCount(){return this._topics.size}hasTopic(e){return this._topics.has(e)}topicNames(){return this._topics.values()}createTopic(e){return this._topics.has(e)?!1:(this._topics.add(e),this._version+=1,!0)}removeTopic(e){let t=this._topics.delete(e);return t&&(this._version+=1),t}};function qa(n={}){let{backend:e}=n,t=e??new rn,r=new Map;function s(o){let i=r.get(o);return i===void 0&&(i=B({describeKind:"state"}),r.set(o,i),t.createTopic(o)),i}return{topic(o){return s(o)},publish(o,i){s(o).emit(i)},publishMany(o){$(()=>{for(let[i,a]of o)s(i).emit(a)})},removeTopic(o){let i=r.get(o);return i===void 0?!1:(r.delete(o),t.removeTopic(o),i.down([[z]]),!0)},has(o){return t.hasTopic(o)},get size(){return t.topicCount},topicNames(){return t.topicNames()}}}ye();X();fe();function Do(n,e){if(n===e)return 0;let t=typeof n;if(t===typeof e&&(t==="number"||t==="string"||t==="boolean"||t==="bigint")){let s=n,o=e;return s<o?-1:s>o?1:0}return String(n).localeCompare(String(e))}function Ja(n,e){let t=Do(n[0],e[0]);return t!==0?t:Do(n[1],e[1])}function Io(n){return[n.secondary,n.primary]}function ht(n,e){let t=Io(e),r=0,s=n.length;for(;r<s;){let o=r+s>>1;Ja(t,Io(n[o]))>0?r=o+1:s=o}return r}var on=class{_version=0;_buf=[];_byPrimary=new Map;get version(){return this._version}get size(){return this._buf.length}has(e){return this._byPrimary.has(e)}get(e){return this._byPrimary.get(e)?.value}upsert(e,t,r,s){let o=this._byPrimary.get(e),i={primary:e,secondary:t,value:r};if(o!==void 0&&s?.equals?.(o,i))return!1;if(o!==void 0){let u=ht(this._buf,o);this._buf.splice(u,1)}let a=ht(this._buf,i);return this._buf.splice(a,0,i),this._byPrimary.set(e,i),this._version+=1,o===void 0}upsertMany(e,t){let r=0;try{for(let s of e){let o=this._byPrimary.get(s.primary),i={primary:s.primary,secondary:s.secondary,value:s.value};if(o!==void 0&&t?.equals?.(o,i))continue;if(o!==void 0){let u=ht(this._buf,o);this._buf.splice(u,1)}let a=ht(this._buf,i);this._buf.splice(a,0,i),this._byPrimary.set(s.primary,i),r+=1}}finally{r>0&&(this._version+=1)}return r}delete(e){let t=this._byPrimary.get(e);if(t===void 0)return!1;let r=ht(this._buf,t);return this._buf.splice(r,1),this._byPrimary.delete(e),this._version+=1,!0}deleteMany(e){let t=0;try{for(let r of e){let s=this._byPrimary.get(r);if(s===void 0)continue;let o=ht(this._buf,s);this._buf.splice(o,1),this._byPrimary.delete(r),t+=1}}finally{t>0&&(this._version+=1)}return t}clear(){let e=this._buf.length;return e===0?0:(this._buf.length=0,this._byPrimary.clear(),this._version+=1,e)}toArray(){return[...this._buf]}toPrimaryMap(){let e=new Map;for(let t of this._buf)e.set(t.primary,t.value);return e}};function Ya(n){return n.subscribe(()=>{})}function Qa(n={}){let{name:e,versioning:t,equals:r,backend:s}=n,o=s??new on;function i(f){return f?.equals!==void 0||r===void 0?f:{...f,equals:r}}let a=F([],{name:e,describeKind:"state",equals:(f,h)=>f===h,...t!=null?{versioning:t}:{}}),u=be([a],([f])=>{let h=f,g=new Map;for(let m of h)g.set(m.primary,m.value);return g},{initial:o.toPrimaryMap(),describeKind:"derived"}),d=Ya(u),c=!1;function l(){let f=o.toArray();$(()=>{a.down([[V]]),a.down([[x,f]])})}function p(f){let h=o.version;try{return f()}finally{o.version!==h&&l()}}return{ordered:a,byPrimary:u,has(f){return o.has(f)},get(f){return o.get(f)},get size(){return o.size},upsert(f,h,g,m){return p(()=>o.upsert(f,h,g,i(m)))},upsertMany(f,h){let g=[...f];g.length!==0&&p(()=>o.upsertMany(g,i(h)))},delete(f){p(()=>o.delete(f))},deleteMany(f){let h=[...f];h.length!==0&&p(()=>o.deleteMany(h))},clear(){p(()=>o.clear())},dispose(){c||(c=!0,d())}}}ye();X();fe();var sn=class{_version=0;_buf;constructor(e){this._buf=e?[...e]:[]}get version(){return this._version}get size(){return this._buf.length}at(e){if(!Number.isInteger(e))return;let t=e>=0?e:this._buf.length+e;if(!(t<0||t>=this._buf.length))return this._buf[t]}append(e){this._buf.push(e),this._version+=1}appendMany(e){if(e.length===0)return;let t=this._buf.length;this._buf.length=t+e.length;for(let r=0;r<e.length;r++)this._buf[t+r]=e[r];this._version+=1}insert(e,t){if(!Number.isInteger(e)||e<0||e>this._buf.length)throw new RangeError(`insert: index ${e} out of range [0, ${this._buf.length}]`);this._buf.splice(e,0,t),this._version+=1}insertMany(e,t){if(!Number.isInteger(e)||e<0||e>this._buf.length)throw new RangeError(`insertMany: index ${e} out of range [0, ${this._buf.length}]`);t.length!==0&&(this._buf.splice(e,0,...t),this._version+=1)}pop(e){if(this._buf.length===0)throw new RangeError("pop from empty list");if(!Number.isInteger(e))throw new RangeError(`pop: index ${e} must be an integer`);let t=e>=0?e:this._buf.length+e;if(t<0||t>=this._buf.length)throw new RangeError(`pop: index ${e} out of range`);let[r]=this._buf.splice(t,1);return this._version+=1,r}clear(){let e=this._buf.length;return e===0?0:(this._buf.length=0,this._version+=1,e)}toArray(){return[...this._buf]}};function Xa(n,e={}){let{name:t,versioning:r,backend:s}=e,o=s??new sn(n),i=F(o.toArray(),{name:t,describeKind:"state",equals:(d,c)=>d===c,...r!=null?{versioning:r}:{}});function a(){let d=o.toArray();$(()=>{i.down([[V]]),i.down([[x,d]])})}function u(d){let c=o.version;try{return d()}finally{o.version!==c&&a()}}return{items:i,get size(){return o.size},at(d){return o.at(d)},append(d){u(()=>o.append(d))},appendMany(d){u(()=>o.appendMany(d))},insert(d,c){u(()=>o.insert(d,c))},insertMany(d,c){u(()=>o.insertMany(d,c))},pop(d=-1){return u(()=>o.pop(d))},clear(){u(()=>o.clear())},dispose(){}}}Ut();X();De();function Za(n,e={}){let t=e.keyFn??(s=>String(s)),r=new Map;return s=>{let o=t(s),i=r.get(o);if(i)return i;let a=n(s),u;a!=null&&typeof a.then=="function"?u=Promise.resolve(a):a!=null&&typeof a=="object"&&"subscribe"in a&&"cache"in a?u=Yn(a):a!=null&&typeof a=="object"&&Symbol.asyncIterator in a?u=(async()=>{let l=a[Symbol.asyncIterator]();try{let{value:p,done:f}=await l.next();if(f)throw new Error("singleFromAny: factory returned empty async iterable");return p}finally{await l.return?.()}})():a!=null&&typeof a=="object"&&Symbol.iterator in a?u=(async()=>{let l=a[Symbol.iterator]();try{let{value:p,done:f}=l.next();if(f)throw new Error("singleFromAny: factory returned empty iterable");return p}finally{l.return?.()}})():u=Promise.resolve(a);let d,c=()=>{r.get(o)===d&&r.delete(o)};return d=u.then(l=>(c(),l),l=>{throw c(),l}),r.set(o,d),d}}function eu(n,e={}){let t=e.keyFn??(s=>String(s)),r=new Map;return s=>{let o=t(s),i=r.get(o);if(i)return i;let a=ie(n(s));r.set(o,a);let u=a.subscribe(d=>{for(let c of d)if(c[0]===S||c[0]===N){r.get(o)===a&&r.delete(o),u();return}});return a}}De();function an(n){if(n===null||typeof n!="object")return n;if(Array.isArray(n))return n.map(an);let e=n,t=Object.keys(e).sort(),r={};for(let s of t)r[s]=an(e[s]);return r}function dr(n){return JSON.stringify(an(n),void 0,0)}var tu=new TextEncoder,nu=new TextDecoder("utf-8",{fatal:!0}),Pt={name:"json",version:1,encode(n){return tu.encode(dr(n))},decode(n){return JSON.parse(nu.decode(n))}};function ru(){return Pt}function un(){let n=new Map;return{name:"memory",read(e){let t=n.get(e);return t===void 0?void 0:new Uint8Array(t)},write(e,t){n.set(e,new Uint8Array(t))},delete(e){n.delete(e)},list(e){let t=[...n.keys()];return e?t.filter(r=>r.startsWith(e)).sort():t.sort()}}}function cr(n,e={}){let t=e.codec??Pt,r=e.name??n.name??"snapshot",s=e.keyOf??(l=>l.name??e.name??n.name??"snapshot"),o,i=0,a=e.compactEvery,u,d={name:r,debounceMs:e.debounceMs,compactEvery:a,filter:e.filter,keyOf:s,save(l){if(!(e.filter&&!e.filter(l))&&(o={snapshot:l},i+=1,a!==void 0&&i%a===0||!e.debounceMs))return c()},load(){let l=u??r,p=n.read(l);if(p!==void 0)return p instanceof Uint8Array?p.length===0?void 0:t.decode(p):Promise.resolve(p).then(f=>f===void 0||f.length===0?void 0:t.decode(f))},async flush(){await c()},async rollback(){o=void 0}};function c(){let l=o;if(!l)return;o=void 0;let p=s(l.snapshot),f=t.encode(l.snapshot),h=n.write(p,f);if(h instanceof Promise)return h.then(()=>{u=p});u=p}return d}function Lo(n,e={}){let t=e.codec??Pt,r=e.name??n.name??"append-log",s=e.keyOf??(p=>r),o=e.compactEvery,i=new Map,a=0,u,d={name:r,debounceMs:e.debounceMs,compactEvery:o,keyOf:s,appendEntries(p){if(p.length!==0){for(let f of p){let h=s(f),g=i.get(h);g||(g=[],i.set(h,g)),g.push(f)}if(a+=p.length,o!==void 0&&a%o===0||!e.debounceMs)return c()}},async loadEntries(p){let f=p?.keyFilter,h=n.list===void 0?f!==void 0?[f]:[r]:await Promise.resolve(n.list(f)),g=[];for(let m of h){let y=await Promise.resolve(n.read(m));if(y===void 0||y.length===0)continue;let b=t.decode(y);Array.isArray(b)&&g.push(...b)}return{entries:g,cursor:void 0}},async flush(){await c()},async rollback(){i=new Map}};function c(){if(i.size===0)return;let p=i;i=new Map;let f=(u??Promise.resolve()).then(()=>{let h=l(p);return h instanceof Promise?h:Promise.resolve()},()=>{let h=l(p);return h instanceof Promise?h:Promise.resolve()});return u=f.finally(()=>{u===f&&(u=void 0)}),u}function l(p){let f=[];for(let[h,g]of p){let m=n.read(h),y=b=>{let T=[...b===void 0||b.length===0?[]:t.decode(b)??[],...g],k=t.encode(T);return n.write(h,k)};if(m instanceof Promise)f.push(m.then(async b=>{let v=y(b);v instanceof Promise&&await v}));else{let b=y(m);b instanceof Promise&&f.push(b)}}if(f.length>0)return Promise.all(f).then(()=>{})}return d}function lr(n,e={}){let t=e.codec??Pt,r=e.name??n.name??"kv",s=e.compactEvery,o=new Map,i=0,a={name:r,debounceMs:e.debounceMs,compactEvery:s,filter:e.filter,save(d,c){if(!(e.filter&&!e.filter(d,c))&&(o.set(d,c),i+=1,s!==void 0&&i%s===0||!e.debounceMs))return u()},load(d){let c=n.read(d);if(c!==void 0)return c instanceof Uint8Array?c.length===0?void 0:t.decode(c):Promise.resolve(c).then(l=>l===void 0||l.length===0?void 0:t.decode(l))},delete(d){if(o.delete(d),!!n.delete)return n.delete(d)},list(d){return n.list?n.list(d):[]},async flush(){await u()},async rollback(){o=new Map}};function u(){if(o.size===0)return;let d=o;o=new Map;let c=[];for(let[l,p]of d){let f=t.encode(p),h=n.write(l,f);h instanceof Promise&&c.push(h)}if(c.length>0)return Promise.all(c).then(()=>{})}return a}function ou(n){return cr(un(),n)}function su(n){return Lo(un(),n)}function iu(n){return lr(un(),n)}function au(n,e){let t={name:e?.name??"dict-kv",read(r){return n[r]},write(r,s){n[r]=new Uint8Array(s)},delete(r){delete n[r]},list(r){let s=Object.keys(n).sort();return r?s.filter(o=>o.startsWith(r)):s}};return lr(t,e)}function uu(n,e){return cr({name:"dict",read(r){return n[r]},write(r,s){n[r]=new Uint8Array(s)},delete(r){delete n[r]},list(r){let s=Object.keys(n).sort();return r?s.filter(o=>o.startsWith(r)):s}},e)}X();ge();fe();function du(n,e,t,r){let s=new Xe(n,r);s.add(e,{name:"source"});let o=F(t,{meta:{kind:"stratify_rules"}});s.add(o,{name:"rules"});for(let i of t)cu(s,e,o,i);return s}function cu(n,e,t,r){let s=`branch/${r.name}`,o=Symbol("noValue"),i=!1,a=!1,u=!1,d=o,c=!1,l=t.cache??[];function p(g){if(u){u=!1;let m=d;if(d=o,m!==o){let y=l.find(v=>v.name===r.name),b=!1;try{b=y?.classify(m)??!1}catch{b=!1}b?(c=!1,g.emit(m)):c&&(c=!1,g.down([[V],[C]]))}else c?(c=!1,g.down([[V],[C]])):g.down([[C]])}}let f=B([],(g,m)=>{let y=e.subscribe(v=>{for(let T of v)h(T,0,m)}),b=t.subscribe(v=>{for(let T of v)h(T,1,m)});return()=>{y(),b()}},{describeKind:"derived",meta:{kind:"stratify_branch",branch:r.name},completeWhenDepsComplete:!1});function h(g,m,y){let b=g[0];return b===V?(m===0?(i=!0,c=!0):a=!0,!0):b===x||b===C?(m===0?(i=!1,u=!0,d=b===x?g[1]:o):(b===x&&(l=g[1]),a=!1),i||a||p(y),!0):b===N||b===S||b===z?(i=!1,a=!1,u=!1,d=o,c=!1,m===0&&y.down([g]),!0):m===1}if(n.add(f,{name:s}),r.ops){let g=r.ops(f),m=`branch/${r.name}/out`;n.add(g,{name:m})}}zt();function Bo(n,e,t,r=0){if(!Number.isFinite(n))return r;if(!Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0)return Math.max(r,n);let s=n*Math.exp(-t*e);return Math.max(r,s)}ye();X();ge();fe();De();X();var lu=new Map([[ke,"INVALIDATE"],[le,"PAUSE"],[pe,"RESUME"],[z,"TEARDOWN"],[N,"COMPLETE"],[S,"ERROR"]]),fu=new Map([["INVALIDATE",ke],["PAUSE",le],["RESUME",pe],["TEARDOWN",z],["COMPLETE",N],["ERROR",S]]);function Ze(n){let e=lu.get(n);return e||(Symbol.keyFor(n)??"UNKNOWN")}function mt(n){let e=fu.get(n);if(e)return e;if(n&&n!=="UNKNOWN")return Symbol.for(n)}function gt(n){return n instanceof Error?{message:n.message,name:n.name,stack:n.stack}:{message:String(n),name:"Error"}}function bt(n){let e=new Error(n.message);return e.name=n.name,n.stack&&(e.stack=n.stack),e}function et(n){if(typeof MessagePort<"u"&&n instanceof MessagePort)return{post(e,t){n.postMessage(e,t??[])},listen(e){let t=r=>e(r.data);return n.addEventListener("message",t),n.start(),()=>n.removeEventListener("message",t)},terminate(){n.close()}};if(typeof SharedWorker<"u"&&n instanceof SharedWorker)return et(n.port);if(typeof Worker<"u"&&n instanceof Worker)return{post(e,t){n.postMessage(e,t??[])},listen(e){let t=r=>e(r.data);return n.addEventListener("message",t),()=>n.removeEventListener("message",t)},terminate(){n.terminate()}};if(typeof BroadcastChannel<"u"&&n instanceof BroadcastChannel)return{post(e,t){t&&t.length>0&&console.warn("[graphrefly] WorkerTransport: BroadcastChannel does not support Transferable objects. The transfer argument is ignored and objects will be cloned instead."),n.postMessage(e)},listen(e){let t=r=>e(r.data);return n.addEventListener("message",t),()=>n.removeEventListener("message",t)},terminate(){n.close()}};if(typeof ServiceWorker<"u"&&n instanceof ServiceWorker)return{post(e,t){n.postMessage(e,t??[])},listen(e){let t=r=>{r.source===n&&e(r.data)};return navigator.serviceWorker.addEventListener("message",t),()=>navigator.serviceWorker.removeEventListener("message",t)}};throw new Error("createTransport: unsupported target type. Expected Worker, SharedWorker, ServiceWorker, BroadcastChannel, or MessagePort.")}function pu(n){return typeof n=="object"&&n!==null&&typeof n.post=="function"&&typeof n.listen=="function"}function Vo(n,e){let t=pu(n)?n:et(n),r=e.name??"workerBridge",s=Object.entries(e.expose??{}),o=e.import??[],i=e.transfer??{},a=F("connecting",{name:`${r}::meta::status`}),u=F(null,{name:`${r}::meta::error`}),d=new Map,c=new Map;for(let b of o){let v=F(void 0,{name:`${r}::${b}`});d.set(b,v)}let l;if(s.length>0){let b=s.map(([,k])=>k),v=B(b,(k,_)=>{let w={};for(let E=0;E<s.length;E++){let[R]=s[E],M=k[E];M!=null&&M.length>0&&(w[R]=M.at(-1))}Object.keys(w).length!==0&&_.emit(w)},{name:`${r}::aggregated`,partial:!0});l=Gt([v],k=>{let _=k[0];if(_==null||Object.keys(_).length===0)return;let w=[];for(let M of Object.keys(_)){let O=i[M];O&&w.push(...O(_[M]))}let E;for(let[M,O]of s)M in _&&O.v!=null&&(E==null&&(E={}),E[M]=O.v.version);let R={t:"b",u:_,...E?{v:E}:{}};try{t.post(R,w.length>0?w:void 0)}catch(M){u.down([[x,M instanceof Error?M:new Error(String(M))]])}}).subscribe(()=>{})}let p=!1,f=t.listen(b=>{if(p)return;let v=b;switch(v.t){case"r":{$(()=>{for(let[k,_]of Object.entries(v.stores)){let w=d.get(k);w&&w.down([[x,_]])}}),a.down([[x,"connected"]]);let T={};for(let[k,_]of s)T[k]=_.cache;t.post({t:"i",stores:T});break}case"v":{let T=d.get(v.s);T&&T.down([[x,v.d]]);break}case"b":{$(()=>{for(let[T,k]of Object.entries(v.u)){let _=v.v?.[T];if(_!=null){let E=c.get(T);if(E!=null&&_<=E)continue;c.set(T,_)}let w=d.get(T);w&&w.down([[x,k]])}});break}case"e":{let T=d.get(v.s);T&&T.down([[S,bt(v.err)]]);break}case"s":{let T=mt(v.sig);if(!T)break;let k=v.s==="*"?[...d.values()]:d.has(v.s)?[d.get(v.s)]:[];for(let _ of k)_.down(v.d===void 0?[[T]]:[[T,v.d]]);break}}}),h=[];for(let[b,v]of s){let T=v.subscribe((k=>{if(!p)for(let _ of k){let w=_[0];w!==x&&(me.isLocalOnly(w)||(w===S?t.post({t:"e",s:b,err:gt(_[1])}):t.post({t:"s",s:b,sig:Ze(w),d:_.length>1?_[1]:void 0})))}}));h.push(T)}let g;if(e.timeoutMs!=null&&e.timeoutMs>0){let b=qe(e.timeoutMs),v=Ht(a,k=>k==="connected");g=Qn(Et(Wt(b,()=>"timeout"),Wt(v,()=>"ready"))).subscribe(k=>{for(let _ of k)_[0]===x&&_[1]==="timeout"&&(u.down([[x,new Error("Worker bridge handshake timeout")]]),m())})}function m(){if(!p){p=!0,g?.(),t.post({t:"s",s:"*",sig:Ze(z)}),l&&l();for(let b of h)b();h.length=0,f(),a.down([[x,"closed"]]),c.clear(),d.clear()}}let y={meta:{status:a,error:u},destroy:m};for(let[b,v]of d)y[b]=v;return y}ye();X();ge();fe();function hu(n){return typeof n=="object"&&n!==null&&typeof n.post=="function"&&typeof n.listen=="function"}function Fo(n,e){let t=hu(n)?n:et(n),r=e.import??[],s=e.transfer??{},o=new Map,i=new Map,a={};for(let m of r){let y=F(void 0,{name:`worker::${m}`});o.set(m,y),a[m]=y}let u=e.expose(a),d=Object.entries(u),c,l=!1;if(d.length>0){let m=d.map(([,v])=>v),y=B(m,(v,T)=>{let k={};for(let _=0;_<d.length;_++){let[w]=d[_],E=v[_];E!=null&&E.length>0&&(k[w]=E.at(-1))}Object.keys(k).length!==0&&T.emit(k)},{name:"workerSelf::aggregated",partial:!0});c=Gt([y],v=>{if(l)return;let T=v[0];if(T==null||Object.keys(T).length===0)return;let k=[];for(let E of Object.keys(T)){let R=s[E];R&&k.push(...R(T[E]))}let _;for(let[E,R]of d)E in T&&R.v!=null&&(_==null&&(_={}),_[E]=R.v.version);let w={t:"b",u:T,..._?{v:_}:{}};try{t.post(w,k.length>0?k:void 0)}catch{}}).subscribe(()=>{})}let p=[];for(let[m,y]of d){let b=y.subscribe((v=>{if(!l)for(let T of v){let k=T[0];k!==x&&(me.isLocalOnly(k)||(k===S?t.post({t:"e",s:m,err:gt(T[1])}):t.post({t:"s",s:m,sig:Ze(k),d:T.length>1?T[1]:void 0})))}}));p.push(b)}let f=t.listen(m=>{if(l)return;let y=m;switch(y.t){case"i":{$(()=>{for(let[b,v]of Object.entries(y.stores)){let T=o.get(b);T&&T.down([[x,v]])}});break}case"v":{let b=o.get(y.s);b&&b.down([[x,y.d]]);break}case"b":{$(()=>{for(let[b,v]of Object.entries(y.u)){let T=y.v?.[b];if(T!=null){let _=i.get(b);if(_!=null&&T<=_)continue;i.set(b,T)}let k=o.get(b);k&&k.down([[x,v]])}});break}case"e":{let b=o.get(y.s);b&&b.down([[S,bt(y.err)]]);break}case"s":{let b=mt(y.sig);if(!b)break;if(b===z&&y.s==="*"){g();return}let v=y.s==="*"?[...o.values()]:o.has(y.s)?[o.get(y.s)]:[];for(let T of v)T.down(y.d===void 0?[[b]]:[[b,y.d]]);break}}}),h={};for(let[m,y]of d)h[m]=y.cache;t.post({t:"r",stores:h});function g(){if(!l){l=!0,c&&c();for(let m of p)m();p.length=0,f(),t.terminate?.(),i.clear(),o.clear()}}return{destroy:g}}0&&(module.exports={CircuitOpenError,ContentAddressedMissError,DEFAULT_AUDIT_GUARD,NS_PER_MS,NS_PER_SEC,NativeIndexBackend,NativeListBackend,NativeLogBackend,NativeMapBackend,NativePubSubBackend,RateLimiterOverflowError,ResettableTimer,TimeoutError,appendAudit,appendLogStorage,audit,awaitSettled,budgetGate,buffer,bufferCount,bufferTime,bumpCursor,cached,canonicalJson,cascadingCache,catchError,checkpointToRedis,checkpointToS3,circuitBreaker,combine,combineLatest,concat,concatMap,constant,contentAddressedStorage,createAuditLog,createTransport,createWatermarkController,csvRows,debounce,debounceTime,decay,decorrelatedJitter,defer,delay,deserializeError,dictKv,dictSnapshot,distill,distinctUntilChanged,domainMeta,elementAt,empty,escapeRegexChar,exhaustMap,exponential,externalBundle,externalProducer,fallback,fibonacci,filter,find,first,firstValueFrom,firstWhere,flatMap,forEach,fromAny,fromAsyncIter,fromCSV,fromClickHouseWatch,fromCron,fromDrizzle,fromEvent,fromHTTP,fromHTTPPoll,fromHTTPStream,fromIter,fromKafka,fromKysely,fromMCP,fromNATS,fromNDJSON,fromOTel,fromPrisma,fromPrometheus,fromPromise,fromPulsar,fromRabbitMQ,fromRaf,fromRedisStream,fromSSE,fromSqlite,fromSqliteCursor,fromStatsD,fromSyslog,fromTimer,fromWebSocket,fromWebSocketReconnect,fromWebhook,globToRegExp,interval,jsonCodec,jsonCodecFor,keepalive,kvStorage,last,lightMutation,linear,lru,makeHttpError,map,matchesAnyPattern,matchesCron,memoryAppendLog,memoryBackend,memoryKv,memorySnapshot,merge,mergeMap,mergeReactiveLogs,nameToSignal,ndjsonRows,never,nodeSignal,of,onFirstData,pairwise,parseCron,parsePrometheusText,parseSSEStream,parseStatsD,parseSyslog,pausable,pubsub,race,rateLimiter,reactiveCounter,reactiveIndex,reactiveList,reactiveLog,reactiveMap,reactiveSink,reduce,registerCursor,registerCursorMap,repeat,replay,rescue,resolveBackoffPreset,retry,sample,scan,serializeError,share,shareReplay,signalToName,singleFromAny,singleNodeFromAny,skip,snapshotStorage,sortJsonValue,stableJsonString,stratify,switchMap,take,takeUntil,takeWhile,tap,tapFirst,throttle,throttleTime,throwError,timeout,toArray,toCSV,toClickHouse,toFile,toHTTP,toKafka,toLoki,toMongo,toNATS,toObservable,toPostgres,toPulsar,toRabbitMQ,toReadableStream,toRedisStream,toS3,toSSE,toSSEBytes,toSqlite,toTempo,toWebSocket,tokenBucket,topologyDiff,tryIncrementBounded,valve,verifiable,window,windowCount,windowTime,withBreaker,withLatestFrom,withMaxAttempts,withStatus,workerBridge,workerSelf,wrapMutation,zip});
18
+ `:JSON.stringify(f),h=s(l,te());await e.putObject({Bucket:t,Key:h,Body:p,ContentType:c})}})}function ra(n,e,t,r){let{toSQL:o=(i,a)=>({sql:`INSERT INTO "${a.replace(/"/g,'""')}" (data) VALUES ($1)`,params:[JSON.stringify(i)]}),onTransportError:s}=r??{};return ae(n,{onTransportError:s,serialize:i=>o(i,t),send:async i=>{let a=i;await e.query(a.sql,a.params)}})}function oa(n,e,t){let{toDocument:r=s=>s,onTransportError:o}=t??{};return ae(n,{onTransportError:o,serialize:r,send:async s=>{await e.insertOne(s)}})}function sa(n,e,t){let{labels:r={},toLine:o=a=>JSON.stringify(a),toLabels:s,onTransportError:i}=t??{};return ae(n,{onTransportError:i,serialize:a=>({line:o(a),labels:s?{...r,...s(a)}:r}),send:async a=>{let{line:u,labels:d}=a,c=`${te()}`;await e.push({streams:[{stream:d,values:[[c,u]]}]})}})}function ia(n,e,t){let{toResourceSpans:r=s=>[s],onTransportError:o}=t??{};return ae(n,{onTransportError:o,serialize:r,send:async s=>{await e.push({resourceSpans:s})}})}function aa(n,e,t,r){let{prefix:o="checkpoints/",debounceMs:s=500,compactEvery:i=10,onError:a}=r??{},u={name:`s3:${t}`,debounceMs:s,compactEvery:i,save(d){let c=Math.floor(te()/1e6),l=`${o}${n.name}/checkpoint-${c}.json`,f;try{f=JSON.stringify(d)}catch(p){a?.(p);return}e.putObject({Bucket:t,Key:l,Body:f,ContentType:"application/json"}).catch(p=>a?.(p))}};return n.attachSnapshotStorage([u],{onError:d=>a?.(d)})}function ua(n,e,t){let{prefix:r="graphrefly:checkpoint:",debounceMs:o=500,compactEvery:s=10,onError:i}=t??{},a=`${r}${n.name}`,u={name:`redis:${a}`,debounceMs:o,compactEvery:s,save(d){let c;try{c=JSON.stringify(d)}catch(l){i?.(l);return}e.set(a,c).catch(l=>i?.(l))},async load(){let d=await e.get(a);if(d!=null)try{return JSON.parse(d)}catch{return}}};return n.attachSnapshotStorage([u],{onError:d=>i?.(d)})}function da(n,e,t){let{mapRow:r=i=>i,params:o,...s}=t??{};return A(i=>{try{let u=n.query(e,o).map(r);i.emit(u),i.down([[N]])}catch(a){i.down([[S,a instanceof Error?a:new Error(String(a))]])}},{describeKind:"producer",completeWhenDepsComplete:!1,...s})}function ca(n,e,t){let{mapRow:r=i=>i,params:o,...s}=t??{};return A(i=>{try{let a=n.iterate(e,o);$(()=>{for(let u of a)i.emit(r(u));i.down([[N]])})}catch(a){i.down([[S,a instanceof Error?a:new Error(String(a))]])}},{describeKind:"producer",completeWhenDepsComplete:!1,...s})}function la(n,e,t,r){if(t.includes("\0")||t.length===0)throw new Error(`toSqlite: invalid table name: ${JSON.stringify(t)}`);let{toSQL:o=(P,L)=>({sql:`INSERT INTO "${L.replace(/"/g,'""')}" (data) VALUES (?)`,params:[JSON.stringify(P)]}),onTransportError:s,batchInsert:i=!1,maxBatchSize:a=1e3,flushIntervalMs:u=0}=r??{},d=P=>o(P,t);if(!i)return ae(n,{onTransportError:s,serialize:d,send:P=>{let L=P;e.query(L.sql,L.params)}});let c=F(null),l=F(void 0,{equals:()=>!1}),f=F(null),p=F(0),h=F(0),g=P=>{try{s?.(P)}catch{}try{c.down([[x,P]])}catch{}},m=[],y=!1,b,v=!1,T=()=>h.down([[x,m.length]]),w=P=>{v||l.down([[x,P]])},_=P=>{v||f.down([[x,P]])},k=P=>{v||p.down([[x,P]])},E=P=>{v||g(P)},O=()=>{if(m.length===0||y)return;y=!0,k(1);try{e.query("BEGIN",[])}catch(U){y=!1,k(0),E({stage:"send",error:U instanceof Error?U:new Error(String(U)),value:void 0});return}let P=m;m=[],T();let L,ue=0;for(let U of P)try{e.query(U.query.sql,U.query.params),ue+=1}catch(de){L=de instanceof Error?de:new Error(String(de));break}if(L){try{e.query("ROLLBACK",[])}catch{}E({stage:"send",error:L,value:void 0});for(let U of P)_({value:U.value,error:L,attempts:1})}else try{e.query("COMMIT",[]);for(let U of P)w(U.value)}catch(U){let de=U instanceof Error?U:new Error(String(U));E({stage:"send",error:de,value:void 0});for(let _e=0;_e<ue;_e++)_({value:P[_e].value,error:de,attempts:1})}y=!1,k(0)},R=()=>{u>0&&b===void 0&&!v&&(b=setTimeout(()=>{b=void 0,O()},u))},M=n.subscribe(P=>{for(let L of P){let ue=L[0];if(ue===x){let U=L[1],de;try{de=d(U)}catch(_e){let Ve=_e instanceof Error?_e:new Error(String(_e));g({stage:"serialize",error:Ve,value:U}),f.down([[x,{value:U,error:Ve,attempts:0}]]);continue}m.push({value:U,query:de}),T(),m.length>=a?O():R()}else me.messageTier(ue)>=3&&O()}});return{dispose:()=>{if(!v){b!==void 0&&(clearTimeout(b),b=void 0),O(),v=!0,M();for(let P of[c,l,f,p,h])try{P.down([[K]])}catch{}}},sent:l,failed:f,inFlight:p,errors:c,buffered:h,flush:async()=>{v||O()}}}function fa(n,e){let{args:t,mapRow:r=s=>s,...o}=e??{};return A(s=>{let i=!0;return n.findMany(t).then(a=>{i&&(s.emit(a.map(r)),s.down([[N]]))}).catch(a=>{if(i)try{s.down([[S,a instanceof Error?a:new Error(String(a))]])}catch{}}),()=>{i=!1}},{...o,describeKind:"producer",completeWhenDepsComplete:!1})}function pa(n,e){let{mapRow:t=o=>o,...r}=e??{};return A(o=>{let s=!0;return n.execute().then(i=>{s&&(o.emit(i.map(t)),o.down([[N]]))}).catch(i=>{if(s)try{o.down([[S,i instanceof Error?i:new Error(String(i))]])}catch{}}),()=>{s=!1}},{...r,describeKind:"producer",completeWhenDepsComplete:!1})}function ha(n,e){let{mapRow:t=o=>o,...r}=e??{};return A(o=>{let s=!0;return n.execute().then(i=>{s&&(o.emit(i.map(t)),o.down([[N]]))}).catch(i=>{if(s)try{o.down([[S,i instanceof Error?i:new Error(String(i))]])}catch{}}),()=>{s=!1}},{...r,describeKind:"producer",completeWhenDepsComplete:!1})}kt();X();var ma=0;function ga(n,e){if(e.highWaterMark<1)throw new RangeError("highWaterMark must be >= 1");if(e.lowWaterMark<0)throw new RangeError("lowWaterMark must be >= 0");if(e.lowWaterMark>=e.highWaterMark)throw new RangeError("lowWaterMark must be < highWaterMark");let t=Symbol(`bp-${++ma}`),r=0,o=!1;return{onEnqueue(){return r+=1,!o&&r>=e.highWaterMark?(o=!0,n([[le,t]]),!0):!1},onDequeue(){return r>0&&(r-=1),o&&r<=e.lowWaterMark?(o=!1,n([[pe,t]]),!0):!1},get pending(){return r},get paused(){return o},dispose(){o&&(o=!1,n([[pe,t]]))}}}X();fe();function fo(){let n=new Map,e=null,t=null;function r(s){s.prev?s.prev.next=s.next:e=s.next,s.next?s.next.prev=s.prev:t=s.prev,s.prev=null,s.next=null}function o(s){s.next=e,s.prev=null,e&&(e.prev=s),e=s,t===null&&(t=s)}return{insert(s){if(n.has(s)){this.touch(s);return}let i={key:s,prev:null,next:null};n.set(s,i),o(i)},touch(s){let i=n.get(s);i&&(r(i),o(i))},delete(s){let i=n.get(s);i&&(r(i),n.delete(s))},evict(s){let i=[];for(let a=0;a<s&&t!==null;a++){let u=t;i.push(u.key),r(u),n.delete(u.key)}return i},size(){return n.size}}}function po(n){return n!=null&&typeof n.then=="function"}function ft(n){po(n)&&n.catch(()=>{})}function ba(n,e){let t=new Map,r=e?.maxSize??0,o=r>0?e?.eviction??fo():null,s=e?.writeThrough??!1;function i(d,c,l){for(let f=0;f<l;f++)try{ft(n[f].save(d,c))}catch{}}function a(d,c,l=0){for(let f=l;f<n.length;f++){let p;try{p=n[f].load(d)}catch{continue}if(po(p)){let h=f;p.then(g=>{g!==void 0?(c.down([[x,g]]),i(d,g,h)):a(d,c,h+1)},()=>{a(d,c,h+1)});return}if(p!==void 0){c.down([[x,p]]),i(d,p,f);return}}}function u(){if(!(!o||r<=0))for(;o.size()>=r;){let d=o.evict(1);if(d.length===0)break;for(let c of d){let l=t.get(c);if(l){let f=l.cache;if(l.status!=="sentinel"&&n.length>0){let p=n.length-1;try{ft(n[p].save(c,f))}catch{}for(let h=0;h<p;h++)try{let g=n[h].delete;g&&ft(g.call(n[h],c))}catch{}}l.down([[K]])}t.delete(c)}}}return{load(d){let c=t.get(d);if(c)return o?.touch(d),c;o&&r>0&&o.size()>=r&&u();let l=F(void 0);return t.set(d,l),o?.insert(d),a(d,l),l},save(d,c){if(s)for(let f of n)try{ft(f.save(d,c))}catch{}else if(n[0])try{ft(n[0].save(d,c))}catch{}let l=t.get(d);if(l)l.down([[x,c]]),o?.touch(d);else{o&&r>0&&o.size()>=r&&u();let f=F(c);t.set(d,f),o?.insert(d)}},invalidate(d){let c=t.get(d);c&&a(d,c)},delete(d){o?.delete(d);let c=t.get(d);c&&c.down([[K]]),t.delete(d);for(let l of n)try{let f=l.delete;f&&ft(f.call(l,d))}catch{}},has(d){return t.has(d)},get size(){return t.size}}}ye();X();xt();fe();ye();Ae();X();fe();var Qt=class{_version=0;_store=new Map;_maxSize;_defaultTtl;constructor(e={}){let{maxSize:t,defaultTtl:r}=e;if(t!==void 0&&t<1)throw new RangeError("maxSize must be >= 1");if(r!==void 0&&r<=0)throw new RangeError("defaultTtl must be positive");this._maxSize=t,this._defaultTtl=r}get version(){return this._version}get size(){return this._store.size}has(e){let t=this._store.get(e);return t===void 0?!1:this._isExpired(t)?(this._store.delete(e),this._version+=1,!1):(this._touchLru(e,t),!0)}get(e){let t=this._store.get(e);if(t!==void 0){if(this._isExpired(t)){this._store.delete(e),this._version+=1;return}return this._touchLru(e,t),t.value}}set(e,t,r){let o=this._resolveExpiresAt(r);this._store.has(e)&&this._store.delete(e),this._store.set(e,{value:t,expiresAt:o}),this._evictLruWhileOver(),this._version+=1}setMany(e,t){let r=this._resolveExpiresAt(t),o=0;try{for(let[s,i]of e)this._store.has(s)&&this._store.delete(s),this._store.set(s,{value:i,expiresAt:r}),o+=1}finally{o>0&&(this._evictLruWhileOver(),this._version+=1)}}delete(e){let t=this._store.delete(e);return t&&(this._version+=1),t}deleteMany(e){let t=0;try{for(let r of e)this._store.delete(r)&&(t+=1)}finally{t>0&&(this._version+=1)}return t}clear(){let e=this._store.size;return e===0?0:(this._store.clear(),this._version+=1,e)}pruneExpired(){let e=re(),t=0;for(let[r,o]of this._store)this._isExpired(o,e)&&(this._store.delete(r),t+=1);return t>0&&(this._version+=1),t}toMap(){let e=re(),t=new Map;for(let[r,o]of this._store)this._isExpired(o,e)||t.set(r,o.value);return t}_resolveExpiresAt(e){let t=e??this._defaultTtl;if(t!==void 0){if(!Number.isFinite(t)||t<=0)throw new RangeError(`MapBackend: ttl must be a positive finite number (got ${t})`);return re()+t*1e9}}_isExpired(e,t){return e.expiresAt===void 0?!1:(t??re())>=e.expiresAt}_touchLru(e,t){this._store.delete(e),this._store.set(e,t)}_evictLruWhileOver(){if(this._maxSize!==void 0)for(;this._store.size>this._maxSize;){let e=this._store.keys().next().value;if(e===void 0)break;this._store.delete(e)}}};function tr(n={}){let{name:e,maxSize:t,defaultTtl:r,versioning:o,backend:s,retention:i}=n;if(i&&t!==void 0)throw new RangeError("reactiveMap: `maxSize` (LRU) and `retention` (score-based) are mutually exclusive. Pick one eviction policy.");if(i&&i.archiveThreshold===void 0&&i.maxSize===void 0)throw new RangeError("reactiveMap: `retention` requires at least one of `archiveThreshold` or `maxSize` to trigger archival.");let a=s??new Qt({maxSize:t,defaultTtl:r}),u=F(a.toMap(),{name:e,describeKind:"state",equals:(f,p)=>f===p,...o!=null?{versioning:o}:{}});function d(){let f=a.toMap();$(()=>{u.down([[V]]),u.down([[x,f]])})}function c(){if(!i)return;let f=a.toMap(),p=i.archiveThreshold,h=i.maxSize,g=[];for(let[y,b]of f)g.push({key:y,value:b,score:i.score(y,b)});g.sort((y,b)=>y.score-b.score);let m=new Set;if(p!==void 0)for(let y of g)if(y.score<p)m.add(y.key);else break;if(h!==void 0&&g.length-m.size>h)for(let y of g){if(g.length-m.size<=h)break;m.has(y.key)||m.add(y.key)}if(m.size!==0)for(let y of g)m.has(y.key)&&(i.onArchive?.(y.key,y.value,y.score),a.delete(y.key))}function l(f,p="mutation"){let h=a.version;try{return f()}finally{a.version!==h&&(p==="mutation"&&c(),d())}}return{entries:u,has(f){return l(()=>a.has(f),"read")},get(f){return l(()=>a.get(f),"read")},set(f,p,h){l(()=>a.set(f,p,h?.ttl))},setMany(f,p){l(()=>a.setMany(f,p?.ttl))},delete(f){l(()=>a.delete(f))},deleteMany(f){l(()=>a.deleteMany(f))},clear(){l(()=>a.clear())},pruneExpired(){l(()=>a.pruneExpired())},get size(){return a.size},dispose(){}}}De();function ya(n){return typeof n=="object"&&n!==null&&"cache"in n&&typeof n.subscribe=="function"}function va(n,e,t){let r=ie(n),o=r.v!=null,s=F(t?.initialVerified??null,{meta:{...q("verifiable"),...o?{sourceVersion:null}:{}}}),i=t?.trigger!==void 0&&t.trigger!==null,a=null;if(i&&t?.autoVerify?a=Et(ie(t.trigger),r):i?a=ie(t.trigger):t?.autoVerify&&(a=r),a!==null){let u;if(a===r)u=Be(r,d=>e(d));else{let d=r.cache;r.subscribe(c=>{for(let l of c)l[0]===x&&(d=l[1])}),u=Be(a,()=>e(d))}Je(u,d=>{$(()=>{if(s.down([[x,d]]),o){let c=r.v;c!=null&&s.meta.sourceVersion.down([[x,{id:c.id,version:c.version}]])}})})}return{node:r,verified:s,trigger:a}}function ho(n){n.subscribe(()=>{})}function Rt(n){return n instanceof Map?n:new Map}function mo(n,e){if(!Array.isArray(e.upsert))throw new TypeError("distill extraction requires upsert: Array<{ key, value }>");$(()=>{for(let{key:t,value:r}of e.upsert)n.set(t,r);for(let t of e.remove??[])n.delete(t)})}function Ta(n,e,t){let r=ie(n),o=tr(t.mapOptions??{}),s=t.budget??2e3,a=t.context!==void 0&&t.context!==null?ie(t.context):F(null),u=Rt(o.entries.cache);o.entries.subscribe(p=>{for(let h of p)h[0]===x&&(u=Rt(h[1]))});let d=ie(e(r,o.entries));if(Je(d,p=>{mo(o,p)}),t.evict){let p=new Map,h=be([o.entries],([g])=>{let m=[],y=Rt(g);for(let b of p.keys())y.has(b)||(p.get(b)(),p.delete(b));for(let[b,v]of y){let T=t.evict(b,v);if(ya(T)){if(!p.has(b)){let w=Je(T,_=>{_===!0&&o.has(b)&&o.delete(b)});p.set(b,w)}continue}if(typeof T=="boolean"){T&&m.push(b);continue}throw new TypeError("distill evict() must return boolean or Node<boolean>")}return m});Je(h,g=>{for(let m of g)o.delete(m)})}let c=t.consolidateTrigger!==void 0&&t.consolidateTrigger!==null;if(t.consolidate&&c){let p=ie(t.consolidateTrigger),h=Be(p,()=>t.consolidate(u));Je(h,g=>{mo(o,g)})}let l=be([o.entries,a],([p,h])=>{let g=[...Rt(p).entries()].map(([b,v])=>({key:b,value:v,score:t.score(v,h),cost:t.cost(v)}));g.sort((b,v)=>v.score-b.score);let m=[],y=s;for(let b of g)b.cost<=y&&(m.push({key:b.key,value:b.value,score:b.score}),y-=b.cost);return m},{meta:{...q("distill",{budget:s})}}),f=be([o.entries],([p])=>Rt(p).size);return ho(l),ho(f),{store:o,compact:l,size:f}}Ae();function nr(n,e){if(Object.is(n,e))return!0;if(n==null||e==null||typeof n!="object"||typeof e!="object")return!1;if(Array.isArray(n)){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let s=0;s<n.length;s++)if(!nr(n[s],e[s]))return!1;return!0}if(Array.isArray(e))return!1;let t=Object.keys(n),r=Object.keys(e);if(t.length!==r.length)return!1;let o=new Set(r);for(let s of t)if(!o.has(s)||!nr(n[s],e[s]))return!1;return!0}function go(n,e){return`${n}\0${e}`}function Mt(n,e){let t=[],r=new Set(n.subgraphs),o=new Set(e.subgraphs),s=[];for(let m of o)r.has(m)||s.push(m);s.sort();for(let m of s)t.push({type:"subgraph-mounted",path:m});let i=new Set(Object.keys(n.nodes)),a=new Set(Object.keys(e.nodes)),u=[];for(let m of a)i.has(m)||u.push(m);u.sort();for(let m of u)t.push({type:"node-added",path:m,node:{...e.nodes[m]}});let d=[];for(let m of a){if(!i.has(m))continue;let y=n.nodes[m]?.meta,b=e.nodes[m]?.meta;y==null&&b==null||nr(y??{},b??{})||d.push(m)}d.sort();for(let m of d)t.push({type:"node-meta-changed",path:m,prevMeta:n.nodes[m]?.meta??{},nextMeta:e.nodes[m]?.meta??{}});let c=new Map;for(let m of n.edges)c.set(go(m.from,m.to),m);let l=new Map;for(let m of e.edges)l.set(go(m.from,m.to),m);let f=[];for(let[m,y]of l)c.has(m)||f.push(y);f.sort((m,y)=>m.from<y.from?-1:m.from>y.from?1:m.to<y.to?-1:m.to>y.to?1:0);for(let m of f)t.push({type:"edge-added",from:m.from,to:m.to});let p=[];for(let[m,y]of c)l.has(m)||p.push(y);p.sort((m,y)=>m.from<y.from?-1:m.from>y.from?1:m.to<y.to?-1:m.to>y.to?1:0);for(let m of p)t.push({type:"edge-removed",from:m.from,to:m.to});let h=[];for(let m of i)a.has(m)||h.push(m);h.sort();for(let m of h)t.push({type:"node-removed",path:m});let g=[];for(let m of r)o.has(m)||g.push(m);g.sort();for(let m of g)t.push({type:"subgraph-unmounted",path:m});return{events:t,flushedAt_ns:re()}}async function bo(n){let e=typeof n=="string"?new TextEncoder().encode(n):n,t=await globalThis.crypto.subtle.digest("SHA-256",e),r=new Uint8Array(t),o="";for(let s=0;s<r.length;s++)o+=yo[r[s]];return o}var yo=new Array(256);for(let n=0;n<256;n++)yo[n]=n.toString(16).padStart(2,"0");var Xt=class extends Error{constructor(t,r){super(`content-addressed lookup miss in read-strict mode: ${t}`);this.key=t;this.context=r;this.name="ContentAddressedMissError"}};function vo(n){let e=new Set,t=r=>{if(r===null||typeof r!="object")return r;let o=r;if(e.has(o))return{__cycle:!0};e.add(o);try{if(Array.isArray(r))return r.map(t);let s={};for(let i of Object.keys(r).sort())s[i]=t(r[i]);return s}finally{e.delete(o)}};return JSON.stringify(t(n))}function wa(n){let{storage:e,keyContext:t,keyPrefix:r,mode:o="read-write"}=n,s=t??(a=>a);async function i(a){let u=vo(s(a)),d=await bo(u);return r?`${r}:${d}`:d}return{keyFor:i,async lookup(a){if(o==="write")return;let u=await i(a),d=await e.load(u);if(d===void 0){if(o==="read-strict")throw new Xt(u,a);return}return d},async store(a,u){if(o==="read")return;let d=await i(a);await e.save(d,u)},async forget(a){if(o==="read"||o==="write"||!e.delete)return;let u=await i(a);await e.delete(u)}}}Bn();async function ka(n,e){let t;try{t=await n.text()}catch{t=""}let r=e??"HTTP",o=new Error(`${r} API ${n.status}: ${n.statusText}${t?` \u2014 ${t}`:""}`);return o.status=n.status,o.headers=n.headers,o}Fn();ye();Ae();wt();X();fe();Tn();ye();Ae();wt();X();xt();ge();fe();De();Kt();$t();vn();function To(n,e,t,r={}){let o=e in n.nodes,s=t in n.nodes;if(!o)return Zt(e,t,"no-such-from");if(!s)return Zt(e,t,"no-such-to");let i=r.maxDepth;if(i!=null&&(!Number.isInteger(i)||i<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(e===t){if(r.findCycle===!0){let d=xa(n,e,r);if(d!=null)return d}let u=en(e,n.nodes[e],0,r);return tn(e,t,[u])}if(i===0)return Zt(e,t,"no-path");let a=wo(n,e,t,i);return a.found?tn(e,t,ko(n,a.pathOrder,r)):Zt(e,t,a.truncated?"max-depth-exceeded":"no-path")}function wo(n,e,t,r){let o=new Map,s=[{path:t,depth:0}],i=new Set([t]),a=0,u=!1;for(;a<s.length;){let l=s[a++];if(l.path===e)break;if(r!=null&&l.depth>=r){let g=n.nodes[l.path];g?.deps&&g.deps.length>0&&(u=!0);continue}let f=n.nodes[l.path];if(f==null)continue;let p=f.deps??[],h=new Map;for(let g=0;g<p.length;g++){let m=p[g];if(!m)continue;let y=h.get(m);y==null&&(y=[],h.set(m,y)),y.push(g)}for(let[g,m]of h)i.has(g)||(i.add(g),o.set(g,{from:l.path,depIndices:m}),s.push({path:g,depth:l.depth+1}))}if(!o.has(e))return{found:!1,pathOrder:[],truncated:u};let d=[{path:e}],c=e;for(;c!==t;){let l=o.get(c);if(l==null)return{found:!1,pathOrder:[],truncated:!1};d[d.length-1].depIndices=l.depIndices,d.push({path:l.from}),c=l.from}return{found:!0,pathOrder:d,truncated:!1}}function xa(n,e,t){let r=n.nodes[e];if(r==null)return null;let o=r.deps??[],s=[];for(let a=0;a<o.length;a++)o[a]===e&&s.push(a);if(s.length>0){let a=en(e,r,0,t);a.dep_index=s[0];let u=en(e,r,1,t);return tn(e,e,[a,u])}let i=null;for(let a=0;a<o.length;a++){let u=o[a];if(!u||u===e)continue;let d=wo(n,u,e,t.maxDepth);d.found&&(i==null||d.pathOrder.length<i.pathOrder.length)&&(i=d,i={found:!0,pathOrder:[{path:e,depIndices:[a]},...d.pathOrder],truncated:!1})}return i==null?null:tn(e,e,ko(n,i.pathOrder,t))}function ko(n,e,t){return e.map((r,o)=>{let s=n.nodes[r.path],i=en(r.path,s,o,t);return r.depIndices!=null&&r.depIndices.length>0&&(i.dep_index=r.depIndices[0],r.depIndices.length>1&&(i.dep_indices=[...r.depIndices])),i})}function en(n,e,t,r){let o={path:n,type:e.type,hop:t};e.status!==void 0&&(o.status=e.status),"value"in e&&(o.value=e.value),e.v!=null&&(o.v=e.v);let s=r.annotations?.get(n)??e.annotation;s!=null&&(o.annotation=s);let i=r.lastMutations?.get(n)??e.lastMutation;return i!=null&&(o.lastMutation=i),o}function tn(n,e,t){return xo(n,e,!0,"ok",t)}function Zt(n,e,t){return xo(n,e,!1,t,[])}function xo(n,e,t,r,o){let s=Na(n,e,t,r,o);return{from:n,to:e,found:t,reason:r,steps:o,text:s,toJSON(){return{from:n,to:e,found:t,reason:r,steps:o}}}}function Na(n,e,t,r,o){if(!t)switch(r){case"no-such-from":return`explainPath: no node named "${n}"`;case"no-such-to":return`explainPath: no node named "${e}"`;case"max-depth-exceeded":return`explainPath: no path from "${n}" to "${e}" within maxDepth`;default:return`explainPath: no path from "${n}" to "${e}"`}let s=[`Causal path: ${n} \u2192 ${e} (${o.length} step(s))`];for(let i of o){let u=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(s.push(u),"value"in i&&s.push(` value: ${_a(i.value)}`),i.annotation!=null&&s.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let d=i.lastMutation.actor;s.push(` actor: ${d.type}${d.id?`:${d.id}`:""}`)}}return s.join(`
19
+ `)}function _a(n){if(n===void 0)return"<sentinel>";if(n===null)return"null";if(typeof n=="string")return JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean"||typeof n=="bigint")return String(n);try{let e=JSON.stringify(n);return e.length>80?`${e.slice(0,77)}...`:e}catch{return String(n)}}ge();var se={object:56,array:64,string:40,number:8,boolean:4,null:0,undefined:0,symbol:40,bigint:16,function:120,map:72,set:72,mapEntry:40,setEntry:24,date:24,regexp:48,error:64,url:80,promise:48,weakmap:40,weakset:40},Sa=Symbol.for("sizeof");function No(n){let e=new WeakSet,t=new WeakSet,r=[n],o=0;for(;r.length>0;){let s=r.pop();o+=Ea(s,e,t,r)}return o}function Ea(n,e,t,r){if(n==null)return 0;switch(typeof n){case"number":return se.number;case"boolean":return se.boolean;case"string":return se.string+n.length*2;case"bigint":return se.bigint+Oa(n);case"symbol":return se.symbol;case"function":return e.has(n)?0:(e.add(n),se.function);case"undefined":return 0}let s=n;if(e.has(s))return 0;e.add(s);let i=s[Sa];if(typeof i=="function")try{let d=i.call(s);if(typeof d=="number"&&Number.isFinite(d))return d}catch{}if(s instanceof Date)return se.date;if(s instanceof RegExp)return se.regexp+s.source.length*2;if(s instanceof Error){let d=s.message?s.message.length*2:0,c=s.stack?s.stack.length*2:0;return se.error+d+c}if(typeof URL<"u"&&s instanceof URL)return se.url+s.href.length*2;if(typeof Promise<"u"&&s instanceof Promise)return se.promise;if(s instanceof WeakMap)return se.weakmap;if(s instanceof WeakSet)return se.weakset;if(s instanceof Map){let d=se.map;for(let[c,l]of s)d+=se.mapEntry,r.push(c),r.push(l);return d}if(s instanceof Set){let d=se.set;for(let c of s)d+=se.setEntry,r.push(c);return d}if(Array.isArray(s)){let d=se.array+s.length*8;for(let c of s)r.push(c);return d}if(s instanceof ArrayBuffer)return t.has(s)?0:(t.add(s),s.byteLength);if(ArrayBuffer.isView(s)){let d=s;return t.has(d.buffer)?48:(t.add(d.buffer),d.buffer.byteLength+48)}let a=se.object,u=Object.keys(s);for(let d of u){a+=se.string+d.length*2;try{r.push(s[d])}catch{}}return a}function Oa(n){let e=n<0n?-n:n;if(e===0n)return 0;let t=e.toString(2).length;return Math.ceil(t/32)*8}function _o(n,e){let t=e?.topN??10,r=n.describe({detail:"standard"}),o=[],s=n._collectObserveTargets;typeof s=="function"&&s.call(n,"",o);let i=new Map;for(let[f,p]of o)i.set(f,p);let a=[];for(let[f,p]of Object.entries(r.nodes)){let h=i.get(f),g=h instanceof oe?h:null,m=g?No(g.cache):0,y=g?g._sinkCount:0,b=p.deps?.length??0,v=p.type==="effect"&&y===0,T=y===0?p.type==="effect"?"orphan-effect":p.type==="derived"?"idle-derived":p.type==="producer"?"idle-producer":null:null;a.push({path:f,type:p.type,status:p.status??"unknown",valueSizeBytes:m,subscriberCount:y,depCount:b,isOrphanEffect:v,orphanKind:T})}let u=a.reduce((f,p)=>f+p.valueSizeBytes,0),d=(f,p)=>[...a].sort(p??((h,g)=>g[f]-h[f])).slice(0,t),c=a.filter(f=>f.orphanKind!=null),l=a.filter(f=>f.isOrphanEffect);return{nodeCount:a.length,edgeCount:r.edges.length,subgraphCount:r.subgraphs.length,nodes:a,totalValueSizeBytes:u,hotspots:{byValueSize:d("valueSizeBytes"),bySubscriberCount:d("subscriberCount"),byDepCount:d("depCount")},orphans:c,orphanEffects:l}}var ee="::",Me="__meta__",pt=1;function So(n,e){let t=Math.max(16,n.size*4),r=0;for(;n.size>0;){if(r++>=t){console.error(`[Graph "${e}".destroy] disposer drain exceeded cap (${t}); ${n.size} disposer(s) discarded`),n.clear();return}let o=n.values().next();if(o.done)return;let s=o.value;n.delete(s);try{s()}catch(i){console.error(`[Graph "${e}".destroy] disposer threw:`,i)}}}function Co(n){return n!=null&&typeof n=="object"&&"cache"in n&&typeof n.subscribe=="function"&&typeof n.down=="function"}function Ra(n){if(n!=null)return Co(n)?n.cache:n}function Qe(n){return n!=null&&typeof n=="object"&&"cache"in n&&typeof n.subscribe=="function"&&typeof n.down=="function"}function ze(n){return Qe(n)?n.cache??"":n}function Eo(n){return Qe(n)?n.cache??0:n}function Oo(n){return Qe(n)?n.cache??!1:n}function Ma(n){let e=[];for(let t of Object.keys(n).sort()){let r=n[t].v;r!=null&&e.push(`${t} ${r.id} ${r.version}`)}return e.join(`
20
+ `)}function Ro(n){if(n.version!==pt)throw new Error(`unsupported snapshot version ${String(n.version)} (expected ${pt})`);for(let e of["name","nodes","edges","subgraphs"])if(!(e in n))throw new Error(`snapshot missing required key "${e}"`);if(typeof n.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof n.nodes!="object"||n.nodes===null||Array.isArray(n.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(n.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(n.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function Aa(n,e){let t=new WeakMap,r=(o,s)=>{if(Object.is(o,s))return!0;if(o==null||s==null||typeof o!="object"||typeof s!="object")return!1;let i=t.get(o);if(i==null&&(i=new WeakSet,t.set(o,i)),i.has(s))return!0;i.add(s);let a=o.constructor,u=s.constructor;if(a!==u)return!1;if(o instanceof Date)return o.getTime()===s.getTime();if(o instanceof RegExp)return o.source===s.source&&o.flags===s.flags;if(Array.isArray(o)){let f=s;if(o.length!==f.length)return!1;for(let p=0;p<o.length;p++)if(!r(o[p],f[p]))return!1;return!0}if(o instanceof Map){let f=s;if(o.size!==f.size)return!1;for(let[p,h]of o)if(!f.has(p)||!r(h,f.get(p)))return!1;return!0}if(o instanceof Set){let f=s;if(o.size!==f.size)return!1;for(let p of o){let h=!1;for(let g of f)if(r(p,g)){h=!0;break}if(!h)return!1}return!0}if(ArrayBuffer.isView(o)){let f=o,p=s;if(f.length!==p.length)return!1;for(let h=0;h<f.length;h++)if(f[h]!==p[h])return!1;return!0}let d=Object.keys(o),c=Object.keys(s);if(d.length!==c.length)return!1;let l=new Set(c);for(let f of d)if(!l.has(f)||!r(o[f],s[f]))return!1;return!0};return r(n,e)}function Ca(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function nn(n){let e="^";for(let t=0;t<n.length;t+=1){let r=n[t];if(r==="*"){e+=".*";continue}if(r==="?"){e+=".";continue}if(r==="["){let o=n.indexOf("]",t+1);if(o<=t+1){e+="\\[";continue}let s=n.slice(t+1,o);s.startsWith("!")&&(s=`^${s.slice(1)}`),s=s.replace(/\\/g,"\\\\"),e+=`[${s}]`,t=o;continue}e+=Ca(r)}return e+="$",new RegExp(e)}var Pa={data:"\x1B[32m",dirty:"\x1B[33m",resolved:"\x1B[36m",invalidate:"\x1B[93m",pause:"\x1B[90m",resume:"\x1B[96m",complete:"\x1B[34m",error:"\x1B[31m",teardown:"\x1B[91m",derived:"\x1B[35m",path:"\x1B[90m",reset:"\x1B[0m"},Da={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function rr(n){if(typeof n=="string")return JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean"||n==null)return String(n);try{return JSON.stringify(n)}catch{return"[unserializable]"}}function Ia(n){return n==="none"?Da:n==="ansi"||n==null?Pa:{data:n.data??"",dirty:n.dirty??"",resolved:n.resolved??"",invalidate:n.invalidate??"",pause:n.pause??"",resume:n.resume??"",complete:n.complete??"",error:n.error??"",teardown:n.teardown??"",derived:n.derived??"",path:n.path??"",reset:n.reset??""}}function Mo(n){if(n==null)return{};let e=n.detail;return e==="full"?{...n,structured:n.structured??!0,timeline:n.timeline??!0,causal:n.causal??!0,derived:n.derived??!0}:e==="minimal"?{...n,structured:n.structured??!0}:n.format==="stage-log"?{...n,structured:n.structured??!0,timeline:n.timeline??!0}:n}function La(n,e,t){for(let r=0;r<n.length;r++){let o=n.charCodeAt(r);if(o<32||o===127)throw new Error(`Graph "${e}": ${t} "${n}" must not contain control character (U+${o.toString(16).padStart(4,"0").toUpperCase()} at index ${r})`)}}function or(n,e,t){if(n==="")throw new Error(`Graph "${e}": ${t} name must be non-empty`);if(n.includes(ee))throw new Error(`Graph "${e}": ${t} "${n}" must not contain '${ee}' (path separator)`);if(n===Me)throw new Error(`Graph "${e}": ${t} name "${Me}" is reserved for meta companion paths`);La(n,e,t)}function Ba(n,e){if(n==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let t=n.split(ee);for(let r of t)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return t}function Va(n,e){let t=!1;for(let o of n)if(!e.isMetaPassthrough(o[0])){t=!0;break}return t?n.filter(o=>e.isMetaPassthrough(o[0])):n}function Po(n){for(let e of n._mounts.values())Po(e);for(let e of n._nodes.values())try{e.down([[K]],{internal:!0})}catch{}}var Xe=class n{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_destroyed=!1;_topology;_topologyEmitters=new Set;_factory;_factoryArgs;constructor(e,t){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(ee))throw new Error(`Graph name must not contain '${ee}' (got "${e}")`);if(e===Me)throw new Error(`Graph name "${Me}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...t??{}}),this.config=t?.config??me,this._traceRing=new Le(t?.traceCapacity??1e3),t?.versioning!=null&&this.setVersioning(t.versioning),typeof t?.factory=="string"&&(this._factory=t.factory,t.factoryArgs!==void 0&&(this._factoryArgs=t.factoryArgs))}tagFactory(e,t){return this._factory=e,this._factoryArgs=t,this}ancestors(e=!0){let t=[],r=e?this:this._parent;for(;r!=null;)t.push(r),r=r._parent;return t}get topology(){return this._topology==null&&(this._topology=A(e=>{let t=r=>{e.emit(r)};return this._topologyEmitters.add(t),()=>{this._topologyEmitters.delete(t)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let t of this._topologyEmitters)t(e)}nameOf(e){return this._nodeToName.get(e)}add(e,t){let r=e.name,o=t?.name??r;if(o==null||o==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let s=o,i=t?.annotation;if(or(s,this.name,"add"),this._mounts.has(s))throw new Error(`Graph "${this.name}": name "${s}" is already a mount point`);if(this._nodes.has(s))throw new Error(`Graph "${this.name}": node "${s}" already exists`);let a=this._nodeToName.get(e);if(a!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${a}"`);return this._nodes.set(s,e),this._nodeToName.set(e,s),this._emitTopology({kind:"added",name:s,nodeKind:"node"}),i!=null&&(this._annotations.set(s,i),this.config.inspectorEnabled&&this._traceRing.push({path:s,annotation:i,timestamp_ns:re()})),e}setVersioning(e){if(e!=null)for(let t of this._nodes.values())t instanceof oe&&t._applyVersioning(e)}remove(e){or(e,this.name,"remove");let t=this._mounts.get(e);if(t){let s={kind:"mount",nodes:[],mounts:[]},i=[];t._collectObserveTargets("",i);for(let[a,u]of i)a.includes(`${ee}${Me}${ee}`)||s.nodes.push(a);return s.nodes.sort(),s.mounts.push(e),s.mounts.push(...t._collectSubgraphs(`${e}${ee}`)),this._mounts.delete(e),t._parent=void 0,Po(t),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:s}),s}let r=this._nodes.get(e);if(!r)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(r),r.down([[K]],{internal:!0});let o={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:o}),o}removeAll(e){let t=typeof e=="function"?e:(()=>{let s=nn(e);return i=>s.test(i)})(),r={kind:"mount",nodes:[],mounts:[]},o=[...this._nodes.keys(),...this._mounts.keys()].filter(s=>t(s));for(let s of o){let i=this.remove(s);r.nodes.push(...i.nodes),r.mounts.push(...i.mounts)}return r.nodes.sort(),r.mounts.sort(),r}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),t=this._nodes,r=0;return{[Symbol.iterator](){return this},next(){if(r>=e.length)return{value:void 0,done:!0};let o=e[r++];return{value:[o,t.get(o)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(ee))return this.resolve(e);let t=this._nodes.get(e);if(!t)throw new Error(`Graph "${this.name}": unknown node "${e}"`);return t}get(e){return this.node(e).cache}set(e,t,r){let o=r?.internal===!0;this.node(e).down([[x,t]],{actor:r?.actor,internal:o,delivery:"write"})}setAll(e,t){let r=Symbol.iterator in e?e:Object.entries(e);$(()=>{for(let[o,s]of r)this.set(o,s,t)})}invalidate(e,t){let r=t?.internal===!0;this.node(e).down([[ke]],{actor:t?.actor,internal:r,delivery:"write"})}error(e,t,r){let o=r?.internal===!0;this.node(e).down([[S,t]],{actor:r?.actor,internal:o,delivery:"write"})}complete(e,t){let r=t?.internal===!0;this.node(e).down([[N]],{actor:t?.actor,internal:r,delivery:"write"})}edges(e){let t=e?.recursive===!0,r=new Map;if(!t){for(let[u,d]of this._nodes)r.set(d,u);let a=[];for(let[u,d]of this._nodes)if(d instanceof oe)for(let c of d._deps){let l=r.get(c.node);l!=null&&a.push([l,u])}return a.sort((u,d)=>u[0]<d[0]?-1:u[0]>d[0]?1:u[1]<d[1]?-1:u[1]>d[1]?1:0),a}let o=[];this._collectObserveTargets("",o);let s=new Map;for(let[a,u]of o)s.set(u,a);let i=[];for(let[a,u]of o)if(u instanceof oe)for(let d of u._deps){let c=s.get(d.node);c!=null&&i.push([c,a])}return i.sort((a,u)=>a[0]<u[0]?-1:a[0]>u[0]?1:a[1]<u[1]?-1:a[1]>u[1]?1:0),i}mount(e,t){if(t===void 0){let o=new n(e);return this.mount(e,o)}if(typeof t=="function"){let o=new n(e);return t(o),this.mount(e,o)}let r=t;if(or(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(r===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(r._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${r._parent.name}"`);for(let o=this;o!=null;o=o._parent)if(o===r)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,r),r._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),r}resolve(e){let t=Ba(e,this.name);return this._resolveFromSegments(t)}tryResolve(e){try{return this.resolve(e)}catch{return}}_resolveFromSegments(e){let t=e;if(t[0]===this.name&&(t=t.slice(1),t.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let r=t[0],o=t.slice(1);if(o.length===0){let a=this._nodes.get(r);if(a)return a;throw this._mounts.has(r)?new Error(`Graph "${this.name}": path ends at subgraph "${r}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${r}"`)}let s=this._nodes.get(r);if(s&&o.length>0&&o[0]===Me)return this._resolveMetaChainFromNode(s,o,t.join(ee));let i=this._mounts.get(r);if(!i)throw this._nodes.has(r)?new Error(`Graph "${this.name}": "${r}" is a node; trailing path "${o.join(ee)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(o.join(ee))}_resolveMetaChainFromNode(e,t,r){let o=e,s=0,i=[...t];for(;s<i.length;){if(i[s]!==Me)throw new Error(`Graph "${this.name}": expected ${Me} segment in meta path "${r}"`);if(s+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${Me} in "${r}"`);let a=i[s+1],u=o.meta[a];if(!u)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);o=u,s+=2}return o}signal(e,t){if(t?.internal!==!0){for(let o of e)if(this.config.messageTier(o[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let r=[];if(this._signalDeliver(e,t??{},new Set,r),r.length>0)throw r[0]}_signalDeliver(e,t,r,o){for(let u of this._mounts.values())u._signalDeliver(e,t,r,o);let i=t.internal===!0?{internal:!0}:{actor:t.actor,delivery:"signal"},a=Va(e,this.config);for(let u of[...this._nodes.keys()].sort()){let d=this._nodes.get(u);if(!r.has(d)){r.add(d);try{d.down(e,i)}catch(c){if(c instanceof Ee)throw c;o.push(c)}a.length!==0&&this._signalMetaSubtree(d,a,r,i,o)}}}_signalMetaSubtree(e,t,r,o,s){for(let i of Object.keys(e.meta).sort()){let a=e.meta[i];if(!r.has(a)){r.add(a);try{a.down(t,o)}catch(u){if(u instanceof Ee)throw u;s.push(u)}this._signalMetaSubtree(a,t,r,o,s)}}}describe(e){if(e?.reactive==="diff")return this._describeReactiveDiff(e);if(e?.reactive===!0)return this._describeReactive(e);let t=Ra(e?.actor),r=e?.filter;if(e?.detail!=null&&e?.fields!=null)throw new TypeError("Graph.describe(): pass either `detail` or `fields`, not both. `detail: 'spec'` is the canonical spec projection; use `fields` only when you need a custom subset.");let o=Pn(e?.detail,e?.fields),s=e?.detail==="spec",i=o,a=[];this._collectObserveTargets("",a);let u=new Map;for(let[T,w]of a)u.set(w,T);let d=[];{let T=a.map(([,k])=>k),w=new Set(u.values()),_=0;for(;T.length>0;){let k=T.shift();if(k instanceof oe)for(let E of k._deps){let O=E.node;if(u.has(O))continue;let R=O.name??"",M=R;if(!M||w.has(M))if(R){let G=2;for(;w.has(`${R}#${G}`);)G++;M=`${R}#${G}`}else for(M=`__internal__/${_++}`;w.has(M);)M=`__internal__/${_++}`;u.set(O,M),w.add(M),d.push([M,O]),T.push(O)}}}let c=[...a,...d],l={};for(let[T,w]of c){if(t!=null&&!w.allowsObserve(t))continue;let _=Dn(w,i,s),k=w instanceof oe?w._deps.map(M=>u.get(M.node)??M.node.name??""):[],{name:E,...O}=_,R={...O,deps:k};if(!s){let M=this._annotations.get(T);M!=null&&(R.annotation=M)}if(r!=null)if(typeof r=="function"){let M=r;if(!(M.length>=2?M(T,R):M(R)))continue}else{let M=!0;for(let[G,P]of Object.entries(r)){let L=G==="deps_includes"?"depsIncludes":G==="meta_has"?"metaHas":G;if(L==="depsIncludes"){if(!R.deps.includes(String(P))){M=!1;break}continue}if(L==="metaHas"){if(!Object.hasOwn(R.meta??{},String(P))){M=!1;break}continue}if(R[L]!==P){M=!1;break}}if(!M)continue}l[T]=R}let f=new Set(Object.keys(l)),p=[];for(let[T,w]of c)if(w instanceof oe)for(let _ of w._deps){let k=u.get(_.node);k!=null&&p.push([k,T])}p.sort((T,w)=>T[0]<w[0]?-1:T[0]>w[0]?1:T[1]<w[1]?-1:T[1]>w[1]?1:0);let h=p.map(([T,w])=>({from:T,to:w}));(t!=null||r!=null)&&(h=h.filter(T=>f.has(T.from)&&f.has(T.to)));let g=this._collectSubgraphs(""),m=t!=null||r!=null?g.filter(T=>{let w=`${T}${ee}`;return[...f].some(_=>_===T||_.startsWith(w))}):g,y=this,b=e;return{name:this.name,nodes:l,edges:h,subgraphs:m,...this._factory!==void 0?{factory:this._factory}:{},...this._factoryArgs!==void 0?{factoryArgs:this._factoryArgs}:{},expand(T){let w={...b};return Array.isArray(T)?(w.fields=T,w.detail=void 0):(w.detail=T,w.fields=void 0),y.describe(w)}}}_collectSubgraphs(e){let t=[];for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${r}`;t.push(o),t.push(...this._mounts.get(r)._collectSubgraphs(`${o}${ee}`))}return t}resourceProfile(e){return _o(this,e)}reachable(e,t,r={}){return r.withDetail===!0?Ao(this.describe(),e,t,{...r,withDetail:!0}):Ao(this.describe(),e,t,r)}explain(e,t,r){return r?.reactive===!0?this._explainReactive(e,t,r):this._explainStatic(ze(e),ze(t),{...r?.maxDepth!==void 0?{maxDepth:Eo(r.maxDepth)}:{},...r?.findCycle!==void 0?{findCycle:Oo(r.findCycle)}:{}})}_explainStatic(e,t,r){let o=this.describe({detail:"full"}),s=new Map(this._annotations),i=new Map;for(let[a,u]of Object.entries(o.nodes))u.lastMutation!=null&&i.set(a,u.lastMutation);return To(o,e,t,{...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{},annotations:s,lastMutations:i})}_describeReactive(e){let t={...e,reactive:!1},r=e.reactiveName??"describe",o=0,s=F(o,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,u=!1,d=()=>{a||u||(a=!0,rt(()=>{a=!1,!u&&(o+=1,s.emit(o))}))},c=i.onEvent(b=>{let v=b.type;v!=="data"&&v!=="error"&&v!=="complete"&&v!=="teardown"||d()}),l=[],f=new WeakSet,p=b=>{if(f.has(b)||u)return;f.add(b);let v=b.topology.subscribe(T=>{for(let w of T){if(w[0]!==x)continue;let _=w[1];if(d(),_.kind==="added"&&_.nodeKind==="mount"){let k=b._mounts.get(_.name);k!=null&&p(k)}}});l.push(v);for(let T of b._mounts.keys()){let w=b._mounts.get(T);w!=null&&p(w)}};p(this);let h,g=e.actor;Co(g)&&(h=g.subscribe(b=>{let v=!1,T=!1;for(let w of b){let _=w[0];_===x?v=!0:(_===N||_===S||_===K)&&(T=!0)}v&&d(),T&&(h?.(),h=void 0,d())}));let m;try{m=be([s],()=>this.describe(t),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(b,v)=>b===v})}catch(b){c(),h?.();for(let v of l)v();throw i.dispose(),b}let y=Ye(m);return{node:m,dispose(){u=!0,c(),h?.();for(let b of l)b();l.length=0,i.dispose(),y()}}}_describeReactiveDiff(e){let t={...e,reactive:!1},r=e.reactiveName??"describe-diff",o={name:this.name,nodes:{},edges:[],subgraphs:[]},s=this.describe(t),i=Mt(o,s),a=F(i,{name:r,meta:{domain:"audit",kind:"describe-diff"},equals:(f,p)=>f===p}),u=this._describeReactive({...e,reactiveName:void 0}),d=!1,c=u.node.subscribe(f=>{if(!d)for(let p of f){if(p[0]!==x)continue;let h=p[1],g=Mt(s,h);s=h,g.events.length!==0&&a.emit(g)}}),l=Ye(a);return{node:a,dispose(){d=!0,c(),u.dispose(),a.down([[K,"describe-diff disposed"]]),l()}}}_explainReactive(e,t,r){let o=0,s=F(o,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,u=!1,d=()=>{a||u||(a=!0,rt(()=>{a=!1,!u&&(o+=1,s.emit(o))}))},c=i.onEvent(b=>{let v=b.type;v!=="data"&&v!=="error"&&v!=="complete"&&v!=="teardown"||d()}),l=[];e!=null&&Qe(e)&&l.push(e),t!=null&&Qe(t)&&l.push(t),r?.maxDepth!=null&&Qe(r.maxDepth)&&l.push(r.maxDepth),r?.findCycle!=null&&Qe(r.findCycle)&&l.push(r.findCycle);let f=()=>{for(let b of l)if(b.cache===void 0)return!1;return!0},p=()=>{let b=ze(e),v=ze(t);return{from:b,to:v,found:!1,reason:"pending",steps:[],text:"(awaiting reactive args)",toJSON:()=>({from:b,to:v,found:!1,reason:"pending",steps:[]})}},h;try{h=be([s],()=>{if(!f())return p();let b=ze(e),v=ze(t),T={...r?.maxDepth!==void 0?{maxDepth:Eo(r.maxDepth)}:{},...r?.findCycle!==void 0?{findCycle:Oo(r.findCycle)}:{}};return this._explainStatic(b,v,T)},{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:ze(e),to:ze(t)},equals:(b,v)=>b.found===v.found&&b.reason===v.reason&&b.steps.length===v.steps.length&&Ga(b.steps,v.steps)})}catch(b){throw c(),i.dispose(),b}let g=Ye(h),m=[],y=b=>{let v;return v=b.subscribe(T=>{let w=!1,_=!1;for(let k of T){let E=k[0];E===x?w=!0:(E===N||E===S||E===K)&&(_=!0)}(w||_)&&d(),_&&v&&(v(),v=void 0)}),()=>{v&&(v(),v=void 0)}};for(let b of l)m.push(y(b));return{node:h,dispose(){u=!0,c();for(let b of m)b?.();m.length=0,i.dispose(),g()}}}_pathsMatching(e){let t=nn(e),r=[];return this._collectObserveTargets("",r),r.map(([o])=>o).filter(o=>t.test(o))}_collectObserveTargets(e,t){for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${ee}${r}`;this._mounts.get(r)._collectObserveTargets(o,t)}for(let r of[...this._nodes.keys()].sort()){let o=this._nodes.get(r),s=e===""?r:`${e}${ee}${r}`;t.push([s,o]),this._appendMetaObserveTargets(s,o,t)}}_appendMetaObserveTargets(e,t,r){for(let o of Object.keys(t.meta).sort()){let s=t.meta[o],i=`${e}${ee}${Me}${ee}${o}`;r.push([i,s]),this._appendMetaObserveTargets(i,s,r)}}observe(e,t){let r=typeof e=="string",s=Mo(r?t:e);if(s.reactive===!0)return this._observeReactive(r?e:void 0,s);let i=s.structured===!0||s.timeline===!0||s.causal===!0||s.derived===!0||s.detail==="minimal"||s.detail==="full"||s.format!=null,a=s.actor;if(r){let c=e,l=this.resolve(c);if(a!=null&&!l.allowsObserve(a))throw new Ee({actor:a,action:"observe",nodeName:c});return i?this._buildStructuredObserver([[c,l]],s,"one"):{subscribe(f){return l.subscribe(f)},up(f){try{l.up?.(f)}catch(p){if(p instanceof Ee)return;throw p}}}}let u=[];this._collectObserveTargets("",u),u.sort((c,l)=>c[0]<l[0]?-1:c[0]>l[0]?1:0);let d=a==null?u:u.filter(([,c])=>c.allowsObserve(a));return i?this._buildStructuredObserver(d,s,"all"):{subscribe:c=>{let l=d.map(([f,p])=>p.subscribe(h=>{c(f,h)}));return()=>{for(let f of l)f()}},up:(c,l)=>{try{this.resolve(c).up?.(l)}catch(f){if(f instanceof Ee)return;throw f}}}}_observeReactive(e,t){let r=t.tiers,o=r!=null?new Set(r):null,s=t.reactiveName??"observe";return A(i=>{let a=[],u=!1,d=!1,c=()=>{if(a.length===0||d)return;let g={events:a.slice(),flushedAt_ns:re()};a.length=0,i.emit(g)},l={...t,reactive:!1,structured:!0,timeline:!0},f=e!=null?this.observe(e,l):this.observe(l),p=g=>{d||(a.push(g),!u&&(u=!0,rt(()=>{u=!1,c()})))};for(let g of f.events)p(g);let h=f.onEvent(p);return()=>{d=!0,h(),f.dispose()}},{name:s,meta:{domain:"audit",kind:"observe-reactive"}})}_buildStructuredObserver(e,t,r){let o=r==="one"?e[0]?.[0]:void 0,s=i=>{if(r==="one"&&o!=null){let c=this.resolve(o);return this._buildStructuredObserver([[o,c]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((c,l)=>c[0]<l[0]?-1:c[0]>l[0]?1:0);let u=i.actor,d=u==null?a:a.filter(([,c])=>c.allowsObserve(u));return this._buildStructuredObserver(d,i,"all")};return this._createObserveResult(e,t,s)}_createObserveResult(e,t,r){let o=t.timeline===!0,s=t.causal===!0,i=t.derived===!0,a=t.detail==="minimal",u=this.config.inspectorEnabled,d=(s||i)&&u,c=t.maxEvents,l=c!=null&&c>0?new Le(c):null,f=[],p=new Set,h=t.tiers!=null?new Set(t.tiers):null,g={},m=new Set,y=0,b=0,v=0,T=0,w=0,_=0,k=!1,E=!1,O=0,R=new Map,M=new Map,G=new Map,P=I=>{if(!(h!=null&&!h.has(I.type))){l?l.push(I):f.push(I);for(let Q of p)Q(I)}},L=I=>h==null||h.has(I),ue=()=>o?{timestamp_ns:re(),in_batch:It(),batch_id:O}:{},U=(I,Q)=>{if(!(!d||!(I instanceof oe)))return I._setInspectorHook(Te=>{if(Te.kind==="dep_message")R.set(I,Te.depIndex);else if(Te.kind==="run"){let $e=Te.batchData.map((j,he)=>j!=null&&j.length>0?j.at(-1):Te.prevData[he]);M.set(I,$e);let we=Te.batchData.map(j=>j!=null?[...j]:void 0);G.set(I,we),i&&P({type:"derived",path:Q,dep_values:$e,dep_batches:we,...ue()})}})},de=I=>{let Q=R.get(I),Te=M.get(I);if(!s||Te==null)return{};let we=(Q!=null&&Q>=0&&I instanceof oe?I._deps[Q]:void 0)?.node,j=we?.v,he=G.get(I);return{trigger_dep_index:Q,trigger_dep_name:we?.name,...j!=null?{trigger_version:{id:j.id,version:j.version}}:{},dep_values:[...Te],...he!=null?{dep_batches:he}:{}}},_e=[],Ve=[];for(let[I,Q]of e){let Te=U(Q,I);Te&&_e.push(Te),Ve.push(Q.subscribe($e=>{O++;for(let we of $e){let j=we[0],he=ue();if(j===x){g[I]=we[1];let yt=Q instanceof oe?Q.lastMutation?.actor??st:st;P({type:"data",path:I,data:we[1],actor:yt,...he,...de(Q)})}else if(a)j===V?L("dirty")&&y++:j===C?L("resolved")&&b++:j===ke?L("invalidate")&&v++:j===le?L("pause")&&T++:j===pe?L("resume")&&w++:j===K?L("teardown")&&_++:j===N&&!m.has(I)?L("complete")&&(k=!0):j===S&&L("error")&&(E=!0,m.add(I));else if(j===V)L("dirty")&&y++,P({type:"dirty",path:I,...he});else if(j===C)L("resolved")&&b++,P({type:"resolved",path:I,...he,...de(Q)});else if(j===ke)L("invalidate")&&v++,P({type:"invalidate",path:I,...he});else if(j===le)L("pause")&&T++,P({type:"pause",path:I,lockId:we[1],...he});else if(j===pe)L("resume")&&w++,P({type:"resume",path:I,lockId:we[1],...he});else if(j===N)L("complete")&&!m.has(I)&&(k=!0),P({type:"complete",path:I,...he});else if(j===S){L("error")&&(E=!0,m.add(I));let yt=Q instanceof oe?Q.lastMutation?.actor??st:st;P({type:"error",path:I,data:we[1],actor:yt,...he})}else j===K&&(L("teardown")&&_++,P({type:"teardown",path:I,...he}))}}))}let Se=!1,xe=()=>{if(!Se){Se=!0;for(let I of Ve)I();for(let I of _e)I();for(let I of Ge)I({value:void 0,done:!0});Ge.length=0}},Fe=[],Ge=[];p.add(I=>{let Q=Ge.shift();Q?Q({value:I,done:!1}):Fe.push(I)});let Ke={get values(){return g},get dirtyCount(){return y},get resolvedCount(){return b},get invalidateCount(){return v},get pauseCount(){return T},get resumeCount(){return w},get teardownCount(){return _},get events(){return l?l.toArray():[...f]},get anyCompletedCleanly(){return k},get anyErrored(){return E},get completedWithoutErrors(){return k&&!E},onEvent(I){return p.add(I),()=>p.delete(I)},dispose:xe,expand(I){xe();let Q={...t};return typeof I=="string"?Q.detail=I:Object.assign(Q,I),r(Mo(Q))},[Symbol.asyncIterator](){return{next(){return Fe.length>0?Promise.resolve({value:Fe.shift(),done:!1}):Se?Promise.resolve({value:void 0,done:!0}):new Promise(I=>Ge.push(I))},return(){return xe(),Promise.resolve({value:void 0,done:!0})}}}};return t.format!=null&&this._attachFormatLogger(Ke,t),Ke}_attachFormatLogger(e,t){let r=t.format;if(r==null)return;let o=t.logger??(h=>console.log(h)),s=t.includeTypes?new Set(t.includeTypes):null,i=t.excludeTypes?new Set(t.excludeTypes):null,a=s==null&&i==null?()=>!0:h=>(s==null||s.has(h))&&(i==null||!i.has(h)),u=Ia(t.theme),d=r==="stage-log"?re():0,c=h=>h==null?"":t.stageLabels?.[h]??h,l=(h,g)=>h.length>g?`${h.slice(0,g-1)}\u2026`:h,f=h=>h.type==="data"||h.type==="error"?l(rr(h.data),120):"",p=h=>{if(r==="stage-log"){let k=(re()-d)/1e9,E=c(h.path).padEnd(9);if(h.type==="data"){let O=f(h);return`[${k.toFixed(3)}s] ${E} \u2190${O?` ${O}`:""}`}if(h.type==="error"){let O=f(h);return`[${k.toFixed(3)}s] ${E} \u2717${O?` ${O}`:""}`}return h.type==="complete"?`[${k.toFixed(3)}s] ${E} \u25A0 complete`:`[${k.toFixed(3)}s] ${E} ${h.type}`}if(r==="json")try{return JSON.stringify(h)}catch{return JSON.stringify({type:h.type,path:h.path,data:"[unserializable]"})}let g=u[h.type]??"",m=h.path?`${u.path}${h.path}${u.reset} `:"",y=h.type==="data"||h.type==="error",b=h.type==="pause"||h.type==="resume",v=y?` ${rr(h.data)}`:b?` ${rr(h.lockId)}`:"",T=h.type==="data"||h.type==="resolved"||h.type==="derived"?h:void 0,w=T?.trigger_dep_name!=null?` <- ${T.trigger_dep_name}`:T?.trigger_dep_index!=null?` <- #${T.trigger_dep_index}`:"",_=h.in_batch?" [batch]":"";return`${m}${g}${h.type.toUpperCase()}${u.reset}${v}${w}${_}`};e.onEvent(h=>{a(h.type)&&o(p(h),h)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){So(this._disposers,this.name),this.signal([[K]],{internal:!0}),So(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}get destroyed(){return this._destroyed}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}snapshot(e){let{expand:t,...r}=this.describe({detail:"full"}),o={};for(let a of Object.keys(r.nodes).sort()){let{lastMutation:u,guard:d,...c}=r.nodes[a];o[a]=c}let s=[...r.subgraphs].sort(),i={...r,version:1,nodes:o,subgraphs:s};if(e?.format==null)return i;if(e.format==="json-string")return JSON.stringify(i);if(e.format==="bytes"){if(e.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let a=this.config.lookupCodec(e.codec);if(a==null)throw new Error(`snapshot: codec "${e.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return wr(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,t){let r=t?.config??me,{codec:o,codecVersion:s,payload:i}=kr(e,r);return o.decode(i,s)}restore(e,t){if(Ro(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let r=t?.only==null?null:(Array.isArray(t.only)?t.only:[t.only]).map(s=>nn(s)),o=t?.includeProducers===!0;for(let s of Object.keys(e.nodes).sort()){if(r!==null&&!r.some(a=>a.test(s)))continue;let i=e.nodes[s];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&t?.onError?.(s,new Error(`restore: slice.value is undefined for "${s}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!o)){if(i.v!=null){let u=this.tryResolve(s)?.v;if(u!=null&&u.id===i.v.id&&u.version===i.v.version)continue}try{this.set(s,i.value)}catch(a){t?.onError?.(s,a)}}}}}static fromSnapshot(e,t){Ro(e);let r=typeof t=="function"?t:t?.build,o=typeof t=="function"?void 0:t?.factories,s=new n(e.name);if(r)return r(s),s.restore(e),s;for(let p of[...e.subgraphs].sort((h,g)=>{let m=h.split(ee).length,y=g.split(ee).length;return m!==y?m-y:h<g?-1:h>g?1:0})){let h=p.split(ee),g=s;for(let m of h)g._mounts.has(m)||g.mount(m,new n(m)),g=g._mounts.get(m)}let i=o?Object.entries(o).map(([p,h])=>({re:nn(p),factory:h})):[],a=p=>{for(let h of i)if(h.re.test(p))return h.factory},u=p=>{let h=p.split(ee),g=h.pop();if(g==null||g.length===0)throw new Error(`invalid snapshot path "${p}"`);let m=s;for(let y of h){let b=m._mounts.get(y);if(!b)throw new Error(`unknown mount "${y}" in path "${p}"`);m=b}return[m,g]},d=Object.entries(e.nodes).filter(([p])=>!p.includes(`${ee}${Me}${ee}`)).sort((p,h)=>p[0]<h[0]?-1:p[0]>h[0]?1:0),c=new Map(d),l=new Map,f=!0;for(;c.size>0&&f;){f=!1;for(let[p,h]of[...c.entries()]){let g=h?.deps??[];if(!g.every(w=>l.has(w)))continue;let[m,y]=u(p),b={...h?.meta??{}},v=a(p),T;if(h?.type==="state")T=F(h.value,{meta:b});else{if(v==null)continue;T=v(y,{path:p,type:h.type,value:h.value,meta:b,deps:g,resolvedDeps:g.map(w=>l.get(w))})}m.add(T,{name:y}),l.set(p,T),c.delete(p),f=!0}}if(c.size>0){let p=[...c.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${p}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return s.restore(e),s}toJSON(){return this.snapshot()}attachSnapshotStorage(e,t={}){let r=e.map(d=>({tier:d,debounceMs:Math.max(0,d.debounceMs??0),compactEvery:Math.max(1,d.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));t.autoRestore===!0&&this._cascadeRestore(e,t.onError);let o=(d,c)=>{if(d.disposed)return;let l=Ma(c.nodes);if(d.lastSnapshot!=null&&l!==""&&l===d.lastFingerprint)return;let f=d.seq+1,p=te(),m=d.lastSnapshot==null||f%d.compactEvery===0?{name:this.name,mode:"full",snapshot:c,seq:f,timestamp_ns:p,format_version:pt}:{name:this.name,mode:"diff",diff:Fa(d.lastSnapshot,c),seq:f,timestamp_ns:p,format_version:pt};if(d.tier.filter&&!d.tier.filter(m))return;let y;try{y=d.tier.save(m)}catch(b){t.onError?.(b,d.tier);return}if(y&&typeof y.then=="function"){let T=(d.savePending??Promise.resolve()).then(()=>y,()=>y).then(()=>{d.disposed||(d.seq=f,d.lastSnapshot=c,d.lastFingerprint=l)},w=>{t.onError?.(w,d.tier)});d.savePending=T.finally(()=>{d.savePending===T&&(d.savePending=void 0)})}else d.seq=f,d.lastSnapshot=c,d.lastFingerprint=l},s=(d,c)=>{try{o(d,c)}catch(l){t.onError?.(l,d.tier)}},i=(d,c)=>{if(!c.some(h=>{let g=this.config.messageTier(h[0]);return g>=3&&g<5}))return;if(t.filter){let h=this.tryResolve(d);if(h==null)return;let g=Dn(h,Pn("standard"));if(!t.filter(d,g))return}let f,p=()=>(f==null&&(f=this.snapshot()),f);for(let h of r)h.disposed||(h.debounceMs===0?s(h,p()):(h.timer==null&&(h.timer=new Pe),h.timer.start(h.debounceMs,()=>{h.disposed||s(h,this.snapshot())})))},a;if(t.paths!=null){let c=(typeof t.paths=="string"?this._pathsMatching(t.paths):t.paths).map(l=>{let f=this.tryResolve(l);return f==null?()=>{}:f.subscribe(p=>i(l,p))});a=()=>{for(let l of c)l()}}else a=this.observe().subscribe((d,c)=>i(d,c));let u=()=>{a();for(let d of r)d.disposed=!0,d.timer?.cancel();this._storageDisposers.delete(u)};return this._storageDisposers.add(u),{dispose:u}}async _cascadeRestore(e,t){for(let r of e){let o;try{o=await r.load?.()}catch(i){t?.(i,r);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let s=o;try{if(s.mode==="full"&&s.snapshot!=null)return this.restore(s.snapshot),!0;if(s.version===pt&&s.nodes!=null)return this.restore(s),!0}catch(i){t?.(i,r)}}return!1}static async fromStorage(e,t,r){for(let o of t){let s;try{s=await o.load?.()}catch(u){r?.onError?.(u,o);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let i=s,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===pt&&i.nodes!=null?i:void 0;if(a!=null)try{return n.fromSnapshot(a,r)}catch(u){r?.onError?.(u,o)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${e}" across ${t.length} tier(s)`)}_annotations=new Map;_traceRing;trace(e,t,r){if(e!=null&&t!=null){if(this.tryResolve(e)==null)return;if(this._annotations.set(e,t),this.config.inspectorEnabled){let o={path:e,annotation:t,timestamp_ns:re(),...r?.actor!=null?{actor:r.actor}:{}};this._traceRing.push(o)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let t=this._traceRing.toArray().filter(o=>!e(o)),r=this._traceRing.size-t.length;this._traceRing.clear();for(let o of t)this._traceRing.push(o);return r}static diff(e,t){let r=new Set(Object.keys(e.nodes)),o=new Set(Object.keys(t.nodes)),s=[...o].filter(b=>!r.has(b)).sort(),i=[...r].filter(b=>!o.has(b)).sort(),a=[],u=[];for(let b of r){if(!o.has(b))continue;let v=e.nodes[b],T=t.nodes[b],w=v.v,_=T.v;w!=null&&_!=null&&w.id===_.id&&w.version!==_.version&&u.push({path:b,id:w.id,from:w.version,to:_.version});let k=w!=null&&_!=null&&w.id===_.id&&w.version===_.version;for(let E of["type","status","sentinel"]){let O=v[E],R=T[E];O!==R&&a.push({path:b,field:E,from:O,to:R})}if(!k)for(let E of["value","meta"]){let O=v[E],R=T[E];Aa(O,R)||a.push({path:b,field:E,from:O,to:R})}}let d=b=>`${b.from} ${b.to}`,c=new Set(e.edges.map(d)),l=new Set(t.edges.map(d)),f=t.edges.filter(b=>!c.has(d(b))),p=e.edges.filter(b=>!l.has(d(b))),h=new Set(e.subgraphs),g=new Set(t.subgraphs),m=[...g].filter(b=>!h.has(b)).sort(),y=[...h].filter(b=>!g.has(b)).sort();return{nodesAdded:s,nodesRemoved:i,nodesChanged:a,versionChanges:u,edgesAdded:f,edgesRemoved:p,subgraphsAdded:m,subgraphsRemoved:y}}};function Fa(n,e){let t=Xe.diff(n,e),r={};for(let o of t.nodesAdded){let s=e.nodes[o];s!=null&&(r[o]=s)}return{...t,nodesAddedFull:r}}function Ao(n,e,t,r={}){let o={paths:[],depths:new Map,truncated:!1};if(!e)return r.withDetail?o:[];if(!r.both&&t!=="upstream"&&t!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let s=r.maxDepth;if(s!=null&&(!Number.isInteger(s)||s<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(s===0)return r.withDetail?o:[];let i=new Map,a=new Map,u=new Map,d=new Map,c=new Set;for(let[v,T]of Object.entries(n.nodes)){if(!v)continue;c.add(v);let w=T.deps??[];i.set(v,w);for(let _ of w)_&&(c.add(_),a.has(_)||a.set(_,new Set),a.get(_).add(v))}for(let v of n.edges){if(v==null||typeof v!="object")continue;let T=typeof v.from=="string"?v.from:"",w=typeof v.to=="string"?v.to:"";!T||!w||(c.add(T),c.add(w),d.has(T)||d.set(T,new Set),d.get(T).add(w),u.has(w)||u.set(w,new Set),u.get(w).add(T))}if(!c.has(e))return r.withDetail?o:[];let l=r.both===!0,f=v=>{if(l){let k=i.get(v)??[],E=u.get(v),O=a.get(v),R=d.get(v),M=[...k];return E&&M.push(...E),O&&M.push(...O),R&&M.push(...R),M}if(t==="upstream"){let k=i.get(v)??[],E=u.get(v);return E?[...k,...E]:k}let T=a.get(v),w=d.get(v),_=T?[...T]:[];return w&&_.push(...w),_},p=new Set([e]),h=new Map,g=[{path:e,depth:0}],m=0,y=!1;for(;m<g.length;){let v=g[m++];if(s!=null&&v.depth>=s){f(v.path).length>0&&(y=!0);continue}for(let T of f(v.path))!T||p.has(T)||(p.add(T),h.set(T,v.depth+1),g.push({path:T,depth:v.depth+1}))}let b=[...h.keys()].sort((v,T)=>v<T?-1:v>T?1:0);return r.withDetail?{paths:b,depths:h,truncated:y}:b}function Ga(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++){let r=n[t],o=e[t];if(r.path!==o.path||r.type!==o.type||r.status!==o.status||r.hop!==o.hop||r.dep_index!==o.dep_index||r.annotation!==o.annotation||r.value!==o.value||r.lastMutation!==o.lastMutation)return!1;let s=r.v,i=o.v;if(s!==i&&(s==null||i==null||s.id!==i.id||s.version!==i.version))return!1}return!0}ye();X();ge();fe();De();var rn=class{_version=0;_maxSize;_buf;_head=0;_size=0;constructor(e,t){if(t!==void 0&&t<1)throw new RangeError("maxSize must be >= 1");if(this._maxSize=t,t!==void 0){if(this._buf=new Array(t),e&&e.length>0){let r=Math.min(e.length,t),o=e.length-r;for(let s=0;s<r;s++)this._buf[s]=e[o+s];this._size=r}}else this._buf=e?[...e]:[],this._size=this._buf.length}get version(){return this._version}get size(){return this._size}at(e){if(!Number.isInteger(e))return;let t=e>=0?e:this._size+e;if(!(t<0||t>=this._size))return this._maxSize!==void 0?this._buf[(this._head+t)%this._maxSize]:this._buf[t]}append(e){this._rawAppend(e),this._version+=1}appendMany(e){if(e.length===0)return;let t=this._maxSize!==void 0&&e.length>this._maxSize?e.length-this._maxSize:0;for(let r=t;r<e.length;r++)this._rawAppend(e[r]);this._version+=1}clear(){if(this._size===0)return 0;let e=this._size;if(this._maxSize===void 0)this._buf.length=0;else for(let t=0;t<e;t++)this._buf[(this._head+t)%this._maxSize]=void 0;return this._head=0,this._size=0,this._version+=1,e}trimHead(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`trimHead: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return 0;let t=Math.min(e,this._size);if(this._maxSize===void 0)this._buf.splice(0,t);else{for(let r=0;r<t;r++)this._buf[(this._head+r)%this._maxSize]=void 0;this._head=(this._head+t)%this._maxSize}return this._size-=t,this._version+=1,t}slice(e,t){if(!Number.isInteger(e)||e<0)throw new RangeError(`slice: start must be a non-negative integer (got ${e})`);if(t!==void 0&&(!Number.isInteger(t)||t<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${t})`);let r=t===void 0?this._size:Math.min(Math.max(t,0),this._size),o=Math.min(e,this._size);if(o>=r)return[];let s=r-o;if(this._maxSize===void 0)return this._buf.slice(o,r);let i=new Array(s);for(let a=0;a<s;a++)i[a]=this._buf[(this._head+o+a)%this._maxSize];return i}tail(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`tail: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return[];let t=Math.min(e,this._size);return this.slice(this._size-t,this._size)}toArray(){if(this._maxSize===void 0)return[...this._buf];let e=new Array(this._size);for(let t=0;t<this._size;t++)e[t]=this._buf[(this._head+t)%this._maxSize];return e}snapshot(){return this.toArray()}restore(e){if(this._maxSize===void 0){this._buf.length=0;for(let t=0;t<e.length;t++)this._buf.push(e[t]);this._size=this._buf.length}else{let t=this._maxSize;for(let s=0;s<t;s++)this._buf[s]=void 0;this._head=0;let r=Math.min(e.length,t),o=e.length-r;for(let s=0;s<r;s++)this._buf[s]=e[o+s];this._size=r}this._version+=1}_rawAppend(e){if(this._maxSize===void 0){this._buf.push(e),this._size=this._buf.length;return}this._size<this._maxSize?(this._buf[(this._head+this._size)%this._maxSize]=e,this._size+=1):(this._buf[this._head]=e,this._head=(this._head+1)%this._maxSize)}};function At(n){return n.subscribe(()=>{})}var za=64;function ir(n,e={}){let{name:t,maxSize:r,versioning:o,guard:s,backend:i}=e,a=i??new rn(n,r),u=F(a.toArray(),{name:t,describeKind:"state",equals:(k,E)=>k===E,...o!=null?{versioning:o}:{},...s!=null?{guard:s}:{}});function d(){let k=a.toArray();$(()=>{u.down([[V]],{internal:!0}),u.down([[x,k]],{internal:!0})})}let c=new Map,l=new Map,f=new Map;function p(k,E){return`${k}:${E===void 0?"END":E}`}function h(k){if(k.size<za)return;let E=k.keys().next();if(E.done)return;let O=k.get(E.value);O!==void 0&&O.dispose(),k.delete(E.value)}function g(k){let E=a.version;try{return k()}finally{a.version!==E&&d()}}function m(k){if(!Number.isInteger(k)||k<0)throw new RangeError(`tail: n must be a non-negative integer (got ${k})`);let E=c.get(k);if(E!==void 0)return c.delete(k),c.set(k,E),E.node;h(c);let O=be([u],([M])=>{let G=M;return k===0||G.length===0?[]:G.slice(Math.max(0,G.length-k))},{initial:a.tail(k),describeKind:"derived"}),R=At(O);return c.set(k,{node:O,dispose:R}),O}function y(k,E){if(!Number.isInteger(k)||k<0)throw new RangeError(`slice: start must be a non-negative integer (got ${k})`);if(E!==void 0&&(!Number.isInteger(E)||E<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${E})`);let O=p(k,E),R=l.get(O);if(R!==void 0)return l.delete(O),l.set(O,R),R.node;h(l);let M=be([u],([P])=>{let L=P;return E===void 0?L.slice(k):L.slice(k,E)},{initial:a.slice(k,E),describeKind:"derived"}),G=At(M);return l.set(O,{node:M,dispose:G}),M}function b(k){let E=f.get(k);if(E!==void 0)return E.node;let O=be([u,k],([M,G])=>{let P=M,L=Math.max(0,Math.trunc(G??0));return P.slice(L)},{initial:[],describeKind:"derived"}),R=At(O);return f.set(k,{node:O,dispose:R}),O}let v,T;function w(){v===void 0&&(v=B([u],(k,E,O)=>{let R=k[0],G=R!=null&&R.length>0?R.at(-1):O.prevData[0];if(G==null||G.length===0){E.down([[C]]);return}E.emit(G[G.length-1])},{name:t!=null?`${t}::lastValue`:"lastValue",describeKind:"derived",initial:a.size===0?void 0:a.at(a.size-1)}),T=be([u],([k])=>k.length>0,{name:t!=null?`${t}::hasLatest`:"hasLatest",describeKind:"derived",initial:a.size>0}),At(v),At(T))}let _={entries:u,get size(){return a.size},at(k){return a.at(k)},append(k){g(()=>a.append(k))},appendMany(k){k.length!==0&&g(()=>a.appendMany(k))},clear(){g(()=>a.clear())},trimHead(k){g(()=>a.trimHead(k))},withLatest(){return w(),u},get lastValue(){return w(),v},get hasLatest(){return w(),T},view(k){switch(k.kind){case"tail":return m(k.n);case"slice":return y(k.start,k.stop);case"fromCursor":return b(k.cursor)}},attach(k){let E=k.subscribe(O=>{for(let R of O)R[0]===x&&_.append(R[1])});return()=>E()},attachStorage(k){if(k.length===0)return()=>{};let E=new Map;for(let R of k)E.set(R,a.size);(async()=>{for(let R of k)if(typeof R.loadEntries=="function")try{let M=await Promise.resolve(R.loadEntries());M.entries.length>0&&a.size===0&&(a.restore(M.entries),E.set(R,M.entries.length),d());break}catch{}})();let O=u.subscribe(R=>{for(let M of R){if(M[0]!==x)continue;let G=M[1];for(let P of k){let L=E.get(P)??0;if(G.length<L){try{let U=P.appendEntries(G);U instanceof Promise&&U.catch(()=>{})}catch{}E.set(P,G.length);continue}if(G.length===L)continue;let ue=G.slice(L);E.set(P,G.length);try{let U=P.appendEntries(ue);U instanceof Promise&&U.catch(()=>{})}catch{}}}});return()=>O()},disposeAllViews(){for(let k of c.values())k.dispose();c.clear();for(let k of l.values())k.dispose();l.clear();for(let k of f.values())k.dispose();f.clear()},dispose(){for(let k of c.values())k.dispose();c.clear();for(let k of l.values())k.dispose();l.clear();for(let k of f.values())k.dispose();f.clear()}};return _}var sr=new WeakMap;function Ka(n){let e=sr.get(n);if(e)return e;let t=n.map(c=>c.cache??[]),r=t.flat(),o=F(r,{name:"mergeReactiveLogs",describeKind:"state",equals:(c,l)=>c===l}),s=n.map((c,l)=>[...t[l]??[]]),i=[];for(let c=0;c<n.length;c++){let l=c,f=n[l].subscribe(p=>{for(let h of p)if(h[0]===x)s[l]=[...h[1]],o.emit(s.flat());else if(h[0]===N){s[l]=[];let g=i[l];g!==void 0&&(i[l]=void 0,g())}else h[0]===S&&o.down([[S,h[1]]])});i.push(f)}let a=Ye(o),u=!1,d={node:o,dispose(){if(!u){u=!0;for(let c of i)c?.();i.length=0,a(),sr.delete(n)}}};return sr.set(n,d),d}function $a(n,e){let t=n.cache??0;return t>=e?!1:(n.down([[V],[x,t+1]]),!0)}var Do=Er((n,e)=>{n("observe"),n("signal"),e("write")});function ja(n){let e=ir([],{name:n.name,maxSize:n.retainedLimit??1024,guard:n.guard??Do,...n.versioning!=null?{versioning:n.versioning}:{}});return e.withLatest(),n.graph&&n.graph.add(e.entries,{name:n.name}),e}function ar(n){if(n===null||typeof n!="object"||Object.isFrozen(n))return n;for(let e of Object.keys(n))ar(n[e]);return Object.freeze(n)}function ur(n){let e=n.cache,r=(typeof e=="number"&&Number.isFinite(e)?e:0)+1;return n.down([[V],[x,r]]),r}function Ct(n,e,t,r,o,s){let i=e(t,r,o);if(i===void 0)return;let a=s!=null?{...i,handlerVersion:s}:i;n.append(a)}function Ua(n,e){let t=e.freeze??!0;return function(...o){let s=t?o.map(ar):o,i=te(),a=e.seq?ur(e.seq):void 0;try{let u=n(...s);return e.onSuccess&&Ct(e.audit,e.onSuccess,s,u,{t_ns:i,seq:a},e.handlerVersion),u}catch(u){if(e.onFailure){let d=u instanceof Error?u.name:typeof u;Ct(e.audit,e.onFailure,s,u,{t_ns:i,seq:a,errorType:d},e.handlerVersion)}throw u}}}function Wa(n,e){let t=e.freeze??!0;return function(...o){let s=t?o.map(ar):o,i=te(),a,u,d=!1,c;try{$(()=>{e.seq&&(c=ur(e.seq));try{a=n(...s),e.onSuccess&&Ct(e.audit,e.onSuccess,s,a,{t_ns:i,seq:c},e.handlerVersion)}catch(l){throw u=l,d=!0,l}})}catch(l){if(d&&e.onFailure){let f=u instanceof Error?u.name:typeof u;Ct(e.audit,e.onFailure,s,u,{t_ns:i,seq:c,errorType:f},e.handlerVersion)}throw d?u:l}return a}}function Ha(n,e,t=0){let r=F(t,{name:e,describeKind:"state"});return n.add(r,{name:e}),r}function qa(n,e,t,r=0){let o={},s=new Xe(e);for(let i of t){let a=F(r,{name:i,describeKind:"state"});s.add(a,{name:i}),o[i]=a}return n.mount(e,s),o}var dr=require("rxjs");X();function Ja(n,e){return e?.raw?new dr.Observable(t=>n.subscribe(o=>{if(!t.closed){t.next(o);for(let s of o){if(s[0]===S){t.error(s[1]);return}if(s[0]===N){t.complete();return}}}})):new dr.Observable(t=>n.subscribe(o=>{for(let s of o){if(t.closed)return;if(s[0]===x)t.next(s[1]);else if(s[0]===S){t.error(s[1]);return}else if(s[0]===N){t.complete();return}}}))}ye();X();ge();var on=class{_version=0;_topics=new Set;get version(){return this._version}get topicCount(){return this._topics.size}hasTopic(e){return this._topics.has(e)}topicNames(){return this._topics.values()}createTopic(e){return this._topics.has(e)?!1:(this._topics.add(e),this._version+=1,!0)}removeTopic(e){let t=this._topics.delete(e);return t&&(this._version+=1),t}};function Ya(n={}){let{backend:e}=n,t=e??new on,r=new Map;function o(s){let i=r.get(s);return i===void 0&&(i=B({describeKind:"state"}),r.set(s,i),t.createTopic(s)),i}return{topic(s){return o(s)},publish(s,i){o(s).emit(i)},publishMany(s){$(()=>{for(let[i,a]of s)o(i).emit(a)})},removeTopic(s){let i=r.get(s);return i===void 0?!1:(r.delete(s),t.removeTopic(s),i.down([[K]]),!0)},has(s){return t.hasTopic(s)},get size(){return t.topicCount},topicNames(){return t.topicNames()}}}ye();X();fe();function Io(n,e){if(n===e)return 0;let t=typeof n;if(t===typeof e&&(t==="number"||t==="string"||t==="boolean"||t==="bigint")){let o=n,s=e;return o<s?-1:o>s?1:0}return String(n).localeCompare(String(e))}function Qa(n,e){let t=Io(n[0],e[0]);return t!==0?t:Io(n[1],e[1])}function Lo(n){return[n.secondary,n.primary]}function ht(n,e){let t=Lo(e),r=0,o=n.length;for(;r<o;){let s=r+o>>1;Qa(t,Lo(n[s]))>0?r=s+1:o=s}return r}var sn=class{_version=0;_buf=[];_byPrimary=new Map;get version(){return this._version}get size(){return this._buf.length}has(e){return this._byPrimary.has(e)}get(e){return this._byPrimary.get(e)?.value}upsert(e,t,r,o){let s=this._byPrimary.get(e),i={primary:e,secondary:t,value:r};if(s!==void 0&&o?.equals?.(s,i))return!1;if(s!==void 0){let u=ht(this._buf,s);this._buf.splice(u,1)}let a=ht(this._buf,i);return this._buf.splice(a,0,i),this._byPrimary.set(e,i),this._version+=1,s===void 0}upsertMany(e,t){let r=0;try{for(let o of e){let s=this._byPrimary.get(o.primary),i={primary:o.primary,secondary:o.secondary,value:o.value};if(s!==void 0&&t?.equals?.(s,i))continue;if(s!==void 0){let u=ht(this._buf,s);this._buf.splice(u,1)}let a=ht(this._buf,i);this._buf.splice(a,0,i),this._byPrimary.set(o.primary,i),r+=1}}finally{r>0&&(this._version+=1)}return r}delete(e){let t=this._byPrimary.get(e);if(t===void 0)return!1;let r=ht(this._buf,t);return this._buf.splice(r,1),this._byPrimary.delete(e),this._version+=1,!0}deleteMany(e){let t=0;try{for(let r of e){let o=this._byPrimary.get(r);if(o===void 0)continue;let s=ht(this._buf,o);this._buf.splice(s,1),this._byPrimary.delete(r),t+=1}}finally{t>0&&(this._version+=1)}return t}clear(){let e=this._buf.length;return e===0?0:(this._buf.length=0,this._byPrimary.clear(),this._version+=1,e)}toArray(){return[...this._buf]}toPrimaryMap(){let e=new Map;for(let t of this._buf)e.set(t.primary,t.value);return e}};function Xa(n){return n.subscribe(()=>{})}function Za(n={}){let{name:e,versioning:t,equals:r,backend:o}=n,s=o??new sn;function i(p){return p?.equals!==void 0||r===void 0?p:{...p,equals:r}}let a=F([],{name:e,describeKind:"state",equals:(p,h)=>p===h,...t!=null?{versioning:t}:{}}),u=be([a],([p])=>{let h=p,g=new Map;for(let m of h)g.set(m.primary,m.value);return g},{initial:s.toPrimaryMap(),describeKind:"derived"}),d=Xa(u),c=!1;function l(){let p=s.toArray();$(()=>{a.down([[V]]),a.down([[x,p]])})}function f(p){let h=s.version;try{return p()}finally{s.version!==h&&l()}}return{ordered:a,byPrimary:u,has(p){return s.has(p)},get(p){return s.get(p)},get size(){return s.size},upsert(p,h,g,m){return f(()=>s.upsert(p,h,g,i(m)))},upsertMany(p,h){let g=[...p];g.length!==0&&f(()=>s.upsertMany(g,i(h)))},delete(p){f(()=>s.delete(p))},deleteMany(p){let h=[...p];h.length!==0&&f(()=>s.deleteMany(h))},clear(){f(()=>s.clear())},dispose(){c||(c=!0,d())}}}ye();X();fe();var an=class{_version=0;_buf;constructor(e){this._buf=e?[...e]:[]}get version(){return this._version}get size(){return this._buf.length}at(e){if(!Number.isInteger(e))return;let t=e>=0?e:this._buf.length+e;if(!(t<0||t>=this._buf.length))return this._buf[t]}append(e){this._buf.push(e),this._version+=1}appendMany(e){if(e.length===0)return;let t=this._buf.length;this._buf.length=t+e.length;for(let r=0;r<e.length;r++)this._buf[t+r]=e[r];this._version+=1}insert(e,t){if(!Number.isInteger(e)||e<0||e>this._buf.length)throw new RangeError(`insert: index ${e} out of range [0, ${this._buf.length}]`);this._buf.splice(e,0,t),this._version+=1}insertMany(e,t){if(!Number.isInteger(e)||e<0||e>this._buf.length)throw new RangeError(`insertMany: index ${e} out of range [0, ${this._buf.length}]`);t.length!==0&&(this._buf.splice(e,0,...t),this._version+=1)}pop(e){if(this._buf.length===0)throw new RangeError("pop from empty list");if(!Number.isInteger(e))throw new RangeError(`pop: index ${e} must be an integer`);let t=e>=0?e:this._buf.length+e;if(t<0||t>=this._buf.length)throw new RangeError(`pop: index ${e} out of range`);let[r]=this._buf.splice(t,1);return this._version+=1,r}clear(){let e=this._buf.length;return e===0?0:(this._buf.length=0,this._version+=1,e)}toArray(){return[...this._buf]}};function eu(n,e={}){let{name:t,versioning:r,backend:o}=e,s=o??new an(n),i=F(s.toArray(),{name:t,describeKind:"state",equals:(d,c)=>d===c,...r!=null?{versioning:r}:{}});function a(){let d=s.toArray();$(()=>{i.down([[V]]),i.down([[x,d]])})}function u(d){let c=s.version;try{return d()}finally{s.version!==c&&a()}}return{items:i,get size(){return s.size},at(d){return s.at(d)},append(d){u(()=>s.append(d))},appendMany(d){u(()=>s.appendMany(d))},insert(d,c){u(()=>s.insert(d,c))},insertMany(d,c){u(()=>s.insertMany(d,c))},pop(d=-1){return u(()=>s.pop(d))},clear(){u(()=>s.clear())},dispose(){}}}Wt();X();De();function tu(n,e={}){let t=e.keyFn??(o=>String(o)),r=new Map;return o=>{let s=t(o),i=r.get(s);if(i)return i;let a=n(o),u;a!=null&&typeof a.then=="function"?u=Promise.resolve(a):a!=null&&typeof a=="object"&&"subscribe"in a&&"cache"in a?u=Qn(a):a!=null&&typeof a=="object"&&Symbol.asyncIterator in a?u=(async()=>{let l=a[Symbol.asyncIterator]();try{let{value:f,done:p}=await l.next();if(p)throw new Error("singleFromAny: factory returned empty async iterable");return f}finally{await l.return?.()}})():a!=null&&typeof a=="object"&&Symbol.iterator in a?u=(async()=>{let l=a[Symbol.iterator]();try{let{value:f,done:p}=l.next();if(p)throw new Error("singleFromAny: factory returned empty iterable");return f}finally{l.return?.()}})():u=Promise.resolve(a);let d,c=()=>{r.get(s)===d&&r.delete(s)};return d=u.then(l=>(c(),l),l=>{throw c(),l}),r.set(s,d),d}}function nu(n,e={}){let t=e.keyFn??(o=>String(o)),r=new Map;return o=>{let s=t(o),i=r.get(s);if(i)return i;let a=ie(n(o));r.set(s,a);let u=a.subscribe(d=>{for(let c of d)if(c[0]===S||c[0]===N){r.get(s)===a&&r.delete(s),u();return}});return a}}De();function un(n){if(n===null||typeof n!="object")return n;if(Array.isArray(n))return n.map(un);let e=n,t=Object.keys(e).sort(),r={};for(let o of t)r[o]=un(e[o]);return r}function cr(n){return JSON.stringify(un(n),void 0,0)}var ru=new TextEncoder,ou=new TextDecoder("utf-8",{fatal:!0}),Pt={name:"json",version:1,encode(n){return ru.encode(cr(n))},decode(n){return JSON.parse(ou.decode(n))}};function su(){return Pt}function dn(){let n=new Map;return{name:"memory",read(e){let t=n.get(e);return t===void 0?void 0:new Uint8Array(t)},write(e,t){n.set(e,new Uint8Array(t))},delete(e){n.delete(e)},list(e){let t=[...n.keys()];return e?t.filter(r=>r.startsWith(e)).sort():t.sort()}}}function lr(n,e={}){let t=e.codec??Pt,r=e.name??n.name??"snapshot",o=e.keyOf??(l=>l.name??e.name??n.name??"snapshot"),s,i=0,a=e.compactEvery,u,d={name:r,debounceMs:e.debounceMs,compactEvery:a,filter:e.filter,keyOf:o,save(l){if(!(e.filter&&!e.filter(l))&&(s={snapshot:l},i+=1,a!==void 0&&i%a===0||!e.debounceMs))return c()},load(){let l=u??r,f=n.read(l);if(f!==void 0)return f instanceof Uint8Array?f.length===0?void 0:t.decode(f):Promise.resolve(f).then(p=>p===void 0||p.length===0?void 0:t.decode(p))},async flush(){await c()},async rollback(){s=void 0}};function c(){let l=s;if(!l)return;s=void 0;let f=o(l.snapshot),p=t.encode(l.snapshot),h=n.write(f,p);if(h instanceof Promise)return h.then(()=>{u=f});u=f}return d}function Bo(n,e={}){let t=e.codec??Pt,r=e.name??n.name??"append-log",o=e.keyOf??(f=>r),s=e.compactEvery,i=new Map,a=0,u,d={name:r,debounceMs:e.debounceMs,compactEvery:s,keyOf:o,appendEntries(f){if(f.length!==0){for(let p of f){let h=o(p),g=i.get(h);g||(g=[],i.set(h,g)),g.push(p)}if(a+=f.length,s!==void 0&&a%s===0||!e.debounceMs)return c()}},async loadEntries(f){let p=f?.keyFilter,h=n.list===void 0?p!==void 0?[p]:[r]:await Promise.resolve(n.list(p)),g=[];for(let m of h){let y=await Promise.resolve(n.read(m));if(y===void 0||y.length===0)continue;let b=t.decode(y);Array.isArray(b)&&g.push(...b)}return{entries:g,cursor:void 0}},async flush(){await c()},async rollback(){i=new Map}};function c(){if(i.size===0)return;let f=i;i=new Map;let p=(u??Promise.resolve()).then(()=>{let h=l(f);return h instanceof Promise?h:Promise.resolve()},()=>{let h=l(f);return h instanceof Promise?h:Promise.resolve()});return u=p.finally(()=>{u===p&&(u=void 0)}),u}function l(f){let p=[];for(let[h,g]of f){let m=n.read(h),y=b=>{let T=[...b===void 0||b.length===0?[]:t.decode(b)??[],...g],w=t.encode(T);return n.write(h,w)};if(m instanceof Promise)p.push(m.then(async b=>{let v=y(b);v instanceof Promise&&await v}));else{let b=y(m);b instanceof Promise&&p.push(b)}}if(p.length>0)return Promise.all(p).then(()=>{})}return d}function fr(n,e={}){let t=e.codec??Pt,r=e.name??n.name??"kv",o=e.compactEvery,s=new Map,i=0,a={name:r,debounceMs:e.debounceMs,compactEvery:o,filter:e.filter,save(d,c){if(!(e.filter&&!e.filter(d,c))&&(s.set(d,c),i+=1,o!==void 0&&i%o===0||!e.debounceMs))return u()},load(d){let c=n.read(d);if(c!==void 0)return c instanceof Uint8Array?c.length===0?void 0:t.decode(c):Promise.resolve(c).then(l=>l===void 0||l.length===0?void 0:t.decode(l))},delete(d){if(s.delete(d),!!n.delete)return n.delete(d)},list(d){return n.list?n.list(d):[]},async flush(){await u()},async rollback(){s=new Map}};function u(){if(s.size===0)return;let d=s;s=new Map;let c=[];for(let[l,f]of d){let p=t.encode(f),h=n.write(l,p);h instanceof Promise&&c.push(h)}if(c.length>0)return Promise.all(c).then(()=>{})}return a}function iu(n){return lr(dn(),n)}function au(n){return Bo(dn(),n)}function uu(n){return fr(dn(),n)}function du(n,e){let t={name:e?.name??"dict-kv",read(r){return n[r]},write(r,o){n[r]=new Uint8Array(o)},delete(r){delete n[r]},list(r){let o=Object.keys(n).sort();return r?o.filter(s=>s.startsWith(r)):o}};return fr(t,e)}function cu(n,e){return lr({name:"dict",read(r){return n[r]},write(r,o){n[r]=new Uint8Array(o)},delete(r){delete n[r]},list(r){let o=Object.keys(n).sort();return r?o.filter(s=>s.startsWith(r)):o}},e)}X();ge();fe();function lu(n,e,t,r){let o=new Xe(n,r);o.add(e,{name:"source"});let s=F(t,{meta:{kind:"stratify_rules"}});o.add(s,{name:"rules"});for(let i of t)fu(o,e,s,i);return o}function fu(n,e,t,r){let o=`branch/${r.name}`,s=Symbol("noValue"),i=!1,a=!1,u=!1,d=s,c=!1,l=t.cache??[];function f(g){if(u){u=!1;let m=d;if(d=s,m!==s){let y=l.find(v=>v.name===r.name),b=!1;try{b=y?.classify(m)??!1}catch{b=!1}b?(c=!1,g.emit(m)):c&&(c=!1,g.down([[V],[C]]))}else c?(c=!1,g.down([[V],[C]])):g.down([[C]])}}let p=B([],(g,m)=>{let y=e.subscribe(v=>{for(let T of v)h(T,0,m)}),b=t.subscribe(v=>{for(let T of v)h(T,1,m)});return()=>{y(),b()}},{describeKind:"derived",meta:{kind:"stratify_branch",branch:r.name},completeWhenDepsComplete:!1});function h(g,m,y){let b=g[0];return b===V?(m===0?(i=!0,c=!0):a=!0,!0):b===x||b===C?(m===0?(i=!1,u=!0,d=b===x?g[1]:s):(b===x&&(l=g[1]),a=!1),i||a||f(y),!0):b===N||b===S||b===K?(i=!1,a=!1,u=!1,d=s,c=!1,m===0&&y.down([g]),!0):m===1}if(n.add(p,{name:o}),r.ops){let g=r.ops(p),m=`branch/${r.name}/out`;n.add(g,{name:m})}}Kt();var wl=Math.LN2/604800;function Vo(n,e,t,r=0){if(!Number.isFinite(n))return r;if(!Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0)return Math.max(r,n);let o=n*Math.exp(-t*e);return Math.max(r,o)}ye();X();ge();fe();De();X();var pu=new Map([[ke,"INVALIDATE"],[le,"PAUSE"],[pe,"RESUME"],[K,"TEARDOWN"],[N,"COMPLETE"],[S,"ERROR"]]),hu=new Map([["INVALIDATE",ke],["PAUSE",le],["RESUME",pe],["TEARDOWN",K],["COMPLETE",N],["ERROR",S]]);function Ze(n){let e=pu.get(n);return e||(Symbol.keyFor(n)??"UNKNOWN")}function mt(n){let e=hu.get(n);if(e)return e;if(n&&n!=="UNKNOWN")return Symbol.for(n)}function gt(n){return n instanceof Error?{message:n.message,name:n.name,stack:n.stack}:{message:String(n),name:"Error"}}function bt(n){let e=new Error(n.message);return e.name=n.name,n.stack&&(e.stack=n.stack),e}function et(n){if(typeof MessagePort<"u"&&n instanceof MessagePort)return{post(e,t){n.postMessage(e,t??[])},listen(e){let t=r=>e(r.data);return n.addEventListener("message",t),n.start(),()=>n.removeEventListener("message",t)},terminate(){n.close()}};if(typeof SharedWorker<"u"&&n instanceof SharedWorker)return et(n.port);if(typeof Worker<"u"&&n instanceof Worker)return{post(e,t){n.postMessage(e,t??[])},listen(e){let t=r=>e(r.data);return n.addEventListener("message",t),()=>n.removeEventListener("message",t)},terminate(){n.terminate()}};if(typeof BroadcastChannel<"u"&&n instanceof BroadcastChannel)return{post(e,t){t&&t.length>0&&console.warn("[graphrefly] WorkerTransport: BroadcastChannel does not support Transferable objects. The transfer argument is ignored and objects will be cloned instead."),n.postMessage(e)},listen(e){let t=r=>e(r.data);return n.addEventListener("message",t),()=>n.removeEventListener("message",t)},terminate(){n.close()}};if(typeof ServiceWorker<"u"&&n instanceof ServiceWorker)return{post(e,t){n.postMessage(e,t??[])},listen(e){let t=r=>{r.source===n&&e(r.data)};return navigator.serviceWorker.addEventListener("message",t),()=>navigator.serviceWorker.removeEventListener("message",t)}};throw new Error("createTransport: unsupported target type. Expected Worker, SharedWorker, ServiceWorker, BroadcastChannel, or MessagePort.")}function mu(n){return typeof n=="object"&&n!==null&&typeof n.post=="function"&&typeof n.listen=="function"}function Fo(n,e){let t=mu(n)?n:et(n),r=e.name??"workerBridge",o=Object.entries(e.expose??{}),s=e.import??[],i=e.transfer??{},a=F("connecting",{name:`${r}::meta::status`}),u=F(null,{name:`${r}::meta::error`}),d=new Map,c=new Map;for(let b of s){let v=F(void 0,{name:`${r}::${b}`});d.set(b,v)}let l;if(o.length>0){let b=o.map(([,w])=>w),v=B(b,(w,_)=>{let k={};for(let E=0;E<o.length;E++){let[O]=o[E],R=w[E];R!=null&&R.length>0&&(k[O]=R.at(-1))}Object.keys(k).length!==0&&_.emit(k)},{name:`${r}::aggregated`,partial:!0});l=Gt([v],w=>{let _=w[0];if(_==null||Object.keys(_).length===0)return;let k=[];for(let R of Object.keys(_)){let M=i[R];M&&k.push(...M(_[R]))}let E;for(let[R,M]of o)R in _&&M.v!=null&&(E==null&&(E={}),E[R]=M.v.version);let O={t:"b",u:_,...E?{v:E}:{}};try{t.post(O,k.length>0?k:void 0)}catch(R){u.down([[x,R instanceof Error?R:new Error(String(R))]])}}).subscribe(()=>{})}let f=!1,p=t.listen(b=>{if(f)return;let v=b;switch(v.t){case"r":{$(()=>{for(let[w,_]of Object.entries(v.stores)){let k=d.get(w);k&&k.down([[x,_]])}}),a.down([[x,"connected"]]);let T={};for(let[w,_]of o)T[w]=_.cache;t.post({t:"i",stores:T});break}case"v":{let T=d.get(v.s);T&&T.down([[x,v.d]]);break}case"b":{$(()=>{for(let[T,w]of Object.entries(v.u)){let _=v.v?.[T];if(_!=null){let E=c.get(T);if(E!=null&&_<=E)continue;c.set(T,_)}let k=d.get(T);k&&k.down([[x,w]])}});break}case"e":{let T=d.get(v.s);T&&T.down([[S,bt(v.err)]]);break}case"s":{let T=mt(v.sig);if(!T)break;let w=v.s==="*"?[...d.values()]:d.has(v.s)?[d.get(v.s)]:[];for(let _ of w)_.down(v.d===void 0?[[T]]:[[T,v.d]]);break}}}),h=[];for(let[b,v]of o){let T=v.subscribe((w=>{if(!f)for(let _ of w){let k=_[0];k!==x&&(me.isLocalOnly(k)||(k===S?t.post({t:"e",s:b,err:gt(_[1])}):t.post({t:"s",s:b,sig:Ze(k),d:_.length>1?_[1]:void 0})))}}));h.push(T)}let g;if(e.timeoutMs!=null&&e.timeoutMs>0){let b=qe(e.timeoutMs),v=qt(a,w=>w==="connected");g=Xn(Et(Ht(b,()=>"timeout"),Ht(v,()=>"ready"))).subscribe(w=>{for(let _ of w)_[0]===x&&_[1]==="timeout"&&(u.down([[x,new Error("Worker bridge handshake timeout")]]),m())})}function m(){if(!f){f=!0,g?.(),t.post({t:"s",s:"*",sig:Ze(K)}),l&&l();for(let b of h)b();h.length=0,p(),a.down([[x,"closed"]]),c.clear(),d.clear()}}let y={meta:{status:a,error:u},destroy:m};for(let[b,v]of d)y[b]=v;return y}ye();X();ge();fe();function gu(n){return typeof n=="object"&&n!==null&&typeof n.post=="function"&&typeof n.listen=="function"}function Go(n,e){let t=gu(n)?n:et(n),r=e.import??[],o=e.transfer??{},s=new Map,i=new Map,a={};for(let m of r){let y=F(void 0,{name:`worker::${m}`});s.set(m,y),a[m]=y}let u=e.expose(a),d=Object.entries(u),c,l=!1;if(d.length>0){let m=d.map(([,v])=>v),y=B(m,(v,T)=>{let w={};for(let _=0;_<d.length;_++){let[k]=d[_],E=v[_];E!=null&&E.length>0&&(w[k]=E.at(-1))}Object.keys(w).length!==0&&T.emit(w)},{name:"workerSelf::aggregated",partial:!0});c=Gt([y],v=>{if(l)return;let T=v[0];if(T==null||Object.keys(T).length===0)return;let w=[];for(let E of Object.keys(T)){let O=o[E];O&&w.push(...O(T[E]))}let _;for(let[E,O]of d)E in T&&O.v!=null&&(_==null&&(_={}),_[E]=O.v.version);let k={t:"b",u:T,..._?{v:_}:{}};try{t.post(k,w.length>0?w:void 0)}catch{}}).subscribe(()=>{})}let f=[];for(let[m,y]of d){let b=y.subscribe((v=>{if(!l)for(let T of v){let w=T[0];w!==x&&(me.isLocalOnly(w)||(w===S?t.post({t:"e",s:m,err:gt(T[1])}):t.post({t:"s",s:m,sig:Ze(w),d:T.length>1?T[1]:void 0})))}}));f.push(b)}let p=t.listen(m=>{if(l)return;let y=m;switch(y.t){case"i":{$(()=>{for(let[b,v]of Object.entries(y.stores)){let T=s.get(b);T&&T.down([[x,v]])}});break}case"v":{let b=s.get(y.s);b&&b.down([[x,y.d]]);break}case"b":{$(()=>{for(let[b,v]of Object.entries(y.u)){let T=y.v?.[b];if(T!=null){let _=i.get(b);if(_!=null&&T<=_)continue;i.set(b,T)}let w=s.get(b);w&&w.down([[x,v]])}});break}case"e":{let b=s.get(y.s);b&&b.down([[S,bt(y.err)]]);break}case"s":{let b=mt(y.sig);if(!b)break;if(b===K&&y.s==="*"){g();return}let v=y.s==="*"?[...s.values()]:s.has(y.s)?[s.get(y.s)]:[];for(let T of v)T.down(y.d===void 0?[[b]]:[[b,y.d]]);break}}}),h={};for(let[m,y]of d)h[m]=y.cache;t.post({t:"r",stores:h});function g(){if(!l){l=!0,c&&c();for(let m of f)m();f.length=0,p(),t.terminate?.(),i.clear(),s.clear()}}return{destroy:g}}0&&(module.exports={CircuitOpenError,ContentAddressedMissError,DEFAULT_AUDIT_GUARD,NS_PER_MS,NS_PER_SEC,NativeIndexBackend,NativeListBackend,NativeLogBackend,NativeMapBackend,NativePubSubBackend,RateLimiterOverflowError,ResettableTimer,TimeoutError,appendAudit,appendLogStorage,audit,awaitSettled,budgetGate,buffer,bufferCount,bufferTime,bumpCursor,cached,canonicalJson,cascadingCache,catchError,checkpointToRedis,checkpointToS3,circuitBreaker,combine,combineLatest,concat,concatMap,constant,contentAddressedStorage,createAuditLog,createTransport,createWatermarkController,csvRows,debounce,debounceTime,decay,decorrelatedJitter,defer,delay,deserializeError,dictKv,dictSnapshot,distill,distinctUntilChanged,domainMeta,elementAt,empty,escapeRegexChar,exhaustMap,exponential,externalBundle,externalProducer,fallback,fibonacci,filter,find,first,firstValueFrom,firstWhere,flatMap,forEach,fromAny,fromAsyncIter,fromCSV,fromClickHouseWatch,fromCron,fromDrizzle,fromEvent,fromHTTP,fromHTTPPoll,fromHTTPStream,fromIter,fromKafka,fromKysely,fromMCP,fromNATS,fromNDJSON,fromOTel,fromPrisma,fromPrometheus,fromPromise,fromPulsar,fromRabbitMQ,fromRaf,fromRedisStream,fromSSE,fromSqlite,fromSqliteCursor,fromStatsD,fromSyslog,fromTimer,fromWebSocket,fromWebSocketReconnect,fromWebhook,globToRegExp,interval,jsonCodec,jsonCodecFor,keepalive,kvStorage,last,lightMutation,linear,lru,makeHttpError,map,matchesAnyPattern,matchesCron,memoryAppendLog,memoryBackend,memoryKv,memorySnapshot,merge,mergeMap,mergeReactiveLogs,nameToSignal,ndjsonRows,never,nodeSignal,of,onFirstData,pairwise,parseCron,parsePrometheusText,parseSSEStream,parseStatsD,parseSyslog,pausable,pubsub,race,rateLimiter,reactiveCounter,reactiveIndex,reactiveList,reactiveLog,reactiveMap,reactiveSink,reduce,registerCursor,registerCursorMap,repeat,replay,rescue,resolveBackoffPreset,retry,sample,scan,serializeError,share,shareReplay,signalToName,singleFromAny,singleNodeFromAny,skip,snapshotStorage,sortJsonValue,stableJsonString,stratify,switchMap,take,takeUntil,takeWhile,tap,tapFirst,throttle,throttleTime,throwError,timeout,toArray,toCSV,toClickHouse,toFile,toHTTP,toKafka,toLoki,toMongo,toNATS,toObservable,toPostgres,toPulsar,toRabbitMQ,toReadableStream,toRedisStream,toS3,toSSE,toSSEBytes,toSqlite,toTempo,toWebSocket,tokenBucket,topologyDiff,tryIncrementBounded,valve,verifiable,window,windowCount,windowTime,withBreaker,withLatestFrom,withMaxAttempts,withStatus,workerBridge,workerSelf,wrapMutation,zip});