@graphrefly/graphrefly 0.28.0 → 0.29.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 (284) hide show
  1. package/dist/{cascading-D9WG1-9L.d.ts → cascading-Bp99ckMJ.d.ts} +1 -1
  2. package/dist/{cascading-B-5zmAUv.d.cts → cascading-CcAgRacD.d.cts} +1 -1
  3. package/dist/{chunk-XAUNPIMX.js → chunk-22F4K3G7.js} +1 -1
  4. package/dist/chunk-22SVXUPB.js +64 -0
  5. package/dist/{chunk-OAWLCNJJ.js → chunk-2GQREQ6C.js} +1 -1
  6. package/dist/chunk-4JJCCD5S.js +2 -0
  7. package/dist/{chunk-GHJJR5P4.js → chunk-4OFIQ66T.js} +1 -1
  8. package/dist/chunk-4V4C7K56.js +1 -0
  9. package/dist/{chunk-PIOGHC63.js → chunk-567NWZ3T.js} +1 -1
  10. package/dist/chunk-5JDE5JHE.js +1 -0
  11. package/dist/{chunk-ETWTCCJI.js → chunk-5Z4HDCO6.js} +1 -1
  12. package/dist/{chunk-WQ2BN6X6.js → chunk-63FFOHLA.js} +1 -1
  13. package/dist/{chunk-CRXTH3SH.js → chunk-7JDLFI6N.js} +1 -1
  14. package/dist/{chunk-DQA3UIQ2.js → chunk-7TDOES3L.js} +1 -1
  15. package/dist/{chunk-CWLN3X3N.js → chunk-A7IAQQ63.js} +1 -1
  16. package/dist/{chunk-ERLIRFPA.js → chunk-AMG5VBHW.js} +1 -1
  17. package/dist/{chunk-D7A7DBE4.js → chunk-AUY2YKCO.js} +1 -1
  18. package/dist/{chunk-FNYWM6JC.js → chunk-AV3PIDFQ.js} +1 -1
  19. package/dist/{chunk-UMBIDLJ4.js → chunk-BA5URFYW.js} +1 -1
  20. package/dist/chunk-BKPLTBL5.js +1 -0
  21. package/dist/{chunk-UPXUCFMX.js → chunk-BZP5T4X6.js} +1 -1
  22. package/dist/{chunk-S35VARIR.js → chunk-CSJE2EKV.js} +1 -1
  23. package/dist/{chunk-76A3HVQE.js → chunk-E3AXATVZ.js} +1 -1
  24. package/dist/{chunk-LQ3Y5NJS.js → chunk-GJR3P6JG.js} +1 -1
  25. package/dist/{chunk-2FOAM3OR.js → chunk-GNCBXARM.js} +1 -1
  26. package/dist/{chunk-OBKQQA5I.js → chunk-HSIEYSDY.js} +1 -1
  27. package/dist/{chunk-K2GNMCQT.js → chunk-ISCENNXS.js} +1 -1
  28. package/dist/{chunk-OYHGKYQM.js → chunk-JYOUF6UQ.js} +1 -1
  29. package/dist/{chunk-2PMCKKRK.js → chunk-KASHOCF5.js} +1 -1
  30. package/dist/{chunk-MIQTDPY4.js → chunk-LGSNR4LU.js} +1 -1
  31. package/dist/{chunk-UPHHLMHE.js → chunk-LVGBLZM2.js} +1 -1
  32. package/dist/chunk-MGKAO4EK.js +7 -0
  33. package/dist/{chunk-ZV2DXV5A.js → chunk-NSG4C6BF.js} +1 -1
  34. package/dist/{chunk-4GKB4OUJ.js → chunk-OL33ZI6R.js} +1 -1
  35. package/dist/{chunk-3R5HFPX7.js → chunk-PCZ35NXD.js} +1 -1
  36. package/dist/chunk-PGMUCUHG.js +43 -0
  37. package/dist/{chunk-U3AICJKU.js → chunk-RD52SNH2.js} +1 -1
  38. package/dist/{chunk-VTPVOGHH.js → chunk-SLMYTGTU.js} +1 -1
  39. package/dist/{chunk-VPYBOXVT.js → chunk-TWMEGG45.js} +1 -1
  40. package/dist/{chunk-Y2EMPB3I.js → chunk-UVJQ35G2.js} +1 -1
  41. package/dist/{chunk-UWJE5FQA.js → chunk-VGTCGNRX.js} +11 -11
  42. package/dist/{chunk-SC3U7ETD.js → chunk-VWPRPPKR.js} +1 -1
  43. package/dist/chunk-W4TSQ6RJ.js +1 -0
  44. package/dist/{chunk-LBTDSCCO.js → chunk-WM7H7WTY.js} +1 -1
  45. package/dist/{chunk-MTTAAPCK.js → chunk-Y32RJO24.js} +1 -1
  46. package/dist/{chunk-DBGGMN3D.js → chunk-Y53B6NS4.js} +1 -1
  47. package/dist/compat/index.cjs +13 -12
  48. package/dist/compat/index.d.cts +14 -14
  49. package/dist/compat/index.d.ts +14 -14
  50. package/dist/compat/index.js +1 -1
  51. package/dist/compat/jotai/index.cjs +1 -1
  52. package/dist/compat/jotai/index.d.cts +2 -2
  53. package/dist/compat/jotai/index.d.ts +2 -2
  54. package/dist/compat/jotai/index.js +1 -1
  55. package/dist/compat/nanostores/index.cjs +1 -1
  56. package/dist/compat/nanostores/index.d.cts +2 -2
  57. package/dist/compat/nanostores/index.d.ts +2 -2
  58. package/dist/compat/nanostores/index.js +1 -1
  59. package/dist/compat/nestjs/index.cjs +13 -12
  60. package/dist/compat/nestjs/index.d.cts +6 -6
  61. package/dist/compat/nestjs/index.d.ts +6 -6
  62. package/dist/compat/nestjs/index.js +1 -1
  63. package/dist/compat/react/index.d.cts +2 -2
  64. package/dist/compat/react/index.d.ts +2 -2
  65. package/dist/compat/solid/index.d.cts +2 -2
  66. package/dist/compat/solid/index.d.ts +2 -2
  67. package/dist/compat/svelte/index.d.cts +2 -2
  68. package/dist/compat/svelte/index.d.ts +2 -2
  69. package/dist/compat/vue/index.d.cts +2 -2
  70. package/dist/compat/vue/index.d.ts +2 -2
  71. package/dist/compat/zustand/index.cjs +7 -6
  72. package/dist/compat/zustand/index.d.cts +4 -4
  73. package/dist/compat/zustand/index.d.ts +4 -4
  74. package/dist/compat/zustand/index.js +1 -1
  75. package/dist/{composite-BhbKHbOS.d.ts → composite-BL-llbnE.d.ts} +2 -2
  76. package/dist/{composite-B-xqw4Kk.d.cts → composite-Dze--DaA.d.cts} +2 -2
  77. package/dist/core/index.cjs +1 -1
  78. package/dist/core/index.d.cts +4 -4
  79. package/dist/core/index.d.ts +4 -4
  80. package/dist/core/index.js +1 -1
  81. package/dist/extra/browser.cjs +1 -1
  82. package/dist/extra/browser.d.cts +1 -1
  83. package/dist/extra/browser.d.ts +1 -1
  84. package/dist/extra/browser.js +1 -1
  85. package/dist/extra/index.cjs +20 -19
  86. package/dist/extra/index.d.cts +9 -9
  87. package/dist/extra/index.d.ts +9 -9
  88. package/dist/extra/index.js +1 -1
  89. package/dist/extra/node.cjs +3 -3
  90. package/dist/extra/node.d.cts +1 -1
  91. package/dist/extra/node.d.ts +1 -1
  92. package/dist/extra/node.js +1 -1
  93. package/dist/extra/operators.cjs +1 -1
  94. package/dist/extra/operators.d.cts +1 -1
  95. package/dist/extra/operators.d.ts +1 -1
  96. package/dist/extra/operators.js +1 -1
  97. package/dist/extra/reactive.cjs +1 -1
  98. package/dist/extra/reactive.d.cts +3 -3
  99. package/dist/extra/reactive.d.ts +3 -3
  100. package/dist/extra/reactive.js +1 -1
  101. package/dist/extra/sources.cjs +1 -1
  102. package/dist/extra/sources.d.cts +1 -1
  103. package/dist/extra/sources.d.ts +1 -1
  104. package/dist/extra/sources.js +1 -1
  105. package/dist/extra/storage-browser.cjs +1 -1
  106. package/dist/extra/storage-browser.d.cts +1 -1
  107. package/dist/extra/storage-browser.d.ts +1 -1
  108. package/dist/extra/storage-browser.js +1 -1
  109. package/dist/graph/index.cjs +7 -6
  110. package/dist/graph/index.d.cts +5 -5
  111. package/dist/graph/index.d.ts +5 -5
  112. package/dist/graph/index.js +1 -1
  113. package/dist/{graph-D48Qw9Cg.d.cts → graph-DgohqXK-.d.cts} +22 -6
  114. package/dist/{graph-BZGRXwOm.d.ts → graph-Qjg9gWHI.d.ts} +22 -6
  115. package/dist/{index-ZftwfxJM.d.ts → index-2BVuRCI4.d.ts} +7 -7
  116. package/dist/{index-m-yHof5p.d.ts → index-2NvguqQA.d.ts} +4 -4
  117. package/dist/{index-DpHe5e0Q.d.ts → index-A65LZhoM.d.ts} +2 -2
  118. package/dist/{index-cByzxQIC.d.cts → index-B-8FCEua.d.cts} +4 -4
  119. package/dist/{index-8FSVk4Uf.d.ts → index-B-gqvYel.d.ts} +4 -4
  120. package/dist/{index-vscRDkjW.d.cts → index-B2PRuolf.d.cts} +2 -2
  121. package/dist/{index-DAlweici.d.ts → index-BJqt9EwW.d.ts} +2 -2
  122. package/dist/{index-DUqMOlKZ.d.cts → index-BKjT5DiZ.d.cts} +7 -7
  123. package/dist/{index-CMn8S8Hw.d.ts → index-BM8BU4q6.d.ts} +1 -1
  124. package/dist/{index-B1AmmSlb.d.ts → index-BQaEnxBf.d.ts} +1 -1
  125. package/dist/{index-sm373fsH.d.ts → index-BSfwiy5B.d.ts} +2 -2
  126. package/dist/{index-9oDeHH2u.d.cts → index-BTSkeCZs.d.cts} +2 -2
  127. package/dist/{index-rHJSKsU8.d.cts → index-BUVtw1Ay.d.cts} +2 -2
  128. package/dist/{index-BgyGlizc.d.ts → index-BUi57v_p.d.ts} +4 -4
  129. package/dist/{index-DyxjtScX.d.cts → index-BanNUILp.d.cts} +2 -2
  130. package/dist/{index-C73n7lo-.d.cts → index-BayHDRx6.d.cts} +3 -3
  131. package/dist/{index-umtoWT8K.d.ts → index-BiyjsZ0m.d.ts} +6 -5
  132. package/dist/{index-BHvIquRZ.d.ts → index-BqZ6vB2A.d.ts} +592 -492
  133. package/dist/{index-tbf2gKHd.d.cts → index-BuVidq3D.d.cts} +3 -3
  134. package/dist/{index-DaLJvH8Z.d.ts → index-Byh-xTyp.d.ts} +3 -3
  135. package/dist/{index-rX8HBM5h.d.cts → index-C08QPDcV.d.cts} +2 -2
  136. package/dist/{index-CzobVSMr.d.ts → index-C66RJiX8.d.ts} +2 -2
  137. package/dist/{index-CpgYhnrG.d.ts → index-C8RfjffH.d.ts} +2 -2
  138. package/dist/{index-Btib9rsU.d.ts → index-CA1Cu7Ud.d.ts} +275 -9
  139. package/dist/{index-CRO83MmV.d.cts → index-CABbltIu.d.cts} +1 -1
  140. package/dist/{index-B2pwesl9.d.cts → index-CHEBsnYv.d.cts} +1 -1
  141. package/dist/{index-CloUk1kY.d.ts → index-CI0yDnLp.d.ts} +9 -9
  142. package/dist/{index-DiOXyAwt.d.ts → index-CJ45TW-h.d.ts} +1 -1
  143. package/dist/{index-rnwQly8X.d.cts → index-CJZKZoo4.d.cts} +6 -5
  144. package/dist/{index-BwM9BEkt.d.ts → index-CX2tFJL1.d.ts} +1 -1
  145. package/dist/{index-D-YB-Vl3.d.ts → index-CcWOJ6F0.d.ts} +3 -3
  146. package/dist/{index-HDpJe9hX.d.ts → index-CiaVoZGo.d.ts} +3 -3
  147. package/dist/{index-BVHOrDwO.d.ts → index-Ct5CWc4E.d.ts} +1 -1
  148. package/dist/{index-BpIFjILY.d.cts → index-D38duMCv.d.cts} +4 -4
  149. package/dist/{index-ROpQmGjE.d.ts → index-D5XJ2tSx.d.ts} +3 -3
  150. package/dist/{index-Cyojz0AE.d.cts → index-D80do5jX.d.cts} +1 -1
  151. package/dist/{index-pXrDMpRO.d.cts → index-D9HKAH_-.d.cts} +2 -2
  152. package/dist/{index-dtN7YA2x.d.cts → index-DBe_8XW5.d.cts} +3 -3
  153. package/dist/{index-DP4ZTkdw.d.ts → index-DCeTyFlB.d.ts} +3 -3
  154. package/dist/{index-DfyOkTvs.d.ts → index-DDy8eeXS.d.ts} +2 -2
  155. package/dist/{index-Czq6ynh8.d.ts → index-DJ5oNBc8.d.ts} +3 -3
  156. package/dist/{index-fM6y00vT.d.cts → index-DP0_O3ls.d.cts} +3 -3
  157. package/dist/{index-u15meRxL.d.cts → index-DX8xS-yB.d.cts} +2 -2
  158. package/dist/{index-DEwTb_fm.d.cts → index-DiZejfCI.d.cts} +592 -492
  159. package/dist/{index-CHEswufn.d.cts → index-DknyJ2Fu.d.cts} +4 -4
  160. package/dist/{index-DcXZBF5a.d.cts → index-DoWMs-Kk.d.cts} +4 -4
  161. package/dist/{index-B0c4cmIO.d.ts → index-DuB5aO4-.d.ts} +2 -2
  162. package/dist/{index-BpA5c4G9.d.ts → index-DwjJGKxV.d.ts} +4 -4
  163. package/dist/{index-Oi8d8w4R.d.cts → index-H_oxVec5.d.cts} +1 -1
  164. package/dist/{index-Bqachn9_.d.ts → index-IMAHq-ia.d.ts} +1 -1
  165. package/dist/{index-D_NwnRYS.d.cts → index-U1nir7MX.d.cts} +1 -1
  166. package/dist/{index-DraikLjn.d.ts → index-Vg7tORgk.d.ts} +2 -2
  167. package/dist/{index-RukJ4DLS.d.cts → index-dig-r2tQ.d.cts} +275 -9
  168. package/dist/{index-BWJV63ti.d.ts → index-gsT79Xu9.d.ts} +1 -1
  169. package/dist/{index-DxsnAMWD.d.cts → index-i99Ka8s7.d.cts} +9 -9
  170. package/dist/{index-BxJ86YZZ.d.cts → index-iKkyJosF.d.cts} +3 -3
  171. package/dist/{index-B_agccPe.d.cts → index-jleeotBT.d.cts} +1 -1
  172. package/dist/{index-O6TgGUBV.d.cts → index-kykKWwV-.d.cts} +3 -3
  173. package/dist/{index-CEXXwWVH.d.cts → index-vgcLF5TH.d.cts} +2 -2
  174. package/dist/{index-DL-rYJrx.d.cts → index-y1RllPn4.d.cts} +1 -1
  175. package/dist/index.cjs +53 -52
  176. package/dist/index.d.cts +42 -42
  177. package/dist/index.d.ts +42 -42
  178. package/dist/index.js +1 -1
  179. package/dist/{meta-Cgj6zeji.d.cts → meta-CX7YsOzp.d.cts} +1 -1
  180. package/dist/{meta-CwesDrMD.d.ts → meta-CckhhFRd.d.ts} +1 -1
  181. package/dist/{node-Cc1TniY8.d.ts → node-Dd6wHSib.d.cts} +35 -2
  182. package/dist/{node-Cc1TniY8.d.cts → node-Dd6wHSib.d.ts} +35 -2
  183. package/dist/{observable-Ct-gJ9jI.d.ts → observable-BZJgo616.d.ts} +1 -1
  184. package/dist/{observable-glXQoGj2.d.cts → observable-kwzpLvbi.d.cts} +1 -1
  185. package/dist/patterns/ai/browser.d.cts +3 -3
  186. package/dist/patterns/ai/browser.d.ts +3 -3
  187. package/dist/patterns/ai/browser.js +1 -1
  188. package/dist/patterns/ai/index.cjs +25 -24
  189. package/dist/patterns/ai/index.d.cts +15 -15
  190. package/dist/patterns/ai/index.d.ts +15 -15
  191. package/dist/patterns/ai/index.js +1 -1
  192. package/dist/patterns/ai/node.d.cts +1 -1
  193. package/dist/patterns/ai/node.d.ts +1 -1
  194. package/dist/patterns/ai/node.js +1 -1
  195. package/dist/patterns/audit/index.cjs +7 -6
  196. package/dist/patterns/audit/index.d.cts +5 -5
  197. package/dist/patterns/audit/index.d.ts +5 -5
  198. package/dist/patterns/audit/index.js +1 -1
  199. package/dist/patterns/cqrs/index.cjs +7 -6
  200. package/dist/patterns/cqrs/index.d.cts +4 -4
  201. package/dist/patterns/cqrs/index.d.ts +4 -4
  202. package/dist/patterns/cqrs/index.js +1 -1
  203. package/dist/patterns/demo-shell/index.cjs +8 -7
  204. package/dist/patterns/demo-shell/index.d.cts +5 -5
  205. package/dist/patterns/demo-shell/index.d.ts +5 -5
  206. package/dist/patterns/demo-shell/index.js +1 -1
  207. package/dist/patterns/domain-templates/index.cjs +7 -6
  208. package/dist/patterns/domain-templates/index.d.cts +4 -4
  209. package/dist/patterns/domain-templates/index.d.ts +4 -4
  210. package/dist/patterns/domain-templates/index.js +1 -1
  211. package/dist/patterns/graphspec/index.cjs +26 -25
  212. package/dist/patterns/graphspec/index.d.cts +4 -4
  213. package/dist/patterns/graphspec/index.d.ts +4 -4
  214. package/dist/patterns/graphspec/index.js +1 -1
  215. package/dist/patterns/guarded-execution/index.cjs +7 -6
  216. package/dist/patterns/guarded-execution/index.d.cts +6 -6
  217. package/dist/patterns/guarded-execution/index.d.ts +6 -6
  218. package/dist/patterns/guarded-execution/index.js +1 -1
  219. package/dist/patterns/harness/index.cjs +11 -10
  220. package/dist/patterns/harness/index.d.cts +10 -7
  221. package/dist/patterns/harness/index.d.ts +10 -7
  222. package/dist/patterns/harness/index.js +1 -1
  223. package/dist/patterns/job-queue/index.cjs +7 -6
  224. package/dist/patterns/job-queue/index.d.cts +4 -4
  225. package/dist/patterns/job-queue/index.d.ts +4 -4
  226. package/dist/patterns/job-queue/index.js +1 -1
  227. package/dist/patterns/lens/index.cjs +7 -6
  228. package/dist/patterns/lens/index.d.cts +6 -6
  229. package/dist/patterns/lens/index.d.ts +6 -6
  230. package/dist/patterns/lens/index.js +1 -1
  231. package/dist/patterns/memory/index.cjs +7 -6
  232. package/dist/patterns/memory/index.d.cts +4 -4
  233. package/dist/patterns/memory/index.d.ts +4 -4
  234. package/dist/patterns/memory/index.js +1 -1
  235. package/dist/patterns/messaging/index.cjs +7 -6
  236. package/dist/patterns/messaging/index.d.cts +4 -4
  237. package/dist/patterns/messaging/index.d.ts +4 -4
  238. package/dist/patterns/messaging/index.js +1 -1
  239. package/dist/patterns/orchestration/index.cjs +7 -6
  240. package/dist/patterns/orchestration/index.d.cts +5 -5
  241. package/dist/patterns/orchestration/index.d.ts +5 -5
  242. package/dist/patterns/orchestration/index.js +1 -1
  243. package/dist/patterns/reactive-layout/index.cjs +8 -7
  244. package/dist/patterns/reactive-layout/index.d.cts +5 -5
  245. package/dist/patterns/reactive-layout/index.d.ts +5 -5
  246. package/dist/patterns/reactive-layout/index.js +1 -1
  247. package/dist/patterns/reduction/index.cjs +7 -6
  248. package/dist/patterns/reduction/index.d.cts +4 -4
  249. package/dist/patterns/reduction/index.d.ts +4 -4
  250. package/dist/patterns/reduction/index.js +1 -1
  251. package/dist/patterns/refine-loop/index.cjs +9 -8
  252. package/dist/patterns/refine-loop/index.d.cts +5 -5
  253. package/dist/patterns/refine-loop/index.d.ts +5 -5
  254. package/dist/patterns/refine-loop/index.js +1 -1
  255. package/dist/patterns/resilient-pipeline/index.cjs +1 -1
  256. package/dist/patterns/resilient-pipeline/index.d.cts +6 -6
  257. package/dist/patterns/resilient-pipeline/index.d.ts +6 -6
  258. package/dist/patterns/resilient-pipeline/index.js +1 -1
  259. package/dist/patterns/surface/index.cjs +14 -13
  260. package/dist/patterns/surface/index.d.cts +5 -5
  261. package/dist/patterns/surface/index.d.ts +5 -5
  262. package/dist/patterns/surface/index.js +1 -1
  263. package/dist/{reactive-layout-D8u4wuUR.d.ts → reactive-layout-BkBwVvwm.d.ts} +2 -2
  264. package/dist/{reactive-layout-CpYb5qLP.d.cts → reactive-layout-PiFwVaWS.d.cts} +2 -2
  265. package/dist/{reactive-log-YuH9VYN8.d.ts → reactive-log-1QTyx10a.d.ts} +1 -1
  266. package/dist/{reactive-log-DPzuUDj5.d.cts → reactive-log-BiVoSxke.d.cts} +1 -1
  267. package/dist/{reactive-map-DUeRmb9d.d.cts → reactive-map-CwO_COHy.d.cts} +1 -1
  268. package/dist/{reactive-map-CdbNoSgP.d.ts → reactive-map-FeuTVAJb.d.ts} +1 -1
  269. package/dist/{resilience-CGRzhnD3.d.ts → resilience-CBfYJW5C.d.ts} +1 -1
  270. package/dist/{resilience-QAHKANT5.js → resilience-XRUF267O.js} +1 -1
  271. package/dist/{resilience-Ba5-b4WD.d.cts → resilience-uBz4yvYB.d.cts} +1 -1
  272. package/dist/{sugar-BV0htudb.d.cts → sugar-CY-MCfZ9.d.ts} +10 -12
  273. package/dist/{sugar-Dtyrq2_q.d.ts → sugar-DHttV0LX.d.cts} +10 -12
  274. package/dist/{topology-tree-DROUdq5B.d.cts → topology-tree-CVjt2gp7.d.cts} +1 -1
  275. package/dist/{topology-tree-CYHOwQZ_.d.ts → topology-tree-one6oSKY.d.ts} +1 -1
  276. package/package.json +1 -1
  277. package/dist/chunk-6V3SEX2I.js +0 -1
  278. package/dist/chunk-7H6LGFUG.js +0 -64
  279. package/dist/chunk-CKCSDI7T.js +0 -6
  280. package/dist/chunk-QWAPKG3O.js +0 -2
  281. package/dist/chunk-RHESUC3V.js +0 -43
  282. package/dist/chunk-V6YQICXZ.js +0 -1
  283. package/dist/chunk-Z4HDAS2Q.js +0 -1
  284. package/dist/chunk-ZB5EHBIO.js +0 -1
@@ -1 +1 @@
1
- import{a as $}from"./chunk-DBGGMN3D.js";import{c as O}from"./chunk-ETWTCCJI.js";import{a as C}from"./chunk-2FOAM3OR.js";import{j as A}from"./chunk-CKCSDI7T.js";import{b as x}from"./chunk-D7A7DBE4.js";import{A as R}from"./chunk-2PMCKKRK.js";import{C as T,E as N,G as E,o as b,p as w,u as P,w as S}from"./chunk-ZB5EHBIO.js";import{b as v}from"./chunk-CK2E7BTU.js";import{b as M}from"./chunk-QYADASLV.js";var J={};M(J,{AuditTrailGraph:()=>k,PolicyEnforcerGraph:()=>G,auditTrail:()=>z,complianceSnapshot:()=>F,policyEnforcer:()=>K,reactiveExplainPath:()=>q});function V(i,t){return O("audit",i,t)}var L=new Set(["data","error","complete","teardown"]),k=class extends A{entries;count;_log;_target;constructor(t,n){super(n.name??`${t.name}_audit`,n.graph),this._target=t,this._log=x([],{name:"entries",...n.maxSize!=null?{maxSize:n.maxSize}:{}}),this.entries=this._log.entries,this.add(this.entries,{name:"entries"}),this.count=E([this.entries],([c])=>c.length,{name:"count",describeKind:"derived",meta:V("count")}),this.add(this.count,{name:"count"}),this.addDisposer(R(this.count));let o=n.includeTypes!=null?new Set(n.includeTypes):L,u=n.filter,a=0,h=t.observe({timeline:!0,structured:!0}),m=h.onEvent(c=>{if(c.type==="derived")return;let e=c.type;if(!o.has(e))return;let d=c.path??"",r={seq:a++,timestamp_ns:c.timestamp_ns??b(),wall_clock_ns:w(),path:d,type:e},f=(d?D(t,d):void 0)?.lastMutation;f!=null&&(r.actor=f.actor),e==="data"&&(r.value=c.data),e==="error"&&(r.error=c.data);let l=d?U(t,d):void 0;l!=null&&(r.annotation=l),!(u!=null&&!u(r))&&this._log.append(r)});this.addDisposer(()=>{m(),h.dispose()}),this.addDisposer(()=>this._log.disposeAllViews())}all(){return this.entries.cache??[]}byNode(t){return this.all().filter(n=>n.path===t)}byActor(t){return this.all().filter(n=>n.actor?.id===t)}byActorType(t){return this.all().filter(n=>n.actor?.type===t)}byTimeRange(t,n){return this.all().filter(o=>!(o.timestamp_ns<t||n!=null&&o.timestamp_ns>=n))}get target(){return this._target}};function z(i,t={}){return new k(i,t)}var G=class extends A{policies;violations;violationCount;_target;_mode;_currentGuard;constructor(t,n,o){super(o.name??`${t.name}_policy`,o.graph),this._target=t,this._mode=o.mode??"audit";let u=I(n)?n:N(n,{name:"policies"});this.policies=u,this.add(this.policies,{name:"policies"}),this.violations=new $("violations",{retainedLimit:o.violationsLimit??1e3}),this.mount("violations",this.violations),this.violationCount=E([this.violations.events],([e])=>e.length,{name:"violationCount",describeKind:"derived",meta:V("policy_violation_count")}),this.add(this.violationCount,{name:"violationCount"}),this.addDisposer(R(this.violationCount));let h=u.cache??[];this._currentGuard=P(h);let m=u.subscribe(e=>{for(let d of e)d[0]===v&&(h=d[1]??[],this._currentGuard=P(h))});this.addDisposer(m);let c=o.paths!=null?[...o.paths]:j(t);if(this._mode==="enforce"){let e=new Map,d=r=>{if(e.has(r))return;let s=D(t,r);if(!(s instanceof T))return;let f=(l,p)=>{let y=this._currentGuard(l,p);return y||this._publishViolation(l,p,r,"blocked"),y};e.set(r,s._pushGuard(f))};for(let r of c)d(r);if(o.paths==null){let r=C(t,(s,f,l)=>{if(s.kind==="added")if(s.nodeKind==="node")d(`${l}${s.name}`);else{let p=f._mounts.get(s.name);if(!(p instanceof A))return;let y=`${l}${s.name}::`,_=j(p);for(let g of _)d(g===""?`${l}${s.name}`:`${y}${g}`)}else if(s.kind==="removed")if(s.nodeKind==="node"){let p=`${l}${s.name}`,y=e.get(p);y!=null&&(y(),e.delete(p))}else{let p=`${l}${s.name}`,y=`${p}::`;for(let[_,g]of e)(_===p||_.startsWith(y))&&(g(),e.delete(_))}});this.addDisposer(r)}else{let r=t.topology.subscribe(s=>{for(let f of s){if(f[0]!==v)continue;let l=f[1];if(l.kind!=="removed"||l.nodeKind!=="node")continue;let p=e.get(l.name);p!=null&&(p(),e.delete(l.name))}});this.addDisposer(r)}this.addDisposer(()=>{for(let r of e.values())r();e.clear()})}else{let e=t.observe({timeline:!0,structured:!0}),d=e.onEvent(r=>{if(r.type!=="data"&&r.type!=="error")return;let s=r.path??"";if(!s||o.paths!=null&&!o.paths.includes(s))return;let f=r.actor??D(t,s)?.lastMutation?.actor;if(f==null)return;let l="write";this._currentGuard(f,l)||this._publishViolation(f,l,s,"observed")});this.addDisposer(()=>{d(),e.dispose()})}}_publishViolation(t,n,o,u){this.violations.publish({timestamp_ns:b(),wall_clock_ns:w(),path:o,actor:t,action:n,mode:this._mode,result:u})}all(){return this.violations.retained()}get mode(){return this._mode}get target(){return this._target}};function K(i,t,n={}){return new G(i,t,n)}function q(i,t,n,o){return i.explain(t,n,{reactive:!0,...o})}function F(i,t={}){let n={format_version:1,timestamp_ns:b(),wall_clock_ns:w(),graph:i.snapshot()};if(t.actor!=null&&(n.actor=t.actor),t.audit!=null){let u=[...t.audit.all()];n.audit={count:u.length,entries:u}}if(t.policies!=null){let u=t.policies.policies.cache??[];n.policies={mode:t.policies.mode,rules:u,violations:[...t.policies.all()]}}let o=B(n);return{...n,fingerprint:o}}function I(i){return typeof i=="object"&&i!==null&&"subscribe"in i}function D(i,t){try{return i.node(t)}catch{return}}function U(i,t){try{return i.annotation(t)}catch{return}}function j(i){let t=i.describe({detail:"minimal"});return Object.keys(t.nodes)}function B(i){return S(JSON.stringify(H(i)))}function H(i){let t=new Set,n=o=>{if(o===void 0)return{__undefined:!0};if(o===null)return null;let u=typeof o;if(u==="bigint")return{__bigint:o.toString()};if(u!=="object")return o;let a=o;if(t.has(a))return{__circular:!0};t.add(a);try{if(Array.isArray(a))return a.map(n);if(a instanceof Date)return{__date:a.toISOString()};if(a instanceof RegExp)return{__regexp:{source:a.source,flags:a.flags}};if(a instanceof Map)return{__map:[...a.entries()].map(([c,e])=>[n(c),n(e)])};if(a instanceof Set)return{__set:[...a].map(n)};if(ArrayBuffer.isView(a)){let m=a,c=new Array(m.length);for(let e=0;e<m.length;e++)c[e]=m[e]??0;return{__typed_array:{ctor:a.constructor.name,data:c}}}let h={};for(let m of Object.keys(a).sort())h[m]=n(a[m]);return h}finally{t.delete(a)}};return n(i)}export{k as a,z as b,G as c,K as d,q as e,F as f,J as g};
1
+ import{a as $}from"./chunk-Y53B6NS4.js";import{c as O}from"./chunk-5Z4HDCO6.js";import{a as C}from"./chunk-GNCBXARM.js";import{k as A}from"./chunk-MGKAO4EK.js";import{A as R}from"./chunk-KASHOCF5.js";import{b as x}from"./chunk-AUY2YKCO.js";import{C as T,E as N,G as E,o as b,p as w,u as P,w as S}from"./chunk-W4TSQ6RJ.js";import{b as v}from"./chunk-CK2E7BTU.js";import{b as M}from"./chunk-QYADASLV.js";var J={};M(J,{AuditTrailGraph:()=>k,PolicyEnforcerGraph:()=>G,auditTrail:()=>z,complianceSnapshot:()=>F,policyEnforcer:()=>K,reactiveExplainPath:()=>q});function V(i,t){return O("audit",i,t)}var L=new Set(["data","error","complete","teardown"]),k=class extends A{entries;count;_log;_target;constructor(t,n){super(n.name??`${t.name}_audit`,n.graph),this._target=t,this._log=x([],{name:"entries",...n.maxSize!=null?{maxSize:n.maxSize}:{}}),this.entries=this._log.entries,this.add(this.entries,{name:"entries"}),this.count=E([this.entries],([c])=>c.length,{name:"count",describeKind:"derived",meta:V("count")}),this.add(this.count,{name:"count"}),this.addDisposer(R(this.count));let o=n.includeTypes!=null?new Set(n.includeTypes):L,u=n.filter,a=0,h=t.observe({timeline:!0,structured:!0}),m=h.onEvent(c=>{if(c.type==="derived")return;let e=c.type;if(!o.has(e))return;let d=c.path??"",r={seq:a++,timestamp_ns:c.timestamp_ns??b(),wall_clock_ns:w(),path:d,type:e},f=(d?D(t,d):void 0)?.lastMutation;f!=null&&(r.actor=f.actor),e==="data"&&(r.value=c.data),e==="error"&&(r.error=c.data);let l=d?U(t,d):void 0;l!=null&&(r.annotation=l),!(u!=null&&!u(r))&&this._log.append(r)});this.addDisposer(()=>{m(),h.dispose()}),this.addDisposer(()=>this._log.disposeAllViews())}all(){return this.entries.cache??[]}byNode(t){return this.all().filter(n=>n.path===t)}byActor(t){return this.all().filter(n=>n.actor?.id===t)}byActorType(t){return this.all().filter(n=>n.actor?.type===t)}byTimeRange(t,n){return this.all().filter(o=>!(o.timestamp_ns<t||n!=null&&o.timestamp_ns>=n))}get target(){return this._target}};function z(i,t={}){return new k(i,t)}var G=class extends A{policies;violations;violationCount;_target;_mode;_currentGuard;constructor(t,n,o){super(o.name??`${t.name}_policy`,o.graph),this._target=t,this._mode=o.mode??"audit";let u=I(n)?n:N(n,{name:"policies"});this.policies=u,this.add(this.policies,{name:"policies"}),this.violations=new $("violations",{retainedLimit:o.violationsLimit??1e3}),this.mount("violations",this.violations),this.violationCount=E([this.violations.events],([e])=>e.length,{name:"violationCount",describeKind:"derived",meta:V("policy_violation_count")}),this.add(this.violationCount,{name:"violationCount"}),this.addDisposer(R(this.violationCount));let h=u.cache??[];this._currentGuard=P(h);let m=u.subscribe(e=>{for(let d of e)d[0]===v&&(h=d[1]??[],this._currentGuard=P(h))});this.addDisposer(m);let c=o.paths!=null?[...o.paths]:j(t);if(this._mode==="enforce"){let e=new Map,d=r=>{if(e.has(r))return;let s=D(t,r);if(!(s instanceof T))return;let f=(l,p)=>{let y=this._currentGuard(l,p);return y||this._publishViolation(l,p,r,"blocked"),y};e.set(r,s._pushGuard(f))};for(let r of c)d(r);if(o.paths==null){let r=C(t,(s,f,l)=>{if(s.kind==="added")if(s.nodeKind==="node")d(`${l}${s.name}`);else{let p=f._mounts.get(s.name);if(!(p instanceof A))return;let y=`${l}${s.name}::`,_=j(p);for(let g of _)d(g===""?`${l}${s.name}`:`${y}${g}`)}else if(s.kind==="removed")if(s.nodeKind==="node"){let p=`${l}${s.name}`,y=e.get(p);y!=null&&(y(),e.delete(p))}else{let p=`${l}${s.name}`,y=`${p}::`;for(let[_,g]of e)(_===p||_.startsWith(y))&&(g(),e.delete(_))}});this.addDisposer(r)}else{let r=t.topology.subscribe(s=>{for(let f of s){if(f[0]!==v)continue;let l=f[1];if(l.kind!=="removed"||l.nodeKind!=="node")continue;let p=e.get(l.name);p!=null&&(p(),e.delete(l.name))}});this.addDisposer(r)}this.addDisposer(()=>{for(let r of e.values())r();e.clear()})}else{let e=t.observe({timeline:!0,structured:!0}),d=e.onEvent(r=>{if(r.type!=="data"&&r.type!=="error")return;let s=r.path??"";if(!s||o.paths!=null&&!o.paths.includes(s))return;let f=r.actor??D(t,s)?.lastMutation?.actor;if(f==null)return;let l="write";this._currentGuard(f,l)||this._publishViolation(f,l,s,"observed")});this.addDisposer(()=>{d(),e.dispose()})}}_publishViolation(t,n,o,u){this.violations.publish({timestamp_ns:b(),wall_clock_ns:w(),path:o,actor:t,action:n,mode:this._mode,result:u})}all(){return this.violations.retained()}get mode(){return this._mode}get target(){return this._target}};function K(i,t,n={}){return new G(i,t,n)}function q(i,t,n,o){return i.explain(t,n,{reactive:!0,...o})}function F(i,t={}){let n={format_version:1,timestamp_ns:b(),wall_clock_ns:w(),graph:i.snapshot()};if(t.actor!=null&&(n.actor=t.actor),t.audit!=null){let u=[...t.audit.all()];n.audit={count:u.length,entries:u}}if(t.policies!=null){let u=t.policies.policies.cache??[];n.policies={mode:t.policies.mode,rules:u,violations:[...t.policies.all()]}}let o=B(n);return{...n,fingerprint:o}}function I(i){return typeof i=="object"&&i!==null&&"subscribe"in i}function D(i,t){try{return i.node(t)}catch{return}}function U(i,t){try{return i.annotation(t)}catch{return}}function j(i){let t=i.describe({detail:"minimal"});return Object.keys(t.nodes)}function B(i){return S(JSON.stringify(H(i)))}function H(i){let t=new Set,n=o=>{if(o===void 0)return{__undefined:!0};if(o===null)return null;let u=typeof o;if(u==="bigint")return{__bigint:o.toString()};if(u!=="object")return o;let a=o;if(t.has(a))return{__circular:!0};t.add(a);try{if(Array.isArray(a))return a.map(n);if(a instanceof Date)return{__date:a.toISOString()};if(a instanceof RegExp)return{__regexp:{source:a.source,flags:a.flags}};if(a instanceof Map)return{__map:[...a.entries()].map(([c,e])=>[n(c),n(e)])};if(a instanceof Set)return{__set:[...a].map(n)};if(ArrayBuffer.isView(a)){let m=a,c=new Array(m.length);for(let e=0;e<m.length;e++)c[e]=m[e]??0;return{__typed_array:{ctor:a.constructor.name,data:c}}}let h={};for(let m of Object.keys(a).sort())h[m]=n(a[m]);return h}finally{t.delete(a)}};return n(i)}export{k as a,z as b,G as c,K as d,q as e,F as f,J as g};
@@ -1,18 +1,18 @@
1
- import{a as an}from"./chunk-LQ3Y5NJS.js";import{a as Qt,b as Jt}from"./chunk-UPHHLMHE.js";import{a as $e,b as we,c as _e,d as Qe,e as Je,f as Ye,g as Ge,h as Xe,i as Se,j as Ze,k as er,l as rr}from"./chunk-4GKB4OUJ.js";import{a as en,b as rn}from"./chunk-K2GNMCQT.js";import{a as wr,b as tt}from"./chunk-5QDBSZBV.js";import{a as tr}from"./chunk-CKCSDI7T.js";import{a as Ve}from"./chunk-ESMPEKEV.js";import{a as tn,b as nn,c as on,d as sn}from"./chunk-I6VIH3VA.js";import{A as Nt,B as Ot,C as Rt,D as Mt,E as Pt,G as Ct,H as Lt,I as At,J as Bt,K as It,L as Ft,M as Wt,N as zt,O as Ht,P as Ut,Q as Kt,R as jt,S as Dt,T as qt,U as Vt,a as xe,b as Ie,c as st,d as it,e as at,f as ct,g as ut,h as dt,i as Fe,j as lt,k as ft,l as pt,m as mt,n as gt,o as Tt,p as yt,q as kt,r as We,s as bt,t as ht,u as vt,v as ge,w as wt,x as St,y as xt,z as Et}from"./chunk-Z4HDAS2Q.js";import{a as ne,b as ve,c as Er,d as Nr,e as Or,f as Rr,g as Mr,h as Pr,i as Be}from"./chunk-4VVTGLXJ.js";import{a as Yt,b as Gt}from"./chunk-PIOGHC63.js";import{a as Xt,b as Zt}from"./chunk-VTPVOGHH.js";import{a as $t,b as _t}from"./chunk-OAWLCNJJ.js";import{a as nt,b as ot}from"./chunk-D7A7DBE4.js";import{A as et,B as rt,a as Sr,b as xr,c as Cr,d as Lr,e as Ar,f as oe,g as Br,h as Ir,i as Fr,j as Wr,k as zr,l as Hr,m as Ur,n as Kr,o as jr,p as Dr,q as qr,r as Vr,s as $r,t as _r,u as Qr,v as Jr,w as Yr,x as Gr,y as Xr,z as Zr}from"./chunk-2PMCKKRK.js";import{A as G,D as re,E as B,F as W,H as he,m as j,p as V}from"./chunk-ZB5EHBIO.js";import{b as x,c as Me,d as Pe,e as Ce,f as Le,g as Ae,h as q,i as C,j as E}from"./chunk-CK2E7BTU.js";import{b as vr}from"./chunk-QYADASLV.js";var lo={};vr(lo,{CircuitOpenError:()=>_e,NS_PER_MS:()=>ne,NS_PER_SEC:()=>ve,NativeIndexBackend:()=>Yt,NativeListBackend:()=>Xt,NativeLogBackend:()=>nt,NativeMapBackend:()=>$t,NativePubSubBackend:()=>Ee,RateLimiterOverflowError:()=>Ge,ResettableTimer:()=>Ve,TimeoutError:()=>Ze,audit:()=>Pt,awaitSettled:()=>Xr,buffer:()=>Ct,bufferCount:()=>Lt,bufferTime:()=>Bt,cached:()=>Jr,cascadingCache:()=>oo,catchError:()=>Vt,checkpointToRedis:()=>Gn,checkpointToS3:()=>Yn,circuitBreaker:()=>Qe,combine:()=>yt,combineLatest:()=>jt,concat:()=>ht,concatMap:()=>St,constant:()=>Er,createTransport:()=>ie,createWatermarkController:()=>tt,csvRows:()=>An,debounce:()=>Ot,debounceTime:()=>Dt,decorrelatedJitter:()=>Mr,delay:()=>Nt,deserializeError:()=>fe,dictStorage:()=>sn,distill:()=>Jt,distinctUntilChanged:()=>gt,elementAt:()=>pt,empty:()=>jr,escapeRegexChar:()=>Cr,exhaustMap:()=>wt,exponential:()=>Or,externalBundle:()=>ze,externalProducer:()=>ae,fallback:()=>er,fibonacci:()=>Rr,filter:()=>Ie,find:()=>ft,first:()=>Fe,firstValueFrom:()=>Yr,firstWhere:()=>Gr,flatMap:()=>Et,forEach:()=>Vr,fromAny:()=>Ur,fromAsyncIter:()=>Hr,fromCSV:()=>Ln,fromClickHouseWatch:()=>Fn,fromCron:()=>Ir,fromDrizzle:()=>to,fromEvent:()=>Fr,fromHTTP:()=>sr,fromHTTPPoll:()=>Tn,fromHTTPStream:()=>gn,fromIter:()=>Wr,fromKafka:()=>Rn,fromKysely:()=>no,fromMCP:()=>bn,fromNATS:()=>Hn,fromNDJSON:()=>In,fromOTel:()=>hn,fromPrisma:()=>ro,fromPrometheus:()=>Nn,fromPromise:()=>zr,fromPulsar:()=>Wn,fromRabbitMQ:()=>Kn,fromRaf:()=>Br,fromRedisStream:()=>Pn,fromSSE:()=>mn,fromSqlite:()=>Xn,fromSqliteCursor:()=>Zn,fromStatsD:()=>Sn,fromSyslog:()=>vn,fromTimer:()=>oe,fromWebSocket:()=>or,fromWebSocketReconnect:()=>kn,fromWebhook:()=>un,globToRegExp:()=>Lr,interval:()=>Wt,keepalive:()=>et,last:()=>lt,linear:()=>Nr,lru:()=>lr,map:()=>xe,matchesAnyPattern:()=>Ar,matchesCron:()=>xr,memoryStorage:()=>on,merge:()=>We,mergeMap:()=>xt,nameToSignal:()=>de,ndjsonRows:()=>Bn,never:()=>Dr,of:()=>Kr,pairwise:()=>Tt,parseCron:()=>Sr,parsePrometheusText:()=>cr,parseStatsD:()=>En,parseSyslog:()=>wn,pausable:()=>Ht,pubsub:()=>so,race:()=>vt,rateLimiter:()=>Xe,reactiveCounter:()=>rt,reactiveIndex:()=>Gt,reactiveList:()=>Zt,reactiveLog:()=>ot,reactiveMap:()=>_t,reactiveSink:()=>U,reduce:()=>it,repeat:()=>zt,replay:()=>Qr,rescue:()=>Ut,resolveBackoffPreset:()=>Be,retry:()=>$e,retrySource:()=>we,sample:()=>Mt,scan:()=>st,serializeError:()=>le,share:()=>_r,shareReplay:()=>Zr,signalToName:()=>se,singleFromAny:()=>en,singleNodeFromAny:()=>rn,skip:()=>ct,sortJsonValue:()=>tn,stableJsonString:()=>nn,stratify:()=>an,switchMap:()=>ge,take:()=>at,takeUntil:()=>dt,takeWhile:()=>ut,tap:()=>mt,throttle:()=>Rt,throttleTime:()=>qt,throwError:()=>qr,timeout:()=>rr,toArray:()=>$r,toCSV:()=>Dn,toClickHouse:()=>qn,toFile:()=>dr,toHTTP:()=>dn,toKafka:()=>Mn,toLoki:()=>Qn,toMongo:()=>_n,toNATS:()=>Un,toObservable:()=>wr,toPostgres:()=>$n,toPulsar:()=>zn,toRabbitMQ:()=>jn,toReadableStream:()=>pn,toRedisStream:()=>Cn,toS3:()=>Vn,toSSE:()=>ln,toSSEBytes:()=>fn,toSqlite:()=>eo,toTempo:()=>Jn,toWebSocket:()=>yn,tokenBucket:()=>Ye,valve:()=>Kt,verifiable:()=>Qt,window:()=>Ft,windowCount:()=>At,windowTime:()=>It,withBreaker:()=>Je,withLatestFrom:()=>kt,withMaxAttempts:()=>Pr,withStatus:()=>Se,workerBridge:()=>pr,workerSelf:()=>mr,zip:()=>bt});function nr(e){return{describeKind:"producer",...e}}function ae(e,t){return W(n=>{let a=!0,c={emit(o){a&&n.emit(o)},error(o){a&&(a=!1,n.down([[E,o]]))},complete(){a&&(a=!1,n.down([[C]]))}},r;try{let o=e(c);r=typeof o=="function"?o:void 0}catch(o){return c.error(o),()=>{a=!1}}return()=>{a=!1;try{r?.()}catch{}}},nr(t))}function ze(e,t,n){let a=!0,c,r=0,o=0,s={},d=[],i=()=>{let l=c;c=void 0;try{l?.()}catch{}};for(let l of t){let m=n?.name?`${n.name}::${l}`:l,h=n?.channelOpts?.[l],b=W(g=>(r++,()=>{o++,r>0&&o>=r&&o>=t.length&&i()}),nr({...h,name:m}));s[l]=b,d.push(b)}let p={};for(let l of t)p[l]=m=>{a&&s[l].down([[x,m]])};p.error=l=>{a&&(a=!1,j(()=>{for(let m of d)m.down([[E,l]])}),i())},p.complete=()=>{a&&(a=!1,j(()=>{for(let l of d)l.down([[C]])}),i())};let f=e(p);return c=typeof f=="function"?f:void 0,Object.assign(s,{dispose:()=>{a&&(a=!1,j(()=>{for(let l of d)try{l.down([[C]])}catch{}}),i())}})}var He=class{ring;arr;constructor(t){t===Number.POSITIVE_INFINITY||t<=0?(this.arr=[],this.ring=null):(this.ring=new tr(t),this.arr=null)}get length(){return this.ring!=null?this.ring.size:this.arr.length}push(t){this.ring!=null?this.ring.push(t):this.arr.push(t)}shift(){return this.ring!=null?this.ring.shift():this.arr.shift()}drain(){if(this.ring!=null){let n=this.ring.toArray();return this.ring.clear(),n}let t=this.arr;return this.arr=[],t}};function Te(e){return e instanceof Error?e:new Error(String(e))}function cn(e){return e===void 0?null:typeof e=="string"?Be(e):e}function U(e,t){let{name:n,onTransportError:a,retry:c,backpressure:r,batchSize:o=Number.POSITIVE_INFINITY,flushIntervalMs:s=0,serialize:d,stopOn:i,onUpstreamMessage:p,onDispose:f,send:u,sendBatch:l,ctx:m}=t;if(!u&&!l)throw new Error("reactiveSink: `send` or `sendBatch` must be provided");let h=m,b=Math.max(1,c?.maxAttempts??1),g=cn(c?.backoff??(b>1?"exponential":void 0)),T=c?.shouldRetry??(()=>!0),y=l!==void 0||o<Number.POSITIVE_INFINITY||s>0,k=S=>n?`${n}::${S}`:void 0,v=B(void 0,{equals:()=>!1,name:k("sent")}),w=B(null,{name:k("failed")}),N=B(0,{name:k("inFlight")}),O=B(null,{name:k("errors")}),H=y?B(0,{name:k("buffered")}):void 0,z=r?B(!1,{name:k("paused")}):void 0,J=0,Y=S=>{J+=S,N.down([[x,J]])},R=S=>{try{a?.(S)}catch{}try{O.down([[x,S]])}catch{}},D=new Set,X=S=>{D.add(S);let M=()=>D.delete(S);S.then(M,M)},F=(S,M,L)=>{let I=g?g(M-1,L,null):0,K=I==null?0:typeof I=="number"&&I>0?I:0,_=Math.max(1,Math.ceil(K/1e6));return new Promise(A=>{setTimeout(()=>A(S()),_)})},$=S=>S!=null&&typeof S=="object"&&typeof S.then=="function",Z=S=>{let M;try{M=d?d(S):S}catch(A){let P=Te(A);return R({stage:"serialize",error:P,value:S}),w.down([[x,{value:S,error:P,attempts:0}]]),Promise.resolve()}let L=0,I=A=>{Y(-1);let P=Te(A);if(R({stage:"send",error:P,value:S,attempt:L}),!(L<b&&T(P,L))){w.down([[x,{value:S,error:P,attempts:L}]]);return}return F(_,L,P)},K=()=>{Y(-1),v.down([[x,S]])};function _(){L+=1,Y(1);let A;try{A=u(M,h)}catch(P){return I(P)??Promise.resolve()}return $(A)?A.then(K,P=>I(P)):(K(),Promise.resolve())}return _()},pe=r?.maxBuffer??Number.POSITIVE_INFINITY,te=new He(pe),ee,ye=!1,Ne=()=>{H?.down([[x,te.length]])},ke=S=>{z&&z.down([[x,S]])},Ke=r?.strategy??"drop-oldest",gr=(S,M)=>{let L={value:S,payload:M};if(te.length<pe)return te.push(L),Ne(),!0;if(Ke==="drop-oldest"){let K=te.shift();return te.push(L),Ne(),ke(!0),w.down([[x,{value:K.value,error:new Error("backpressure: buffer overflow \u2014 dropped oldest"),attempts:0}]]),!0}if(Ke==="drop-newest")return ke(!0),w.down([[x,{value:S,error:new Error("backpressure: buffer overflow \u2014 dropped newest"),attempts:0}]]),!1;let I=new Error("backpressure: buffer overflow");return R({stage:"send",error:I,value:S}),w.down([[x,{value:S,error:I,attempts:0}]]),ke(!0),!1},Tr=S=>{let M=0,L=S.map(A=>A.payload),I=A=>{Y(-1);let P=Te(A);if(R({stage:"send",error:P,value:S.map(Re=>Re.value),attempt:M}),!(M<b&&T(P,M))){for(let{value:Re}of S)w.down([[x,{value:Re,error:P,attempts:M}]]);return}return F(_,M,P)},K=()=>{Y(-1);for(let{value:A}of S)v.down([[x,A]])};function _(){M+=1,Y(1);let A;try{A=l(L,h)}catch(P){return I(P)??Promise.resolve()}return $(A)?A.then(K,P=>I(P)):(K(),Promise.resolve())}return _()},yr=async S=>{for(let M of S)await kr(M.value,M.payload)},kr=(S,M)=>{let L=0,I=A=>{Y(-1);let P=Te(A);if(R({stage:"send",error:P,value:S,attempt:L}),!(L<b&&T(P,L))){w.down([[x,{value:S,error:P,attempts:L}]]);return}return F(_,L,P)},K=()=>{Y(-1),v.down([[x,S]])};function _(){L+=1,Y(1);let A;try{A=u(M,h)}catch(P){return I(P)??Promise.resolve()}return $(A)?A.then(K,P=>I(P)):(K(),Promise.resolve())}return _()},me=()=>{if(ye||te.length===0)return Promise.resolve();let S=te.drain();if(Ne(),ke(!1),l!==void 0){let L=Tr(S);return X(L),L}let M=yr(S);return X(M),M},br=()=>{ee!==void 0||ye||s<=0||(ee=setTimeout(()=>{ee=void 0,me()},s))},hr=e.subscribe(S=>{for(let M of S){let L=M[0];if(L!==x)try{p?.(M)}catch{}if(L===x){let I=M[1];if(y){let K;if(d)try{K=d(I)}catch(A){let P=Te(A);R({stage:"serialize",error:P,value:I}),w.down([[x,{value:I,error:P,attempts:0}]]);continue}else K=I;if(!gr(I,K))continue;te.length>=o?me():br()}else{let K=Z(I);X(K)}}else G.messageTier(L)>=3&&y&&(ee!==void 0&&(clearTimeout(ee),ee=void 0),me())}}),je;if(i){let S=!1;je=i.subscribe(M=>{if(!S){S=!0;return}M.length>0&&!Oe&&De()})}let Oe=!1,De=()=>{if(Oe)return;Oe=!0,ee!==void 0&&(clearTimeout(ee),ee=void 0),y&&me(),ye=!0,je?.(),hr();let S=M=>{try{M.down([[q]])}catch{}};S(O),S(w),S(v),S(N),H&&S(H),z&&S(z);try{f?.()}catch{}},be={dispose:De,sent:v,failed:w,inFlight:N,errors:O};return y&&(be.buffered=H,be.flush=async()=>{ye||(await me(),await Promise.all(D))}),z&&(be.paused=z),be}function Q(e){return{describeKind:"producer",...e}}function or(e,t){let{parse:n,closeOnTeardown:a=!1,...c}=t??{};return W(r=>{let o=!0,s,d=()=>{let g=s;s=void 0,g?.()},i=g=>{o&&(o=!1,r.down([g]),d())},p=(g,T=g)=>{if(o)try{let y=g!==null&&typeof g=="object"&&"data"in g?g.data:g,k=n?n(y,T):y;r.emit(k)}catch(y){i([E,y])}},f=g=>{i([E,g])},u=()=>{i([C])};if(typeof e=="function"){try{if(s=e(p,f,u),typeof s!="function")throw new Error("fromWebSocket register contract violation: register must return cleanup callable")}catch(g){i([E,g])}return()=>{o=!1,d()}}let l=e,m=g=>p(g,g),h=g=>f(g),b=()=>u();return l.addEventListener("message",m),l.addEventListener("error",h),l.addEventListener("close",b),s=()=>{l.removeEventListener("message",m),l.removeEventListener("error",h),l.removeEventListener("close",b),a&&l.close()},()=>{o=!1,d()}},Q(c))}function un(e,t){return ae(e,t)}function sr(e,t){let{method:n="GET",headers:a,body:c,transform:r=y=>y.json(),timeoutNs:o=30*1e9,signal:s,completeAfterFetch:d=!1,refetchOnSubscribe:i=!1,...p}=t??{},f=B(0,{name:`${p.name??"http"}/fetchCount`}),u=B(0,{name:`${p.name??"http"}/lastUpdated`}),l=B(!1,{name:`${p.name??"http"}/fetched`}),m=0,h=c!==void 0?typeof c=="string"?c:JSON.stringify(c):void 0,b=y=>{let k=new AbortController,v=!0;if(s?.aborted)return v=!1,y.down([[E,s.reason??new Error("Aborted")]]),()=>{};s?.addEventListener("abort",()=>k.abort(s.reason),{once:!0});let w=setTimeout(()=>k.abort(new Error("Request timeout")),Math.ceil(o/1e6));return fetch(e,{method:n,headers:a,body:h,signal:k.signal}).then(async N=>{if(clearTimeout(w),!v)return;if(!N.ok)throw new Error(`HTTP ${N.status}: ${N.statusText}`);let O=await r(N);v&&(j(()=>{m+=1,f.down([[x,m]]),u.down([[x,V()]]),l.down([[x,!0]]),y.emit(O)}),d&&y.down([[C]]))}).catch(N=>{clearTimeout(w),v&&(N&&N.name==="AbortError"||y.down([[E,N]]))}),()=>{v=!1,k.abort()}},g=W(y=>b({emit:k=>y.emit(k),down:k=>y.down(k)}),{...Q(p),resubscribable:i});return{...Se(g),fetchCount:f,lastUpdated:u,fetched:l}}function dn(e,t,n){let{method:a="POST",headers:c={"Content-Type":"application/json"},serialize:r=m=>JSON.stringify(m),timeoutNs:o,batchFormat:s="json-array",batchSize:d,flushIntervalMs:i,retry:p,onTransportError:f}=n??{},u=async m=>{let h=o!==void 0?new AbortController:void 0,b;h&&o!==void 0&&(b=setTimeout(()=>h.abort(new Error("Request timeout")),Math.ceil(o/1e6)));try{let g=await fetch(t,{method:a,headers:c,body:m,signal:h?.signal}),T=async()=>{try{await g.arrayBuffer?.()}catch{}};if(!g.ok)throw await T(),new Error(`HTTP ${g.status}: ${g.statusText}`);await T()}finally{b!==void 0&&clearTimeout(b)}};return d!==void 0||i!==void 0?U(e,{onTransportError:f,retry:p,batchSize:d,flushIntervalMs:i,sendBatch:async m=>{let h;s==="ndjson"?h=m.map(b=>{let g=r(b);return typeof g=="string"?g:new TextDecoder().decode(g)}).join(`
2
- `):h=JSON.stringify(m),await u(h)}}):U(e,{onTransportError:f,retry:p,serialize:r,send:async m=>{await u(m)}})}function ir(e){return Symbol.keyFor(e)??e.description??"message"}function ce(e,t){return typeof e=="string"?e:t(e)}function ar(e,t){let n=`event: ${e}
1
+ import{a as an}from"./chunk-GJR3P6JG.js";import{a as Qt,b as Jt}from"./chunk-LVGBLZM2.js";import{a as $e,b as we,c as _e,d as Qe,e as Je,f as Ye,g as Ge,h as Xe,i as Se,j as Ze,k as er,l as rr}from"./chunk-OL33ZI6R.js";import{a as en,b as rn}from"./chunk-ISCENNXS.js";import{a as wr,b as tt}from"./chunk-5QDBSZBV.js";import{a as tr}from"./chunk-MGKAO4EK.js";import{a as Ve}from"./chunk-ESMPEKEV.js";import{a as tn,b as nn,c as on,d as sn}from"./chunk-I6VIH3VA.js";import{A as Nt,B as Ot,C as Rt,D as Mt,E as Pt,G as Ct,H as Lt,I as At,J as Bt,K as It,L as Ft,M as Wt,N as zt,O as Ht,P as Ut,Q as Kt,R as jt,S as Dt,T as qt,U as Vt,a as xe,b as Ie,c as st,d as it,e as at,f as ct,g as ut,h as dt,i as Fe,j as lt,k as pt,l as ft,m as mt,n as gt,o as Tt,p as yt,q as kt,r as We,s as bt,t as ht,u as vt,v as ge,w as wt,x as St,y as xt,z as Et}from"./chunk-5JDE5JHE.js";import{a as ne,b as ve,c as Er,d as Nr,e as Or,f as Rr,g as Mr,h as Pr,i as Be}from"./chunk-4VVTGLXJ.js";import{A as et,B as rt,a as Sr,b as xr,c as Cr,d as Lr,e as Ar,f as oe,g as Br,h as Ir,i as Fr,j as Wr,k as zr,l as Hr,m as Ur,n as Kr,o as jr,p as Dr,q as qr,r as Vr,s as $r,t as _r,u as Qr,v as Jr,w as Yr,x as Gr,y as Xr,z as Zr}from"./chunk-KASHOCF5.js";import{a as Yt,b as Gt}from"./chunk-567NWZ3T.js";import{a as Xt,b as Zt}from"./chunk-SLMYTGTU.js";import{a as $t,b as _t}from"./chunk-2GQREQ6C.js";import{a as nt,b as ot}from"./chunk-AUY2YKCO.js";import{A as G,D as re,E as B,F as W,H as he,m as j,p as V}from"./chunk-W4TSQ6RJ.js";import{b as x,c as Me,d as Pe,e as Ce,f as Le,g as Ae,h as q,i as C,j as E}from"./chunk-CK2E7BTU.js";import{b as vr}from"./chunk-QYADASLV.js";var lo={};vr(lo,{CircuitOpenError:()=>_e,NS_PER_MS:()=>ne,NS_PER_SEC:()=>ve,NativeIndexBackend:()=>Yt,NativeListBackend:()=>Xt,NativeLogBackend:()=>nt,NativeMapBackend:()=>$t,NativePubSubBackend:()=>Ee,RateLimiterOverflowError:()=>Ge,ResettableTimer:()=>Ve,TimeoutError:()=>Ze,audit:()=>Pt,awaitSettled:()=>Xr,buffer:()=>Ct,bufferCount:()=>Lt,bufferTime:()=>Bt,cached:()=>Jr,cascadingCache:()=>oo,catchError:()=>Vt,checkpointToRedis:()=>Gn,checkpointToS3:()=>Yn,circuitBreaker:()=>Qe,combine:()=>yt,combineLatest:()=>jt,concat:()=>ht,concatMap:()=>St,constant:()=>Er,createTransport:()=>ie,createWatermarkController:()=>tt,csvRows:()=>An,debounce:()=>Ot,debounceTime:()=>Dt,decorrelatedJitter:()=>Mr,delay:()=>Nt,deserializeError:()=>pe,dictStorage:()=>sn,distill:()=>Jt,distinctUntilChanged:()=>gt,elementAt:()=>ft,empty:()=>jr,escapeRegexChar:()=>Cr,exhaustMap:()=>wt,exponential:()=>Or,externalBundle:()=>ze,externalProducer:()=>ae,fallback:()=>er,fibonacci:()=>Rr,filter:()=>Ie,find:()=>pt,first:()=>Fe,firstValueFrom:()=>Yr,firstWhere:()=>Gr,flatMap:()=>Et,forEach:()=>Vr,fromAny:()=>Ur,fromAsyncIter:()=>Hr,fromCSV:()=>Ln,fromClickHouseWatch:()=>Fn,fromCron:()=>Ir,fromDrizzle:()=>to,fromEvent:()=>Fr,fromHTTP:()=>sr,fromHTTPPoll:()=>Tn,fromHTTPStream:()=>gn,fromIter:()=>Wr,fromKafka:()=>Rn,fromKysely:()=>no,fromMCP:()=>bn,fromNATS:()=>Hn,fromNDJSON:()=>In,fromOTel:()=>hn,fromPrisma:()=>ro,fromPrometheus:()=>Nn,fromPromise:()=>zr,fromPulsar:()=>Wn,fromRabbitMQ:()=>Kn,fromRaf:()=>Br,fromRedisStream:()=>Pn,fromSSE:()=>mn,fromSqlite:()=>Xn,fromSqliteCursor:()=>Zn,fromStatsD:()=>Sn,fromSyslog:()=>vn,fromTimer:()=>oe,fromWebSocket:()=>or,fromWebSocketReconnect:()=>kn,fromWebhook:()=>un,globToRegExp:()=>Lr,interval:()=>Wt,keepalive:()=>et,last:()=>lt,linear:()=>Nr,lru:()=>lr,map:()=>xe,matchesAnyPattern:()=>Ar,matchesCron:()=>xr,memoryStorage:()=>on,merge:()=>We,mergeMap:()=>xt,nameToSignal:()=>de,ndjsonRows:()=>Bn,never:()=>Dr,of:()=>Kr,pairwise:()=>Tt,parseCron:()=>Sr,parsePrometheusText:()=>cr,parseStatsD:()=>En,parseSyslog:()=>wn,pausable:()=>Ht,pubsub:()=>so,race:()=>vt,rateLimiter:()=>Xe,reactiveCounter:()=>rt,reactiveIndex:()=>Gt,reactiveList:()=>Zt,reactiveLog:()=>ot,reactiveMap:()=>_t,reactiveSink:()=>U,reduce:()=>it,repeat:()=>zt,replay:()=>Qr,rescue:()=>Ut,resolveBackoffPreset:()=>Be,retry:()=>$e,retrySource:()=>we,sample:()=>Mt,scan:()=>st,serializeError:()=>le,share:()=>_r,shareReplay:()=>Zr,signalToName:()=>se,singleFromAny:()=>en,singleNodeFromAny:()=>rn,skip:()=>ct,sortJsonValue:()=>tn,stableJsonString:()=>nn,stratify:()=>an,switchMap:()=>ge,take:()=>at,takeUntil:()=>dt,takeWhile:()=>ut,tap:()=>mt,throttle:()=>Rt,throttleTime:()=>qt,throwError:()=>qr,timeout:()=>rr,toArray:()=>$r,toCSV:()=>Dn,toClickHouse:()=>qn,toFile:()=>dr,toHTTP:()=>dn,toKafka:()=>Mn,toLoki:()=>Qn,toMongo:()=>_n,toNATS:()=>Un,toObservable:()=>wr,toPostgres:()=>$n,toPulsar:()=>zn,toRabbitMQ:()=>jn,toReadableStream:()=>fn,toRedisStream:()=>Cn,toS3:()=>Vn,toSSE:()=>ln,toSSEBytes:()=>pn,toSqlite:()=>eo,toTempo:()=>Jn,toWebSocket:()=>yn,tokenBucket:()=>Ye,valve:()=>Kt,verifiable:()=>Qt,window:()=>Ft,windowCount:()=>At,windowTime:()=>It,withBreaker:()=>Je,withLatestFrom:()=>kt,withMaxAttempts:()=>Pr,withStatus:()=>Se,workerBridge:()=>fr,workerSelf:()=>mr,zip:()=>bt});function nr(e){return{describeKind:"producer",...e}}function ae(e,t){return W(n=>{let a=!0,c={emit(o){a&&n.emit(o)},error(o){a&&(a=!1,n.down([[E,o]]))},complete(){a&&(a=!1,n.down([[C]]))}},r;try{let o=e(c);r=typeof o=="function"?o:void 0}catch(o){return c.error(o),()=>{a=!1}}return()=>{a=!1;try{r?.()}catch{}}},nr(t))}function ze(e,t,n){let a=!0,c,r=0,o=0,s={},d=[],i=()=>{let l=c;c=void 0;try{l?.()}catch{}};for(let l of t){let m=n?.name?`${n.name}::${l}`:l,h=n?.channelOpts?.[l],b=W(g=>(r++,()=>{o++,r>0&&o>=r&&o>=t.length&&i()}),nr({...h,name:m}));s[l]=b,d.push(b)}let f={};for(let l of t)f[l]=m=>{a&&s[l].down([[x,m]])};f.error=l=>{a&&(a=!1,j(()=>{for(let m of d)m.down([[E,l]])}),i())},f.complete=()=>{a&&(a=!1,j(()=>{for(let l of d)l.down([[C]])}),i())};let p=e(f);return c=typeof p=="function"?p:void 0,Object.assign(s,{dispose:()=>{a&&(a=!1,j(()=>{for(let l of d)try{l.down([[C]])}catch{}}),i())}})}var He=class{ring;arr;constructor(t){t===Number.POSITIVE_INFINITY||t<=0?(this.arr=[],this.ring=null):(this.ring=new tr(t),this.arr=null)}get length(){return this.ring!=null?this.ring.size:this.arr.length}push(t){this.ring!=null?this.ring.push(t):this.arr.push(t)}shift(){return this.ring!=null?this.ring.shift():this.arr.shift()}drain(){if(this.ring!=null){let n=this.ring.toArray();return this.ring.clear(),n}let t=this.arr;return this.arr=[],t}};function Te(e){return e instanceof Error?e:new Error(String(e))}function cn(e){return e===void 0?null:typeof e=="string"?Be(e):e}function U(e,t){let{name:n,onTransportError:a,retry:c,backpressure:r,batchSize:o=Number.POSITIVE_INFINITY,flushIntervalMs:s=0,serialize:d,stopOn:i,onUpstreamMessage:f,onDispose:p,send:u,sendBatch:l,ctx:m}=t;if(!u&&!l)throw new Error("reactiveSink: `send` or `sendBatch` must be provided");let h=m,b=Math.max(1,c?.maxAttempts??1),g=cn(c?.backoff??(b>1?"exponential":void 0)),T=c?.shouldRetry??(()=>!0),y=l!==void 0||o<Number.POSITIVE_INFINITY||s>0,k=S=>n?`${n}::${S}`:void 0,v=B(void 0,{equals:()=>!1,name:k("sent")}),w=B(null,{name:k("failed")}),N=B(0,{name:k("inFlight")}),O=B(null,{name:k("errors")}),H=y?B(0,{name:k("buffered")}):void 0,z=r?B(!1,{name:k("paused")}):void 0,J=0,Y=S=>{J+=S,N.down([[x,J]])},R=S=>{try{a?.(S)}catch{}try{O.down([[x,S]])}catch{}},D=new Set,X=S=>{D.add(S);let M=()=>D.delete(S);S.then(M,M)},F=(S,M,L)=>{let I=g?g(M-1,L,null):0,K=I==null?0:typeof I=="number"&&I>0?I:0,_=Math.max(1,Math.ceil(K/1e6));return new Promise(A=>{setTimeout(()=>A(S()),_)})},$=S=>S!=null&&typeof S=="object"&&typeof S.then=="function",Z=S=>{let M;try{M=d?d(S):S}catch(A){let P=Te(A);return R({stage:"serialize",error:P,value:S}),w.down([[x,{value:S,error:P,attempts:0}]]),Promise.resolve()}let L=0,I=A=>{Y(-1);let P=Te(A);if(R({stage:"send",error:P,value:S,attempt:L}),!(L<b&&T(P,L))){w.down([[x,{value:S,error:P,attempts:L}]]);return}return F(_,L,P)},K=()=>{Y(-1),v.down([[x,S]])};function _(){L+=1,Y(1);let A;try{A=u(M,h)}catch(P){return I(P)??Promise.resolve()}return $(A)?A.then(K,P=>I(P)):(K(),Promise.resolve())}return _()},fe=r?.maxBuffer??Number.POSITIVE_INFINITY,te=new He(fe),ee,ye=!1,Ne=()=>{H?.down([[x,te.length]])},ke=S=>{z&&z.down([[x,S]])},Ke=r?.strategy??"drop-oldest",gr=(S,M)=>{let L={value:S,payload:M};if(te.length<fe)return te.push(L),Ne(),!0;if(Ke==="drop-oldest"){let K=te.shift();return te.push(L),Ne(),ke(!0),w.down([[x,{value:K.value,error:new Error("backpressure: buffer overflow \u2014 dropped oldest"),attempts:0}]]),!0}if(Ke==="drop-newest")return ke(!0),w.down([[x,{value:S,error:new Error("backpressure: buffer overflow \u2014 dropped newest"),attempts:0}]]),!1;let I=new Error("backpressure: buffer overflow");return R({stage:"send",error:I,value:S}),w.down([[x,{value:S,error:I,attempts:0}]]),ke(!0),!1},Tr=S=>{let M=0,L=S.map(A=>A.payload),I=A=>{Y(-1);let P=Te(A);if(R({stage:"send",error:P,value:S.map(Re=>Re.value),attempt:M}),!(M<b&&T(P,M))){for(let{value:Re}of S)w.down([[x,{value:Re,error:P,attempts:M}]]);return}return F(_,M,P)},K=()=>{Y(-1);for(let{value:A}of S)v.down([[x,A]])};function _(){M+=1,Y(1);let A;try{A=l(L,h)}catch(P){return I(P)??Promise.resolve()}return $(A)?A.then(K,P=>I(P)):(K(),Promise.resolve())}return _()},yr=async S=>{for(let M of S)await kr(M.value,M.payload)},kr=(S,M)=>{let L=0,I=A=>{Y(-1);let P=Te(A);if(R({stage:"send",error:P,value:S,attempt:L}),!(L<b&&T(P,L))){w.down([[x,{value:S,error:P,attempts:L}]]);return}return F(_,L,P)},K=()=>{Y(-1),v.down([[x,S]])};function _(){L+=1,Y(1);let A;try{A=u(M,h)}catch(P){return I(P)??Promise.resolve()}return $(A)?A.then(K,P=>I(P)):(K(),Promise.resolve())}return _()},me=()=>{if(ye||te.length===0)return Promise.resolve();let S=te.drain();if(Ne(),ke(!1),l!==void 0){let L=Tr(S);return X(L),L}let M=yr(S);return X(M),M},br=()=>{ee!==void 0||ye||s<=0||(ee=setTimeout(()=>{ee=void 0,me()},s))},hr=e.subscribe(S=>{for(let M of S){let L=M[0];if(L!==x)try{f?.(M)}catch{}if(L===x){let I=M[1];if(y){let K;if(d)try{K=d(I)}catch(A){let P=Te(A);R({stage:"serialize",error:P,value:I}),w.down([[x,{value:I,error:P,attempts:0}]]);continue}else K=I;if(!gr(I,K))continue;te.length>=o?me():br()}else{let K=Z(I);X(K)}}else G.messageTier(L)>=3&&y&&(ee!==void 0&&(clearTimeout(ee),ee=void 0),me())}}),je;if(i){let S=!1;je=i.subscribe(M=>{if(!S){S=!0;return}M.length>0&&!Oe&&De()})}let Oe=!1,De=()=>{if(Oe)return;Oe=!0,ee!==void 0&&(clearTimeout(ee),ee=void 0),y&&me(),ye=!0,je?.(),hr();let S=M=>{try{M.down([[q]])}catch{}};S(O),S(w),S(v),S(N),H&&S(H),z&&S(z);try{p?.()}catch{}},be={dispose:De,sent:v,failed:w,inFlight:N,errors:O};return y&&(be.buffered=H,be.flush=async()=>{ye||(await me(),await Promise.all(D))}),z&&(be.paused=z),be}function Q(e){return{describeKind:"producer",...e}}function or(e,t){let{parse:n,closeOnTeardown:a=!1,...c}=t??{};return W(r=>{let o=!0,s,d=()=>{let g=s;s=void 0,g?.()},i=g=>{o&&(o=!1,r.down([g]),d())},f=(g,T=g)=>{if(o)try{let y=g!==null&&typeof g=="object"&&"data"in g?g.data:g,k=n?n(y,T):y;r.emit(k)}catch(y){i([E,y])}},p=g=>{i([E,g])},u=()=>{i([C])};if(typeof e=="function"){try{if(s=e(f,p,u),typeof s!="function")throw new Error("fromWebSocket register contract violation: register must return cleanup callable")}catch(g){i([E,g])}return()=>{o=!1,d()}}let l=e,m=g=>f(g,g),h=g=>p(g),b=()=>u();return l.addEventListener("message",m),l.addEventListener("error",h),l.addEventListener("close",b),s=()=>{l.removeEventListener("message",m),l.removeEventListener("error",h),l.removeEventListener("close",b),a&&l.close()},()=>{o=!1,d()}},Q(c))}function un(e,t){return ae(e,t)}function sr(e,t){let{method:n="GET",headers:a,body:c,transform:r=y=>y.json(),timeoutNs:o=30*1e9,signal:s,completeAfterFetch:d=!1,refetchOnSubscribe:i=!1,...f}=t??{},p=B(0,{name:`${f.name??"http"}/fetchCount`}),u=B(0,{name:`${f.name??"http"}/lastUpdated`}),l=B(!1,{name:`${f.name??"http"}/fetched`}),m=0,h=c!==void 0?typeof c=="string"?c:JSON.stringify(c):void 0,b=y=>{let k=new AbortController,v=!0;if(s?.aborted)return v=!1,y.down([[E,s.reason??new Error("Aborted")]]),()=>{};s?.addEventListener("abort",()=>k.abort(s.reason),{once:!0});let w=setTimeout(()=>k.abort(new Error("Request timeout")),Math.ceil(o/1e6));return fetch(e,{method:n,headers:a,body:h,signal:k.signal}).then(async N=>{if(clearTimeout(w),!v)return;if(!N.ok)throw new Error(`HTTP ${N.status}: ${N.statusText}`);let O=await r(N);v&&(j(()=>{m+=1,p.down([[x,m]]),u.down([[x,V()]]),l.down([[x,!0]]),y.emit(O)}),d&&y.down([[C]]))}).catch(N=>{clearTimeout(w),v&&(N&&N.name==="AbortError"||y.down([[E,N]]))}),()=>{v=!1,k.abort()}},g=W(y=>b({emit:k=>y.emit(k),down:k=>y.down(k)}),{...Q(f),resubscribable:i});return{...Se(g),fetchCount:p,lastUpdated:u,fetched:l}}function dn(e,t,n){let{method:a="POST",headers:c={"Content-Type":"application/json"},serialize:r=m=>JSON.stringify(m),timeoutNs:o,batchFormat:s="json-array",batchSize:d,flushIntervalMs:i,retry:f,onTransportError:p}=n??{},u=async m=>{let h=o!==void 0?new AbortController:void 0,b;h&&o!==void 0&&(b=setTimeout(()=>h.abort(new Error("Request timeout")),Math.ceil(o/1e6)));try{let g=await fetch(t,{method:a,headers:c,body:m,signal:h?.signal}),T=async()=>{try{await g.arrayBuffer?.()}catch{}};if(!g.ok)throw await T(),new Error(`HTTP ${g.status}: ${g.statusText}`);await T()}finally{b!==void 0&&clearTimeout(b)}};return d!==void 0||i!==void 0?U(e,{onTransportError:p,retry:f,batchSize:d,flushIntervalMs:i,sendBatch:async m=>{let h;s==="ndjson"?h=m.map(b=>{let g=r(b);return typeof g=="string"?g:new TextDecoder().decode(g)}).join(`
2
+ `):h=JSON.stringify(m),await u(h)}}):U(e,{onTransportError:p,retry:f,serialize:r,send:async m=>{await u(m)}})}function ir(e){return Symbol.keyFor(e)??e.description??"message"}function ce(e,t){return typeof e=="string"?e:t(e)}function ar(e,t){let n=`event: ${e}
3
3
  `;if(t!==void 0){let a=t.split(/\r?\n/);for(let c of a)n+=`data: ${c}
4
4
  `}return`${n}
5
- `}function ln(e,t){let{serialize:n=l=>{if(l instanceof Error)return l.message;try{return JSON.stringify(l)}catch{return String(l)}},dataEvent:a="data",errorEvent:c="error",completeEvent:r="complete",includeResolved:o=!1,includeDirty:s=!1,keepAliveMs:d,signal:i,eventNameResolver:p=ir}=t??{},f=new TextEncoder,u;return new ReadableStream({start(l){let m=!1,h,b=()=>{},g=()=>{m||(m=!0,h!==void 0&&clearInterval(h),i?.removeEventListener("abort",y),b(),l.close())};u=g;let T=(k,v)=>{m||l.enqueue(f.encode(ar(k,v)))},y=()=>{m||g()};b=e.subscribe(k=>{for(let v of k){let w=v[0];if(!(G.isLocalOnly(w)&&!(w===Me&&s))){if(w===x){T(a,ce(v[1],n));continue}if(w===E){T(c,ce(v[1],n)),g();return}if(w===C){T(r),g();return}!o&&w===Pe||T(p(w),v.length>1?ce(v[1],n):void 0)}}}),d!==void 0&&d>0&&(h=setInterval(()=>{m||l.enqueue(f.encode(`: keepalive
5
+ `}function ln(e,t){let{serialize:n=l=>{if(l instanceof Error)return l.message;try{return JSON.stringify(l)}catch{return String(l)}},dataEvent:a="data",errorEvent:c="error",completeEvent:r="complete",includeResolved:o=!1,includeDirty:s=!1,keepAliveMs:d,signal:i,eventNameResolver:f=ir}=t??{},p=new TextEncoder,u;return new ReadableStream({start(l){let m=!1,h,b=()=>{},g=()=>{m||(m=!0,h!==void 0&&clearInterval(h),i?.removeEventListener("abort",y),b(),l.close())};u=g;let T=(k,v)=>{m||l.enqueue(p.encode(ar(k,v)))},y=()=>{m||g()};b=e.subscribe(k=>{for(let v of k){let w=v[0];if(!(G.isLocalOnly(w)&&!(w===Me&&s))){if(w===x){T(a,ce(v[1],n));continue}if(w===E){T(c,ce(v[1],n)),g();return}if(w===C){T(r),g();return}!o&&w===Pe||T(f(w),v.length>1?ce(v[1],n):void 0)}}}),d!==void 0&&d>0&&(h=setInterval(()=>{m||l.enqueue(p.encode(`: keepalive
6
6
 
7
- `))},d)),i?.aborted?y():i?.addEventListener("abort",y,{once:!0})},cancel(){u?.()}})}function fn(e,t){let{serialize:n=u=>{if(u instanceof Error)return u.message;try{return JSON.stringify(u)}catch{return String(u)}},dataEvent:a="data",errorEvent:c="error",completeEvent:r="complete",includeResolved:o=!1,includeDirty:s=!1,keepAliveMs:d,signal:i,eventNameResolver:p=ir}=t??{},f=new TextEncoder;return W(u=>{let l=!0,m,h=(T,y)=>{l&&u.emit(f.encode(ar(T,y)))},b=()=>{l&&(l=!1,u.down([[C]]))},g=e.subscribe(T=>{if(l)for(let y of T){let k=y[0];if(!(G.isLocalOnly(k)&&!(k===Me&&s))){if(k===x){h(a,ce(y[1],n));continue}if(k===E){h(c,ce(y[1],n)),l=!1,u.down([[C]]);return}if(k===C){h(r),l=!1,u.down([[C]]);return}!o&&k===Pe||h(p(k),y.length>1?ce(y[1],n):void 0)}}});return d!==void 0&&d>0&&(m=setInterval(()=>{l&&u.emit(f.encode(`: keepalive
7
+ `))},d)),i?.aborted?y():i?.addEventListener("abort",y,{once:!0})},cancel(){u?.()}})}function pn(e,t){let{serialize:n=u=>{if(u instanceof Error)return u.message;try{return JSON.stringify(u)}catch{return String(u)}},dataEvent:a="data",errorEvent:c="error",completeEvent:r="complete",includeResolved:o=!1,includeDirty:s=!1,keepAliveMs:d,signal:i,eventNameResolver:f=ir}=t??{},p=new TextEncoder;return W(u=>{let l=!0,m,h=(T,y)=>{l&&u.emit(p.encode(ar(T,y)))},b=()=>{l&&(l=!1,u.down([[C]]))},g=e.subscribe(T=>{if(l)for(let y of T){let k=y[0];if(!(G.isLocalOnly(k)&&!(k===Me&&s))){if(k===x){h(a,ce(y[1],n));continue}if(k===E){h(c,ce(y[1],n)),l=!1,u.down([[C]]);return}if(k===C){h(r),l=!1,u.down([[C]]);return}!o&&k===Pe||h(f(k),y.length>1?ce(y[1],n):void 0)}}});return d!==void 0&&d>0&&(m=setInterval(()=>{l&&u.emit(p.encode(`: keepalive
8
8
 
9
- `))},d)),i?.aborted?b():i?.addEventListener("abort",b,{once:!0}),()=>{l=!1,m!==void 0&&clearInterval(m),i?.removeEventListener("abort",b),g()}})}function pn(e){let t,n=!1;return new ReadableStream({start(a){t=e.subscribe(c=>{for(let r of c){let o=r[0];if(n)return;if(o===x)try{a.enqueue(r[1])}catch{n=!0,t?.()}else if(o===E){n=!0;try{a.error(r[1])}catch{}return}else if(o===C){n=!0;try{a.close()}catch{}return}}})},cancel(){n=!0,t?.()}})}function mn(e,t){let{parse:n=c=>c,...a}=t??{};return W(c=>{let r=!0,o=new TextDecoder,s="",d="message",i=[],p,f,u=()=>{if(i.length===0&&d==="message"&&p===void 0){i=[];return}let T=i.join(`
10
- `);c.emit({event:d,data:n(T),id:p,retry:f}),d="message",i=[],p=void 0,f=void 0},l=T=>{if(T===""){u();return}if(T.startsWith(":"))return;let y=T.indexOf(":"),k=y<0?T:T.slice(0,y),v=y<0?"":T.slice(y+1);switch(v.startsWith(" ")&&(v=v.slice(1)),k){case"event":d=v;break;case"data":i.push(v);break;case"id":v.includes("\0")||(p=v);break;case"retry":{let w=Number(v);Number.isFinite(w)&&(f=w);break}}},m=(T,y)=>{if(!r)return;s+=o.decode(T,{stream:!y});let k=s.split(/\r?\n/);s=k.pop()??"";for(let v of k)l(v)},h,b;return(async()=>{try{let T=e,y=e instanceof ReadableStream?e:T&&typeof T=="object"&&T.body instanceof ReadableStream?T.body:null;if(y){for(h=y.getReader();r;){let{value:k,done:v}=await h.read();if(v)break;m(k,!1)}m(new Uint8Array,!0)}else{for(b=e[Symbol.asyncIterator]();r;){let v=await b.next();if(v.done)break;m(v.value,!1)}m(new Uint8Array,!0)}if(s.trim()){for(let k of s.split(/\r?\n/))l(k);u()}r&&c.down([[C]])}catch(T){r&&c.down([[E,T]])}})(),()=>{r=!1,h&&h.cancel().catch(()=>{}),b&&typeof b.return=="function"&&Promise.resolve(b.return()).catch(()=>{})}},Q(a))}function gn(e,t){let{method:n="GET",headers:a,body:c,signal:r,...o}=t??{};return W(s=>{let d=!0,i=new AbortController;if(r?.aborted)return s.down([[E,r.reason??new Error("Aborted")]]),()=>{};r?.addEventListener("abort",()=>i.abort(r.reason),{once:!0});let p=c!==void 0?typeof c=="string"?c:JSON.stringify(c):void 0;return(async()=>{try{let u=await fetch(e,{method:n,headers:a,body:p,signal:i.signal});if(!d)return;if(!u.ok)throw new Error(`HTTP ${u.status}: ${u.statusText}`);if(!u.body)throw new Error("HTTP response has no body");let l=u.body.getReader();for(;d;){let{value:m,done:h}=await l.read();if(h)break;m&&s.emit(m)}d&&s.down([[C]])}catch(u){if(!d||u&&u.name==="AbortError")return;s.down([[E,u]])}})(),()=>{d=!1,i.abort()}},Q(o))}function Tn(e,t){let{intervalMs:n=5e3,...a}=t??{};return ge(oe(n,{period:n}),()=>sr(e,{...a,completeAfterFetch:!0}).node)}function yn(e,t,n){let{serialize:a=g=>{if(typeof g=="string"||g instanceof Blob||g instanceof ArrayBuffer||ArrayBuffer.isView(g))return g;try{return JSON.stringify(g)}catch{return String(g)}},closeOnComplete:c=!0,closeOnError:r=!0,closeCode:o,closeReason:s,onTransportError:d,retry:i,backpressure:p,stopOn:f}=n??{},u=!1,l=g=>{if(!u){u=!0;try{t.close(o,s)}catch(T){let y=T instanceof Error?T:new Error(String(T));try{d?.({stage:"close",error:y,value:void 0,message:g})}catch{}}}},m=null,b=U(e,{onTransportError:d,serialize:g=>{let T=a(g);if(T===void 0)throw new Error("serialize returned undefined");return T},retry:i,backpressure:p,stopOn:f,onDispose:()=>{if(m){try{t.removeEventListener("close",m)}catch{}m=null}},send:g=>{t.send(g)},onUpstreamMessage:g=>{(g[0]===C&&c||g[0]===E&&r)&&l(g)}});return m=()=>{u=!0,b.dispose()},t.addEventListener("close",m),b}function kn(e,t){let{parse:n,maxRetries:a,backoff:c="exponential",closeOnTeardown:r=!0,...o}=t??{};return we(()=>or(e(),{parse:n,closeOnTeardown:r,...o}),{count:a,backoff:c})}function bn(e,t){let{method:n="notifications/message",onDisconnect:a,...c}=t??{};return ae(({emit:r,error:o})=>(e.setNotificationHandler(n,s=>r(s)),a?.(s=>o(s??new Error("MCP client disconnected"))),()=>e.setNotificationHandler(n,()=>{})),c)}function hn(e,t){return ze(({traces:a,metrics:c,logs:r,error:o})=>e({onTraces:s=>{j(()=>{for(let d of s)a(d)})},onMetrics:s=>{j(()=>{for(let d of s)c(d)})},onLogs:s=>{j(()=>{for(let d of s)r(d)})},onError:o})??void 0,["traces","metrics","logs"],t?.name?{name:t.name}:void 0)}function vn(e,t){return ae(e,t)}function wn(e){let t=e.match(/^<(\d{1,3})>\d?\s*(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s*(.*)/s);if(!t){let a=V();return{facility:1,severity:6,timestamp:new Date(Math.floor(a/1e6)).toISOString(),hostname:"-",appName:"-",procId:"-",msgId:"-",message:e.trim(),timestampNs:a}}let n=Number(t[1]);return{facility:n>>3,severity:n&7,timestamp:t[2],hostname:t[3],appName:t[4],procId:t[5],msgId:t[6],message:(t[7]??"").trim(),timestampNs:V()}}function Sn(e,t){return ae(e,t)}var xn={c:"counter",g:"gauge",ms:"timer",h:"histogram",s:"set",d:"distribution"};function En(e){let t=e.split("|"),[n,a]=(t[0]??"").split(":");if(!n||a===void 0)throw new Error(`Invalid StatsD line: ${e}`);let c=t[1]?.trim()??"c",r=xn[c]??"counter",o=r==="set"?0:Number(a),s,d={};for(let i=2;i<t.length;i++){let p=t[i].trim();if(p.startsWith("@"))s=Number(p.slice(1));else if(p.startsWith("#"))for(let f of p.slice(1).split(",")){let[u,l]=f.split(":");u&&(d[u]=l??"")}}return{name:n.trim(),value:o,type:r,sampleRate:s,tags:d,timestampNs:V()}}function Nn(e,t){let{intervalNs:n=15*1e9,headers:a,timeoutNs:c=10*1e9,signal:r,maxConsecutiveErrors:o=1}=t??{},s=Math.ceil(n/1e6),d=0;return ge(oe(0,{period:s,signal:r}),()=>W(i=>{let p=!0,f=new AbortController,u=setTimeout(()=>f.abort(new Error("Scrape timeout")),Math.ceil(c/1e6));return(async()=>{try{let m=await fetch(e,{headers:{Accept:"text/plain",...a},signal:f.signal});if(clearTimeout(u),!p)return;if(!m.ok)throw new Error(`Prometheus scrape ${m.status}: ${m.statusText}`);let h=await m.text();if(!p)return;let b=cr(h);for(let g of b)i.emit(g);d=0,i.down([[C]])}catch(m){if(clearTimeout(u),!p||m instanceof Error&&m.name==="AbortError")return;d+=1,d>=o&&i.down([[E,m]])}})(),()=>{p=!1,clearTimeout(u),f.abort()}}))}function cr(e){let t=[],n=new Map,a=new Map;for(let c of e.split(`
11
- `)){let r=c.trim();if(!r)continue;if(r.startsWith("# TYPE ")){let u=r.slice(7),l=u.indexOf(" ");l>0&&n.set(u.slice(0,l),u.slice(l+1).trim());continue}if(r.startsWith("# HELP ")){let u=r.slice(7),l=u.indexOf(" ");l>0&&a.set(u.slice(0,l),u.slice(l+1).trim());continue}if(r.startsWith("#"))continue;let o,s={},d,i,p=r.indexOf("{");if(p>=0){o=r.slice(0,p);let u=r.indexOf("}",p);if(u<0)continue;let l=r.slice(p+1,u);s=On(l);let m=r.slice(u+1).trim().split(/\s+/);d=m[0]??"",i=m[1]}else{let u=r.split(/\s+/);o=u[0]??"",d=u[1]??"",i=u[2]}if(!o||!d)continue;let f=o.replace(/(_total|_count|_sum|_bucket|_created|_info)$/,"");t.push({name:o,labels:s,value:Number(d),timestampMs:i?Number(i):void 0,type:n.get(f)??n.get(o),help:a.get(f)??a.get(o),timestampNs:V()})}return t}function On(e){let t={},n=/(\w+)="((?:[^"\\]|\\.)*)"/g,a=n.exec(e);for(;a!==null;)t[a[1]]=a[2].replace(/\\(.)/g,"$1"),a=n.exec(e);return t}function Rn(e,t,n){let{fromBeginning:a=!1,deserialize:c=o=>{if(o===null)return null;try{return JSON.parse(o.toString())}catch{return o.toString()}},...r}=n??{};return W(o=>{let s=!0;return(async()=>{try{await e.subscribe({topic:t,fromBeginning:a}),await e.run({eachMessage:async({topic:i,partition:p,message:f})=>{if(!s)return;let u={};if(f.headers)for(let[l,m]of Object.entries(f.headers))m!==void 0&&(u[l]=typeof m=="string"?m:m.toString());o.emit({topic:i,partition:p,key:f.key?.toString()??null,value:c(f.value),headers:u,offset:f.offset,timestamp:f.timestamp,timestampNs:V()})}})}catch(i){s&&o.down([[E,i]])}})(),()=>{s=!1}},Q(r))}function Mn(e,t,n,a){let{serialize:c=s=>JSON.stringify(s),keyExtractor:r,onTransportError:o}=a??{};return U(e,{onTransportError:o,send:async s=>{let d=r?.(s)??null,i=c(s);await t.send({topic:n,messages:[{key:d,value:Buffer.from(i)}]})}})}function Pn(e,t,n){let{blockMs:a=5e3,startId:c="$",parse:r=s=>{for(let i=0;i<s.length;i+=2)if(s[i]==="data")try{return JSON.parse(s[i+1])}catch{return s[i+1]}let d={};for(let i=0;i<s.length;i+=2)d[s[i]]=s[i+1];return d},...o}=n??{};return W(s=>{let d=!0,i=c;return(async()=>{for(;d;)try{let f=await e.xread("BLOCK",a,"STREAMS",t,i);if(!d)return;if(f)for(let[u,l]of f)for(let[m,h]of l)i=m,s.emit({id:m,key:t,data:r(h),timestampNs:V()})}catch(f){if(!d)return;s.down([[E,f]]);return}})(),()=>{d=!1}},Q(o))}function Cn(e,t,n,a){let{serialize:c=s=>["data",JSON.stringify(s)],maxLen:r,onTransportError:o}=a??{};return U(e,{onTransportError:o,send:async s=>{let d=c(s);await(r!==void 0?t.xadd(n,"MAXLEN","~",String(r),"*",...d):t.xadd(n,"*",...d))}})}function Ln(e,t){let{delimiter:n=",",hasHeader:a=!0,columns:c,parseLine:r,...o}=t??{},s=r??(d=>ur(d,n));return W(d=>{let i=!1;return(async()=>{try{let f=c,u="";for await(let l of e){if(i)return;u+=l;let m=u.split(/\r?\n/);u=m.pop()??"";for(let h of m){if(i)return;if(!h.trim())continue;let b=s(h);if(!f&&a){f=b;continue}f||(f=b.map((T,y)=>`col${y}`));let g={};for(let T=0;T<f.length;T++)g[f[T]]=b[T]??"";d.emit(g)}}if(!i&&u.trim()){let l=s(u);if(f){let m={};for(let h=0;h<f.length;h++)m[f[h]]=l[h]??"";d.emit(m)}}i||d.down([[C]])}catch(f){i||d.down([[E,f]])}})(),()=>{i=!0}},Q(o))}function An(e,t){let{delimiter:n=",",hasHeader:a=!0,columns:c,parseLine:r,...o}=t??{},s=r??(d=>ur(d,n));return re([e],(d,i,p)=>{let f=d[0];if(f==null||f.length===0)return;let u=p.store;typeof u.buffer!="string"&&(u.buffer=""),u.headers===void 0&&c&&(u.headers=c.slice());for(let l of f){u.buffer=u.buffer+l;let m=u.buffer.split(/\r?\n/);u.buffer=m.pop()??"";for(let h of m){if(!h.trim())continue;let b=s(h);if(!u.headers&&a){u.headers=b;continue}u.headers||(u.headers=b.map((T,y)=>`col${y}`));let g={};for(let T=0;T<u.headers.length;T++)g[u.headers[T]]=b[T]??"";i.emit(g)}}},{describeKind:"derived",...o})}function Bn(e,t){return re([e],(n,a,c)=>{let r=n[0];if(r==null||r.length===0)return;let o=c.store;typeof o.buffer!="string"&&(o.buffer="");for(let s of r){o.buffer=o.buffer+s;let d=o.buffer.split(/\r?\n/);o.buffer=d.pop()??"";for(let i of d)if(i.trim())try{a.emit(JSON.parse(i))}catch(p){a.down([[E,p]]);return}}},{describeKind:"derived",...t??{}})}function ur(e,t){let n=[],a="",c=!1;for(let r=0;r<e.length;r++){let o=e[r];c?o==='"'?e[r+1]==='"'?(a+='"',r++):c=!1:a+=o:o==='"'?c=!0:o===t?(n.push(a),a=""):a+=o}return n.push(a),n}function In(e,t){return W(n=>{let a=!1;return(async()=>{try{let r="";for await(let o of e){if(a)return;r+=o;let s=r.split(/\r?\n/);r=s.pop()??"";for(let d of s){if(a)return;let i=d.trim();i&&n.emit(JSON.parse(i))}}!a&&r.trim()&&n.emit(JSON.parse(r.trim())),a||n.down([[C]])}catch(r){a||n.down([[E,r]])}})(),()=>{a=!0}},Q(t))}function Fn(e,t,n){let{intervalNs:a=5*1e9,format:c="JSONEachRow",signal:r,maxConsecutiveErrors:o=1}=n??{},s=Math.ceil(a/1e6),d=0;return ge(oe(0,{period:s,signal:r}),()=>W(i=>{let p=!0;return(async()=>{try{let u=await e.query({query:t,format:c});if(!p)return;let l=await u.json();if(!p)return;for(let m of l)i.emit(m);d=0,i.down([[C]])}catch(u){if(!p)return;d+=1,d>=o&&i.down([[E,u]])}})(),()=>{p=!1}}))}function Wn(e,t){let{autoAck:n=!0,deserialize:a=s=>{try{return JSON.parse(s.toString())}catch{return s.toString()}},onAckError:c,...r}=t??{},o=s=>{if(c)try{c(s instanceof Error?s:new Error(String(s)))}catch{}};return W(s=>{let d=!0;return(async()=>{for(;d;)try{let p=await e.receive();if(!d)return;let f={topic:p.getTopicName(),messageId:p.getMessageId().toString(),key:p.getPartitionKey(),value:a(p.getData()),properties:p.getProperties(),publishTime:p.getPublishTimestamp(),eventTime:p.getEventTimestamp(),timestampNs:V()};if(n)s.emit(f),e.acknowledge(p).catch(o);else{let u=!1,l={value:f,ack(){u||(u=!0,e.acknowledge(p).catch(o))},nack(m){if(u)return;u=!0;let h=e;try{let b=h.negativeAcknowledge?.(p);b&&typeof b.then=="function"&&b.catch(o)}catch(b){o(b)}}};s.emit(l)}}catch(p){d&&s.down([[E,p]]);return}})(),()=>{d=!1}},Q(r))}function zn(e,t,n){let{serialize:a=s=>Buffer.from(JSON.stringify(s)),keyExtractor:c,propertiesExtractor:r,onTransportError:o}=n??{};return U(e,{onTransportError:o,send:async s=>{await t.send({data:a(s),partitionKey:c?.(s),properties:r?.(s)})}})}function Hn(e,t,n){let a=new TextDecoder,{queue:c,deserialize:r=s=>{let d=a.decode(s);try{return JSON.parse(d)}catch{return d}},...o}=n??{};return W(s=>{let d=!0,i=e.subscribe(t,c?{queue:c}:void 0);return(async()=>{try{for await(let f of i){if(!d)return;let u={};if(f.headers)for(let l of f.headers.keys())u[l]=f.headers.get(l);s.emit({subject:f.subject,data:r(f.data),headers:u,reply:f.reply,sid:f.sid,timestampNs:V()})}d&&s.down([[C]])}catch(f){d&&s.down([[E,f]])}})(),()=>{d=!1}},Q(o))}function Un(e,t,n,a){let c=new TextEncoder,{serialize:r=s=>c.encode(JSON.stringify(s)),onTransportError:o}=a??{};return U(e,{onTransportError:o,send:s=>{t.publish(n,r(s))}})}function Kn(e,t,n){let{autoAck:a=!0,deserialize:c=d=>{try{return JSON.parse(d.toString())}catch{return d.toString()}},onAckError:r,...o}=n??{},s=d=>{if(r)try{r(d instanceof Error?d:new Error(String(d)))}catch{}};return W(d=>{let i=!0,p;return(async()=>{try{p=(await e.consume(t,l=>{if(!i)return;if(l===null){i&&d.down([[E,new Error("Consumer cancelled by broker")]]);return}let m={queue:t,routingKey:l.fields.routingKey,exchange:l.fields.exchange,content:c(l.content),properties:l.properties,deliveryTag:l.fields.deliveryTag,redelivered:l.fields.redelivered,timestampNs:V()};if(a){d.emit(m);try{e.ack(l)}catch(h){s(h)}}else{let h=!1,b=e,g={value:m,ack(){if(!h){h=!0;try{e.ack(l)}catch(T){s(T)}}},nack(T){if(h)return;h=!0;let y=T?.requeue;if(!b.nack){s(new Error("RabbitMQ channel does not expose `nack`; cannot negative-ack"));return}try{b.nack(l,!1,y)}catch(k){s(k)}}};d.emit(g)}},{noAck:!1})).consumerTag}catch(u){i&&d.down([[E,u]])}})(),()=>{i=!1,p!==void 0&&e.cancel(p)}},Q(o))}function jn(e,t,n,a){let{serialize:c=s=>Buffer.from(JSON.stringify(s)),routingKeyExtractor:r=()=>"",onTransportError:o}=a??{};return U(e,{onTransportError:o,send:s=>{let d=r(s),i=c(s);t.publish(n,d,i)}})}function dr(e,t,n){let{serialize:a=f=>`${JSON.stringify(f)}
12
- `,flushIntervalMs:c=0,batchSize:r=Number.POSITIVE_INFINITY,onTransportError:o,mode:s}=n??{},i=c>0||r<Number.POSITIVE_INFINITY?U(e,{onTransportError:o,batchSize:r,flushIntervalMs:c,serialize:a,sendBatch:f=>{t.write(f.join(""))}}):U(e,{onTransportError:o,serialize:a,send:f=>{t.write(f)}}),p=i.dispose;return i.dispose=()=>{p();try{t.end()}catch{}},i}function Ue(e,t){return e.includes(t)||e.includes('"')||e.includes(`
13
- `)?`"${e.replace(/"/g,'""')}"`:e}function Dn(e,t,n){let{columns:a,delimiter:c=",",writeHeader:r=!0,cellExtractor:o=(l,m)=>String(l[m]??""),flushIntervalMs:s=0,batchSize:d=Number.POSITIVE_INFINITY,onTransportError:i,...p}=n,f=!1;return dr(e,t,{serialize:l=>{if(!f&&r){f=!0;let m=a.map(b=>Ue(b,c)).join(c),h=a.map(b=>Ue(o(l,b),c)).join(c);return`${m}
9
+ `))},d)),i?.aborted?b():i?.addEventListener("abort",b,{once:!0}),()=>{l=!1,m!==void 0&&clearInterval(m),i?.removeEventListener("abort",b),g()}})}function fn(e){let t,n=!1;return new ReadableStream({start(a){t=e.subscribe(c=>{for(let r of c){let o=r[0];if(n)return;if(o===x)try{a.enqueue(r[1])}catch{n=!0,t?.()}else if(o===E){n=!0;try{a.error(r[1])}catch{}return}else if(o===C){n=!0;try{a.close()}catch{}return}}})},cancel(){n=!0,t?.()}})}function mn(e,t){let{parse:n=c=>c,...a}=t??{};return W(c=>{let r=!0,o=new TextDecoder,s="",d="message",i=[],f,p,u=()=>{if(i.length===0&&d==="message"&&f===void 0){i=[];return}let T=i.join(`
10
+ `);c.emit({event:d,data:n(T),id:f,retry:p}),d="message",i=[],f=void 0,p=void 0},l=T=>{if(T===""){u();return}if(T.startsWith(":"))return;let y=T.indexOf(":"),k=y<0?T:T.slice(0,y),v=y<0?"":T.slice(y+1);switch(v.startsWith(" ")&&(v=v.slice(1)),k){case"event":d=v;break;case"data":i.push(v);break;case"id":v.includes("\0")||(f=v);break;case"retry":{let w=Number(v);Number.isFinite(w)&&(p=w);break}}},m=(T,y)=>{if(!r)return;s+=o.decode(T,{stream:!y});let k=s.split(/\r?\n/);s=k.pop()??"";for(let v of k)l(v)},h,b;return(async()=>{try{let T=e,y=e instanceof ReadableStream?e:T&&typeof T=="object"&&T.body instanceof ReadableStream?T.body:null;if(y){for(h=y.getReader();r;){let{value:k,done:v}=await h.read();if(v)break;m(k,!1)}m(new Uint8Array,!0)}else{for(b=e[Symbol.asyncIterator]();r;){let v=await b.next();if(v.done)break;m(v.value,!1)}m(new Uint8Array,!0)}if(s.trim()){for(let k of s.split(/\r?\n/))l(k);u()}r&&c.down([[C]])}catch(T){r&&c.down([[E,T]])}})(),()=>{r=!1,h&&h.cancel().catch(()=>{}),b&&typeof b.return=="function"&&Promise.resolve(b.return()).catch(()=>{})}},Q(a))}function gn(e,t){let{method:n="GET",headers:a,body:c,signal:r,...o}=t??{};return W(s=>{let d=!0,i=new AbortController;if(r?.aborted)return s.down([[E,r.reason??new Error("Aborted")]]),()=>{};r?.addEventListener("abort",()=>i.abort(r.reason),{once:!0});let f=c!==void 0?typeof c=="string"?c:JSON.stringify(c):void 0;return(async()=>{try{let u=await fetch(e,{method:n,headers:a,body:f,signal:i.signal});if(!d)return;if(!u.ok)throw new Error(`HTTP ${u.status}: ${u.statusText}`);if(!u.body)throw new Error("HTTP response has no body");let l=u.body.getReader();for(;d;){let{value:m,done:h}=await l.read();if(h)break;m&&s.emit(m)}d&&s.down([[C]])}catch(u){if(!d||u&&u.name==="AbortError")return;s.down([[E,u]])}})(),()=>{d=!1,i.abort()}},Q(o))}function Tn(e,t){let{intervalMs:n=5e3,...a}=t??{};return ge(oe(n,{period:n}),()=>sr(e,{...a,completeAfterFetch:!0}).node)}function yn(e,t,n){let{serialize:a=g=>{if(typeof g=="string"||g instanceof Blob||g instanceof ArrayBuffer||ArrayBuffer.isView(g))return g;try{return JSON.stringify(g)}catch{return String(g)}},closeOnComplete:c=!0,closeOnError:r=!0,closeCode:o,closeReason:s,onTransportError:d,retry:i,backpressure:f,stopOn:p}=n??{},u=!1,l=g=>{if(!u){u=!0;try{t.close(o,s)}catch(T){let y=T instanceof Error?T:new Error(String(T));try{d?.({stage:"close",error:y,value:void 0,message:g})}catch{}}}},m=null,b=U(e,{onTransportError:d,serialize:g=>{let T=a(g);if(T===void 0)throw new Error("serialize returned undefined");return T},retry:i,backpressure:f,stopOn:p,onDispose:()=>{if(m){try{t.removeEventListener("close",m)}catch{}m=null}},send:g=>{t.send(g)},onUpstreamMessage:g=>{(g[0]===C&&c||g[0]===E&&r)&&l(g)}});return m=()=>{u=!0,b.dispose()},t.addEventListener("close",m),b}function kn(e,t){let{parse:n,maxRetries:a,backoff:c="exponential",closeOnTeardown:r=!0,...o}=t??{};return we(()=>or(e(),{parse:n,closeOnTeardown:r,...o}),{count:a,backoff:c})}function bn(e,t){let{method:n="notifications/message",onDisconnect:a,...c}=t??{};return ae(({emit:r,error:o})=>(e.setNotificationHandler(n,s=>r(s)),a?.(s=>o(s??new Error("MCP client disconnected"))),()=>e.setNotificationHandler(n,()=>{})),c)}function hn(e,t){return ze(({traces:a,metrics:c,logs:r,error:o})=>e({onTraces:s=>{j(()=>{for(let d of s)a(d)})},onMetrics:s=>{j(()=>{for(let d of s)c(d)})},onLogs:s=>{j(()=>{for(let d of s)r(d)})},onError:o})??void 0,["traces","metrics","logs"],t?.name?{name:t.name}:void 0)}function vn(e,t){return ae(e,t)}function wn(e){let t=e.match(/^<(\d{1,3})>\d?\s*(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s*(.*)/s);if(!t){let a=V();return{facility:1,severity:6,timestamp:new Date(Math.floor(a/1e6)).toISOString(),hostname:"-",appName:"-",procId:"-",msgId:"-",message:e.trim(),timestampNs:a}}let n=Number(t[1]);return{facility:n>>3,severity:n&7,timestamp:t[2],hostname:t[3],appName:t[4],procId:t[5],msgId:t[6],message:(t[7]??"").trim(),timestampNs:V()}}function Sn(e,t){return ae(e,t)}var xn={c:"counter",g:"gauge",ms:"timer",h:"histogram",s:"set",d:"distribution"};function En(e){let t=e.split("|"),[n,a]=(t[0]??"").split(":");if(!n||a===void 0)throw new Error(`Invalid StatsD line: ${e}`);let c=t[1]?.trim()??"c",r=xn[c]??"counter",o=r==="set"?0:Number(a),s,d={};for(let i=2;i<t.length;i++){let f=t[i].trim();if(f.startsWith("@"))s=Number(f.slice(1));else if(f.startsWith("#"))for(let p of f.slice(1).split(",")){let[u,l]=p.split(":");u&&(d[u]=l??"")}}return{name:n.trim(),value:o,type:r,sampleRate:s,tags:d,timestampNs:V()}}function Nn(e,t){let{intervalNs:n=15*1e9,headers:a,timeoutNs:c=10*1e9,signal:r,maxConsecutiveErrors:o=1}=t??{},s=Math.ceil(n/1e6),d=0;return ge(oe(0,{period:s,signal:r}),()=>W(i=>{let f=!0,p=new AbortController,u=setTimeout(()=>p.abort(new Error("Scrape timeout")),Math.ceil(c/1e6));return(async()=>{try{let m=await fetch(e,{headers:{Accept:"text/plain",...a},signal:p.signal});if(clearTimeout(u),!f)return;if(!m.ok)throw new Error(`Prometheus scrape ${m.status}: ${m.statusText}`);let h=await m.text();if(!f)return;let b=cr(h);for(let g of b)i.emit(g);d=0,i.down([[C]])}catch(m){if(clearTimeout(u),!f||m instanceof Error&&m.name==="AbortError")return;d+=1,d>=o&&i.down([[E,m]])}})(),()=>{f=!1,clearTimeout(u),p.abort()}}))}function cr(e){let t=[],n=new Map,a=new Map;for(let c of e.split(`
11
+ `)){let r=c.trim();if(!r)continue;if(r.startsWith("# TYPE ")){let u=r.slice(7),l=u.indexOf(" ");l>0&&n.set(u.slice(0,l),u.slice(l+1).trim());continue}if(r.startsWith("# HELP ")){let u=r.slice(7),l=u.indexOf(" ");l>0&&a.set(u.slice(0,l),u.slice(l+1).trim());continue}if(r.startsWith("#"))continue;let o,s={},d,i,f=r.indexOf("{");if(f>=0){o=r.slice(0,f);let u=r.indexOf("}",f);if(u<0)continue;let l=r.slice(f+1,u);s=On(l);let m=r.slice(u+1).trim().split(/\s+/);d=m[0]??"",i=m[1]}else{let u=r.split(/\s+/);o=u[0]??"",d=u[1]??"",i=u[2]}if(!o||!d)continue;let p=o.replace(/(_total|_count|_sum|_bucket|_created|_info)$/,"");t.push({name:o,labels:s,value:Number(d),timestampMs:i?Number(i):void 0,type:n.get(p)??n.get(o),help:a.get(p)??a.get(o),timestampNs:V()})}return t}function On(e){let t={},n=/(\w+)="((?:[^"\\]|\\.)*)"/g,a=n.exec(e);for(;a!==null;)t[a[1]]=a[2].replace(/\\(.)/g,"$1"),a=n.exec(e);return t}function Rn(e,t,n){let{fromBeginning:a=!1,deserialize:c=o=>{if(o===null)return null;try{return JSON.parse(o.toString())}catch{return o.toString()}},...r}=n??{};return W(o=>{let s=!0;return(async()=>{try{await e.subscribe({topic:t,fromBeginning:a}),await e.run({eachMessage:async({topic:i,partition:f,message:p})=>{if(!s)return;let u={};if(p.headers)for(let[l,m]of Object.entries(p.headers))m!==void 0&&(u[l]=typeof m=="string"?m:m.toString());o.emit({topic:i,partition:f,key:p.key?.toString()??null,value:c(p.value),headers:u,offset:p.offset,timestamp:p.timestamp,timestampNs:V()})}})}catch(i){s&&o.down([[E,i]])}})(),()=>{s=!1}},Q(r))}function Mn(e,t,n,a){let{serialize:c=s=>JSON.stringify(s),keyExtractor:r,onTransportError:o}=a??{};return U(e,{onTransportError:o,send:async s=>{let d=r?.(s)??null,i=c(s);await t.send({topic:n,messages:[{key:d,value:Buffer.from(i)}]})}})}function Pn(e,t,n){let{blockMs:a=5e3,startId:c="$",parse:r=s=>{for(let i=0;i<s.length;i+=2)if(s[i]==="data")try{return JSON.parse(s[i+1])}catch{return s[i+1]}let d={};for(let i=0;i<s.length;i+=2)d[s[i]]=s[i+1];return d},...o}=n??{};return W(s=>{let d=!0,i=c;return(async()=>{for(;d;)try{let p=await e.xread("BLOCK",a,"STREAMS",t,i);if(!d)return;if(p)for(let[u,l]of p)for(let[m,h]of l)i=m,s.emit({id:m,key:t,data:r(h),timestampNs:V()})}catch(p){if(!d)return;s.down([[E,p]]);return}})(),()=>{d=!1}},Q(o))}function Cn(e,t,n,a){let{serialize:c=s=>["data",JSON.stringify(s)],maxLen:r,onTransportError:o}=a??{};return U(e,{onTransportError:o,send:async s=>{let d=c(s);await(r!==void 0?t.xadd(n,"MAXLEN","~",String(r),"*",...d):t.xadd(n,"*",...d))}})}function Ln(e,t){let{delimiter:n=",",hasHeader:a=!0,columns:c,parseLine:r,...o}=t??{},s=r??(d=>ur(d,n));return W(d=>{let i=!1;return(async()=>{try{let p=c,u="";for await(let l of e){if(i)return;u+=l;let m=u.split(/\r?\n/);u=m.pop()??"";for(let h of m){if(i)return;if(!h.trim())continue;let b=s(h);if(!p&&a){p=b;continue}p||(p=b.map((T,y)=>`col${y}`));let g={};for(let T=0;T<p.length;T++)g[p[T]]=b[T]??"";d.emit(g)}}if(!i&&u.trim()){let l=s(u);if(p){let m={};for(let h=0;h<p.length;h++)m[p[h]]=l[h]??"";d.emit(m)}}i||d.down([[C]])}catch(p){i||d.down([[E,p]])}})(),()=>{i=!0}},Q(o))}function An(e,t){let{delimiter:n=",",hasHeader:a=!0,columns:c,parseLine:r,...o}=t??{},s=r??(d=>ur(d,n));return re([e],(d,i,f)=>{let p=d[0];if(p==null||p.length===0)return;let u=f.store;typeof u.buffer!="string"&&(u.buffer=""),u.headers===void 0&&c&&(u.headers=c.slice());for(let l of p){u.buffer=u.buffer+l;let m=u.buffer.split(/\r?\n/);u.buffer=m.pop()??"";for(let h of m){if(!h.trim())continue;let b=s(h);if(!u.headers&&a){u.headers=b;continue}u.headers||(u.headers=b.map((T,y)=>`col${y}`));let g={};for(let T=0;T<u.headers.length;T++)g[u.headers[T]]=b[T]??"";i.emit(g)}}},{describeKind:"derived",...o})}function Bn(e,t){return re([e],(n,a,c)=>{let r=n[0];if(r==null||r.length===0)return;let o=c.store;typeof o.buffer!="string"&&(o.buffer="");for(let s of r){o.buffer=o.buffer+s;let d=o.buffer.split(/\r?\n/);o.buffer=d.pop()??"";for(let i of d)if(i.trim())try{a.emit(JSON.parse(i))}catch(f){a.down([[E,f]]);return}}},{describeKind:"derived",...t??{}})}function ur(e,t){let n=[],a="",c=!1;for(let r=0;r<e.length;r++){let o=e[r];c?o==='"'?e[r+1]==='"'?(a+='"',r++):c=!1:a+=o:o==='"'?c=!0:o===t?(n.push(a),a=""):a+=o}return n.push(a),n}function In(e,t){return W(n=>{let a=!1;return(async()=>{try{let r="";for await(let o of e){if(a)return;r+=o;let s=r.split(/\r?\n/);r=s.pop()??"";for(let d of s){if(a)return;let i=d.trim();i&&n.emit(JSON.parse(i))}}!a&&r.trim()&&n.emit(JSON.parse(r.trim())),a||n.down([[C]])}catch(r){a||n.down([[E,r]])}})(),()=>{a=!0}},Q(t))}function Fn(e,t,n){let{intervalNs:a=5*1e9,format:c="JSONEachRow",signal:r,maxConsecutiveErrors:o=1}=n??{},s=Math.ceil(a/1e6),d=0;return ge(oe(0,{period:s,signal:r}),()=>W(i=>{let f=!0;return(async()=>{try{let u=await e.query({query:t,format:c});if(!f)return;let l=await u.json();if(!f)return;for(let m of l)i.emit(m);d=0,i.down([[C]])}catch(u){if(!f)return;d+=1,d>=o&&i.down([[E,u]])}})(),()=>{f=!1}}))}function Wn(e,t){let{autoAck:n=!0,deserialize:a=s=>{try{return JSON.parse(s.toString())}catch{return s.toString()}},onAckError:c,...r}=t??{},o=s=>{if(c)try{c(s instanceof Error?s:new Error(String(s)))}catch{}};return W(s=>{let d=!0;return(async()=>{for(;d;)try{let f=await e.receive();if(!d)return;let p={topic:f.getTopicName(),messageId:f.getMessageId().toString(),key:f.getPartitionKey(),value:a(f.getData()),properties:f.getProperties(),publishTime:f.getPublishTimestamp(),eventTime:f.getEventTimestamp(),timestampNs:V()};if(n)s.emit(p),e.acknowledge(f).catch(o);else{let u=!1,l={value:p,ack(){u||(u=!0,e.acknowledge(f).catch(o))},nack(m){if(u)return;u=!0;let h=e;try{let b=h.negativeAcknowledge?.(f);b&&typeof b.then=="function"&&b.catch(o)}catch(b){o(b)}}};s.emit(l)}}catch(f){d&&s.down([[E,f]]);return}})(),()=>{d=!1}},Q(r))}function zn(e,t,n){let{serialize:a=s=>Buffer.from(JSON.stringify(s)),keyExtractor:c,propertiesExtractor:r,onTransportError:o}=n??{};return U(e,{onTransportError:o,send:async s=>{await t.send({data:a(s),partitionKey:c?.(s),properties:r?.(s)})}})}function Hn(e,t,n){let a=new TextDecoder,{queue:c,deserialize:r=s=>{let d=a.decode(s);try{return JSON.parse(d)}catch{return d}},...o}=n??{};return W(s=>{let d=!0,i=e.subscribe(t,c?{queue:c}:void 0);return(async()=>{try{for await(let p of i){if(!d)return;let u={};if(p.headers)for(let l of p.headers.keys())u[l]=p.headers.get(l);s.emit({subject:p.subject,data:r(p.data),headers:u,reply:p.reply,sid:p.sid,timestampNs:V()})}d&&s.down([[C]])}catch(p){d&&s.down([[E,p]])}})(),()=>{d=!1}},Q(o))}function Un(e,t,n,a){let c=new TextEncoder,{serialize:r=s=>c.encode(JSON.stringify(s)),onTransportError:o}=a??{};return U(e,{onTransportError:o,send:s=>{t.publish(n,r(s))}})}function Kn(e,t,n){let{autoAck:a=!0,deserialize:c=d=>{try{return JSON.parse(d.toString())}catch{return d.toString()}},onAckError:r,...o}=n??{},s=d=>{if(r)try{r(d instanceof Error?d:new Error(String(d)))}catch{}};return W(d=>{let i=!0,f;return(async()=>{try{f=(await e.consume(t,l=>{if(!i)return;if(l===null){i&&d.down([[E,new Error("Consumer cancelled by broker")]]);return}let m={queue:t,routingKey:l.fields.routingKey,exchange:l.fields.exchange,content:c(l.content),properties:l.properties,deliveryTag:l.fields.deliveryTag,redelivered:l.fields.redelivered,timestampNs:V()};if(a){d.emit(m);try{e.ack(l)}catch(h){s(h)}}else{let h=!1,b=e,g={value:m,ack(){if(!h){h=!0;try{e.ack(l)}catch(T){s(T)}}},nack(T){if(h)return;h=!0;let y=T?.requeue;if(!b.nack){s(new Error("RabbitMQ channel does not expose `nack`; cannot negative-ack"));return}try{b.nack(l,!1,y)}catch(k){s(k)}}};d.emit(g)}},{noAck:!1})).consumerTag}catch(u){i&&d.down([[E,u]])}})(),()=>{i=!1,f!==void 0&&e.cancel(f)}},Q(o))}function jn(e,t,n,a){let{serialize:c=s=>Buffer.from(JSON.stringify(s)),routingKeyExtractor:r=()=>"",onTransportError:o}=a??{};return U(e,{onTransportError:o,send:s=>{let d=r(s),i=c(s);t.publish(n,d,i)}})}function dr(e,t,n){let{serialize:a=p=>`${JSON.stringify(p)}
12
+ `,flushIntervalMs:c=0,batchSize:r=Number.POSITIVE_INFINITY,onTransportError:o,mode:s}=n??{},i=c>0||r<Number.POSITIVE_INFINITY?U(e,{onTransportError:o,batchSize:r,flushIntervalMs:c,serialize:a,sendBatch:p=>{t.write(p.join(""))}}):U(e,{onTransportError:o,serialize:a,send:p=>{t.write(p)}}),f=i.dispose;return i.dispose=()=>{f();try{t.end()}catch{}},i}function Ue(e,t){return e.includes(t)||e.includes('"')||e.includes(`
13
+ `)?`"${e.replace(/"/g,'""')}"`:e}function Dn(e,t,n){let{columns:a,delimiter:c=",",writeHeader:r=!0,cellExtractor:o=(l,m)=>String(l[m]??""),flushIntervalMs:s=0,batchSize:d=Number.POSITIVE_INFINITY,onTransportError:i,...f}=n,p=!1;return dr(e,t,{serialize:l=>{if(!p&&r){p=!0;let m=a.map(b=>Ue(b,c)).join(c),h=a.map(b=>Ue(o(l,b),c)).join(c);return`${m}
14
14
  ${h}
15
15
  `}return`${a.map(m=>Ue(o(l,m),c)).join(c)}
16
- `},flushIntervalMs:s,batchSize:d,onTransportError:i,...p})}function qn(e,t,n,a){let{batchSize:c=1e3,flushIntervalMs:r=5e3,format:o="JSONEachRow",transform:s=i=>i,onTransportError:d}=a??{};return U(e,{onTransportError:d,batchSize:c,flushIntervalMs:r,serialize:s,sendBatch:async i=>{await t.insert({table:n,values:i,format:o})}})}function Vn(e,t,n,a){let{format:c="ndjson",keyGenerator:r=(u,l)=>{let m=Math.floor(l/1e6);return`data/${new Date(m).toISOString().replace(/[:.]/g,"-")}-${u}.${c==="ndjson"?"ndjson":"json"}`},batchSize:o=1e3,flushIntervalMs:s=1e4,transform:d=u=>u,onTransportError:i}=a??{},p=c==="ndjson"?"application/x-ndjson":"application/json",f=0;return U(e,{onTransportError:i,batchSize:o,flushIntervalMs:s,serialize:d,sendBatch:async u=>{f+=1;let l=c==="ndjson"?`${u.map(h=>JSON.stringify(h)).join(`
16
+ `},flushIntervalMs:s,batchSize:d,onTransportError:i,...f})}function qn(e,t,n,a){let{batchSize:c=1e3,flushIntervalMs:r=5e3,format:o="JSONEachRow",transform:s=i=>i,onTransportError:d}=a??{};return U(e,{onTransportError:d,batchSize:c,flushIntervalMs:r,serialize:s,sendBatch:async i=>{await t.insert({table:n,values:i,format:o})}})}function Vn(e,t,n,a){let{format:c="ndjson",keyGenerator:r=(u,l)=>{let m=Math.floor(l/1e6);return`data/${new Date(m).toISOString().replace(/[:.]/g,"-")}-${u}.${c==="ndjson"?"ndjson":"json"}`},batchSize:o=1e3,flushIntervalMs:s=1e4,transform:d=u=>u,onTransportError:i}=a??{},f=c==="ndjson"?"application/x-ndjson":"application/json",p=0;return U(e,{onTransportError:i,batchSize:o,flushIntervalMs:s,serialize:d,sendBatch:async u=>{p+=1;let l=c==="ndjson"?`${u.map(h=>JSON.stringify(h)).join(`
17
17
  `)}
18
- `:JSON.stringify(u),m=r(f,V());await t.putObject({Bucket:n,Key:m,Body:l,ContentType:p})}})}function $n(e,t,n,a){let{toSQL:c=(o,s)=>({sql:`INSERT INTO "${s.replace(/"/g,'""')}" (data) VALUES ($1)`,params:[JSON.stringify(o)]}),onTransportError:r}=a??{};return U(e,{onTransportError:r,serialize:o=>c(o,n),send:async o=>{let s=o;await t.query(s.sql,s.params)}})}function _n(e,t,n){let{toDocument:a=r=>r,onTransportError:c}=n??{};return U(e,{onTransportError:c,serialize:a,send:async r=>{await t.insertOne(r)}})}function Qn(e,t,n){let{labels:a={},toLine:c=s=>JSON.stringify(s),toLabels:r,onTransportError:o}=n??{};return U(e,{onTransportError:o,serialize:s=>({line:c(s),labels:r?{...a,...r(s)}:a}),send:async s=>{let{line:d,labels:i}=s,p=`${V()}`;await t.push({streams:[{stream:i,values:[[p,d]]}]})}})}function Jn(e,t,n){let{toResourceSpans:a=r=>[r],onTransportError:c}=n??{};return U(e,{onTransportError:c,serialize:a,send:async r=>{await t.push({resourceSpans:r})}})}function Yn(e,t,n,a){let{prefix:c="checkpoints/",debounceMs:r=500,compactEvery:o=10,onError:s}=a??{},d={debounceMs:r,compactEvery:o,save(i,p){let f=Math.floor(V()/1e6),u=`${c}${e.name}/checkpoint-${f}.json`,l;try{l=JSON.stringify(p)}catch(m){s?.(m);return}t.putObject({Bucket:n,Key:u,Body:l,ContentType:"application/json"}).catch(m=>s?.(m))},load(){return null}};return e.attachStorage([d],{onError:i=>s?.(i)})}function Gn(e,t,n){let{prefix:a="graphrefly:checkpoint:",debounceMs:c=500,compactEvery:r=10,onError:o}=n??{},s=`${a}${e.name}`,d={debounceMs:c,compactEvery:r,save(i,p){let f;try{f=JSON.stringify(p)}catch(u){o?.(u);return}t.set(s,f).catch(u=>o?.(u))},async load(){let i=await t.get(s);if(i==null)return null;try{return JSON.parse(i)}catch{return null}}};return e.attachStorage([d],{onError:i=>o?.(i)})}function Xn(e,t,n){let{mapRow:a=o=>o,params:c,...r}=n??{};return W(o=>{try{let d=e.query(t,c).map(a);o.emit(d),o.down([[C]])}catch(s){o.down([[E,s instanceof Error?s:new Error(String(s))]])}},{describeKind:"producer",completeWhenDepsComplete:!1,...r})}function Zn(e,t,n){let{mapRow:a=o=>o,params:c,...r}=n??{};return W(o=>{try{let s=e.iterate(t,c);j(()=>{for(let d of s)o.emit(a(d));o.down([[C]])})}catch(s){o.down([[E,s instanceof Error?s:new Error(String(s))]])}},{describeKind:"producer",completeWhenDepsComplete:!1,...r})}function eo(e,t,n,a){if(n.includes("\0")||n.length===0)throw new Error(`toSqlite: invalid table name: ${JSON.stringify(n)}`);let{toSQL:c=(R,D)=>({sql:`INSERT INTO "${D.replace(/"/g,'""')}" (data) VALUES (?)`,params:[JSON.stringify(R)]}),onTransportError:r,batchInsert:o=!1,maxBatchSize:s=1e3,flushIntervalMs:d=0}=a??{},i=R=>c(R,n);if(!o)return U(e,{onTransportError:r,serialize:i,send:R=>{let D=R;t.query(D.sql,D.params)}});let p=B(null),f=B(void 0,{equals:()=>!1}),u=B(null),l=B(0),m=B(0),h=R=>{try{r?.(R)}catch{}try{p.down([[x,R]])}catch{}},b=[],g=!1,T,y=!1,k=()=>m.down([[x,b.length]]),v=R=>{y||f.down([[x,R]])},w=R=>{y||u.down([[x,R]])},N=R=>{y||l.down([[x,R]])},O=R=>{y||h(R)},H=()=>{if(b.length===0||g)return;g=!0,N(1);try{t.query("BEGIN",[])}catch(F){g=!1,N(0),O({stage:"send",error:F instanceof Error?F:new Error(String(F)),value:void 0});return}let R=b;b=[],k();let D,X=0;for(let F of R)try{t.query(F.query.sql,F.query.params),X+=1}catch($){D=$ instanceof Error?$:new Error(String($));break}if(D){try{t.query("ROLLBACK",[])}catch{}O({stage:"send",error:D,value:void 0});for(let F of R)w({value:F.value,error:D,attempts:1})}else try{t.query("COMMIT",[]);for(let F of R)v(F.value)}catch(F){let $=F instanceof Error?F:new Error(String(F));O({stage:"send",error:$,value:void 0});for(let Z=0;Z<X;Z++)w({value:R[Z].value,error:$,attempts:1})}g=!1,N(0)},z=()=>{d>0&&T===void 0&&!y&&(T=setTimeout(()=>{T=void 0,H()},d))},J=e.subscribe(R=>{for(let D of R){let X=D[0];if(X===x){let F=D[1],$;try{$=i(F)}catch(Z){let pe=Z instanceof Error?Z:new Error(String(Z));h({stage:"serialize",error:pe,value:F}),u.down([[x,{value:F,error:pe,attempts:0}]]);continue}b.push({value:F,query:$}),k(),b.length>=s?H():z()}else G.messageTier(X)>=3&&H()}});return{dispose:()=>{if(!y){T!==void 0&&(clearTimeout(T),T=void 0),H(),y=!0,J();for(let R of[p,f,u,l,m])try{R.down([[q]])}catch{}}},sent:f,failed:u,inFlight:l,errors:p,buffered:m,flush:async()=>{y||H()}}}function ro(e,t){let{args:n,mapRow:a=r=>r,...c}=t??{};return W(r=>{let o=!0;return e.findMany(n).then(s=>{o&&(r.emit(s.map(a)),r.down([[C]]))}).catch(s=>{if(o)try{r.down([[E,s instanceof Error?s:new Error(String(s))]])}catch{}}),()=>{o=!1}},{...c,describeKind:"producer",completeWhenDepsComplete:!1})}function to(e,t){let{mapRow:n=c=>c,...a}=t??{};return W(c=>{let r=!0;return e.execute().then(o=>{r&&(c.emit(o.map(n)),c.down([[C]]))}).catch(o=>{if(r)try{c.down([[E,o instanceof Error?o:new Error(String(o))]])}catch{}}),()=>{r=!1}},{...a,describeKind:"producer",completeWhenDepsComplete:!1})}function no(e,t){let{mapRow:n=c=>c,...a}=t??{};return W(c=>{let r=!0;return e.execute().then(o=>{r&&(c.emit(o.map(n)),c.down([[C]]))}).catch(o=>{if(r)try{c.down([[E,o instanceof Error?o:new Error(String(o))]])}catch{}}),()=>{r=!1}},{...a,describeKind:"producer",completeWhenDepsComplete:!1})}function lr(){let e=new Map,t=null,n=null;function a(r){r.prev?r.prev.next=r.next:t=r.next,r.next?r.next.prev=r.prev:n=r.prev,r.prev=null,r.next=null}function c(r){r.next=t,r.prev=null,t&&(t.prev=r),t=r,n===null&&(n=r)}return{insert(r){if(e.has(r)){this.touch(r);return}let o={key:r,prev:null,next:null};e.set(r,o),c(o)},touch(r){let o=e.get(r);o&&(a(o),c(o))},delete(r){let o=e.get(r);o&&(a(o),e.delete(r))},evict(r){let o=[];for(let s=0;s<r&&n!==null;s++){let d=n;o.push(d.key),a(d),e.delete(d.key)}return o},size(){return e.size}}}function fr(e){return e!=null&&typeof e.then=="function"}function ue(e){fr(e)&&e.catch(()=>{})}function oo(e,t){let n=new Map,a=t?.maxSize??0,c=a>0?t?.eviction??lr():null,r=t?.writeThrough??!1;function o(i,p,f){for(let u=0;u<f;u++)try{ue(e[u].save(i,p))}catch{}}function s(i,p,f=0){for(let u=f;u<e.length;u++){let l;try{l=e[u].load(i)}catch{continue}if(fr(l)){let m=u;l.then(h=>{h!=null?(p.down([[x,h]]),o(i,h,m)):s(i,p,m+1)},()=>{s(i,p,m+1)});return}if(l!=null){p.down([[x,l]]),o(i,l,u);return}}}function d(){if(!(!c||a<=0))for(;c.size()>=a;){let i=c.evict(1);if(i.length===0)break;for(let p of i){let f=n.get(p);if(f){let u=f.cache;if(f.status!=="sentinel"&&e.length>0){let l=e.length-1;try{ue(e[l].save(p,u))}catch{}for(let m=0;m<l;m++)try{let h=e[m].clear;h&&ue(h.call(e[m],p))}catch{}}f.down([[q]])}n.delete(p)}}}return{load(i){let p=n.get(i);if(p)return c?.touch(i),p;c&&a>0&&c.size()>=a&&d();let f=B(void 0);return n.set(i,f),c?.insert(i),s(i,f),f},save(i,p){if(r)for(let u of e)try{ue(u.save(i,p))}catch{}else if(e[0])try{ue(e[0].save(i,p))}catch{}let f=n.get(i);if(f)f.down([[x,p]]),c?.touch(i);else{c&&a>0&&c.size()>=a&&d();let u=B(p);n.set(i,u),c?.insert(i)}},invalidate(i){let p=n.get(i);p&&s(i,p)},delete(i){c?.delete(i);let p=n.get(i);p&&p.down([[q]]),n.delete(i);for(let f of e)try{let u=f.clear;u&&ue(u.call(f,i))}catch{}},has(i){return n.has(i)},get size(){return n.size}}}var Ee=class{_version=0;_topics=new Set;get version(){return this._version}get topicCount(){return this._topics.size}hasTopic(t){return this._topics.has(t)}topicNames(){return this._topics.values()}createTopic(t){return this._topics.has(t)?!1:(this._topics.add(t),this._version+=1,!0)}removeTopic(t){let n=this._topics.delete(t);return n&&(this._version+=1),n}};function so(e={}){let{backend:t}=e,n=t??new Ee,a=new Map;function c(r){let o=a.get(r);return o===void 0&&(o=re({describeKind:"state"}),a.set(r,o),n.createTopic(r)),o}return{topic(r){return c(r)},publish(r,o){c(r).emit(o)},publishMany(r){j(()=>{for(let[o,s]of r)c(o).emit(s)})},removeTopic(r){let o=a.get(r);return o===void 0?!1:(a.delete(r),n.removeTopic(r),o.down([[q]]),!0)},has(r){return n.hasTopic(r)},get size(){return n.topicCount},topicNames(){return n.topicNames()}}}var io=new Map([[Ce,"INVALIDATE"],[Le,"PAUSE"],[Ae,"RESUME"],[q,"TEARDOWN"],[C,"COMPLETE"],[E,"ERROR"]]),ao=new Map([["INVALIDATE",Ce],["PAUSE",Le],["RESUME",Ae],["TEARDOWN",q],["COMPLETE",C],["ERROR",E]]);function se(e){let t=io.get(e);return t||(Symbol.keyFor(e)??"UNKNOWN")}function de(e){let t=ao.get(e);if(t)return t;if(e&&e!=="UNKNOWN")return Symbol.for(e)}function le(e){return e instanceof Error?{message:e.message,name:e.name,stack:e.stack}:{message:String(e),name:"Error"}}function fe(e){let t=new Error(e.message);return t.name=e.name,e.stack&&(t.stack=e.stack),t}function ie(e){if(typeof MessagePort<"u"&&e instanceof MessagePort)return{post(t,n){e.postMessage(t,n??[])},listen(t){let n=a=>t(a.data);return e.addEventListener("message",n),e.start(),()=>e.removeEventListener("message",n)},terminate(){e.close()}};if(typeof SharedWorker<"u"&&e instanceof SharedWorker)return ie(e.port);if(typeof Worker<"u"&&e instanceof Worker)return{post(t,n){e.postMessage(t,n??[])},listen(t){let n=a=>t(a.data);return e.addEventListener("message",n),()=>e.removeEventListener("message",n)},terminate(){e.terminate()}};if(typeof BroadcastChannel<"u"&&e instanceof BroadcastChannel)return{post(t,n){n&&n.length>0&&console.warn("[graphrefly] WorkerTransport: BroadcastChannel does not support Transferable objects. The transfer argument is ignored and objects will be cloned instead."),e.postMessage(t)},listen(t){let n=a=>t(a.data);return e.addEventListener("message",n),()=>e.removeEventListener("message",n)},terminate(){e.close()}};if(typeof ServiceWorker<"u"&&e instanceof ServiceWorker)return{post(t,n){e.postMessage(t,n??[])},listen(t){let n=a=>{a.source===e&&t(a.data)};return navigator.serviceWorker.addEventListener("message",n),()=>navigator.serviceWorker.removeEventListener("message",n)}};throw new Error("createTransport: unsupported target type. Expected Worker, SharedWorker, ServiceWorker, BroadcastChannel, or MessagePort.")}function co(e){return typeof e=="object"&&e!==null&&typeof e.post=="function"&&typeof e.listen=="function"}function pr(e,t){let n=co(e)?e:ie(e),a=t.name??"workerBridge",c=Object.entries(t.expose??{}),r=t.import??[],o=t.transfer??{},s=B("connecting",{name:`${a}::meta::status`}),d=B(null,{name:`${a}::meta::error`}),i=new Map,p=new Map;for(let T of r){let y=B(void 0,{name:`${a}::${T}`});i.set(T,y)}let f;if(c.length>0){let T=c.map(([,v])=>v),y=re(T,(v,w)=>{let N={};for(let O=0;O<c.length;O++){let[H]=c[O],z=v[O];z!=null&&z.length>0&&(N[H]=z.at(-1))}Object.keys(N).length!==0&&w.emit(N)},{name:`${a}::aggregated`});f=he([y],v=>{let w=v[0];if(w==null||Object.keys(w).length===0)return;let N=[];for(let z of Object.keys(w)){let J=o[z];J&&N.push(...J(w[z]))}let O;for(let[z,J]of c)z in w&&J.v!=null&&(O==null&&(O={}),O[z]=J.v.version);let H={t:"b",u:w,...O?{v:O}:{}};try{n.post(H,N.length>0?N:void 0)}catch(z){d.down([[x,z instanceof Error?z:new Error(String(z))]])}}).subscribe(()=>{})}let u=!1,l=n.listen(T=>{if(u)return;let y=T;switch(y.t){case"r":{j(()=>{for(let[v,w]of Object.entries(y.stores)){let N=i.get(v);N&&N.down([[x,w]])}}),s.down([[x,"connected"]]);let k={};for(let[v,w]of c)k[v]=w.cache;n.post({t:"i",stores:k});break}case"v":{let k=i.get(y.s);k&&k.down([[x,y.d]]);break}case"b":{j(()=>{for(let[k,v]of Object.entries(y.u)){let w=y.v?.[k];if(w!=null){let O=p.get(k);if(O!=null&&w<=O)continue;p.set(k,w)}let N=i.get(k);N&&N.down([[x,v]])}});break}case"e":{let k=i.get(y.s);k&&k.down([[E,fe(y.err)]]);break}case"s":{let k=de(y.sig);if(!k)break;let v=y.s==="*"?[...i.values()]:i.has(y.s)?[i.get(y.s)]:[];for(let w of v)w.down(y.d===void 0?[[k]]:[[k,y.d]]);break}}}),m=[];for(let[T,y]of c){let k=y.subscribe((v=>{if(!u)for(let w of v){let N=w[0];N!==x&&(G.isLocalOnly(N)||(N===E?n.post({t:"e",s:T,err:le(w[1])}):n.post({t:"s",s:T,sig:se(N),d:w.length>1?w[1]:void 0})))}}));m.push(k)}let h;if(t.timeoutMs!=null&&t.timeoutMs>0){let T=oe(t.timeoutMs),y=Ie(s,v=>v==="connected");h=Fe(We(xe(T,()=>"timeout"),xe(y,()=>"ready"))).subscribe(v=>{for(let w of v)w[0]===x&&w[1]==="timeout"&&(d.down([[x,new Error("Worker bridge handshake timeout")]]),b())})}function b(){if(!u){u=!0,h?.(),n.post({t:"s",s:"*",sig:se(q)}),f&&f();for(let T of m)T();m.length=0,l(),s.down([[x,"closed"]]),p.clear(),i.clear()}}let g={meta:{status:s,error:d},destroy:b};for(let[T,y]of i)g[T]=y;return g}function uo(e){return typeof e=="object"&&e!==null&&typeof e.post=="function"&&typeof e.listen=="function"}function mr(e,t){let n=uo(e)?e:ie(e),a=t.import??[],c=t.transfer??{},r=new Map,o=new Map,s={};for(let b of a){let g=B(void 0,{name:`worker::${b}`});r.set(b,g),s[b]=g}let d=t.expose(s),i=Object.entries(d),p,f=!1;if(i.length>0){let b=i.map(([,y])=>y),g=re(b,(y,k)=>{let v={};for(let w=0;w<i.length;w++){let[N]=i[w],O=y[w];O!=null&&O.length>0&&(v[N]=O.at(-1))}Object.keys(v).length!==0&&k.emit(v)},{name:"workerSelf::aggregated"});p=he([g],y=>{if(f)return;let k=y[0];if(k==null||Object.keys(k).length===0)return;let v=[];for(let O of Object.keys(k)){let H=c[O];H&&v.push(...H(k[O]))}let w;for(let[O,H]of i)O in k&&H.v!=null&&(w==null&&(w={}),w[O]=H.v.version);let N={t:"b",u:k,...w?{v:w}:{}};try{n.post(N,v.length>0?v:void 0)}catch{}}).subscribe(()=>{})}let u=[];for(let[b,g]of i){let T=g.subscribe((y=>{if(!f)for(let k of y){let v=k[0];v!==x&&(G.isLocalOnly(v)||(v===E?n.post({t:"e",s:b,err:le(k[1])}):n.post({t:"s",s:b,sig:se(v),d:k.length>1?k[1]:void 0})))}}));u.push(T)}let l=n.listen(b=>{if(f)return;let g=b;switch(g.t){case"i":{j(()=>{for(let[T,y]of Object.entries(g.stores)){let k=r.get(T);k&&k.down([[x,y]])}});break}case"v":{let T=r.get(g.s);T&&T.down([[x,g.d]]);break}case"b":{j(()=>{for(let[T,y]of Object.entries(g.u)){let k=g.v?.[T];if(k!=null){let w=o.get(T);if(w!=null&&k<=w)continue;o.set(T,k)}let v=r.get(T);v&&v.down([[x,y]])}});break}case"e":{let T=r.get(g.s);T&&T.down([[E,fe(g.err)]]);break}case"s":{let T=de(g.sig);if(!T)break;if(T===q&&g.s==="*"){h();return}let y=g.s==="*"?[...r.values()]:r.has(g.s)?[r.get(g.s)]:[];for(let k of y)k.down(g.d===void 0?[[T]]:[[T,g.d]]);break}}}),m={};for(let[b,g]of i)m[b]=g.cache;n.post({t:"r",stores:m});function h(){if(!f){f=!0,p&&p();for(let b of u)b();u.length=0,l(),n.terminate?.(),o.clear(),r.clear()}}return{destroy:h}}export{ae as a,ze as b,U as c,or as d,un as e,sr as f,dn as g,ln as h,fn as i,pn as j,mn as k,gn as l,Tn as m,yn as n,kn as o,bn as p,hn as q,vn as r,wn as s,Sn as t,En as u,Nn as v,cr as w,Rn as x,Mn as y,Pn as z,Cn as A,Ln as B,An as C,Bn as D,In as E,Fn as F,Wn as G,zn as H,Hn as I,Un as J,Kn as K,jn as L,dr as M,Dn as N,qn as O,Vn as P,$n as Q,_n as R,Qn as S,Jn as T,Yn as U,Gn as V,Xn as W,Zn as X,eo as Y,ro as Z,to as _,no as $,lr as aa,oo as ba,Ee as ca,so as da,se as ea,de as fa,le as ga,fe as ha,ie as ia,pr as ja,mr as ka,lo as la};
18
+ `:JSON.stringify(u),m=r(p,V());await t.putObject({Bucket:n,Key:m,Body:l,ContentType:f})}})}function $n(e,t,n,a){let{toSQL:c=(o,s)=>({sql:`INSERT INTO "${s.replace(/"/g,'""')}" (data) VALUES ($1)`,params:[JSON.stringify(o)]}),onTransportError:r}=a??{};return U(e,{onTransportError:r,serialize:o=>c(o,n),send:async o=>{let s=o;await t.query(s.sql,s.params)}})}function _n(e,t,n){let{toDocument:a=r=>r,onTransportError:c}=n??{};return U(e,{onTransportError:c,serialize:a,send:async r=>{await t.insertOne(r)}})}function Qn(e,t,n){let{labels:a={},toLine:c=s=>JSON.stringify(s),toLabels:r,onTransportError:o}=n??{};return U(e,{onTransportError:o,serialize:s=>({line:c(s),labels:r?{...a,...r(s)}:a}),send:async s=>{let{line:d,labels:i}=s,f=`${V()}`;await t.push({streams:[{stream:i,values:[[f,d]]}]})}})}function Jn(e,t,n){let{toResourceSpans:a=r=>[r],onTransportError:c}=n??{};return U(e,{onTransportError:c,serialize:a,send:async r=>{await t.push({resourceSpans:r})}})}function Yn(e,t,n,a){let{prefix:c="checkpoints/",debounceMs:r=500,compactEvery:o=10,onError:s}=a??{},d={debounceMs:r,compactEvery:o,save(i,f){let p=Math.floor(V()/1e6),u=`${c}${e.name}/checkpoint-${p}.json`,l;try{l=JSON.stringify(f)}catch(m){s?.(m);return}t.putObject({Bucket:n,Key:u,Body:l,ContentType:"application/json"}).catch(m=>s?.(m))},load(){return null}};return e.attachStorage([d],{onError:i=>s?.(i)})}function Gn(e,t,n){let{prefix:a="graphrefly:checkpoint:",debounceMs:c=500,compactEvery:r=10,onError:o}=n??{},s=`${a}${e.name}`,d={debounceMs:c,compactEvery:r,save(i,f){let p;try{p=JSON.stringify(f)}catch(u){o?.(u);return}t.set(s,p).catch(u=>o?.(u))},async load(){let i=await t.get(s);if(i==null)return null;try{return JSON.parse(i)}catch{return null}}};return e.attachStorage([d],{onError:i=>o?.(i)})}function Xn(e,t,n){let{mapRow:a=o=>o,params:c,...r}=n??{};return W(o=>{try{let d=e.query(t,c).map(a);o.emit(d),o.down([[C]])}catch(s){o.down([[E,s instanceof Error?s:new Error(String(s))]])}},{describeKind:"producer",completeWhenDepsComplete:!1,...r})}function Zn(e,t,n){let{mapRow:a=o=>o,params:c,...r}=n??{};return W(o=>{try{let s=e.iterate(t,c);j(()=>{for(let d of s)o.emit(a(d));o.down([[C]])})}catch(s){o.down([[E,s instanceof Error?s:new Error(String(s))]])}},{describeKind:"producer",completeWhenDepsComplete:!1,...r})}function eo(e,t,n,a){if(n.includes("\0")||n.length===0)throw new Error(`toSqlite: invalid table name: ${JSON.stringify(n)}`);let{toSQL:c=(R,D)=>({sql:`INSERT INTO "${D.replace(/"/g,'""')}" (data) VALUES (?)`,params:[JSON.stringify(R)]}),onTransportError:r,batchInsert:o=!1,maxBatchSize:s=1e3,flushIntervalMs:d=0}=a??{},i=R=>c(R,n);if(!o)return U(e,{onTransportError:r,serialize:i,send:R=>{let D=R;t.query(D.sql,D.params)}});let f=B(null),p=B(void 0,{equals:()=>!1}),u=B(null),l=B(0),m=B(0),h=R=>{try{r?.(R)}catch{}try{f.down([[x,R]])}catch{}},b=[],g=!1,T,y=!1,k=()=>m.down([[x,b.length]]),v=R=>{y||p.down([[x,R]])},w=R=>{y||u.down([[x,R]])},N=R=>{y||l.down([[x,R]])},O=R=>{y||h(R)},H=()=>{if(b.length===0||g)return;g=!0,N(1);try{t.query("BEGIN",[])}catch(F){g=!1,N(0),O({stage:"send",error:F instanceof Error?F:new Error(String(F)),value:void 0});return}let R=b;b=[],k();let D,X=0;for(let F of R)try{t.query(F.query.sql,F.query.params),X+=1}catch($){D=$ instanceof Error?$:new Error(String($));break}if(D){try{t.query("ROLLBACK",[])}catch{}O({stage:"send",error:D,value:void 0});for(let F of R)w({value:F.value,error:D,attempts:1})}else try{t.query("COMMIT",[]);for(let F of R)v(F.value)}catch(F){let $=F instanceof Error?F:new Error(String(F));O({stage:"send",error:$,value:void 0});for(let Z=0;Z<X;Z++)w({value:R[Z].value,error:$,attempts:1})}g=!1,N(0)},z=()=>{d>0&&T===void 0&&!y&&(T=setTimeout(()=>{T=void 0,H()},d))},J=e.subscribe(R=>{for(let D of R){let X=D[0];if(X===x){let F=D[1],$;try{$=i(F)}catch(Z){let fe=Z instanceof Error?Z:new Error(String(Z));h({stage:"serialize",error:fe,value:F}),u.down([[x,{value:F,error:fe,attempts:0}]]);continue}b.push({value:F,query:$}),k(),b.length>=s?H():z()}else G.messageTier(X)>=3&&H()}});return{dispose:()=>{if(!y){T!==void 0&&(clearTimeout(T),T=void 0),H(),y=!0,J();for(let R of[f,p,u,l,m])try{R.down([[q]])}catch{}}},sent:p,failed:u,inFlight:l,errors:f,buffered:m,flush:async()=>{y||H()}}}function ro(e,t){let{args:n,mapRow:a=r=>r,...c}=t??{};return W(r=>{let o=!0;return e.findMany(n).then(s=>{o&&(r.emit(s.map(a)),r.down([[C]]))}).catch(s=>{if(o)try{r.down([[E,s instanceof Error?s:new Error(String(s))]])}catch{}}),()=>{o=!1}},{...c,describeKind:"producer",completeWhenDepsComplete:!1})}function to(e,t){let{mapRow:n=c=>c,...a}=t??{};return W(c=>{let r=!0;return e.execute().then(o=>{r&&(c.emit(o.map(n)),c.down([[C]]))}).catch(o=>{if(r)try{c.down([[E,o instanceof Error?o:new Error(String(o))]])}catch{}}),()=>{r=!1}},{...a,describeKind:"producer",completeWhenDepsComplete:!1})}function no(e,t){let{mapRow:n=c=>c,...a}=t??{};return W(c=>{let r=!0;return e.execute().then(o=>{r&&(c.emit(o.map(n)),c.down([[C]]))}).catch(o=>{if(r)try{c.down([[E,o instanceof Error?o:new Error(String(o))]])}catch{}}),()=>{r=!1}},{...a,describeKind:"producer",completeWhenDepsComplete:!1})}function lr(){let e=new Map,t=null,n=null;function a(r){r.prev?r.prev.next=r.next:t=r.next,r.next?r.next.prev=r.prev:n=r.prev,r.prev=null,r.next=null}function c(r){r.next=t,r.prev=null,t&&(t.prev=r),t=r,n===null&&(n=r)}return{insert(r){if(e.has(r)){this.touch(r);return}let o={key:r,prev:null,next:null};e.set(r,o),c(o)},touch(r){let o=e.get(r);o&&(a(o),c(o))},delete(r){let o=e.get(r);o&&(a(o),e.delete(r))},evict(r){let o=[];for(let s=0;s<r&&n!==null;s++){let d=n;o.push(d.key),a(d),e.delete(d.key)}return o},size(){return e.size}}}function pr(e){return e!=null&&typeof e.then=="function"}function ue(e){pr(e)&&e.catch(()=>{})}function oo(e,t){let n=new Map,a=t?.maxSize??0,c=a>0?t?.eviction??lr():null,r=t?.writeThrough??!1;function o(i,f,p){for(let u=0;u<p;u++)try{ue(e[u].save(i,f))}catch{}}function s(i,f,p=0){for(let u=p;u<e.length;u++){let l;try{l=e[u].load(i)}catch{continue}if(pr(l)){let m=u;l.then(h=>{h!=null?(f.down([[x,h]]),o(i,h,m)):s(i,f,m+1)},()=>{s(i,f,m+1)});return}if(l!=null){f.down([[x,l]]),o(i,l,u);return}}}function d(){if(!(!c||a<=0))for(;c.size()>=a;){let i=c.evict(1);if(i.length===0)break;for(let f of i){let p=n.get(f);if(p){let u=p.cache;if(p.status!=="sentinel"&&e.length>0){let l=e.length-1;try{ue(e[l].save(f,u))}catch{}for(let m=0;m<l;m++)try{let h=e[m].clear;h&&ue(h.call(e[m],f))}catch{}}p.down([[q]])}n.delete(f)}}}return{load(i){let f=n.get(i);if(f)return c?.touch(i),f;c&&a>0&&c.size()>=a&&d();let p=B(void 0);return n.set(i,p),c?.insert(i),s(i,p),p},save(i,f){if(r)for(let u of e)try{ue(u.save(i,f))}catch{}else if(e[0])try{ue(e[0].save(i,f))}catch{}let p=n.get(i);if(p)p.down([[x,f]]),c?.touch(i);else{c&&a>0&&c.size()>=a&&d();let u=B(f);n.set(i,u),c?.insert(i)}},invalidate(i){let f=n.get(i);f&&s(i,f)},delete(i){c?.delete(i);let f=n.get(i);f&&f.down([[q]]),n.delete(i);for(let p of e)try{let u=p.clear;u&&ue(u.call(p,i))}catch{}},has(i){return n.has(i)},get size(){return n.size}}}var Ee=class{_version=0;_topics=new Set;get version(){return this._version}get topicCount(){return this._topics.size}hasTopic(t){return this._topics.has(t)}topicNames(){return this._topics.values()}createTopic(t){return this._topics.has(t)?!1:(this._topics.add(t),this._version+=1,!0)}removeTopic(t){let n=this._topics.delete(t);return n&&(this._version+=1),n}};function so(e={}){let{backend:t}=e,n=t??new Ee,a=new Map;function c(r){let o=a.get(r);return o===void 0&&(o=re({describeKind:"state"}),a.set(r,o),n.createTopic(r)),o}return{topic(r){return c(r)},publish(r,o){c(r).emit(o)},publishMany(r){j(()=>{for(let[o,s]of r)c(o).emit(s)})},removeTopic(r){let o=a.get(r);return o===void 0?!1:(a.delete(r),n.removeTopic(r),o.down([[q]]),!0)},has(r){return n.hasTopic(r)},get size(){return n.topicCount},topicNames(){return n.topicNames()}}}var io=new Map([[Ce,"INVALIDATE"],[Le,"PAUSE"],[Ae,"RESUME"],[q,"TEARDOWN"],[C,"COMPLETE"],[E,"ERROR"]]),ao=new Map([["INVALIDATE",Ce],["PAUSE",Le],["RESUME",Ae],["TEARDOWN",q],["COMPLETE",C],["ERROR",E]]);function se(e){let t=io.get(e);return t||(Symbol.keyFor(e)??"UNKNOWN")}function de(e){let t=ao.get(e);if(t)return t;if(e&&e!=="UNKNOWN")return Symbol.for(e)}function le(e){return e instanceof Error?{message:e.message,name:e.name,stack:e.stack}:{message:String(e),name:"Error"}}function pe(e){let t=new Error(e.message);return t.name=e.name,e.stack&&(t.stack=e.stack),t}function ie(e){if(typeof MessagePort<"u"&&e instanceof MessagePort)return{post(t,n){e.postMessage(t,n??[])},listen(t){let n=a=>t(a.data);return e.addEventListener("message",n),e.start(),()=>e.removeEventListener("message",n)},terminate(){e.close()}};if(typeof SharedWorker<"u"&&e instanceof SharedWorker)return ie(e.port);if(typeof Worker<"u"&&e instanceof Worker)return{post(t,n){e.postMessage(t,n??[])},listen(t){let n=a=>t(a.data);return e.addEventListener("message",n),()=>e.removeEventListener("message",n)},terminate(){e.terminate()}};if(typeof BroadcastChannel<"u"&&e instanceof BroadcastChannel)return{post(t,n){n&&n.length>0&&console.warn("[graphrefly] WorkerTransport: BroadcastChannel does not support Transferable objects. The transfer argument is ignored and objects will be cloned instead."),e.postMessage(t)},listen(t){let n=a=>t(a.data);return e.addEventListener("message",n),()=>e.removeEventListener("message",n)},terminate(){e.close()}};if(typeof ServiceWorker<"u"&&e instanceof ServiceWorker)return{post(t,n){e.postMessage(t,n??[])},listen(t){let n=a=>{a.source===e&&t(a.data)};return navigator.serviceWorker.addEventListener("message",n),()=>navigator.serviceWorker.removeEventListener("message",n)}};throw new Error("createTransport: unsupported target type. Expected Worker, SharedWorker, ServiceWorker, BroadcastChannel, or MessagePort.")}function co(e){return typeof e=="object"&&e!==null&&typeof e.post=="function"&&typeof e.listen=="function"}function fr(e,t){let n=co(e)?e:ie(e),a=t.name??"workerBridge",c=Object.entries(t.expose??{}),r=t.import??[],o=t.transfer??{},s=B("connecting",{name:`${a}::meta::status`}),d=B(null,{name:`${a}::meta::error`}),i=new Map,f=new Map;for(let T of r){let y=B(void 0,{name:`${a}::${T}`});i.set(T,y)}let p;if(c.length>0){let T=c.map(([,v])=>v),y=re(T,(v,w)=>{let N={};for(let O=0;O<c.length;O++){let[H]=c[O],z=v[O];z!=null&&z.length>0&&(N[H]=z.at(-1))}Object.keys(N).length!==0&&w.emit(N)},{name:`${a}::aggregated`,partial:!0});p=he([y],v=>{let w=v[0];if(w==null||Object.keys(w).length===0)return;let N=[];for(let z of Object.keys(w)){let J=o[z];J&&N.push(...J(w[z]))}let O;for(let[z,J]of c)z in w&&J.v!=null&&(O==null&&(O={}),O[z]=J.v.version);let H={t:"b",u:w,...O?{v:O}:{}};try{n.post(H,N.length>0?N:void 0)}catch(z){d.down([[x,z instanceof Error?z:new Error(String(z))]])}}).subscribe(()=>{})}let u=!1,l=n.listen(T=>{if(u)return;let y=T;switch(y.t){case"r":{j(()=>{for(let[v,w]of Object.entries(y.stores)){let N=i.get(v);N&&N.down([[x,w]])}}),s.down([[x,"connected"]]);let k={};for(let[v,w]of c)k[v]=w.cache;n.post({t:"i",stores:k});break}case"v":{let k=i.get(y.s);k&&k.down([[x,y.d]]);break}case"b":{j(()=>{for(let[k,v]of Object.entries(y.u)){let w=y.v?.[k];if(w!=null){let O=f.get(k);if(O!=null&&w<=O)continue;f.set(k,w)}let N=i.get(k);N&&N.down([[x,v]])}});break}case"e":{let k=i.get(y.s);k&&k.down([[E,pe(y.err)]]);break}case"s":{let k=de(y.sig);if(!k)break;let v=y.s==="*"?[...i.values()]:i.has(y.s)?[i.get(y.s)]:[];for(let w of v)w.down(y.d===void 0?[[k]]:[[k,y.d]]);break}}}),m=[];for(let[T,y]of c){let k=y.subscribe((v=>{if(!u)for(let w of v){let N=w[0];N!==x&&(G.isLocalOnly(N)||(N===E?n.post({t:"e",s:T,err:le(w[1])}):n.post({t:"s",s:T,sig:se(N),d:w.length>1?w[1]:void 0})))}}));m.push(k)}let h;if(t.timeoutMs!=null&&t.timeoutMs>0){let T=oe(t.timeoutMs),y=Ie(s,v=>v==="connected");h=Fe(We(xe(T,()=>"timeout"),xe(y,()=>"ready"))).subscribe(v=>{for(let w of v)w[0]===x&&w[1]==="timeout"&&(d.down([[x,new Error("Worker bridge handshake timeout")]]),b())})}function b(){if(!u){u=!0,h?.(),n.post({t:"s",s:"*",sig:se(q)}),p&&p();for(let T of m)T();m.length=0,l(),s.down([[x,"closed"]]),f.clear(),i.clear()}}let g={meta:{status:s,error:d},destroy:b};for(let[T,y]of i)g[T]=y;return g}function uo(e){return typeof e=="object"&&e!==null&&typeof e.post=="function"&&typeof e.listen=="function"}function mr(e,t){let n=uo(e)?e:ie(e),a=t.import??[],c=t.transfer??{},r=new Map,o=new Map,s={};for(let b of a){let g=B(void 0,{name:`worker::${b}`});r.set(b,g),s[b]=g}let d=t.expose(s),i=Object.entries(d),f,p=!1;if(i.length>0){let b=i.map(([,y])=>y),g=re(b,(y,k)=>{let v={};for(let w=0;w<i.length;w++){let[N]=i[w],O=y[w];O!=null&&O.length>0&&(v[N]=O.at(-1))}Object.keys(v).length!==0&&k.emit(v)},{name:"workerSelf::aggregated",partial:!0});f=he([g],y=>{if(p)return;let k=y[0];if(k==null||Object.keys(k).length===0)return;let v=[];for(let O of Object.keys(k)){let H=c[O];H&&v.push(...H(k[O]))}let w;for(let[O,H]of i)O in k&&H.v!=null&&(w==null&&(w={}),w[O]=H.v.version);let N={t:"b",u:k,...w?{v:w}:{}};try{n.post(N,v.length>0?v:void 0)}catch{}}).subscribe(()=>{})}let u=[];for(let[b,g]of i){let T=g.subscribe((y=>{if(!p)for(let k of y){let v=k[0];v!==x&&(G.isLocalOnly(v)||(v===E?n.post({t:"e",s:b,err:le(k[1])}):n.post({t:"s",s:b,sig:se(v),d:k.length>1?k[1]:void 0})))}}));u.push(T)}let l=n.listen(b=>{if(p)return;let g=b;switch(g.t){case"i":{j(()=>{for(let[T,y]of Object.entries(g.stores)){let k=r.get(T);k&&k.down([[x,y]])}});break}case"v":{let T=r.get(g.s);T&&T.down([[x,g.d]]);break}case"b":{j(()=>{for(let[T,y]of Object.entries(g.u)){let k=g.v?.[T];if(k!=null){let w=o.get(T);if(w!=null&&k<=w)continue;o.set(T,k)}let v=r.get(T);v&&v.down([[x,y]])}});break}case"e":{let T=r.get(g.s);T&&T.down([[E,pe(g.err)]]);break}case"s":{let T=de(g.sig);if(!T)break;if(T===q&&g.s==="*"){h();return}let y=g.s==="*"?[...r.values()]:r.has(g.s)?[r.get(g.s)]:[];for(let k of y)k.down(g.d===void 0?[[T]]:[[T,g.d]]);break}}}),m={};for(let[b,g]of i)m[b]=g.cache;n.post({t:"r",stores:m});function h(){if(!p){p=!0,f&&f();for(let b of u)b();u.length=0,l(),n.terminate?.(),o.clear(),r.clear()}}return{destroy:h}}export{ae as a,ze as b,U as c,or as d,un as e,sr as f,dn as g,ln as h,pn as i,fn as j,mn as k,gn as l,Tn as m,yn as n,kn as o,bn as p,hn as q,vn as r,wn as s,Sn as t,En as u,Nn as v,cr as w,Rn as x,Mn as y,Pn as z,Cn as A,Ln as B,An as C,Bn as D,In as E,Fn as F,Wn as G,zn as H,Hn as I,Un as J,Kn as K,jn as L,dr as M,Dn as N,qn as O,Vn as P,$n as Q,_n as R,Qn as S,Jn as T,Yn as U,Gn as V,Xn as W,Zn as X,eo as Y,ro as Z,to as _,no as $,lr as aa,oo as ba,Ee as ca,so as da,se as ea,de as fa,le as ga,pe as ha,ie as ia,fr as ja,mr as ka,lo as la};
@@ -1 +1 @@
1
- import{c as I}from"./chunk-ETWTCCJI.js";import{g as _,j as P}from"./chunk-CKCSDI7T.js";import{D as y,E as K,G as E,m as F}from"./chunk-ZB5EHBIO.js";import{b as j,d as x,i as A,j as D}from"./chunk-CK2E7BTU.js";import{b as B}from"./chunk-QYADASLV.js";var ee={};B(ee,{approval:()=>V,branch:()=>U,gate:()=>z,join:()=>J,loop:()=>Q,onFailure:()=>Z,pipeline:()=>L,sensor:()=>Y,subPipeline:()=>X,task:()=>H});function O(e,n){if(typeof n=="string")return{node:e.resolve(n),path:n};let o=$(e,n);if(!o)throw new Error("orchestration dep node must already be registered in the graph so explicit edges can be recorded; pass a string path or register the node first");return{node:n,path:o}}function $(e,n){let o=e.describe(),r=`::${_}::`;for(let t of Object.keys(o.nodes).sort())if(!t.includes(r))try{if(e.resolve(t)===n)return t}catch{}}function w(e,n,o,r){e.add(o,{name:n})}function N(e,n){return I("orchestration",e,n)}function W(e){let n=r=>{let t=r.trim();return t.length===0?0:Number(t)},o;return typeof e=="string"?o=n(e):e===null?o=0:o=Number(e),Number.isFinite(o)?Math.max(0,Math.trunc(o)):1}function L(e,n){return new P(e,n)}function H(e,n,o,r){let a=(r?.deps??[]).map(i=>O(e,i)),{deps:s,...p}=r??{},T=(i,f,c)=>{let l=i.map((h,g)=>h!=null&&h.length>0?h.at(-1):c.prevData[g]);f.emit(o(l,c))},d=y(a.map(i=>i.node),T,{...p,name:n,describeKind:"derived",meta:N("task",r?.meta)});return w(e,n,d,a.flatMap(i=>i.path?[i.path]:[])),d}function U(e,n,o,r,t){let a=O(e,o),s=E([a.node],([p])=>({branch:r(p)?"then":"else",value:p}),{...t,name:n,meta:N("branch",t?.meta)});return w(e,n,s,a.path?[a.path]:[]),s}function V(e,n,o,r,t){let a=O(e,o),s=O(e,r),p=t?.isApproved??(d=>!!d),T=y([a.node,s.node],(d,i,f)=>{let c=d[0],l=d[1],h=l!=null&&l.length>0?l.at(-1):f.prevData[1];if(h===void 0||!p(h)){i.down([[x]]);return}if(c==null||c.length===0){l!=null&&l.length>0&&f.prevData[0]!==void 0?i.emit(f.prevData[0]):i.down([[x]]);return}for(let g of c)i.emit(g)},{...t,name:n,describeKind:"derived",meta:N("approval",t?.meta)});return w(e,n,T,[a.path,s.path].filter(d=>typeof d=="string")),T}function z(e,n,o,r){let t=r?.maxPending??1/0;if(t<1&&t!==1/0)throw new RangeError("gate: maxPending must be >= 1");let a=r?.startOpen??!1,s=O(e,o),p=K([],{name:"pending",equals:()=>!1}),T=K(a,{name:"isOpen"}),d=E([p],([u])=>u.length,{name:"count"}),i=[],f=!1,c=a,l=T.subscribe(u=>{for(let m of u)m[0]===j&&(c=m[1])});function h(){p.emit([...i])}function g(u){i.push(u),i.length>t&&i.shift(),h()}function R(u){let m=i.splice(0,u);return h(),m}function k(u){if(f)throw new Error(`gate: ${u}() called after gate was torn down`)}let b=y([s.node],(u,m,S)=>{let G=S.terminalDeps[0];if(G!==void 0){f=!0,i=[],h(),m.down(G===!0?[[A]]:[[D,G]]);return}let v=u[0];if(v==null||v.length===0){m.down([[x]]);return}for(let C of v)c?m.emit(C):(g(C),m.down([[x]]))},{name:n,describeKind:"derived",meta:N("gate",r?.meta)}),q={node:b,pending:p,count:d,isOpen:T,approve(u=1){k("approve");let m=R(u);for(let S of m){if(f)break;b.emit(S)}},reject(u=1){k("reject"),R(u)},modify(u,m=1){k("modify");let S=[...i],G=R(m);for(let v=0;v<G.length&&!f;v++)b.emit(u(G[v],v,S))},open(){k("open"),F(()=>{T.emit(!0);let u=R(i.length);for(let m of u){if(f)break;b.emit(m)}})},close(){k("close"),T.emit(!1)}};e.addDisposer(d.subscribe(()=>{})),e.addDisposer(l),w(e,n,b,s.path?[s.path]:[]);let M=new P(`${n}_state`);return M.add(p,{name:"pending"}),M.add(T,{name:"isOpen"}),M.add(d,{name:"count"}),e.mount(`${n}_state`,M),q}function J(e,n,o,r){let t=o.map(s=>O(e,s)),a=E(t.map(s=>s.node),s=>s,{...r,name:n,meta:N("join",r?.meta)});return w(e,n,a,t.flatMap(s=>s.path?[s.path]:[])),a}function Q(e,n,o,r,t){let a=O(e,o),s=t?.iterations,p=typeof s=="number"||s===void 0?void 0:O(e,s),T=typeof s=="number"?s:void 0,d=y(p?[a.node,p.node]:[a.node],(i,f,c)=>{let l=i[0],h=l!=null&&l.length>0?l.at(-1):c.prevData[0],g=p?i[1]:void 0,R=T??(p?g!=null&&g.length>0?g.at(-1):c.prevData[1]:1),k=W(R);for(let b=0;b<k;b+=1)h=r(h,b,f);f.emit(h)},{...t,name:n,describeKind:"derived",meta:N("loop",t?.meta)});return w(e,n,d,[a.path,p?.path].filter(i=>typeof i=="string")),d}function X(e,n,o,r){let t=o instanceof P?o:L(n,r);return typeof o=="function"&&o(t),e.mount(n,t),t}function Y(e,n,o,r){let t=y([],()=>{},{...r,name:n,initial:o,describeKind:"producer",meta:N("sensor",r?.meta)});return w(e,n,t,[]),{node:t,push(a){t.emit(a)},error(a){t.down([[D,a]])},complete(){t.down([[A]])}}}function Z(e,n,o,r,t){let a=O(e,o),s=!1,p=y([],(T,d)=>{let i=a.node.subscribe(f=>{for(let c of f){if(s)return;if(c[0]===D)try{d.emit(r(c[1],d))}catch(l){s=!0,d.down([[D,l]])}else d.down([c]),c[0]===A&&(s=!0)}});return()=>i()},{...t,name:n,describeKind:"derived",completeWhenDepsComplete:!1,errorWhenDepsError:!1,meta:N("onFailure",t?.meta)});return w(e,n,p,a.path?[a.path]:[]),p}export{L as a,H as b,U as c,V as d,z as e,J as f,Q as g,X as h,Y as i,Z as j,ee as k};
1
+ import{c as I}from"./chunk-5Z4HDCO6.js";import{h as _,k as P}from"./chunk-MGKAO4EK.js";import{D as y,E as K,G as E,m as F}from"./chunk-W4TSQ6RJ.js";import{b as j,d as x,i as A,j as D}from"./chunk-CK2E7BTU.js";import{b as B}from"./chunk-QYADASLV.js";var ee={};B(ee,{approval:()=>V,branch:()=>U,gate:()=>z,join:()=>J,loop:()=>Q,onFailure:()=>Z,pipeline:()=>L,sensor:()=>Y,subPipeline:()=>X,task:()=>H});function O(e,n){if(typeof n=="string")return{node:e.resolve(n),path:n};let o=$(e,n);if(!o)throw new Error("orchestration dep node must already be registered in the graph so explicit edges can be recorded; pass a string path or register the node first");return{node:n,path:o}}function $(e,n){let o=e.describe(),r=`::${_}::`;for(let t of Object.keys(o.nodes).sort())if(!t.includes(r))try{if(e.resolve(t)===n)return t}catch{}}function w(e,n,o,r){e.add(o,{name:n})}function N(e,n){return I("orchestration",e,n)}function W(e){let n=r=>{let t=r.trim();return t.length===0?0:Number(t)},o;return typeof e=="string"?o=n(e):e===null?o=0:o=Number(e),Number.isFinite(o)?Math.max(0,Math.trunc(o)):1}function L(e,n){return new P(e,n)}function H(e,n,o,r){let a=(r?.deps??[]).map(i=>O(e,i)),{deps:s,...p}=r??{},T=(i,f,c)=>{let l=i.map((h,g)=>h!=null&&h.length>0?h.at(-1):c.prevData[g]);f.emit(o(l,c))},d=y(a.map(i=>i.node),T,{...p,name:n,describeKind:"derived",meta:N("task",r?.meta)});return w(e,n,d,a.flatMap(i=>i.path?[i.path]:[])),d}function U(e,n,o,r,t){let a=O(e,o),s=E([a.node],([p])=>({branch:r(p)?"then":"else",value:p}),{...t,name:n,meta:N("branch",t?.meta)});return w(e,n,s,a.path?[a.path]:[]),s}function V(e,n,o,r,t){let a=O(e,o),s=O(e,r),p=t?.isApproved??(d=>!!d),T=y([a.node,s.node],(d,i,f)=>{let c=d[0],l=d[1],h=l!=null&&l.length>0?l.at(-1):f.prevData[1];if(h===void 0||!p(h)){i.down([[x]]);return}if(c==null||c.length===0){l!=null&&l.length>0&&f.prevData[0]!==void 0?i.emit(f.prevData[0]):i.down([[x]]);return}for(let g of c)i.emit(g)},{...t,name:n,describeKind:"derived",meta:N("approval",t?.meta)});return w(e,n,T,[a.path,s.path].filter(d=>typeof d=="string")),T}function z(e,n,o,r){let t=r?.maxPending??1/0;if(t<1&&t!==1/0)throw new RangeError("gate: maxPending must be >= 1");let a=r?.startOpen??!1,s=O(e,o),p=K([],{name:"pending",equals:()=>!1}),T=K(a,{name:"isOpen"}),d=E([p],([u])=>u.length,{name:"count"}),i=[],f=!1,c=a,l=T.subscribe(u=>{for(let m of u)m[0]===j&&(c=m[1])});function h(){p.emit([...i])}function g(u){i.push(u),i.length>t&&i.shift(),h()}function R(u){let m=i.splice(0,u);return h(),m}function k(u){if(f)throw new Error(`gate: ${u}() called after gate was torn down`)}let b=y([s.node],(u,m,S)=>{let G=S.terminalDeps[0];if(G!==void 0){f=!0,i=[],h(),m.down(G===!0?[[A]]:[[D,G]]);return}let v=u[0];if(v==null||v.length===0){m.down([[x]]);return}for(let C of v)c?m.emit(C):(g(C),m.down([[x]]))},{name:n,describeKind:"derived",meta:N("gate",r?.meta)}),q={node:b,pending:p,count:d,isOpen:T,approve(u=1){k("approve");let m=R(u);for(let S of m){if(f)break;b.emit(S)}},reject(u=1){k("reject"),R(u)},modify(u,m=1){k("modify");let S=[...i],G=R(m);for(let v=0;v<G.length&&!f;v++)b.emit(u(G[v],v,S))},open(){k("open"),F(()=>{T.emit(!0);let u=R(i.length);for(let m of u){if(f)break;b.emit(m)}})},close(){k("close"),T.emit(!1)}};e.addDisposer(d.subscribe(()=>{})),e.addDisposer(l),w(e,n,b,s.path?[s.path]:[]);let M=new P(`${n}_state`);return M.add(p,{name:"pending"}),M.add(T,{name:"isOpen"}),M.add(d,{name:"count"}),e.mount(`${n}_state`,M),q}function J(e,n,o,r){let t=o.map(s=>O(e,s)),a=E(t.map(s=>s.node),s=>s,{...r,name:n,meta:N("join",r?.meta)});return w(e,n,a,t.flatMap(s=>s.path?[s.path]:[])),a}function Q(e,n,o,r,t){let a=O(e,o),s=t?.iterations,p=typeof s=="number"||s===void 0?void 0:O(e,s),T=typeof s=="number"?s:void 0,d=y(p?[a.node,p.node]:[a.node],(i,f,c)=>{let l=i[0],h=l!=null&&l.length>0?l.at(-1):c.prevData[0],g=p?i[1]:void 0,R=T??(p?g!=null&&g.length>0?g.at(-1):c.prevData[1]:1),k=W(R);for(let b=0;b<k;b+=1)h=r(h,b,f);f.emit(h)},{...t,name:n,describeKind:"derived",meta:N("loop",t?.meta)});return w(e,n,d,[a.path,p?.path].filter(i=>typeof i=="string")),d}function X(e,n,o,r){let t=o instanceof P?o:L(n,r);return typeof o=="function"&&o(t),e.mount(n,t),t}function Y(e,n,o,r){let t=y([],()=>{},{...r,name:n,initial:o,describeKind:"producer",meta:N("sensor",r?.meta)});return w(e,n,t,[]),{node:t,push(a){t.emit(a)},error(a){t.down([[D,a]])},complete(){t.down([[A]])}}}function Z(e,n,o,r,t){let a=O(e,o),s=!1,p=y([],(T,d)=>{let i=a.node.subscribe(f=>{for(let c of f){if(s)return;if(c[0]===D)try{d.emit(r(c[1],d))}catch(l){s=!0,d.down([[D,l]])}else d.down([c]),c[0]===A&&(s=!0)}});return()=>i()},{...t,name:n,describeKind:"derived",completeWhenDepsComplete:!1,errorWhenDepsError:!1,meta:N("onFailure",t?.meta)});return w(e,n,p,a.path?[a.path]:[]),p}export{L as a,H as b,U as c,V as d,z as e,J as f,Q as g,X as h,Y as i,Z as j,ee as k};
@@ -0,0 +1 @@
1
+ import{a as Y,b as m,c as M,d as S,e as C,f as N,g as L,h as k,i as D,j as _,k as P,l as he,n as se,q as ie,r as fe,s as pe,t as _e,u as re}from"./chunk-CK2E7BTU.js";var De={name:"json",version:1,contentType:"application/json",encode(n){let e=JSON.stringify(n);return new TextEncoder().encode(e)},decode(n,e){let t=new TextDecoder().decode(n);return JSON.parse(t)}};function $e(n){return{name:"dag-cbor",version:1,contentType:"application/dag-cbor",encode:e=>n.encode(e),decode:(e,t)=>n.decode(e)}}function je(n,e){return{name:"dag-cbor-zstd",version:1,contentType:"application/dag-cbor+zstd",encode:t=>e.compressSync(n.encode(t)),decode:(t,s)=>n.decode(e.decompressSync(t))}}var oe=1,ge=4;function ze(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 s=n.version;if(!Number.isInteger(s)||s<0||s>65535)throw new Error(`encodeEnvelope: codec.version ${s} out of u16 range (expected integer 0\u201365535)`);let i=2+t.length+2+e.length;if(i>4294967295)throw new Error(`encodeEnvelope: total envelope size ${i} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let r=new Uint8Array(i),a=0;return r[a++]=oe,r[a++]=t.length,r.set(t,a),a+=t.length,r[a++]=s>>>8&255,r[a++]=s&255,r.set(e,a),r}function qe(n,e){if(n.length<ge)throw new Error(`decodeEnvelope: bytes too short (${n.length} < ${ge})`);let t=0,s=n[t++];if(s!==oe)throw new Error(`decodeEnvelope: unsupported envelope version ${s} (expected ${oe})`);let i=n[t++];if(i===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(t+i+2>n.length)throw new Error(`decodeEnvelope: envelope truncated (need ${t+i+2} bytes, have ${n.length})`);let r=new TextDecoder().decode(n.subarray(t,t+i));t+=i;let a=(n[t]<<8|n[t+1])>>>0;t+=2;let o=n.subarray(t),d=e.lookupCodec(r);if(d==null)throw new Error(`decodeEnvelope: codec "${r}" not registered (envelope codec_v=${a})`);return{codec:d,codecVersion:a,payload:o}}function ye(n){n.registerCodec(De)}function Ke(n){if(n.length===0)throw new Error("WAL is empty \u2014 need at least one full snapshot");let e=n[0];if(e.mode!=="full")throw new Error("WAL must start with a full record carrying a baseline snapshot");let t=JSON.parse(JSON.stringify(e.snapshot)),s=e.seq;for(let i=1;i<n.length;i++){let r=n[i];if(r.seq<=s)throw new Error(`WAL chain broken at index ${i}: seq=${r.seq} must exceed prev seq=${s}`);if(r.mode==="full"){t=JSON.parse(JSON.stringify(r.snapshot)),s=r.seq;continue}let a=r.diff;for(let d of a.nodesRemoved)delete t.nodes[d];let o=a.nodesAddedFull;if(o!=null)for(let[d,l]of Object.entries(o))t.nodes[d]=JSON.parse(JSON.stringify(l));for(let d of a.nodesChanged){let l=t.nodes[d.path];l!=null&&(l[d.field]=d.to)}s=r.seq}return t}var Oe={type:"system",id:""};function J(n){if(n==null)return Oe;let{type:e,id:t,...s}=n;return{type:e??"system",id:t??"",...s}}var O=0,U=!1,A=[],E=[],R=[],W=[];function me(){return O>0||U}function be(){return O>0}function ve(n){O>0?W.push(n):n()}function Xe(n){O+=1;let e=!1;try{n()}catch(t){throw e=!0,t}finally{if(O-=1,O===0)if(e){if(!U){let t=W.splice(0);for(let s of t)try{s()}catch{}A.length=0,E.length=0,R.length=0}}else Re()}}function Re(){let n=!U;n&&(U=!0);let e=[],t=0;try{for(;A.length>0||E.length>0||R.length>0||n&&W.length>0;){if(n&&W.length>0){let r=W.splice(0);for(let a of r)try{a()}catch(o){e.push(o)}continue}if(t+=1,t>1e3)throw A.length=0,E.length=0,R.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let i=(A.length>0?A:E.length>0?E:R).splice(0);for(let r of i)try{r()}catch(a){e.push(a)}}}finally{n&&(U=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function X(n,e,t){if(e.length===0)return;if(e.length===1){let l=t(e[0][0]);if(l<3||!me()){n(e);return}(l>=5?R:l===4?E:A).push(()=>n(e));return}let s=e.length,i=s,r=s,a=s,o=0;for(;o<s&&t(e[o][0])<3;)o++;for(i=o;o<s&&t(e[o][0])===3;)o++;for(r=o;o<s&&t(e[o][0])===4;)o++;a=o;let d=me();if(i>0){let l=e.slice(0,i);n(l)}if(r>i){let l=e.slice(i,r);d?A.push(()=>n(l)):n(l)}if(a>r){let l=e.slice(r,a);d?E.push(()=>n(l)):n(l)}if(s>a){let l=e.slice(a,s);d?R.push(()=>n(l)):n(l)}}function Qe(){return Math.trunc(performance.now()*1e6)}function we(){return Date.now()*1e6}var Z=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=t=>{let s=this._messageTypes.get(t);return s!=null?s.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}registerMessageType(e,t){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:t.tier,wireCrossing:t.wireCrossing??t.tier>=3,metaPassthrough:t.metaPassthrough??!0}),this}messageTier(e){let t=this._messageTypes.get(e);return t!=null?t.tier:1}isWireCrossing(e){let t=this._messageTypes.get(e);return t!=null?t.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let t=this._messageTypes.get(e);return t!=null?t.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}};function xe(n){n.registerMessageType(Y,{tier:0,wireCrossing:!1}),n.registerMessageType(M,{tier:1,wireCrossing:!1}),n.registerMessageType(C,{tier:1,wireCrossing:!1,metaPassthrough:!1}),n.registerMessageType(N,{tier:2,wireCrossing:!1}),n.registerMessageType(L,{tier:2,wireCrossing:!1}),n.registerMessageType(m,{tier:3,wireCrossing:!0}),n.registerMessageType(S,{tier:3,wireCrossing:!0}),n.registerMessageType(D,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(_,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(k,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var F=class extends Error{actor;action;nodeName;constructor(e,t){super(t??`GuardDenied: action "${String(e.action)}" denied for actor type "${String(e.actor.type)}"`),this.name="GuardDenied",this.actor=e.actor,this.action=e.action,this.nodeName=e.nodeName}get node(){return this.nodeName}};function Te(n){return Array.isArray(n)?[...n]:[n]}function Fe(n,e){return n.has(e)||n.has("*")}function Ge(n){let e=[];return n((i,r)=>{e.push({kind:"allow",actions:new Set(Te(i)),where:r?.where??(()=>!0)})},(i,r)=>{e.push({kind:"deny",actions:new Set(Te(i)),where:r?.where??(()=>!0)})}),(i,r)=>{let a=!1,o=!1;for(let d of e)Fe(d.actions,r)&&d.where(i)&&(d.kind==="deny"?a=!0:o=!0);return a?!1:o}}function st(n){return Ge((e,t)=>{for(let s of n){let i=s.actorType==null?null:new Set(Array.isArray(s.actorType)?s.actorType:[s.actorType]),r=s.actorId==null?null:new Set(Array.isArray(s.actorId)?s.actorId:[s.actorId]),a=Object.entries(s.claims??{}),o=d=>{if(i!==null&&!i.has(String(d.type))||r!==null&&!r.has(String(d.id??"")))return!1;for(let[l,c]of a)if(d[l]!==c)return!1;return!0};s.effect==="deny"?t(s.action,{where:o}):e(s.action,{where:o})}})}var Ie=["human","llm","wallet","system"];function it(n){let e=Ie.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("+")}function ae(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(ae);if(typeof n=="object"&&n!==null){let e={};for(let t of Object.keys(n).sort())e[t]=ae(n[t]);return e}return null}var He=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]),Ve=new TextEncoder;function Le(n){let e=Ve.encode(n),t=e.length,s=t*8,i=t+9+63&-64,r=new Uint8Array(i);r.set(e),r[t]=128;let a=new DataView(r.buffer);a.setUint32(i-4,s>>>0,!1),a.setUint32(i-8,Math.floor(s/4294967296)>>>0,!1);let o=1779033703,d=3144134277,l=1013904242,c=2773480762,u=1359893119,p=2600822924,h=528734635,b=1541459225,T=new Uint32Array(64),y=(w,g)=>w>>>g|w<<32-g;for(let w=0;w<i;w+=64){for(let f=0;f<16;f++)T[f]=a.getUint32(w+f*4,!1);for(let f=16;f<64;f++){let H=T[f-15],V=T[f-2],K=y(H,7)^y(H,18)^H>>>3,ne=y(V,17)^y(V,19)^V>>>10;T[f]=T[f-16]+K+T[f-7]+ne>>>0}let g=o,G=d,I=l,ee=c,x=u,z=p,q=h,te=b;for(let f=0;f<64;f++){let H=y(x,6)^y(x,11)^y(x,25),V=x&z^~x&q,K=te+H+V+He[f]+T[f]>>>0,ne=y(g,2)^y(g,13)^y(g,22),Se=g&G^g&I^G&I,Ce=ne+Se>>>0;te=q,q=z,z=x,x=ee+K>>>0,ee=I,I=G,G=g,g=K+Ce>>>0}o=o+g>>>0,d=d+G>>>0,l=l+I>>>0,c=c+ee>>>0,u=u+x>>>0,p=p+z>>>0,h=h+q>>>0,b=b+te>>>0}let v=w=>w.toString(16).padStart(8,"0");return v(o)+v(d)+v(l)+v(c)+v(u)+v(p)+v(h)+v(b)}function de(n){let e=ae(n??null),t=JSON.stringify(e);return Le(t).slice(0,16)}function Pe(){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 le(n,e,t){let s=t?.id??Pe();if(n===0)return{id:s,version:0};let r=(t?.hash??de)(e);return{id:s,version:0,cid:r,prev:null}}function Ne(n,e,t){n.version+=1,"cid"in n&&(n.prev=n.cid,n.cid=t(e))}function ot(n){return"cid"in n}var ke=()=>{},Ae=100;function Ee(n){return{node:n,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function ce(n){n.prevData=void 0,n.dirty=!1,n.involvedThisWave=!1,n.dataBatch.length=0,n.terminal=void 0}function Q(n){return n.length===0?n:typeof n[0]=="symbol"?[n]:n}var Ue=(n,e,t,s)=>{t.direction==="down-in"&&n._onDepMessage(t.depIndex,e)},We=(n,e,t,s)=>{let i=n;if(i._status==="completed"||i._status==="errored")return;let r=i._cached,a=r===void 0?[se]:[se,[m,r]];i._status==="dirty"&&a.push(P),X(e,a,i._config.tierOf)},B=new Z({onMessage:Ue,onSubscribe:We});xe(B);ye(B);function gt(n){if(B._isFrozen())throw new Error("configure() called after a node was created \u2014 the default GraphReFlyConfig is frozen. Call configure(...) at application startup, before any node factories run.");n(B)}var $=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,s){this._config=s.config??B,this._config.onMessage,this._optsName=s.name,this._describeKind=s.describeKind,this._equals=s.equals??Object.is,this._resubscribable=s.resubscribable??!1,this._resetOnTeardown=s.resetOnTeardown??!1,this._autoComplete=s.completeWhenDepsComplete??!0,this._autoError=s.errorWhenDepsError??!0,this._pausable=s.pausable??!0,this._guard=s.guard,this._fn=t,this._partial=s.partial??!1,this._cached=s.initial!==void 0?s.initial:void 0,this._status=e.length===0&&t==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=s.versioningHash??this._config.defaultHashFn??de;let i=s.versioning??this._config.defaultVersioning;this._versioningLevel=i,this._versioning=i!=null?le(i,this._cached===void 0?void 0:this._cached,{id:s.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Ee);let r={};for(let[o,d]of Object.entries(s.meta??{})){let l={initial:d,name:`${s.name??"node"}:meta:${o}`,describeKind:"state",config:this._config};s.guard!=null&&(l.guard=s.guard),r[o]=new n([],void 0,l)}Object.freeze(r),this.meta=r,this._hasMeta=Object.keys(r).length>0;let a=this;this._actions={emit(o){a._emit([[m,o]])},down(o){a._emit(Q(o))},up(o){a._emitUp(Q(o))}},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 s=this._versioningLevel;if(s!=null&&e<=s)return;let i=t?.hash??this._hashFn;i!==this._hashFn&&(this._hashFn=i);let r=this._cached===void 0?void 0:this._cached,a=this._versioning,o=a?.id??t?.id,d=a?.version??0,l=le(e,r,{id:o,hash:i});l.version=d,this._versioning=l,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=J(e);if(this._guard!=null&&!this._guard(t,"observe"))return!1;if(this._extraGuards!=null){for(let s of this._extraGuards)if(!s(t,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let t=this._guard!=null||this._extraGuards!=null,s=e?.actor!=null;if(!t&&!s)return;let i=J(e?.actor),r=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(i,r))throw new F({actor:i,action:r,nodeName:this.name});if(this._extraGuards!=null){for(let a of this._extraGuards)if(!a(i,r))throw new F({actor:i,action:r,nodeName:this.name})}this._lastMutation={actor:i,timestamp_ns:we()}}down(e,t){let s=Q(e);s.length!==0&&(this._checkGuard(t),this._emit(s))}emit(e,t){this._checkGuard(t),this._emit([[m,e]])}up(e,t){if(this._deps.length===0)return;let s=Q(e);if(s.length===0)return;this._checkGuard(t);let i=t??{internal:!0};this._validateUpTiers(s);for(let r of this._deps)r.node.up?.(s,i)}_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 s of e){let i=t(s[0]);if(i===3||i===4)throw new Error(`Node "${this.name}": tier-${i} 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 d=J(t);if(!this._guard(d,"observe"))throw new F({actor:d,action:"observe",nodeName:this.name})}let i=this._isTerminal&&this._resubscribable;if(i){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 d of this._deps)ce(d);if(this._partial===!1){for(let d of this._deps)if(d.prevData!==void 0||d.dataBatch.length!==0||d.terminal!==void 0||d.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let r;try{r=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:i},this._actions)}catch(d){throw this._sinkCount-=1,d}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let a=this._isTerminal;if(this._sinkCount===1&&!a)try{this._activate()}catch(d){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof r=="function")try{r()}catch{}throw d}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let o=!1;return()=>{o||(o=!0,this._sinkCount-=1,this._removeSink(e),typeof r=="function"&&r(),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 s=0;s<e;s++){let i=s,r=this._deps[s];r.unsub=ke,r.unsub=r.node.subscribe(a=>{if(r.unsub===null)return;let o=this._config.tierOf,d=!1;for(let l of a)o(l[0])>=3&&(d=!0),this._config.onMessage(this,l,{direction:"down-in",depIndex:i},this._actions);d&&this._maybeRunFnOnSettlement()}),t++}}catch(s){this._deps[t].unsub=null;for(let i=0;i<t;i++){let r=this._deps[i];if(r.unsub!=null){let a=r.unsub;r.unsub=null;try{a()}catch{}ce(r)}}throw this._dirtyDepCount=0,s}}_addDep(e){for(let i=0;i<this._deps.length;i++)if(this._deps[i].node===e)return i;let t=this._deps.length,s=Ee(e);if(this._deps.push(s),this._sinks==null)return t;s.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(ie),s.unsub=ke;try{s.unsub=e.subscribe(i=>{if(s.unsub===null)return;let r=this._config.tierOf,a=!1;for(let o of i)r(o[0])>=3&&(a=!0),this._config.onMessage(this,o,{direction:"down-in",depIndex:t},this._actions);a&&this._maybeRunFnOnSettlement()})}catch(i){throw s.unsub=null,this._deps.pop(),this._dirtyDepCount--,i}return t}_deactivate(e=!1){let t=this._cleanup;if(this._cleanup=void 0,typeof t=="function")try{t()}catch(s){this._emit([[_,this._wrapFnError("cleanup threw",s)]])}else if(t!=null&&typeof t=="object"){let s=t.deactivate;if(typeof s=="function")try{s()}catch(i){this._emit([[_,this._wrapFnError("cleanup.deactivate threw",i)]])}}for(let s of this._deps){if(s.unsub!=null){let i=s.unsub;s.unsub=null;try{i()}catch{}}ce(s)}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 s=this._deps[e],i=t[0];if(this._inspectorHooks!=null){let r={kind:"dep_message",depIndex:e,message:t};for(let a of this._inspectorHooks)a(r)}if(i!==Y){if(i===M){this._depDirtied(s);return}if(i===C){this._depInvalidated(s),this._emit(pe);return}if(i===N||i===L){this._emit([t]);return}if(i===k){this._emit(re);return}if(i===m)this._depSettledAsData(s,t[1]);else if(i===S)this._depSettledAsResolved(s);else if(i===D)this._depSettledAsTerminal(s,!0);else if(i===_)this._depSettledAsTerminal(s,t[1]);else{this._emit([t]);return}if(!this._fn){(i===m||i===S)&&this._emit([t]),(i===D||i===_)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(ie))}_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(fe),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([[_,e.terminal]]);return}this._autoComplete&&this._deps.every(t=>t.terminal!==void 0)&&this._emit(_e)}_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(a){this._emit([[_,this._wrapFnError("cleanup threw",a)]]);return}}else if(e!=null&&typeof e=="object"){let a=e.beforeRun;if(typeof a=="function"){e.beforeRun=void 0;try{a()}catch(o){this._emit([[_,this._wrapFnError("cleanup.beforeRun threw",o)]]);return}}}let t=this._deps.map(a=>a.involvedThisWave?a.dataBatch.length>0?[...a.dataBatch]:[]:void 0),s=this._deps.map(a=>a.prevData);for(let a=0;a<this._deps.length;a++){let o=t[a];o!=null&&o.length>0&&(this._deps[a].prevData=o[o.length-1])}let i=this._deps.map(a=>a.terminal),r={prevData:s,terminalDeps:i,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let a={kind:"run",batchData:t,prevData:s};for(let o of this._inspectorHooks)o(a)}this._isExecutingFn=!0;try{let a=this._fn(t,this._actions,r);if(typeof a=="function")this._cleanup=a;else if(a!=null&&typeof a=="object"){let o=a;(typeof o.beforeRun=="function"||typeof o.deactivate=="function"||typeof o.invalidate=="function")&&(this._cleanup=a)}}catch(a){this._emit([[_,this._wrapFnError("fn threw",a)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>Ae?(this._rerunDepth=0,this._emit([[_,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${Ae} \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 s=t instanceof Error?t.message:String(t);return new Error(`Node "${this.name}": ${e}: ${s}`,{cause:t})}_frameBatch(e){let t=this._config.tierOf;if(e.length===1)return t(e[0][0])===3&&this._status!=="dirty"?[P,e[0]]:e;let s=!0,i=!1,r=!1,a=-1;for(let d of e){let l=t(d[0]);l<a&&(s=!1),l===3&&(i=!0),d[0]===M&&(r=!0),a=l}let o=e;if(!s){let d=e.map((l,c)=>({m:l,i:c,tier:t(l[0])}));d.sort((l,c)=>l.tier-c.tier||l.i-c.i),o=d.map(l=>l.m)}if(i&&!r&&this._status!=="dirty"){let d=0;for(;d<o.length&&t(o[d][0])===0;)d++;return d===0?[P,...o]:[...o.slice(0,d),P,...o.slice(d)]}return o}_emit(e){if(e.length===0)return;for(let o=0;o<e.length;o++){let d=e[o];if(d[0]===_&&d[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 o=e.filter(d=>d[0]===k||d[0]===C);if(o.length===0)return;t=o}t=this._frameBatch(t);let i=null;for(let o=0;o<t.length;o++){let d=t[o],l=d[0];if(l!==N&&l!==L){i?.push(d);continue}if(d.length<2)throw new Error(`Node "${this.name}": [[${l===N?"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 u=d[1];if(l===N)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(u),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(u))c=!1;else if(this._pauseLocks.delete(u),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?i?.push(d):i==null&&(i=t.slice(0,o))}if(i!=null){if(i.length===0)return;t=i}if(this._hasMeta&&t.some(o=>o[0]===k))for(let o of Object.keys(this.meta))try{this.meta[o]._emit(re)}catch{}let{finalMessages:r,equalsError:a}=this._updateState(t);if(r.length>0&&this._config.inspectorEnabled){let o=this._config.globalInspector;if(o!=null)try{o({kind:"emit",node:this,messages:r})}catch{}}if(r.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let o=this._config.tierOf,d=[];for(let l of r)o(l[0])===3?this._pauseBuffer.push(l):d.push(l);d.length>0&&this._dispatchOrAccumulate(d)}else this._dispatchOrAccumulate(r);a!=null&&this._emit([[_,a]])}_updateState(e){let t=this._config.tierOf,s,i,r=-1,a=0;for(let c of e)t(c[0])===3&&a++;let o=a<=1,d=-1;if(this._versioning!=null&&a>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===m){d=c;break}}for(let c=0;c<e.length;c++){let u=e[c],p=u[0];if(p===m){if(u.length>=2){let h=!1;if(o&&this._cached!==void 0)try{h=this._equals(this._cached,u[1])}catch(b){i=this._wrapFnError("equals threw",b),r=c;break}if(h){s==null&&(s=e.slice(0,c)),s.push(he),this._status="resolved";continue}this._cached=u[1],this._versioning!=null&&(d<0||c===d)&&Ne(this._versioning,u[1],this._hashFn)}this._status="settled",s?.push(u)}else if(s?.push(u),p===M)this._status="dirty";else if(p===S)this._status="resolved";else if(p===D)this._status="completed";else if(p===_)this._status="errored";else if(p===C){this._cached=void 0,this._status="dirty";let h=this._cleanup;if(typeof h=="function"){this._cleanup=void 0;try{h()}catch{}}else if(h!=null&&typeof h=="object"){let b=h.invalidate;if(typeof b=="function")try{b()}catch{}}}else p===k&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let l=r>=0?s??e.slice(0,r):s??e;return i!=null?{finalMessages:l,equalsError:i}:{finalMessages:l}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let t=[...this._sinks];for(let s of t)s(e)};_dispatchOrAccumulate(e){if(be()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],ve(()=>this._flushBatchPending()));for(let t of e)this._batchPendingMessages.push(t);return}X(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);X(this._deliverToSinks,t,this._config.tierOf)}},Me=n=>Array.isArray(n),ue=n=>typeof n=="object"&&n!=null&&!Array.isArray(n);function j(n,e,t){let s=Me(n)?n:[],i=typeof n=="function"?n:typeof e=="function"?e:void 0,r={};return Me(n)?r=(ue(e)?e:t)??{}:ue(n)?r=n:r=(ue(e)?e:t)??{},new $(s,i,r)}function bt(n,e){return j([],{...e,initial:n})}function vt(n,e){return j((s,i,r)=>n(i,r)??void 0,{describeKind:"producer",...e})}function Be(n,e,t){return j(n,(i,r,a)=>{let o=i.map((d,l)=>d!=null&&d.length>0?d.at(-1):a.prevData[l]);r.emit(e(o,a))},{describeKind:"derived",...t})}function wt(n,e,t){return j(n,(i,r,a)=>{let o=i.map((d,l)=>d!=null&&d.length>0?d.at(-1):a.prevData[l]);return e(o,r,a)??void 0},{describeKind:"effect",...t})}function xt(n,e,t){let s=new Map;return n.forEach((i,r)=>{s.set(i,r)}),Be(n,(i,r)=>e(o=>{let d=s.get(o);if(d==null)throw new Error(`dynamicNode: untracked dep "${o.name??"<unnamed>"}"`);return i[d]},r),t)}function Tt(n,e){let t,s=new Map,i=(r,a,o)=>{let d=!1,l=c=>{let u=s.get(c);if(u!==void 0){if(u<r.length){let h=r[u];return h!=null&&h.length>0?h.at(-1):o.prevData[u]}return c.cache}d=!0;let p=t._addDep(c);return s.set(c,p),c.cache};try{let c=n(l,o);d||(a.emit(c),o.store.__autoTrackLastDiscoveryError!=null&&delete o.store.__autoTrackLastDiscoveryError)}catch(c){if(!d)throw c;o.store.__autoTrackLastDiscoveryError=c}};return t=new $([],i,{describeKind:"derived",...e}),t}function Nt(n,...e){let t=n;for(let s of e)t=s(t);return t}export{De as a,$e as b,je as c,oe as d,ze as e,qe as f,ye as g,Ke as h,Oe as i,J as j,me as k,ve as l,Xe as m,X as n,Qe as o,we as p,Z as q,xe as r,F as s,Ge as t,st as u,it as v,de as w,le as x,Ne as y,ot as z,B as A,gt as B,$ as C,j as D,bt as E,vt as F,Be as G,wt as H,xt as I,Tt as J,Nt as K};
@@ -1,3 +1,3 @@
1
- import{e as O}from"./chunk-DBGGMN3D.js";import{j as ce}from"./chunk-CKCSDI7T.js";import{v as ue}from"./chunk-Z4HDAS2Q.js";import{D as le,E as p,G as N,H as G,m as L,o as A}from"./chunk-ZB5EHBIO.js";import{b as P,j as Q}from"./chunk-CK2E7BTU.js";import{b as pe}from"./chunk-QYADASLV.js";var Se={};pe(Se,{blindVariation:()=>ke,errorCritique:()=>Ie,refineLoop:()=>Ee});function ve(n){if(typeof n!="object"||n===null)return!1;let l=n;return typeof l.subscribe=="function"&&typeof l.down=="function"&&typeof l.emit=="function"}function me(n,l){if(n.length===0)return{best:null,bestScore:Number.NEGATIVE_INFINITY};if(n.length===1){let e=X(l);return{best:n[0],bestScore:e}}if(l.some(e=>typeof e.candidateIndex=="number")){let e=new Array(n.length);for(let i=0;i<n.length;i++)e[i]={sum:0,count:0};for(let i of l){let d=i.candidateIndex;typeof d=="number"&&d>=0&&d<n.length&&(e[d].sum+=i.score,e[d].count+=1)}let s=n[0],o=e[0].count>0?e[0].sum/e[0].count:Number.NEGATIVE_INFINITY;for(let i=1;i<n.length;i++){let d=e[i].count>0?e[i].sum/e[i].count:Number.NEGATIVE_INFINITY;d>o&&(o=d,s=n[i])}return{best:s,bestScore:o}}let t=n[0],m=l[0]?.score??Number.NEGATIVE_INFINITY;for(let e=1;e<n.length;e++){let s=l[e]?.score??Number.NEGATIVE_INFINITY;s>m&&(m=s,t=n[e])}return{best:t,bestScore:m}}function X(n){if(n.length===0)return Number.NEGATIVE_INFINITY;let l=0;for(let k of n)l+=k.score;return l/n.length}function Ee(n,l,k,t){let m=t.name??"refine-loop",e=new ce(m,t.graph),s=ve(t.dataset)?t.dataset:p(t.dataset,{name:"dataset"});e.add(s,{name:"dataset"});let o=p(0,{name:"iteration"});e.add(o,{name:"iteration"});let i=p(k,{name:"strategy",equals:()=>!1});e.add(i,{name:"strategy"});let d=p(null,{name:"lastFeedback"});e.add(d,{name:"lastFeedback"});let E=p([],{name:"prevCandidates"});e.add(E,{name:"prevCandidates"});let g=p(!1,{name:"paused"});e.add(g,{name:"paused"});let b=p("running",{name:"status"});e.add(b,{name:"status"});let v=p([],{name:"history",equals:()=>!1});e.add(v,{name:"history"});let T=p(null,{name:"best"});e.add(T,{name:"best"});let x=p(Number.NEGATIVE_INFINITY,{name:"score"});e.add(x,{name:"score"});let R=p(0,{name:"budget-used"});e.add(R,{name:"budget-used"});let _=O("GENERATE"),V=O("EVALUATE"),f=O("ANALYZE"),F=O("DECIDE");e.mount("GENERATE",_),e.mount("EVALUATE",V),e.mount("ANALYZE",f),e.mount("DECIDE",F);let Y=k,B=null,ee=[];e.addDisposer(i.subscribe(r=>{for(let a of r)a[0]===P&&(Y=a[1])})),e.addDisposer(d.subscribe(r=>{for(let a of r)a[0]===P&&(B=a[1])})),e.addDisposer(E.subscribe(r=>{for(let a of r)a[0]===P&&(ee=a[1])}));let I=ue(o,r=>{let a=Y,c=r===0||B==null;return le([],(u,y)=>{let S=!1;try{let C=c?a.seed(n):a.generate(B,ee);if(C instanceof Promise)return C.then(q=>{S||y.emit(q)},q=>{S||y.down([[Q,q]])}),()=>{S=!0};y.emit(C)}catch(C){S=!0,y.down([[Q,C]])}},{describeKind:"producer"})},{name:"candidates"});e.add(I,{name:"candidates"});let ne=G([I],(r,a,c)=>{let u=c.terminalDeps[0];u!==void 0&&u!==!0&&b.emit("errored")},{name:"error-watcher",errorWhenDepsError:!1});e.add(ne,{name:"error-watcher"}),e.addDisposer(ne.subscribe(()=>{}));let te=G([I,o],([r,a])=>{let c=r,u=a;L(()=>{_.publish({iteration:u,candidates:c,timestamp_ns:A()}),E.emit(c)})},{name:"generate-bridge"});e.add(te,{name:"generate-bridge"}),e.addDisposer(te.subscribe(()=>{}));let $=l(I,s);e.add($,{name:"scores"});let re=G([$,I,o],([r,a,c])=>{V.publish({iteration:c,candidates:a,scores:r,timestamp_ns:A()})},{name:"evaluate-bridge"});e.add(re,{name:"evaluate-bridge"}),e.addDisposer(re.subscribe(()=>{}));let j=N([$,I],([r,a])=>Y.analyze(r,a),{name:"feedback"});e.add(j,{name:"feedback"});let ae=G([j,I,o],([r,a,c])=>{f.publish({iteration:c,candidates:a,feedback:r,timestamp_ns:A()})},{name:"analyze-bridge"});e.add(ae,{name:"analyze-bridge"}),e.addDisposer(ae.subscribe(()=>{}));let M=N([v],([r])=>{let a=r;if(t.patience==null||a.length<=t.patience)return!1;let c=a.slice(-(t.patience+1)),u=c[0].bestScore;return c.slice(1).every(y=>y.bestScore<=u)},{name:"patience-check"});e.add(M,{name:"patience-check"});let U=N([x],([r])=>t.minScore!=null&&r>=t.minScore,{name:"min-score-check"});e.add(U,{name:"min-score-check"});let H=N([v],([r])=>{let a=r;if(t.minDelta==null||a.length<2)return!1;let c=a[a.length-2].bestScore,u=a[a.length-1].bestScore;return Math.abs(u-c)<t.minDelta},{name:"min-delta-check"});e.add(H,{name:"min-delta-check"});let W=N([R],([r])=>t.maxEvaluations!=null&&r>=t.maxEvaluations,{name:"max-evaluations-check"});e.add(W,{name:"max-evaluations-check"});let Z=N([o],([r])=>t.maxIterations!=null&&r>=t.maxIterations,{name:"max-iterations-check"});e.add(Z,{name:"max-iterations-check"});let oe=N([R],([r])=>t.budget!=null&&r>=t.budget,{name:"budget-exhausted-check"});e.add(oe,{name:"budget-exhausted-check"}),e.addDisposer(M.subscribe(()=>{})),e.addDisposer(U.subscribe(()=>{})),e.addDisposer(H.subscribe(()=>{})),e.addDisposer(W.subscribe(()=>{})),e.addDisposer(Z.subscribe(()=>{})),e.addDisposer(oe.subscribe(()=>{}));let ie=N([M,U,H,W,Z],([r,a,c,u,y])=>r?{converged:!0,reason:"patience"}:a?{converged:!0,reason:"min-score"}:c?{converged:!0,reason:"min-delta"}:u?{converged:!0,reason:"max-evaluations"}:y?{converged:!0,reason:"max-iterations"}:{converged:!1},{name:"converged"});e.add(ie,{name:"converged"}),e.addDisposer(ie.subscribe(()=>{}));let se=-1,de=G([j,$,I],([r,a,c])=>{let u=o.cache,y=r,S=c,C=a;if(u<=se)return;se=u;let{best:q,bestScore:be}=me(S,C),fe=v.cache,ye={n:u,candidates:S,scores:C,feedback:y,best:q,bestScore:be,timestamp_ns:A()},D=[...fe,ye],K=R.cache+S.length,h="continue",w,ge=t.budget!=null&&K>=t.budget,Te=g.cache;if(ge)h="budget",w="budget";else if(t.minScore!=null&&y.score>=t.minScore)h="converged",w="min-score";else if(t.maxIterations!=null&&u>=t.maxIterations)h="converged",w="max-iterations";else if(t.maxEvaluations!=null&&K>=t.maxEvaluations)h="converged",w="max-evaluations";else if(t.minDelta!=null&&D.length>=2){let z=D[D.length-2].bestScore,J=D[D.length-1].bestScore;Math.abs(J-z)<t.minDelta&&(h="converged",w="min-delta")}else if(t.patience!=null&&D.length>t.patience){let z=D.slice(-(t.patience+1)),J=z[0].bestScore;z.slice(1).every(he=>he.bestScore<=J)&&(h="converged",w="patience")}h==="continue"&&Te&&(h="paused"),L(()=>{T.emit(q),x.emit(y.score),v.emit(D),R.emit(K),d.emit(y),F.publish({iteration:u,decision:h,reason:w,timestamp_ns:A()}),h==="continue"?o.emit(u+1):b.emit(h==="converged"?"converged":h==="budget"?"budget":"paused")})},{name:"decide-bridge"});return e.add(de,{name:"decide-bridge"}),e.addDisposer(de.subscribe(()=>{})),Object.assign(e,{best:T,score:x,status:b,history:v,strategy:i,iteration:o,generate:_,evaluate:V,analyze:f,decide:F,setStrategy(r){i.emit(r)},pause(){g.emit(!0)},resume(){b.cache==="paused"&&L(()=>{g.emit(!1),b.emit("running"),o.emit(o.cache+1)})}})}function ke(n){let l=n.width??4;return{name:n.name??"blindVariation",seed(t){return[t]},analyze(t,m){let e=X(t),s=null;for(let o of t)(!s||o.score<s.score)&&(s=o);return{summary:`blindVariation iteration: mean=${e.toFixed(3)}, n=${t.length}`,score:e,weakTasks:s?[s.taskId]:[]}},async generate(t,m){if(m.length===0)throw new Error("blindVariation.generate: empty candidate batch \u2014 cannot derive prior for teacher");let e=m[m.length-1],s=0,i={prior:e,reportCost:d=>{s+=d}};try{if(n.parallel!==!1)return await Promise.all(Array.from({length:l},()=>n.teacher(i)));let d=[];for(let E=0;E<l;E++)d.push(await n.teacher(i));return d}finally{if(n.tokens!=null&&s>0){let d=n.tokens.cache??0;n.tokens.emit(d+s)}}}}}function xe(n){return typeof n=="object"&&n!==null&&n.kind==="errorCritique"}function Ne(n,l){return n.length===0?`No task scored below the batch mean (${l.score.toFixed(3)}). Reinforce the current direction.`:`Failures below threshold:
1
+ import{e as O}from"./chunk-Y53B6NS4.js";import{k as ce}from"./chunk-MGKAO4EK.js";import{v as ue}from"./chunk-5JDE5JHE.js";import{D as le,E as p,G as N,H as G,m as L,o as A}from"./chunk-W4TSQ6RJ.js";import{b as P,j as Q}from"./chunk-CK2E7BTU.js";import{b as pe}from"./chunk-QYADASLV.js";var Se={};pe(Se,{blindVariation:()=>ke,errorCritique:()=>Ie,refineLoop:()=>Ee});function ve(n){if(typeof n!="object"||n===null)return!1;let l=n;return typeof l.subscribe=="function"&&typeof l.down=="function"&&typeof l.emit=="function"}function me(n,l){if(n.length===0)return{best:null,bestScore:Number.NEGATIVE_INFINITY};if(n.length===1){let e=X(l);return{best:n[0],bestScore:e}}if(l.some(e=>typeof e.candidateIndex=="number")){let e=new Array(n.length);for(let i=0;i<n.length;i++)e[i]={sum:0,count:0};for(let i of l){let d=i.candidateIndex;typeof d=="number"&&d>=0&&d<n.length&&(e[d].sum+=i.score,e[d].count+=1)}let s=n[0],o=e[0].count>0?e[0].sum/e[0].count:Number.NEGATIVE_INFINITY;for(let i=1;i<n.length;i++){let d=e[i].count>0?e[i].sum/e[i].count:Number.NEGATIVE_INFINITY;d>o&&(o=d,s=n[i])}return{best:s,bestScore:o}}let t=n[0],m=l[0]?.score??Number.NEGATIVE_INFINITY;for(let e=1;e<n.length;e++){let s=l[e]?.score??Number.NEGATIVE_INFINITY;s>m&&(m=s,t=n[e])}return{best:t,bestScore:m}}function X(n){if(n.length===0)return Number.NEGATIVE_INFINITY;let l=0;for(let k of n)l+=k.score;return l/n.length}function Ee(n,l,k,t){let m=t.name??"refine-loop",e=new ce(m,t.graph),s=ve(t.dataset)?t.dataset:p(t.dataset,{name:"dataset"});e.add(s,{name:"dataset"});let o=p(0,{name:"iteration"});e.add(o,{name:"iteration"});let i=p(k,{name:"strategy",equals:()=>!1});e.add(i,{name:"strategy"});let d=p(null,{name:"lastFeedback"});e.add(d,{name:"lastFeedback"});let E=p([],{name:"prevCandidates"});e.add(E,{name:"prevCandidates"});let g=p(!1,{name:"paused"});e.add(g,{name:"paused"});let b=p("running",{name:"status"});e.add(b,{name:"status"});let v=p([],{name:"history",equals:()=>!1});e.add(v,{name:"history"});let T=p(null,{name:"best"});e.add(T,{name:"best"});let x=p(Number.NEGATIVE_INFINITY,{name:"score"});e.add(x,{name:"score"});let R=p(0,{name:"budget-used"});e.add(R,{name:"budget-used"});let _=O("GENERATE"),V=O("EVALUATE"),f=O("ANALYZE"),F=O("DECIDE");e.mount("GENERATE",_),e.mount("EVALUATE",V),e.mount("ANALYZE",f),e.mount("DECIDE",F);let Y=k,B=null,ee=[];e.addDisposer(i.subscribe(r=>{for(let a of r)a[0]===P&&(Y=a[1])})),e.addDisposer(d.subscribe(r=>{for(let a of r)a[0]===P&&(B=a[1])})),e.addDisposer(E.subscribe(r=>{for(let a of r)a[0]===P&&(ee=a[1])}));let I=ue(o,r=>{let a=Y,c=r===0||B==null;return le([],(u,y)=>{let S=!1;try{let C=c?a.seed(n):a.generate(B,ee);if(C instanceof Promise)return C.then(q=>{S||y.emit(q)},q=>{S||y.down([[Q,q]])}),()=>{S=!0};y.emit(C)}catch(C){S=!0,y.down([[Q,C]])}},{describeKind:"producer"})},{name:"candidates"});e.add(I,{name:"candidates"});let ne=G([I],(r,a,c)=>{let u=c.terminalDeps[0];u!==void 0&&u!==!0&&b.emit("errored")},{name:"error-watcher",errorWhenDepsError:!1});e.add(ne,{name:"error-watcher"}),e.addDisposer(ne.subscribe(()=>{}));let te=G([I,o],([r,a])=>{let c=r,u=a;L(()=>{_.publish({iteration:u,candidates:c,timestamp_ns:A()}),E.emit(c)})},{name:"generate-bridge"});e.add(te,{name:"generate-bridge"}),e.addDisposer(te.subscribe(()=>{}));let $=l(I,s);e.add($,{name:"scores"});let re=G([$,I,o],([r,a,c])=>{V.publish({iteration:c,candidates:a,scores:r,timestamp_ns:A()})},{name:"evaluate-bridge"});e.add(re,{name:"evaluate-bridge"}),e.addDisposer(re.subscribe(()=>{}));let j=N([$,I],([r,a])=>Y.analyze(r,a),{name:"feedback"});e.add(j,{name:"feedback"});let ae=G([j,I,o],([r,a,c])=>{f.publish({iteration:c,candidates:a,feedback:r,timestamp_ns:A()})},{name:"analyze-bridge"});e.add(ae,{name:"analyze-bridge"}),e.addDisposer(ae.subscribe(()=>{}));let M=N([v],([r])=>{let a=r;if(t.patience==null||a.length<=t.patience)return!1;let c=a.slice(-(t.patience+1)),u=c[0].bestScore;return c.slice(1).every(y=>y.bestScore<=u)},{name:"patience-check"});e.add(M,{name:"patience-check"});let U=N([x],([r])=>t.minScore!=null&&r>=t.minScore,{name:"min-score-check"});e.add(U,{name:"min-score-check"});let H=N([v],([r])=>{let a=r;if(t.minDelta==null||a.length<2)return!1;let c=a[a.length-2].bestScore,u=a[a.length-1].bestScore;return Math.abs(u-c)<t.minDelta},{name:"min-delta-check"});e.add(H,{name:"min-delta-check"});let W=N([R],([r])=>t.maxEvaluations!=null&&r>=t.maxEvaluations,{name:"max-evaluations-check"});e.add(W,{name:"max-evaluations-check"});let Z=N([o],([r])=>t.maxIterations!=null&&r>=t.maxIterations,{name:"max-iterations-check"});e.add(Z,{name:"max-iterations-check"});let oe=N([R],([r])=>t.budget!=null&&r>=t.budget,{name:"budget-exhausted-check"});e.add(oe,{name:"budget-exhausted-check"}),e.addDisposer(M.subscribe(()=>{})),e.addDisposer(U.subscribe(()=>{})),e.addDisposer(H.subscribe(()=>{})),e.addDisposer(W.subscribe(()=>{})),e.addDisposer(Z.subscribe(()=>{})),e.addDisposer(oe.subscribe(()=>{}));let ie=N([M,U,H,W,Z],([r,a,c,u,y])=>r?{converged:!0,reason:"patience"}:a?{converged:!0,reason:"min-score"}:c?{converged:!0,reason:"min-delta"}:u?{converged:!0,reason:"max-evaluations"}:y?{converged:!0,reason:"max-iterations"}:{converged:!1},{name:"converged"});e.add(ie,{name:"converged"}),e.addDisposer(ie.subscribe(()=>{}));let se=-1,de=G([j,$,I],([r,a,c])=>{let u=o.cache,y=r,S=c,C=a;if(u<=se)return;se=u;let{best:q,bestScore:be}=me(S,C),fe=v.cache,ye={n:u,candidates:S,scores:C,feedback:y,best:q,bestScore:be,timestamp_ns:A()},D=[...fe,ye],K=R.cache+S.length,h="continue",w,ge=t.budget!=null&&K>=t.budget,Te=g.cache;if(ge)h="budget",w="budget";else if(t.minScore!=null&&y.score>=t.minScore)h="converged",w="min-score";else if(t.maxIterations!=null&&u>=t.maxIterations)h="converged",w="max-iterations";else if(t.maxEvaluations!=null&&K>=t.maxEvaluations)h="converged",w="max-evaluations";else if(t.minDelta!=null&&D.length>=2){let z=D[D.length-2].bestScore,J=D[D.length-1].bestScore;Math.abs(J-z)<t.minDelta&&(h="converged",w="min-delta")}else if(t.patience!=null&&D.length>t.patience){let z=D.slice(-(t.patience+1)),J=z[0].bestScore;z.slice(1).every(he=>he.bestScore<=J)&&(h="converged",w="patience")}h==="continue"&&Te&&(h="paused"),L(()=>{T.emit(q),x.emit(y.score),v.emit(D),R.emit(K),d.emit(y),F.publish({iteration:u,decision:h,reason:w,timestamp_ns:A()}),h==="continue"?o.emit(u+1):b.emit(h==="converged"?"converged":h==="budget"?"budget":"paused")})},{name:"decide-bridge"});return e.add(de,{name:"decide-bridge"}),e.addDisposer(de.subscribe(()=>{})),Object.assign(e,{best:T,score:x,status:b,history:v,strategy:i,iteration:o,generate:_,evaluate:V,analyze:f,decide:F,setStrategy(r){i.emit(r)},pause(){g.emit(!0)},resume(){b.cache==="paused"&&L(()=>{g.emit(!1),b.emit("running"),o.emit(o.cache+1)})}})}function ke(n){let l=n.width??4;return{name:n.name??"blindVariation",seed(t){return[t]},analyze(t,m){let e=X(t),s=null;for(let o of t)(!s||o.score<s.score)&&(s=o);return{summary:`blindVariation iteration: mean=${e.toFixed(3)}, n=${t.length}`,score:e,weakTasks:s?[s.taskId]:[]}},async generate(t,m){if(m.length===0)throw new Error("blindVariation.generate: empty candidate batch \u2014 cannot derive prior for teacher");let e=m[m.length-1],s=0,i={prior:e,reportCost:d=>{s+=d}};try{if(n.parallel!==!1)return await Promise.all(Array.from({length:l},()=>n.teacher(i)));let d=[];for(let E=0;E<l;E++)d.push(await n.teacher(i));return d}finally{if(n.tokens!=null&&s>0){let d=n.tokens.cache??0;n.tokens.emit(d+s)}}}}}function xe(n){return typeof n=="object"&&n!==null&&n.kind==="errorCritique"}function Ne(n,l){return n.length===0?`No task scored below the batch mean (${l.score.toFixed(3)}). Reinforce the current direction.`:`Failures below threshold:
2
2
  ${n.map(t=>{let m=t.error!=null?` | error: ${t.error}`:"";return`- ${t.taskId} (score=${t.score.toFixed(3)})${m}`}).join(`
3
3
  `)}`}function Ie(n){let l=n.width??4,k=n.name??"errorCritique",t=n.maxFailureSamples??5,m=n.formatCritique??Ne;return{name:k,seed(e){return[e]},analyze(e,s){let o=X(e),i=typeof n.failureThreshold=="function"?n.failureThreshold(e):n.failureThreshold,d=i===void 0&&!Number.isFinite(o),E=i??o,g=d?[...e].sort((f,F)=>f.score-F.score):e.filter(f=>f.score<E).slice().sort((f,F)=>f.score-F.score),b=g.slice(0,t),{best:v,bestScore:T}=me(s,e),x={summary:"",score:o,weakTasks:b.map(f=>f.taskId)},R=m(b,x),_={kind:"errorCritique",best:v,failures:b,critiqueText:R},V=g.length>b.length?` (top ${b.length} retained)`:"";return{summary:`errorCritique iteration: mean=${o.toFixed(3)}, failures=${g.length}${V}/${e.length}, bestScore=${T.toFixed(3)}`,critique:_,weakTasks:b.map(f=>f.taskId),score:o}},async generate(e,s){if(s.length===0)throw new Error("errorCritique.generate: empty candidate batch \u2014 cannot derive prior for teacher");let o=xe(e.critique)?e.critique:void 0,i=o!==void 0?o.best:s[s.length-1],d=o?.critiqueText??e.summary,E=o?.failures??[],g=0,v={prior:i,critique:d,failures:E,reportCost:T=>{g+=T}};try{if(n.parallel!==!1)return await Promise.all(Array.from({length:l},()=>n.teacher(v)));let T=[];for(let x=0;x<l;x++)T.push(await n.teacher(v));return T}finally{if(n.tokens!=null&&g>0){let T=n.tokens.cache??0;n.tokens.emit(T+g)}}}}}export{Ee as a,ke as b,Ie as c,Se as d};
@@ -1 +1 @@
1
- import{a as w}from"./chunk-VPYBOXVT.js";import{A as b,B as F,C as H,D as G,E as k,F as B,G as Y,H as h,I as v,J as P,K as W,i as K,j,k as S,m as g,n as C,o as I,p as M,q as _,r as u,s as q,t as z,u as J,v as Q,w as L,x as m,y as x,z as V}from"./chunk-ZB5EHBIO.js";import{a as e,b as t,c as o,d as p,e as r,f as n,g as s,h as i,i as y,j as a,k as d,l as c,m as N,n as T,o as E,p as O,q as D,r as A,s as f,t as l,u as R}from"./chunk-CK2E7BTU.js";import{b as U}from"./chunk-QYADASLV.js";var X={};U(X,{COMPLETE:()=>y,COMPLETE_MSG:()=>E,COMPLETE_ONLY_BATCH:()=>l,DATA:()=>t,DEFAULT_ACTOR:()=>K,DIRTY:()=>o,DIRTY_MSG:()=>d,DIRTY_ONLY_BATCH:()=>D,ERROR:()=>a,GraphReFlyConfig:()=>_,GuardDenied:()=>q,INVALIDATE:()=>r,INVALIDATE_MSG:()=>N,INVALIDATE_ONLY_BATCH:()=>f,NodeImpl:()=>H,PAUSE:()=>n,RESOLVED:()=>p,RESOLVED_MSG:()=>c,RESOLVED_ONLY_BATCH:()=>A,RESUME:()=>s,START:()=>e,START_MSG:()=>T,TEARDOWN:()=>i,TEARDOWN_MSG:()=>O,TEARDOWN_ONLY_BATCH:()=>R,accessHintForGuard:()=>Q,advanceVersion:()=>x,autoTrackNode:()=>P,batch:()=>g,configure:()=>F,createVersioning:()=>m,defaultConfig:()=>b,defaultHash:()=>L,derived:()=>Y,downWithBatch:()=>C,dynamicNode:()=>v,effect:()=>h,isBatching:()=>S,isV1:()=>V,monotonicNs:()=>I,node:()=>G,normalizeActor:()=>j,pipe:()=>W,policy:()=>z,policyFromRules:()=>J,producer:()=>B,registerBuiltins:()=>u,resolveDescribeFields:()=>w,state:()=>k,wallClockNs:()=>M});export{X as a};
1
+ import{a as w}from"./chunk-TWMEGG45.js";import{A as b,B as F,C as H,D as G,E as k,F as B,G as Y,H as h,I as v,J as P,K as W,i as K,j,k as S,m as g,n as C,o as I,p as M,q as _,r as u,s as q,t as z,u as J,v as Q,w as L,x as m,y as x,z as V}from"./chunk-W4TSQ6RJ.js";import{a as e,b as t,c as o,d as p,e as r,f as n,g as s,h as i,i as y,j as a,k as d,l as c,m as N,n as T,o as E,p as O,q as D,r as A,s as f,t as l,u as R}from"./chunk-CK2E7BTU.js";import{b as U}from"./chunk-QYADASLV.js";var X={};U(X,{COMPLETE:()=>y,COMPLETE_MSG:()=>E,COMPLETE_ONLY_BATCH:()=>l,DATA:()=>t,DEFAULT_ACTOR:()=>K,DIRTY:()=>o,DIRTY_MSG:()=>d,DIRTY_ONLY_BATCH:()=>D,ERROR:()=>a,GraphReFlyConfig:()=>_,GuardDenied:()=>q,INVALIDATE:()=>r,INVALIDATE_MSG:()=>N,INVALIDATE_ONLY_BATCH:()=>f,NodeImpl:()=>H,PAUSE:()=>n,RESOLVED:()=>p,RESOLVED_MSG:()=>c,RESOLVED_ONLY_BATCH:()=>A,RESUME:()=>s,START:()=>e,START_MSG:()=>T,TEARDOWN:()=>i,TEARDOWN_MSG:()=>O,TEARDOWN_ONLY_BATCH:()=>R,accessHintForGuard:()=>Q,advanceVersion:()=>x,autoTrackNode:()=>P,batch:()=>g,configure:()=>F,createVersioning:()=>m,defaultConfig:()=>b,defaultHash:()=>L,derived:()=>Y,downWithBatch:()=>C,dynamicNode:()=>v,effect:()=>h,isBatching:()=>S,isV1:()=>V,monotonicNs:()=>I,node:()=>G,normalizeActor:()=>j,pipe:()=>W,policy:()=>z,policyFromRules:()=>J,producer:()=>B,registerBuiltins:()=>u,resolveDescribeFields:()=>w,state:()=>k,wallClockNs:()=>M});export{X as a};
@@ -1 +1 @@
1
- import{c as k}from"./chunk-ETWTCCJI.js";import{j as h}from"./chunk-CKCSDI7T.js";import{b as I}from"./chunk-D7A7DBE4.js";import{A as p}from"./chunk-2PMCKKRK.js";import{D as w,E as f,G as d,m as x}from"./chunk-ZB5EHBIO.js";import{i as y}from"./chunk-CK2E7BTU.js";import{b as M}from"./chunk-QYADASLV.js";var C={};M(C,{MessagingHubGraph:()=>v,SubscriptionGraph:()=>T,TopicBridgeGraph:()=>g,TopicGraph:()=>l,messagingHub:()=>L,subscription:()=>G,topic:()=>P,topicBridge:()=>S});var N=2147483647;function m(n,t){if(!Number.isFinite(n)||!Number.isInteger(n)||n<0)throw new Error(`${t} must be a non-negative integer`);return n}function o(n,t){return k("messaging",n,t)}var l=class extends h{_log;events;latest;hasLatest;constructor(t,e={}){super(t,e.graph),this._log=I([],{name:"events",maxSize:e.retainedLimit}),this.events=this._log.entries,this.add(this.events,{name:"events"}),this.latest=d([this.events],([i])=>{let s=i;return s.length===0?null:s[s.length-1]},{name:"latest",describeKind:"derived",meta:o("topic_latest")}),this.add(this.latest,{name:"latest"}),this.addDisposer(p(this.latest)),this.hasLatest=d([this.events],([i])=>i.length>0,{name:"hasLatest",describeKind:"derived",meta:o("topic_has_latest")}),this.add(this.hasLatest,{name:"hasLatest"}),this.addDisposer(p(this.hasLatest)),this.addDisposer(()=>{this.events.down([[y]])}),this.addDisposer(()=>this._log.disposeAllViews())}publish(t){this._log.append(t)}retained(){return this.events.cache}},T=class extends h{source;cursor;available;topic;constructor(t,e,i={}){super(t,i.graph);let s=m(i.cursor??0,"subscription cursor");this.topic=e;let r=e.events;this.source=d([r],([u])=>u,{name:"source",describeKind:"derived",meta:o("subscription_source"),initial:r.cache}),this.add(this.source,{name:"source"}),this.cursor=f(s,{name:"cursor",describeKind:"state",meta:o("subscription_cursor")}),this.add(this.cursor,{name:"cursor"}),this.available=d([this.source,this.cursor],([u,b])=>{let a=u,c=Math.max(0,Math.trunc(b??0));return a.slice(c)},{name:"available",describeKind:"derived",meta:o("subscription_available"),initial:[]}),this.add(this.available,{name:"available"}),this.addDisposer(p(this.source)),this.addDisposer(p(this.available))}ack(t){let e=this.available.cache,i=t===void 0?e.length:m(t,"subscription ack count"),s=Math.min(i,e.length);if(s<=0)return this.cursor.cache;let r=this.cursor.cache+s;return this.cursor.emit(r),r}pull(t,e={}){let i=this.available.cache,s=t===void 0?i.length:m(t,"subscription pull limit"),r=i.slice(0,s);return e.ack&&r.length>0&&this.ack(r.length),r}},g=class extends h{_sourceSub;_target;bridgedCount;constructor(t,e,i,s={}){super(t,s.graph),this._sourceSub=G(`${t}-subscription`,e,{cursor:s.cursor}),this._target=i,this.mount("subscription",this._sourceSub),this.bridgedCount=f(0,{name:"bridgedCount",describeKind:"state",meta:o("topic_bridge_count")}),this.add(this.bridgedCount,{name:"bridgedCount"});let r=Math.max(1,m(s.maxPerPump??N,"topic bridge maxPerPump")),u=s.map??(a=>a),b=w([this._sourceSub.available],()=>{let a=this._sourceSub.pull(r,{ack:!0});if(a.length===0)return;let c=0;for(let _ of a){let O=u(_);O!==void 0&&(this._target.publish(O),c+=1)}if(c>0){let _=this.bridgedCount.cache;this.bridgedCount.emit(_+c)}},{name:"pump",describeKind:"effect",meta:o("topic_bridge_pump")});this.add(b,{name:"pump"}),this.addDisposer(p(b))}},v=class extends h{_topics=new Map;_version=0;_defaultTopicOptions;constructor(t,e={}){super(t,e.graph),this._defaultTopicOptions={...e.defaultTopicOptions??{}}}get version(){return this._version}get size(){return this._topics.size}has(t){return this._topics.has(t)}topicNames(){return this._topics.keys()}topic(t,e){let i=this._topics.get(t);if(i===void 0){let s={...this._defaultTopicOptions,...e??{}};i=new l(t,s),this._topics.set(t,i),this.mount(t,i),this._version+=1}return i}publish(t,e){this.topic(t).publish(e)}publishMany(t){x(()=>{for(let[e,i]of t)this.topic(e).publish(i)})}subscribe(t,e,i){let s=this.topic(e);return new T(t,s,i)}removeTopic(t){if(!this._topics.has(t))return!1;try{this.remove(t)}finally{this._topics.delete(t),this._version+=1}return!0}};function P(n,t){return new l(n,t)}function L(n,t){return new v(n,t)}function G(n,t,e){return new T(n,t,e)}function S(n,t,e,i){return new g(n,t,e,i)}export{l as a,T as b,g as c,v as d,P as e,L as f,G as g,S as h,C as i};
1
+ import{c as k}from"./chunk-5Z4HDCO6.js";import{k as h}from"./chunk-MGKAO4EK.js";import{A as p}from"./chunk-KASHOCF5.js";import{b as I}from"./chunk-AUY2YKCO.js";import{D as w,E as f,G as d,m as x}from"./chunk-W4TSQ6RJ.js";import{i as y}from"./chunk-CK2E7BTU.js";import{b as M}from"./chunk-QYADASLV.js";var C={};M(C,{MessagingHubGraph:()=>v,SubscriptionGraph:()=>T,TopicBridgeGraph:()=>g,TopicGraph:()=>l,messagingHub:()=>L,subscription:()=>G,topic:()=>P,topicBridge:()=>S});var N=2147483647;function m(n,t){if(!Number.isFinite(n)||!Number.isInteger(n)||n<0)throw new Error(`${t} must be a non-negative integer`);return n}function o(n,t){return k("messaging",n,t)}var l=class extends h{_log;events;latest;hasLatest;constructor(t,e={}){super(t,e.graph),this._log=I([],{name:"events",maxSize:e.retainedLimit}),this.events=this._log.entries,this.add(this.events,{name:"events"}),this.latest=d([this.events],([i])=>{let s=i;return s.length===0?null:s[s.length-1]},{name:"latest",describeKind:"derived",meta:o("topic_latest")}),this.add(this.latest,{name:"latest"}),this.addDisposer(p(this.latest)),this.hasLatest=d([this.events],([i])=>i.length>0,{name:"hasLatest",describeKind:"derived",meta:o("topic_has_latest")}),this.add(this.hasLatest,{name:"hasLatest"}),this.addDisposer(p(this.hasLatest)),this.addDisposer(()=>{this.events.down([[y]])}),this.addDisposer(()=>this._log.disposeAllViews())}publish(t){this._log.append(t)}retained(){return this.events.cache}},T=class extends h{source;cursor;available;topic;constructor(t,e,i={}){super(t,i.graph);let s=m(i.cursor??0,"subscription cursor");this.topic=e;let r=e.events;this.source=d([r],([u])=>u,{name:"source",describeKind:"derived",meta:o("subscription_source"),initial:r.cache}),this.add(this.source,{name:"source"}),this.cursor=f(s,{name:"cursor",describeKind:"state",meta:o("subscription_cursor")}),this.add(this.cursor,{name:"cursor"}),this.available=d([this.source,this.cursor],([u,b])=>{let a=u,c=Math.max(0,Math.trunc(b??0));return a.slice(c)},{name:"available",describeKind:"derived",meta:o("subscription_available"),initial:[]}),this.add(this.available,{name:"available"}),this.addDisposer(p(this.source)),this.addDisposer(p(this.available))}ack(t){let e=this.available.cache,i=t===void 0?e.length:m(t,"subscription ack count"),s=Math.min(i,e.length);if(s<=0)return this.cursor.cache;let r=this.cursor.cache+s;return this.cursor.emit(r),r}pull(t,e={}){let i=this.available.cache,s=t===void 0?i.length:m(t,"subscription pull limit"),r=i.slice(0,s);return e.ack&&r.length>0&&this.ack(r.length),r}},g=class extends h{_sourceSub;_target;bridgedCount;constructor(t,e,i,s={}){super(t,s.graph),this._sourceSub=G(`${t}-subscription`,e,{cursor:s.cursor}),this._target=i,this.mount("subscription",this._sourceSub),this.bridgedCount=f(0,{name:"bridgedCount",describeKind:"state",meta:o("topic_bridge_count")}),this.add(this.bridgedCount,{name:"bridgedCount"});let r=Math.max(1,m(s.maxPerPump??N,"topic bridge maxPerPump")),u=s.map??(a=>a),b=w([this._sourceSub.available],()=>{let a=this._sourceSub.pull(r,{ack:!0});if(a.length===0)return;let c=0;for(let _ of a){let O=u(_);O!==void 0&&(this._target.publish(O),c+=1)}if(c>0){let _=this.bridgedCount.cache;this.bridgedCount.emit(_+c)}},{name:"pump",describeKind:"effect",meta:o("topic_bridge_pump")});this.add(b,{name:"pump"}),this.addDisposer(p(b))}},v=class extends h{_topics=new Map;_version=0;_defaultTopicOptions;constructor(t,e={}){super(t,e.graph),this._defaultTopicOptions={...e.defaultTopicOptions??{}}}get version(){return this._version}get size(){return this._topics.size}has(t){return this._topics.has(t)}topicNames(){return this._topics.keys()}topic(t,e){let i=this._topics.get(t);if(i===void 0){let s={...this._defaultTopicOptions,...e??{}};i=new l(t,s),this._topics.set(t,i),this.mount(t,i),this._version+=1}return i}publish(t,e){this.topic(t).publish(e)}publishMany(t){x(()=>{for(let[e,i]of t)this.topic(e).publish(i)})}subscribe(t,e,i){let s=this.topic(e);return new T(t,s,i)}removeTopic(t){if(!this._topics.has(t))return!1;try{this.remove(t)}finally{this._topics.delete(t),this._version+=1}return!0}};function P(n,t){return new l(n,t)}function L(n,t){return new v(n,t)}function G(n,t,e){return new T(n,t,e)}function S(n,t,e,i){return new g(n,t,e,i)}export{l as a,T as b,g as c,v as d,P as e,L as f,G as g,S as h,C as i};