@graphrefly/graphrefly 0.42.0 → 0.44.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-CH-_VwG9.d.cts → cascading-BglDkMdX.d.cts} +2 -2
  2. package/dist/{cascading-OgKQZjsa.d.ts → cascading-MFgxu7Yo.d.ts} +2 -2
  3. package/dist/chunk-2T7U5EU6.js +1 -0
  4. package/dist/chunk-5M4CCMMD.js +45 -0
  5. package/dist/{chunk-YGL7FPVQ.js → chunk-5XJ6B66J.js} +1 -1
  6. package/dist/{chunk-NWXQIOIB.js → chunk-6X7AFUJV.js} +1 -1
  7. package/dist/chunk-7K6PWTDQ.js +1 -0
  8. package/dist/{chunk-D27JNOLZ.js → chunk-7LIAPXJB.js} +1 -1
  9. package/dist/{chunk-CLD3F4R5.js → chunk-7WPU3UHQ.js} +1 -1
  10. package/dist/{chunk-NNKJUORL.js → chunk-A5WCQ5NO.js} +1 -1
  11. package/dist/chunk-APPIWSGD.js +84 -0
  12. package/dist/{chunk-TZQPPQEQ.js → chunk-BEZWM2SY.js} +1 -1
  13. package/dist/{chunk-5QRRKBUT.js → chunk-CB676TKJ.js} +1 -1
  14. package/dist/{chunk-KT5DTRBP.js → chunk-CE6TI2TL.js} +1 -1
  15. package/dist/{chunk-6YFZMUMR.js → chunk-CLVB32RD.js} +1 -1
  16. package/dist/{chunk-2K5RXLAH.js → chunk-CRVT7D2P.js} +1 -1
  17. package/dist/chunk-D7GPHKFH.js +1 -0
  18. package/dist/{chunk-FUZ6S2DY.js → chunk-DHRX7JX4.js} +1 -1
  19. package/dist/chunk-FZMYDOWV.js +1 -0
  20. package/dist/{chunk-35JTVPOX.js → chunk-GHBWHMRZ.js} +1 -1
  21. package/dist/{chunk-KGKJCHEK.js → chunk-GLERH466.js} +1 -1
  22. package/dist/{chunk-CISGGAIF.js → chunk-HIDYF36O.js} +1 -1
  23. package/dist/chunk-HITNVN6B.js +3 -0
  24. package/dist/{chunk-7ARY3Y3T.js → chunk-HY4DJBA7.js} +1 -1
  25. package/dist/chunk-KZIEYVXN.js +1 -0
  26. package/dist/{chunk-IZM3UEH3.js → chunk-N4MQX6JU.js} +1 -1
  27. package/dist/{chunk-FDZAZNRO.js → chunk-N7FHEL4D.js} +1 -1
  28. package/dist/chunk-NTEURFZH.js +1 -0
  29. package/dist/{chunk-4QH6VJF4.js → chunk-OIVP6KFV.js} +1 -1
  30. package/dist/{chunk-KCACBSJH.js → chunk-OPHBU3LG.js} +1 -1
  31. package/dist/{chunk-Q7QQQA3I.js → chunk-OYQOZP2F.js} +1 -1
  32. package/dist/{chunk-7B7ELAT2.js → chunk-PTZK576G.js} +1 -1
  33. package/dist/{chunk-DEJTNNQC.js → chunk-ST7UXLWR.js} +1 -1
  34. package/dist/chunk-SVY7VUYU.js +1 -0
  35. package/dist/{chunk-WHMUB5QB.js → chunk-TK3NWWD4.js} +1 -1
  36. package/dist/chunk-UNGSTR4X.js +61 -0
  37. package/dist/{chunk-VRALOYRD.js → chunk-VV4N5P64.js} +1 -1
  38. package/dist/chunk-W3I423PS.js +1 -0
  39. package/dist/{chunk-HZKW2AAB.js → chunk-WJR24TAG.js} +1 -1
  40. package/dist/{chunk-F3IGTWCQ.js → chunk-XTGKMHSW.js} +1 -1
  41. package/dist/{chunk-LDQ3IUIP.js → chunk-YBB7ZGTY.js} +1 -1
  42. package/dist/{chunk-G5VBJ5K6.js → chunk-Z4NPUARF.js} +1 -1
  43. package/dist/{chunk-KRH66M4O.js → chunk-ZGNQRPDT.js} +1 -1
  44. package/dist/{chunk-AGNM6RS6.js → chunk-ZKPSFFKU.js} +1 -1
  45. package/dist/{chunk-KY2LMAXU.js → chunk-ZLV5SQSX.js} +1 -1
  46. package/dist/compat/index.cjs +5 -5
  47. package/dist/compat/index.d.cts +16 -16
  48. package/dist/compat/index.d.ts +16 -16
  49. package/dist/compat/index.js +1 -1
  50. package/dist/compat/jotai/index.cjs +1 -1
  51. package/dist/compat/jotai/index.d.cts +2 -2
  52. package/dist/compat/jotai/index.d.ts +2 -2
  53. package/dist/compat/jotai/index.js +1 -1
  54. package/dist/compat/nanostores/index.cjs +1 -1
  55. package/dist/compat/nanostores/index.d.cts +2 -2
  56. package/dist/compat/nanostores/index.d.ts +2 -2
  57. package/dist/compat/nanostores/index.js +1 -1
  58. package/dist/compat/nestjs/index.cjs +5 -5
  59. package/dist/compat/nestjs/index.d.cts +8 -8
  60. package/dist/compat/nestjs/index.d.ts +8 -8
  61. package/dist/compat/nestjs/index.js +1 -1
  62. package/dist/compat/react/index.d.cts +2 -2
  63. package/dist/compat/react/index.d.ts +2 -2
  64. package/dist/compat/solid/index.d.cts +2 -2
  65. package/dist/compat/solid/index.d.ts +2 -2
  66. package/dist/compat/svelte/index.d.cts +2 -2
  67. package/dist/compat/svelte/index.d.ts +2 -2
  68. package/dist/compat/vue/index.d.cts +2 -2
  69. package/dist/compat/vue/index.d.ts +2 -2
  70. package/dist/compat/zustand/index.cjs +3 -3
  71. package/dist/compat/zustand/index.d.cts +4 -4
  72. package/dist/compat/zustand/index.d.ts +4 -4
  73. package/dist/compat/zustand/index.js +1 -1
  74. package/dist/core/index.cjs +1 -1
  75. package/dist/core/index.d.cts +3 -4
  76. package/dist/core/index.d.ts +3 -4
  77. package/dist/core/index.js +1 -1
  78. package/dist/{decay-CdEBmDIs.d.ts → decay-BvOWTZ00.d.ts} +2 -2
  79. package/dist/{decay-2ZukgQ4o.d.cts → decay-CFlLvXUT.d.cts} +2 -2
  80. package/dist/extra/browser.cjs +1 -1
  81. package/dist/extra/browser.d.cts +1 -1
  82. package/dist/extra/browser.d.ts +1 -1
  83. package/dist/extra/browser.js +1 -1
  84. package/dist/extra/index.cjs +15 -15
  85. package/dist/extra/index.d.cts +10 -10
  86. package/dist/extra/index.d.ts +10 -10
  87. package/dist/extra/index.js +1 -1
  88. package/dist/extra/node.cjs +2 -2
  89. package/dist/extra/node.d.cts +1 -1
  90. package/dist/extra/node.d.ts +1 -1
  91. package/dist/extra/node.js +1 -1
  92. package/dist/extra/operators.cjs +1 -1
  93. package/dist/extra/operators.d.cts +9 -1
  94. package/dist/extra/operators.d.ts +9 -1
  95. package/dist/extra/operators.js +1 -1
  96. package/dist/extra/reactive.cjs +1 -1
  97. package/dist/extra/reactive.d.cts +3 -3
  98. package/dist/extra/reactive.d.ts +3 -3
  99. package/dist/extra/reactive.js +1 -1
  100. package/dist/extra/render/index.d.cts +3 -3
  101. package/dist/extra/render/index.d.ts +3 -3
  102. package/dist/extra/sources.cjs +3 -3
  103. package/dist/extra/sources.d.cts +1 -1
  104. package/dist/extra/sources.d.ts +1 -1
  105. package/dist/extra/sources.js +1 -1
  106. package/dist/extra/storage-browser.cjs +1 -1
  107. package/dist/extra/storage-browser.d.cts +1 -1
  108. package/dist/extra/storage-browser.d.ts +1 -1
  109. package/dist/extra/storage-browser.js +1 -1
  110. package/dist/{fallback-Ctlj2tMY.d.cts → fallback-74oxi34l.d.cts} +1 -1
  111. package/dist/{fallback-CqYVLL6X.d.ts → fallback-DUyyBTBK.d.ts} +1 -1
  112. package/dist/graph/index.cjs +7 -7
  113. package/dist/graph/index.d.cts +5 -5
  114. package/dist/graph/index.d.ts +5 -5
  115. package/dist/graph/index.js +1 -1
  116. package/dist/{graph-C4SHb3Ly.d.cts → graph-CWvEUQAq.d.cts} +196 -3
  117. package/dist/{graph-7VguS7a4.d.ts → graph-D9LFnda9.d.ts} +196 -3
  118. package/dist/{index-LIpQQE9f.d.cts → index-5k1T6jl0.d.cts} +9 -9
  119. package/dist/{index-CPNSy-U0.d.cts → index-9770hRuQ.d.cts} +23 -4
  120. package/dist/{index-CEMx8n40.d.cts → index-B-_tFaqV.d.cts} +4 -4
  121. package/dist/{index-2B7u2pVn.d.cts → index-B17QddL1.d.cts} +4 -4
  122. package/dist/{index-B-i4_g3k.d.ts → index-B1F8Enjf.d.ts} +61 -8
  123. package/dist/{index-DBevwHj_.d.ts → index-B5S8ULbU.d.ts} +3 -3
  124. package/dist/{index-Dgs8zcj7.d.ts → index-B8YnZpIR.d.ts} +2 -2
  125. package/dist/{index-B3OTH1dV.d.ts → index-BHskSB8v.d.ts} +28 -17
  126. package/dist/{index-sl4NyzQx.d.cts → index-BIYAkbAi.d.cts} +1 -1
  127. package/dist/{index-C9kSENB4.d.cts → index-BQSKmbuG.d.cts} +1 -1
  128. package/dist/{index-tJoTcnHh.d.cts → index-BaQaY_IQ.d.cts} +2 -2
  129. package/dist/{index-CJK1JkYy.d.ts → index-BmZXHqkE.d.ts} +1 -1
  130. package/dist/{index-pT8sCpOJ.d.ts → index-BoJ5JHxI.d.ts} +12 -3
  131. package/dist/{index-BeT2r7sk.d.ts → index-BocU7pqs.d.ts} +23 -4
  132. package/dist/{index-ChOyVLKm.d.cts → index-BrPrLl4e.d.cts} +1 -1
  133. package/dist/{index-D-Xs74HZ.d.cts → index-BxNs2HB9.d.cts} +33 -9
  134. package/dist/{index-Bf7eqeSF.d.ts → index-Byu-OpX_.d.ts} +2 -2
  135. package/dist/{index-BoLv_OfD.d.cts → index-C1T3d7V-.d.cts} +61 -8
  136. package/dist/{index-BTQtTb_H.d.cts → index-C5ri2Axc.d.cts} +3 -3
  137. package/dist/{index-z96luz5O.d.cts → index-C5stwKcw.d.cts} +1 -1
  138. package/dist/{index-CZmcDtFn.d.ts → index-C9l6OEBL.d.ts} +1 -1
  139. package/dist/{index-CCq87F7t.d.ts → index-CBBLl_rc.d.ts} +1 -1
  140. package/dist/{index-D6egPFAL.d.ts → index-CBGUK09R.d.ts} +4 -4
  141. package/dist/{index-C0-Jv1kP.d.cts → index-CC-AvFTy.d.cts} +12 -3
  142. package/dist/{index-DQo8xBgd.d.ts → index-CJF1URuX.d.ts} +9 -9
  143. package/dist/{index-BJX94aud.d.cts → index-CK29LV56.d.cts} +1 -1
  144. package/dist/{index-BP8a88zx.d.ts → index-CMh5Rz1y.d.ts} +4 -4
  145. package/dist/{index-CvrqGfNS.d.ts → index-CPQlGA29.d.ts} +1 -1
  146. package/dist/{index-Bbkgpt5t.d.ts → index-CR8QpwX8.d.ts} +49 -24
  147. package/dist/{index-Du7u1lSf.d.cts → index-CS0LTlB8.d.cts} +4 -4
  148. package/dist/{index-Bc41FuHp.d.cts → index-CSOmP7xT.d.cts} +2 -2
  149. package/dist/{index-BsT7F2et.d.ts → index-CYq8vAyV.d.ts} +2 -2
  150. package/dist/{index-Bn4zHYLj.d.ts → index-CZ3r5Rxp.d.ts} +4 -4
  151. package/dist/{index-HoU88d5U.d.cts → index-CasX6Pfq.d.cts} +68 -9
  152. package/dist/{index-BG0BN3PB.d.ts → index-CdAlHFEt.d.ts} +1 -1
  153. package/dist/{index-CpyNFqkB.d.ts → index-CdTelp1M.d.ts} +8 -4
  154. package/dist/{index-D8l8hNXn.d.ts → index-CeFiHtAg.d.ts} +4 -4
  155. package/dist/{index-DmAgG5CI.d.cts → index-Cj3WohTd.d.cts} +8 -4
  156. package/dist/{index-BtAsBp8K.d.cts → index-Climxqsu.d.cts} +4 -4
  157. package/dist/{index-CJIuLu2f.d.cts → index-Co7uli2l.d.cts} +28 -17
  158. package/dist/{index-DIOoAZUX.d.ts → index-CviRnE4K.d.ts} +1 -1
  159. package/dist/{index-Dhc7a7Xo.d.cts → index-Cwv0KWcU.d.cts} +2 -2
  160. package/dist/{index-Dn-wI9g4.d.ts → index-CzLVrjxn.d.ts} +2 -2
  161. package/dist/{index-DO9XxMzS.d.ts → index-D0aciIex.d.cts} +3 -18
  162. package/dist/{index-4Uz-e_fL.d.ts → index-DHen9Klo.d.ts} +33 -9
  163. package/dist/{index-3NmAfcH0.d.cts → index-DV_1YuVk.d.cts} +40 -8
  164. package/dist/{index-BdGtBX-X.d.cts → index-Dc4AYqrJ.d.cts} +3 -3
  165. package/dist/{index-Dmqp7KjD.d.ts → index-Dgl1HpPn.d.ts} +1 -1
  166. package/dist/{index-CJQm0g38.d.ts → index-DisjX8a-.d.ts} +40 -8
  167. package/dist/{index-B11anra4.d.cts → index-UPSiS-X7.d.cts} +49 -24
  168. package/dist/{index-DBIqYS43.d.cts → index-Yq60JP3s.d.ts} +3 -18
  169. package/dist/{index-f5IivDUX.d.cts → index-ZVQhLa2i.d.cts} +1 -1
  170. package/dist/{index-hHcaFlJX.d.cts → index-_6ODbuOu.d.cts} +1 -1
  171. package/dist/{index-BVpm6noz.d.cts → index-hcDJ8PSI.d.cts} +1 -1
  172. package/dist/{index-DBHK8O6H.d.ts → index-nozs3fFC.d.ts} +3 -3
  173. package/dist/{index-BUYXac2c.d.ts → index-p09KSrTN.d.ts} +68 -9
  174. package/dist/{index-C7O6r5fV.d.ts → index-sqkqlb1p.d.ts} +1 -1
  175. package/dist/{index-CZjOhcBy.d.cts → index-tRCxuAXF.d.cts} +2 -2
  176. package/dist/index.cjs +48 -48
  177. package/dist/index.d.cts +42 -43
  178. package/dist/index.d.ts +42 -43
  179. package/dist/index.js +1 -1
  180. package/dist/{node-ClS5yC-B.d.cts → node-kK3CvTrR.d.cts} +1 -1
  181. package/dist/{node-ClS5yC-B.d.ts → node-kK3CvTrR.d.ts} +1 -1
  182. package/dist/{observable-BsBzUrcI.d.ts → observable-DWjNfLvC.d.ts} +1 -1
  183. package/dist/{observable-DLGPPtb8.d.cts → observable-e3eiPPFy.d.cts} +1 -1
  184. package/dist/patterns/ai/browser.cjs +5 -5
  185. package/dist/patterns/ai/browser.d.cts +4 -4
  186. package/dist/patterns/ai/browser.d.ts +4 -4
  187. package/dist/patterns/ai/browser.js +1 -1
  188. package/dist/patterns/ai/index.cjs +16 -16
  189. package/dist/patterns/ai/index.d.cts +16 -17
  190. package/dist/patterns/ai/index.d.ts +16 -17
  191. package/dist/patterns/ai/index.js +1 -1
  192. package/dist/patterns/ai/node.cjs +1 -1
  193. package/dist/patterns/ai/node.d.cts +4 -4
  194. package/dist/patterns/ai/node.d.ts +4 -4
  195. package/dist/patterns/ai/node.js +1 -1
  196. package/dist/patterns/cqrs/index.cjs +3 -3
  197. package/dist/patterns/cqrs/index.d.cts +6 -6
  198. package/dist/patterns/cqrs/index.d.ts +6 -6
  199. package/dist/patterns/cqrs/index.js +1 -1
  200. package/dist/patterns/demo-shell/index.cjs +5 -5
  201. package/dist/patterns/demo-shell/index.d.cts +5 -5
  202. package/dist/patterns/demo-shell/index.d.ts +5 -5
  203. package/dist/patterns/demo-shell/index.js +1 -1
  204. package/dist/patterns/domain-templates/index.cjs +3 -3
  205. package/dist/patterns/domain-templates/index.d.cts +4 -4
  206. package/dist/patterns/domain-templates/index.d.ts +4 -4
  207. package/dist/patterns/domain-templates/index.js +1 -1
  208. package/dist/patterns/graphspec/index.cjs +16 -16
  209. package/dist/patterns/graphspec/index.d.cts +5 -5
  210. package/dist/patterns/graphspec/index.d.ts +5 -5
  211. package/dist/patterns/graphspec/index.js +1 -1
  212. package/dist/patterns/harness/index.cjs +9 -9
  213. package/dist/patterns/harness/index.d.cts +10 -11
  214. package/dist/patterns/harness/index.d.ts +10 -11
  215. package/dist/patterns/harness/index.js +1 -1
  216. package/dist/patterns/inspect/index.cjs +3 -3
  217. package/dist/patterns/inspect/index.d.cts +7 -7
  218. package/dist/patterns/inspect/index.d.ts +7 -7
  219. package/dist/patterns/inspect/index.js +1 -1
  220. package/dist/patterns/job-queue/index.cjs +3 -3
  221. package/dist/patterns/job-queue/index.d.cts +6 -6
  222. package/dist/patterns/job-queue/index.d.ts +6 -6
  223. package/dist/patterns/job-queue/index.js +1 -1
  224. package/dist/patterns/memory/index.cjs +3 -3
  225. package/dist/patterns/memory/index.d.cts +6 -6
  226. package/dist/patterns/memory/index.d.ts +6 -6
  227. package/dist/patterns/memory/index.js +1 -1
  228. package/dist/patterns/messaging/index.cjs +3 -3
  229. package/dist/patterns/messaging/index.d.cts +5 -5
  230. package/dist/patterns/messaging/index.d.ts +5 -5
  231. package/dist/patterns/messaging/index.js +1 -1
  232. package/dist/patterns/orchestration/index.cjs +3 -3
  233. package/dist/patterns/orchestration/index.d.cts +6 -7
  234. package/dist/patterns/orchestration/index.d.ts +6 -7
  235. package/dist/patterns/orchestration/index.js +1 -1
  236. package/dist/patterns/process/index.cjs +3 -1
  237. package/dist/patterns/process/index.d.cts +7 -7
  238. package/dist/patterns/process/index.d.ts +7 -7
  239. package/dist/patterns/process/index.js +1 -1
  240. package/dist/patterns/reactive-layout/index.cjs +4 -4
  241. package/dist/patterns/reactive-layout/index.d.cts +5 -5
  242. package/dist/patterns/reactive-layout/index.d.ts +5 -5
  243. package/dist/patterns/reactive-layout/index.js +1 -1
  244. package/dist/patterns/reduction/index.cjs +3 -3
  245. package/dist/patterns/reduction/index.d.cts +4 -4
  246. package/dist/patterns/reduction/index.d.ts +4 -4
  247. package/dist/patterns/reduction/index.js +1 -1
  248. package/dist/patterns/surface/index.cjs +10 -10
  249. package/dist/patterns/surface/index.d.cts +6 -6
  250. package/dist/patterns/surface/index.d.ts +6 -6
  251. package/dist/patterns/surface/index.js +1 -1
  252. package/dist/{pipeline-graph-WBlobVhU.d.cts → pipeline-graph-CIKhynsF.d.cts} +11 -6
  253. package/dist/{pipeline-graph-v8fMvqNk.d.ts → pipeline-graph-Sgj0gCwn.d.ts} +11 -6
  254. package/dist/{reactive-layout-v7KPvxoc.d.ts → reactive-layout-DOTs9P3X.d.ts} +2 -2
  255. package/dist/{reactive-layout-Dsvob4zD.d.cts → reactive-layout-DgctbqZo.d.cts} +2 -2
  256. package/dist/{reactive-log-BezYsbA_.d.ts → reactive-log-BKALbfal.d.ts} +1 -1
  257. package/dist/{reactive-log-B00laMSQ.d.cts → reactive-log-DIGdYqQ6.d.cts} +1 -1
  258. package/dist/{reactive-map-48mnZ-nu.d.cts → reactive-map-CEFGp8TK.d.cts} +1 -1
  259. package/dist/{reactive-map-BVVPdvmi.d.ts → reactive-map-DS_SIAxv.d.ts} +1 -1
  260. package/dist/resilience-6LYQJAC5.js +1 -0
  261. package/dist/sugar-DQjFmVqb.d.cts +399 -0
  262. package/dist/sugar-fhLIE7TT.d.ts +399 -0
  263. package/dist/{topology-tree-BSdfSwMi.d.cts → topology-tree-Bcz27hpF.d.cts} +1 -1
  264. package/dist/{topology-tree-BNGvuG82.d.ts → topology-tree-xvaD0fOX.d.ts} +1 -1
  265. package/dist/{types-B1jDWVsM.d.cts → types-C0_yquda.d.cts} +1 -1
  266. package/dist/{types-DkzUUs0H.d.ts → types-CWFysE9E.d.ts} +1 -1
  267. package/package.json +1 -1
  268. package/dist/chunk-3ERTUW2J.js +0 -45
  269. package/dist/chunk-3K7HA4Y6.js +0 -1
  270. package/dist/chunk-3ZZX7M25.js +0 -1
  271. package/dist/chunk-4I45FVQS.js +0 -1
  272. package/dist/chunk-5ST42ESJ.js +0 -1
  273. package/dist/chunk-7VKFXLZQ.js +0 -84
  274. package/dist/chunk-ACMJ2ZPS.js +0 -3
  275. package/dist/chunk-AS3TV2TV.js +0 -1
  276. package/dist/chunk-LPRWATHB.js +0 -61
  277. package/dist/chunk-LYCLF26R.js +0 -1
  278. package/dist/chunk-VE5SIZEM.js +0 -1
  279. package/dist/chunk-XLQPNNIC.js +0 -1
  280. package/dist/meta-BgVAsg9j.d.ts +0 -102
  281. package/dist/meta-vE8bxW1E.d.cts +0 -102
  282. package/dist/resilience-445VFFXQ.js +0 -1
  283. package/dist/sugar-CH-2ZY90.d.ts +0 -203
  284. package/dist/sugar-DStZfUEK.d.cts +0 -203
@@ -1,20 +1,20 @@
1
- "use strict";var xn=Object.defineProperty;var os=Object.getOwnPropertyDescriptor;var ss=Object.getOwnPropertyNames;var is=Object.prototype.hasOwnProperty;var q=(n,e)=>()=>(n&&(e=n(n=0)),e);var Nn=(n,e)=>{for(var t in e)xn(n,t,{get:e[t],enumerable:!0})},as=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ss(e))!is.call(n,o)&&o!==t&&xn(n,o,{get:()=>e[o],enumerable:!(r=os(e,o))||r.enumerable});return n};var us=n=>as(xn({},"__esModule",{value:!0}),n);function Wt(){return it>0||Rt}function Nr(){return it>0}function ut(n){it>0?Mt.push(n):n()}function $(n){it+=1;let e=!1;try{n()}catch(t){throw e=!0,t}finally{if(it-=1,it===0)if(e){if(!Rt){let t=Mt.splice(0);for(let r of t)try{r()}catch{}He.length=0,qe.length=0,at.length=0}}else ds()}}function ds(){let n=!Rt;n&&(Rt=!0);let e=[],t=0;try{for(;He.length>0||qe.length>0||at.length>0||n&&Mt.length>0;){if(n&&Mt.length>0){let s=Mt.splice(0);for(let i of s)try{i()}catch(a){e.push(a)}continue}if(t+=1,t>1e3)throw He.length=0,qe.length=0,at.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let o=(He.length>0?He:qe.length>0?qe:at).splice(0);for(let s of o)try{s()}catch(i){e.push(i)}}}finally{n&&(Rt=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function Ut(n,e,t){if(e.length===0)return;if(e.length===1){let d=t(e[0][0]);if(d<3||!Wt()){n(e);return}(d>=5?at:d===4?qe:He).push(()=>n(e));return}let r=e.length,o=r,s=r,i=r,a=0;for(;a<r&&t(e[a][0])<3;)a++;for(o=a;a<r&&t(e[a][0])===3;)a++;for(s=a;a<r&&t(e[a][0])===4;)a++;i=a;let u=Wt();if(o>0){let d=e.slice(0,o);n(d)}if(s>o){let d=e.slice(o,s);u?He.push(()=>n(d)):n(d)}if(i>s){let d=e.slice(s,i);u?qe.push(()=>n(d)):n(d)}if(r>i){let d=e.slice(i,r);u?at.push(()=>n(d)):n(d)}}var it,Rt,He,qe,at,Mt,Te=q(()=>{"use strict";it=0,Rt=!1,He=[],qe=[],at=[],Mt=[]});function re(){return Math.trunc(performance.now()*1e6)}function ne(){return Date.now()*1e6}var Pe=q(()=>{"use strict"});var Ve,x,V,C,Ne,le,pe,K,N,S,dt,_n,cs,Sn,ls,fs,On,_r,Sr,Or,En,Z=q(()=>{"use strict";Ve=Symbol.for("graphrefly/START"),x=Symbol.for("graphrefly/DATA"),V=Symbol.for("graphrefly/DIRTY"),C=Symbol.for("graphrefly/RESOLVED"),Ne=Symbol.for("graphrefly/INVALIDATE"),le=Symbol.for("graphrefly/PAUSE"),pe=Symbol.for("graphrefly/RESUME"),K=Symbol.for("graphrefly/TEARDOWN"),N=Symbol.for("graphrefly/COMPLETE"),S=Symbol.for("graphrefly/ERROR"),dt=Object.freeze([V]),_n=Object.freeze([C]),cs=Object.freeze([Ne]),Sn=Object.freeze([Ve]),ls=Object.freeze([N]),fs=Object.freeze([K]),On=Object.freeze([dt]),_r=Object.freeze([_n]),Sr=Object.freeze([cs]),Or=Object.freeze([ls]),En=Object.freeze([fs])});function Rr(n,e){let t=new TextEncoder().encode(n.name);if(t.length===0||t.length>255)throw new Error(`encodeEnvelope: codec name "${n.name}" encodes to ${t.length} bytes (must be 1\u2013255)`);let r=n.version;if(!Number.isInteger(r)||r<0||r>65535)throw new Error(`encodeEnvelope: codec.version ${r} out of u16 range (expected integer 0\u201365535)`);let o=2+t.length+2+e.length;if(o>4294967295)throw new Error(`encodeEnvelope: total envelope size ${o} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let s=new Uint8Array(o),i=0;return s[i++]=Rn,s[i++]=t.length,s.set(t,i),i+=t.length,s[i++]=r>>>8&255,s[i++]=r&255,s.set(e,i),s}function Mr(n,e){if(n.length<Er)throw new Error(`decodeEnvelope: bytes too short (${n.length} < ${Er})`);let t=0,r=n[t++];if(r!==Rn)throw new Error(`decodeEnvelope: unsupported envelope version ${r} (expected ${Rn})`);let o=n[t++];if(o===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(t+o+2>n.length)throw new Error(`decodeEnvelope: envelope truncated (need ${t+o+2} bytes, have ${n.length})`);let s=new TextDecoder().decode(n.subarray(t,t+o));t+=o;let i=(n[t]<<8|n[t+1])>>>0;t+=2;let a=n.subarray(t),u=e.lookupCodec(s);if(u==null)throw new Error(`decodeEnvelope: codec "${s}" not registered (envelope codec_v=${i})`);return{codec:u,codecVersion:i,payload:a}}function Ar(n){n.registerCodec(ps)}var ps,Rn,Er,Mn=q(()=>{"use strict";ps={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)}},Rn=1,Er=4});function Ht(n){if(n==null)return ct;let{type:e,id:t,...r}=n;return{type:e??"system",id:t??"",...r}}var ct,An=q(()=>{"use strict";ct={type:"system",id:""}});function Cr(n){n.registerMessageType(Ve,{tier:0,wireCrossing:!1}),n.registerMessageType(V,{tier:1,wireCrossing:!1}),n.registerMessageType(Ne,{tier:1,wireCrossing:!1,metaPassthrough:!1}),n.registerMessageType(le,{tier:2,wireCrossing:!1}),n.registerMessageType(pe,{tier:2,wireCrossing:!1}),n.registerMessageType(x,{tier:3,wireCrossing:!0}),n.registerMessageType(C,{tier:3,wireCrossing:!0}),n.registerMessageType(N,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(S,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(K,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var qt,Pr=q(()=>{"use strict";Z();qt=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_rigorRecorder;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=t=>{let r=this._messageTypes.get(t);return r!=null?r.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}get rigorRecorder(){return this._rigorRecorder}set rigorRecorder(e){this._rigorRecorder=e}registerMessageType(e,t){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:t.tier,wireCrossing:t.wireCrossing??t.tier>=3,metaPassthrough:t.metaPassthrough??!0}),this}messageTier(e){let t=this._messageTypes.get(e);return t!=null?t.tier:1}isWireCrossing(e){let t=this._messageTypes.get(e);return t!=null?t.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let t=this._messageTypes.get(e);return t!=null?t.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}}});function Dr(n){return Array.isArray(n)?[...n]:[n]}function hs(n,e){return n.has(e)||n.has("*")}function Lr(n){let e=[];return n((o,s)=>{e.push({kind:"allow",actions:new Set(Dr(o)),where:s?.where??(()=>!0)})},(o,s)=>{e.push({kind:"deny",actions:new Set(Dr(o)),where:s?.where??(()=>!0)})}),(o,s)=>{let i=!1,a=!1;for(let u of e)hs(u.actions,s)&&u.where(o)&&(u.kind==="deny"?i=!0:a=!0);return i?!1:a}}function Cn(n){let e=ms.filter(t=>n({type:t,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(t=>t==="human"||t==="llm"||t==="system")?"both":e.length===1?e[0]:e.join("+")}var Re,ms,At=q(()=>{"use strict";Re=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}};ms=["human","llm","wallet","system"]});function Pn(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(Pn);if(typeof n=="object"&&n!==null){let e={};for(let t of Object.keys(n).sort())e[t]=Pn(n[t]);return e}return null}function ys(n){let e=bs.encode(n),t=e.length,r=t*8,o=t+9+63&-64,s=new Uint8Array(o);s.set(e),s[t]=128;let i=new DataView(s.buffer);i.setUint32(o-4,r>>>0,!1),i.setUint32(o-8,Math.floor(r/4294967296)>>>0,!1);let a=1779033703,u=3144134277,d=1013904242,c=2773480762,l=1359893119,f=2600822924,p=528734635,h=1541459225,g=new Uint32Array(64),m=(b,v)=>b>>>v|b<<32-v;for(let b=0;b<o;b+=64){for(let M=0;M<16;M++)g[M]=i.getUint32(b+M*4,!1);for(let M=16;M<64;M++){let F=g[M-15],P=g[M-2],I=m(F,7)^m(F,18)^F>>>3,ue=m(P,17)^m(P,19)^P>>>10;g[M]=g[M-16]+I+g[M-7]+ue>>>0}let v=a,T=u,w=d,_=c,k=l,O=f,E=p,R=h;for(let M=0;M<64;M++){let F=m(k,6)^m(k,11)^m(k,25),P=k&O^~k&E,I=R+F+P+gs[M]+g[M]>>>0,ue=m(v,2)^m(v,13)^m(v,22),W=v&T^v&w^T&w,de=ue+W>>>0;R=E,E=O,O=k,k=_+I>>>0,_=w,w=T,T=v,v=I+de>>>0}a=a+v>>>0,u=u+T>>>0,d=d+w>>>0,c=c+_>>>0,l=l+k>>>0,f=f+O>>>0,p=p+E>>>0,h=h+R>>>0}let y=b=>b.toString(16).padStart(8,"0");return y(a)+y(u)+y(d)+y(c)+y(l)+y(f)+y(p)+y(h)}function Dn(n){let e=Pn(n??null),t=JSON.stringify(e);return ys(t).slice(0,16)}function vs(){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 Ln(n,e,t){let r=t?.id??vs();if(n===0)return{id:r,version:0};let s=(t?.hash??Dn)(e);return{id:r,version:0,cid:s,prev:null}}function Ir(n,e,t){n.version+=1,"cid"in n&&(n.prev=n.cid,n.cid=t(e))}var gs,bs,Br=q(()=>{"use strict";gs=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]),bs=new TextEncoder});function Fr(n){return{node:n,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function In(n){n.prevData=void 0,n.dirty=!1,n.involvedThisWave=!1,n.dataBatch.length=0,n.terminal=void 0}function Jt(n){return n.length===0?n:typeof n[0]=="symbol"?[n]:n}function B(n,e,t){let r=zr(n)?n:[],o=typeof n=="function"?n:typeof e=="function"?e:void 0,s={};return zr(n)?s=(Bn(e)?e:t)??{}:Bn(n)?s=n:s=(Bn(e)?e:t)??{},new oe(r,o,s)}var Vr,Gr,Ts,ws,ge,oe,zr,Bn,be=q(()=>{"use strict";Mn();An();Te();Pe();Pr();At();Z();Br();Vr=()=>{},Gr=100;Ts=(n,e,t,r)=>{t.direction==="down-in"&&n._onDepMessage(t.depIndex,e)},ws=(n,e,t,r)=>{let o=n;if(o._status==="completed"||o._status==="errored")return;let s=o._cached,i=s===void 0?[Sn]:[Sn,[x,s]];o._status==="dirty"&&i.push(dt),Ut(e,i,o._config.tierOf)},ge=new qt({onMessage:Ts,onSubscribe:ws});Cr(ge);Ar(ge);oe=class n{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,t,r){this._config=r.config??ge,this._config.onMessage,this._optsName=r.name,this._describeKind=r.describeKind,this._equals=r.equals??Object.is,this._resubscribable=r.resubscribable??!1,this._resetOnTeardown=r.resetOnTeardown??!1,this._autoComplete=r.completeWhenDepsComplete??!0,this._autoError=r.errorWhenDepsError??!0,this._pausable=r.pausable??!0,this._guard=r.guard,this._fn=t,this._partial=r.partial??!1,this._cached=r.initial!==void 0?r.initial:void 0,this._status=e.length===0&&t==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=r.versioningHash??this._config.defaultHashFn??Dn;let o=r.versioning??this._config.defaultVersioning;this._versioningLevel=o,this._versioning=o!=null?Ln(o,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Fr);let s={};for(let[a,u]of Object.entries(r.meta??{})){let d={initial:u,name:`${r.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};r.guard!=null&&(d.guard=r.guard),s[a]=new n([],void 0,d)}Object.freeze(s),this.meta=s,this._hasMeta=Object.keys(s).length>0;let i=this;this._actions={emit(a){i._emit([[x,a]])},down(a){i._emit(Jt(a))},up(a){i._emitUp(Jt(a))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,t){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let r=this._versioningLevel;if(r!=null&&e<=r)return;let o=t?.hash??this._hashFn;o!==this._hashFn&&(this._hashFn=o);let s=this._cached===void 0?void 0:this._cached,i=this._versioning,a=i?.id??t?.id,u=i?.version??0,d=Ln(e,s,{id:a,hash:o});d.version=u,this._versioning=d,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let t=Ht(e);if(this._guard!=null&&!this._guard(t,"observe"))return!1;if(this._extraGuards!=null){for(let r of this._extraGuards)if(!r(t,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let t=this._guard!=null||this._extraGuards!=null,r=e?.actor!=null;if(!t&&!r)return;let o=Ht(e?.actor),s=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(o,s))throw new Re({actor:o,action:s,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(o,s))throw new Re({actor:o,action:s,nodeName:this.name})}this._lastMutation={actor:o,timestamp_ns:ne()}}down(e,t){let r=Jt(e);r.length!==0&&(this._checkGuard(t),this._emit(r))}emit(e,t){this._checkGuard(t),this._emit([[x,e]])}up(e,t){if(this._deps.length===0)return;let r=Jt(e);if(r.length===0)return;this._checkGuard(t);let o=t??{internal:!0};this._validateUpTiers(r);for(let s of this._deps)s.node.up?.(r,o)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let t of this._deps)t.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let t=this._config.tierOf;for(let r of e){let o=t(r[0]);if(o===3||o===4)throw new Error(`Node "${this.name}": tier-${o} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,t){if(t!=null&&this._guard!=null){let u=Ht(t);if(!this._guard(u,"observe"))throw new Re({actor:u,action:"observe",nodeName:this.name})}let o=this._isTerminal&&this._resubscribable;if(o){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let u of this._deps)In(u);if(this._partial===!1){for(let u of this._deps)if(u.prevData!==void 0||u.dataBatch.length!==0||u.terminal!==void 0||u.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let s;try{s=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:o},this._actions)}catch(u){throw this._sinkCount-=1,u}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let i=this._isTerminal;if(this._sinkCount===1&&!i)try{this._activate()}catch(u){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof s=="function")try{s()}catch{}throw u}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let a=!1;return()=>{a||(a=!0,this._sinkCount-=1,this._removeSink(e),typeof s=="function"&&s(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[t]=this._sinks;this._sinks=t}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,t=0;try{for(let r=0;r<e;r++){let o=r,s=this._deps[r];s.unsub=Vr,s.unsub=s.node.subscribe(i=>{if(s.unsub===null)return;let a=this._config.tierOf,u=!1;for(let d of i)a(d[0])>=3&&(u=!0),this._config.onMessage(this,d,{direction:"down-in",depIndex:o},this._actions);u&&this._maybeRunFnOnSettlement()}),t++}}catch(r){this._deps[t].unsub=null;for(let o=0;o<t;o++){let s=this._deps[o];if(s.unsub!=null){let i=s.unsub;s.unsub=null;try{i()}catch{}In(s)}}throw this._dirtyDepCount=0,r}}_addDep(e){for(let o=0;o<this._deps.length;o++)if(this._deps[o].node===e)return o;let t=this._deps.length,r=Fr(e);if(this._deps.push(r),this._sinks==null)return t;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(On),r.unsub=Vr;try{r.unsub=e.subscribe(o=>{if(r.unsub===null)return;let s=this._config.tierOf,i=!1;for(let a of o)s(a[0])>=3&&(i=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:t},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(o){throw r.unsub=null,this._deps.pop(),this._dirtyDepCount--,o}return t}_deactivate(e=!1){let t=this._cleanup;if(this._cleanup=void 0,typeof t=="function")try{t()}catch(r){this._emit([[S,this._wrapFnError("cleanup threw",r)]])}else if(t!=null&&typeof t=="object"){let r=t.deactivate;if(typeof r=="function")try{r()}catch(o){this._emit([[S,this._wrapFnError("cleanup.deactivate threw",o)]])}}for(let r of this._deps){if(r.unsub!=null){let o=r.unsub;r.unsub=null;try{o()}catch{}}In(r)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,t){let r=this._deps[e],o=t[0];if(this._inspectorHooks!=null){let s={kind:"dep_message",depIndex:e,message:t};for(let i of this._inspectorHooks)i(s)}if(o!==Ve){if(o===V){this._depDirtied(r);return}if(o===Ne){if(this._depInvalidated(r),this._cached===void 0)return;this._emit(Sr);return}if(o===le||o===pe){this._emit([t]);return}if(o===K){this._emit(En);return}if(o===x)this._depSettledAsData(r,t[1]);else if(o===C)this._depSettledAsResolved(r);else if(o===N)this._depSettledAsTerminal(r,!0);else if(o===S)this._depSettledAsTerminal(r,t[1]);else{this._emit([t]);return}if(!this._fn){(o===x||o===C)&&this._emit([t]),(o===N||o===S)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(On))}_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(_r),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(t=>t.terminal!==void 0&&t.terminal!==!0);if(e!=null){this._autoError&&this._emit([[S,e.terminal]]);return}this._autoComplete&&this._deps.every(t=>t.terminal!==void 0)&&this._emit(Or)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(i){this._emit([[S,this._wrapFnError("cleanup threw",i)]]);return}}else if(e!=null&&typeof e=="object"){let i=e.beforeRun;if(typeof i=="function"){e.beforeRun=void 0;try{i()}catch(a){this._emit([[S,this._wrapFnError("cleanup.beforeRun threw",a)]]);return}}}let t=this._deps.map(i=>i.involvedThisWave?i.dataBatch.length>0?[...i.dataBatch]:[]:void 0),r=this._deps.map(i=>i.prevData);for(let i=0;i<this._deps.length;i++){let a=t[i];a!=null&&a.length>0&&(this._deps[i].prevData=a[a.length-1])}let o=this._deps.map(i=>i.terminal),s={prevData:r,terminalDeps:o,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let i={kind:"run",batchData:t,prevData:r};for(let a of this._inspectorHooks)a(i)}this._isExecutingFn=!0;try{let i=this._fn(t,this._actions,s);if(typeof i=="function")this._cleanup=i;else if(i!=null&&typeof i=="object"){let a=i;(typeof a.beforeRun=="function"||typeof a.deactivate=="function"||typeof a.invalidate=="function")&&(this._cleanup=i)}}catch(i){this._emit([[S,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>Gr?(this._rerunDepth=0,this._emit([[S,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${Gr} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,t){let r=t instanceof Error?t.message:String(t);return new Error(`Node "${this.name}": ${e}: ${r}`,{cause:t})}_frameBatch(e){let t=this._config.tierOf;if(e.length===1)return t(e[0][0])===3&&this._status!=="dirty"?[dt,e[0]]:e;let r=!0,o=!1,s=!1,i=-1;for(let u of e){let d=t(u[0]);d<i&&(r=!1),d===3&&(o=!0),u[0]===V&&(s=!0),i=d}let a=e;if(!r){let u=e.map((d,c)=>({m:d,i:c,tier:t(d[0])}));u.sort((d,c)=>d.tier-c.tier||d.i-c.i),a=u.map(d=>d.m)}if(o&&!s&&this._status!=="dirty"){let u=0;for(;u<a.length&&t(a[u][0])===0;)u++;return u===0?[dt,...a]:[...a.slice(0,u),dt,...a.slice(u)]}return a}_emit(e){if(e.length===0)return;for(let a=0;a<e.length;a++){let u=e[a];if(u[0]===S&&u[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let t=e;if(this._isTerminal&&!this._resubscribable){let a=e.filter(u=>u[0]===K||u[0]===Ne);if(a.length===0)return;t=a}t=this._frameBatch(t);let o=null;for(let a=0;a<t.length;a++){let u=t[a],d=u[0];if(d!==le&&d!==pe){o?.push(u);continue}if(u.length<2)throw new Error(`Node "${this.name}": [[${d===le?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let c=!0;if(this._pausable!==!1){let l=u[1];if(d===le)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(l),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(l))c=!1;else if(this._pauseLocks.delete(l),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let f=this._pauseBuffer;this._pauseBuffer=[],this._emit(f)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}c?o?.push(u):o==null&&(o=t.slice(0,a))}if(o!=null){if(o.length===0)return;t=o}if(this._hasMeta&&t.some(a=>a[0]===K))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(En)}catch{}let{finalMessages:s,equalsError:i}=this._updateState(t);if(s.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:s})}catch{}}if(s.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,u=[];for(let d of s)a(d[0])===3?this._pauseBuffer.push(d):u.push(d);u.length>0&&this._dispatchOrAccumulate(u)}else this._dispatchOrAccumulate(s);i!=null&&this._emit([[S,i]])}_updateState(e){let t=this._config.tierOf,r,o,s=-1,i=0;for(let c of e)t(c[0])===3&&i++;let a=i<=1,u=-1;if(this._versioning!=null&&i>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===x){u=c;break}}for(let c=0;c<e.length;c++){let l=e[c],f=l[0];if(f===x){if(l.length>=2){let p=!1;if(a&&this._cached!==void 0)try{p=this._equals(this._cached,l[1])}catch(h){o=this._wrapFnError("equals threw",h),s=c;break}if(p){r==null&&(r=e.slice(0,c)),r.push(_n),this._status="resolved";continue}this._cached=l[1],this._versioning!=null&&(u<0||c===u)&&Ir(this._versioning,l[1],this._hashFn)}this._status="settled",r?.push(l)}else if(r?.push(l),f===V)this._status="dirty";else if(f===C)this._status="resolved";else if(f===N){this._status="completed";{let p=this._config.rigorRecorder;if(p!=null)try{p.onTerminalTransition(this,"completed",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(f===S){this._status="errored";{let p=this._config.rigorRecorder;if(p!=null)try{p.onTerminalTransition(this,"errored",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(f===Ne){if(this._cached!==void 0){let h=this._config.rigorRecorder;if(h!=null)try{h.onNonVacuousInvalidate(this,this._cached)}catch{}}this._cached=void 0,this._status="dirty";let p=this._cleanup;if(typeof p=="function"){this._cleanup=void 0;try{p()}catch{}}else if(p!=null&&typeof p=="object"){let h=p.invalidate;if(typeof h=="function")try{h()}catch{}}}else f===K&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let d=s>=0?r??e.slice(0,s):r??e;return o!=null?{finalMessages:d,equalsError:o}:{finalMessages:d}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let t=[...this._sinks];for(let r of t)r(e)};_dispatchOrAccumulate(e){if(Nr()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],ut(()=>this._flushBatchPending()));for(let t of e)this._batchPendingMessages.push(t);return}Ut(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);Ut(this._deliverToSinks,t,this._config.tierOf)}},zr=n=>Array.isArray(n),Bn=n=>typeof n=="object"&&n!=null&&!Array.isArray(n)});function G(n,e){return B([],{...e,initial:n})}function A(n,e){return B((r,o,s)=>n(o,s)??void 0,{describeKind:"producer",...e})}function ye(n,e,t){return B(n,(o,s,i)=>{let a=o.map((u,d)=>u!=null&&u.length>0?u.at(-1):i.prevData[d]);s.emit(e(a,i))},{describeKind:"derived",...t})}function Yt(n,e,t){return B(n,(o,s,i)=>{let a=o.map((u,d)=>u!=null&&u.length>0?u.at(-1):i.prevData[d]);return e(a,s,i)??void 0},{describeKind:"effect",...t})}var fe=q(()=>{"use strict";be()});var $r={};Nn($r,{NS_PER_MS:()=>he,NS_PER_SEC:()=>De,constant:()=>Vn,decorrelatedJitter:()=>Kn,exponential:()=>Fn,fibonacci:()=>zn,linear:()=>Gn,resolveBackoffPreset:()=>lt,withMaxAttempts:()=>Kr});function Je(n){return n<0?0:n}function ks(n,e){return e==="none"?n:e==="full"?Math.random()*n:n/2+Math.random()*(n/2)}function xs(n,e){return n+Math.random()*(e-n)}function Vn(n){let e=Je(n);return()=>e}function Gn(n,e){let t=Je(n),r=e===void 0?t:Je(e);return o=>t+r*Math.max(0,o)}function Fn(n){let e=Je(n?.baseNs??1e8),t=n?.factor!==void 0&&n.factor<1?1:n?.factor??2,r=Je(n?.maxDelayNs??30*1e9),o=n?.jitter??"none";return s=>{let i;if(e===0)i=0;else if(t===1)i=e;else{let a=r/e,u=1;for(let d=0;d<Math.max(0,s);d++){if(u>=a){u=a;break}u*=t}i=e*u,i>r&&(i=r)}return ks(i,o)}}function zn(n=100*1e6,e=30*1e9){let t=Je(n),r=Je(e);function o(s){if(s<=0)return 1;let i=1,a=2;for(let u=1;u<s;u++){let d=i+a;i=a,a=d}return a}return s=>{let i=o(s)*t;return i<=r?i:r}}function Kn(n=100*1e6,e=30*1e9){return(t,r,o)=>{let i=Math.min(e,(o??n)*3);return xs(n,i)}}function Kr(n,e){return(t,r,o)=>t>=e?null:n(t,r,o)}function lt(n){if(n==="constant")return Vn(1*1e9);if(n==="linear")return Gn(1*1e9);if(n==="exponential")return Fn();if(n==="fibonacci")return zn();if(n==="decorrelatedJitter")return Kn();throw new Error(`Unknown backoff preset: "${String(n)}". Use one of: constant, linear, exponential, fibonacci, decorrelatedJitter`)}var he,De,Ct=q(()=>{"use strict";he=1e6,De=1e9});function Wn(n,e){if(e!=null&&e.length>0)return new Set(e);switch(n){case"standard":return new Set(["type","status","value","deps","meta","v"]);case"full":return null;case"spec":return new Set(["type","deps","meta","value"]);default:return new Set(["type","deps"])}}function Ns(n){return n._describeKind!=null?n._describeKind:n._deps.length>0?"derived":n._fn!=null?"producer":"state"}function Wr(n){let e=new WeakSet,t={};for(let[r,o]of Ur(n))t[r]=jn(o,e);return t}function jn(n,e){if(n==null)return n;let t=typeof n;if(t==="boolean"||t==="number"||t==="string")return n;if(t==="function")return"<function>";if(Array.isArray(n))return e.has(n)?"<cycle>":(e.add(n),n.map(r=>jn(r,e)));if(t==="object"){let r=n;if(e.has(r))return"<cycle>";e.add(r);try{if(typeof r.subscribe=="function"&&"cache"in r)return"<Node>"}catch{return"<unserializable>"}let o={};for(let[s,i]of Ur(r))o[s]=jn(i,e);return o}return"<unserializable>"}function Ur(n){let e=[],t;try{t=Object.keys(n)}catch{return e}for(let r of t)try{e.push([r,n[r]])}catch{e.push([r,"<unserializable>"])}return e}function J(n,e){let t={factory:n};return e!==void 0&&(t.factoryArgs=e),t}function _s(n){let e={};for(let[t,r]of Object.entries(n.meta))try{e[t]=r.cache}catch{}return e}function Un(n,e,t){let r=e==null,o=!r&&e!=null?[...e].filter(c=>c.startsWith("meta.")).map(c=>c.slice(5)):null,s=r||e.has("meta")||o!=null&&o.length>0,i="state",a=[];n instanceof oe&&(i=Ns(n),a=n._deps.map(c=>c.node.name??""));let u={type:i,deps:a};(r||e.has("status"))&&(u.status=n.status);let d=n instanceof oe?n._guard:void 0;if(s){let c={..._s(n)};if(d!=null&&c.access===void 0&&(c.access=Cn(d)),o!=null&&o.length>0&&!e.has("meta")){let l={};for(let f of o)f in c&&(l[f]=c[f]);u.meta=l}else u.meta=c}if(n.name!=null&&(u.name=n.name),(r||e.has("value"))&&(!t||i==="state")){n.status==="sentinel"&&(u.sentinel=!0);try{u.value=n.cache}catch{}}if((r||e.has("v"))&&n.v!=null){let c={id:n.v.id,version:n.v.version};"cid"in n.v&&(c.cid=n.v.cid,c.prev=n.v.prev),u.v=c}return(r||e.has("guard"))&&d!=null&&(u.guard=Cn(d)),(r||e.has("lastMutation"))&&n.lastMutation!=null&&(u.lastMutation=n.lastMutation),u}var pt=q(()=>{"use strict";At();be()});function Pt(n,e,t){let r=new Set;for(let o of n.split(",")){let[s,i]=o.split("/"),a=i?Number.parseInt(i,10):1;if(Number.isNaN(a)||a<1)throw new Error(`Invalid cron step: ${o}`);let u,d;if(s==="*")u=e,d=t;else if(s.includes("-")){let[c,l]=s.split("-");u=Number.parseInt(c,10),d=Number.parseInt(l,10)}else u=Number.parseInt(s,10),d=u;if(Number.isNaN(u)||Number.isNaN(d))throw new Error(`Invalid cron field: ${n}`);if(u<e||d>t)throw new Error(`Cron field out of range: ${n} (${e}-${t})`);if(u>d)throw new Error(`Invalid cron range: ${u}-${d} in ${n}`);for(let c=u;c<=d;c+=a)r.add(c)}return r}function Hn(n){let e=n.trim().split(/\s+/);if(e.length!==5)throw new Error(`Invalid cron: expected 5 fields, got ${e.length}`);return{minutes:Pt(e[0],0,59),hours:Pt(e[1],0,23),daysOfMonth:Pt(e[2],1,31),months:Pt(e[3],1,12),daysOfWeek:Pt(e[4],0,6)}}function qn(n,e){return n.minutes.has(e.getMinutes())&&n.hours.has(e.getHours())&&n.daysOfMonth.has(e.getDate())&&n.months.has(e.getMonth()+1)&&n.daysOfWeek.has(e.getDay())}var Jn=q(()=>{"use strict"});function ve(n,e,t){return{[n]:!0,[`${n}_type`]:e,...t??{}}}var Qt=q(()=>{"use strict"});function Ye(n,e,t){if(e.length===0)throw new RangeError("budgetGate requires at least one constraint");let r=e.map(p=>p.node),o=[n,...r],s=new Yn,i=!1,a=!1,u=Symbol("budget-gate"),d=new Array(e.length);function c(){return e.every((p,h)=>p.check(d[h]))}function l(p){for(;s.size>0&&c();){let h=s.shift();p.emit(h)}s.size===0&&a&&(a=!1,p.down([[C]]))}return B([],(p,h)=>{for(let m=0;m<e.length;m++)d[m]=e[m].node.cache;let g=[];for(let m=0;m<o.length;m++){let y=o[m];g.push(y.subscribe(b=>{for(let v of b)f(v,m,h)}))}return()=>{for(let m of g)m()}},{...t,describeKind:"derived",meta:ve("resilience","budget_gate",t?.meta)});function f(p,h,g){let m=p[0];if(h===0){if(m===x)return c()&&s.size===0?g.emit(p[1]):(s.push(p[1]),i||(i=!0,g.up([[le,u]]))),!0;if(m===V)return g.down([[V]]),!0;if(m===C)return s.size===0?g.down([[C]]):a=!0,!0;if(m===N||m===S){for(;s.size>0;)g.emit(s.shift());return a=!1,i&&(i=!1,g.up([[pe,u]])),g.down([p]),!0}return!1}if(m===x&&(d[h-1]=p[1]),m===x||m===C){let y=c();return y&&s.size>0?(l(g),s.size===0&&i&&(i=!1,g.up([[pe,u]]))):!y&&!i&&s.size>0&&(i=!0,g.up([[le,u]])),!0}return m===V?!0:m===S?(g.down([p]),!0):m===N}}var Yn,Hr=q(()=>{"use strict";Z();be();Qt();Yn=class{buf=[];head=0;get size(){return this.buf.length-this.head}push(e){this.buf.push(e)}shift(){if(this.head>=this.buf.length)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head++,this.head>32&&this.head*2>this.buf.length&&(this.buf=this.buf.slice(this.head),this.head=0),e}clear(){this.buf=[],this.head=0}}});function qr(n){let e=new WeakSet,t=new WeakSet,r=[n],o=0;for(;r.length>0;){let s=r.pop();o+=Os(s,e,t,r)}return o}function Os(n,e,t,r){if(n==null)return 0;switch(typeof n){case"number":return se.number;case"boolean":return se.boolean;case"string":return se.string+n.length*2;case"bigint":return se.bigint+Es(n);case"symbol":return se.symbol;case"function":return e.has(n)?0:(e.add(n),se.function);case"undefined":return 0}let s=n;if(e.has(s))return 0;e.add(s);let i=s[Ss];if(typeof i=="function")try{let d=i.call(s);if(typeof d=="number"&&Number.isFinite(d))return d}catch{}if(s instanceof Date)return se.date;if(s instanceof RegExp)return se.regexp+s.source.length*2;if(s instanceof Error){let d=s.message?s.message.length*2:0,c=s.stack?s.stack.length*2:0;return se.error+d+c}if(typeof URL<"u"&&s instanceof URL)return se.url+s.href.length*2;if(typeof Promise<"u"&&s instanceof Promise)return se.promise;if(s instanceof WeakMap)return se.weakmap;if(s instanceof WeakSet)return se.weakset;if(s instanceof Map){let d=se.map;for(let[c,l]of s)d+=se.mapEntry,r.push(c),r.push(l);return d}if(s instanceof Set){let d=se.set;for(let c of s)d+=se.setEntry,r.push(c);return d}if(Array.isArray(s)){let d=se.array+s.length*8;for(let c of s)r.push(c);return d}if(s instanceof ArrayBuffer)return t.has(s)?0:(t.add(s),s.byteLength);if(ArrayBuffer.isView(s)){let d=s;return t.has(d.buffer)?48:(t.add(d.buffer),d.buffer.byteLength+48)}let a=se.object,u=Object.keys(s);for(let d of u){a+=se.string+d.length*2;try{r.push(s[d])}catch{}}return a}function Es(n){let e=n<0n?-n:n;if(e===0n)return 0;let t=e.toString(2).length;return Math.ceil(t/32)*8}var se,Ss,Jr=q(()=>{"use strict";se={object:56,array:64,string:40,number:8,boolean:4,null:0,undefined:0,symbol:40,bigint:16,function:120,map:72,set:72,mapEntry:40,setEntry:24,date:24,regexp:48,error:64,url:80,promise:48,weakmap:40,weakset:40},Ss=Symbol.for("sizeof")});function Yr(n,e,t,r={}){let o=e in n.nodes,s=t in n.nodes;if(!o)return Xt(e,t,"no-such-from");if(!s)return Xt(e,t,"no-such-to");let i=r.maxDepth;if(i!=null&&(!Number.isInteger(i)||i<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(e===t){if(r.findCycle===!0){let d=Rs(n,e,r);if(d!=null)return d}let u=Zt(e,n.nodes[e],0,r);return en(e,t,[u])}if(i===0)return Xt(e,t,"no-path");let a=Qr(n,e,t,i);return a.found?en(e,t,Xr(n,a.pathOrder,r)):Xt(e,t,a.truncated?"max-depth-exceeded":"no-path")}function Qr(n,e,t,r){let o=new Map,s=[{path:t,depth:0}],i=new Set([t]),a=0,u=!1;for(;a<s.length;){let l=s[a++];if(l.path===e)break;if(r!=null&&l.depth>=r){let g=n.nodes[l.path];g?.deps&&g.deps.length>0&&(u=!0);continue}let f=n.nodes[l.path];if(f==null)continue;let p=f.deps??[],h=new Map;for(let g=0;g<p.length;g++){let m=p[g];if(!m)continue;let y=h.get(m);y==null&&(y=[],h.set(m,y)),y.push(g)}for(let[g,m]of h)i.has(g)||(i.add(g),o.set(g,{from:l.path,depIndices:m}),s.push({path:g,depth:l.depth+1}))}if(!o.has(e))return{found:!1,pathOrder:[],truncated:u};let d=[{path:e}],c=e;for(;c!==t;){let l=o.get(c);if(l==null)return{found:!1,pathOrder:[],truncated:!1};d[d.length-1].depIndices=l.depIndices,d.push({path:l.from}),c=l.from}return{found:!0,pathOrder:d,truncated:!1}}function Rs(n,e,t){let r=n.nodes[e];if(r==null)return null;let o=r.deps??[],s=[];for(let a=0;a<o.length;a++)o[a]===e&&s.push(a);if(s.length>0){let a=Zt(e,r,0,t);a.dep_index=s[0];let u=Zt(e,r,1,t);return en(e,e,[a,u])}let i=null;for(let a=0;a<o.length;a++){let u=o[a];if(!u||u===e)continue;let d=Qr(n,u,e,t.maxDepth);d.found&&(i==null||d.pathOrder.length<i.pathOrder.length)&&(i=d,i={found:!0,pathOrder:[{path:e,depIndices:[a]},...d.pathOrder],truncated:!1})}return i==null?null:en(e,e,Xr(n,i.pathOrder,t))}function Xr(n,e,t){return e.map((r,o)=>{let s=n.nodes[r.path],i=Zt(r.path,s,o,t);return r.depIndices!=null&&r.depIndices.length>0&&(i.dep_index=r.depIndices[0],r.depIndices.length>1&&(i.dep_indices=[...r.depIndices])),i})}function Zt(n,e,t,r){let o={path:n,type:e.type,hop:t};e.status!==void 0&&(o.status=e.status),"value"in e&&(o.value=e.value),e.v!=null&&(o.v=e.v);let s=r.annotations?.get(n)??e.annotation;s!=null&&(o.annotation=s);let i=r.lastMutations?.get(n)??e.lastMutation;return i!=null&&(o.lastMutation=i),o}function en(n,e,t){return Zr(n,e,!0,"ok",t)}function Xt(n,e,t){return Zr(n,e,!1,t,[])}function Zr(n,e,t,r,o){let s=Ms(n,e,t,r,o);return{from:n,to:e,found:t,reason:r,steps:o,text:s,toJSON(){return{from:n,to:e,found:t,reason:r,steps:o}}}}function Ms(n,e,t,r,o){if(!t)switch(r){case"no-such-from":return`explainPath: no node named "${n}"`;case"no-such-to":return`explainPath: no node named "${e}"`;case"max-depth-exceeded":return`explainPath: no path from "${n}" to "${e}" within maxDepth`;default:return`explainPath: no path from "${n}" to "${e}"`}let s=[`Causal path: ${n} \u2192 ${e} (${o.length} step(s))`];for(let i of o){let u=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(s.push(u),"value"in i&&s.push(` value: ${As(i.value)}`),i.annotation!=null&&s.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let d=i.lastMutation.actor;s.push(` actor: ${d.type}${d.id?`:${d.id}`:""}`)}}return s.join(`
2
- `)}function As(n){if(n===void 0)return"<sentinel>";if(n===null)return"null";if(typeof n=="string")return JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean"||typeof n=="bigint")return String(n);try{let e=JSON.stringify(n);return e.length>80?`${e.slice(0,77)}...`:e}catch{return String(n)}}var eo=q(()=>{"use strict"});function Qn(n,e){if(Object.is(n,e))return!0;if(n==null||e==null||typeof n!="object"||typeof e!="object")return!1;if(Array.isArray(n)){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let s=0;s<n.length;s++)if(!Qn(n[s],e[s]))return!1;return!0}if(Array.isArray(e))return!1;let t=Object.keys(n),r=Object.keys(e);if(t.length!==r.length)return!1;let o=new Set(r);for(let s of t)if(!o.has(s)||!Qn(n[s],e[s]))return!1;return!0}function to(n,e){return`${n}\0${e}`}function Dt(n,e){let t=[],r=new Set(n.subgraphs),o=new Set(e.subgraphs),s=[];for(let m of o)r.has(m)||s.push(m);s.sort();for(let m of s)t.push({type:"subgraph-mounted",path:m});let i=new Set(Object.keys(n.nodes)),a=new Set(Object.keys(e.nodes)),u=[];for(let m of a)i.has(m)||u.push(m);u.sort();for(let m of u)t.push({type:"node-added",path:m,node:{...e.nodes[m]}});let d=[];for(let m of a){if(!i.has(m))continue;let y=n.nodes[m]?.meta,b=e.nodes[m]?.meta;y==null&&b==null||Qn(y??{},b??{})||d.push(m)}d.sort();for(let m of d)t.push({type:"node-meta-changed",path:m,prevMeta:n.nodes[m]?.meta??{},nextMeta:e.nodes[m]?.meta??{}});let c=new Map;for(let m of n.edges)c.set(to(m.from,m.to),m);let l=new Map;for(let m of e.edges)l.set(to(m.from,m.to),m);let f=[];for(let[m,y]of l)c.has(m)||f.push(y);f.sort((m,y)=>m.from<y.from?-1:m.from>y.from?1:m.to<y.to?-1:m.to>y.to?1:0);for(let m of f)t.push({type:"edge-added",from:m.from,to:m.to});let p=[];for(let[m,y]of c)l.has(m)||p.push(y);p.sort((m,y)=>m.from<y.from?-1:m.from>y.from?1:m.to<y.to?-1:m.to>y.to?1:0);for(let m of p)t.push({type:"edge-removed",from:m.from,to:m.to});let h=[];for(let m of i)a.has(m)||h.push(m);h.sort();for(let m of h)t.push({type:"node-removed",path:m});let g=[];for(let m of r)o.has(m)||g.push(m);g.sort();for(let m of g)t.push({type:"subgraph-unmounted",path:m});return{events:t,flushedAt_ns:re()}}var Xn=q(()=>{"use strict";Pe()});var Le,tn=q(()=>{"use strict";Le=class{_timer;_gen=0;start(e,t){this.cancel(),this._gen+=1;let r=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,r===this._gen&&t()},e)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});var Ge,nn=q(()=>{"use strict";Ge=class{constructor(e){this.capacity=e;if(!Number.isInteger(e)||e<=0)throw new Error(`RingBuffer capacity must be a positive integer (got ${e})`);this.buf=new Array(e)}buf;head=0;_size=0;get size(){return this._size}get maxSize(){return this.capacity}push(e){let t=(this.head+this._size)%this.capacity;this.buf[t]=e,this._size<this.capacity?this._size++:this.head=(this.head+1)%this.capacity}shift(){if(this._size===0)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head=(this.head+1)%this.capacity,this._size--,e}at(e){if(this._size===0)return;let t=e<0?this._size+e:e;if(!(t<0||t>=this._size))return this.buf[(this.head+t)%this.capacity]}toArray(){let e=new Array(this._size);for(let t=0;t<this._size;t++)e[t]=this.buf[(this.head+t)%this.capacity];return e}clear(){for(let e=0;e<this._size;e++)this.buf[(this.head+e)%this.capacity]=void 0;this.head=0,this._size=0}}});function no(n,e){let t=e?.topN??10,r=n.describe({detail:"standard"}),o=[],s=n._collectObserveTargets;typeof s=="function"&&s.call(n,"",o);let i=new Map;for(let[f,p]of o)i.set(f,p);let a=[];for(let[f,p]of Object.entries(r.nodes)){let h=i.get(f),g=h instanceof oe?h:null,m=g?qr(g.cache):0,y=g?g._sinkCount:0,b=p.deps?.length??0,v=p.type==="effect"&&y===0,T=y===0?p.type==="effect"?"orphan-effect":p.type==="derived"?"idle-derived":p.type==="producer"?"idle-producer":null:null;a.push({path:f,type:p.type,status:p.status??"unknown",valueSizeBytes:m,subscriberCount:y,depCount:b,isOrphanEffect:v,orphanKind:T})}let u=a.reduce((f,p)=>f+p.valueSizeBytes,0),d=(f,p)=>[...a].sort(p??((h,g)=>g[f]-h[f])).slice(0,t),c=a.filter(f=>f.orphanKind!=null),l=a.filter(f=>f.isOrphanEffect);return{nodeCount:a.length,edgeCount:r.edges.length,subgraphCount:r.subgraphs.length,nodes:a,totalValueSizeBytes:u,hotspots:{byValueSize:d("valueSizeBytes"),bySubscriberCount:d("subscriberCount"),byDepCount:d("depCount")},orphans:c,orphanEffects:l}}var ro=q(()=>{"use strict";be();Jr()});function oo(n,e){let t=Math.max(16,n.size*4),r=0;for(;n.size>0;){if(r++>=t){console.error(`[Graph "${e}".destroy] disposer drain exceeded cap (${t}); ${n.size} disposer(s) discarded`),n.clear();return}let o=n.values().next();if(o.done)return;let s=o.value;n.delete(s);try{s()}catch(i){console.error(`[Graph "${e}".destroy] disposer threw:`,i)}}}function co(n){return n!=null&&typeof n=="object"&&"cache"in n&&typeof n.subscribe=="function"&&typeof n.down=="function"}function Cs(n){if(n!=null)return co(n)?n.cache:n}function Xe(n){return n!=null&&typeof n=="object"&&"cache"in n&&typeof n.subscribe=="function"&&typeof n.down=="function"}function $e(n){return Xe(n)?n.cache??"":n}function so(n){return Xe(n)?n.cache??0:n}function io(n){return Xe(n)?n.cache??!1:n}function Ps(n){let e=[];for(let t of Object.keys(n).sort()){let r=n[t].v;r!=null&&e.push(`${t} ${r.id} ${r.version}`)}return e.join(`
3
- `)}function ao(n){if(n.version!==Qe)throw new Error(`unsupported snapshot version ${String(n.version)} (expected ${Qe})`);for(let e of["name","nodes","edges","subgraphs"])if(!(e in n))throw new Error(`snapshot missing required key "${e}"`);if(typeof n.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof n.nodes!="object"||n.nodes===null||Array.isArray(n.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(n.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(n.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function Ds(n,e){let t=new WeakMap,r=(o,s)=>{if(Object.is(o,s))return!0;if(o==null||s==null||typeof o!="object"||typeof s!="object")return!1;let i=t.get(o);if(i==null&&(i=new WeakSet,t.set(o,i)),i.has(s))return!0;i.add(s);let a=o.constructor,u=s.constructor;if(a!==u)return!1;if(o instanceof Date)return o.getTime()===s.getTime();if(o instanceof RegExp)return o.source===s.source&&o.flags===s.flags;if(Array.isArray(o)){let f=s;if(o.length!==f.length)return!1;for(let p=0;p<o.length;p++)if(!r(o[p],f[p]))return!1;return!0}if(o instanceof Map){let f=s;if(o.size!==f.size)return!1;for(let[p,h]of o)if(!f.has(p)||!r(h,f.get(p)))return!1;return!0}if(o instanceof Set){let f=s;if(o.size!==f.size)return!1;for(let p of o){let h=!1;for(let g of f)if(r(p,g)){h=!0;break}if(!h)return!1}return!0}if(ArrayBuffer.isView(o)){let f=o,p=s;if(f.length!==p.length)return!1;for(let h=0;h<f.length;h++)if(f[h]!==p[h])return!1;return!0}let d=Object.keys(o),c=Object.keys(s);if(d.length!==c.length)return!1;let l=new Set(c);for(let f of d)if(!l.has(f)||!r(o[f],s[f]))return!1;return!0};return r(n,e)}function Ls(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function rn(n){let e="^";for(let t=0;t<n.length;t+=1){let r=n[t];if(r==="*"){e+=".*";continue}if(r==="?"){e+=".";continue}if(r==="["){let o=n.indexOf("]",t+1);if(o<=t+1){e+="\\[";continue}let s=n.slice(t+1,o);s.startsWith("!")&&(s=`^${s.slice(1)}`),s=s.replace(/\\/g,"\\\\"),e+=`[${s}]`,t=o;continue}e+=Ls(r)}return e+="$",new RegExp(e)}function Zn(n){if(typeof n=="string")return JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean"||n==null)return String(n);try{return JSON.stringify(n)}catch{return"[unserializable]"}}function Vs(n){return n==="none"?Bs:n==="ansi"||n==null?Is:{data:n.data??"",dirty:n.dirty??"",resolved:n.resolved??"",invalidate:n.invalidate??"",pause:n.pause??"",resume:n.resume??"",complete:n.complete??"",error:n.error??"",teardown:n.teardown??"",derived:n.derived??"",path:n.path??"",reset:n.reset??""}}function uo(n){if(n==null)return{};let e=n.detail;return e==="full"?{...n,structured:n.structured??!0,timeline:n.timeline??!0,causal:n.causal??!0,derived:n.derived??!0}:e==="minimal"?{...n,structured:n.structured??!0}:n.format==="stage-log"?{...n,structured:n.structured??!0,timeline:n.timeline??!0}:n}function Gs(n,e,t){for(let r=0;r<n.length;r++){let o=n.charCodeAt(r);if(o<32||o===127)throw new Error(`Graph "${e}": ${t} "${n}" must not contain control character (U+${o.toString(16).padStart(4,"0").toUpperCase()} at index ${r})`)}}function er(n,e,t){if(n==="")throw new Error(`Graph "${e}": ${t} name must be non-empty`);if(n.includes(te))throw new Error(`Graph "${e}": ${t} "${n}" must not contain '${te}' (path separator)`);if(n===Me)throw new Error(`Graph "${e}": ${t} name "${Me}" is reserved for meta companion paths`);Gs(n,e,t)}function Fs(n,e){if(n==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let t=n.split(te);for(let r of t)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return t}function zs(n,e){let t=!1;for(let o of n)if(!e.isMetaPassthrough(o[0])){t=!0;break}return t?n.filter(o=>e.isMetaPassthrough(o[0])):n}function lo(n){for(let e of n._mounts.values())lo(e);for(let e of n._nodes.values())try{e.down([[K]],{internal:!0})}catch{}}function fo(n,e){let t=Ie.diff(n,e),r={};for(let o of t.nodesAdded){let s=e.nodes[o];s!=null&&(r[o]=s)}return{...t,nodesAddedFull:r}}function tr(n,e,t,r={}){let o={paths:[],depths:new Map,truncated:!1};if(!e)return r.withDetail?o:[];if(!r.both&&t!=="upstream"&&t!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let s=r.maxDepth;if(s!=null&&(!Number.isInteger(s)||s<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(s===0)return r.withDetail?o:[];let i=new Map,a=new Map,u=new Map,d=new Map,c=new Set;for(let[v,T]of Object.entries(n.nodes)){if(!v)continue;c.add(v);let w=T.deps??[];i.set(v,w);for(let _ of w)_&&(c.add(_),a.has(_)||a.set(_,new Set),a.get(_).add(v))}for(let v of n.edges){if(v==null||typeof v!="object")continue;let T=typeof v.from=="string"?v.from:"",w=typeof v.to=="string"?v.to:"";!T||!w||(c.add(T),c.add(w),d.has(T)||d.set(T,new Set),d.get(T).add(w),u.has(w)||u.set(w,new Set),u.get(w).add(T))}if(!c.has(e))return r.withDetail?o:[];let l=r.both===!0,f=v=>{if(l){let k=i.get(v)??[],O=u.get(v),E=a.get(v),R=d.get(v),M=[...k];return O&&M.push(...O),E&&M.push(...E),R&&M.push(...R),M}if(t==="upstream"){let k=i.get(v)??[],O=u.get(v);return O?[...k,...O]:k}let T=a.get(v),w=d.get(v),_=T?[...T]:[];return w&&_.push(...w),_},p=new Set([e]),h=new Map,g=[{path:e,depth:0}],m=0,y=!1;for(;m<g.length;){let v=g[m++];if(s!=null&&v.depth>=s){f(v.path).length>0&&(y=!0);continue}for(let T of f(v.path))!T||p.has(T)||(p.add(T),h.set(T,v.depth+1),g.push({path:T,depth:v.depth+1}))}let b=[...h.keys()].sort((v,T)=>v<T?-1:v>T?1:0);return r.withDetail?{paths:b,depths:h,truncated:y}:b}function Ks(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++){let r=n[t],o=e[t];if(r.path!==o.path||r.type!==o.type||r.status!==o.status||r.hop!==o.hop||r.dep_index!==o.dep_index||r.annotation!==o.annotation||r.value!==o.value||r.lastMutation!==o.lastMutation)return!1;let s=r.v,i=o.v;if(s!==i&&(s==null||i==null||s.id!==i.id||s.version!==i.version))return!1}return!0}var te,Me,Qe,Is,Bs,Ie,on=q(()=>{"use strict";An();Te();Pe();At();Z();pt();be();fe();Xn();Be();tn();nn();Mn();eo();ro();te="::",Me="__meta__",Qe=1;Is={data:"\x1B[32m",dirty:"\x1B[33m",resolved:"\x1B[36m",invalidate:"\x1B[93m",pause:"\x1B[90m",resume:"\x1B[96m",complete:"\x1B[34m",error:"\x1B[31m",teardown:"\x1B[91m",derived:"\x1B[35m",path:"\x1B[90m",reset:"\x1B[0m"},Bs={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};Ie=class n{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_destroyed=!1;_topology;_topologyEmitters=new Set;_factory;_factoryArgs;constructor(e,t){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(te))throw new Error(`Graph name must not contain '${te}' (got "${e}")`);if(e===Me)throw new Error(`Graph name "${Me}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...t??{}}),this.config=t?.config??ge,this._traceRing=new Ge(t?.traceCapacity??1e3),t?.versioning!=null&&this.setVersioning(t.versioning),typeof t?.factory=="string"&&(this._factory=t.factory,t.factoryArgs!==void 0&&(this._factoryArgs=t.factoryArgs))}tagFactory(e,t){return this._factory=e,this._factoryArgs=t,this}ancestors(e=!0){let t=[],r=e?this:this._parent;for(;r!=null;)t.push(r),r=r._parent;return t}get topology(){return this._topology==null&&(this._topology=A(e=>{let t=r=>{e.emit(r)};return this._topologyEmitters.add(t),()=>{this._topologyEmitters.delete(t)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let t of this._topologyEmitters)t(e)}nameOf(e){return this._nodeToName.get(e)}add(e,t){let r=e.name,o=t?.name??r;if(o==null||o==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let s=o,i=t?.annotation;if(er(s,this.name,"add"),this._mounts.has(s))throw new Error(`Graph "${this.name}": name "${s}" is already a mount point`);if(this._nodes.has(s))throw new Error(`Graph "${this.name}": node "${s}" already exists`);let a=this._nodeToName.get(e);if(a!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${a}"`);return this._nodes.set(s,e),this._nodeToName.set(e,s),this._emitTopology({kind:"added",name:s,nodeKind:"node"}),i!=null&&(this._annotations.set(s,i),this.config.inspectorEnabled&&this._traceRing.push({path:s,annotation:i,timestamp_ns:re()})),e}setVersioning(e){if(e!=null)for(let t of this._nodes.values())t instanceof oe&&t._applyVersioning(e)}remove(e){er(e,this.name,"remove");let t=this._mounts.get(e);if(t){let s={kind:"mount",nodes:[],mounts:[]},i=[];t._collectObserveTargets("",i);for(let[a,u]of i)a.includes(`${te}${Me}${te}`)||s.nodes.push(a);return s.nodes.sort(),s.mounts.push(e),s.mounts.push(...t._collectSubgraphs(`${e}${te}`)),this._mounts.delete(e),t._parent=void 0,lo(t),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:s}),s}let r=this._nodes.get(e);if(!r)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(r),r.down([[K]],{internal:!0});let o={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:o}),o}removeAll(e){let t=typeof e=="function"?e:(()=>{let s=rn(e);return i=>s.test(i)})(),r={kind:"mount",nodes:[],mounts:[]},o=[...this._nodes.keys(),...this._mounts.keys()].filter(s=>t(s));for(let s of o){let i=this.remove(s);r.nodes.push(...i.nodes),r.mounts.push(...i.mounts)}return r.nodes.sort(),r.mounts.sort(),r}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),t=this._nodes,r=0;return{[Symbol.iterator](){return this},next(){if(r>=e.length)return{value:void 0,done:!0};let o=e[r++];return{value:[o,t.get(o)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(te))return this.resolve(e);let t=this._nodes.get(e);if(!t)throw new Error(`Graph "${this.name}": unknown node "${e}"`);return t}get(e){return this.node(e).cache}set(e,t,r){let o=r?.internal===!0;this.node(e).down([[x,t]],{actor:r?.actor,internal:o,delivery:"write"})}setAll(e,t){let r=Symbol.iterator in e?e:Object.entries(e);$(()=>{for(let[o,s]of r)this.set(o,s,t)})}invalidate(e,t){let r=t?.internal===!0;this.node(e).down([[Ne]],{actor:t?.actor,internal:r,delivery:"write"})}error(e,t,r){let o=r?.internal===!0;this.node(e).down([[S,t]],{actor:r?.actor,internal:o,delivery:"write"})}complete(e,t){let r=t?.internal===!0;this.node(e).down([[N]],{actor:t?.actor,internal:r,delivery:"write"})}edges(e){let t=e?.recursive===!0,r=new Map;if(!t){for(let[u,d]of this._nodes)r.set(d,u);let a=[];for(let[u,d]of this._nodes)if(d instanceof oe)for(let c of d._deps){let l=r.get(c.node);l!=null&&a.push([l,u])}return a.sort((u,d)=>u[0]<d[0]?-1:u[0]>d[0]?1:u[1]<d[1]?-1:u[1]>d[1]?1:0),a}let o=[];this._collectObserveTargets("",o);let s=new Map;for(let[a,u]of o)s.set(u,a);let i=[];for(let[a,u]of o)if(u instanceof oe)for(let d of u._deps){let c=s.get(d.node);c!=null&&i.push([c,a])}return i.sort((a,u)=>a[0]<u[0]?-1:a[0]>u[0]?1:a[1]<u[1]?-1:a[1]>u[1]?1:0),i}mount(e,t){if(t===void 0){let o=new n(e);return this.mount(e,o)}if(typeof t=="function"){let o=new n(e);return t(o),this.mount(e,o)}let r=t;if(er(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(r===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(r._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${r._parent.name}"`);for(let o=this;o!=null;o=o._parent)if(o===r)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,r),r._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),r}resolve(e){let t=Fs(e,this.name);return this._resolveFromSegments(t)}tryResolve(e){try{return this.resolve(e)}catch{return}}_resolveFromSegments(e){let t=e;if(t[0]===this.name&&(t=t.slice(1),t.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let r=t[0],o=t.slice(1);if(o.length===0){let a=this._nodes.get(r);if(a)return a;throw this._mounts.has(r)?new Error(`Graph "${this.name}": path ends at subgraph "${r}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${r}"`)}let s=this._nodes.get(r);if(s&&o.length>0&&o[0]===Me)return this._resolveMetaChainFromNode(s,o,t.join(te));let i=this._mounts.get(r);if(!i)throw this._nodes.has(r)?new Error(`Graph "${this.name}": "${r}" is a node; trailing path "${o.join(te)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(o.join(te))}_resolveMetaChainFromNode(e,t,r){let o=e,s=0,i=[...t];for(;s<i.length;){if(i[s]!==Me)throw new Error(`Graph "${this.name}": expected ${Me} segment in meta path "${r}"`);if(s+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${Me} in "${r}"`);let a=i[s+1],u=o.meta[a];if(!u)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);o=u,s+=2}return o}signal(e,t){if(t?.internal!==!0){for(let o of e)if(this.config.messageTier(o[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let r=[];if(this._signalDeliver(e,t??{},new Set,r),r.length>0)throw r[0]}_signalDeliver(e,t,r,o){for(let u of this._mounts.values())u._signalDeliver(e,t,r,o);let i=t.internal===!0?{internal:!0}:{actor:t.actor,delivery:"signal"},a=zs(e,this.config);for(let u of[...this._nodes.keys()].sort()){let d=this._nodes.get(u);if(!r.has(d)){r.add(d);try{d.down(e,i)}catch(c){if(c instanceof Re)throw c;o.push(c)}a.length!==0&&this._signalMetaSubtree(d,a,r,i,o)}}}_signalMetaSubtree(e,t,r,o,s){for(let i of Object.keys(e.meta).sort()){let a=e.meta[i];if(!r.has(a)){r.add(a);try{a.down(t,o)}catch(u){if(u instanceof Re)throw u;s.push(u)}this._signalMetaSubtree(a,t,r,o,s)}}}describe(e){if(e?.reactive==="diff")return this._describeReactiveDiff(e);if(e?.reactive===!0)return this._describeReactive(e);let t=Cs(e?.actor),r=e?.filter;if(e?.detail!=null&&e?.fields!=null)throw new TypeError("Graph.describe(): pass either `detail` or `fields`, not both. `detail: 'spec'` is the canonical spec projection; use `fields` only when you need a custom subset.");let o=Wn(e?.detail,e?.fields),s=e?.detail==="spec",i=o,a=[];this._collectObserveTargets("",a);let u=new Map;for(let[T,w]of a)u.set(w,T);let d=[];{let T=a.map(([,k])=>k),w=new Set(u.values()),_=0;for(;T.length>0;){let k=T.shift();if(k instanceof oe)for(let O of k._deps){let E=O.node;if(u.has(E))continue;let R=E.name??"",M=R;if(!M||w.has(M))if(R){let F=2;for(;w.has(`${R}#${F}`);)F++;M=`${R}#${F}`}else for(M=`__internal__/${_++}`;w.has(M);)M=`__internal__/${_++}`;u.set(E,M),w.add(M),d.push([M,E]),T.push(E)}}}let c=[...a,...d],l={};for(let[T,w]of c){if(t!=null&&!w.allowsObserve(t))continue;let _=Un(w,i,s),k=w instanceof oe?w._deps.map(M=>u.get(M.node)??M.node.name??""):[],{name:O,...E}=_,R={...E,deps:k};if(!s){let M=this._annotations.get(T);M!=null&&(R.annotation=M)}if(r!=null)if(typeof r=="function"){let M=r;if(!(M.length>=2?M(T,R):M(R)))continue}else{let M=!0;for(let[F,P]of Object.entries(r)){let I=F==="deps_includes"?"depsIncludes":F==="meta_has"?"metaHas":F;if(I==="depsIncludes"){if(!R.deps.includes(String(P))){M=!1;break}continue}if(I==="metaHas"){if(!Object.hasOwn(R.meta??{},String(P))){M=!1;break}continue}if(R[I]!==P){M=!1;break}}if(!M)continue}l[T]=R}let f=new Set(Object.keys(l)),p=[];for(let[T,w]of c)if(w instanceof oe)for(let _ of w._deps){let k=u.get(_.node);k!=null&&p.push([k,T])}p.sort((T,w)=>T[0]<w[0]?-1:T[0]>w[0]?1:T[1]<w[1]?-1:T[1]>w[1]?1:0);let h=p.map(([T,w])=>({from:T,to:w}));(t!=null||r!=null)&&(h=h.filter(T=>f.has(T.from)&&f.has(T.to)));let g=this._collectSubgraphs(""),m=t!=null||r!=null?g.filter(T=>{let w=`${T}${te}`;return[...f].some(_=>_===T||_.startsWith(w))}):g,y=this,b=e;return{name:this.name,nodes:l,edges:h,subgraphs:m,...this._factory!==void 0?{factory:this._factory}:{},...this._factoryArgs!==void 0?{factoryArgs:this._factoryArgs}:{},expand(T){let w={...b};return Array.isArray(T)?(w.fields=T,w.detail=void 0):(w.detail=T,w.fields=void 0),y.describe(w)}}}_collectSubgraphs(e){let t=[];for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${r}`;t.push(o),t.push(...this._mounts.get(r)._collectSubgraphs(`${o}${te}`))}return t}resourceProfile(e){return no(this,e)}reachable(e,t,r={}){return r.withDetail===!0?tr(this.describe(),e,t,{...r,withDetail:!0}):tr(this.describe(),e,t,r)}explain(e,t,r){return r?.reactive===!0?this._explainReactive(e,t,r):this._explainStatic($e(e),$e(t),{...r?.maxDepth!==void 0?{maxDepth:so(r.maxDepth)}:{},...r?.findCycle!==void 0?{findCycle:io(r.findCycle)}:{}})}_explainStatic(e,t,r){let o=this.describe({detail:"full"}),s=new Map(this._annotations),i=new Map;for(let[a,u]of Object.entries(o.nodes))u.lastMutation!=null&&i.set(a,u.lastMutation);return Yr(o,e,t,{...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{},annotations:s,lastMutations:i})}_describeReactive(e){let t={...e,reactive:!1},r=e.reactiveName??"describe",o=0,s=G(o,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,u=!1,d=()=>{a||u||(a=!0,ut(()=>{a=!1,!u&&(o+=1,s.emit(o))}))},c=i.onEvent(b=>{let v=b.type;v!=="data"&&v!=="error"&&v!=="complete"&&v!=="teardown"||d()}),l=[],f=new WeakSet,p=b=>{if(f.has(b)||u)return;f.add(b);let v=b.topology.subscribe(T=>{for(let w of T){if(w[0]!==x)continue;let _=w[1];if(d(),_.kind==="added"&&_.nodeKind==="mount"){let k=b._mounts.get(_.name);k!=null&&p(k)}}});l.push(v);for(let T of b._mounts.keys()){let w=b._mounts.get(T);w!=null&&p(w)}};p(this);let h,g=e.actor;co(g)&&(h=g.subscribe(b=>{let v=!1,T=!1;for(let w of b){let _=w[0];_===x?v=!0:(_===N||_===S||_===K)&&(T=!0)}v&&d(),T&&(h?.(),h=void 0,d())}));let m;try{m=ye([s],()=>this.describe(t),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(b,v)=>b===v})}catch(b){c(),h?.();for(let v of l)v();throw i.dispose(),b}let y=Ze(m);return{node:m,dispose(){u=!0,c(),h?.();for(let b of l)b();l.length=0,i.dispose(),y()}}}_describeReactiveDiff(e){let t={...e,reactive:!1},r=e.reactiveName??"describe-diff",o={name:this.name,nodes:{},edges:[],subgraphs:[]},s=this.describe(t),i=Dt(o,s),a=G(i,{name:r,meta:{domain:"audit",kind:"describe-diff"},equals:(f,p)=>f===p}),u=this._describeReactive({...e,reactiveName:void 0}),d=!1,c=u.node.subscribe(f=>{if(!d)for(let p of f){if(p[0]!==x)continue;let h=p[1],g=Dt(s,h);s=h,g.events.length!==0&&a.emit(g)}}),l=Ze(a);return{node:a,dispose(){d=!0,c(),u.dispose(),a.down([[K,"describe-diff disposed"]]),l()}}}_explainReactive(e,t,r){let o=0,s=G(o,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,u=!1,d=()=>{a||u||(a=!0,ut(()=>{a=!1,!u&&(o+=1,s.emit(o))}))},c=i.onEvent(b=>{let v=b.type;v!=="data"&&v!=="error"&&v!=="complete"&&v!=="teardown"||d()}),l=[];e!=null&&Xe(e)&&l.push(e),t!=null&&Xe(t)&&l.push(t),r?.maxDepth!=null&&Xe(r.maxDepth)&&l.push(r.maxDepth),r?.findCycle!=null&&Xe(r.findCycle)&&l.push(r.findCycle);let f=()=>{for(let b of l)if(b.cache===void 0)return!1;return!0},p=()=>{let b=$e(e),v=$e(t);return{from:b,to:v,found:!1,reason:"pending",steps:[],text:"(awaiting reactive args)",toJSON:()=>({from:b,to:v,found:!1,reason:"pending",steps:[]})}},h;try{h=ye([s],()=>{if(!f())return p();let b=$e(e),v=$e(t),T={...r?.maxDepth!==void 0?{maxDepth:so(r.maxDepth)}:{},...r?.findCycle!==void 0?{findCycle:io(r.findCycle)}:{}};return this._explainStatic(b,v,T)},{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:$e(e),to:$e(t)},equals:(b,v)=>b.found===v.found&&b.reason===v.reason&&b.steps.length===v.steps.length&&Ks(b.steps,v.steps)})}catch(b){throw c(),i.dispose(),b}let g=Ze(h),m=[],y=b=>{let v;return v=b.subscribe(T=>{let w=!1,_=!1;for(let k of T){let O=k[0];O===x?w=!0:(O===N||O===S||O===K)&&(_=!0)}(w||_)&&d(),_&&v&&(v(),v=void 0)}),()=>{v&&(v(),v=void 0)}};for(let b of l)m.push(y(b));return{node:h,dispose(){u=!0,c();for(let b of m)b?.();m.length=0,i.dispose(),g()}}}_pathsMatching(e){let t=rn(e),r=[];return this._collectObserveTargets("",r),r.map(([o])=>o).filter(o=>t.test(o))}_collectObserveTargets(e,t){for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${te}${r}`;this._mounts.get(r)._collectObserveTargets(o,t)}for(let r of[...this._nodes.keys()].sort()){let o=this._nodes.get(r),s=e===""?r:`${e}${te}${r}`;t.push([s,o]),this._appendMetaObserveTargets(s,o,t)}}_appendMetaObserveTargets(e,t,r){for(let o of Object.keys(t.meta).sort()){let s=t.meta[o],i=`${e}${te}${Me}${te}${o}`;r.push([i,s]),this._appendMetaObserveTargets(i,s,r)}}observe(e,t){let r=typeof e=="string",s=uo(r?t:e);if(s.reactive===!0)return this._observeReactive(r?e:void 0,s);let i=s.structured===!0||s.timeline===!0||s.causal===!0||s.derived===!0||s.detail==="minimal"||s.detail==="full"||s.format!=null,a=s.actor;if(r){let c=e,l=this.resolve(c);if(a!=null&&!l.allowsObserve(a))throw new Re({actor:a,action:"observe",nodeName:c});return i?this._buildStructuredObserver([[c,l]],s,"one"):{subscribe(f){return l.subscribe(f)},up(f){try{l.up?.(f)}catch(p){if(p instanceof Re)return;throw p}}}}let u=[];this._collectObserveTargets("",u),u.sort((c,l)=>c[0]<l[0]?-1:c[0]>l[0]?1:0);let d=a==null?u:u.filter(([,c])=>c.allowsObserve(a));return i?this._buildStructuredObserver(d,s,"all"):{subscribe:c=>{let l=d.map(([f,p])=>p.subscribe(h=>{c(f,h)}));return()=>{for(let f of l)f()}},up:(c,l)=>{try{this.resolve(c).up?.(l)}catch(f){if(f instanceof Re)return;throw f}}}}_observeReactive(e,t){let r=t.tiers,o=r!=null?new Set(r):null,s=t.reactiveName??"observe";return A(i=>{let a=[],u=!1,d=!1,c=()=>{if(a.length===0||d)return;let g={events:a.slice(),flushedAt_ns:re()};a.length=0,i.emit(g)},l={...t,reactive:!1,structured:!0,timeline:!0},f=e!=null?this.observe(e,l):this.observe(l),p=g=>{d||(a.push(g),!u&&(u=!0,ut(()=>{u=!1,c()})))};for(let g of f.events)p(g);let h=f.onEvent(p);return()=>{d=!0,h(),f.dispose()}},{name:s,meta:{domain:"audit",kind:"observe-reactive"}})}_buildStructuredObserver(e,t,r){let o=r==="one"?e[0]?.[0]:void 0,s=i=>{if(r==="one"&&o!=null){let c=this.resolve(o);return this._buildStructuredObserver([[o,c]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((c,l)=>c[0]<l[0]?-1:c[0]>l[0]?1:0);let u=i.actor,d=u==null?a:a.filter(([,c])=>c.allowsObserve(u));return this._buildStructuredObserver(d,i,"all")};return this._createObserveResult(e,t,s)}_createObserveResult(e,t,r){let o=t.timeline===!0,s=t.causal===!0,i=t.derived===!0,a=t.detail==="minimal",u=this.config.inspectorEnabled,d=(s||i)&&u,c=t.maxEvents,l=c!=null&&c>0?new Ge(c):null,f=[],p=new Set,h=t.tiers!=null?new Set(t.tiers):null,g={},m=new Set,y=0,b=0,v=0,T=0,w=0,_=0,k=!1,O=!1,E=0,R=new Map,M=new Map,F=new Map,P=L=>{if(!(h!=null&&!h.has(L.type))){l?l.push(L):f.push(L);for(let X of p)X(L)}},I=L=>h==null||h.has(L),ue=()=>o?{timestamp_ns:re(),in_batch:Wt(),batch_id:E}:{},W=(L,X)=>{if(!(!d||!(L instanceof oe)))return L._setInspectorHook(ke=>{if(ke.kind==="dep_message")R.set(L,ke.depIndex);else if(ke.kind==="run"){let Ue=ke.batchData.map((j,me)=>j!=null&&j.length>0?j.at(-1):ke.prevData[me]);M.set(L,Ue);let xe=ke.batchData.map(j=>j!=null?[...j]:void 0);F.set(L,xe),i&&P({type:"derived",path:X,dep_values:Ue,dep_batches:xe,...ue()})}})},de=L=>{let X=R.get(L),ke=M.get(L);if(!s||ke==null)return{};let xe=(X!=null&&X>=0&&L instanceof oe?L._deps[X]:void 0)?.node,j=xe?.v,me=F.get(L);return{trigger_dep_index:X,trigger_dep_name:xe?.name,...j!=null?{trigger_version:{id:j.id,version:j.version}}:{},dep_values:[...ke],...me!=null?{dep_batches:me}:{}}},Oe=[],Fe=[];for(let[L,X]of e){let ke=W(X,L);ke&&Oe.push(ke),Fe.push(X.subscribe(Ue=>{E++;for(let xe of Ue){let j=xe[0],me=ue();if(j===x){g[L]=xe[1];let Et=X instanceof oe?X.lastMutation?.actor??ct:ct;P({type:"data",path:L,data:xe[1],actor:Et,...me,...de(X)})}else if(a)j===V?I("dirty")&&y++:j===C?I("resolved")&&b++:j===Ne?I("invalidate")&&v++:j===le?I("pause")&&T++:j===pe?I("resume")&&w++:j===K?I("teardown")&&_++:j===N&&!m.has(L)?I("complete")&&(k=!0):j===S&&I("error")&&(O=!0,m.add(L));else if(j===V)I("dirty")&&y++,P({type:"dirty",path:L,...me});else if(j===C)I("resolved")&&b++,P({type:"resolved",path:L,...me,...de(X)});else if(j===Ne)I("invalidate")&&v++,P({type:"invalidate",path:L,...me});else if(j===le)I("pause")&&T++,P({type:"pause",path:L,lockId:xe[1],...me});else if(j===pe)I("resume")&&w++,P({type:"resume",path:L,lockId:xe[1],...me});else if(j===N)I("complete")&&!m.has(L)&&(k=!0),P({type:"complete",path:L,...me});else if(j===S){I("error")&&(O=!0,m.add(L));let Et=X instanceof oe?X.lastMutation?.actor??ct:ct;P({type:"error",path:L,data:xe[1],actor:Et,...me})}else j===K&&(I("teardown")&&_++,P({type:"teardown",path:L,...me}))}}))}let Ee=!1,_e=()=>{if(!Ee){Ee=!0;for(let L of Fe)L();for(let L of Oe)L();for(let L of Ke)L({value:void 0,done:!0});Ke.length=0}},ze=[],Ke=[];p.add(L=>{let X=Ke.shift();X?X({value:L,done:!1}):ze.push(L)});let We={get values(){return g},get dirtyCount(){return y},get resolvedCount(){return b},get invalidateCount(){return v},get pauseCount(){return T},get resumeCount(){return w},get teardownCount(){return _},get events(){return l?l.toArray():[...f]},get anyCompletedCleanly(){return k},get anyErrored(){return O},get completedWithoutErrors(){return k&&!O},onEvent(L){return p.add(L),()=>p.delete(L)},dispose:_e,expand(L){_e();let X={...t};return typeof L=="string"?X.detail=L:Object.assign(X,L),r(uo(X))},[Symbol.asyncIterator](){return{next(){return ze.length>0?Promise.resolve({value:ze.shift(),done:!1}):Ee?Promise.resolve({value:void 0,done:!0}):new Promise(L=>Ke.push(L))},return(){return _e(),Promise.resolve({value:void 0,done:!0})}}}};return t.format!=null&&this._attachFormatLogger(We,t),We}_attachFormatLogger(e,t){let r=t.format;if(r==null)return;let o=t.logger??(h=>console.log(h)),s=t.includeTypes?new Set(t.includeTypes):null,i=t.excludeTypes?new Set(t.excludeTypes):null,a=s==null&&i==null?()=>!0:h=>(s==null||s.has(h))&&(i==null||!i.has(h)),u=Vs(t.theme),d=r==="stage-log"?re():0,c=h=>h==null?"":t.stageLabels?.[h]??h,l=(h,g)=>h.length>g?`${h.slice(0,g-1)}\u2026`:h,f=h=>h.type==="data"||h.type==="error"?l(Zn(h.data),120):"",p=h=>{if(r==="stage-log"){let k=(re()-d)/1e9,O=c(h.path).padEnd(9);if(h.type==="data"){let E=f(h);return`[${k.toFixed(3)}s] ${O} \u2190${E?` ${E}`:""}`}if(h.type==="error"){let E=f(h);return`[${k.toFixed(3)}s] ${O} \u2717${E?` ${E}`:""}`}return h.type==="complete"?`[${k.toFixed(3)}s] ${O} \u25A0 complete`:`[${k.toFixed(3)}s] ${O} ${h.type}`}if(r==="json")try{return JSON.stringify(h)}catch{return JSON.stringify({type:h.type,path:h.path,data:"[unserializable]"})}let g=u[h.type]??"",m=h.path?`${u.path}${h.path}${u.reset} `:"",y=h.type==="data"||h.type==="error",b=h.type==="pause"||h.type==="resume",v=y?` ${Zn(h.data)}`:b?` ${Zn(h.lockId)}`:"",T=h.type==="data"||h.type==="resolved"||h.type==="derived"?h:void 0,w=T?.trigger_dep_name!=null?` <- ${T.trigger_dep_name}`:T?.trigger_dep_index!=null?` <- #${T.trigger_dep_index}`:"",_=h.in_batch?" [batch]":"";return`${m}${g}${h.type.toUpperCase()}${u.reset}${v}${w}${_}`};e.onEvent(h=>{a(h.type)&&o(p(h),h)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){oo(this._disposers,this.name),this.signal([[K]],{internal:!0}),oo(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}get destroyed(){return this._destroyed}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}snapshot(e){let{expand:t,...r}=this.describe({detail:"full"}),o={};for(let a of Object.keys(r.nodes).sort()){let{lastMutation:u,guard:d,...c}=r.nodes[a];o[a]=c}let s=[...r.subgraphs].sort(),i={...r,version:1,nodes:o,subgraphs:s};if(e?.format==null)return i;if(e.format==="json-string")return JSON.stringify(i);if(e.format==="bytes"){if(e.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let a=this.config.lookupCodec(e.codec);if(a==null)throw new Error(`snapshot: codec "${e.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return Rr(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,t){let r=t?.config??ge,{codec:o,codecVersion:s,payload:i}=Mr(e,r);return o.decode(i,s)}restore(e,t){if(ao(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let r=t?.only==null?null:(Array.isArray(t.only)?t.only:[t.only]).map(s=>rn(s)),o=t?.includeProducers===!0;for(let s of Object.keys(e.nodes).sort()){if(r!==null&&!r.some(a=>a.test(s)))continue;let i=e.nodes[s];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&t?.onError?.(s,new Error(`restore: slice.value is undefined for "${s}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!o)){if(i.v!=null){let u=this.tryResolve(s)?.v;if(u!=null&&u.id===i.v.id&&u.version===i.v.version)continue}try{this.set(s,i.value)}catch(a){t?.onError?.(s,a)}}}}}static fromSnapshot(e,t){ao(e);let r=typeof t=="function"?t:t?.build,o=typeof t=="function"?void 0:t?.factories,s=new n(e.name);if(r)return r(s),s.restore(e),s;for(let p of[...e.subgraphs].sort((h,g)=>{let m=h.split(te).length,y=g.split(te).length;return m!==y?m-y:h<g?-1:h>g?1:0})){let h=p.split(te),g=s;for(let m of h)g._mounts.has(m)||g.mount(m,new n(m)),g=g._mounts.get(m)}let i=o?Object.entries(o).map(([p,h])=>({re:rn(p),factory:h})):[],a=p=>{for(let h of i)if(h.re.test(p))return h.factory},u=p=>{let h=p.split(te),g=h.pop();if(g==null||g.length===0)throw new Error(`invalid snapshot path "${p}"`);let m=s;for(let y of h){let b=m._mounts.get(y);if(!b)throw new Error(`unknown mount "${y}" in path "${p}"`);m=b}return[m,g]},d=Object.entries(e.nodes).filter(([p])=>!p.includes(`${te}${Me}${te}`)).sort((p,h)=>p[0]<h[0]?-1:p[0]>h[0]?1:0),c=new Map(d),l=new Map,f=!0;for(;c.size>0&&f;){f=!1;for(let[p,h]of[...c.entries()]){let g=h?.deps??[];if(!g.every(w=>l.has(w)))continue;let[m,y]=u(p),b={...h?.meta??{}},v=a(p),T;if(h?.type==="state")T=G(h.value,{meta:b});else{if(v==null)continue;T=v(y,{path:p,type:h.type,value:h.value,meta:b,deps:g,resolvedDeps:g.map(w=>l.get(w))})}m.add(T,{name:y}),l.set(p,T),c.delete(p),f=!0}}if(c.size>0){let p=[...c.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${p}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return s.restore(e),s}toJSON(){return this.snapshot()}attachSnapshotStorage(e,t={}){let r=e.map(d=>({tier:d,debounceMs:Math.max(0,d.debounceMs??0),compactEvery:Math.max(1,d.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));t.autoRestore===!0&&this._cascadeRestore(e,t.onError);let o=(d,c)=>{if(d.disposed)return;let l=Ps(c.nodes);if(d.lastSnapshot!=null&&l!==""&&l===d.lastFingerprint)return;let f=d.seq+1,p=ne(),m=d.lastSnapshot==null||f%d.compactEvery===0?{name:this.name,mode:"full",snapshot:c,seq:f,timestamp_ns:p,format_version:Qe}:{name:this.name,mode:"diff",diff:fo(d.lastSnapshot,c),seq:f,timestamp_ns:p,format_version:Qe};if(d.tier.filter&&!d.tier.filter(m))return;let y;try{y=d.tier.save(m)}catch(b){t.onError?.(b,d.tier);return}if(y&&typeof y.then=="function"){let T=(d.savePending??Promise.resolve()).then(()=>y,()=>y).then(()=>{d.disposed||(d.seq=f,d.lastSnapshot=c,d.lastFingerprint=l)},w=>{t.onError?.(w,d.tier)});d.savePending=T.finally(()=>{d.savePending===T&&(d.savePending=void 0)})}else d.seq=f,d.lastSnapshot=c,d.lastFingerprint=l},s=(d,c)=>{try{o(d,c)}catch(l){t.onError?.(l,d.tier)}},i=(d,c)=>{if(!c.some(h=>{let g=this.config.messageTier(h[0]);return g>=3&&g<5}))return;if(t.filter){let h=this.tryResolve(d);if(h==null)return;let g=Un(h,Wn("standard"));if(!t.filter(d,g))return}let f,p=()=>(f==null&&(f=this.snapshot()),f);for(let h of r)h.disposed||(h.debounceMs===0?s(h,p()):(h.timer==null&&(h.timer=new Le),h.timer.start(h.debounceMs,()=>{h.disposed||s(h,this.snapshot())})))},a;if(t.paths!=null){let c=(typeof t.paths=="string"?this._pathsMatching(t.paths):t.paths).map(l=>{let f=this.tryResolve(l);return f==null?()=>{}:f.subscribe(p=>i(l,p))});a=()=>{for(let l of c)l()}}else a=this.observe().subscribe((d,c)=>i(d,c));let u=()=>{a();for(let d of r)d.disposed=!0,d.timer?.cancel();this._storageDisposers.delete(u)};return this._storageDisposers.add(u),{dispose:u}}async _cascadeRestore(e,t){for(let r of e){let o;try{o=await r.load?.()}catch(i){t?.(i,r);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let s=o;try{if(s.mode==="full"&&s.snapshot!=null)return this.restore(s.snapshot),!0;if(s.version===Qe&&s.nodes!=null)return this.restore(s),!0}catch(i){t?.(i,r)}}return!1}static async fromStorage(e,t,r){for(let o of t){let s;try{s=await o.load?.()}catch(u){r?.onError?.(u,o);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let i=s,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===Qe&&i.nodes!=null?i:void 0;if(a!=null)try{return n.fromSnapshot(a,r)}catch(u){r?.onError?.(u,o)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${e}" across ${t.length} tier(s)`)}_annotations=new Map;_traceRing;trace(e,t,r){if(e!=null&&t!=null){if(this.tryResolve(e)==null)return;if(this._annotations.set(e,t),this.config.inspectorEnabled){let o={path:e,annotation:t,timestamp_ns:re(),...r?.actor!=null?{actor:r.actor}:{}};this._traceRing.push(o)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let t=this._traceRing.toArray().filter(o=>!e(o)),r=this._traceRing.size-t.length;this._traceRing.clear();for(let o of t)this._traceRing.push(o);return r}static diff(e,t){let r=new Set(Object.keys(e.nodes)),o=new Set(Object.keys(t.nodes)),s=[...o].filter(b=>!r.has(b)).sort(),i=[...r].filter(b=>!o.has(b)).sort(),a=[],u=[];for(let b of r){if(!o.has(b))continue;let v=e.nodes[b],T=t.nodes[b],w=v.v,_=T.v;w!=null&&_!=null&&w.id===_.id&&w.version!==_.version&&u.push({path:b,id:w.id,from:w.version,to:_.version});let k=w!=null&&_!=null&&w.id===_.id&&w.version===_.version;for(let O of["type","status","sentinel"]){let E=v[O],R=T[O];E!==R&&a.push({path:b,field:O,from:E,to:R})}if(!k)for(let O of["value","meta"]){let E=v[O],R=T[O];Ds(E,R)||a.push({path:b,field:O,from:E,to:R})}}let d=b=>`${b.from} ${b.to}`,c=new Set(e.edges.map(d)),l=new Set(t.edges.map(d)),f=t.edges.filter(b=>!c.has(d(b))),p=e.edges.filter(b=>!l.has(d(b))),h=new Set(e.subgraphs),g=new Set(t.subgraphs),m=[...g].filter(b=>!h.has(b)).sort(),y=[...h].filter(b=>!g.has(b)).sort();return{nodesAdded:s,nodesRemoved:i,nodesChanged:a,versionChanges:u,edgesAdded:f,edgesRemoved:p,subgraphsAdded:m,subgraphsRemoved:y}}}});var po=q(()=>{"use strict";on()});function Lt(n){return typeof n=="object"&&n!==null&&"subscribe"in n&&"down"in n}function ho(n){if(n<=0)throw new RangeError("timeoutMs must be > 0");if(n>9e6)throw new RangeError("timeoutMs must be <= 9_000_000 (\u22482.5h) to stay within safe ns arithmetic")}function mo(n,e={}){let t=new It(n,e);return t.tagFactory("resilientPipeline",Wr(e)),t}var It,go=q(()=>{"use strict";pt();po();Qt();yt();nr();It=class extends Ie{output;status;lastError;breakerState;droppedCount;rateLimitState;constructor(e,t={}){super(t.name??"resilient_pipeline",t.graph);let r=e,o,s,i;if(t.rateLimit!=null)if(Lt(t.rateLimit)){let u=r,d=t.rateLimit;r=we(d,c=>{let l={...c,maxBuffer:c.maxBuffer??1/0,meta:ve("resilient","rate-limit")};return gt(u,l).node}),this.add(r,{name:"rateLimited"})}else{let u={...t.rateLimit,maxBuffer:t.rateLimit.maxBuffer??1/0,meta:ve("resilient","rate-limit")},d=gt(r,u);r=d.node,o=d.droppedCount,s=d.rateLimitState,this.add(r,{name:"rateLimited"}),this.add(o,{name:"droppedCount"}),this.add(s,{name:"rateLimitState"})}if(t.budget!=null)if(Lt(t.budget)){let u=r,d=t.budget;r=we(d,c=>c.length>0?Ye(u,c,{meta:ve("resilient","budget")}):u),this.add(r,{name:"budgetGated"})}else t.budget.length>0&&(r=Ye(r,t.budget,{meta:ve("resilient","budget")}),this.add(r,{name:"budgetGated"}));if(t.breaker!=null)if(Lt(t.breaker)){let u=r,d=t.breaker,c=t.breakerOnOpen??"skip";r=we(d,l=>{let f=ht(l);return mt(f,{onOpen:c,meta:ve("resilient","breaker")})(u).node}),this.add(r,{name:"breakerWrapped"})}else{let u=ht(t.breaker),d=t.breakerOnOpen??"skip",c=mt(u,{onOpen:d,meta:ve("resilient","breaker")})(r);r=c.node,i=c.breakerState,this.add(r,{name:"breakerWrapped"}),this.add(i,{name:"breakerState"})}if(t.timeoutMs!=null)if(Lt(t.timeoutMs)){let u=r,d=t.timeoutMs;r=we(d,c=>(ho(c),bt(u,c*1e6,{meta:ve("resilient","timeout")}))),this.add(r,{name:"timeoutWrapped"})}else ho(t.timeoutMs),r=bt(r,t.timeoutMs*1e6,{meta:ve("resilient","timeout")}),this.add(r,{name:"timeoutWrapped"});if(t.retry!=null)if(Lt(t.retry)){let u=r,d=t.retry;r=we(d,c=>je(u,{...c,meta:ve("resilient","retry")})),this.add(r,{name:"retryWrapped"})}else r=je(r,{...t.retry,meta:ve("resilient","retry")}),this.add(r,{name:"retryWrapped"});t.fallback!==void 0&&(r=Bt(r,t.fallback,{meta:ve("resilient","fallback")}),this.add(r,{name:"fallbackWrapped"}));let a=et(r,{initialStatus:t.initialStatus??"pending",meta:ve("resilient","status")});this.output=a.node,this.status=a.status,this.lastError=a.error,this.breakerState=i,this.droppedCount=o,this.rateLimitState=s,this.add(this.output,{name:"output"}),this.add(this.status,{name:"status"}),this.add(this.lastError,{name:"lastError"})}}});function tt(n){return{describeKind:"derived",...n}}function $s(n){return n<0?0:n}function rr(n){return n[1]}function js(n){if(typeof n!="number"||!Number.isFinite(n))throw new TypeError("backoff strategy must return a finite number");return n<0?0:n}function bo(n){let e=n?.count,t=n?.backoff;if(t!==void 0&&e===void 0)throw new RangeError("retry({ backoff }) requires explicit count to prevent unbounded retries; pass { count: <n>, backoff: ... }");let r=e!==void 0?e:0;if(r<0)throw new RangeError("retry count must be >= 0");let o=t===void 0?null:typeof t=="string"?lt(t):t;return{maxRetries:r,strategy:o}}function yo(n){let e={};return n?.count!==void 0&&(e.count=n.count),typeof n?.backoff=="string"&&(e.backoff=n.backoff),Object.keys(e).length>0?e:void 0}function vo(n,e,t){let r=0,o=!1,s=null,i,a=new Le;function u(){i?.(),i=void 0}function d(l){if(o)return;if(r>=n.maxRetries){u(),t.down([[S,l]]);return}let f=n.strategy===null?0:n.strategy(r,l,s);if(f==null){u(),t.down([[S,l]]);return}let p;try{p=js(f)}catch{u(),t.down([[S,l]]);return}s=p,r+=1,u();let h=p>0?p/1e6:1;a.start(h,()=>{o||c()})}function c(){a.cancel(),u();let l;try{l=e()}catch(f){d(f);return}i=l.subscribe(f=>{if(!o)for(let p of f){let h=p[0];if(h===V)t.down([[V]]);else if(h===x)r=0,s=null,t.emit(p[1]);else if(h===C)t.down([[C]]);else if(h===N)u(),t.down([[N]]);else if(h===S){d(rr(p));return}else t.down([p])}})}return c(),()=>{o=!0,a.cancel(),u()}}function je(n,e){return typeof n=="function"?Us(n,e):Ws(n,e)}function Ws(n,e){let t=bo(e);return A(r=>vo(t,()=>n,r),{...tt(),initial:n.cache,meta:{...e?.meta??{},...J("retry",yo(e))}})}function Us(n,e){let t=bo(e);return A(r=>vo(t,n,r),{...tt(),initial:e?.initial,meta:{...e?.meta??{},...J("retry",yo(e))}})}function ht(n){let e=Math.max(1,n?.failureThreshold??5),t=$s(n?.cooldownNs??30*1e9),r=n?.cooldown??null,o=Math.max(1,n?.halfOpenMax??1),s=n?.now??re,i="closed",a=0,u=0,d=0,c=t,l=0;function f(){if(!r)return t;let g=r(u);return g!==null?g:t}function p(){i="open",c=f(),d=s(),l=0}return{canExecute(){return i==="closed"?!0:i==="open"?s()-d>=c?(i="half-open",l=1,!0):!1:l<o?(l++,!0):!1},recordSuccess(){i==="half-open"?(i="closed",a=0,u=0):i==="closed"&&(a=0)},recordFailure(g){if(i==="half-open"){u++,p();return}i==="closed"&&(a++,a>=e&&p())},get state(){return i},get failureCount(){return a},reset(){i="closed",a=0,u=0,l=0}}}function mt(n,e){let t=e?.onOpen??"skip",r=e?.meta;return o=>{let s=B([],(i,a)=>{function u(){s.meta.breakerState.down([[x,n.state]])}let d=o.subscribe(c=>{for(let l of c){let f=l[0];f===V?a.down([[V]]):f===x?n.canExecute()?(u(),a.emit(l[1])):(u(),t==="error"?a.down([[S,new vt]]):a.down([[C]])):f===C?a.down([[C]]):f===N?(n.recordSuccess(),u(),a.down([[N]])):f===S?(n.recordFailure(rr(l)),u(),a.down([l])):a.down([l])}});return u(),d},{...tt(),meta:{...r??{},breakerState:n.state,...J("withBreaker",{onOpen:t})},completeWhenDepsComplete:!1,initial:o.cache});return{node:s,breakerState:s.meta.breakerState}}}function an(n,e,t){if(n<=0)throw new RangeError("capacity must be > 0");if(e<0)throw new RangeError("refillPerSecond must be >= 0");let r=t?.clock??re,o=n,s=r();function i(a){if(e>0){let u=a-s;o=Math.min(n,o+u/1e9*e)}s=a}return{available(){return i(r()),o},tryConsume(a=1){if(a<=0)return!0;let u=r();return i(u),o>=a?(o-=a,!0):!1},putBack(a=1){a<=0||(i(r()),o=Math.min(n,o+a))}}}function Hs(n,e){return n.droppedCount===e.droppedCount&&n.pendingCount===e.pendingCount&&n.paused===e.paused}function gt(n,e){let{maxEvents:t,windowNs:r}=e;if(t<=0)throw new RangeError("maxEvents must be > 0");if(r<=0)throw new RangeError("windowNs must be > 0");let o=e.maxBuffer;if(o===void 0)throw new RangeError("rateLimiter requires explicit maxBuffer (use Infinity to opt in to unbounded)");let s=o===1/0;if(!s&&(!Number.isInteger(o)||o<1))throw new RangeError("maxBuffer must be a positive integer (or Infinity for unbounded)");let i=e.onOverflow??"drop-newest",a=t*1e9/r,u=A(d=>{let c=an(t,a),l=s?Js():qs(o),f=new Le,p=!1,h=0,g=1e9/a,m=u.meta.droppedCount,y=u.meta.rateLimitState,b=sn;function v(){m.emit(h);let O={droppedCount:h,pendingCount:l.size,paused:l.size>0};Hs(b,O)||(b=O,y.emit(O))}b=sn,m.emit(0),y.emit(sn);function T(){for(;l.size>0;)if(c.tryConsume(1))d.emit(l.shift()),v();else{f.start(Math.max(1,g/1e6),T);return}}function w(){h+=1,v()}function _(){for(p=!0,f.cancel();l.size>0;)l.shift();h=0}let k=n.subscribe(O=>{for(let E of O){if(p)return;let R=E[0];if(R===V)d.down([[V]]);else if(R===x){if(!s&&l.size>=o)if(i==="drop-newest")w();else if(i==="drop-oldest")l.shift(),l.push(E[1]),w();else{w(),_(),d.down([[S,new Tt(o)]]);return}else l.push(E[1]),v();T()}else if(R===C)d.down([[C]]);else if(R===N)_(),d.down([[N]]);else if(R===S)_(),d.down([E]);else if(R===K){_(),d.down([E]);return}else d.down([E])}});return()=>{p=!0,f.cancel(),k()}},{...tt(),initial:n.cache,meta:{...e.meta??{},droppedCount:0,rateLimitState:sn,...J("rateLimiter",e)}});return{node:u,droppedCount:u.meta.droppedCount,rateLimitState:u.meta.rateLimitState}}function qs(n){let e=new Ge(n);return{push:t=>e.push(t),shift:()=>e.shift(),get size(){return e.size}}}function Js(){let n=[];return{push:e=>{n.push(e)},shift:()=>n.shift(),get size(){return n.length}}}function et(n,e){let t=e?.initialStatus??"pending",r=e?.meta,o=B([],(s,i)=>{let a=t;return o.meta.status.down([[x,t]]),o.meta.error.down([[x,null]]),n.subscribe(d=>{for(let c of d){let l=c[0];if(l===V)i.down([[V]]);else if(l===x)a==="errored"?$(()=>{o.meta.error.down([[x,null]]),o.meta.status.down([[x,"running"]])}):o.meta.status.down([[x,"running"]]),a="running",i.emit(c[1]);else if(l===C)i.down([[C]]);else if(l===N)o.meta.status.down([[x,"completed"]]),a="completed",i.down([[N]]);else if(l===S){let f=rr(c);$(()=>{o.meta.error.down([[x,f]]),o.meta.status.down([[x,"errored"]])}),a="errored",i.down([c])}else i.down([c])}})},{...tt(),meta:{...r??{},status:t,error:null,...J("withStatus",{initialStatus:t})},completeWhenDepsComplete:!1,resubscribable:!0,initial:n.cache});return{node:o,status:o.meta.status,error:o.meta.error}}function Ys(n){return n!=null&&typeof n=="object"&&"cache"in n&&typeof n.subscribe=="function"}function Qs(n){return n!=null&&typeof n.then=="function"}function Xs(n){return n!=null&&typeof n=="object"&&typeof n[Symbol.asyncIterator]=="function"}function Bt(n,e,t){let r=t?.meta;return A(o=>{let s,i;function a(){i?.(),i=void 0,Ys(e)||Qs(e)||Xs(e)?s=ie(e).subscribe(d=>{o.down(d);for(let c of d){let l=c[0];if(l===N||l===S||l===K){s=void 0;return}}}):(o.emit(e),o.down([[N]]))}return i=n.subscribe(u=>{for(let d of u){let c=d[0];if(c===V)o.down([[V]]);else if(c===x)o.emit(d[1]);else if(c===C)o.down([[C]]);else if(c===N)o.down([[N]]);else if(c===S){a();return}else if(c===K){s?.(),o.down([d]);return}else o.down([d])}}),()=>{i?.(),s?.()}},{...tt(),initial:n.cache,meta:{...r??{},...J("fallback")}})}function bt(n,e,t){if(e<=0)throw new RangeError("timeoutNs must be > 0");let r=t?.meta;return A(o=>{let s=!1,i=new Le;function a(){let d=e/1e6;i.start(d,()=>{s||(s=!0,u(),o.down([[S,new wt(e)]]))})}let u=n.subscribe(d=>{for(let c of d){if(s)return;let l=c[0];if(l===V)o.down([[V]]);else if(l===x)a(),o.emit(c[1]);else if(l===C)o.down([[C]]);else if(l===N){i.cancel(),s=!0,o.down([[N]]);return}else if(l===S){i.cancel(),s=!0,o.down([c]);return}else if(l===K){i.cancel(),s=!0,o.down([c]);return}else o.down([c])}});return a(),()=>{s=!0,i.cancel(),u()}},{...tt(),initial:n.cache,meta:{...r??{},...J("timeout",{timeoutNs:e})}})}var vt,Tt,sn,wt,nr=q(()=>{"use strict";Hr();go();Te();Pe();Z();pt();be();fe();Ct();Be();tn();nn();vt=class extends Error{name="CircuitOpenError";constructor(){super("Circuit breaker is open")}};Tt=class extends Error{name="RateLimiterOverflowError";constructor(e){super(`rateLimiter buffer overflow (maxBuffer=${e})`)}};sn=Object.freeze({droppedCount:0,pendingCount:0,paused:!1});wt=class extends Error{name="TimeoutError";constructor(e){super(`Timed out after ${e/1e6}ms`)}}});var To={};Nn(To,{CircuitOpenError:()=>vt,RateLimiterOverflowError:()=>Tt,ResilientPipelineGraph:()=>It,TimeoutError:()=>wt,budgetGate:()=>Ye,circuitBreaker:()=>ht,fallback:()=>Bt,rateLimiter:()=>gt,resilientPipeline:()=>mo,retry:()=>je,timeout:()=>bt,tokenBucket:()=>an,withBreaker:()=>mt,withStatus:()=>et});var un=q(()=>{"use strict";nr()});function Se(n){return{describeKind:"producer",...n}}function ko(n){return/[\\^$+?.()|[\]{}]/.test(n)?`\\${n}`:n}function Zs(n){let e="^";for(let t=0;t<n.length;t+=1){let r=n[t];if(r==="*"){n[t+1]==="*"?(e+=".*",t+=1):e+="[^/]*";continue}e+=ko(r)}return e+="$",new RegExp(e)}function ei(n,e){for(let t of e)if(t.test(n))return!0;return!1}function ti(n,e){let t=B([n],(o,s)=>{let i=o[0];if(i==null||i.length===0){s.down([[C]]);return}for(let a of i)s.emit(a)},{describeKind:"derived",initial:n.cache}),r=t.subscribe.bind(t);return t.subscribe=(o,s)=>(e(o),r(o,s)),t}function nt(n,e){let{signal:t,period:r,...o}=e??{};return A(s=>{let i=!1,a=0,u,d,c=()=>{i=!0,u!==void 0&&clearTimeout(u),d!==void 0&&clearInterval(d),t?.removeEventListener("abort",f)},l=()=>{i||(r!=null?(s.emit(a++),d=setInterval(()=>{i||s.emit(a++)},r)):(i=!0,t?.removeEventListener("abort",f),s.emit(a++),s.down([[N]])))},f=()=>{i||(c(),s.down([[S,t.reason]]))};if(t?.aborted){f();return}return u=setTimeout(l,n),t?.addEventListener("abort",f,{once:!0}),c},Se(o))}function ni(n){let{signal:e,...t}=n??{};return A(r=>{let o=!1,s,i,a=!1,u=!1,d=typeof requestAnimationFrame=="function"?requestAnimationFrame:void 0,c=typeof cancelAnimationFrame=="function"?cancelAnimationFrame:void 0,l=typeof document<"u"?document:void 0,f=()=>{s!==void 0&&c&&c(s),i!==void 0&&clearTimeout(i),s=void 0,i=void 0},p=()=>{o=!0,f(),a&&(e?.removeEventListener("abort",h),a=!1),u&&l&&(l.removeEventListener("visibilitychange",y),u=!1)},h=()=>{o||(p(),r.down([[S,e.reason]]))},g=b=>{o||(r.emit(b),m())},m=()=>{o||(d&&(!l||l.visibilityState!=="hidden")?s=d(g):i=setTimeout(()=>g(performance.now()),16))},y=()=>{o||(f(),m())};return e?.aborted?(h(),p):(e?.addEventListener("abort",h,{once:!0}),a=e!==void 0,l&&d&&(l.addEventListener("visibilitychange",y),u=!0),m(),p)},Se(t))}function ri(n,e){let t=Hn(n),{tickMs:r,output:o,...s}=e??{},i=r??6e4,a=o==="date";return A(u=>{let d=-1,c=()=>{let f=new Date,p=f.getFullYear()*1e8+(f.getMonth()+1)*1e6+f.getDate()*1e4+f.getHours()*100+f.getMinutes();p!==d&&qn(t,f)&&(d=p,u.emit(a?f:ne()))};c();let l=setInterval(c,i);return()=>clearInterval(l)},{...Se(s),name:s.name??`cron:${n}`})}function oi(n,e,t){let{capture:r,passive:o,once:s,...i}=t??{};return A(a=>{let u=c=>{a.emit(c)},d={capture:r,passive:o,once:s};return n.addEventListener(e,u,d),()=>n.removeEventListener(e,u,d)},Se(i))}function ir(n,e){return A(t=>{let r=!1;try{for(let o of n){if(r)return;t.emit(o)}r||t.down([[N]])}catch(o){r||t.down([[S,o]])}return()=>{r=!0}},Se(e))}function si(n){return n!=null&&typeof n.then=="function"}function xo(n,e){let{signal:t,...r}=e??{};return A(o=>{let s=!1,i=()=>{s||(s=!0,o.down([[S,t.reason]]))};if(t?.aborted){i();return}return t?.addEventListener("abort",i,{once:!0}),Promise.resolve(n).then(a=>{s||(s=!0,t?.removeEventListener("abort",i),o.emit(a),o.down([[N]]))},a=>{s||(s=!0,t?.removeEventListener("abort",i),o.down([[S,a]]))}),()=>{s=!0,t?.removeEventListener("abort",i)}},Se(r))}function No(n,e){let{signal:t,...r}=e??{};return A(o=>{let s=new AbortController,i=()=>s.abort(t?.reason);t?.aborted?s.abort(t.reason):t?.addEventListener("abort",i,{once:!0});let a=t??s.signal,u=!1,d=n[Symbol.asyncIterator](),c=()=>{u||a.aborted||Promise.resolve(d.next()).then(l=>{if(!(u||a.aborted)){if(l.done){o.down([[N]]);return}o.emit(l.value),c()}},l=>{!u&&!a.aborted&&o.down([[S,l]])})};return c(),()=>{u=!0,t?.removeEventListener("abort",i),s.abort(),Promise.resolve(d.return?.()).catch(()=>{})}},Se(r))}function ii(n){return n!=null&&typeof n=="object"&&"cache"in n&&typeof n.subscribe=="function"}function ie(n,e){if(ii(n))return n;if(si(n))return xo(n,e);if(n!=null){let t=n;if(typeof t[Symbol.asyncIterator]=="function")return No(n,e);if(typeof t[Symbol.iterator]=="function")return ir(n,e)}return _o(n)}function _o(...n){return ir(n,void 0)}function ai(n){return A(e=>{e.down([[N]])},Se(n))}function ui(n){return A(()=>{},Se(n))}function di(n,e){return A(t=>{t.down([[S,n]])},Se(e))}function ci(n,e){let{signal:t,...r}=e??{},o=Se(r),s=o.resubscribable===void 0?{...o,resubscribable:!0}:o;return A(i=>{let a,u=!1;try{let d=n();a=ie(d,e).subscribe(l=>{if(!u)for(let f of l){let p=f[0];if(p!==Ve)if(p===x)i.emit(f[1]);else if(p===N){u=!0,i.down([[N]]);break}else if(p===S){u=!0,i.down([[S,f[1]]]);break}else i.down([f])}})}catch(d){let c=d===void 0?new Error("defer: thunk threw undefined"):d;i.down([[S,c]])}return()=>{u=!0,a?.()}},s)}function rt(n,e,t){return B([n],(o,s)=>{let i=o[0];if(i!=null&&i.length>0)for(let a of i)e(a)},{describeKind:"effect",...t}).subscribe(()=>{})}function li(n,e){return B([n],(t,r,o)=>{o.store.buf||(o.store.buf=[]);let s=o.store.buf,i=t[0];if(i!=null&&i.length>0)for(let a of i)s.push(a);if(o.terminalDeps[0]===!0){r.emit([...s]),r.down([[N]]);return}(i==null||i.length===0)&&r.down([[C]])},{describeKind:"derived",completeWhenDepsComplete:!1,...e})}function fi(n,e){return A(t=>n.subscribe(r=>{t.down(r)}),{...Se(e),initial:n.cache})}function ar(n,e,t){if(e<1)throw new RangeError("replay expects bufferSize >= 1");let r=[],o=A(s=>n.subscribe(i=>{for(let a of i)a[0]===x&&(r.push(a[1]),r.length>e&&r.shift());s.down(i)}),{...Se(t),initial:n.cache});return ti(o,s=>{for(let i of r)s([[x,i]])})}function pi(n,e){return ar(n,1,e)}function ur(n){return new Promise((e,t)=>{let r=!1,o=!1,s;s=n.subscribe(i=>{for(let a of i){if(r)return;if(a[0]===x){r=!0,e(a[1]),s?(s(),s=void 0):o=!0;return}if(a[0]===S){r=!0,t(a[1]),s?(s(),s=void 0):o=!0;return}if(a[0]===N){r=!0,t(new Error("completed without DATA")),s?(s(),s=void 0):o=!0;return}}}),o&&(s?.(),s=void 0)})}function sr(n,e,t){return new Promise((r,o)=>{let s=!1,i=!1,a,u=t?.skipCurrent===!0;a=n.subscribe(d=>{for(let c of d){if(s)return;if(!(u&&c[0]===x)){if(c[0]===x){let l=c[1];if(e(l)){s=!0,r(l),a?(a(),a=void 0):i=!0;return}}if(c[0]===S){s=!0,o(c[1]),a?(a(),a=void 0):i=!0;return}if(c[0]===N){s=!0,o(new Error("completed without matching value")),a?(a(),a=void 0):i=!0;return}}}}),u=!1,i&&(a?.(),a=void 0)})}async function hi(n,e){let t=e?.predicate??(s=>s!=null),r=e?.skipCurrent;if(e?.timeoutMs==null||e.timeoutMs<=0)return await sr(n,t,{skipCurrent:r});if(or===void 0){let[s,i]=await Promise.all([Promise.resolve().then(()=>(un(),To)),Promise.resolve().then(()=>(Ct(),$r))]);or=s.timeout,wo=i.NS_PER_MS}let o=or(n,e.timeoutMs*wo);return await sr(o,t,{skipCurrent:r})}function mi(n,e){let t=new AbortController,r=e?.reason??new Error("cancelled via nodeSignal"),o,s=!1,i=()=>{o?(o(),o=void 0):s=!0};return o=n.subscribe(a=>{if(!t.signal.aborted)for(let u of a){if(u[0]===x&&u[1]===!0){t.abort(r),i();return}if(u[0]===S){t.abort(u[1]),i();return}if(u[0]===N){i();return}}}),s&&(o?.(),o=void 0),{signal:t.signal,dispose:()=>{o&&(o(),o=void 0)}}}function Ze(n){return n.subscribe(()=>{})}function bi(n){let e=G(0);return{node:e,increment(){let t=e.cache??0;return t>=n?!1:(e.down([[V],[x,t+1]]),!0)},get(){return e.cache??0},atCap(){return(e.cache??0)>=n}}}var or,wo,gi,So=q(()=>{"use strict";Pe();Z();be();fe();Jn();gi=ar});var Be=q(()=>{"use strict";So()});function z(n){return{describeKind:"derived",...n}}function Oo(n){return{describeKind:"derived",partial:!0,...n}}function dn(n,e,t){return B([n],(r,o)=>{let s=r[0];if(s==null||s.length===0){o.down([[C]]);return}for(let i of s)o.emit(e(i))},{...z(t),meta:{...J("map"),...t?.meta??{}}})}function cn(n,e,t){return B([n],(r,o)=>{let s=r[0];if(s==null||s.length===0){o.down([[C]]);return}let i=!1;for(let a of s)e(a)&&(o.emit(a),i=!0);i||o.down([[C]])},{...z(t),meta:{...J("filter"),...t?.meta??{}}})}function yi(n,e,t,r){return B([n],(o,s,i)=>{"acc"in i.store||(i.store.acc=t);let a=o[0];if(a==null||a.length===0){s.down([[C]]);return}for(let u of a)i.store.acc=e(i.store.acc,u),s.emit(i.store.acc)},{...z(r),initial:t,resetOnTeardown:!0,meta:{...J("scan",{initial:t}),...r?.meta??{}}})}function vi(n,e,t,r){return B([n],(o,s,i)=>{if("acc"in i.store||(i.store.acc=t),i.terminalDeps[0]===!0){s.emit(i.store.acc),s.down([[N]]);return}let a=o[0];if(a==null||a.length===0){s.down([[C]]);return}for(let u of a)i.store.acc=e(i.store.acc,u)},{...z(r),completeWhenDepsComplete:!1,meta:{...J("reduce",{initial:t}),...r?.meta??{}}})}function ln(n,e,t){return e<=0?B([n],(r,o,s)=>{s.store.completed||(s.store.completed=!0,o.down([[N]]))},{...z(t),completeWhenDepsComplete:!1,meta:{...J("take",{count:e}),...t?.meta??{}}}):B([n],(r,o,s)=>{if("taken"in s.store||(s.store.taken=0),s.store.done){o.down([[C]]);return}if(s.terminalDeps[0]===!0){s.store.done=!0,o.down([[N]]);return}let i=r[0];if(i==null||i.length===0){o.down([[C]]);return}for(let a of i)if(s.store.taken++,o.emit(a),s.store.taken>=e){s.store.done=!0,o.down([[N]]);return}},{...z(t),completeWhenDepsComplete:!1,meta:{...J("take",{count:e}),...t?.meta??{}}})}function Eo(n,e,t){return B([n],(r,o,s)=>{"skipped"in s.store||(s.store.skipped=0);let i=r[0];if(i==null||i.length===0){o.down([[C]]);return}let a=!1;for(let u of i)s.store.skipped++,s.store.skipped<=e||(o.emit(u),a=!0);a||o.down([[C]])},z(t))}function Ti(n,e,t){return B([n],(r,o,s)=>{if(s.store.done){o.down([[C]]);return}let i=r[0];if(i==null||i.length===0){o.down([[C]]);return}for(let a of i){if(!e(a)){s.store.done=!0,o.down([[N]]);return}o.emit(a)}},{...z(t),completeWhenDepsComplete:!1})}function wi(n,e,t){let r=t?.predicate??(i=>i[0]===x),{predicate:o,...s}=t??{};return A(i=>{let a=!1,u=n.subscribe(c=>{if(!a)for(let l of c){if(a)return;l[0]===x?i.emit(l[1]):(l[0]===N||l[0]===S)&&(a=!0,i.down([l]))}}),d=e.subscribe(c=>{if(!a)for(let l of c){if(a)return;if(r(l)){a=!0,i.down([[N]]);return}}});return()=>{u(),d()}},z(s))}function dr(n,e){return ln(n,1,e)}function ki(n,e){let{defaultValue:t,...r}=e??{},o=e!=null&&Object.hasOwn(e,"defaultValue");return B([n],(s,i,a)=>{if(a.terminalDeps[0]===!0){a.store.has?i.emit(a.store.latest):o&&i.emit(t),i.down([[N]]);return}let u=s[0];if(u==null||u.length===0){i.down([[C]]);return}a.store.latest=u.at(-1),a.store.has=!0},{...z(r),completeWhenDepsComplete:!1})}function xi(n,e,t){return ln(cn(n,e,t),1,t)}function Ni(n,e,t){return ln(Eo(n,e,t),1,t)}function _i(n,e,t){if(typeof e=="function")return B([n],(o,s)=>{let i=o[0];if(i==null||i.length===0){s.down([[C]]);return}for(let a of i)e(a),s.emit(a)},{...z(t),meta:{...J("tap"),...t?.meta??{}}});let r=e;return B([n],(o,s,i)=>{if(i.terminalDeps[0]!==void 0){i.terminalDeps[0]===!0?(r.complete?.(),s.down([[N]])):(r.error?.(i.terminalDeps[0]),s.down([[S,i.terminalDeps[0]]]));return}let a=o[0];if(a==null||a.length===0){s.down([[C]]);return}for(let u of a)r.data?.(u),s.emit(u)},{...z(t),completeWhenDepsComplete:!1,meta:{...J("tap"),...t?.meta??{}}})}function Ro(n,e,t){let r=t?.where??(s=>s!=null),o=!1;return B([n],(s,i)=>{let a=s[0];if(a==null||a.length===0){i.down([[C]]);return}for(let u of a)!o&&r(u)&&(o=!0,e(u)),i.emit(u)},z(t))}function Oi(n,e=Object.is,t){return B([n],(r,o,s)=>{let i=r[0];if(i==null||i.length===0){o.down([[C]]);return}let a=!1;for(let u of i)s.store.hasPrev&&e(s.store.prev,u)||(s.store.prev=u,s.store.hasPrev=!0,o.emit(u),a=!0);a||o.down([[C]])},{...z(t),meta:{...J("distinctUntilChanged"),...t?.meta??{}}})}function Ei(n,e){return B([n],(t,r,o)=>{let s=t[0];if(s==null||s.length===0){r.down([[C]]);return}let i=!1;for(let a of s)if(!o.store.hasPrev)o.store.prev=a,o.store.hasPrev=!0;else{let u=[o.store.prev,a];o.store.prev=a,r.emit(u),i=!0}i||r.down([[C]])},z(e))}function Mo(...n){let e=[...n];return ye(e,t=>t,{...z(),equals:(t,r)=>{if(t.length!==r.length)return!1;for(let o=0;o<t.length;o++)if(!Object.is(t[o],r[o]))return!1;return!0}})}function Ri(n,e,t){return B([n,e],(r,o,s)=>{let i=r[0],a=r[1],u=a!=null&&a.length>0?a.at(-1):s.prevData[1];if(i!=null&&i.length>0){if(!(a!=null&&a.length>0)&&s.prevData[1]===void 0){o.down([[C]]);return}for(let d of i)o.emit([d,u])}else o.down([[C]])},{...Oo(t),meta:{...J("withLatestFrom"),...t?.meta??{}}})}function Vt(...n){return n.length===0?A(e=>{e.down([[N]])},{...z(),meta:{...J("merge")}}):A(e=>{let t=n.length,r=0,o=[];for(let s of n){let i=s.subscribe(a=>{for(let u of a)u[0]===x?e.emit(u[1]):u[0]===N?(r+=1,r>=t&&e.down([[N]])):u[0]===S&&e.down([u])});o.push(i)}return()=>{for(let s of o)s()}},{...z(),meta:{...J("merge")}})}function Mi(...n){let e=n.length;return e===0?A(t=>{t.emit([]),t.down([[N]])},z()):A(t=>{let r=Array.from({length:e},()=>[]),o=e;function s(){for(;r.every(a=>a.length>0);){let a=r.map(u=>u.shift());t.emit(a)}}let i=[];for(let a=0;a<e;a++){let u=a,d=n[a].subscribe(c=>{for(let l of c)l[0]===x?(r[u].push(l[1]),s()):l[0]===N?(o-=1,(o===0||r[u].length===0)&&t.down([[N]])):l[0]===S&&t.down([l])});i.push(d)}return()=>{for(let a of i)a()}},z())}function Ai(n,e,t){return A(r=>{let o=0,s=[],i,a;return a=e.subscribe(u=>{for(let d of u)o===0?d[0]===x?s.push(d[1]):d[0]===S&&r.down([d]):d[0]===x?r.emit(d[1]):(d[0]===N||d[0]===S)&&r.down([d])}),i=n.subscribe(u=>{for(let d of u)if(o===0)if(d[0]===x)r.emit(d[1]);else if(d[0]===N){o=1;for(let c of s)r.emit(c);s.length=0}else d[0]===S&&r.down([d])}),()=>{i?.(),a?.()}},z(t))}function Ci(...n){return n.length===0?A(e=>{e.down([[N]])},z()):n.length===1?B([n[0]],(e,t)=>{let r=e[0];if(r==null||r.length===0){t.down([[C]]);return}for(let o of r)t.emit(o)},z()):A(e=>{let t=null,r=[];for(let o=0;o<n.length;o++){let s=o,i=n[o].subscribe(a=>{for(let u of a){if(t!==null&&s!==t)return;u[0]===x?(t===null&&(t=s),e.emit(u[1])):(u[0]===N||u[0]===S)&&(t===null||s===t)&&e.down([u])}});r.push(i)}return()=>{for(let o of r)o()}},z())}function fn(n,e,t){let r,o=!1,s=()=>{o||(o=!0,t())};return r=n.subscribe(i=>{let a=!1,u=!1;for(let d of i)d[0]!==Ve&&(d[0]===x?e.emit(d[1]):d[0]===N?a=!0:d[0]===S?(u=!0,e.down([d])):(d[0]===V||d[0]===C)&&e.down([d]));u?(r?.(),r=void 0,s()):a&&s()}),()=>{r?.(),r=void 0}}function we(n,e,t){let r,o=!1;function s(){r?.(),r=void 0}return B([n],(i,a,u)=>{if(u.terminalDeps[0]!=null&&u.terminalDeps[0]!==!0){s();return}if(u.terminalDeps[0]===!0){o=!0,r||a.down([[N]]);return}let d=i[0];if(!(d==null||d.length===0))return s(),r=fn(ie(e(d[d.length-1])),a,()=>{s(),o&&a.down([[N]])}),{deactivate:()=>{s(),o=!1}}},{...z(t),completeWhenDepsComplete:!1,meta:{...J("switchMap"),...t?.meta??{}}})}function Pi(n,e,t){let r,o=!1;function s(){r?.(),r=void 0}return B([n],(i,a,u)=>{if(u.terminalDeps[0]!=null&&u.terminalDeps[0]!==!0){s();return}if(u.terminalDeps[0]===!0){o=!0,r||a.down([[N]]);return}let d=i[0];if(!(d==null||d.length===0))return r===void 0?r=fn(ie(e(d[0])),a,()=>{s(),o&&a.down([[N]])}):a.down([[C]]),{deactivate:()=>{s(),o=!1}}},{...z(t),completeWhenDepsComplete:!1})}function Di(n,e,t){let{maxBuffer:r,...o}=t??{},s=[],i,a=!1,u;function d(){i?.(),i=void 0}function c(){if(!u||i!==void 0)return;if(s.length===0){a&&u.down([[N]]);return}let f=s.shift();i=fn(ie(e(f)),u,()=>{d(),c()})}function l(f){r&&r>0&&s.length>=r&&s.shift(),s.push(f),c()}return B([n],(f,p,h)=>{if(u=p,h.terminalDeps[0]!=null&&h.terminalDeps[0]!==!0){d(),s.length=0;return}if(h.terminalDeps[0]===!0){a=!0,c();return}let g=f[0];if(!(g==null||g.length===0)){for(let m of g)l(m);return{deactivate:()=>{d(),s.length=0,a=!1}}}},{...z(o),completeWhenDepsComplete:!1})}function Ao(n,e,t){let{concurrent:r,...o}=t??{},s=r!=null&&r>0?r:Number.POSITIVE_INFINITY,i=0,a=!1,u=new Set,d=[],c;function l(){a&&i===0&&d.length===0&&c&&c.down([[N]])}function f(m){if(!c)return;i++;let y;y=fn(ie(e(m)),c,()=>{y&&u.delete(y),i--,p(),l()}),u.add(y)}function p(){for(;d.length>0&&i<s;)f(d.shift())}function h(m){i<s?f(m):d.push(m)}function g(){for(let m of u)m();u.clear(),i=0,d.length=0}return B([n],(m,y,b)=>{if(c=y,b.terminalDeps[0]!=null&&b.terminalDeps[0]!==!0){g();return}if(b.terminalDeps[0]===!0){a=!0,l();return}let v=m[0];if(!(v==null||v.length===0)){for(let T of v)h(T);return{deactivate:()=>{g(),a=!1}}}},{...z(o),completeWhenDepsComplete:!1})}function Ii(n,e,t){return A(r=>{let o=new Set;function s(){for(let a of o)clearTimeout(a);o.clear()}let i=n.subscribe(a=>{for(let u of a)if(u[0]===x){let d=setTimeout(()=>{o.delete(d),r.emit(u[1])},e);o.add(d)}else if(u[0]===N){let d=setTimeout(()=>{o.delete(d),r.down([[N]])},e);o.add(d)}else u[0]===S&&(s(),r.down([u]))});return()=>{i(),s()}},z(t))}function Co(n,e,t){return A(r=>{let o,s;function i(){o!==void 0&&(clearTimeout(o),o=void 0)}let a=n.subscribe(u=>{for(let d of u)d[0]===x?(i(),s=d[1],o=setTimeout(()=>{o=void 0,r.emit(s)},e)):d[0]===N?(o!==void 0&&(i(),r.emit(s)),r.down([[N]])):d[0]===S&&(i(),r.down([d]))});return()=>{a(),i()}},{...z(t),meta:{...J("debounce",{ms:e}),...t?.meta??{}}})}function Po(n,e,t){let{leading:r,trailing:o,...s}=t??{},i=r!==!1,a=o===!0,u=e*1e6;return A(d=>{let c,l=-1/0,f,p=!1;function h(){c!==void 0&&(clearTimeout(c),c=void 0)}let g=n.subscribe(m=>{for(let y of m)if(y[0]===x){let b=y[1],v=re();if(i&&v-l>=u)l=v,d.emit(b),h(),a&&(c=setTimeout(()=>{c=void 0,p&&(l=re(),d.emit(f),p=!1)},e));else if(a&&(f=b,p=!0,c===void 0)){let T=(v-l)/1e6;c=setTimeout(()=>{c=void 0,p&&(l=re(),d.emit(f),p=!1)},Math.max(0,e-T))}}else(y[0]===N||y[0]===S)&&(h(),d.down([y]))});return()=>{g(),h()}},{...z(s),meta:{...J("throttle",{ms:e,leading:i,trailing:a}),...s.meta??{}}})}function Bi(n,e,t){return A(r=>{let o,s=!1,i=!1,a=n.subscribe(d=>{if(!s)for(let c of d){if(s)return;c[0]===x?o={v:c[1]}:c[0]===S?(s=!0,r.down([c])):c[0]===N&&(i=!0,o=void 0)}}),u=e.subscribe(d=>{if(!s)for(let c of d){if(s)return;c[0]===x?o!==void 0&&!i&&r.emit(o.v):c[0]===S?(s=!0,r.down([c])):c[0]===N&&(s=!0,r.down([[N]]))}});return()=>{a(),u()}},z(t))}function Vi(n,e,t){return A(r=>{let o,s,i=!1;function a(){o!==void 0&&(clearTimeout(o),o=void 0)}let u=n.subscribe(d=>{for(let c of d)c[0]===x?(s=c[1],i=!0,a(),o=setTimeout(()=>{o=void 0,i&&(i=!1,r.emit(s))},e)):(c[0]===N||c[0]===S)&&(a(),r.down([c]))});return()=>{u(),a()}},z(t))}function Gi(n,e,t){return A(r=>{let o=[],s=n.subscribe(a=>{for(let u of a)u[0]===x?o.push(u[1]):u[0]===N?(o.length>0&&r.emit([...o]),o.length=0,r.down([[N]])):u[0]===S&&r.down([u])}),i=e.subscribe(a=>{for(let u of a)u[0]===x?o.length>0&&(r.emit([...o]),o.length=0):u[0]===N?r.down([[N]]):u[0]===S&&r.down([u])});return()=>{s(),i(),o.length=0}},z(t))}function Fi(n,e,t){if(e<=0)throw new RangeError("bufferCount expects count > 0");return A(r=>{let o=[],s=n.subscribe(i=>{for(let a of i)a[0]===x?(o.push(a[1]),o.length>=e&&r.emit(o.splice(0,o.length))):a[0]===N?(o.length>0&&r.emit([...o]),o.length=0,r.down([[N]])):a[0]===S&&r.down([a])});return()=>{s(),o.length=0}},z(t))}function zi(n,e,t){if(e<=0)throw new RangeError("windowCount expects count > 0");return A(r=>{let o,s=0;function i(){let u=A(d=>(o=d.down.bind(d),()=>{o=void 0}),z());s=0,r.emit(u)}let a=n.subscribe(u=>{for(let d of u)d[0]===x?(o||i(),o?.([[x,d[1]]]),s+=1,s>=e&&(o?.([[N]]),o=void 0)):d[0]===N?(o?.([[N]]),o=void 0,r.down([[N]])):d[0]===S&&(o?.([d]),o=void 0,r.down([d]))});return()=>{a(),o?.([[N]]),o=void 0}},z(t))}function Ki(n,e,t){return A(r=>{let o=[],s=setInterval(()=>{o.length>0&&(r.emit([...o]),o.length=0)},e),i=n.subscribe(a=>{for(let u of a)u[0]===x?o.push(u[1]):u[0]===N?(clearInterval(s),o.length>0&&r.emit([...o]),o.length=0,r.down([[N]])):u[0]===S&&(clearInterval(s),r.down([u]))});return()=>{i(),clearInterval(s),o.length=0}},{...z(t),meta:{...J("bufferTime",{ms:e}),...t?.meta??{}}})}function $i(n,e,t){return A(r=>{let o;function s(){o?.([[N]]),o=void 0}function i(){let d=A(c=>(o=c.down.bind(c),()=>{o=void 0}),z());r.emit(d)}i();let a=setInterval(()=>{s(),i()},e),u=n.subscribe(d=>{for(let c of d)c[0]===x?o?.([[x,c[1]]]):c[0]===N?(clearInterval(a),s(),r.down([[N]])):c[0]===S&&(clearInterval(a),o?.([c]),s(),r.down([c]))});return()=>{u(),clearInterval(a),s()}},z(t))}function ji(n,e,t){return A(r=>{let o;function s(){o?.([[N]]),o=void 0}function i(){let d=A(c=>(o=c.down.bind(c),()=>{o=void 0}),z());r.emit(d)}let a=n.subscribe(d=>{for(let c of d)c[0]===x?(o||i(),o?.([[x,c[1]]])):c[0]===N?(s(),r.down([[N]])):c[0]===S&&(o?.([c]),o=void 0,r.down([c]))}),u=e.subscribe(d=>{for(let c of d)c[0]===x&&(s(),i())});return()=>{a(),u(),s()}},z(t))}function Wi(n,e){return A((t,r)=>{"n"in r.store||(r.store.n=0);let o=setInterval(()=>{t.emit(r.store.n),r.store.n=r.store.n+1},n);return()=>clearInterval(o)},z(e))}function Ui(n,e,t){if(e<=0)throw new RangeError("repeat expects count > 0");return A(r=>{let o=e,s,i=()=>{s?.(),s=n.subscribe(a=>{let u=!1,d=[];for(let c of a)c[0]===N?u=!0:d.push(c);d.length>0&&r.down(d),u&&(s?.(),s=void 0,o-=1,o>0?i():r.down([[N]]))})};return i(),()=>{s?.()}},z(t))}function Hi(n,e){return B([n],(t,r)=>{let o=t[0];if(o==null||o.length===0){r.down([[C]]);return}for(let s of o)r.emit(s)},z(e))}function Do(n,e,t){return A(r=>{let o=n.subscribe(s=>{for(let i of s)if(i[0]===x)r.emit(i[1]);else if(i[0]===S)try{r.emit(e(i[1]))}catch(a){r.down([[S,a]])}else i[0]===N&&r.down([[N]])});return()=>{o()}},z(t))}function qi(n,e,t){return B([n,e],(r,o,s)=>{let i=r[1];if(!(i!=null&&i.length>0?i.at(-1):s.prevData[1])){o.down([[C]]);return}let u=r[0];if(u!=null&&u.length>0){for(let d of u)o.emit(d);return}if(i!=null&&i.length>0&&s.prevData[0]!==void 0){o.emit(s.prevData[0]);return}o.down([[C]])},Oo(t))}var Si,Li,Ji,Yi,Qi,Xi,Lo=q(()=>{"use strict";Pe();Z();pt();be();fe();Be();Si=Ro;Li=Ao;Ji=Mo,Yi=Co,Qi=Po,Xi=Do});var yt=q(()=>{"use strict";Lo()});var Pu={};Nn(Pu,{CircuitOpenError:()=>vt,ContentAddressedMissError:()=>hn,DEFAULT_AUDIT_GUARD:()=>Qo,NS_PER_MS:()=>he,NS_PER_SEC:()=>De,NativeIndexBackend:()=>bn,NativeListBackend:()=>yn,NativeLogBackend:()=>mn,NativeMapBackend:()=>pn,NativePubSubBackend:()=>gn,RateLimiterOverflowError:()=>Tt,ResettableTimer:()=>Le,TimeoutError:()=>wt,appendAudit:()=>Kt,appendLogStorage:()=>es,audit:()=>Vi,awaitSettled:()=>hi,budgetGate:()=>Ye,buffer:()=>Gi,bufferCount:()=>Fi,bufferTime:()=>Ki,bumpCursor:()=>gr,cached:()=>pi,canonicalJson:()=>Yo,cascadingCache:()=>Qa,catchError:()=>Xi,checkpointToRedis:()=>Ka,checkpointToS3:()=>za,circuitBreaker:()=>ht,combine:()=>Mo,combineLatest:()=>Ji,concat:()=>Ai,concatMap:()=>Di,constant:()=>Vn,contentAddressedStorage:()=>tu,createAuditLog:()=>iu,createTransport:()=>st,createWatermarkController:()=>Ya,csvRows:()=>Na,debounce:()=>Co,debounceTime:()=>Yi,decay:()=>ts,decorrelatedJitter:()=>Kn,defer:()=>ci,delay:()=>Ii,deserializeError:()=>Ot,dictKv:()=>_u,dictSnapshot:()=>Su,distill:()=>eu,distinctUntilChanged:()=>Oi,domainMeta:()=>ve,elementAt:()=>Ni,empty:()=>ai,escapeRegexChar:()=>ko,exhaustMap:()=>Pi,exponential:()=>Fn,externalBundle:()=>$n,externalProducer:()=>ft,fallback:()=>Bt,fibonacci:()=>zn,filter:()=>cn,find:()=>xi,first:()=>dr,firstValueFrom:()=>ur,firstWhere:()=>sr,flatMap:()=>Li,forEach:()=>rt,fromAny:()=>ie,fromAsyncIter:()=>No,fromCSV:()=>xa,fromClickHouseWatch:()=>Oa,fromCron:()=>ri,fromDrizzle:()=>Ha,fromEvent:()=>oi,fromHTTP:()=>Bo,fromHTTPPoll:()=>aa,fromHTTPStream:()=>ia,fromIter:()=>ir,fromKafka:()=>va,fromKysely:()=>qa,fromMCP:()=>ca,fromNATS:()=>Ma,fromNDJSON:()=>Sa,fromOTel:()=>la,fromPrisma:()=>Ua,fromPrometheus:()=>ba,fromPromise:()=>xo,fromPulsar:()=>Ea,fromRabbitMQ:()=>Ca,fromRaf:()=>ni,fromRedisStream:()=>wa,fromSSE:()=>sa,fromSqlite:()=>$a,fromSqliteCursor:()=>ja,fromStatsD:()=>ha,fromSyslog:()=>fa,fromTimer:()=>nt,fromWebSocket:()=>Io,fromWebSocketReconnect:()=>da,fromWebhook:()=>ea,globToRegExp:()=>Zs,interval:()=>Wi,jsonCodec:()=>$t,jsonCodecFor:()=>wu,keepalive:()=>Ze,kvStorage:()=>Tr,last:()=>ki,lightMutation:()=>au,linear:()=>Gn,lru:()=>jo,makeHttpError:()=>nu,map:()=>dn,matchesAnyPattern:()=>ei,matchesCron:()=>qn,memoryAppendLog:()=>xu,memoryBackend:()=>Tn,memoryKv:()=>Nu,memorySnapshot:()=>ku,merge:()=>Vt,mergeMap:()=>Ao,mergeReactiveLogs:()=>ou,nameToSignal:()=>_t,ndjsonRows:()=>_a,never:()=>ui,nodeSignal:()=>mi,of:()=>_o,onFirstData:()=>Ro,pairwise:()=>Ei,parseCron:()=>Hn,parsePrometheusText:()=>zo,parseSSEStream:()=>Fo,parseStatsD:()=>ga,parseSyslog:()=>pa,pausable:()=>Hi,pubsub:()=>fu,race:()=>Ci,rateLimiter:()=>gt,reactiveCounter:()=>bi,reactiveIndex:()=>mu,reactiveList:()=>gu,reactiveLog:()=>hr,reactiveMap:()=>fr,reactiveSink:()=>ae,reduce:()=>vi,registerCursor:()=>du,registerCursorMap:()=>cu,repeat:()=>Ui,replay:()=>ar,rescue:()=>Do,resolveBackoffPreset:()=>lt,retry:()=>je,sample:()=>Bi,scan:()=>yi,serializeError:()=>St,share:()=>fi,shareReplay:()=>gi,signalToName:()=>ot,singleFromAny:()=>bu,singleNodeFromAny:()=>yu,skip:()=>Eo,snapshotStorage:()=>vr,sortJsonValue:()=>vn,stableJsonString:()=>yr,stratify:()=>Ou,switchMap:()=>we,take:()=>ln,takeUntil:()=>wi,takeWhile:()=>Ti,tap:()=>_i,tapFirst:()=>Si,throttle:()=>Po,throttleTime:()=>Qi,throwError:()=>di,timeout:()=>bt,toArray:()=>li,toCSV:()=>Da,toClickHouse:()=>La,toFile:()=>$o,toHTTP:()=>ta,toKafka:()=>Ta,toLoki:()=>Ga,toMongo:()=>Va,toNATS:()=>Aa,toObservable:()=>lu,toPostgres:()=>Ba,toPulsar:()=>Ra,toRabbitMQ:()=>Pa,toReadableStream:()=>oa,toRedisStream:()=>ka,toS3:()=>Ia,toSSE:()=>na,toSSEBytes:()=>ra,toSqlite:()=>Wa,toTempo:()=>Fa,toWebSocket:()=>ua,tokenBucket:()=>an,topologyDiff:()=>Dt,tryIncrementBounded:()=>su,valve:()=>qi,verifiable:()=>Za,window:()=>ji,windowCount:()=>zi,windowTime:()=>$i,withBreaker:()=>mt,withLatestFrom:()=>Ri,withMaxAttempts:()=>Kr,withStatus:()=>et,workerBridge:()=>ns,workerSelf:()=>rs,wrapMutation:()=>uu,zip:()=>Mi});module.exports=us(Pu);Te();Pe();Z();be();fe();Te();Z();fe();function jr(n){return{describeKind:"producer",...n}}function ft(n,e){return A(t=>{let r=!0,o={emit(i){r&&t.emit(i)},error(i){r&&(r=!1,t.down([[S,i]]))},complete(){r&&(r=!1,t.down([[N]]))}},s;try{let i=n(o);s=typeof i=="function"?i:void 0}catch(i){return o.error(i),()=>{r=!1}}return()=>{r=!1;try{s?.()}catch{}}},jr(e))}function $n(n,e,t){let r=!0,o,s=0,i=0,a={},u=[],d=()=>{let p=o;o=void 0;try{p?.()}catch{}};for(let p of e){let h=t?.name?`${t.name}::${p}`:p,g=t?.channelOpts?.[p],m=A(y=>(s++,()=>{i++,s>0&&i>=s&&i>=e.length&&d()}),jr({...g,name:h}));a[p]=m,u.push(m)}let c={};for(let p of e)c[p]=h=>{r&&a[p].down([[x,h]])};c.error=p=>{r&&(r=!1,$(()=>{for(let h of u)h.down([[S,p]])}),d())},c.complete=()=>{r&&(r=!1,$(()=>{for(let p of u)p.down([[N]])}),d())};let l=n(c);return o=typeof l=="function"?l:void 0,Object.assign(a,{dispose:()=>{r&&(r=!1,$(()=>{for(let p of u)try{p.down([[N]])}catch{}}),d())}})}yt();Z();be();fe();Ct();nn();var cr=class{ring;arr;constructor(e){e===Number.POSITIVE_INFINITY||e<=0?(this.arr=[],this.ring=null):(this.ring=new Ge(e),this.arr=null)}get length(){return this.ring!=null?this.ring.size:this.arr.length}push(e){this.ring!=null?this.ring.push(e):this.arr.push(e)}shift(){return this.ring!=null?this.ring.shift():this.arr.shift()}drain(){if(this.ring!=null){let t=this.ring.toArray();return this.ring.clear(),t}let e=this.arr;return this.arr=[],e}};function Gt(n){return n instanceof Error?n:new Error(String(n))}function Zi(n){return n===void 0?null:typeof n=="string"?lt(n):n}function ae(n,e){let{name:t,onTransportError:r,retry:o,backpressure:s,batchSize:i=Number.POSITIVE_INFINITY,flushIntervalMs:a=0,serialize:u,stopOn:d,onUpstreamMessage:c,onDispose:l,send:f,sendBatch:p,ctx:h}=e;if(!f&&!p)throw new Error("reactiveSink: `send` or `sendBatch` must be provided");let g=h,m=Math.max(1,o?.maxAttempts??1),y=Zi(o?.backoff??(m>1?"exponential":void 0)),b=o?.shouldRetry??(()=>!0),v=p!==void 0||i<Number.POSITIVE_INFINITY||a>0,T=D=>t?`${t}::${D}`:void 0,w=G(void 0,{equals:()=>!1,name:T("sent")}),_=G(null,{name:T("failed")}),k=G(0,{name:T("inFlight")}),O=G(null,{name:T("errors")}),E=v?G(0,{name:T("buffered")}):void 0,R=s?G(!1,{name:T("paused")}):void 0,M=0,F=D=>{M+=D,k.down([[x,M]])},P=D=>{try{r?.(D)}catch{}try{O.down([[x,D]])}catch{}},I=new Set,ue=D=>{I.add(D);let U=()=>I.delete(D);D.then(U,U)},W=(D,U,Y)=>{let ee=y?y(U-1,Y,null):0,ce=ee==null?0:typeof ee=="number"&&ee>0?ee:0,Ae=Math.max(1,Math.ceil(ce/1e6));return new Promise(Q=>{setTimeout(()=>Q(D()),Ae)})},de=D=>D!=null&&typeof D=="object"&&typeof D.then=="function",Oe=D=>{let U;try{U=u?u(D):D}catch(Q){let H=Gt(Q);return P({stage:"serialize",error:H,value:D}),_.down([[x,{value:D,error:H,attempts:0}]]),Promise.resolve()}let Y=0,ee=Q=>{F(-1);let H=Gt(Q);if(P({stage:"send",error:H,value:D,attempt:Y}),!(Y<m&&b(H,Y))){_.down([[x,{value:D,error:H,attempts:Y}]]);return}return W(Ae,Y,H)},ce=()=>{F(-1),w.down([[x,D]])};function Ae(){Y+=1,F(1);let Q;try{Q=f(U,g)}catch(H){return ee(H)??Promise.resolve()}return de(Q)?Q.then(ce,H=>ee(H)):(ce(),Promise.resolve())}return Ae()},Fe=s?.maxBuffer??Number.POSITIVE_INFINITY,Ee=new cr(Fe),_e,ze=!1,Ke=()=>{E?.down([[x,Ee.length]])},We=D=>{R&&R.down([[x,D]])},L=s?.strategy??"drop-oldest",X=(D,U)=>{let Y={value:D,payload:U};if(Ee.length<Fe)return Ee.push(Y),Ke(),!0;if(L==="drop-oldest"){let ce=Ee.shift();return Ee.push(Y),Ke(),We(!0),_.down([[x,{value:ce.value,error:new Error("backpressure: buffer overflow \u2014 dropped oldest"),attempts:0}]]),!0}if(L==="drop-newest")return We(!0),_.down([[x,{value:D,error:new Error("backpressure: buffer overflow \u2014 dropped newest"),attempts:0}]]),!1;let ee=new Error("backpressure: buffer overflow");return P({stage:"send",error:ee,value:D}),_.down([[x,{value:D,error:ee,attempts:0}]]),We(!0),!1},ke=D=>{let U=0,Y=D.map(Q=>Q.payload),ee=Q=>{F(-1);let H=Gt(Q);if(P({stage:"send",error:H,value:D.map(kn=>kn.value),attempt:U}),!(U<m&&b(H,U))){for(let{value:kn}of D)_.down([[x,{value:kn,error:H,attempts:U}]]);return}return W(Ae,U,H)},ce=()=>{F(-1);for(let{value:Q}of D)w.down([[x,Q]])};function Ae(){U+=1,F(1);let Q;try{Q=p(Y,g)}catch(H){return ee(H)??Promise.resolve()}return de(Q)?Q.then(ce,H=>ee(H)):(ce(),Promise.resolve())}return Ae()},Ue=async D=>{for(let U of D)await xe(U.value,U.payload)},xe=(D,U)=>{let Y=0,ee=Q=>{F(-1);let H=Gt(Q);if(P({stage:"send",error:H,value:D,attempt:Y}),!(Y<m&&b(H,Y))){_.down([[x,{value:D,error:H,attempts:Y}]]);return}return W(Ae,Y,H)},ce=()=>{F(-1),w.down([[x,D]])};function Ae(){Y+=1,F(1);let Q;try{Q=f(U,g)}catch(H){return ee(H)??Promise.resolve()}return de(Q)?Q.then(ce,H=>ee(H)):(ce(),Promise.resolve())}return Ae()},j=()=>{if(ze||Ee.length===0)return Promise.resolve();let D=Ee.drain();if(Ke(),We(!1),p!==void 0){let Y=ke(D);return ue(Y),Y}let U=Ue(D);return ue(U),U},me=()=>{_e!==void 0||ze||a<=0||(_e=setTimeout(()=>{_e=void 0,j()},a))},Et=n.subscribe(D=>{for(let U of D){let Y=U[0];if(Y!==x)try{c?.(U)}catch{}if(Y===x){let ee=U[1];if(v){let ce;if(u)try{ce=u(ee)}catch(Q){let H=Gt(Q);P({stage:"serialize",error:H,value:ee}),_.down([[x,{value:ee,error:H,attempts:0}]]);continue}else ce=ee;if(!X(ee,ce))continue;Ee.length>=i?j():me()}else{let ce=Oe(ee);ue(ce)}}else ge.messageTier(Y)>=3&&v&&(_e!==void 0&&(clearTimeout(_e),_e=void 0),j())}}),wr;if(d){let D=!1;wr=d.subscribe(U=>{if(!D){D=!0;return}U.length>0&&!wn&&kr()})}let wn=!1,kr=()=>{if(wn)return;wn=!0,_e!==void 0&&(clearTimeout(_e),_e=void 0),v&&j(),ze=!0,wr?.(),Et();let D=U=>{try{U.down([[K]])}catch{}};D(O),D(_),D(w),D(k),E&&D(E),R&&D(R);try{l?.()}catch{}},jt={dispose:kr,sent:w,failed:_,inFlight:k,errors:O};return v&&(jt.buffered=E,jt.flush=async()=>{ze||(await j(),await Promise.all(I))}),R&&(jt.paused=R),jt}un();Be();function Ce(n){return{describeKind:"producer",...n}}function Io(n,e){let{parse:t,closeOnTeardown:r=!1,...o}=e??{};return A(s=>{let i=!0,a,u=()=>{let y=a;a=void 0,y?.()},d=y=>{i&&(i=!1,s.down([y]),u())},c=(y,b=y)=>{if(i)try{let v=y!==null&&typeof y=="object"&&"data"in y?y.data:y,T=t?t(v,b):v;s.emit(T)}catch(v){d([S,v])}},l=y=>{d([S,y])},f=()=>{d([N])};if(typeof n=="function"){try{if(a=n(c,l,f),typeof a!="function")throw new Error("fromWebSocket register contract violation: register must return cleanup callable")}catch(y){d([S,y])}return()=>{i=!1,u()}}let p=n,h=y=>c(y,y),g=y=>l(y),m=()=>f();return p.addEventListener("message",h),p.addEventListener("error",g),p.addEventListener("close",m),a=()=>{p.removeEventListener("message",h),p.removeEventListener("error",g),p.removeEventListener("close",m),r&&p.close()},()=>{i=!1,u()}},Ce(o))}function ea(n,e){return ft(n,e)}function Bo(n,e){let{method:t="GET",headers:r,body:o,transform:s=v=>v.json(),timeoutNs:i=30*1e9,signal:a,completeAfterFetch:u=!1,refetchOnSubscribe:d=!1,...c}=e??{},l=G(0,{name:`${c.name??"http"}/fetchCount`}),f=G(0,{name:`${c.name??"http"}/lastUpdated`}),p=G(!1,{name:`${c.name??"http"}/fetched`}),h=0,g=o!==void 0?typeof o=="string"?o:JSON.stringify(o):void 0,m=v=>{let T=new AbortController,w=!0;if(a?.aborted)return w=!1,v.down([[S,a.reason??new Error("Aborted")]]),()=>{};a?.addEventListener("abort",()=>T.abort(a.reason),{once:!0});let _=setTimeout(()=>T.abort(new Error("Request timeout")),Math.ceil(i/1e6));return fetch(n,{method:t,headers:r,body:g,signal:T.signal}).then(async k=>{if(clearTimeout(_),!w)return;if(!k.ok)throw new Error(`HTTP ${k.status}: ${k.statusText}`);let O=await s(k);w&&($(()=>{h+=1,l.down([[x,h]]),f.down([[x,ne()]]),p.down([[x,!0]]),v.emit(O)}),u&&v.down([[N]]))}).catch(k=>{clearTimeout(_),w&&(k&&k.name==="AbortError"||v.down([[S,k]]))}),()=>{w=!1,T.abort()}},y=A(v=>m({emit:T=>v.emit(T),down:T=>v.down(T)}),{...Ce(c),resubscribable:d});return{...et(y),fetchCount:l,lastUpdated:f,fetched:p}}function ta(n,e,t){let{method:r="POST",headers:o={"Content-Type":"application/json"},serialize:s=h=>JSON.stringify(h),timeoutNs:i,batchFormat:a="json-array",batchSize:u,flushIntervalMs:d,retry:c,onTransportError:l}=t??{},f=async h=>{let g=i!==void 0?new AbortController:void 0,m;g&&i!==void 0&&(m=setTimeout(()=>g.abort(new Error("Request timeout")),Math.ceil(i/1e6)));try{let y=await fetch(e,{method:r,headers:o,body:h,signal:g?.signal}),b=async()=>{try{await y.arrayBuffer?.()}catch{}};if(!y.ok)throw await b(),new Error(`HTTP ${y.status}: ${y.statusText}`);await b()}finally{m!==void 0&&clearTimeout(m)}};return u!==void 0||d!==void 0?ae(n,{onTransportError:l,retry:c,batchSize:u,flushIntervalMs:d,sendBatch:async h=>{let g;a==="ndjson"?g=h.map(m=>{let y=s(m);return typeof y=="string"?y:new TextDecoder().decode(y)}).join(`
4
- `):g=JSON.stringify(h),await f(g)}}):ae(n,{onTransportError:l,retry:c,serialize:s,send:async h=>{await f(h)}})}function Vo(n){return Symbol.keyFor(n)??n.description??"message"}function kt(n,e){return typeof n=="string"?n:e(n)}function Go(n,e){let t=`event: ${n}
5
- `;if(e!==void 0){let r=e.split(/\r?\n/);for(let o of r)t+=`data: ${o}
1
+ "use strict";var Sn=Object.defineProperty;var us=Object.getOwnPropertyDescriptor;var ds=Object.getOwnPropertyNames;var cs=Object.prototype.hasOwnProperty;var q=(n,e)=>()=>(n&&(e=n(n=0)),e);var En=(n,e)=>{for(var t in e)Sn(n,t,{get:e[t],enumerable:!0})},ls=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ds(e))!cs.call(n,s)&&s!==t&&Sn(n,s,{get:()=>e[s],enumerable:!(r=us(e,s))||r.enumerable});return n};var fs=n=>ls(Sn({},"__esModule",{value:!0}),n);function Jt(){return at>0||At}function Er(){return at>0}function dt(n){at>0?Ct.push(n):n()}function $(n){at+=1;let e=!1;try{n()}catch(t){throw e=!0,t}finally{if(at-=1,at===0)if(e){if(!At){let t=Ct.splice(0);for(let r of t)try{r()}catch{}qe.length=0,Je.length=0,ut.length=0}}else ps()}}function ps(){let n=!At;n&&(At=!0);let e=[],t=0;try{for(;qe.length>0||Je.length>0||ut.length>0||n&&Ct.length>0;){if(n&&Ct.length>0){let o=Ct.splice(0);for(let a of o)try{a()}catch(i){e.push(i)}continue}if(t+=1,t>1e3)throw qe.length=0,Je.length=0,ut.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let s=(qe.length>0?qe:Je.length>0?Je:ut).splice(0);for(let o of s)try{o()}catch(a){e.push(a)}}}finally{n&&(At=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function Yt(n,e,t){if(e.length===0)return;if(e.length===1){let d=t(e[0][0]);if(d<3||!Jt()){n(e);return}(d>=5?ut:d===4?Je:qe).push(()=>n(e));return}let r=e.length,s=r,o=r,a=r,i=0;for(;i<r&&t(e[i][0])<3;)i++;for(s=i;i<r&&t(e[i][0])===3;)i++;for(o=i;i<r&&t(e[i][0])===4;)i++;a=i;let u=Jt();if(s>0){let d=e.slice(0,s);n(d)}if(o>s){let d=e.slice(s,o);u?qe.push(()=>n(d)):n(d)}if(a>o){let d=e.slice(o,a);u?Je.push(()=>n(d)):n(d)}if(r>a){let d=e.slice(a,r);u?ut.push(()=>n(d)):n(d)}}var at,At,qe,Je,ut,Ct,Te=q(()=>{"use strict";at=0,At=!1,qe=[],Je=[],ut=[],Ct=[]});function re(){return Math.trunc(performance.now()*1e6)}function ne(){return Date.now()*1e6}var Le=q(()=>{"use strict"});var Fe,x,F,D,Ne,le,pe,K,N,_,ct,Rn,hs,Mn,ms,gs,An,Rr,Mr,Ar,Cn,Z=q(()=>{"use strict";Fe=Symbol.for("graphrefly/START"),x=Symbol.for("graphrefly/DATA"),F=Symbol.for("graphrefly/DIRTY"),D=Symbol.for("graphrefly/RESOLVED"),Ne=Symbol.for("graphrefly/INVALIDATE"),le=Symbol.for("graphrefly/PAUSE"),pe=Symbol.for("graphrefly/RESUME"),K=Symbol.for("graphrefly/TEARDOWN"),N=Symbol.for("graphrefly/COMPLETE"),_=Symbol.for("graphrefly/ERROR"),ct=Object.freeze([F]),Rn=Object.freeze([D]),hs=Object.freeze([Ne]),Mn=Object.freeze([Fe]),ms=Object.freeze([N]),gs=Object.freeze([K]),An=Object.freeze([ct]),Rr=Object.freeze([Rn]),Mr=Object.freeze([hs]),Ar=Object.freeze([ms]),Cn=Object.freeze([gs])});function Dr(n,e){let t=new TextEncoder().encode(n.name);if(t.length===0||t.length>255)throw new Error(`encodeEnvelope: codec name "${n.name}" encodes to ${t.length} bytes (must be 1\u2013255)`);let r=n.version;if(!Number.isInteger(r)||r<0||r>65535)throw new Error(`encodeEnvelope: codec.version ${r} out of u16 range (expected integer 0\u201365535)`);let s=2+t.length+2+e.length;if(s>4294967295)throw new Error(`encodeEnvelope: total envelope size ${s} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let o=new Uint8Array(s),a=0;return o[a++]=Dn,o[a++]=t.length,o.set(t,a),a+=t.length,o[a++]=r>>>8&255,o[a++]=r&255,o.set(e,a),o}function Pr(n,e){if(n.length<Cr)throw new Error(`decodeEnvelope: bytes too short (${n.length} < ${Cr})`);let t=0,r=n[t++];if(r!==Dn)throw new Error(`decodeEnvelope: unsupported envelope version ${r} (expected ${Dn})`);let s=n[t++];if(s===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(t+s+2>n.length)throw new Error(`decodeEnvelope: envelope truncated (need ${t+s+2} bytes, have ${n.length})`);let o=new TextDecoder().decode(n.subarray(t,t+s));t+=s;let a=(n[t]<<8|n[t+1])>>>0;t+=2;let i=n.subarray(t),u=e.lookupCodec(o);if(u==null)throw new Error(`decodeEnvelope: codec "${o}" not registered (envelope codec_v=${a})`);return{codec:u,codecVersion:a,payload:i}}function Lr(n){n.registerCodec(bs)}var bs,Dn,Cr,Pn=q(()=>{"use strict";bs={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)}},Dn=1,Cr=4});function Qt(n){if(n==null)return lt;let{type:e,id:t,...r}=n;return{type:e??"system",id:t??"",...r}}var lt,Ln=q(()=>{"use strict";lt={type:"system",id:""}});function Ir(n){n.registerMessageType(Fe,{tier:0,wireCrossing:!1}),n.registerMessageType(F,{tier:1,wireCrossing:!1}),n.registerMessageType(Ne,{tier:1,wireCrossing:!1,metaPassthrough:!1}),n.registerMessageType(le,{tier:2,wireCrossing:!1}),n.registerMessageType(pe,{tier:2,wireCrossing:!1}),n.registerMessageType(x,{tier:3,wireCrossing:!0}),n.registerMessageType(D,{tier:3,wireCrossing:!0}),n.registerMessageType(N,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(_,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(K,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var Xt,Br=q(()=>{"use strict";Z();Xt=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_rigorRecorder;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=t=>{let r=this._messageTypes.get(t);return r!=null?r.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}get rigorRecorder(){return this._rigorRecorder}set rigorRecorder(e){this._rigorRecorder=e}registerMessageType(e,t){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:t.tier,wireCrossing:t.wireCrossing??t.tier>=3,metaPassthrough:t.metaPassthrough??!0}),this}messageTier(e){let t=this._messageTypes.get(e);return t!=null?t.tier:1}isWireCrossing(e){let t=this._messageTypes.get(e);return t!=null?t.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let t=this._messageTypes.get(e);return t!=null?t.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}}});function Vr(n){return Array.isArray(n)?[...n]:[n]}function ys(n,e){return n.has(e)||n.has("*")}function Fr(n){let e=[];return n((s,o)=>{e.push({kind:"allow",actions:new Set(Vr(s)),where:o?.where??(()=>!0)})},(s,o)=>{e.push({kind:"deny",actions:new Set(Vr(s)),where:o?.where??(()=>!0)})}),(s,o)=>{let a=!1,i=!1;for(let u of e)ys(u.actions,o)&&u.where(s)&&(u.kind==="deny"?a=!0:i=!0);return a?!1:i}}function In(n){let e=vs.filter(t=>n({type:t,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(t=>t==="human"||t==="llm"||t==="system")?"both":e.length===1?e[0]:e.join("+")}var Me,vs,Dt=q(()=>{"use strict";Me=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}};vs=["human","llm","wallet","system"]});function Bn(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(Bn);if(typeof n=="object"&&n!==null){let e={};for(let t of Object.keys(n).sort())e[t]=Bn(n[t]);return e}return null}function ks(n){let e=ws.encode(n),t=e.length,r=t*8,s=t+9+63&-64,o=new Uint8Array(s);o.set(e),o[t]=128;let a=new DataView(o.buffer);a.setUint32(s-4,r>>>0,!1),a.setUint32(s-8,Math.floor(r/4294967296)>>>0,!1);let i=1779033703,u=3144134277,d=1013904242,c=2773480762,f=1359893119,l=2600822924,p=528734635,h=1541459225,g=new Uint32Array(64),m=(y,v)=>y>>>v|y<<32-v;for(let y=0;y<s;y+=64){for(let M=0;M<16;M++)g[M]=a.getUint32(y+M*4,!1);for(let M=16;M<64;M++){let L=g[M-15],A=g[M-2],P=m(L,7)^m(L,18)^L>>>3,ue=m(A,17)^m(A,19)^A>>>10;g[M]=g[M-16]+P+g[M-7]+ue>>>0}let v=i,T=u,w=d,O=c,k=f,S=l,E=p,R=h;for(let M=0;M<64;M++){let L=m(k,6)^m(k,11)^m(k,25),A=k&S^~k&E,P=R+L+A+Ts[M]+g[M]>>>0,ue=m(v,2)^m(v,13)^m(v,22),W=v&T^v&w^T&w,de=ue+W>>>0;R=E,E=S,S=k,k=O+P>>>0,O=w,w=T,T=v,v=P+de>>>0}i=i+v>>>0,u=u+T>>>0,d=d+w>>>0,c=c+O>>>0,f=f+k>>>0,l=l+S>>>0,p=p+E>>>0,h=h+R>>>0}let b=y=>y.toString(16).padStart(8,"0");return b(i)+b(u)+b(d)+b(c)+b(f)+b(l)+b(p)+b(h)}function Vn(n){let e=Bn(n??null),t=JSON.stringify(e);return ks(t).slice(0,16)}function xs(){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 Fn(n,e,t){let r=t?.id??xs();if(n===0)return{id:r,version:0};let o=(t?.hash??Vn)(e);return{id:r,version:0,cid:o,prev:null}}function Gr(n,e,t){n.version+=1,"cid"in n&&(n.prev=n.cid,n.cid=t(e))}var Ts,ws,zr=q(()=>{"use strict";Ts=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]),ws=new TextEncoder});function jr(n){return{node:n,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function Gn(n){n.prevData=void 0,n.dirty=!1,n.involvedThisWave=!1,n.dataBatch.length=0,n.terminal=void 0}function Zt(n){return n.length===0?n:typeof n[0]=="symbol"?[n]:n}function V(n,e,t){let r=Wr(n)?n:[],s=typeof n=="function"?n:typeof e=="function"?e:void 0,o={};return Wr(n)?o=(zn(e)?e:t)??{}:zn(n)?o=n:o=(zn(e)?e:t)??{},new se(r,s,o)}var Kr,$r,Ns,Os,be,se,Wr,zn,ye=q(()=>{"use strict";Pn();Ln();Te();Le();Br();Dt();Z();zr();Kr=()=>{},$r=100;Ns=(n,e,t,r)=>{t.direction==="down-in"&&n._onDepMessage(t.depIndex,e)},Os=(n,e,t,r)=>{let s=n;if(s._status==="completed"||s._status==="errored")return;let o=s._cached,a=o===void 0?[Mn]:[Mn,[x,o]];s._status==="dirty"&&a.push(ct),Yt(e,a,s._config.tierOf)},be=new Xt({onMessage:Ns,onSubscribe:Os});Ir(be);Lr(be);se=class n{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,t,r){this._config=r.config??be,this._config.onMessage,this._optsName=r.name,this._describeKind=r.describeKind,this._equals=r.equals??Object.is,this._resubscribable=r.resubscribable??!1,this._resetOnTeardown=r.resetOnTeardown??!1,this._autoComplete=r.completeWhenDepsComplete??!0,this._autoError=r.errorWhenDepsError??!0,this._pausable=r.pausable??!0,this._guard=r.guard,this._fn=t,this._partial=r.partial??!1,this._cached=r.initial!==void 0?r.initial:void 0,this._status=e.length===0&&t==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=r.versioningHash??this._config.defaultHashFn??Vn;let s=r.versioning??this._config.defaultVersioning;this._versioningLevel=s,this._versioning=s!=null?Fn(s,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(jr);let o={};for(let[i,u]of Object.entries(r.meta??{})){let d={initial:u,name:`${r.name??"node"}:meta:${i}`,describeKind:"state",config:this._config};r.guard!=null&&(d.guard=r.guard),r.resubscribable===!0&&(d.resubscribable=!0),o[i]=new n([],void 0,d)}Object.freeze(o),this.meta=o,this._hasMeta=Object.keys(o).length>0;let a=this;this._actions={emit(i){a._emit([[x,i]])},down(i){a._emit(Zt(i))},up(i){a._emitUp(Zt(i))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,t){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let r=this._versioningLevel;if(r!=null&&e<=r)return;let s=t?.hash??this._hashFn;s!==this._hashFn&&(this._hashFn=s);let o=this._cached===void 0?void 0:this._cached,a=this._versioning,i=a?.id??t?.id,u=a?.version??0,d=Fn(e,o,{id:i,hash:s});d.version=u,this._versioning=d,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let t=Qt(e);if(this._guard!=null&&!this._guard(t,"observe"))return!1;if(this._extraGuards!=null){for(let r of this._extraGuards)if(!r(t,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let t=this._guard!=null||this._extraGuards!=null,r=e?.actor!=null;if(!t&&!r)return;let s=Qt(e?.actor),o=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(s,o))throw new Me({actor:s,action:o,nodeName:this.name});if(this._extraGuards!=null){for(let a of this._extraGuards)if(!a(s,o))throw new Me({actor:s,action:o,nodeName:this.name})}this._lastMutation={actor:s,timestamp_ns:ne()}}down(e,t){let r=Zt(e);r.length!==0&&(this._checkGuard(t),this._emit(r))}emit(e,t){this._checkGuard(t),this._emit([[x,e]])}up(e,t){if(this._deps.length===0)return;let r=Zt(e);if(r.length===0)return;this._checkGuard(t);let s=t??{internal:!0};this._validateUpTiers(r);for(let o of this._deps)o.node.up?.(r,s)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let t of this._deps)t.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let t=this._config.tierOf;for(let r of e){let s=t(r[0]);if(s===3||s===4)throw new Error(`Node "${this.name}": tier-${s} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,t){if(t!=null&&this._guard!=null){let u=Qt(t);if(!this._guard(u,"observe"))throw new Me({actor:u,action:"observe",nodeName:this.name})}let s=this._isTerminal&&this._resubscribable;if(s){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let u of this._deps)Gn(u);if(this._partial===!1){for(let u of this._deps)if(u.prevData!==void 0||u.dataBatch.length!==0||u.terminal!==void 0||u.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let o;try{o=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:s},this._actions)}catch(u){throw this._sinkCount-=1,u}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let a=this._isTerminal;if(this._sinkCount===1&&!a)try{this._activate()}catch(u){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof o=="function")try{o()}catch{}throw u}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let i=!1;return()=>{i||(i=!0,this._sinkCount-=1,this._removeSink(e),typeof o=="function"&&o(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[t]=this._sinks;this._sinks=t}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,t=0;try{for(let r=0;r<e;r++){let s=r,o=this._deps[r];o.unsub=Kr,o.unsub=o.node.subscribe(a=>{if(o.unsub===null)return;let i=this._config.tierOf,u=!1;for(let d of a)i(d[0])>=3&&(u=!0),this._config.onMessage(this,d,{direction:"down-in",depIndex:s},this._actions);u&&this._maybeRunFnOnSettlement()}),t++}}catch(r){this._deps[t].unsub=null;for(let s=0;s<t;s++){let o=this._deps[s];if(o.unsub!=null){let a=o.unsub;o.unsub=null;try{a()}catch{}Gn(o)}}throw this._dirtyDepCount=0,r}}_addDep(e){for(let s=0;s<this._deps.length;s++)if(this._deps[s].node===e)return s;let t=this._deps.length,r=jr(e);if(this._deps.push(r),this._sinks==null)return t;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(An),r.unsub=Kr;try{r.unsub=e.subscribe(s=>{if(r.unsub===null)return;let o=this._config.tierOf,a=!1;for(let i of s)o(i[0])>=3&&(a=!0),this._config.onMessage(this,i,{direction:"down-in",depIndex:t},this._actions);a&&this._maybeRunFnOnSettlement()})}catch(s){throw r.unsub=null,this._deps.pop(),this._dirtyDepCount--,s}return t}_deactivate(e=!1){let t=this._cleanup;if(this._cleanup=void 0,typeof t=="function")try{t()}catch(r){this._emit([[_,this._wrapFnError("cleanup threw",r)]])}else if(t!=null&&typeof t=="object"){let r=t.deactivate;if(typeof r=="function")try{r()}catch(s){this._emit([[_,this._wrapFnError("cleanup.deactivate threw",s)]])}}for(let r of this._deps){if(r.unsub!=null){let s=r.unsub;r.unsub=null;try{s()}catch{}}Gn(r)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,t){let r=this._deps[e],s=t[0];if(this._inspectorHooks!=null){let o={kind:"dep_message",depIndex:e,message:t};for(let a of this._inspectorHooks)a(o)}if(s!==Fe){if(s===F){this._depDirtied(r);return}if(s===Ne){if(this._depInvalidated(r),this._cached===void 0)return;this._emit(Mr);return}if(s===le||s===pe){this._emit([t]);return}if(s===K){this._emit(Cn);return}if(s===x)this._depSettledAsData(r,t[1]);else if(s===D)this._depSettledAsResolved(r);else if(s===N)this._depSettledAsTerminal(r,!0);else if(s===_)this._depSettledAsTerminal(r,t[1]);else{this._emit([t]);return}if(!this._fn){(s===x||s===D)&&this._emit([t]),(s===N||s===_)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(An))}_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(Rr),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(Ar)}_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(i){this._emit([[_,this._wrapFnError("cleanup.beforeRun threw",i)]]);return}}}let t=this._deps.map(a=>a.involvedThisWave?a.dataBatch.length>0?[...a.dataBatch]:[]:void 0),r=this._deps.map(a=>a.prevData);for(let a=0;a<this._deps.length;a++){let i=t[a];i!=null&&i.length>0&&(this._deps[a].prevData=i[i.length-1])}let s=this._deps.map(a=>a.terminal),o={prevData:r,terminalDeps:s,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let a={kind:"run",batchData:t,prevData:r};for(let i of this._inspectorHooks)i(a)}this._isExecutingFn=!0;try{let a=this._fn(t,this._actions,o);if(typeof a=="function")this._cleanup=a;else if(a!=null&&typeof a=="object"){let i=a;(typeof i.beforeRun=="function"||typeof i.deactivate=="function"||typeof i.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>$r?(this._rerunDepth=0,this._emit([[_,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${$r} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,t){let r=t instanceof Error?t.message:String(t);return new Error(`Node "${this.name}": ${e}: ${r}`,{cause:t})}_frameBatch(e){let t=this._config.tierOf;if(e.length===1)return t(e[0][0])===3&&this._status!=="dirty"?[ct,e[0]]:e;let r=!0,s=!1,o=!1,a=-1;for(let u of e){let d=t(u[0]);d<a&&(r=!1),d===3&&(s=!0),u[0]===F&&(o=!0),a=d}let i=e;if(!r){let u=e.map((d,c)=>({m:d,i:c,tier:t(d[0])}));u.sort((d,c)=>d.tier-c.tier||d.i-c.i),i=u.map(d=>d.m)}if(s&&!o&&this._status!=="dirty"){let u=0;for(;u<i.length&&t(i[u][0])===0;)u++;return u===0?[ct,...i]:[...i.slice(0,u),ct,...i.slice(u)]}return i}_emit(e){if(e.length===0)return;for(let i=0;i<e.length;i++){let u=e[i];if(u[0]===_&&u[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let t=e;if(this._isTerminal&&!this._resubscribable){let i=e.filter(u=>u[0]===K||u[0]===Ne);if(i.length===0)return;t=i}t=this._frameBatch(t);let s=null;for(let i=0;i<t.length;i++){let u=t[i],d=u[0];if(d!==le&&d!==pe){s?.push(u);continue}if(u.length<2)throw new Error(`Node "${this.name}": [[${d===le?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let c=!0;if(this._pausable!==!1){let f=u[1];if(d===le)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(f),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(f))c=!1;else if(this._pauseLocks.delete(f),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let l=this._pauseBuffer;this._pauseBuffer=[],this._emit(l)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}c?s?.push(u):s==null&&(s=t.slice(0,i))}if(s!=null){if(s.length===0)return;t=s}if(this._hasMeta&&t.some(i=>i[0]===K))for(let i of Object.keys(this.meta))try{this.meta[i]._emit(Cn)}catch{}let{finalMessages:o,equalsError:a}=this._updateState(t);if(o.length>0&&this._config.inspectorEnabled){let i=this._config.globalInspector;if(i!=null)try{i({kind:"emit",node:this,messages:o})}catch{}}if(o.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let i=this._config.tierOf,u=[];for(let d of o)i(d[0])===3?this._pauseBuffer.push(d):u.push(d);u.length>0&&this._dispatchOrAccumulate(u)}else this._dispatchOrAccumulate(o);a!=null&&this._emit([[_,a]])}_updateState(e){let t=this._config.tierOf,r,s,o=-1,a=0;for(let c of e)t(c[0])===3&&a++;let i=a<=1,u=-1;if(this._versioning!=null&&a>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===x){u=c;break}}for(let c=0;c<e.length;c++){let f=e[c],l=f[0];if(l===x){if(f.length>=2){let p=!1;if(i&&this._cached!==void 0)try{p=this._equals(this._cached,f[1])}catch(h){s=this._wrapFnError("equals threw",h),o=c;break}if(p){r==null&&(r=e.slice(0,c)),r.push(Rn),this._status="resolved";continue}this._cached=f[1],this._versioning!=null&&(u<0||c===u)&&Gr(this._versioning,f[1],this._hashFn)}this._status="settled",r?.push(f)}else if(r?.push(f),l===F)this._status="dirty";else if(l===D)this._status="resolved";else if(l===N){this._status="completed";{let p=this._config.rigorRecorder;if(p!=null)try{p.onTerminalTransition(this,"completed",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(l===_){this._status="errored";{let p=this._config.rigorRecorder;if(p!=null)try{p.onTerminalTransition(this,"errored",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(l===Ne){if(this._cached!==void 0){let h=this._config.rigorRecorder;if(h!=null)try{h.onNonVacuousInvalidate(this,this._cached)}catch{}}this._cached=void 0,this._status="dirty";let p=this._cleanup;if(typeof p=="function"){this._cleanup=void 0;try{p()}catch{}}else if(p!=null&&typeof p=="object"){let h=p.invalidate;if(typeof h=="function")try{h()}catch{}}}else l===K&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let d=o>=0?r??e.slice(0,o):r??e;return s!=null?{finalMessages:d,equalsError:s}:{finalMessages:d}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let t=[...this._sinks];for(let r of t)r(e)};_dispatchOrAccumulate(e){if(Er()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],dt(()=>this._flushBatchPending()));for(let t of e)this._batchPendingMessages.push(t);return}Yt(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);Yt(this._deliverToSinks,t,this._config.tierOf)}},Wr=n=>Array.isArray(n),zn=n=>typeof n=="object"&&n!=null&&!Array.isArray(n)});function G(n,e){return V([],{...e,initial:n})}function C(n,e){return V((r,s,o)=>n(s,o)??void 0,{describeKind:"producer",...e})}function he(n,e,t){return V(n,(s,o,a)=>{let i=s.map((u,d)=>u!=null&&u.length>0?u.at(-1):a.prevData[d]);o.emit(e(i,a))},{describeKind:"derived",...t})}function ft(n,e,t){return V(n,(s,o,a)=>{let i=s.map((u,d)=>u!=null&&u.length>0?u.at(-1):a.prevData[d]);return e(i,o,a)??void 0},{describeKind:"effect",...t})}var fe=q(()=>{"use strict";ye()});var Hr={};En(Hr,{NS_PER_MS:()=>me,NS_PER_SEC:()=>Oe,constant:()=>Kn,decorrelatedJitter:()=>Un,exponential:()=>jn,fibonacci:()=>Wn,linear:()=>$n,resolveBackoffPreset:()=>pt,withMaxAttempts:()=>Ur});function Ye(n){return n<0?0:n}function _s(n,e){return e==="none"?n:e==="full"?Math.random()*n:n/2+Math.random()*(n/2)}function Ss(n,e){return n+Math.random()*(e-n)}function Kn(n){let e=Ye(n);return()=>e}function $n(n,e){let t=Ye(n),r=e===void 0?t:Ye(e);return s=>t+r*Math.max(0,s)}function jn(n){let e=Ye(n?.baseNs??1e8),t=n?.factor!==void 0&&n.factor<1?1:n?.factor??2,r=Ye(n?.maxDelayNs??30*1e9),s=n?.jitter??"none";return o=>{let a;if(e===0)a=0;else if(t===1)a=e;else{let i=r/e,u=1;for(let d=0;d<Math.max(0,o);d++){if(u>=i){u=i;break}u*=t}a=e*u,a>r&&(a=r)}return _s(a,s)}}function Wn(n=100*1e6,e=30*1e9){let t=Ye(n),r=Ye(e);function s(o){if(o<=0)return 1;let a=1,i=2;for(let u=1;u<o;u++){let d=a+i;a=i,i=d}return i}return o=>{let a=s(o)*t;return a<=r?a:r}}function Un(n=100*1e6,e=30*1e9){return(t,r,s)=>{let a=Math.min(e,(s??n)*3);return Ss(n,a)}}function Ur(n,e){return(t,r,s)=>t>=e?null:n(t,r,s)}function pt(n){if(n==="constant")return Kn(1*1e9);if(n==="linear")return $n(1*1e9);if(n==="exponential")return jn();if(n==="fibonacci")return Wn();if(n==="decorrelatedJitter")return Un();throw new Error(`Unknown backoff preset: "${String(n)}". Use one of: constant, linear, exponential, fibonacci, decorrelatedJitter`)}var me,Oe,Pt=q(()=>{"use strict";me=1e6,Oe=1e9});function Jn(n,e){if(e!=null&&e.length>0)return new Set(e);switch(n){case"standard":return new Set(["type","status","value","deps","meta","v"]);case"full":return null;case"spec":return new Set(["type","deps","meta","value"]);default:return new Set(["type","deps"])}}function Es(n){return n._describeKind!=null?n._describeKind:n._deps.length>0?"derived":n._fn!=null?"producer":"state"}function Jr(n){let e=new WeakSet,t={};for(let[r,s]of Yr(n))t[r]=qn(s,e);return t}function qn(n,e){if(n==null)return n;let t=typeof n;if(t==="boolean"||t==="number"||t==="string")return n;if(t==="function")return"<function>";if(Array.isArray(n))return e.has(n)?"<cycle>":(e.add(n),n.map(r=>qn(r,e)));if(t==="object"){let r=n;if(e.has(r))return"<cycle>";e.add(r);try{if(typeof r.subscribe=="function"&&"cache"in r)return"<Node>"}catch{return"<unserializable>"}let s={};for(let[o,a]of Yr(r))s[o]=qn(a,e);return s}return"<unserializable>"}function Yr(n){let e=[],t;try{t=Object.keys(n)}catch{return e}for(let r of t)try{e.push([r,n[r]])}catch{e.push([r,"<unserializable>"])}return e}function J(n,e){let t={factory:n};return e!==void 0&&(t.factoryArgs=e),t}function Rs(n){let e={};for(let[t,r]of Object.entries(n.meta))try{e[t]=r.cache}catch{}return e}function Yn(n,e,t){let r=e==null,s=!r&&e!=null?[...e].filter(c=>c.startsWith("meta.")).map(c=>c.slice(5)):null,o=r||e.has("meta")||s!=null&&s.length>0,a="state",i=[];n instanceof se&&(a=Es(n),i=n._deps.map(c=>c.node.name??""));let u={type:a,deps:i};(r||e.has("status"))&&(u.status=n.status);let d=n instanceof se?n._guard:void 0;if(o){let c={...Rs(n)};if(d!=null&&c.access===void 0&&(c.access=In(d)),s!=null&&s.length>0&&!e.has("meta")){let f={};for(let l of s)l in c&&(f[l]=c[l]);u.meta=f}else u.meta=c}if(n.name!=null&&(u.name=n.name),(r||e.has("value"))&&(!t||a==="state")){n.status==="sentinel"&&(u.sentinel=!0);try{u.value=n.cache}catch{}}if((r||e.has("v"))&&n.v!=null){let c={id:n.v.id,version:n.v.version};"cid"in n.v&&(c.cid=n.v.cid,c.prev=n.v.prev),u.v=c}return(r||e.has("guard"))&&d!=null&&(u.guard=In(d)),(r||e.has("lastMutation"))&&n.lastMutation!=null&&(u.lastMutation=n.lastMutation),u}var mt=q(()=>{"use strict";Dt();ye()});function Lt(n,e,t){let r=new Set;for(let s of n.split(",")){let[o,a]=s.split("/"),i=a?Number.parseInt(a,10):1;if(Number.isNaN(i)||i<1)throw new Error(`Invalid cron step: ${s}`);let u,d;if(o==="*")u=e,d=t;else if(o.includes("-")){let[c,f]=o.split("-");u=Number.parseInt(c,10),d=Number.parseInt(f,10)}else u=Number.parseInt(o,10),d=u;if(Number.isNaN(u)||Number.isNaN(d))throw new Error(`Invalid cron field: ${n}`);if(u<e||d>t)throw new Error(`Cron field out of range: ${n} (${e}-${t})`);if(u>d)throw new Error(`Invalid cron range: ${u}-${d} in ${n}`);for(let c=u;c<=d;c+=i)r.add(c)}return r}function Qn(n){let e=n.trim().split(/\s+/);if(e.length!==5)throw new Error(`Invalid cron: expected 5 fields, got ${e.length}`);return{minutes:Lt(e[0],0,59),hours:Lt(e[1],0,23),daysOfMonth:Lt(e[2],1,31),months:Lt(e[3],1,12),daysOfWeek:Lt(e[4],0,6)}}function Xn(n,e){return n.minutes.has(e.getMinutes())&&n.hours.has(e.getHours())&&n.daysOfMonth.has(e.getDate())&&n.months.has(e.getMonth()+1)&&n.daysOfWeek.has(e.getDay())}var Zn=q(()=>{"use strict"});function ve(n,e,t){return{[n]:!0,[`${n}_type`]:e,...t??{}}}var en=q(()=>{"use strict"});function Qe(n,e,t){if(e.length===0)throw new RangeError("budgetGate requires at least one constraint");let r=e.map(p=>p.node),s=[n,...r],o=new er,a=!1,i=!1,u=Symbol("budget-gate"),d=new Array(e.length);function c(){return e.every((p,h)=>p.check(d[h]))}function f(p){for(;o.size>0&&c();){let h=o.shift();p.emit(h)}o.size===0&&i&&(i=!1,p.down([[D]]))}return V([],(p,h)=>{for(let m=0;m<e.length;m++)d[m]=e[m].node.cache;let g=[];for(let m=0;m<s.length;m++){let b=s[m];g.push(b.subscribe(y=>{for(let v of y)l(v,m,h)}))}return()=>{for(let m of g)m()}},{...t,describeKind:"derived",meta:ve("resilience","budget_gate",t?.meta)});function l(p,h,g){let m=p[0];if(h===0){if(m===x)return c()&&o.size===0?g.emit(p[1]):(o.push(p[1]),a||(a=!0,g.up([[le,u]]))),!0;if(m===F)return g.down([[F]]),!0;if(m===D)return o.size===0?g.down([[D]]):i=!0,!0;if(m===N||m===_){for(;o.size>0;)g.emit(o.shift());return i=!1,a&&(a=!1,g.up([[pe,u]])),g.down([p]),!0}return!1}if(m===x&&(d[h-1]=p[1]),m===x||m===D){let b=c();return b&&o.size>0?(f(g),o.size===0&&a&&(a=!1,g.up([[pe,u]]))):!b&&!a&&o.size>0&&(a=!0,g.up([[le,u]])),!0}return m===F?!0:m===_?(g.down([p]),!0):m===N}}var er,Qr=q(()=>{"use strict";Z();ye();en();er=class{buf=[];head=0;get size(){return this.buf.length-this.head}push(e){this.buf.push(e)}shift(){if(this.head>=this.buf.length)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head++,this.head>32&&this.head*2>this.buf.length&&(this.buf=this.buf.slice(this.head),this.head=0),e}clear(){this.buf=[],this.head=0}}});function Xr(n){let e=new WeakSet,t=new WeakSet,r=[n],s=0;for(;r.length>0;){let o=r.pop();s+=As(o,e,t,r)}return s}function As(n,e,t,r){if(n==null)return 0;switch(typeof n){case"number":return ie.number;case"boolean":return ie.boolean;case"string":return ie.string+n.length*2;case"bigint":return ie.bigint+Cs(n);case"symbol":return ie.symbol;case"function":return e.has(n)?0:(e.add(n),ie.function);case"undefined":return 0}let o=n;if(e.has(o))return 0;e.add(o);let a=o[Ms];if(typeof a=="function")try{let d=a.call(o);if(typeof d=="number"&&Number.isFinite(d))return d}catch{}if(o instanceof Date)return ie.date;if(o instanceof RegExp)return ie.regexp+o.source.length*2;if(o instanceof Error){let d=o.message?o.message.length*2:0,c=o.stack?o.stack.length*2:0;return ie.error+d+c}if(typeof URL<"u"&&o instanceof URL)return ie.url+o.href.length*2;if(typeof Promise<"u"&&o instanceof Promise)return ie.promise;if(o instanceof WeakMap)return ie.weakmap;if(o instanceof WeakSet)return ie.weakset;if(o instanceof Map){let d=ie.map;for(let[c,f]of o)d+=ie.mapEntry,r.push(c),r.push(f);return d}if(o instanceof Set){let d=ie.set;for(let c of o)d+=ie.setEntry,r.push(c);return d}if(Array.isArray(o)){let d=ie.array+o.length*8;for(let c of o)r.push(c);return d}if(o instanceof ArrayBuffer)return t.has(o)?0:(t.add(o),o.byteLength);if(ArrayBuffer.isView(o)){let d=o;return t.has(d.buffer)?48:(t.add(d.buffer),d.buffer.byteLength+48)}let i=ie.object,u=Object.keys(o);for(let d of u){i+=ie.string+d.length*2;try{r.push(o[d])}catch{}}return i}function Cs(n){let e=n<0n?-n:n;if(e===0n)return 0;let t=e.toString(2).length;return Math.ceil(t/32)*8}var ie,Ms,Zr=q(()=>{"use strict";ie={object:56,array:64,string:40,number:8,boolean:4,null:0,undefined:0,symbol:40,bigint:16,function:120,map:72,set:72,mapEntry:40,setEntry:24,date:24,regexp:48,error:64,url:80,promise:48,weakmap:40,weakset:40},Ms=Symbol.for("sizeof")});function eo(n,e,t,r={}){let s=e in n.nodes,o=t in n.nodes;if(!s)return tn(e,t,"no-such-from");if(!o)return tn(e,t,"no-such-to");let a=r.maxDepth;if(a!=null&&(!Number.isInteger(a)||a<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(e===t){if(r.findCycle===!0){let d=Ds(n,e,r);if(d!=null)return d}let u=nn(e,n.nodes[e],0,r);return rn(e,t,[u])}if(a===0)return tn(e,t,"no-path");let i=to(n,e,t,a);return i.found?rn(e,t,no(n,i.pathOrder,r)):tn(e,t,i.truncated?"max-depth-exceeded":"no-path")}function to(n,e,t,r){let s=new Map,o=[{path:t,depth:0}],a=new Set([t]),i=0,u=!1;for(;i<o.length;){let f=o[i++];if(f.path===e)break;if(r!=null&&f.depth>=r){let g=n.nodes[f.path];g?.deps&&g.deps.length>0&&(u=!0);continue}let l=n.nodes[f.path];if(l==null)continue;let p=l.deps??[],h=new Map;for(let g=0;g<p.length;g++){let m=p[g];if(!m)continue;let b=h.get(m);b==null&&(b=[],h.set(m,b)),b.push(g)}for(let[g,m]of h)a.has(g)||(a.add(g),s.set(g,{from:f.path,depIndices:m}),o.push({path:g,depth:f.depth+1}))}if(!s.has(e))return{found:!1,pathOrder:[],truncated:u};let d=[{path:e}],c=e;for(;c!==t;){let f=s.get(c);if(f==null)return{found:!1,pathOrder:[],truncated:!1};d[d.length-1].depIndices=f.depIndices,d.push({path:f.from}),c=f.from}return{found:!0,pathOrder:d,truncated:!1}}function Ds(n,e,t){let r=n.nodes[e];if(r==null)return null;let s=r.deps??[],o=[];for(let i=0;i<s.length;i++)s[i]===e&&o.push(i);if(o.length>0){let i=nn(e,r,0,t);i.dep_index=o[0];let u=nn(e,r,1,t);return rn(e,e,[i,u])}let a=null;for(let i=0;i<s.length;i++){let u=s[i];if(!u||u===e)continue;let d=to(n,u,e,t.maxDepth);d.found&&(a==null||d.pathOrder.length<a.pathOrder.length)&&(a=d,a={found:!0,pathOrder:[{path:e,depIndices:[i]},...d.pathOrder],truncated:!1})}return a==null?null:rn(e,e,no(n,a.pathOrder,t))}function no(n,e,t){return e.map((r,s)=>{let o=n.nodes[r.path],a=nn(r.path,o,s,t);return r.depIndices!=null&&r.depIndices.length>0&&(a.dep_index=r.depIndices[0],r.depIndices.length>1&&(a.dep_indices=[...r.depIndices])),a})}function nn(n,e,t,r){let s={path:n,type:e.type,hop:t};e.status!==void 0&&(s.status=e.status),"value"in e&&(s.value=e.value),e.v!=null&&(s.v=e.v);let o=r.annotations?.get(n)??e.annotation;o!=null&&(s.annotation=o);let a=r.lastMutations?.get(n)??e.lastMutation;return a!=null&&(s.lastMutation=a),s}function rn(n,e,t){return ro(n,e,!0,"ok",t)}function tn(n,e,t){return ro(n,e,!1,t,[])}function ro(n,e,t,r,s){let o=Ps(n,e,t,r,s);return{from:n,to:e,found:t,reason:r,steps:s,text:o,toJSON(){return{from:n,to:e,found:t,reason:r,steps:s}}}}function Ps(n,e,t,r,s){if(!t)switch(r){case"no-such-from":return`explainPath: no node named "${n}"`;case"no-such-to":return`explainPath: no node named "${e}"`;case"max-depth-exceeded":return`explainPath: no path from "${n}" to "${e}" within maxDepth`;default:return`explainPath: no path from "${n}" to "${e}"`}let o=[`Causal path: ${n} \u2192 ${e} (${s.length} step(s))`];for(let a of s){let u=` ${a.hop===0?"\xB7":"\u2193"} ${a.path} (${a.type}${a.status?`/${a.status}`:""})`;if(o.push(u),"value"in a&&o.push(` value: ${Ls(a.value)}`),a.annotation!=null&&o.push(` annotation: ${a.annotation}`),a.lastMutation!=null){let d=a.lastMutation.actor;o.push(` actor: ${d.type}${d.id?`:${d.id}`:""}`)}}return o.join(`
2
+ `)}function Ls(n){if(n===void 0)return"<sentinel>";if(n===null)return"null";if(typeof n=="string")return JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean"||typeof n=="bigint")return String(n);try{let e=JSON.stringify(n);return e.length>80?`${e.slice(0,77)}...`:e}catch{return String(n)}}var oo=q(()=>{"use strict"});function tr(n,e){if(Object.is(n,e))return!0;if(n==null||e==null||typeof n!="object"||typeof e!="object")return!1;if(Array.isArray(n)){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let o=0;o<n.length;o++)if(!tr(n[o],e[o]))return!1;return!0}if(Array.isArray(e))return!1;let t=Object.keys(n),r=Object.keys(e);if(t.length!==r.length)return!1;let s=new Set(r);for(let o of t)if(!s.has(o)||!tr(n[o],e[o]))return!1;return!0}function so(n,e){return`${n}\0${e}`}function It(n,e){let t=[],r=new Set(n.subgraphs),s=new Set(e.subgraphs),o=[];for(let m of s)r.has(m)||o.push(m);o.sort();for(let m of o)t.push({type:"subgraph-mounted",path:m});let a=new Set(Object.keys(n.nodes)),i=new Set(Object.keys(e.nodes)),u=[];for(let m of i)a.has(m)||u.push(m);u.sort();for(let m of u)t.push({type:"node-added",path:m,node:{...e.nodes[m]}});let d=[];for(let m of i){if(!a.has(m))continue;let b=n.nodes[m]?.meta,y=e.nodes[m]?.meta;b==null&&y==null||tr(b??{},y??{})||d.push(m)}d.sort();for(let m of d)t.push({type:"node-meta-changed",path:m,prevMeta:n.nodes[m]?.meta??{},nextMeta:e.nodes[m]?.meta??{}});let c=new Map;for(let m of n.edges)c.set(so(m.from,m.to),m);let f=new Map;for(let m of e.edges)f.set(so(m.from,m.to),m);let l=[];for(let[m,b]of f)c.has(m)||l.push(b);l.sort((m,b)=>m.from<b.from?-1:m.from>b.from?1:m.to<b.to?-1:m.to>b.to?1:0);for(let m of l)t.push({type:"edge-added",from:m.from,to:m.to});let p=[];for(let[m,b]of c)f.has(m)||p.push(b);p.sort((m,b)=>m.from<b.from?-1:m.from>b.from?1:m.to<b.to?-1:m.to>b.to?1:0);for(let m of p)t.push({type:"edge-removed",from:m.from,to:m.to});let h=[];for(let m of a)i.has(m)||h.push(m);h.sort();for(let m of h)t.push({type:"node-removed",path:m});let g=[];for(let m of r)s.has(m)||g.push(m);g.sort();for(let m of g)t.push({type:"subgraph-unmounted",path:m});return{events:t,flushedAt_ns:re()}}var nr=q(()=>{"use strict";Le()});var Ie,on=q(()=>{"use strict";Ie=class{_timer;_gen=0;start(e,t){this.cancel(),this._gen+=1;let r=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,r===this._gen&&t()},e)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});var Ge,sn=q(()=>{"use strict";Ge=class{constructor(e){this.capacity=e;if(!Number.isInteger(e)||e<=0)throw new Error(`RingBuffer capacity must be a positive integer (got ${e})`);this.buf=new Array(e)}buf;head=0;_size=0;get size(){return this._size}get maxSize(){return this.capacity}push(e){let t=(this.head+this._size)%this.capacity;this.buf[t]=e,this._size<this.capacity?this._size++:this.head=(this.head+1)%this.capacity}shift(){if(this._size===0)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head=(this.head+1)%this.capacity,this._size--,e}at(e){if(this._size===0)return;let t=e<0?this._size+e:e;if(!(t<0||t>=this._size))return this.buf[(this.head+t)%this.capacity]}toArray(){let e=new Array(this._size);for(let t=0;t<this._size;t++)e[t]=this.buf[(this.head+t)%this.capacity];return e}clear(){for(let e=0;e<this._size;e++)this.buf[(this.head+e)%this.capacity]=void 0;this.head=0,this._size=0}}});function io(n,e){let t=e?.topN??10,r=n.describe({detail:"standard"}),s=[],o=n._collectObserveTargets;typeof o=="function"&&o.call(n,"",s);let a=new Map;for(let[l,p]of s)a.set(l,p);let i=[];for(let[l,p]of Object.entries(r.nodes)){let h=a.get(l),g=h instanceof se?h:null,m=g?Xr(g.cache):0,b=g?g._sinkCount:0,y=p.deps?.length??0,v=p.type==="effect"&&b===0,T=b===0?p.type==="effect"?"orphan-effect":p.type==="derived"?"idle-derived":p.type==="producer"?"idle-producer":null:null;i.push({path:l,type:p.type,status:p.status??"unknown",valueSizeBytes:m,subscriberCount:b,depCount:y,isOrphanEffect:v,orphanKind:T})}let u=i.reduce((l,p)=>l+p.valueSizeBytes,0),d=(l,p)=>[...i].sort(p??((h,g)=>g[l]-h[l])).slice(0,t),c=i.filter(l=>l.orphanKind!=null),f=i.filter(l=>l.isOrphanEffect);return{nodeCount:i.length,edgeCount:r.edges.length,subgraphCount:r.subgraphs.length,nodes:i,totalValueSizeBytes:u,hotspots:{byValueSize:d("valueSizeBytes"),bySubscriberCount:d("subscriberCount"),byDepCount:d("depCount")},orphans:c,orphanEffects:f}}var ao=q(()=>{"use strict";ye();Zr()});function an(n,e){let t=Math.max(16,n.size*4),r=0;for(;n.size>0;){if(r++>=t){console.error(`[Graph "${e}".destroy] disposer drain exceeded cap (${t}); ${n.size} disposer(s) discarded`),n.clear();return}let s=n.values().next();if(s.done)return;let o=s.value;n.delete(o);try{o()}catch(a){console.error(`[Graph "${e}".destroy] disposer threw:`,a)}}}function po(n){return n!=null&&typeof n=="object"&&"cache"in n&&typeof n.subscribe=="function"&&typeof n.down=="function"}function Is(n){if(n!=null)return po(n)?n.cache:n}function Ze(n){return n!=null&&typeof n=="object"&&"cache"in n&&typeof n.subscribe=="function"&&typeof n.down=="function"}function je(n){return Ze(n)?n.cache??"":n}function uo(n){return Ze(n)?n.cache??0:n}function co(n){return Ze(n)?n.cache??!1:n}function Bs(n){let e=[];for(let t of Object.keys(n).sort()){let r=n[t].v;r!=null&&e.push(`${t} ${r.id} ${r.version}`)}return e.join(`
3
+ `)}function lo(n){if(n.version!==Xe)throw new Error(`unsupported snapshot version ${String(n.version)} (expected ${Xe})`);for(let e of["name","nodes","edges","subgraphs"])if(!(e in n))throw new Error(`snapshot missing required key "${e}"`);if(typeof n.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof n.nodes!="object"||n.nodes===null||Array.isArray(n.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(n.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(n.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function Vs(n,e){let t=new WeakMap,r=(s,o)=>{if(Object.is(s,o))return!0;if(s==null||o==null||typeof s!="object"||typeof o!="object")return!1;let a=t.get(s);if(a==null&&(a=new WeakSet,t.set(s,a)),a.has(o))return!0;a.add(o);let i=s.constructor,u=o.constructor;if(i!==u)return!1;if(s instanceof Date)return s.getTime()===o.getTime();if(s instanceof RegExp)return s.source===o.source&&s.flags===o.flags;if(Array.isArray(s)){let l=o;if(s.length!==l.length)return!1;for(let p=0;p<s.length;p++)if(!r(s[p],l[p]))return!1;return!0}if(s instanceof Map){let l=o;if(s.size!==l.size)return!1;for(let[p,h]of s)if(!l.has(p)||!r(h,l.get(p)))return!1;return!0}if(s instanceof Set){let l=o;if(s.size!==l.size)return!1;for(let p of s){let h=!1;for(let g of l)if(r(p,g)){h=!0;break}if(!h)return!1}return!0}if(ArrayBuffer.isView(s)){let l=s,p=o;if(l.length!==p.length)return!1;for(let h=0;h<l.length;h++)if(l[h]!==p[h])return!1;return!0}let d=Object.keys(s),c=Object.keys(o);if(d.length!==c.length)return!1;let f=new Set(c);for(let l of d)if(!f.has(l)||!r(s[l],o[l]))return!1;return!0};return r(n,e)}function Fs(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function un(n){let e="^";for(let t=0;t<n.length;t+=1){let r=n[t];if(r==="*"){e+=".*";continue}if(r==="?"){e+=".";continue}if(r==="["){let s=n.indexOf("]",t+1);if(s<=t+1){e+="\\[";continue}let o=n.slice(t+1,s);o.startsWith("!")&&(o=`^${o.slice(1)}`),o=o.replace(/\\/g,"\\\\"),e+=`[${o}]`,t=s;continue}e+=Fs(r)}return e+="$",new RegExp(e)}function rr(n){if(typeof n=="string")return JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean"||n==null)return String(n);try{return JSON.stringify(n)}catch{return"[unserializable]"}}function Ks(n){return n==="none"?zs:n==="ansi"||n==null?Gs:{data:n.data??"",dirty:n.dirty??"",resolved:n.resolved??"",invalidate:n.invalidate??"",pause:n.pause??"",resume:n.resume??"",complete:n.complete??"",error:n.error??"",teardown:n.teardown??"",derived:n.derived??"",path:n.path??"",reset:n.reset??""}}function fo(n){if(n==null)return{};let e=n.detail;return e==="full"?{...n,structured:n.structured??!0,timeline:n.timeline??!0,causal:n.causal??!0,derived:n.derived??!0}:e==="minimal"?{...n,structured:n.structured??!0}:n.format==="stage-log"?{...n,structured:n.structured??!0,timeline:n.timeline??!0}:n}function $s(n,e,t){for(let r=0;r<n.length;r++){let s=n.charCodeAt(r);if(s<32||s===127)throw new Error(`Graph "${e}": ${t} "${n}" must not contain control character (U+${s.toString(16).padStart(4,"0").toUpperCase()} at index ${r})`)}}function or(n,e,t){if(n==="")throw new Error(`Graph "${e}": ${t} name must be non-empty`);if(n.includes(te))throw new Error(`Graph "${e}": ${t} "${n}" must not contain '${te}' (path separator)`);if(n===Ae)throw new Error(`Graph "${e}": ${t} name "${Ae}" is reserved for meta companion paths`);$s(n,e,t)}function js(n,e){if(n==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let t=n.split(te);for(let r of t)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return t}function Ws(n,e){let t=!1;for(let s of n)if(!e.isMetaPassthrough(s[0])){t=!0;break}return t?n.filter(s=>e.isMetaPassthrough(s[0])):n}function ho(n){for(let e of n._mounts.values())ho(e);for(let e of n._nodes.values())try{e.down([[K]],{internal:!0})}catch{}}function mo(n,e){let t=Be.diff(n,e),r={};for(let s of t.nodesAdded){let o=e.nodes[s];o!=null&&(r[s]=o)}return{...t,nodesAddedFull:r}}function sr(n,e,t,r={}){let s={paths:[],depths:new Map,truncated:!1};if(!e)return r.withDetail?s:[];if(!r.both&&t!=="upstream"&&t!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let o=r.maxDepth;if(o!=null&&(!Number.isInteger(o)||o<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(o===0)return r.withDetail?s:[];let a=new Map,i=new Map,u=new Map,d=new Map,c=new Set;for(let[v,T]of Object.entries(n.nodes)){if(!v)continue;c.add(v);let w=T.deps??[];a.set(v,w);for(let O of w)O&&(c.add(O),i.has(O)||i.set(O,new Set),i.get(O).add(v))}for(let v of n.edges){if(v==null||typeof v!="object")continue;let T=typeof v.from=="string"?v.from:"",w=typeof v.to=="string"?v.to:"";!T||!w||(c.add(T),c.add(w),d.has(T)||d.set(T,new Set),d.get(T).add(w),u.has(w)||u.set(w,new Set),u.get(w).add(T))}if(!c.has(e))return r.withDetail?s:[];let f=r.both===!0,l=v=>{if(f){let k=a.get(v)??[],S=u.get(v),E=i.get(v),R=d.get(v),M=[...k];return S&&M.push(...S),E&&M.push(...E),R&&M.push(...R),M}if(t==="upstream"){let k=a.get(v)??[],S=u.get(v);return S?[...k,...S]:k}let T=i.get(v),w=d.get(v),O=T?[...T]:[];return w&&O.push(...w),O},p=new Set([e]),h=new Map,g=[{path:e,depth:0}],m=0,b=!1;for(;m<g.length;){let v=g[m++];if(o!=null&&v.depth>=o){l(v.path).length>0&&(b=!0);continue}for(let T of l(v.path))!T||p.has(T)||(p.add(T),h.set(T,v.depth+1),g.push({path:T,depth:v.depth+1}))}let y=[...h.keys()].sort((v,T)=>v<T?-1:v>T?1:0);return r.withDetail?{paths:y,depths:h,truncated:b}:y}function Us(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++){let r=n[t],s=e[t];if(r.path!==s.path||r.type!==s.type||r.status!==s.status||r.hop!==s.hop||r.dep_index!==s.dep_index||r.annotation!==s.annotation||r.value!==s.value||r.lastMutation!==s.lastMutation)return!1;let o=r.v,a=s.v;if(o!==a&&(o==null||a==null||o.id!==a.id||o.version!==a.version))return!1}return!0}var te,Ae,Xe,Gs,zs,Be,dn=q(()=>{"use strict";Ln();Te();Le();Dt();Z();mt();ye();fe();nr();Ve();on();sn();Pn();oo();ao();te="::",Ae="__meta__",Xe=1;Gs={data:"\x1B[32m",dirty:"\x1B[33m",resolved:"\x1B[36m",invalidate:"\x1B[93m",pause:"\x1B[90m",resume:"\x1B[96m",complete:"\x1B[34m",error:"\x1B[31m",teardown:"\x1B[91m",derived:"\x1B[35m",path:"\x1B[90m",reset:"\x1B[0m"},zs={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};Be=class n{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_destroyed=!1;_topology;_topologyEmitters=new Set;_factory;_factoryArgs;constructor(e,t){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(te))throw new Error(`Graph name must not contain '${te}' (got "${e}")`);if(e===Ae)throw new Error(`Graph name "${Ae}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...t??{}}),this.config=t?.config??be,this._traceRing=new Ge(t?.traceCapacity??1e3),t?.versioning!=null&&this.setVersioning(t.versioning),typeof t?.factory=="string"&&(this._factory=t.factory,t.factoryArgs!==void 0&&(this._factoryArgs=t.factoryArgs))}tagFactory(e,t){return this._factory=e,this._factoryArgs=t,this}ancestors(e=!0){let t=[],r=e?this:this._parent;for(;r!=null;)t.push(r),r=r._parent;return t}get topology(){return this._topology==null&&(this._topology=C(e=>{let t=r=>{e.emit(r)};return this._topologyEmitters.add(t),()=>{this._topologyEmitters.delete(t)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let t of this._topologyEmitters)t(e)}nameOf(e){return this._nodeToName.get(e)}add(e,t){let r=e.name,s=t?.name??r;if(s==null||s==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let o=s,a=t?.annotation;if(or(o,this.name,"add"),this._mounts.has(o))throw new Error(`Graph "${this.name}": name "${o}" is already a mount point`);if(this._nodes.has(o))throw new Error(`Graph "${this.name}": node "${o}" already exists`);let i=this._nodeToName.get(e);if(i!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${i}"`);return this._nodes.set(o,e),this._nodeToName.set(e,o),this._emitTopology({kind:"added",name:o,nodeKind:"node"}),a!=null&&(this._annotations.set(o,a),this.config.inspectorEnabled&&this._traceRing.push({path:o,annotation:a,timestamp_ns:re()})),e}setVersioning(e){if(e!=null)for(let t of this._nodes.values())t instanceof se&&t._applyVersioning(e)}remove(e){or(e,this.name,"remove");let t=this._mounts.get(e);if(t){let o={kind:"mount",nodes:[],mounts:[]},a=[];t._collectObserveTargets("",a);for(let[i,u]of a)i.includes(`${te}${Ae}${te}`)||o.nodes.push(i);return o.nodes.sort(),o.mounts.push(e),o.mounts.push(...t._collectSubgraphs(`${e}${te}`)),this._mounts.delete(e),t._parent=void 0,ho(t),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:o}),o}let r=this._nodes.get(e);if(!r)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(r),r.down([[K]],{internal:!0});let s={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:s}),s}removeAll(e){let t=typeof e=="function"?e:(()=>{let o=un(e);return a=>o.test(a)})(),r={kind:"mount",nodes:[],mounts:[]},s=[...this._nodes.keys(),...this._mounts.keys()].filter(o=>t(o));for(let o of s){let a=this.remove(o);r.nodes.push(...a.nodes),r.mounts.push(...a.mounts)}return r.nodes.sort(),r.mounts.sort(),r}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),t=this._nodes,r=0;return{[Symbol.iterator](){return this},next(){if(r>=e.length)return{value:void 0,done:!0};let s=e[r++];return{value:[s,t.get(s)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(te))return this.resolve(e);let t=this._nodes.get(e);if(!t)throw new Error(`Graph "${this.name}": unknown node "${e}"`);return t}get(e){return this.node(e).cache}set(e,t,r){let s=r?.internal===!0;this.node(e).down([[x,t]],{actor:r?.actor,internal:s,delivery:"write"})}setAll(e,t){let r=Symbol.iterator in e?e:Object.entries(e);$(()=>{for(let[s,o]of r)this.set(s,o,t)})}invalidate(e,t){let r=t?.internal===!0;this.node(e).down([[Ne]],{actor:t?.actor,internal:r,delivery:"write"})}error(e,t,r){let s=r?.internal===!0;this.node(e).down([[_,t]],{actor:r?.actor,internal:s,delivery:"write"})}complete(e,t){let r=t?.internal===!0;this.node(e).down([[N]],{actor:t?.actor,internal:r,delivery:"write"})}_registerSelfPruningKeepalive(e){let t,r,s=()=>{t?.(),t=void 0,r?.(),r=void 0};t=e.subscribe(o=>{for(let a of o){let i=a[0];if(i===K||i===N||i===_){s();return}}}),r=this.addDisposer(s)}_wireSignalToRemove(e,t){if(t==null)return;let r=()=>{try{this.remove(e)}catch{}};if(t.aborted){r();return}t.addEventListener("abort",r,{once:!0}),this.addDisposer(()=>t.removeEventListener("abort",r))}derived(e,t,r,s){let o=t.map(p=>this.resolve(p)),{keepAlive:a,annotation:i,equals:u,initial:d,meta:c,signal:f}=s??{},l=he(o,r,{name:e,...u!=null?{equals:u}:{},...d!==void 0?{initial:d}:{},...c!=null?{meta:c}:{}});return this.add(l,{name:e,...i!=null?{annotation:i}:{}}),a===!0&&this._registerSelfPruningKeepalive(l),this._wireSignalToRemove(e,f),l}effect(e,t,r,s){let o=t.map(c=>this.resolve(c)),{annotation:a,meta:i,signal:u}=s??{},d=ft(o,r,{name:e,...i!=null?{meta:i}:{}});return this.add(d,{name:e,...a!=null?{annotation:a}:{}}),this._wireSignalToRemove(e,u),d}produce(e,t,r){if(t===void 0)throw new Error(`Graph "${this.name}".produce("${e}", \u2026): source must not be \`undefined\` \u2014 undefined is the global SENTINEL (spec \xA71.1). Pass \`null\` for nullary DATA, or a Promise/AsyncIterable/Iterable for async sources.`);if(t!==null&&typeof t=="object"&&"cache"in t&&typeof t.subscribe=="function")throw new Error(`Graph "${this.name}".produce("${e}", \u2026): Node sources are rejected. For Node\u2192Node, use graph.derived(name, [path], ([v]) => v, { keepAlive: true }) \u2014 fromAny passes Nodes through verbatim and silently drops opts.`);let{annotation:s,meta:o,equals:a,signal:i}=r??{},u=oe(t,{name:e,...o!=null?{meta:o}:{},...a!=null?{equals:a}:{},...i!=null?{signal:i}:{}});return this.add(u,{name:e,...s!=null?{annotation:s}:{}}),this._wireSignalToRemove(e,i),u}batch(e){$(e)}edges(e){let t=e?.recursive===!0,r=new Map;if(!t){for(let[u,d]of this._nodes)r.set(d,u);let i=[];for(let[u,d]of this._nodes)if(d instanceof se)for(let c of d._deps){let f=r.get(c.node);f!=null&&i.push([f,u])}return i.sort((u,d)=>u[0]<d[0]?-1:u[0]>d[0]?1:u[1]<d[1]?-1:u[1]>d[1]?1:0),i}let s=[];this._collectObserveTargets("",s);let o=new Map;for(let[i,u]of s)o.set(u,i);let a=[];for(let[i,u]of s)if(u instanceof se)for(let d of u._deps){let c=o.get(d.node);c!=null&&a.push([c,i])}return a.sort((i,u)=>i[0]<u[0]?-1:i[0]>u[0]?1:i[1]<u[1]?-1:i[1]>u[1]?1:0),a}mount(e,t){if(t===void 0){let s=new n(e);return this.mount(e,s)}if(typeof t=="function"){let s=new n(e);return t(s),this.mount(e,s)}let r=t;if(or(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(r===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(r._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${r._parent.name}"`);for(let s=this;s!=null;s=s._parent)if(s===r)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,r),r._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),r}resolve(e){let t=js(e,this.name);return this._resolveFromSegments(t)}tryResolve(e){try{return this.resolve(e)}catch{return}}_resolveFromSegments(e){let t=e;if(t[0]===this.name&&(t=t.slice(1),t.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let r=t[0],s=t.slice(1);if(s.length===0){let i=this._nodes.get(r);if(i)return i;throw this._mounts.has(r)?new Error(`Graph "${this.name}": path ends at subgraph "${r}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${r}"`)}let o=this._nodes.get(r);if(o&&s.length>0&&s[0]===Ae)return this._resolveMetaChainFromNode(o,s,t.join(te));let a=this._mounts.get(r);if(!a)throw this._nodes.has(r)?new Error(`Graph "${this.name}": "${r}" is a node; trailing path "${s.join(te)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return a.resolve(s.join(te))}_resolveMetaChainFromNode(e,t,r){let s=e,o=0,a=[...t];for(;o<a.length;){if(a[o]!==Ae)throw new Error(`Graph "${this.name}": expected ${Ae} segment in meta path "${r}"`);if(o+1>=a.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${Ae} in "${r}"`);let i=a[o+1],u=s.meta[i];if(!u)throw new Error(`Graph "${this.name}": unknown meta "${i}" in path "${r}"`);s=u,o+=2}return s}signal(e,t){if(t?.internal!==!0){for(let s of e)if(this.config.messageTier(s[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let r=[];if(this._signalDeliver(e,t??{},new Set,r),r.length>0)throw r[0]}_signalDeliver(e,t,r,s){for(let u of this._mounts.values())u._signalDeliver(e,t,r,s);let a=t.internal===!0?{internal:!0}:{actor:t.actor,delivery:"signal"},i=Ws(e,this.config);for(let u of[...this._nodes.keys()].sort()){let d=this._nodes.get(u);if(!r.has(d)){r.add(d);try{d.down(e,a)}catch(c){if(c instanceof Me)throw c;s.push(c)}i.length!==0&&this._signalMetaSubtree(d,i,r,a,s)}}}_signalMetaSubtree(e,t,r,s,o){for(let a of Object.keys(e.meta).sort()){let i=e.meta[a];if(!r.has(i)){r.add(i);try{i.down(t,s)}catch(u){if(u instanceof Me)throw u;o.push(u)}this._signalMetaSubtree(i,t,r,s,o)}}}describe(e){if(e?.reactive==="diff")return this._describeReactiveDiff(e);if(e?.reactive===!0)return this._describeReactive(e);let t=Is(e?.actor),r=e?.filter;if(e?.detail!=null&&e?.fields!=null)throw new TypeError("Graph.describe(): pass either `detail` or `fields`, not both. `detail: 'spec'` is the canonical spec projection; use `fields` only when you need a custom subset.");let s=Jn(e?.detail,e?.fields),o=e?.detail==="spec",a=s,i=[];this._collectObserveTargets("",i);let u=new Map;for(let[T,w]of i)u.set(w,T);let d=[];{let T=i.map(([,k])=>k),w=new Set(u.values()),O=0;for(;T.length>0;){let k=T.shift();if(k instanceof se)for(let S of k._deps){let E=S.node;if(u.has(E))continue;let R=E.name??"",M=R;if(!M||w.has(M))if(R){let L=2;for(;w.has(`${R}#${L}`);)L++;M=`${R}#${L}`}else for(M=`__internal__/${O++}`;w.has(M);)M=`__internal__/${O++}`;u.set(E,M),w.add(M),d.push([M,E]),T.push(E)}}}let c=[...i,...d],f={};for(let[T,w]of c){if(t!=null&&!w.allowsObserve(t))continue;let O=Yn(w,a,o),k=w instanceof se?w._deps.map(M=>u.get(M.node)??M.node.name??""):[],{name:S,...E}=O,R={...E,deps:k};if(!o){let M=this._annotations.get(T);M!=null&&(R.annotation=M)}if(r!=null)if(typeof r=="function"){let M=r;if(!(M.length>=2?M(T,R):M(R)))continue}else{let M=!0;for(let[L,A]of Object.entries(r)){let P=L==="deps_includes"?"depsIncludes":L==="meta_has"?"metaHas":L;if(P==="depsIncludes"){if(!R.deps.includes(String(A))){M=!1;break}continue}if(P==="metaHas"){if(!Object.hasOwn(R.meta??{},String(A))){M=!1;break}continue}if(R[P]!==A){M=!1;break}}if(!M)continue}f[T]=R}let l=new Set(Object.keys(f)),p=[];for(let[T,w]of c)if(w instanceof se)for(let O of w._deps){let k=u.get(O.node);k!=null&&p.push([k,T])}p.sort((T,w)=>T[0]<w[0]?-1:T[0]>w[0]?1:T[1]<w[1]?-1:T[1]>w[1]?1:0);let h=p.map(([T,w])=>({from:T,to:w}));(t!=null||r!=null)&&(h=h.filter(T=>l.has(T.from)&&l.has(T.to)));let g=this._collectSubgraphs(""),m=t!=null||r!=null?g.filter(T=>{let w=`${T}${te}`;return[...l].some(O=>O===T||O.startsWith(w))}):g,b=this,y=e;return{name:this.name,nodes:f,edges:h,subgraphs:m,...this._factory!==void 0?{factory:this._factory}:{},...this._factoryArgs!==void 0?{factoryArgs:this._factoryArgs}:{},expand(T){let w={...y};return Array.isArray(T)?(w.fields=T,w.detail=void 0):(w.detail=T,w.fields=void 0),b.describe(w)}}}_collectSubgraphs(e){let t=[];for(let r of[...this._mounts.keys()].sort()){let s=e===""?r:`${e}${r}`;t.push(s),t.push(...this._mounts.get(r)._collectSubgraphs(`${s}${te}`))}return t}resourceProfile(e){return io(this,e)}reachable(e,t,r={}){return r.withDetail===!0?sr(this.describe(),e,t,{...r,withDetail:!0}):sr(this.describe(),e,t,r)}explain(e,t,r){return r?.reactive===!0?this._explainReactive(e,t,r):this._explainStatic(je(e),je(t),{...r?.maxDepth!==void 0?{maxDepth:uo(r.maxDepth)}:{},...r?.findCycle!==void 0?{findCycle:co(r.findCycle)}:{}})}_explainStatic(e,t,r){let s=this.describe({detail:"full"}),o=new Map(this._annotations),a=new Map;for(let[i,u]of Object.entries(s.nodes))u.lastMutation!=null&&a.set(i,u.lastMutation);return eo(s,e,t,{...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{},annotations:o,lastMutations:a})}_describeReactive(e){let t={...e,reactive:!1},r=e.reactiveName??"describe",s=0,o=G(s,{name:`${r}_version`}),a=this.observe({timeline:!0,structured:!0}),i=!1,u=!1,d=()=>{i||u||(i=!0,dt(()=>{i=!1,!u&&(s+=1,o.emit(s))}))},c=a.onEvent(y=>{let v=y.type;v!=="data"&&v!=="error"&&v!=="complete"&&v!=="teardown"||d()}),f=[],l=new WeakSet,p=y=>{if(l.has(y)||u)return;l.add(y);let v=y.topology.subscribe(T=>{for(let w of T){if(w[0]!==x)continue;let O=w[1];if(d(),O.kind==="added"&&O.nodeKind==="mount"){let k=y._mounts.get(O.name);k!=null&&p(k)}}});f.push(v);for(let T of y._mounts.keys()){let w=y._mounts.get(T);w!=null&&p(w)}};p(this);let h,g=e.actor;po(g)&&(h=g.subscribe(y=>{let v=!1,T=!1;for(let w of y){let O=w[0];O===x?v=!0:(O===N||O===_||O===K)&&(T=!0)}v&&d(),T&&(h?.(),h=void 0,d())}));let m;try{m=he([o],()=>this.describe(t),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(y,v)=>y===v})}catch(y){c(),h?.();for(let v of f)v();throw a.dispose(),y}let b=et(m);return{node:m,dispose(){u=!0,c(),h?.();for(let y of f)y();f.length=0,a.dispose(),b()}}}_describeReactiveDiff(e){let t={...e,reactive:!1},r=e.reactiveName??"describe-diff",s={name:this.name,nodes:{},edges:[],subgraphs:[]},o=this.describe(t),a=It(s,o),i=G(a,{name:r,meta:{domain:"audit",kind:"describe-diff"},equals:(l,p)=>l===p}),u=this._describeReactive({...e,reactiveName:void 0}),d=!1,c=u.node.subscribe(l=>{if(!d)for(let p of l){if(p[0]!==x)continue;let h=p[1],g=It(o,h);o=h,g.events.length!==0&&i.emit(g)}}),f=et(i);return{node:i,dispose(){d=!0,c(),u.dispose(),i.down([[K,"describe-diff disposed"]]),f()}}}_explainReactive(e,t,r){let s=0,o=G(s,{name:"explain_version"}),a=this.observe({timeline:!0,structured:!0}),i=!1,u=!1,d=()=>{i||u||(i=!0,dt(()=>{i=!1,!u&&(s+=1,o.emit(s))}))},c=a.onEvent(y=>{let v=y.type;v!=="data"&&v!=="error"&&v!=="complete"&&v!=="teardown"||d()}),f=[];e!=null&&Ze(e)&&f.push(e),t!=null&&Ze(t)&&f.push(t),r?.maxDepth!=null&&Ze(r.maxDepth)&&f.push(r.maxDepth),r?.findCycle!=null&&Ze(r.findCycle)&&f.push(r.findCycle);let l=()=>{for(let y of f)if(y.cache===void 0)return!1;return!0},p=()=>{let y=je(e),v=je(t);return{from:y,to:v,found:!1,reason:"pending",steps:[],text:"(awaiting reactive args)",toJSON:()=>({from:y,to:v,found:!1,reason:"pending",steps:[]})}},h;try{h=he([o],()=>{if(!l())return p();let y=je(e),v=je(t),T={...r?.maxDepth!==void 0?{maxDepth:uo(r.maxDepth)}:{},...r?.findCycle!==void 0?{findCycle:co(r.findCycle)}:{}};return this._explainStatic(y,v,T)},{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:je(e),to:je(t)},equals:(y,v)=>y.found===v.found&&y.reason===v.reason&&y.steps.length===v.steps.length&&Us(y.steps,v.steps)})}catch(y){throw c(),a.dispose(),y}let g=et(h),m=[],b=y=>{let v;return v=y.subscribe(T=>{let w=!1,O=!1;for(let k of T){let S=k[0];S===x?w=!0:(S===N||S===_||S===K)&&(O=!0)}(w||O)&&d(),O&&v&&(v(),v=void 0)}),()=>{v&&(v(),v=void 0)}};for(let y of f)m.push(b(y));return{node:h,dispose(){u=!0,c();for(let y of m)y?.();m.length=0,a.dispose(),g()}}}_pathsMatching(e){let t=un(e),r=[];return this._collectObserveTargets("",r),r.map(([s])=>s).filter(s=>t.test(s))}_collectObserveTargets(e,t){for(let r of[...this._mounts.keys()].sort()){let s=e===""?r:`${e}${te}${r}`;this._mounts.get(r)._collectObserveTargets(s,t)}for(let r of[...this._nodes.keys()].sort()){let s=this._nodes.get(r),o=e===""?r:`${e}${te}${r}`;t.push([o,s]),this._appendMetaObserveTargets(o,s,t)}}_appendMetaObserveTargets(e,t,r){for(let s of Object.keys(t.meta).sort()){let o=t.meta[s],a=`${e}${te}${Ae}${te}${s}`;r.push([a,o]),this._appendMetaObserveTargets(a,o,r)}}observe(e,t){let r=typeof e=="string",o=fo(r?t:e);if(o.reactive===!0)return this._observeReactive(r?e:void 0,o);let a=o.structured===!0||o.timeline===!0||o.causal===!0||o.derived===!0||o.detail==="minimal"||o.detail==="full"||o.format!=null,i=o.actor;if(r){let c=e,f=this.resolve(c);if(i!=null&&!f.allowsObserve(i))throw new Me({actor:i,action:"observe",nodeName:c});return a?this._buildStructuredObserver([[c,f]],o,"one"):{subscribe(l){return f.subscribe(l)},up(l){try{f.up?.(l)}catch(p){if(p instanceof Me)return;throw p}}}}let u=[];this._collectObserveTargets("",u),u.sort((c,f)=>c[0]<f[0]?-1:c[0]>f[0]?1:0);let d=i==null?u:u.filter(([,c])=>c.allowsObserve(i));return a?this._buildStructuredObserver(d,o,"all"):{subscribe:c=>{let f=d.map(([l,p])=>p.subscribe(h=>{c(l,h)}));return()=>{for(let l of f)l()}},up:(c,f)=>{try{this.resolve(c).up?.(f)}catch(l){if(l instanceof Me)return;throw l}}}}_observeReactive(e,t){let r=t.tiers,s=r!=null?new Set(r):null,o=t.reactiveName??"observe";return C(a=>{let i=[],u=!1,d=!1,c=()=>{if(i.length===0||d)return;let g={events:i.slice(),flushedAt_ns:re()};i.length=0,a.emit(g)},f={...t,reactive:!1,structured:!0,timeline:!0},l=e!=null?this.observe(e,f):this.observe(f),p=g=>{d||(i.push(g),!u&&(u=!0,dt(()=>{u=!1,c()})))};for(let g of l.events)p(g);let h=l.onEvent(p);return()=>{d=!0,h(),l.dispose()}},{name:o,meta:{domain:"audit",kind:"observe-reactive"}})}_buildStructuredObserver(e,t,r){let s=r==="one"?e[0]?.[0]:void 0,o=a=>{if(r==="one"&&s!=null){let c=this.resolve(s);return this._buildStructuredObserver([[s,c]],a,"one")}let i=[];this._collectObserveTargets("",i),i.sort((c,f)=>c[0]<f[0]?-1:c[0]>f[0]?1:0);let u=a.actor,d=u==null?i:i.filter(([,c])=>c.allowsObserve(u));return this._buildStructuredObserver(d,a,"all")};return this._createObserveResult(e,t,o)}_createObserveResult(e,t,r){let s=t.timeline===!0,o=t.causal===!0,a=t.derived===!0,i=t.detail==="minimal",u=this.config.inspectorEnabled,d=(o||a)&&u,c=t.maxEvents,f=c!=null&&c>0?new Ge(c):null,l=[],p=new Set,h=t.tiers!=null?new Set(t.tiers):null,g={},m=new Set,b=0,y=0,v=0,T=0,w=0,O=0,k=!1,S=!1,E=0,R=new Map,M=new Map,L=new Map,A=B=>{if(!(h!=null&&!h.has(B.type))){f?f.push(B):l.push(B);for(let X of p)X(B)}},P=B=>h==null||h.has(B),ue=()=>s?{timestamp_ns:re(),in_batch:Jt(),batch_id:E}:{},W=(B,X)=>{if(!(!d||!(B instanceof se)))return B._setInspectorHook(ke=>{if(ke.kind==="dep_message")R.set(B,ke.depIndex);else if(ke.kind==="run"){let He=ke.batchData.map((j,ge)=>j!=null&&j.length>0?j.at(-1):ke.prevData[ge]);M.set(B,He);let xe=ke.batchData.map(j=>j!=null?[...j]:void 0);L.set(B,xe),a&&A({type:"derived",path:X,dep_values:He,dep_batches:xe,...ue()})}})},de=B=>{let X=R.get(B),ke=M.get(B);if(!o||ke==null)return{};let xe=(X!=null&&X>=0&&B instanceof se?B._deps[X]:void 0)?.node,j=xe?.v,ge=L.get(B);return{trigger_dep_index:X,trigger_dep_name:xe?.name,...j!=null?{trigger_version:{id:j.id,version:j.version}}:{},dep_values:[...ke],...ge!=null?{dep_batches:ge}:{}}},Ee=[],ze=[];for(let[B,X]of e){let ke=W(X,B);ke&&Ee.push(ke),ze.push(X.subscribe(He=>{E++;for(let xe of He){let j=xe[0],ge=ue();if(j===x){g[B]=xe[1];let Mt=X instanceof se?X.lastMutation?.actor??lt:lt;A({type:"data",path:B,data:xe[1],actor:Mt,...ge,...de(X)})}else if(i)j===F?P("dirty")&&b++:j===D?P("resolved")&&y++:j===Ne?P("invalidate")&&v++:j===le?P("pause")&&T++:j===pe?P("resume")&&w++:j===K?P("teardown")&&O++:j===N&&!m.has(B)?P("complete")&&(k=!0):j===_&&P("error")&&(S=!0,m.add(B));else if(j===F)P("dirty")&&b++,A({type:"dirty",path:B,...ge});else if(j===D)P("resolved")&&y++,A({type:"resolved",path:B,...ge,...de(X)});else if(j===Ne)P("invalidate")&&v++,A({type:"invalidate",path:B,...ge});else if(j===le)P("pause")&&T++,A({type:"pause",path:B,lockId:xe[1],...ge});else if(j===pe)P("resume")&&w++,A({type:"resume",path:B,lockId:xe[1],...ge});else if(j===N)P("complete")&&!m.has(B)&&(k=!0),A({type:"complete",path:B,...ge});else if(j===_){P("error")&&(S=!0,m.add(B));let Mt=X instanceof se?X.lastMutation?.actor??lt:lt;A({type:"error",path:B,data:xe[1],actor:Mt,...ge})}else j===K&&(P("teardown")&&O++,A({type:"teardown",path:B,...ge}))}}))}let Re=!1,_e=()=>{if(!Re){Re=!0;for(let B of ze)B();for(let B of Ee)B();for(let B of $e)B({value:void 0,done:!0});$e.length=0}},Ke=[],$e=[];p.add(B=>{let X=$e.shift();X?X({value:B,done:!1}):Ke.push(B)});let Ue={get values(){return g},get dirtyCount(){return b},get resolvedCount(){return y},get invalidateCount(){return v},get pauseCount(){return T},get resumeCount(){return w},get teardownCount(){return O},get events(){return f?f.toArray():[...l]},get anyCompletedCleanly(){return k},get anyErrored(){return S},get completedWithoutErrors(){return k&&!S},onEvent(B){return p.add(B),()=>p.delete(B)},dispose:_e,expand(B){_e();let X={...t};return typeof B=="string"?X.detail=B:Object.assign(X,B),r(fo(X))},[Symbol.asyncIterator](){return{next(){return Ke.length>0?Promise.resolve({value:Ke.shift(),done:!1}):Re?Promise.resolve({value:void 0,done:!0}):new Promise(B=>$e.push(B))},return(){return _e(),Promise.resolve({value:void 0,done:!0})}}}};return t.format!=null&&this._attachFormatLogger(Ue,t),Ue}_attachFormatLogger(e,t){let r=t.format;if(r==null)return;let s=t.logger??(h=>console.log(h)),o=t.includeTypes?new Set(t.includeTypes):null,a=t.excludeTypes?new Set(t.excludeTypes):null,i=o==null&&a==null?()=>!0:h=>(o==null||o.has(h))&&(a==null||!a.has(h)),u=Ks(t.theme),d=r==="stage-log"?re():0,c=h=>h==null?"":t.stageLabels?.[h]??h,f=(h,g)=>h.length>g?`${h.slice(0,g-1)}\u2026`:h,l=h=>h.type==="data"||h.type==="error"?f(rr(h.data),120):"",p=h=>{if(r==="stage-log"){let k=(re()-d)/1e9,S=c(h.path).padEnd(9);if(h.type==="data"){let E=l(h);return`[${k.toFixed(3)}s] ${S} \u2190${E?` ${E}`:""}`}if(h.type==="error"){let E=l(h);return`[${k.toFixed(3)}s] ${S} \u2717${E?` ${E}`:""}`}return h.type==="complete"?`[${k.toFixed(3)}s] ${S} \u25A0 complete`:`[${k.toFixed(3)}s] ${S} ${h.type}`}if(r==="json")try{return JSON.stringify(h)}catch{return JSON.stringify({type:h.type,path:h.path,data:"[unserializable]"})}let g=u[h.type]??"",m=h.path?`${u.path}${h.path}${u.reset} `:"",b=h.type==="data"||h.type==="error",y=h.type==="pause"||h.type==="resume",v=b?` ${rr(h.data)}`:y?` ${rr(h.lockId)}`:"",T=h.type==="data"||h.type==="resolved"||h.type==="derived"?h:void 0,w=T?.trigger_dep_name!=null?` <- ${T.trigger_dep_name}`:T?.trigger_dep_index!=null?` <- #${T.trigger_dep_index}`:"",O=h.in_batch?" [batch]":"";return`${m}${g}${h.type.toUpperCase()}${u.reset}${v}${w}${O}`};e.onEvent(h=>{i(h.type)&&s(p(h),h)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){an(this._disposers,this.name),this.signal([[K]],{internal:!0}),an(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}get destroyed(){return this._destroyed}_destroyClearOnly(){an(this._disposers,this.name),an(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}snapshot(e){let{expand:t,...r}=this.describe({detail:"full"}),s={};for(let i of Object.keys(r.nodes).sort()){let{lastMutation:u,guard:d,...c}=r.nodes[i];s[i]=c}let o=[...r.subgraphs].sort(),a={...r,version:1,nodes:s,subgraphs:o};if(e?.format==null)return a;if(e.format==="json-string")return JSON.stringify(a);if(e.format==="bytes"){if(e.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let i=this.config.lookupCodec(e.codec);if(i==null)throw new Error(`snapshot: codec "${e.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return Dr(i,i.encode(a))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,t){let r=t?.config??be,{codec:s,codecVersion:o,payload:a}=Pr(e,r);return s.decode(a,o)}restore(e,t){if(lo(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let r=t?.only==null?null:(Array.isArray(t.only)?t.only:[t.only]).map(o=>un(o)),s=t?.includeProducers===!0;for(let o of Object.keys(e.nodes).sort()){if(r!==null&&!r.some(i=>i.test(o)))continue;let a=e.nodes[o];if(a!==void 0){if(!("value"in a)||a.value===void 0){"value"in a&&a.value===void 0&&t?.onError?.(o,new Error(`restore: slice.value is undefined for "${o}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(a.type==="derived"||a.type==="effect")&&!(a.type==="producer"&&!s)){if(a.v!=null){let u=this.tryResolve(o)?.v;if(u!=null&&u.id===a.v.id&&u.version===a.v.version)continue}try{this.set(o,a.value)}catch(i){t?.onError?.(o,i)}}}}}static fromSnapshot(e,t){lo(e);let r=typeof t=="function"?t:t?.build,s=typeof t=="function"?void 0:t?.factories,o=new n(e.name);if(r)return r(o),o.restore(e),o;for(let p of[...e.subgraphs].sort((h,g)=>{let m=h.split(te).length,b=g.split(te).length;return m!==b?m-b:h<g?-1:h>g?1:0})){let h=p.split(te),g=o;for(let m of h)g._mounts.has(m)||g.mount(m,new n(m)),g=g._mounts.get(m)}let a=s?Object.entries(s).map(([p,h])=>({re:un(p),factory:h})):[],i=p=>{for(let h of a)if(h.re.test(p))return h.factory},u=p=>{let h=p.split(te),g=h.pop();if(g==null||g.length===0)throw new Error(`invalid snapshot path "${p}"`);let m=o;for(let b of h){let y=m._mounts.get(b);if(!y)throw new Error(`unknown mount "${b}" in path "${p}"`);m=y}return[m,g]},d=Object.entries(e.nodes).filter(([p])=>!p.includes(`${te}${Ae}${te}`)).sort((p,h)=>p[0]<h[0]?-1:p[0]>h[0]?1:0),c=new Map(d),f=new Map,l=!0;for(;c.size>0&&l;){l=!1;for(let[p,h]of[...c.entries()]){let g=h?.deps??[];if(!g.every(w=>f.has(w)))continue;let[m,b]=u(p),y={...h?.meta??{}},v=i(p),T;if(h?.type==="state")T=G(h.value,{meta:y});else{if(v==null)continue;T=v(b,{path:p,type:h.type,value:h.value,meta:y,deps:g,resolvedDeps:g.map(w=>f.get(w))})}m.add(T,{name:b}),f.set(p,T),c.delete(p),l=!0}}if(c.size>0){let p=[...c.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${p}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return o.restore(e),o}toJSON(){return this.snapshot()}attachSnapshotStorage(e,t={}){let r=e.map(d=>({tier:d,debounceMs:Math.max(0,d.debounceMs??0),compactEvery:Math.max(1,d.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));t.autoRestore===!0&&this._cascadeRestore(e,t.onError);let s=(d,c)=>{if(d.disposed)return;let f=Bs(c.nodes);if(d.lastSnapshot!=null&&f!==""&&f===d.lastFingerprint)return;let l=d.seq+1,p=ne(),m=d.lastSnapshot==null||l%d.compactEvery===0?{name:this.name,mode:"full",snapshot:c,seq:l,timestamp_ns:p,format_version:Xe}:{name:this.name,mode:"diff",diff:mo(d.lastSnapshot,c),seq:l,timestamp_ns:p,format_version:Xe};if(d.tier.filter&&!d.tier.filter(m))return;let b;try{b=d.tier.save(m)}catch(y){t.onError?.(y,d.tier);return}if(b&&typeof b.then=="function"){let T=(d.savePending??Promise.resolve()).then(()=>b,()=>b).then(()=>{d.disposed||(d.seq=l,d.lastSnapshot=c,d.lastFingerprint=f)},w=>{t.onError?.(w,d.tier)});d.savePending=T.finally(()=>{d.savePending===T&&(d.savePending=void 0)})}else d.seq=l,d.lastSnapshot=c,d.lastFingerprint=f},o=(d,c)=>{try{s(d,c)}catch(f){t.onError?.(f,d.tier)}},a=(d,c)=>{if(!c.some(h=>{let g=this.config.messageTier(h[0]);return g>=3&&g<5}))return;if(t.filter){let h=this.tryResolve(d);if(h==null)return;let g=Yn(h,Jn("standard"));if(!t.filter(d,g))return}let l,p=()=>(l==null&&(l=this.snapshot()),l);for(let h of r)h.disposed||(h.debounceMs===0?o(h,p()):(h.timer==null&&(h.timer=new Ie),h.timer.start(h.debounceMs,()=>{h.disposed||o(h,this.snapshot())})))},i;if(t.paths!=null){let c=(typeof t.paths=="string"?this._pathsMatching(t.paths):t.paths).map(f=>{let l=this.tryResolve(f);return l==null?()=>{}:l.subscribe(p=>a(f,p))});i=()=>{for(let f of c)f()}}else i=this.observe().subscribe((d,c)=>a(d,c));let u=()=>{i();for(let d of r)d.disposed=!0,d.timer?.cancel();this._storageDisposers.delete(u)};return this._storageDisposers.add(u),{dispose:u}}async _cascadeRestore(e,t){for(let r of e){let s;try{s=await r.load?.()}catch(a){t?.(a,r);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let o=s;try{if(o.mode==="full"&&o.snapshot!=null)return this.restore(o.snapshot),!0;if(o.version===Xe&&o.nodes!=null)return this.restore(o),!0}catch(a){t?.(a,r)}}return!1}static async fromStorage(e,t,r){for(let s of t){let o;try{o=await s.load?.()}catch(u){r?.onError?.(u,s);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let a=o,i=a.mode==="full"&&a.snapshot!=null?a.snapshot:a.version===Xe&&a.nodes!=null?a:void 0;if(i!=null)try{return n.fromSnapshot(i,r)}catch(u){r?.onError?.(u,s)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${e}" across ${t.length} tier(s)`)}_annotations=new Map;_traceRing;trace(e,t,r){if(e!=null&&t!=null){if(this.tryResolve(e)==null)return;if(this._annotations.set(e,t),this.config.inspectorEnabled){let s={path:e,annotation:t,timestamp_ns:re(),...r?.actor!=null?{actor:r.actor}:{}};this._traceRing.push(s)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let t=this._traceRing.toArray().filter(s=>!e(s)),r=this._traceRing.size-t.length;this._traceRing.clear();for(let s of t)this._traceRing.push(s);return r}static diff(e,t){let r=new Set(Object.keys(e.nodes)),s=new Set(Object.keys(t.nodes)),o=[...s].filter(y=>!r.has(y)).sort(),a=[...r].filter(y=>!s.has(y)).sort(),i=[],u=[];for(let y of r){if(!s.has(y))continue;let v=e.nodes[y],T=t.nodes[y],w=v.v,O=T.v;w!=null&&O!=null&&w.id===O.id&&w.version!==O.version&&u.push({path:y,id:w.id,from:w.version,to:O.version});let k=w!=null&&O!=null&&w.id===O.id&&w.version===O.version;for(let S of["type","status","sentinel"]){let E=v[S],R=T[S];E!==R&&i.push({path:y,field:S,from:E,to:R})}if(!k)for(let S of["value","meta"]){let E=v[S],R=T[S];Vs(E,R)||i.push({path:y,field:S,from:E,to:R})}}let d=y=>`${y.from} ${y.to}`,c=new Set(e.edges.map(d)),f=new Set(t.edges.map(d)),l=t.edges.filter(y=>!c.has(d(y))),p=e.edges.filter(y=>!f.has(d(y))),h=new Set(e.subgraphs),g=new Set(t.subgraphs),m=[...g].filter(y=>!h.has(y)).sort(),b=[...h].filter(y=>!g.has(y)).sort();return{nodesAdded:o,nodesRemoved:a,nodesChanged:i,versionChanges:u,edgesAdded:l,edgesRemoved:p,subgraphsAdded:m,subgraphsRemoved:b}}}});var go=q(()=>{"use strict";dn()});function Bt(n){return typeof n=="object"&&n!==null&&"subscribe"in n&&"down"in n}function bo(n){if(n<=0)throw new RangeError("timeoutMs must be > 0");if(n>9e6)throw new RangeError("timeoutMs must be <= 9_000_000 (\u22482.5h) to stay within safe ns arithmetic")}function yo(n,e={}){let t=new Vt(n,e);return t.tagFactory("resilientPipeline",Jr(e)),t}var Vt,vo=q(()=>{"use strict";mt();go();en();Tt();ir();Vt=class extends Be{output;status;lastError;breakerState;droppedCount;rateLimitState;constructor(e,t={}){super(t.name??"resilient_pipeline",t.graph);let r=e,s,o,a;if(t.rateLimit!=null)if(Bt(t.rateLimit)){let u=r,d=t.rateLimit;r=we(d,c=>{let f={...c,maxBuffer:c.maxBuffer??1/0,meta:ve("resilient","rate-limit")};return yt(u,f).node}),this.add(r,{name:"rateLimited"})}else{let u={...t.rateLimit,maxBuffer:t.rateLimit.maxBuffer??1/0,meta:ve("resilient","rate-limit")},d=yt(r,u);r=d.node,s=d.droppedCount,o=d.rateLimitState,this.add(r,{name:"rateLimited"}),this.add(s,{name:"droppedCount"}),this.add(o,{name:"rateLimitState"})}if(t.budget!=null)if(Bt(t.budget)){let u=r,d=t.budget;r=we(d,c=>c.length>0?Qe(u,c,{meta:ve("resilient","budget")}):u),this.add(r,{name:"budgetGated"})}else t.budget.length>0&&(r=Qe(r,t.budget,{meta:ve("resilient","budget")}),this.add(r,{name:"budgetGated"}));if(t.breaker!=null)if(Bt(t.breaker)){let u=r,d=t.breaker,c=t.breakerOnOpen??"skip";r=we(d,f=>{let l=gt(f);return bt(l,{onOpen:c,meta:ve("resilient","breaker")})(u).node}),this.add(r,{name:"breakerWrapped"})}else{let u=gt(t.breaker),d=t.breakerOnOpen??"skip",c=bt(u,{onOpen:d,meta:ve("resilient","breaker")})(r);r=c.node,a=c.breakerState,this.add(r,{name:"breakerWrapped"}),this.add(a,{name:"breakerState"})}if(t.timeoutMs!=null)if(Bt(t.timeoutMs)){let u=r,d=t.timeoutMs;r=we(d,c=>(bo(c),vt(u,c*1e6,{meta:ve("resilient","timeout")}))),this.add(r,{name:"timeoutWrapped"})}else bo(t.timeoutMs),r=vt(r,t.timeoutMs*1e6,{meta:ve("resilient","timeout")}),this.add(r,{name:"timeoutWrapped"});if(t.retry!=null)if(Bt(t.retry)){let u=r,d=t.retry;r=we(d,c=>We(u,{...c,meta:ve("resilient","retry")})),this.add(r,{name:"retryWrapped"})}else r=We(r,{...t.retry,meta:ve("resilient","retry")}),this.add(r,{name:"retryWrapped"});t.fallback!==void 0&&(r=Ft(r,t.fallback,{meta:ve("resilient","fallback")}),this.add(r,{name:"fallbackWrapped"}));let i=tt(r,{initialStatus:t.initialStatus??"pending",meta:ve("resilient","status")});this.output=i.node,this.status=i.status,this.lastError=i.error,this.breakerState=a,this.droppedCount=s,this.rateLimitState=o,this.add(this.output,{name:"output"}),this.add(this.status,{name:"status"}),this.add(this.lastError,{name:"lastError"})}}});function nt(n){return{describeKind:"derived",...n}}function Hs(n){return n<0?0:n}function ar(n){return n[1]}function qs(n){if(typeof n!="number"||!Number.isFinite(n))throw new TypeError("backoff strategy must return a finite number");return n<0?0:n}function ln(n){let e=n?.count,t=n?.backoff;if(t!==void 0&&e===void 0)throw new RangeError("retry({ backoff }) requires explicit count to prevent unbounded retries; pass { count: <n>, backoff: ... }");let r=e!==void 0?e:0;if(r<0)throw new RangeError("retry count must be >= 0");let s=t===void 0?null:typeof t=="string"?pt(t):t;return{maxRetries:r,strategy:s}}function wo(n){let e={};return n?.count!==void 0&&(e.count=n.count),typeof n?.backoff=="string"&&(e.backoff=n.backoff),Object.keys(e).length>0?e:void 0}function ko(n,e,t){let r=0,s=!1,o=null,a,i=new Ie;function u(){a?.(),a=void 0}function d(f){if(s)return;let l=n();if(r>=l.maxRetries){u(),t.down([[_,f]]);return}let p=l.strategy===null?0:l.strategy(r,f,o);if(p==null){u(),t.down([[_,f]]);return}let h;try{h=qs(p)}catch{u(),t.down([[_,f]]);return}o=h,r+=1,u();let g=h>0?h/1e6:1;i.start(g,()=>{s||c()})}function c(){i.cancel(),u();let f;try{f=e()}catch(l){d(l);return}a=f.subscribe(l=>{if(!s)for(let p of l){let h=p[0];if(h===F)t.down([[F]]);else if(h===x)r=0,o=null,t.emit(p[1]);else if(h===D)t.down([[D]]);else if(h===N)s=!0,u(),t.down([[N]]);else if(h===_){d(ar(p));return}else t.down([p])}})}return c(),()=>{s=!0,i.cancel(),u()}}function We(n,e){return typeof n=="function"?Ys(n,e):Js(n,e)}function Js(n,e){n._resubscribable===!1&&!To.has(n)&&(To.add(n),console.warn("retry(source, opts): source-mode requires `resubscribable: true` on the upstream node. Retries will be silent no-ops after the first ERROR. Either pass `resubscribable: true` to the source factory, OR use factory-mode retry `retry(() => buildSource(), opts)` so each attempt builds a fresh node."));let r=De(e)?void 0:e;return De(e)||ln(r),C(s=>{let o=zt(e),i=ko(()=>ln(o.current()),()=>n,s);return()=>{i(),o.unsub()}},{...nt(),initial:n.cache,meta:{...r?.meta??{},...J("retry",De(e)?{reactiveOpts:!0}:wo(r))}})}function Ys(n,e){let t=De(e)?void 0:e;return De(e)||ln(t),C(r=>{let s=zt(e),a=ko(()=>ln(s.current()),n,r);return()=>{a(),s.unsub()}},{...nt(),initial:t?.initial,meta:{...t?.meta??{},...J("retry",De(e)?{reactiveOpts:!0}:wo(t))}})}function gt(n){let e=5,t=30*1e9,r=null,s=1,o=re;function a(b){e=Math.max(1,b?.failureThreshold??5),t=Hs(b?.cooldownNs??30*1e9),r=b?.cooldown??null,s=Math.max(1,b?.halfOpenMax??1),o=b?.now??re}let i="closed",u=0,d=0,c=0,f=t,l=0,p=zt(n,b=>{a(b),i="closed",u=0,d=0,l=0,f=t});a(p.current()),f=t;function h(){if(!r)return t;let b=r(d);return b!==null?b:t}function g(){i="open",f=h(),c=o(),l=0}return{canExecute(){return i==="closed"?!0:i==="open"?o()-c>=f?(i="half-open",l=1,!0):!1:l<s?(l++,!0):!1},recordSuccess(){i==="half-open"?(i="closed",u=0,d=0):i==="closed"&&(u=0)},recordFailure(b){if(i==="half-open"){d++,g();return}i==="closed"&&(u++,u>=e&&g())},get state(){return i},get failureCount(){return u},reset(){i="closed",u=0,d=0,l=0},dispose(){p.unsub()}}}function bt(n,e){let t=e?.onOpen??"skip",r=e?.meta;return s=>{let o=V([],(a,i)=>{function u(){o.meta.breakerState.down([[x,n.state]])}let d=s.subscribe(c=>{for(let f of c){let l=f[0];l===F?i.down([[F]]):l===x?n.canExecute()?(u(),i.emit(f[1])):(u(),t==="error"?i.down([[_,new wt]]):i.down([[D]])):l===D?i.down([[D]]):l===N?(n.recordSuccess(),u(),i.down([[N]])):l===_?(n.recordFailure(ar(f)),u(),i.down([f])):i.down([f])}});return u(),d},{...nt(),meta:{...r??{},breakerState:n.state,...J("withBreaker",{onOpen:t})},completeWhenDepsComplete:!1,initial:s.cache});return{node:o,breakerState:o.meta.breakerState}}}function Gt(n,e,t){if(n<=0)throw new RangeError("capacity must be > 0");if(e<0)throw new RangeError("refillPerSecond must be >= 0");let r=t?.clock??re,s=n,o=r();function a(i){if(e>0){let u=i-o;s=Math.min(n,s+u/1e9*e)}o=i}return{available(){return a(r()),s},tryConsume(i=1){if(i<=0)return!0;let u=r();return a(u),s>=i?(s-=i,!0):!1},putBack(i=1){i<=0||(a(r()),s=Math.min(n,s+i))}}}function Qs(n,e){return n.droppedCount===e.droppedCount&&n.pendingCount===e.pendingCount&&n.paused===e.paused}function yt(n,e){let t=De(e);if(!t){let i=e;if(i.maxEvents<=0)throw new RangeError("maxEvents must be > 0");if(i.windowNs<=0)throw new RangeError("windowNs must be > 0");if(i.maxBuffer===void 0)throw new RangeError("rateLimiter requires explicit maxBuffer (use Infinity to opt in to unbounded)");if(!(i.maxBuffer===1/0)&&(!Number.isInteger(i.maxBuffer)||i.maxBuffer<1))throw new RangeError("maxBuffer must be a positive integer (or Infinity for unbounded)")}let r=t?e.cache:e,s=r?.maxBuffer,o=s===1/0,a=C(i=>{let u=r?.maxEvents??1,d=r?.windowNs??1e9,c=s??1,f=r?.onOverflow??"drop-newest",l=u*1e9/d,p=1e9/l,h=Gt(u,l),g=o?Zs():Xs(Math.max(1,c)),m=new Ie,b=!1,y=0,v=a.meta.droppedCount,T=a.meta.rateLimitState,w=cn;function O(){v.emit(y);let L={droppedCount:y,pendingCount:g.size,paused:g.size>0};Qs(w,L)||(w=L,T.emit(L))}w=cn,v.emit(0),T.emit(cn);let k=zt(e,L=>{if(b||L==null||!(L.maxEvents>0)||!(L.windowNs>0))return;let A=L.maxBuffer;if(A===void 0)return;let P=A===1/0;if(P===o&&!(!P&&(!Number.isInteger(A)||A<1))){if(!P&&A>c){console.warn(`rateLimiter: reactive maxBuffer grow (${c} \u2192 ${A}) rejected. The pending ring buffer is allocated at construction; reactive maxBuffer is monotonically non-increasing. Recreate the rateLimiter with the larger cap if growth is required.`);return}if(u=L.maxEvents,d=L.windowNs,c=A,f=L.onOverflow??"drop-newest",l=u*1e9/d,p=1e9/l,h=Gt(u,l),!P)for(;g.size>c;)g.shift(),y+=1;O()}});function S(){for(;g.size>0;)if(h.tryConsume(1))i.emit(g.shift()),O();else{m.start(Math.max(1,p/1e6),S);return}}function E(){y+=1,O()}function R(){for(b=!0,m.cancel();g.size>0;)g.shift();y=0}let M=n.subscribe(L=>{for(let A of L){if(b)return;let P=A[0];if(P===F)i.down([[F]]);else if(P===x){if(!o&&g.size>=c)if(f==="drop-newest")E();else if(f==="drop-oldest")g.shift(),g.push(A[1]),E();else{E(),R(),i.down([[_,new kt(c)]]);return}else g.push(A[1]),O();S()}else if(P===D)i.down([[D]]);else if(P===N)R(),i.down([[N]]);else if(P===_)R(),i.down([A]);else if(P===K){R(),i.down([A]);return}else i.down([A])}});return()=>{b=!0,m.cancel(),M(),k.unsub()}},{...nt(),initial:n.cache,meta:{...t?{}:e.meta??{},droppedCount:0,rateLimitState:cn,...J("rateLimiter",t?{reactiveOpts:!0}:e)}});return{node:a,droppedCount:a.meta.droppedCount,rateLimitState:a.meta.rateLimitState}}function Xs(n){let e=new Ge(n);return{push:t=>e.push(t),shift:()=>e.shift(),get size(){return e.size}}}function Zs(){let n=[];return{push:e=>{n.push(e)},shift:()=>n.shift(),get size(){return n.length}}}function tt(n,e){let t=e?.initialStatus??"pending",r=e?.meta,s=V([],(o,a)=>{let i=t;return s.meta.status.down([[x,t]]),s.meta.error.down([[x,null]]),n.subscribe(d=>{for(let c of d){let f=c[0];if(f===F)a.down([[F]]);else if(f===x)i==="errored"?$(()=>{s.meta.error.down([[x,null]]),s.meta.status.down([[x,"running"]])}):s.meta.status.down([[x,"running"]]),i="running",a.emit(c[1]);else if(f===D)a.down([[D]]);else if(f===N)s.meta.status.down([[x,"completed"]]),i="completed",a.down([[N]]);else if(f===_){let l=ar(c);$(()=>{s.meta.error.down([[x,l]]),s.meta.status.down([[x,"errored"]])}),i="errored",a.down([c])}else a.down([c])}})},{...nt(),meta:{...r??{},status:t,error:null,...J("withStatus",{initialStatus:t})},completeWhenDepsComplete:!1,resubscribable:!0,initial:n.cache});return{node:s,status:s.meta.status,error:s.meta.error}}function De(n){return n!=null&&typeof n=="object"&&"cache"in n&&typeof n.subscribe=="function"}function zt(n,e){if(!De(n))return{current:()=>n,unsub:()=>{}};let t=n,r=t.cache,s=t.subscribe(o=>{for(let a of o)a[0]===x&&(r=a[1],e&&e(r))});return{current:()=>r,unsub:s}}function ei(n){return n!=null&&typeof n.then=="function"}function ti(n){return n!=null&&typeof n=="object"&&typeof n[Symbol.asyncIterator]=="function"}function Ft(n,e,t){let r=t?.meta;return C(s=>{let o,a;function i(){a?.(),a=void 0,De(e)||ei(e)||ti(e)?o=oe(e).subscribe(d=>{s.down(d);for(let c of d){let f=c[0];if(f===N||f===_||f===K){o=void 0;return}}}):(s.emit(e),s.down([[N]]))}return a=n.subscribe(u=>{for(let d of u){let c=d[0];if(c===F)s.down([[F]]);else if(c===x)s.emit(d[1]);else if(c===D)s.down([[D]]);else if(c===N)s.down([[N]]);else if(c===_){i();return}else if(c===K){o?.(),s.down([d]);return}else s.down([d])}}),()=>{a?.(),o?.()}},{...nt(),initial:n.cache,meta:{...r??{},...J("fallback")}})}function vt(n,e,t){if(!De(e)&&e<=0)throw new RangeError("timeoutNs must be > 0");let r=t?.meta,s=De(e)?{timeoutNs:"Node<number>"}:{timeoutNs:e};return C(o=>{let a=!1,i=new Ie,u=zt(e),d=()=>{let l=u.current();return typeof l=="number"&&l>0?l:0};function c(){let l=d();if(l<=0)return;let p=l/1e6;i.start(p,()=>{a||(a=!0,f(),o.down([[_,new xt(l)]]))})}let f=n.subscribe(l=>{for(let p of l){if(a)return;let h=p[0];if(h===F)o.down([[F]]);else if(h===x)c(),o.emit(p[1]);else if(h===D)o.down([[D]]);else if(h===N){i.cancel(),a=!0,o.down([[N]]);return}else if(h===_){i.cancel(),a=!0,o.down([p]);return}else if(h===K){i.cancel(),a=!0,o.down([p]);return}else o.down([p])}});return c(),()=>{a=!0,i.cancel(),f(),u.unsub()}},{...nt(),initial:n.cache,meta:{...r??{},...J("timeout",s)}})}var To,wt,kt,cn,xt,ir=q(()=>{"use strict";Qr();vo();Te();Le();Z();mt();ye();fe();Pt();Ve();on();sn();To=new WeakSet;wt=class extends Error{name="CircuitOpenError";constructor(){super("Circuit breaker is open")}};kt=class extends Error{name="RateLimiterOverflowError";constructor(e){super(`rateLimiter buffer overflow (maxBuffer=${e})`)}};cn=Object.freeze({droppedCount:0,pendingCount:0,paused:!1});xt=class extends Error{name="TimeoutError";constructor(e){super(`Timed out after ${e/1e6}ms`)}}});var xo={};En(xo,{CircuitOpenError:()=>wt,RateLimiterOverflowError:()=>kt,ResilientPipelineGraph:()=>Vt,TimeoutError:()=>xt,budgetGate:()=>Qe,circuitBreaker:()=>gt,fallback:()=>Ft,rateLimiter:()=>yt,resilientPipeline:()=>yo,retry:()=>We,timeout:()=>vt,tokenBucket:()=>Gt,withBreaker:()=>bt,withStatus:()=>tt});var fn=q(()=>{"use strict";ir()});function Se(n){return{describeKind:"producer",...n}}function Oo(n){return/[\\^$+?.()|[\]{}]/.test(n)?`\\${n}`:n}function ni(n){let e="^";for(let t=0;t<n.length;t+=1){let r=n[t];if(r==="*"){n[t+1]==="*"?(e+=".*",t+=1):e+="[^/]*";continue}e+=Oo(r)}return e+="$",new RegExp(e)}function ri(n,e){for(let t of e)if(t.test(n))return!0;return!1}function oi(n,e){let t=V([n],(s,o)=>{let a=s[0];if(a==null||a.length===0){o.down([[D]]);return}for(let i of a)o.emit(i)},{describeKind:"derived",initial:n.cache}),r=t.subscribe.bind(t);return t.subscribe=(s,o)=>(e(s),r(s,o)),t}function rt(n,e){let{signal:t,period:r,...s}=e??{};return C(o=>{let a=!1,i=0,u,d,c=()=>{a=!0,u!==void 0&&clearTimeout(u),d!==void 0&&clearInterval(d),t?.removeEventListener("abort",l)},f=()=>{a||(r!=null?(o.emit(i++),d=setInterval(()=>{a||o.emit(i++)},r)):(a=!0,t?.removeEventListener("abort",l),o.emit(i++),o.down([[N]])))},l=()=>{a||(c(),o.down([[_,t.reason]]))};if(t?.aborted){l();return}return u=setTimeout(f,n),t?.addEventListener("abort",l,{once:!0}),c},Se(s))}function si(n){let{signal:e,...t}=n??{};return C(r=>{let s=!1,o,a,i=!1,u=!1,d=typeof requestAnimationFrame=="function"?requestAnimationFrame:void 0,c=typeof cancelAnimationFrame=="function"?cancelAnimationFrame:void 0,f=typeof document<"u"?document:void 0,l=()=>{o!==void 0&&c&&c(o),a!==void 0&&clearTimeout(a),o=void 0,a=void 0},p=()=>{s=!0,l(),i&&(e?.removeEventListener("abort",h),i=!1),u&&f&&(f.removeEventListener("visibilitychange",b),u=!1)},h=()=>{s||(p(),r.down([[_,e.reason]]))},g=y=>{s||(r.emit(y),m())},m=()=>{s||(d&&(!f||f.visibilityState!=="hidden")?o=d(g):a=setTimeout(()=>g(performance.now()),16))},b=()=>{s||(l(),m())};return e?.aborted?(h(),p):(e?.addEventListener("abort",h,{once:!0}),i=e!==void 0,f&&d&&(f.addEventListener("visibilitychange",b),u=!0),m(),p)},Se(t))}function ii(n,e){let t=Qn(n),{tickMs:r,output:s,...o}=e??{},a=r??6e4,i=s==="date";return C(u=>{let d=-1,c=()=>{let l=new Date,p=l.getFullYear()*1e8+(l.getMonth()+1)*1e6+l.getDate()*1e4+l.getHours()*100+l.getMinutes();p!==d&&Xn(t,l)&&(d=p,u.emit(i?l:ne()))};c();let f=setInterval(c,a);return()=>clearInterval(f)},{...Se(o),name:o.name??`cron:${n}`})}function ai(n,e,t){let{capture:r,passive:s,once:o,...a}=t??{};return C(i=>{let u=c=>{i.emit(c)},d={capture:r,passive:s,once:o};return n.addEventListener(e,u,d),()=>n.removeEventListener(e,u,d)},Se(a))}function cr(n,e){return C(t=>{let r=!1;try{for(let s of n){if(r)return;t.emit(s)}r||t.down([[N]])}catch(s){r||t.down([[_,s]])}return()=>{r=!0}},Se(e))}function ui(n){return n!=null&&typeof n.then=="function"}function _o(n,e){let{signal:t,...r}=e??{};return C(s=>{let o=!1,a=()=>{o||(o=!0,s.down([[_,t.reason]]))};if(t?.aborted){a();return}return t?.addEventListener("abort",a,{once:!0}),Promise.resolve(n).then(i=>{o||(o=!0,t?.removeEventListener("abort",a),s.emit(i),s.down([[N]]))},i=>{o||(o=!0,t?.removeEventListener("abort",a),s.down([[_,i]]))}),()=>{o=!0,t?.removeEventListener("abort",a)}},Se(r))}function So(n,e){let{signal:t,...r}=e??{};return C(s=>{let o=new AbortController,a=()=>o.abort(t?.reason);t?.aborted?o.abort(t.reason):t?.addEventListener("abort",a,{once:!0});let i=t??o.signal,u=!1,d=n[Symbol.asyncIterator](),c=()=>{u||i.aborted||Promise.resolve(d.next()).then(f=>{if(!(u||i.aborted)){if(f.done){s.down([[N]]);return}s.emit(f.value),c()}},f=>{!u&&!i.aborted&&s.down([[_,f]])})};return c(),()=>{u=!0,t?.removeEventListener("abort",a),o.abort(),Promise.resolve(d.return?.()).catch(()=>{})}},Se(r))}function di(n){return n!=null&&typeof n=="object"&&"cache"in n&&typeof n.subscribe=="function"}function oe(n,e){if(di(n))return n;if(ui(n))return _o(n,e);if(n!=null){let t=n;if(typeof t[Symbol.asyncIterator]=="function")return So(n,e);if(typeof t[Symbol.iterator]=="function")return cr(n,e)}return Eo(n)}function Eo(...n){return cr(n,void 0)}function ci(n){return C(e=>{e.down([[N]])},Se(n))}function li(n){return C(()=>{},Se(n))}function fi(n,e){return C(t=>{t.down([[_,n]])},Se(e))}function pi(n,e){let{signal:t,...r}=e??{},s=Se(r),o=s.resubscribable===void 0?{...s,resubscribable:!0}:s;return C(a=>{let i,u=!1;try{let d=n();i=oe(d,e).subscribe(f=>{if(!u)for(let l of f){let p=l[0];if(p!==Fe)if(p===x)a.emit(l[1]);else if(p===N){u=!0,a.down([[N]]);break}else if(p===_){u=!0,a.down([[_,l[1]]]);break}else a.down([l])}})}catch(d){let c=d===void 0?new Error("defer: thunk threw undefined"):d;a.down([[_,c]])}return()=>{u=!0,i?.()}},o)}function ot(n,e,t){return V([n],(s,o)=>{let a=s[0];if(a!=null&&a.length>0)for(let i of a)e(i)},{describeKind:"effect",...t}).subscribe(()=>{})}function hi(n,e){return V([n],(t,r,s)=>{s.store.buf||(s.store.buf=[]);let o=s.store.buf,a=t[0];if(a!=null&&a.length>0)for(let i of a)o.push(i);if(s.terminalDeps[0]===!0){r.emit([...o]),r.down([[N]]);return}(a==null||a.length===0)&&r.down([[D]])},{describeKind:"derived",completeWhenDepsComplete:!1,...e})}function mi(n,e){return C(t=>n.subscribe(r=>{t.down(r)}),{...Se(e),initial:n.cache})}function lr(n,e,t){if(e<1)throw new RangeError("replay expects bufferSize >= 1");let r=[],s=C(o=>n.subscribe(a=>{for(let i of a)i[0]===x&&(r.push(i[1]),r.length>e&&r.shift());o.down(a)}),{...Se(t),initial:n.cache});return oi(s,o=>{for(let a of r)o([[x,a]])})}function gi(n,e){return lr(n,1,e)}function fr(n){return new Promise((e,t)=>{let r=!1,s=!1,o;o=n.subscribe(a=>{for(let i of a){if(r)return;if(i[0]===x){r=!0,e(i[1]),o?(o(),o=void 0):s=!0;return}if(i[0]===_){r=!0,t(i[1]),o?(o(),o=void 0):s=!0;return}if(i[0]===N){r=!0,t(new Error("completed without DATA")),o?(o(),o=void 0):s=!0;return}}}),s&&(o?.(),o=void 0)})}function dr(n,e,t){return new Promise((r,s)=>{let o=!1,a=!1,i,u=t?.skipCurrent===!0;i=n.subscribe(d=>{for(let c of d){if(o)return;if(!(u&&c[0]===x)){if(c[0]===x){let f=c[1];if(e(f)){o=!0,r(f),i?(i(),i=void 0):a=!0;return}}if(c[0]===_){o=!0,s(c[1]),i?(i(),i=void 0):a=!0;return}if(c[0]===N){o=!0,s(new Error("completed without matching value")),i?(i(),i=void 0):a=!0;return}}}}),u=!1,a&&(i?.(),i=void 0)})}async function bi(n,e){let t=e?.predicate??(o=>o!=null),r=e?.skipCurrent;if(e?.timeoutMs==null||e.timeoutMs<=0)return await dr(n,t,{skipCurrent:r});if(ur===void 0){let[o,a]=await Promise.all([Promise.resolve().then(()=>(fn(),xo)),Promise.resolve().then(()=>(Pt(),Hr))]);ur=o.timeout,No=a.NS_PER_MS}let s=ur(n,e.timeoutMs*No);return await dr(s,t,{skipCurrent:r})}function yi(n,e){let t=new AbortController,r=e?.reason??new Error("cancelled via nodeSignal"),s,o=!1,a=()=>{s?(s(),s=void 0):o=!0};return s=n.subscribe(i=>{if(!t.signal.aborted)for(let u of i){if(u[0]===x&&u[1]===!0){t.abort(r),a();return}if(u[0]===_){t.abort(u[1]),a();return}if(u[0]===N){a();return}}}),o&&(s?.(),s=void 0),{signal:t.signal,dispose:()=>{s&&(s(),s=void 0)}}}function et(n){return n.subscribe(()=>{})}function Ti(n){let e=G(0);return{node:e,increment(){let t=e.cache??0;return t>=n?!1:(e.down([[F],[x,t+1]]),!0)},get(){return e.cache??0},atCap(){return(e.cache??0)>=n}}}var ur,No,vi,Ro=q(()=>{"use strict";Le();Z();ye();fe();Zn();vi=lr});var Ve=q(()=>{"use strict";Ro()});function z(n){return{describeKind:"derived",...n}}function Mo(n){return{describeKind:"derived",partial:!0,...n}}function pn(n,e,t){return V([n],(r,s)=>{let o=r[0];if(o==null||o.length===0){s.down([[D]]);return}for(let a of o)s.emit(e(a))},{...z(t),meta:{...J("map"),...t?.meta??{}}})}function hn(n,e,t){return V([n],(r,s)=>{let o=r[0];if(o==null||o.length===0){s.down([[D]]);return}let a=!1;for(let i of o)e(i)&&(s.emit(i),a=!0);a||s.down([[D]])},{...z(t),meta:{...J("filter"),...t?.meta??{}}})}function wi(n,e,t,r){return V([n],(s,o,a)=>{"acc"in a.store||(a.store.acc=t);let i=s[0];if(i==null||i.length===0){o.down([[D]]);return}for(let u of i)a.store.acc=e(a.store.acc,u),o.emit(a.store.acc)},{...z(r),initial:t,resetOnTeardown:!0,meta:{...J("scan",{initial:t}),...r?.meta??{}}})}function ki(n,e,t,r){return V([n],(s,o,a)=>{if("acc"in a.store||(a.store.acc=t),a.terminalDeps[0]===!0){o.emit(a.store.acc),o.down([[N]]);return}let i=s[0];if(i==null||i.length===0){o.down([[D]]);return}for(let u of i)a.store.acc=e(a.store.acc,u)},{...z(r),completeWhenDepsComplete:!1,meta:{...J("reduce",{initial:t}),...r?.meta??{}}})}function mn(n,e,t){return e<=0?V([n],(r,s,o)=>{o.store.completed||(o.store.completed=!0,s.down([[N]]))},{...z(t),completeWhenDepsComplete:!1,meta:{...J("take",{count:e}),...t?.meta??{}}}):V([n],(r,s,o)=>{if("taken"in o.store||(o.store.taken=0),o.store.done){s.down([[D]]);return}if(o.terminalDeps[0]===!0){o.store.done=!0,s.down([[N]]);return}let a=r[0];if(a==null||a.length===0){s.down([[D]]);return}for(let i of a)if(o.store.taken++,s.emit(i),o.store.taken>=e){o.store.done=!0,s.down([[N]]);return}},{...z(t),completeWhenDepsComplete:!1,meta:{...J("take",{count:e}),...t?.meta??{}}})}function Ao(n,e,t){return V([n],(r,s,o)=>{"skipped"in o.store||(o.store.skipped=0);let a=r[0];if(a==null||a.length===0){s.down([[D]]);return}let i=!1;for(let u of a)o.store.skipped++,o.store.skipped<=e||(s.emit(u),i=!0);i||s.down([[D]])},z(t))}function xi(n,e,t){return V([n],(r,s,o)=>{if(o.store.done){s.down([[D]]);return}let a=r[0];if(a==null||a.length===0){s.down([[D]]);return}for(let i of a){if(!e(i)){o.store.done=!0,s.down([[N]]);return}s.emit(i)}},{...z(t),completeWhenDepsComplete:!1})}function Ni(n,e,t){let r=t?.predicate??(a=>a[0]===x),{predicate:s,...o}=t??{};return C(a=>{let i=!1,u=n.subscribe(c=>{if(!i)for(let f of c){if(i)return;f[0]===x?a.emit(f[1]):(f[0]===N||f[0]===_)&&(i=!0,a.down([f]))}}),d=e.subscribe(c=>{if(!i)for(let f of c){if(i)return;if(r(f)){i=!0,a.down([[N]]);return}}});return()=>{u(),d()}},z(o))}function pr(n,e){return mn(n,1,e)}function Oi(n,e){let{defaultValue:t,...r}=e??{},s=e!=null&&Object.hasOwn(e,"defaultValue");return V([n],(o,a,i)=>{if(i.terminalDeps[0]===!0){i.store.has?a.emit(i.store.latest):s&&a.emit(t),a.down([[N]]);return}let u=o[0];if(u==null||u.length===0){a.down([[D]]);return}i.store.latest=u.at(-1),i.store.has=!0},{...z(r),completeWhenDepsComplete:!1})}function _i(n,e,t){return mn(hn(n,e,t),1,t)}function Si(n,e,t){return mn(Ao(n,e,t),1,t)}function Ei(n,e,t){if(typeof e=="function")return V([n],(s,o)=>{let a=s[0];if(a==null||a.length===0){o.down([[D]]);return}for(let i of a)e(i),o.emit(i)},{...z(t),meta:{...J("tap"),...t?.meta??{}}});let r=e;return V([n],(s,o,a)=>{if(a.terminalDeps[0]!==void 0){a.terminalDeps[0]===!0?(r.complete?.(),o.down([[N]])):(r.error?.(a.terminalDeps[0]),o.down([[_,a.terminalDeps[0]]]));return}let i=s[0];if(i==null||i.length===0){o.down([[D]]);return}for(let u of i)r.data?.(u),o.emit(u)},{...z(t),completeWhenDepsComplete:!1,meta:{...J("tap"),...t?.meta??{}}})}function Co(n,e,t){let r=t?.where??(o=>o!=null),s=!1;return V([n],(o,a)=>{let i=o[0];if(i==null||i.length===0){a.down([[D]]);return}for(let u of i)!s&&r(u)&&(s=!0,e(u)),a.emit(u)},z(t))}function Mi(n,e=Object.is,t){return V([n],(r,s,o)=>{let a=r[0];if(a==null||a.length===0){s.down([[D]]);return}let i=!1;for(let u of a)o.store.hasPrev&&e(o.store.prev,u)||(o.store.prev=u,o.store.hasPrev=!0,s.emit(u),i=!0);i||s.down([[D]])},{...z(t),meta:{...J("distinctUntilChanged"),...t?.meta??{}}})}function Ai(n,e){return V([n],(t,r,s)=>{let o=t[0];if(o==null||o.length===0){r.down([[D]]);return}let a=!1;for(let i of o)if(!s.store.hasPrev)s.store.prev=i,s.store.hasPrev=!0;else{let u=[s.store.prev,i];s.store.prev=i,r.emit(u),a=!0}a||r.down([[D]])},z(e))}function Do(...n){let e=[...n];return he(e,t=>t,{...z(),equals:(t,r)=>{if(t.length!==r.length)return!1;for(let s=0;s<t.length;s++)if(!Object.is(t[s],r[s]))return!1;return!0}})}function Ci(n,e,t){return V([n,e],(r,s,o)=>{let a=r[0],i=r[1],u=i!=null&&i.length>0?i.at(-1):o.prevData[1];if(a!=null&&a.length>0){if(!(i!=null&&i.length>0)&&o.prevData[1]===void 0){s.down([[D]]);return}for(let d of a)s.emit([d,u])}else s.down([[D]])},{...Mo(t),meta:{...J("withLatestFrom"),...t?.meta??{}}})}function Kt(...n){return n.length===0?C(e=>{e.down([[N]])},{...z(),meta:{...J("merge")}}):C(e=>{let t=n.length,r=0,s=[];for(let o of n){let a=o.subscribe(i=>{for(let u of i)u[0]===x?e.emit(u[1]):u[0]===N?(r+=1,r>=t&&e.down([[N]])):u[0]===_&&e.down([u])});s.push(a)}return()=>{for(let o of s)o()}},{...z(),meta:{...J("merge")}})}function Di(...n){let e=n.length;return e===0?C(t=>{t.emit([]),t.down([[N]])},z()):C(t=>{let r=Array.from({length:e},()=>[]),s=e;function o(){for(;r.every(i=>i.length>0);){let i=r.map(u=>u.shift());t.emit(i)}}let a=[];for(let i=0;i<e;i++){let u=i,d=n[i].subscribe(c=>{for(let f of c)f[0]===x?(r[u].push(f[1]),o()):f[0]===N?(s-=1,(s===0||r[u].length===0)&&t.down([[N]])):f[0]===_&&t.down([f])});a.push(d)}return()=>{for(let i of a)i()}},z())}function Pi(n,e,t){return C(r=>{let s=0,o=[],a,i;return i=e.subscribe(u=>{for(let d of u)s===0?d[0]===x?o.push(d[1]):d[0]===_&&r.down([d]):d[0]===x?r.emit(d[1]):(d[0]===N||d[0]===_)&&r.down([d])}),a=n.subscribe(u=>{for(let d of u)if(s===0)if(d[0]===x)r.emit(d[1]);else if(d[0]===N){s=1;for(let c of o)r.emit(c);o.length=0}else d[0]===_&&r.down([d])}),()=>{a?.(),i?.()}},z(t))}function Li(...n){return n.length===0?C(e=>{e.down([[N]])},z()):n.length===1?V([n[0]],(e,t)=>{let r=e[0];if(r==null||r.length===0){t.down([[D]]);return}for(let s of r)t.emit(s)},z()):C(e=>{let t=null,r=[];for(let s=0;s<n.length;s++){let o=s,a=n[s].subscribe(i=>{for(let u of i){if(t!==null&&o!==t)return;u[0]===x?(t===null&&(t=o),e.emit(u[1])):(u[0]===N||u[0]===_)&&(t===null||o===t)&&e.down([u])}});r.push(a)}return()=>{for(let s of r)s()}},z())}function gn(n,e,t){let r,s=!1,o=()=>{s||(s=!0,t())};return r=n.subscribe(a=>{let i=!1,u=!1;for(let d of a)d[0]!==Fe&&(d[0]===x?e.emit(d[1]):d[0]===N?i=!0:d[0]===_?(u=!0,e.down([d])):(d[0]===F||d[0]===D)&&e.down([d]));u?(r?.(),r=void 0,o()):i&&o()}),()=>{r?.(),r=void 0}}function we(n,e,t){let r,s=!1;function o(){r?.(),r=void 0}return V([n],(a,i,u)=>{if(u.terminalDeps[0]!=null&&u.terminalDeps[0]!==!0){o();return}if(u.terminalDeps[0]===!0){s=!0,r||i.down([[N]]);return}let d=a[0];if(!(d==null||d.length===0))return o(),r=gn(oe(e(d[d.length-1])),i,()=>{o(),s&&i.down([[N]])}),{deactivate:()=>{o(),s=!1}}},{...z(t),completeWhenDepsComplete:!1,meta:{...J("switchMap"),...t?.meta??{}}})}function Ii(n,e,t){let r,s=!1;function o(){r?.(),r=void 0}return V([n],(a,i,u)=>{if(u.terminalDeps[0]!=null&&u.terminalDeps[0]!==!0){o();return}if(u.terminalDeps[0]===!0){s=!0,r||i.down([[N]]);return}let d=a[0];if(!(d==null||d.length===0))return r===void 0?r=gn(oe(e(d[0])),i,()=>{o(),s&&i.down([[N]])}):i.down([[D]]),{deactivate:()=>{o(),s=!1}}},{...z(t),completeWhenDepsComplete:!1})}function Bi(n,e,t){let{maxBuffer:r,...s}=t??{},o=[],a,i=!1,u;function d(){a?.(),a=void 0}function c(){if(!u||a!==void 0)return;if(o.length===0){i&&u.down([[N]]);return}let l=o.shift();a=gn(oe(e(l)),u,()=>{d(),c()})}function f(l){r&&r>0&&o.length>=r&&o.shift(),o.push(l),c()}return V([n],(l,p,h)=>{if(u=p,h.terminalDeps[0]!=null&&h.terminalDeps[0]!==!0){d(),o.length=0;return}if(h.terminalDeps[0]===!0){i=!0,c();return}let g=l[0];if(!(g==null||g.length===0)){for(let m of g)f(m);return{deactivate:()=>{d(),o.length=0,i=!1}}}},{...z(s),completeWhenDepsComplete:!1})}function Po(n,e,t){let{concurrent:r,...s}=t??{},o=r!=null&&r>0?r:Number.POSITIVE_INFINITY,a=0,i=!1,u=new Set,d=[],c;function f(){i&&a===0&&d.length===0&&c&&c.down([[N]])}function l(m){if(!c)return;a++;let b;b=gn(oe(e(m)),c,()=>{b&&u.delete(b),a--,p(),f()}),u.add(b)}function p(){for(;d.length>0&&a<o;)l(d.shift())}function h(m){a<o?l(m):d.push(m)}function g(){for(let m of u)m();u.clear(),a=0,d.length=0}return V([n],(m,b,y)=>{if(c=b,y.terminalDeps[0]!=null&&y.terminalDeps[0]!==!0){g();return}if(y.terminalDeps[0]===!0){i=!0,f();return}let v=m[0];if(!(v==null||v.length===0)){for(let T of v)h(T);return{deactivate:()=>{g(),i=!1}}}},{...z(s),completeWhenDepsComplete:!1})}function Fi(n,e,t){return C(r=>{let s=new Set;function o(){for(let i of s)clearTimeout(i);s.clear()}let a=n.subscribe(i=>{for(let u of i)if(u[0]===x){let d=setTimeout(()=>{s.delete(d),r.emit(u[1])},e);s.add(d)}else if(u[0]===N){let d=setTimeout(()=>{s.delete(d),r.down([[N]])},e);s.add(d)}else u[0]===_&&(o(),r.down([u]))});return()=>{a(),o()}},z(t))}function Lo(n,e,t){return C(r=>{let s,o;function a(){s!==void 0&&(clearTimeout(s),s=void 0)}let i=n.subscribe(u=>{for(let d of u)d[0]===x?(a(),o=d[1],s=setTimeout(()=>{s=void 0,r.emit(o)},e)):d[0]===N?(s!==void 0&&(a(),r.emit(o)),r.down([[N]])):d[0]===_&&(a(),r.down([d]))});return()=>{i(),a()}},{...z(t),meta:{...J("debounce",{ms:e}),...t?.meta??{}}})}function Io(n,e,t){let{leading:r,trailing:s,...o}=t??{},a=r!==!1,i=s===!0,u=e*1e6;return C(d=>{let c,f=-1/0,l,p=!1;function h(){c!==void 0&&(clearTimeout(c),c=void 0)}let g=n.subscribe(m=>{for(let b of m)if(b[0]===x){let y=b[1],v=re();if(a&&v-f>=u)f=v,d.emit(y),h(),i&&(c=setTimeout(()=>{c=void 0,p&&(f=re(),d.emit(l),p=!1)},e));else if(i&&(l=y,p=!0,c===void 0)){let T=(v-f)/1e6;c=setTimeout(()=>{c=void 0,p&&(f=re(),d.emit(l),p=!1)},Math.max(0,e-T))}}else(b[0]===N||b[0]===_)&&(h(),d.down([b]))});return()=>{g(),h()}},{...z(o),meta:{...J("throttle",{ms:e,leading:a,trailing:i}),...o.meta??{}}})}function Gi(n,e,t){return C(r=>{let s,o=!1,a=!1,i=n.subscribe(d=>{if(!o)for(let c of d){if(o)return;c[0]===x?s={v:c[1]}:c[0]===_?(o=!0,r.down([c])):c[0]===N&&(a=!0,s=void 0)}}),u=e.subscribe(d=>{if(!o)for(let c of d){if(o)return;c[0]===x?s!==void 0&&!a&&r.emit(s.v):c[0]===_?(o=!0,r.down([c])):c[0]===N&&(o=!0,r.down([[N]]))}});return()=>{i(),u()}},z(t))}function zi(n,e,t){return C(r=>{let s,o,a=!1;function i(){s!==void 0&&(clearTimeout(s),s=void 0)}let u=n.subscribe(d=>{for(let c of d)c[0]===x?(o=c[1],a=!0,i(),s=setTimeout(()=>{s=void 0,a&&(a=!1,r.emit(o))},e)):(c[0]===N||c[0]===_)&&(i(),r.down([c]))});return()=>{u(),i()}},z(t))}function Ki(n,e,t){return C(r=>{let s=[],o=n.subscribe(i=>{for(let u of i)u[0]===x?s.push(u[1]):u[0]===N?(s.length>0&&r.emit([...s]),s.length=0,r.down([[N]])):u[0]===_&&r.down([u])}),a=e.subscribe(i=>{for(let u of i)u[0]===x?s.length>0&&(r.emit([...s]),s.length=0):u[0]===N?r.down([[N]]):u[0]===_&&r.down([u])});return()=>{o(),a(),s.length=0}},z(t))}function $i(n,e,t){if(e<=0)throw new RangeError("bufferCount expects count > 0");return C(r=>{let s=[],o=n.subscribe(a=>{for(let i of a)i[0]===x?(s.push(i[1]),s.length>=e&&r.emit(s.splice(0,s.length))):i[0]===N?(s.length>0&&r.emit([...s]),s.length=0,r.down([[N]])):i[0]===_&&r.down([i])});return()=>{o(),s.length=0}},z(t))}function ji(n,e,t){if(e<=0)throw new RangeError("windowCount expects count > 0");return C(r=>{let s,o=0;function a(){let u=C(d=>(s=d.down.bind(d),()=>{s=void 0}),z());o=0,r.emit(u)}let i=n.subscribe(u=>{for(let d of u)d[0]===x?(s||a(),s?.([[x,d[1]]]),o+=1,o>=e&&(s?.([[N]]),s=void 0)):d[0]===N?(s?.([[N]]),s=void 0,r.down([[N]])):d[0]===_&&(s?.([d]),s=void 0,r.down([d]))});return()=>{i(),s?.([[N]]),s=void 0}},z(t))}function Wi(n,e,t){return C(r=>{let s=[],o=setInterval(()=>{s.length>0&&(r.emit([...s]),s.length=0)},e),a=n.subscribe(i=>{for(let u of i)u[0]===x?s.push(u[1]):u[0]===N?(clearInterval(o),s.length>0&&r.emit([...s]),s.length=0,r.down([[N]])):u[0]===_&&(clearInterval(o),r.down([u]))});return()=>{a(),clearInterval(o),s.length=0}},{...z(t),meta:{...J("bufferTime",{ms:e}),...t?.meta??{}}})}function Ui(n,e,t){return C(r=>{let s;function o(){s?.([[N]]),s=void 0}function a(){let d=C(c=>(s=c.down.bind(c),()=>{s=void 0}),z());r.emit(d)}a();let i=setInterval(()=>{o(),a()},e),u=n.subscribe(d=>{for(let c of d)c[0]===x?s?.([[x,c[1]]]):c[0]===N?(clearInterval(i),o(),r.down([[N]])):c[0]===_&&(clearInterval(i),s?.([c]),o(),r.down([c]))});return()=>{u(),clearInterval(i),o()}},z(t))}function Hi(n,e,t){return C(r=>{let s;function o(){s?.([[N]]),s=void 0}function a(){let d=C(c=>(s=c.down.bind(c),()=>{s=void 0}),z());r.emit(d)}let i=n.subscribe(d=>{for(let c of d)c[0]===x?(s||a(),s?.([[x,c[1]]])):c[0]===N?(o(),r.down([[N]])):c[0]===_&&(s?.([c]),s=void 0,r.down([c]))}),u=e.subscribe(d=>{for(let c of d)c[0]===x&&(o(),a())});return()=>{i(),u(),o()}},z(t))}function qi(n,e){return C((t,r)=>{"n"in r.store||(r.store.n=0);let s=setInterval(()=>{t.emit(r.store.n),r.store.n=r.store.n+1},n);return()=>clearInterval(s)},z(e))}function Ji(n,e,t){if(e<=0)throw new RangeError("repeat expects count > 0");return C(r=>{let s=e,o,a=()=>{o?.(),o=n.subscribe(i=>{let u=!1,d=[];for(let c of i)c[0]===N?u=!0:d.push(c);d.length>0&&r.down(d),u&&(o?.(),o=void 0,s-=1,s>0?a():r.down([[N]]))})};return a(),()=>{o?.()}},z(t))}function Yi(n,e){return V([n],(t,r)=>{let s=t[0];if(s==null||s.length===0){r.down([[D]]);return}for(let o of s)r.emit(o)},z(e))}function Bo(n,e,t){return C(r=>{let s=n.subscribe(o=>{for(let a of o)if(a[0]===x)r.emit(a[1]);else if(a[0]===_)try{r.emit(e(a[1]))}catch(i){r.down([[_,i]])}else a[0]===N&&r.down([[N]])});return()=>{s()}},z(t))}function Qi(n,e,t){return V([n,e],(r,s,o)=>{let a=r[1];if(!(a!=null&&a.length>0?a.at(-1):o.prevData[1])){s.down([[D]]);return}let u=r[0];if(u!=null&&u.length>0){for(let d of u)s.emit(d);return}if(a!=null&&a.length>0&&o.prevData[0]!==void 0){s.emit(o.prevData[0]);return}s.down([[D]])},Mo(t))}var Ri,Vi,Xi,Zi,ea,ta,Vo=q(()=>{"use strict";Le();Z();mt();ye();fe();Ve();Ri=Co;Vi=Po;Xi=Do,Zi=Lo,ea=Io,ta=Bo});var Tt=q(()=>{"use strict";Vo()});var Iu={};En(Iu,{CircuitOpenError:()=>wt,ContentAddressedMissError:()=>yn,DEFAULT_AUDIT_GUARD:()=>ts,NS_PER_MS:()=>me,NS_PER_SEC:()=>Oe,NativeIndexBackend:()=>wn,NativeListBackend:()=>kn,NativeLogBackend:()=>vn,NativeMapBackend:()=>bn,NativePubSubBackend:()=>Tn,RateLimiterOverflowError:()=>kt,ResettableTimer:()=>Ie,TimeoutError:()=>xt,appendAudit:()=>Ut,appendLogStorage:()=>os,audit:()=>zi,awaitSettled:()=>bi,budgetGate:()=>Qe,buffer:()=>Ki,bufferCount:()=>$i,bufferTime:()=>Wi,bumpCursor:()=>Tr,cached:()=>gi,canonicalJson:()=>Zo,cascadingCache:()=>eu,catchError:()=>ta,checkpointToRedis:()=>Wa,checkpointToS3:()=>ja,circuitBreaker:()=>gt,combine:()=>Do,combineLatest:()=>Xi,concat:()=>Pi,concatMap:()=>Bi,constant:()=>Kn,contentAddressedStorage:()=>ou,createAuditLog:()=>du,createTransport:()=>it,createWatermarkController:()=>Za,csvRows:()=>Sa,debounce:()=>Lo,debounceTime:()=>Zi,decay:()=>ss,decorrelatedJitter:()=>Un,defer:()=>pi,delay:()=>Fi,deserializeError:()=>Rt,dictKv:()=>Eu,dictSnapshot:()=>Ru,distill:()=>ru,distinctUntilChanged:()=>Mi,domainMeta:()=>ve,elementAt:()=>Si,empty:()=>ci,escapeRegexChar:()=>Oo,exhaustMap:()=>Ii,exponential:()=>jn,externalBundle:()=>Hn,externalProducer:()=>ht,fallback:()=>Ft,fibonacci:()=>Wn,filter:()=>hn,find:()=>_i,first:()=>pr,firstValueFrom:()=>fr,firstWhere:()=>dr,flatMap:()=>Vi,forEach:()=>ot,fromAny:()=>oe,fromAsyncIter:()=>So,fromCSV:()=>_a,fromClickHouseWatch:()=>Ma,fromCron:()=>ii,fromDrizzle:()=>Ya,fromEvent:()=>ai,fromHTTP:()=>Go,fromHTTPPoll:()=>ca,fromHTTPStream:()=>da,fromIter:()=>cr,fromKafka:()=>ka,fromKysely:()=>Qa,fromMCP:()=>pa,fromNATS:()=>Da,fromNDJSON:()=>Ra,fromOTel:()=>ha,fromPrisma:()=>Ja,fromPrometheus:()=>Ta,fromPromise:()=>_o,fromPulsar:()=>Aa,fromRabbitMQ:()=>La,fromRaf:()=>si,fromRedisStream:()=>Na,fromSSE:()=>ua,fromSqlite:()=>Ua,fromSqliteCursor:()=>Ha,fromStatsD:()=>ba,fromSyslog:()=>ma,fromTimer:()=>rt,fromWebSocket:()=>Fo,fromWebSocketReconnect:()=>fa,fromWebhook:()=>ra,globToRegExp:()=>ni,interval:()=>qi,jsonCodec:()=>Ht,jsonCodecFor:()=>Nu,keepalive:()=>et,kvStorage:()=>Nr,last:()=>Oi,lightMutation:()=>cu,linear:()=>$n,lru:()=>Ho,makeHttpError:()=>su,map:()=>pn,matchesAnyPattern:()=>ri,matchesCron:()=>Xn,memoryAppendLog:()=>_u,memoryBackend:()=>Nn,memoryKv:()=>Su,memorySnapshot:()=>Ou,merge:()=>Kt,mergeMap:()=>Po,mergeReactiveLogs:()=>au,nameToSignal:()=>St,ndjsonRows:()=>Ea,never:()=>li,nodeSignal:()=>yi,of:()=>Eo,onFirstData:()=>Co,pairwise:()=>Ai,parseCron:()=>Qn,parsePrometheusText:()=>jo,parseSSEStream:()=>$o,parseStatsD:()=>va,parseSyslog:()=>ga,pausable:()=>Yi,pubsub:()=>mu,race:()=>Li,rateLimiter:()=>yt,reactiveCounter:()=>Ti,reactiveIndex:()=>yu,reactiveList:()=>vu,reactiveLog:()=>yr,reactiveMap:()=>gr,reactiveSink:()=>ae,reduce:()=>ki,registerCursor:()=>fu,registerCursorMap:()=>pu,repeat:()=>Ji,replay:()=>lr,rescue:()=>Bo,resolveBackoffPreset:()=>pt,retry:()=>We,sample:()=>Gi,scan:()=>wi,serializeError:()=>Et,share:()=>mi,shareReplay:()=>vi,signalToName:()=>st,singleFromAny:()=>Tu,singleNodeFromAny:()=>wu,skip:()=>Ao,snapshotStorage:()=>xr,sortJsonValue:()=>xn,stableJsonString:()=>kr,stratify:()=>Mu,switchMap:()=>we,take:()=>mn,takeUntil:()=>Ni,takeWhile:()=>xi,tap:()=>Ei,tapFirst:()=>Ri,throttle:()=>Io,throttleTime:()=>ea,throwError:()=>fi,timeout:()=>vt,toArray:()=>hi,toCSV:()=>Ba,toClickHouse:()=>Va,toFile:()=>Uo,toHTTP:()=>oa,toKafka:()=>xa,toLoki:()=>Ka,toMongo:()=>za,toNATS:()=>Pa,toObservable:()=>hu,toPostgres:()=>Ga,toPulsar:()=>Ca,toRabbitMQ:()=>Ia,toReadableStream:()=>aa,toRedisStream:()=>Oa,toS3:()=>Fa,toSSE:()=>sa,toSSEBytes:()=>ia,toSqlite:()=>qa,toTempo:()=>$a,toWebSocket:()=>la,tokenBucket:()=>Gt,topologyDiff:()=>It,tryIncrementBounded:()=>uu,valve:()=>Qi,verifiable:()=>nu,window:()=>Hi,windowCount:()=>ji,windowTime:()=>Ui,withBreaker:()=>bt,withLatestFrom:()=>Ci,withMaxAttempts:()=>Ur,withStatus:()=>tt,workerBridge:()=>is,workerSelf:()=>as,wrapMutation:()=>lu,zip:()=>Di});module.exports=fs(Iu);Te();Le();Z();ye();fe();Te();Z();fe();function qr(n){return{describeKind:"producer",...n}}function ht(n,e){return C(t=>{let r=!0,s={emit(a){r&&t.emit(a)},error(a){r&&(r=!1,t.down([[_,a]]))},complete(){r&&(r=!1,t.down([[N]]))}},o;try{let a=n(s);o=typeof a=="function"?a:void 0}catch(a){return s.error(a),()=>{r=!1}}return()=>{r=!1;try{o?.()}catch{}}},qr(e))}function Hn(n,e,t){let r=!0,s,o=0,a=0,i={},u=[],d=()=>{let p=s;s=void 0;try{p?.()}catch{}};for(let p of e){let h=t?.name?`${t.name}::${p}`:p,g=t?.channelOpts?.[p],m=C(b=>(o++,()=>{a++,o>0&&a>=o&&a>=e.length&&d()}),qr({...g,name:h}));i[p]=m,u.push(m)}let c={};for(let p of e)c[p]=h=>{r&&i[p].down([[x,h]])};c.error=p=>{r&&(r=!1,$(()=>{for(let h of u)h.down([[_,p]])}),d())},c.complete=()=>{r&&(r=!1,$(()=>{for(let p of u)p.down([[N]])}),d())};let f=n(c);return s=typeof f=="function"?f:void 0,Object.assign(i,{dispose:()=>{r&&(r=!1,$(()=>{for(let p of u)try{p.down([[N]])}catch{}}),d())}})}Tt();Z();ye();fe();Pt();sn();var hr=class{ring;arr;constructor(e){e===Number.POSITIVE_INFINITY||e<=0?(this.arr=[],this.ring=null):(this.ring=new Ge(e),this.arr=null)}get length(){return this.ring!=null?this.ring.size:this.arr.length}push(e){this.ring!=null?this.ring.push(e):this.arr.push(e)}shift(){return this.ring!=null?this.ring.shift():this.arr.shift()}drain(){if(this.ring!=null){let t=this.ring.toArray();return this.ring.clear(),t}let e=this.arr;return this.arr=[],e}};function $t(n){return n instanceof Error?n:new Error(String(n))}function na(n){return n===void 0?null:typeof n=="string"?pt(n):n}function ae(n,e){let{name:t,onTransportError:r,retry:s,backpressure:o,batchSize:a=Number.POSITIVE_INFINITY,flushIntervalMs:i=0,serialize:u,stopOn:d,onUpstreamMessage:c,onDispose:f,send:l,sendBatch:p,ctx:h}=e;if(!l&&!p)throw new Error("reactiveSink: `send` or `sendBatch` must be provided");let g=h,m=Math.max(1,s?.maxAttempts??1),b=na(s?.backoff??(m>1?"exponential":void 0)),y=s?.shouldRetry??(()=>!0),v=p!==void 0||a<Number.POSITIVE_INFINITY||i>0,T=I=>t?`${t}::${I}`:void 0,w=G(void 0,{equals:()=>!1,name:T("sent")}),O=G(null,{name:T("failed")}),k=G(0,{name:T("inFlight")}),S=G(null,{name:T("errors")}),E=v?G(0,{name:T("buffered")}):void 0,R=o?G(!1,{name:T("paused")}):void 0,M=0,L=I=>{M+=I,k.down([[x,M]])},A=I=>{try{r?.(I)}catch{}try{S.down([[x,I]])}catch{}},P=new Set,ue=I=>{P.add(I);let U=()=>P.delete(I);I.then(U,U)},W=(I,U,Y)=>{let ee=b?b(U-1,Y,null):0,ce=ee==null?0:typeof ee=="number"&&ee>0?ee:0,Ce=Math.max(1,Math.ceil(ce/1e6));return new Promise(Q=>{setTimeout(()=>Q(I()),Ce)})},de=I=>I!=null&&typeof I=="object"&&typeof I.then=="function",Ee=I=>{let U;try{U=u?u(I):I}catch(Q){let H=$t(Q);return A({stage:"serialize",error:H,value:I}),O.down([[x,{value:I,error:H,attempts:0}]]),Promise.resolve()}let Y=0,ee=Q=>{L(-1);let H=$t(Q);if(A({stage:"send",error:H,value:I,attempt:Y}),!(Y<m&&y(H,Y))){O.down([[x,{value:I,error:H,attempts:Y}]]);return}return W(Ce,Y,H)},ce=()=>{L(-1),w.down([[x,I]])};function Ce(){Y+=1,L(1);let Q;try{Q=l(U,g)}catch(H){return ee(H)??Promise.resolve()}return de(Q)?Q.then(ce,H=>ee(H)):(ce(),Promise.resolve())}return Ce()},ze=o?.maxBuffer??Number.POSITIVE_INFINITY,Re=new hr(ze),_e,Ke=!1,$e=()=>{E?.down([[x,Re.length]])},Ue=I=>{R&&R.down([[x,I]])},B=o?.strategy??"drop-oldest",X=(I,U)=>{let Y={value:I,payload:U};if(Re.length<ze)return Re.push(Y),$e(),!0;if(B==="drop-oldest"){let ce=Re.shift();return Re.push(Y),$e(),Ue(!0),O.down([[x,{value:ce.value,error:new Error("backpressure: buffer overflow \u2014 dropped oldest"),attempts:0}]]),!0}if(B==="drop-newest")return Ue(!0),O.down([[x,{value:I,error:new Error("backpressure: buffer overflow \u2014 dropped newest"),attempts:0}]]),!1;let ee=new Error("backpressure: buffer overflow");return A({stage:"send",error:ee,value:I}),O.down([[x,{value:I,error:ee,attempts:0}]]),Ue(!0),!1},ke=I=>{let U=0,Y=I.map(Q=>Q.payload),ee=Q=>{L(-1);let H=$t(Q);if(A({stage:"send",error:H,value:I.map(_n=>_n.value),attempt:U}),!(U<m&&y(H,U))){for(let{value:_n}of I)O.down([[x,{value:_n,error:H,attempts:U}]]);return}return W(Ce,U,H)},ce=()=>{L(-1);for(let{value:Q}of I)w.down([[x,Q]])};function Ce(){U+=1,L(1);let Q;try{Q=p(Y,g)}catch(H){return ee(H)??Promise.resolve()}return de(Q)?Q.then(ce,H=>ee(H)):(ce(),Promise.resolve())}return Ce()},He=async I=>{for(let U of I)await xe(U.value,U.payload)},xe=(I,U)=>{let Y=0,ee=Q=>{L(-1);let H=$t(Q);if(A({stage:"send",error:H,value:I,attempt:Y}),!(Y<m&&y(H,Y))){O.down([[x,{value:I,error:H,attempts:Y}]]);return}return W(Ce,Y,H)},ce=()=>{L(-1),w.down([[x,I]])};function Ce(){Y+=1,L(1);let Q;try{Q=l(U,g)}catch(H){return ee(H)??Promise.resolve()}return de(Q)?Q.then(ce,H=>ee(H)):(ce(),Promise.resolve())}return Ce()},j=()=>{if(Ke||Re.length===0)return Promise.resolve();let I=Re.drain();if($e(),Ue(!1),p!==void 0){let Y=ke(I);return ue(Y),Y}let U=He(I);return ue(U),U},ge=()=>{_e!==void 0||Ke||i<=0||(_e=setTimeout(()=>{_e=void 0,j()},i))},Mt=n.subscribe(I=>{for(let U of I){let Y=U[0];if(Y!==x)try{c?.(U)}catch{}if(Y===x){let ee=U[1];if(v){let ce;if(u)try{ce=u(ee)}catch(Q){let H=$t(Q);A({stage:"serialize",error:H,value:ee}),O.down([[x,{value:ee,error:H,attempts:0}]]);continue}else ce=ee;if(!X(ee,ce))continue;Re.length>=a?j():ge()}else{let ce=Ee(ee);ue(ce)}}else be.messageTier(Y)>=3&&v&&(_e!==void 0&&(clearTimeout(_e),_e=void 0),j())}}),Or;if(d){let I=!1;Or=d.subscribe(U=>{if(!I){I=!0;return}U.length>0&&!On&&_r()})}let On=!1,_r=()=>{if(On)return;On=!0,_e!==void 0&&(clearTimeout(_e),_e=void 0),v&&j(),Ke=!0,Or?.(),Mt();let I=U=>{try{U.down([[K]])}catch{}};I(S),I(O),I(w),I(k),E&&I(E),R&&I(R);try{f?.()}catch{}},qt={dispose:_r,sent:w,failed:O,inFlight:k,errors:S};return v&&(qt.buffered=E,qt.flush=async()=>{Ke||(await j(),await Promise.all(P))}),R&&(qt.paused=R),qt}fn();Ve();function Pe(n){return{describeKind:"producer",...n}}function Fo(n,e){let{parse:t,closeOnTeardown:r=!1,...s}=e??{};return C(o=>{let a=!0,i,u=()=>{let b=i;i=void 0,b?.()},d=b=>{a&&(a=!1,o.down([b]),u())},c=(b,y=b)=>{if(a)try{let v=b!==null&&typeof b=="object"&&"data"in b?b.data:b,T=t?t(v,y):v;o.emit(T)}catch(v){d([_,v])}},f=b=>{d([_,b])},l=()=>{d([N])};if(typeof n=="function"){try{if(i=n(c,f,l),typeof i!="function")throw new Error("fromWebSocket register contract violation: register must return cleanup callable")}catch(b){d([_,b])}return()=>{a=!1,u()}}let p=n,h=b=>c(b,b),g=b=>f(b),m=()=>l();return p.addEventListener("message",h),p.addEventListener("error",g),p.addEventListener("close",m),i=()=>{p.removeEventListener("message",h),p.removeEventListener("error",g),p.removeEventListener("close",m),r&&p.close()},()=>{a=!1,u()}},Pe(s))}function ra(n,e){return ht(n,e)}function Go(n,e){let{method:t="GET",headers:r,body:s,transform:o=v=>v.json(),timeoutNs:a=30*1e9,signal:i,completeAfterFetch:u=!1,refetchOnSubscribe:d=!1,...c}=e??{},f=G(0,{name:`${c.name??"http"}/fetchCount`}),l=G(0,{name:`${c.name??"http"}/lastUpdated`}),p=G(!1,{name:`${c.name??"http"}/fetched`}),h=0,g=s!==void 0?typeof s=="string"?s:JSON.stringify(s):void 0,m=v=>{let T=new AbortController,w=!0;if(i?.aborted)return w=!1,v.down([[_,i.reason??new Error("Aborted")]]),()=>{};i?.addEventListener("abort",()=>T.abort(i.reason),{once:!0});let O=setTimeout(()=>T.abort(new Error("Request timeout")),Math.ceil(a/1e6));return fetch(n,{method:t,headers:r,body:g,signal:T.signal}).then(async k=>{if(clearTimeout(O),!w)return;if(!k.ok)throw new Error(`HTTP ${k.status}: ${k.statusText}`);let S=await o(k);w&&($(()=>{h+=1,f.down([[x,h]]),l.down([[x,ne()]]),p.down([[x,!0]]),v.emit(S)}),u&&v.down([[N]]))}).catch(k=>{clearTimeout(O),w&&(k&&k.name==="AbortError"||v.down([[_,k]]))}),()=>{w=!1,T.abort()}},b=C(v=>m({emit:T=>v.emit(T),down:T=>v.down(T)}),{...Pe(c),resubscribable:d});return{...tt(b),fetchCount:f,lastUpdated:l,fetched:p}}function oa(n,e,t){let{method:r="POST",headers:s={"Content-Type":"application/json"},serialize:o=h=>JSON.stringify(h),timeoutNs:a,batchFormat:i="json-array",batchSize:u,flushIntervalMs:d,retry:c,onTransportError:f}=t??{},l=async h=>{let g=a!==void 0?new AbortController:void 0,m;g&&a!==void 0&&(m=setTimeout(()=>g.abort(new Error("Request timeout")),Math.ceil(a/1e6)));try{let b=await fetch(e,{method:r,headers:s,body:h,signal:g?.signal}),y=async()=>{try{await b.arrayBuffer?.()}catch{}};if(!b.ok)throw await y(),new Error(`HTTP ${b.status}: ${b.statusText}`);await y()}finally{m!==void 0&&clearTimeout(m)}};return u!==void 0||d!==void 0?ae(n,{onTransportError:f,retry:c,batchSize:u,flushIntervalMs:d,sendBatch:async h=>{let g;i==="ndjson"?g=h.map(m=>{let b=o(m);return typeof b=="string"?b:new TextDecoder().decode(b)}).join(`
4
+ `):g=JSON.stringify(h),await l(g)}}):ae(n,{onTransportError:f,retry:c,serialize:o,send:async h=>{await l(h)}})}function zo(n){return Symbol.keyFor(n)??n.description??"message"}function Nt(n,e){return typeof n=="string"?n:e(n)}function Ko(n,e){let t=`event: ${n}
5
+ `;if(e!==void 0){let r=e.split(/\r?\n/);for(let s of r)t+=`data: ${s}
6
6
  `}return`${t}
7
- `}function na(n,e){let{serialize:t=p=>{if(p instanceof Error)return p.message;try{return JSON.stringify(p)}catch{return String(p)}},dataEvent:r="data",errorEvent:o="error",completeEvent:s="complete",includeResolved:i=!1,includeDirty:a=!1,keepAliveMs:u,signal:d,eventNameResolver:c=Vo}=e??{},l=new TextEncoder,f;return new ReadableStream({start(p){let h=!1,g,m=()=>{},y=()=>{h||(h=!0,g!==void 0&&clearInterval(g),d?.removeEventListener("abort",v),m(),p.close())};f=y;let b=(T,w)=>{h||p.enqueue(l.encode(Go(T,w)))},v=()=>{h||y()};m=n.subscribe(T=>{for(let w of T){let _=w[0];if(!(ge.isLocalOnly(_)&&!(_===V&&a))){if(_===x){b(r,kt(w[1],t));continue}if(_===S){b(o,kt(w[1],t)),y();return}if(_===N){b(s),y();return}!i&&_===C||b(c(_),w.length>1?kt(w[1],t):void 0)}}}),u!==void 0&&u>0&&(g=setInterval(()=>{h||p.enqueue(l.encode(`: keepalive
7
+ `}function sa(n,e){let{serialize:t=p=>{if(p instanceof Error)return p.message;try{return JSON.stringify(p)}catch{return String(p)}},dataEvent:r="data",errorEvent:s="error",completeEvent:o="complete",includeResolved:a=!1,includeDirty:i=!1,keepAliveMs:u,signal:d,eventNameResolver:c=zo}=e??{},f=new TextEncoder,l;return new ReadableStream({start(p){let h=!1,g,m=()=>{},b=()=>{h||(h=!0,g!==void 0&&clearInterval(g),d?.removeEventListener("abort",v),m(),p.close())};l=b;let y=(T,w)=>{h||p.enqueue(f.encode(Ko(T,w)))},v=()=>{h||b()};m=n.subscribe(T=>{for(let w of T){let O=w[0];if(!(be.isLocalOnly(O)&&!(O===F&&i))){if(O===x){y(r,Nt(w[1],t));continue}if(O===_){y(s,Nt(w[1],t)),b();return}if(O===N){y(o),b();return}!a&&O===D||y(c(O),w.length>1?Nt(w[1],t):void 0)}}}),u!==void 0&&u>0&&(g=setInterval(()=>{h||p.enqueue(f.encode(`: keepalive
8
8
 
9
- `))},u)),d?.aborted?v():d?.addEventListener("abort",v,{once:!0})},cancel(){f?.()}})}function ra(n,e){let{serialize:t=f=>{if(f instanceof Error)return f.message;try{return JSON.stringify(f)}catch{return String(f)}},dataEvent:r="data",errorEvent:o="error",completeEvent:s="complete",includeResolved:i=!1,includeDirty:a=!1,keepAliveMs:u,signal:d,eventNameResolver:c=Vo}=e??{},l=new TextEncoder;return A(f=>{let p=!0,h,g=(b,v)=>{p&&f.emit(l.encode(Go(b,v)))},m=()=>{p&&(p=!1,f.down([[N]]))},y=n.subscribe(b=>{if(p)for(let v of b){let T=v[0];if(!(ge.isLocalOnly(T)&&!(T===V&&a))){if(T===x){g(r,kt(v[1],t));continue}if(T===S){g(o,kt(v[1],t)),p=!1,f.down([[N]]);return}if(T===N){g(s),p=!1,f.down([[N]]);return}!i&&T===C||g(c(T),v.length>1?kt(v[1],t):void 0)}}});return u!==void 0&&u>0&&(h=setInterval(()=>{p&&f.emit(l.encode(`: keepalive
9
+ `))},u)),d?.aborted?v():d?.addEventListener("abort",v,{once:!0})},cancel(){l?.()}})}function ia(n,e){let{serialize:t=l=>{if(l instanceof Error)return l.message;try{return JSON.stringify(l)}catch{return String(l)}},dataEvent:r="data",errorEvent:s="error",completeEvent:o="complete",includeResolved:a=!1,includeDirty:i=!1,keepAliveMs:u,signal:d,eventNameResolver:c=zo}=e??{},f=new TextEncoder;return C(l=>{let p=!0,h,g=(y,v)=>{p&&l.emit(f.encode(Ko(y,v)))},m=()=>{p&&(p=!1,l.down([[N]]))},b=n.subscribe(y=>{if(p)for(let v of y){let T=v[0];if(!(be.isLocalOnly(T)&&!(T===F&&i))){if(T===x){g(r,Nt(v[1],t));continue}if(T===_){g(s,Nt(v[1],t)),p=!1,l.down([[N]]);return}if(T===N){g(o),p=!1,l.down([[N]]);return}!a&&T===D||g(c(T),v.length>1?Nt(v[1],t):void 0)}}});return u!==void 0&&u>0&&(h=setInterval(()=>{p&&l.emit(f.encode(`: keepalive
10
10
 
11
- `))},u)),d?.aborted?m():d?.addEventListener("abort",m,{once:!0}),()=>{p=!1,h!==void 0&&clearInterval(h),d?.removeEventListener("abort",m),y()}})}function oa(n){let e,t=!1;return new ReadableStream({start(r){e=n.subscribe(o=>{for(let s of o){let i=s[0];if(t)return;if(i===x)try{r.enqueue(s[1])}catch{t=!0,e?.()}else if(i===S){t=!0;try{r.error(s[1])}catch{}return}else if(i===N){t=!0;try{r.close()}catch{}return}}})},cancel(){t=!0,e?.()}})}async function*Fo(n,e){let t=e?.parse??(w=>w),r=e?.signal,o=new TextDecoder,s="",i="message",a=[],u,d,c=[],l=()=>{if(a.length===0&&i==="message"&&u===void 0){a=[];return}let w=a.join(`
12
- `);c.push({event:i,data:t(w),id:u,retry:d}),i="message",a=[],u=void 0,d=void 0},f=w=>{if(w===""){l();return}if(w.startsWith(":"))return;let _=w.indexOf(":"),k=_<0?w:w.slice(0,_),O=_<0?"":w.slice(_+1);switch(O.startsWith(" ")&&(O=O.slice(1)),k){case"event":i=O;break;case"data":a.push(O);break;case"id":O.includes("\0")||(u=O);break;case"retry":{let E=Number(O);Number.isFinite(E)&&(d=E);break}}},p=(w,_)=>{s+=o.decode(w,{stream:!_});let k=s.split(/\r?\n/);s=k.pop()??"";for(let O of k)f(O)},h=n,g=n instanceof ReadableStream?n:h&&typeof h=="object"&&h.body instanceof ReadableStream?h.body:null,m,y,b=!1,v=()=>{b||(b=!0,m&&m.cancel().catch(()=>{}),y&&typeof y.return=="function"&&Promise.resolve(y.return()).catch(()=>{}))},T=()=>{v()};if(r){if(r.aborted)return;r.addEventListener("abort",T,{once:!0})}try{if(g){for(m=g.getReader();!r?.aborted;){let{value:w,done:_}=await m.read();if(_)break;for(p(w,!1);c.length>0;)yield c.shift()}p(new Uint8Array,!0)}else{for(y=n[Symbol.asyncIterator]();!r?.aborted;){let _=await y.next();if(_.done)break;for(p(_.value,!1);c.length>0;)yield c.shift()}p(new Uint8Array,!0)}if(s.trim()){for(let w of s.split(/\r?\n/))f(w);l()}for(;c.length>0;)yield c.shift()}finally{r&&r.removeEventListener("abort",T),v()}}function sa(n,e){let{parse:t,...r}=e??{};return A(o=>{let s=!0,i=new AbortController;return(async()=>{try{for await(let u of Fo(n,{parse:t,signal:i.signal})){if(!s)return;o.emit(u)}s&&o.down([[N]])}catch(u){s&&o.down([[S,u]])}})(),()=>{s=!1,i.abort()}},Ce(r))}function ia(n,e){let{method:t="GET",headers:r,body:o,signal:s,...i}=e??{};return A(a=>{let u=!0,d=new AbortController;if(s?.aborted)return a.down([[S,s.reason??new Error("Aborted")]]),()=>{};s?.addEventListener("abort",()=>d.abort(s.reason),{once:!0});let c=o!==void 0?typeof o=="string"?o:JSON.stringify(o):void 0;return(async()=>{try{let f=await fetch(n,{method:t,headers:r,body:c,signal:d.signal});if(!u)return;if(!f.ok)throw new Error(`HTTP ${f.status}: ${f.statusText}`);if(!f.body)throw new Error("HTTP response has no body");let p=f.body.getReader();for(;u;){let{value:h,done:g}=await p.read();if(g)break;h&&a.emit(h)}u&&a.down([[N]])}catch(f){if(!u||f&&f.name==="AbortError")return;a.down([[S,f]])}})(),()=>{u=!1,d.abort()}},Ce(i))}function aa(n,e){let{intervalMs:t=5e3,...r}=e??{};return we(nt(t,{period:t}),()=>Bo(n,{...r,completeAfterFetch:!0}).node)}function ua(n,e,t){let{serialize:r=y=>{if(typeof y=="string"||y instanceof Blob||y instanceof ArrayBuffer||ArrayBuffer.isView(y))return y;try{return JSON.stringify(y)}catch{return String(y)}},closeOnComplete:o=!0,closeOnError:s=!0,closeCode:i,closeReason:a,onTransportError:u,retry:d,backpressure:c,stopOn:l}=t??{},f=!1,p=y=>{if(!f){f=!0;try{e.close(i,a)}catch(b){let v=b instanceof Error?b:new Error(String(b));try{u?.({stage:"close",error:v,value:void 0,message:y})}catch{}}}},h=null,m=ae(n,{onTransportError:u,serialize:y=>{let b=r(y);if(b===void 0)throw new Error("serialize returned undefined");return b},retry:d,backpressure:c,stopOn:l,onDispose:()=>{if(h){try{e.removeEventListener("close",h)}catch{}h=null}},send:y=>{e.send(y)},onUpstreamMessage:y=>{(y[0]===N&&o||y[0]===S&&s)&&p(y)}});return h=()=>{f=!0,m.dispose()},e.addEventListener("close",h),m}function da(n,e){let{parse:t,maxRetries:r,backoff:o="exponential",closeOnTeardown:s=!0,...i}=e??{};return je(()=>Io(n(),{parse:t,closeOnTeardown:s,...i}),{count:r,backoff:o})}function ca(n,e){let{method:t="notifications/message",onDisconnect:r,...o}=e??{};return ft(({emit:s,error:i})=>(n.setNotificationHandler(t,a=>s(a)),r?.(a=>i(a??new Error("MCP client disconnected"))),()=>n.setNotificationHandler(t,()=>{})),o)}function la(n,e){return $n(({traces:r,metrics:o,logs:s,error:i})=>n({onTraces:a=>{$(()=>{for(let u of a)r(u)})},onMetrics:a=>{$(()=>{for(let u of a)o(u)})},onLogs:a=>{$(()=>{for(let u of a)s(u)})},onError:i})??void 0,["traces","metrics","logs"],e?.name?{name:e.name}:void 0)}function fa(n,e){return ft(n,e)}function pa(n){let e=n.match(/^<(\d{1,3})>\d?\s*(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s*(.*)/s);if(!e){let r=ne();return{facility:1,severity:6,timestamp:new Date(Math.floor(r/1e6)).toISOString(),hostname:"-",appName:"-",procId:"-",msgId:"-",message:n.trim(),timestampNs:r}}let t=Number(e[1]);return{facility:t>>3,severity:t&7,timestamp:e[2],hostname:e[3],appName:e[4],procId:e[5],msgId:e[6],message:(e[7]??"").trim(),timestampNs:ne()}}function ha(n,e){return ft(n,e)}var ma={c:"counter",g:"gauge",ms:"timer",h:"histogram",s:"set",d:"distribution"};function ga(n){let e=n.split("|"),[t,r]=(e[0]??"").split(":");if(!t||r===void 0)throw new Error(`Invalid StatsD line: ${n}`);let o=e[1]?.trim()??"c",s=ma[o]??"counter",i=s==="set"?0:Number(r),a,u={};for(let d=2;d<e.length;d++){let c=e[d].trim();if(c.startsWith("@"))a=Number(c.slice(1));else if(c.startsWith("#"))for(let l of c.slice(1).split(",")){let[f,p]=l.split(":");f&&(u[f]=p??"")}}return{name:t.trim(),value:i,type:s,sampleRate:a,tags:u,timestampNs:ne()}}function ba(n,e){let{intervalNs:t=15*1e9,headers:r,timeoutNs:o=10*1e9,signal:s,maxConsecutiveErrors:i=1}=e??{},a=Math.ceil(t/1e6),u=0;return we(nt(0,{period:a,signal:s}),()=>A(d=>{let c=!0,l=new AbortController,f=setTimeout(()=>l.abort(new Error("Scrape timeout")),Math.ceil(o/1e6));return(async()=>{try{let h=await fetch(n,{headers:{Accept:"text/plain",...r},signal:l.signal});if(clearTimeout(f),!c)return;if(!h.ok)throw new Error(`Prometheus scrape ${h.status}: ${h.statusText}`);let g=await h.text();if(!c)return;let m=zo(g);for(let y of m)d.emit(y);u=0,d.down([[N]])}catch(h){if(clearTimeout(f),!c||h instanceof Error&&h.name==="AbortError")return;u+=1,u>=i&&d.down([[S,h]])}})(),()=>{c=!1,clearTimeout(f),l.abort()}}))}function zo(n){let e=[],t=new Map,r=new Map;for(let o of n.split(`
13
- `)){let s=o.trim();if(!s)continue;if(s.startsWith("# TYPE ")){let f=s.slice(7),p=f.indexOf(" ");p>0&&t.set(f.slice(0,p),f.slice(p+1).trim());continue}if(s.startsWith("# HELP ")){let f=s.slice(7),p=f.indexOf(" ");p>0&&r.set(f.slice(0,p),f.slice(p+1).trim());continue}if(s.startsWith("#"))continue;let i,a={},u,d,c=s.indexOf("{");if(c>=0){i=s.slice(0,c);let f=s.indexOf("}",c);if(f<0)continue;let p=s.slice(c+1,f);a=ya(p);let h=s.slice(f+1).trim().split(/\s+/);u=h[0]??"",d=h[1]}else{let f=s.split(/\s+/);i=f[0]??"",u=f[1]??"",d=f[2]}if(!i||!u)continue;let l=i.replace(/(_total|_count|_sum|_bucket|_created|_info)$/,"");e.push({name:i,labels:a,value:Number(u),timestampMs:d?Number(d):void 0,type:t.get(l)??t.get(i),help:r.get(l)??r.get(i),timestampNs:ne()})}return e}function ya(n){let e={},t=/(\w+)="((?:[^"\\]|\\.)*)"/g,r=t.exec(n);for(;r!==null;)e[r[1]]=r[2].replace(/\\(.)/g,"$1"),r=t.exec(n);return e}function va(n,e,t){let{fromBeginning:r=!1,deserialize:o=i=>{if(i===null)return null;try{return JSON.parse(i.toString())}catch{return i.toString()}},...s}=t??{};return A(i=>{let a=!0;return(async()=>{try{await n.subscribe({topic:e,fromBeginning:r}),await n.run({eachMessage:async({topic:d,partition:c,message:l})=>{if(!a)return;let f={};if(l.headers)for(let[p,h]of Object.entries(l.headers))h!==void 0&&(f[p]=typeof h=="string"?h:h.toString());i.emit({topic:d,partition:c,key:l.key?.toString()??null,value:o(l.value),headers:f,offset:l.offset,timestamp:l.timestamp,timestampNs:ne()})}})}catch(d){a&&i.down([[S,d]])}})(),()=>{a=!1}},Ce(s))}function Ta(n,e,t,r){let{serialize:o=a=>JSON.stringify(a),keyExtractor:s,onTransportError:i}=r??{};return ae(n,{onTransportError:i,send:async a=>{let u=s?.(a)??null,d=o(a);await e.send({topic:t,messages:[{key:u,value:Buffer.from(d)}]})}})}function wa(n,e,t){let{blockMs:r=5e3,startId:o="$",parse:s=a=>{for(let d=0;d<a.length;d+=2)if(a[d]==="data")try{return JSON.parse(a[d+1])}catch{return a[d+1]}let u={};for(let d=0;d<a.length;d+=2)u[a[d]]=a[d+1];return u},...i}=t??{};return A(a=>{let u=!0,d=o;return(async()=>{for(;u;)try{let l=await n.xread("BLOCK",r,"STREAMS",e,d);if(!u)return;if(l)for(let[f,p]of l)for(let[h,g]of p)d=h,a.emit({id:h,key:e,data:s(g),timestampNs:ne()})}catch(l){if(!u)return;a.down([[S,l]]);return}})(),()=>{u=!1}},Ce(i))}function ka(n,e,t,r){let{serialize:o=a=>["data",JSON.stringify(a)],maxLen:s,onTransportError:i}=r??{};return ae(n,{onTransportError:i,send:async a=>{let u=o(a);await(s!==void 0?e.xadd(t,"MAXLEN","~",String(s),"*",...u):e.xadd(t,"*",...u))}})}function xa(n,e){let{delimiter:t=",",hasHeader:r=!0,columns:o,parseLine:s,...i}=e??{},a=s??(u=>Ko(u,t));return A(u=>{let d=!1;return(async()=>{try{let l=o,f="";for await(let p of n){if(d)return;f+=p;let h=f.split(/\r?\n/);f=h.pop()??"";for(let g of h){if(d)return;if(!g.trim())continue;let m=a(g);if(!l&&r){l=m;continue}l||(l=m.map((b,v)=>`col${v}`));let y={};for(let b=0;b<l.length;b++)y[l[b]]=m[b]??"";u.emit(y)}}if(!d&&f.trim()){let p=a(f);if(l){let h={};for(let g=0;g<l.length;g++)h[l[g]]=p[g]??"";u.emit(h)}}d||u.down([[N]])}catch(l){d||u.down([[S,l]])}})(),()=>{d=!0}},Ce(i))}function Na(n,e){let{delimiter:t=",",hasHeader:r=!0,columns:o,parseLine:s,...i}=e??{},a=s??(u=>Ko(u,t));return B([n],(u,d,c)=>{let l=u[0];if(l==null||l.length===0)return;let f=c.store;typeof f.buffer!="string"&&(f.buffer=""),f.headers===void 0&&o&&(f.headers=o.slice());for(let p of l){f.buffer=f.buffer+p;let h=f.buffer.split(/\r?\n/);f.buffer=h.pop()??"";for(let g of h){if(!g.trim())continue;let m=a(g);if(!f.headers&&r){f.headers=m;continue}f.headers||(f.headers=m.map((b,v)=>`col${v}`));let y={};for(let b=0;b<f.headers.length;b++)y[f.headers[b]]=m[b]??"";d.emit(y)}}},{describeKind:"derived",...i})}function _a(n,e){return B([n],(t,r,o)=>{let s=t[0];if(s==null||s.length===0)return;let i=o.store;typeof i.buffer!="string"&&(i.buffer="");for(let a of s){i.buffer=i.buffer+a;let u=i.buffer.split(/\r?\n/);i.buffer=u.pop()??"";for(let d of u)if(d.trim())try{r.emit(JSON.parse(d))}catch(c){r.down([[S,c]]);return}}},{describeKind:"derived",...e??{}})}function Ko(n,e){let t=[],r="",o=!1;for(let s=0;s<n.length;s++){let i=n[s];o?i==='"'?n[s+1]==='"'?(r+='"',s++):o=!1:r+=i:i==='"'?o=!0:i===e?(t.push(r),r=""):r+=i}return t.push(r),t}function Sa(n,e){return A(t=>{let r=!1;return(async()=>{try{let s="";for await(let i of n){if(r)return;s+=i;let a=s.split(/\r?\n/);s=a.pop()??"";for(let u of a){if(r)return;let d=u.trim();d&&t.emit(JSON.parse(d))}}!r&&s.trim()&&t.emit(JSON.parse(s.trim())),r||t.down([[N]])}catch(s){r||t.down([[S,s]])}})(),()=>{r=!0}},Ce(e))}function Oa(n,e,t){let{intervalNs:r=5*1e9,format:o="JSONEachRow",signal:s,maxConsecutiveErrors:i=1}=t??{},a=Math.ceil(r/1e6),u=0;return we(nt(0,{period:a,signal:s}),()=>A(d=>{let c=!0;return(async()=>{try{let f=await n.query({query:e,format:o});if(!c)return;let p=await f.json();if(!c)return;for(let h of p)d.emit(h);u=0,d.down([[N]])}catch(f){if(!c)return;u+=1,u>=i&&d.down([[S,f]])}})(),()=>{c=!1}}))}function Ea(n,e){let{autoAck:t=!0,deserialize:r=a=>{try{return JSON.parse(a.toString())}catch{return a.toString()}},onAckError:o,...s}=e??{},i=a=>{if(o)try{o(a instanceof Error?a:new Error(String(a)))}catch{}};return A(a=>{let u=!0;return(async()=>{for(;u;)try{let c=await n.receive();if(!u)return;let l={topic:c.getTopicName(),messageId:c.getMessageId().toString(),key:c.getPartitionKey(),value:r(c.getData()),properties:c.getProperties(),publishTime:c.getPublishTimestamp(),eventTime:c.getEventTimestamp(),timestampNs:ne()};if(t)a.emit(l),n.acknowledge(c).catch(i);else{let f=!1,p={value:l,ack(){f||(f=!0,n.acknowledge(c).catch(i))},nack(h){if(f)return;f=!0;let g=n;try{let m=g.negativeAcknowledge?.(c);m&&typeof m.then=="function"&&m.catch(i)}catch(m){i(m)}}};a.emit(p)}}catch(c){u&&a.down([[S,c]]);return}})(),()=>{u=!1}},Ce(s))}function Ra(n,e,t){let{serialize:r=a=>Buffer.from(JSON.stringify(a)),keyExtractor:o,propertiesExtractor:s,onTransportError:i}=t??{};return ae(n,{onTransportError:i,send:async a=>{await e.send({data:r(a),partitionKey:o?.(a),properties:s?.(a)})}})}function Ma(n,e,t){let r=new TextDecoder,{queue:o,deserialize:s=a=>{let u=r.decode(a);try{return JSON.parse(u)}catch{return u}},...i}=t??{};return A(a=>{let u=!0,d=n.subscribe(e,o?{queue:o}:void 0);return(async()=>{try{for await(let l of d){if(!u)return;let f={};if(l.headers)for(let p of l.headers.keys())f[p]=l.headers.get(p);a.emit({subject:l.subject,data:s(l.data),headers:f,reply:l.reply,sid:l.sid,timestampNs:ne()})}u&&a.down([[N]])}catch(l){u&&a.down([[S,l]])}})(),()=>{u=!1}},Ce(i))}function Aa(n,e,t,r){let o=new TextEncoder,{serialize:s=a=>o.encode(JSON.stringify(a)),onTransportError:i}=r??{};return ae(n,{onTransportError:i,send:a=>{e.publish(t,s(a))}})}function Ca(n,e,t){let{autoAck:r=!0,deserialize:o=u=>{try{return JSON.parse(u.toString())}catch{return u.toString()}},onAckError:s,...i}=t??{},a=u=>{if(s)try{s(u instanceof Error?u:new Error(String(u)))}catch{}};return A(u=>{let d=!0,c;return(async()=>{try{c=(await n.consume(e,p=>{if(!d)return;if(p===null){d&&u.down([[S,new Error("Consumer cancelled by broker")]]);return}let h={queue:e,routingKey:p.fields.routingKey,exchange:p.fields.exchange,content:o(p.content),properties:p.properties,deliveryTag:p.fields.deliveryTag,redelivered:p.fields.redelivered,timestampNs:ne()};if(r){u.emit(h);try{n.ack(p)}catch(g){a(g)}}else{let g=!1,m=n,y={value:h,ack(){if(!g){g=!0;try{n.ack(p)}catch(b){a(b)}}},nack(b){if(g)return;g=!0;let v=b?.requeue;if(!m.nack){a(new Error("RabbitMQ channel does not expose `nack`; cannot negative-ack"));return}try{m.nack(p,!1,v)}catch(T){a(T)}}};u.emit(y)}},{noAck:!1})).consumerTag}catch(f){d&&u.down([[S,f]])}})(),()=>{d=!1,c!==void 0&&n.cancel(c)}},Ce(i))}function Pa(n,e,t,r){let{serialize:o=a=>Buffer.from(JSON.stringify(a)),routingKeyExtractor:s=()=>"",onTransportError:i}=r??{};return ae(n,{onTransportError:i,send:a=>{let u=s(a),d=o(a);e.publish(t,u,d)}})}function $o(n,e,t){let{serialize:r=l=>`${JSON.stringify(l)}
14
- `,flushIntervalMs:o=0,batchSize:s=Number.POSITIVE_INFINITY,onTransportError:i,mode:a}=t??{},d=o>0||s<Number.POSITIVE_INFINITY?ae(n,{onTransportError:i,batchSize:s,flushIntervalMs:o,serialize:r,sendBatch:l=>{e.write(l.join(""))}}):ae(n,{onTransportError:i,serialize:r,send:l=>{e.write(l)}}),c=d.dispose;return d.dispose=()=>{c();try{e.end()}catch{}},d}function lr(n,e){return n.includes(e)||n.includes('"')||n.includes(`
15
- `)?`"${n.replace(/"/g,'""')}"`:n}function Da(n,e,t){let{columns:r,delimiter:o=",",writeHeader:s=!0,cellExtractor:i=(p,h)=>String(p[h]??""),flushIntervalMs:a=0,batchSize:u=Number.POSITIVE_INFINITY,onTransportError:d,...c}=t,l=!1;return $o(n,e,{serialize:p=>{if(!l&&s){l=!0;let h=r.map(m=>lr(m,o)).join(o),g=r.map(m=>lr(i(p,m),o)).join(o);return`${h}
11
+ `))},u)),d?.aborted?m():d?.addEventListener("abort",m,{once:!0}),()=>{p=!1,h!==void 0&&clearInterval(h),d?.removeEventListener("abort",m),b()}})}function aa(n){let e,t=!1;return new ReadableStream({start(r){e=n.subscribe(s=>{for(let o of s){let a=o[0];if(t)return;if(a===x)try{r.enqueue(o[1])}catch{t=!0,e?.()}else if(a===_){t=!0;try{r.error(o[1])}catch{}return}else if(a===N){t=!0;try{r.close()}catch{}return}}})},cancel(){t=!0,e?.()}})}async function*$o(n,e){let t=e?.parse??(w=>w),r=e?.signal,s=new TextDecoder,o="",a="message",i=[],u,d,c=[],f=()=>{if(i.length===0&&a==="message"&&u===void 0){i=[];return}let w=i.join(`
12
+ `);c.push({event:a,data:t(w),id:u,retry:d}),a="message",i=[],u=void 0,d=void 0},l=w=>{if(w===""){f();return}if(w.startsWith(":"))return;let O=w.indexOf(":"),k=O<0?w:w.slice(0,O),S=O<0?"":w.slice(O+1);switch(S.startsWith(" ")&&(S=S.slice(1)),k){case"event":a=S;break;case"data":i.push(S);break;case"id":S.includes("\0")||(u=S);break;case"retry":{let E=Number(S);Number.isFinite(E)&&(d=E);break}}},p=(w,O)=>{o+=s.decode(w,{stream:!O});let k=o.split(/\r?\n/);o=k.pop()??"";for(let S of k)l(S)},h=n,g=n instanceof ReadableStream?n:h&&typeof h=="object"&&h.body instanceof ReadableStream?h.body:null,m,b,y=!1,v=()=>{y||(y=!0,m&&m.cancel().catch(()=>{}),b&&typeof b.return=="function"&&Promise.resolve(b.return()).catch(()=>{}))},T=()=>{v()};if(r){if(r.aborted)return;r.addEventListener("abort",T,{once:!0})}try{if(g){for(m=g.getReader();!r?.aborted;){let{value:w,done:O}=await m.read();if(O)break;for(p(w,!1);c.length>0;)yield c.shift()}p(new Uint8Array,!0)}else{for(b=n[Symbol.asyncIterator]();!r?.aborted;){let O=await b.next();if(O.done)break;for(p(O.value,!1);c.length>0;)yield c.shift()}p(new Uint8Array,!0)}if(o.trim()){for(let w of o.split(/\r?\n/))l(w);f()}for(;c.length>0;)yield c.shift()}finally{r&&r.removeEventListener("abort",T),v()}}function ua(n,e){let{parse:t,...r}=e??{};return C(s=>{let o=!0,a=new AbortController;return(async()=>{try{for await(let u of $o(n,{parse:t,signal:a.signal})){if(!o)return;s.emit(u)}o&&s.down([[N]])}catch(u){o&&s.down([[_,u]])}})(),()=>{o=!1,a.abort()}},Pe(r))}function da(n,e){let{method:t="GET",headers:r,body:s,signal:o,...a}=e??{};return C(i=>{let u=!0,d=new AbortController;if(o?.aborted)return i.down([[_,o.reason??new Error("Aborted")]]),()=>{};o?.addEventListener("abort",()=>d.abort(o.reason),{once:!0});let c=s!==void 0?typeof s=="string"?s:JSON.stringify(s):void 0;return(async()=>{try{let l=await fetch(n,{method:t,headers:r,body:c,signal:d.signal});if(!u)return;if(!l.ok)throw new Error(`HTTP ${l.status}: ${l.statusText}`);if(!l.body)throw new Error("HTTP response has no body");let p=l.body.getReader();for(;u;){let{value:h,done:g}=await p.read();if(g)break;h&&i.emit(h)}u&&i.down([[N]])}catch(l){if(!u||l&&l.name==="AbortError")return;i.down([[_,l]])}})(),()=>{u=!1,d.abort()}},Pe(a))}function ca(n,e){let{intervalMs:t=5e3,...r}=e??{};return we(rt(t,{period:t}),()=>Go(n,{...r,completeAfterFetch:!0}).node)}function la(n,e,t){let{serialize:r=b=>{if(typeof b=="string"||b instanceof Blob||b instanceof ArrayBuffer||ArrayBuffer.isView(b))return b;try{return JSON.stringify(b)}catch{return String(b)}},closeOnComplete:s=!0,closeOnError:o=!0,closeCode:a,closeReason:i,onTransportError:u,retry:d,backpressure:c,stopOn:f}=t??{},l=!1,p=b=>{if(!l){l=!0;try{e.close(a,i)}catch(y){let v=y instanceof Error?y:new Error(String(y));try{u?.({stage:"close",error:v,value:void 0,message:b})}catch{}}}},h=null,m=ae(n,{onTransportError:u,serialize:b=>{let y=r(b);if(y===void 0)throw new Error("serialize returned undefined");return y},retry:d,backpressure:c,stopOn:f,onDispose:()=>{if(h){try{e.removeEventListener("close",h)}catch{}h=null}},send:b=>{e.send(b)},onUpstreamMessage:b=>{(b[0]===N&&s||b[0]===_&&o)&&p(b)}});return h=()=>{l=!0,m.dispose()},e.addEventListener("close",h),m}function fa(n,e){let{parse:t,maxRetries:r,backoff:s="exponential",closeOnTeardown:o=!0,...a}=e??{};return We(()=>Fo(n(),{parse:t,closeOnTeardown:o,...a}),{count:r,backoff:s})}function pa(n,e){let{method:t="notifications/message",onDisconnect:r,...s}=e??{};return ht(({emit:o,error:a})=>(n.setNotificationHandler(t,i=>o(i)),r?.(i=>a(i??new Error("MCP client disconnected"))),()=>n.setNotificationHandler(t,()=>{})),s)}function ha(n,e){return Hn(({traces:r,metrics:s,logs:o,error:a})=>n({onTraces:i=>{$(()=>{for(let u of i)r(u)})},onMetrics:i=>{$(()=>{for(let u of i)s(u)})},onLogs:i=>{$(()=>{for(let u of i)o(u)})},onError:a})??void 0,["traces","metrics","logs"],e?.name?{name:e.name}:void 0)}function ma(n,e){return ht(n,e)}function ga(n){let e=n.match(/^<(\d{1,3})>\d?\s*(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s*(.*)/s);if(!e){let r=ne();return{facility:1,severity:6,timestamp:new Date(Math.floor(r/1e6)).toISOString(),hostname:"-",appName:"-",procId:"-",msgId:"-",message:n.trim(),timestampNs:r}}let t=Number(e[1]);return{facility:t>>3,severity:t&7,timestamp:e[2],hostname:e[3],appName:e[4],procId:e[5],msgId:e[6],message:(e[7]??"").trim(),timestampNs:ne()}}function ba(n,e){return ht(n,e)}var ya={c:"counter",g:"gauge",ms:"timer",h:"histogram",s:"set",d:"distribution"};function va(n){let e=n.split("|"),[t,r]=(e[0]??"").split(":");if(!t||r===void 0)throw new Error(`Invalid StatsD line: ${n}`);let s=e[1]?.trim()??"c",o=ya[s]??"counter",a=o==="set"?0:Number(r),i,u={};for(let d=2;d<e.length;d++){let c=e[d].trim();if(c.startsWith("@"))i=Number(c.slice(1));else if(c.startsWith("#"))for(let f of c.slice(1).split(",")){let[l,p]=f.split(":");l&&(u[l]=p??"")}}return{name:t.trim(),value:a,type:o,sampleRate:i,tags:u,timestampNs:ne()}}function Ta(n,e){let{intervalNs:t=15*1e9,headers:r,timeoutNs:s=10*1e9,signal:o,maxConsecutiveErrors:a=1}=e??{},i=Math.ceil(t/1e6),u=0;return we(rt(0,{period:i,signal:o}),()=>C(d=>{let c=!0,f=new AbortController,l=setTimeout(()=>f.abort(new Error("Scrape timeout")),Math.ceil(s/1e6));return(async()=>{try{let h=await fetch(n,{headers:{Accept:"text/plain",...r},signal:f.signal});if(clearTimeout(l),!c)return;if(!h.ok)throw new Error(`Prometheus scrape ${h.status}: ${h.statusText}`);let g=await h.text();if(!c)return;let m=jo(g);for(let b of m)d.emit(b);u=0,d.down([[N]])}catch(h){if(clearTimeout(l),!c||h instanceof Error&&h.name==="AbortError")return;u+=1,u>=a&&d.down([[_,h]])}})(),()=>{c=!1,clearTimeout(l),f.abort()}}))}function jo(n){let e=[],t=new Map,r=new Map;for(let s of n.split(`
13
+ `)){let o=s.trim();if(!o)continue;if(o.startsWith("# TYPE ")){let l=o.slice(7),p=l.indexOf(" ");p>0&&t.set(l.slice(0,p),l.slice(p+1).trim());continue}if(o.startsWith("# HELP ")){let l=o.slice(7),p=l.indexOf(" ");p>0&&r.set(l.slice(0,p),l.slice(p+1).trim());continue}if(o.startsWith("#"))continue;let a,i={},u,d,c=o.indexOf("{");if(c>=0){a=o.slice(0,c);let l=o.indexOf("}",c);if(l<0)continue;let p=o.slice(c+1,l);i=wa(p);let h=o.slice(l+1).trim().split(/\s+/);u=h[0]??"",d=h[1]}else{let l=o.split(/\s+/);a=l[0]??"",u=l[1]??"",d=l[2]}if(!a||!u)continue;let f=a.replace(/(_total|_count|_sum|_bucket|_created|_info)$/,"");e.push({name:a,labels:i,value:Number(u),timestampMs:d?Number(d):void 0,type:t.get(f)??t.get(a),help:r.get(f)??r.get(a),timestampNs:ne()})}return e}function wa(n){let e={},t=/(\w+)="((?:[^"\\]|\\.)*)"/g,r=t.exec(n);for(;r!==null;)e[r[1]]=r[2].replace(/\\(.)/g,"$1"),r=t.exec(n);return e}function ka(n,e,t){let{fromBeginning:r=!1,deserialize:s=a=>{if(a===null)return null;try{return JSON.parse(a.toString())}catch{return a.toString()}},...o}=t??{};return C(a=>{let i=!0;return(async()=>{try{await n.subscribe({topic:e,fromBeginning:r}),await n.run({eachMessage:async({topic:d,partition:c,message:f})=>{if(!i)return;let l={};if(f.headers)for(let[p,h]of Object.entries(f.headers))h!==void 0&&(l[p]=typeof h=="string"?h:h.toString());a.emit({topic:d,partition:c,key:f.key?.toString()??null,value:s(f.value),headers:l,offset:f.offset,timestamp:f.timestamp,timestampNs:ne()})}})}catch(d){i&&a.down([[_,d]])}})(),()=>{i=!1}},Pe(o))}function xa(n,e,t,r){let{serialize:s=i=>JSON.stringify(i),keyExtractor:o,onTransportError:a}=r??{};return ae(n,{onTransportError:a,send:async i=>{let u=o?.(i)??null,d=s(i);await e.send({topic:t,messages:[{key:u,value:Buffer.from(d)}]})}})}function Na(n,e,t){let{blockMs:r=5e3,startId:s="$",parse:o=i=>{for(let d=0;d<i.length;d+=2)if(i[d]==="data")try{return JSON.parse(i[d+1])}catch{return i[d+1]}let u={};for(let d=0;d<i.length;d+=2)u[i[d]]=i[d+1];return u},...a}=t??{};return C(i=>{let u=!0,d=s;return(async()=>{for(;u;)try{let f=await n.xread("BLOCK",r,"STREAMS",e,d);if(!u)return;if(f)for(let[l,p]of f)for(let[h,g]of p)d=h,i.emit({id:h,key:e,data:o(g),timestampNs:ne()})}catch(f){if(!u)return;i.down([[_,f]]);return}})(),()=>{u=!1}},Pe(a))}function Oa(n,e,t,r){let{serialize:s=i=>["data",JSON.stringify(i)],maxLen:o,onTransportError:a}=r??{};return ae(n,{onTransportError:a,send:async i=>{let u=s(i);await(o!==void 0?e.xadd(t,"MAXLEN","~",String(o),"*",...u):e.xadd(t,"*",...u))}})}function _a(n,e){let{delimiter:t=",",hasHeader:r=!0,columns:s,parseLine:o,...a}=e??{},i=o??(u=>Wo(u,t));return C(u=>{let d=!1;return(async()=>{try{let f=s,l="";for await(let p of n){if(d)return;l+=p;let h=l.split(/\r?\n/);l=h.pop()??"";for(let g of h){if(d)return;if(!g.trim())continue;let m=i(g);if(!f&&r){f=m;continue}f||(f=m.map((y,v)=>`col${v}`));let b={};for(let y=0;y<f.length;y++)b[f[y]]=m[y]??"";u.emit(b)}}if(!d&&l.trim()){let p=i(l);if(f){let h={};for(let g=0;g<f.length;g++)h[f[g]]=p[g]??"";u.emit(h)}}d||u.down([[N]])}catch(f){d||u.down([[_,f]])}})(),()=>{d=!0}},Pe(a))}function Sa(n,e){let{delimiter:t=",",hasHeader:r=!0,columns:s,parseLine:o,...a}=e??{},i=o??(u=>Wo(u,t));return V([n],(u,d,c)=>{let f=u[0];if(f==null||f.length===0)return;let l=c.store;typeof l.buffer!="string"&&(l.buffer=""),l.headers===void 0&&s&&(l.headers=s.slice());for(let p of f){l.buffer=l.buffer+p;let h=l.buffer.split(/\r?\n/);l.buffer=h.pop()??"";for(let g of h){if(!g.trim())continue;let m=i(g);if(!l.headers&&r){l.headers=m;continue}l.headers||(l.headers=m.map((y,v)=>`col${v}`));let b={};for(let y=0;y<l.headers.length;y++)b[l.headers[y]]=m[y]??"";d.emit(b)}}},{describeKind:"derived",...a})}function Ea(n,e){return V([n],(t,r,s)=>{let o=t[0];if(o==null||o.length===0)return;let a=s.store;typeof a.buffer!="string"&&(a.buffer="");for(let i of o){a.buffer=a.buffer+i;let u=a.buffer.split(/\r?\n/);a.buffer=u.pop()??"";for(let d of u)if(d.trim())try{r.emit(JSON.parse(d))}catch(c){r.down([[_,c]]);return}}},{describeKind:"derived",...e??{}})}function Wo(n,e){let t=[],r="",s=!1;for(let o=0;o<n.length;o++){let a=n[o];s?a==='"'?n[o+1]==='"'?(r+='"',o++):s=!1:r+=a:a==='"'?s=!0:a===e?(t.push(r),r=""):r+=a}return t.push(r),t}function Ra(n,e){return C(t=>{let r=!1;return(async()=>{try{let o="";for await(let a of n){if(r)return;o+=a;let i=o.split(/\r?\n/);o=i.pop()??"";for(let u of i){if(r)return;let d=u.trim();d&&t.emit(JSON.parse(d))}}!r&&o.trim()&&t.emit(JSON.parse(o.trim())),r||t.down([[N]])}catch(o){r||t.down([[_,o]])}})(),()=>{r=!0}},Pe(e))}function Ma(n,e,t){let{intervalNs:r=5*1e9,format:s="JSONEachRow",signal:o,maxConsecutiveErrors:a=1}=t??{},i=Math.ceil(r/1e6),u=0;return we(rt(0,{period:i,signal:o}),()=>C(d=>{let c=!0;return(async()=>{try{let l=await n.query({query:e,format:s});if(!c)return;let p=await l.json();if(!c)return;for(let h of p)d.emit(h);u=0,d.down([[N]])}catch(l){if(!c)return;u+=1,u>=a&&d.down([[_,l]])}})(),()=>{c=!1}}))}function Aa(n,e){let{autoAck:t=!0,deserialize:r=i=>{try{return JSON.parse(i.toString())}catch{return i.toString()}},onAckError:s,...o}=e??{},a=i=>{if(s)try{s(i instanceof Error?i:new Error(String(i)))}catch{}};return C(i=>{let u=!0;return(async()=>{for(;u;)try{let c=await n.receive();if(!u)return;let f={topic:c.getTopicName(),messageId:c.getMessageId().toString(),key:c.getPartitionKey(),value:r(c.getData()),properties:c.getProperties(),publishTime:c.getPublishTimestamp(),eventTime:c.getEventTimestamp(),timestampNs:ne()};if(t)i.emit(f),n.acknowledge(c).catch(a);else{let l=!1,p={value:f,ack(){l||(l=!0,n.acknowledge(c).catch(a))},nack(h){if(l)return;l=!0;let g=n;try{let m=g.negativeAcknowledge?.(c);m&&typeof m.then=="function"&&m.catch(a)}catch(m){a(m)}}};i.emit(p)}}catch(c){u&&i.down([[_,c]]);return}})(),()=>{u=!1}},Pe(o))}function Ca(n,e,t){let{serialize:r=i=>Buffer.from(JSON.stringify(i)),keyExtractor:s,propertiesExtractor:o,onTransportError:a}=t??{};return ae(n,{onTransportError:a,send:async i=>{await e.send({data:r(i),partitionKey:s?.(i),properties:o?.(i)})}})}function Da(n,e,t){let r=new TextDecoder,{queue:s,deserialize:o=i=>{let u=r.decode(i);try{return JSON.parse(u)}catch{return u}},...a}=t??{};return C(i=>{let u=!0,d=n.subscribe(e,s?{queue:s}:void 0);return(async()=>{try{for await(let f of d){if(!u)return;let l={};if(f.headers)for(let p of f.headers.keys())l[p]=f.headers.get(p);i.emit({subject:f.subject,data:o(f.data),headers:l,reply:f.reply,sid:f.sid,timestampNs:ne()})}u&&i.down([[N]])}catch(f){u&&i.down([[_,f]])}})(),()=>{u=!1}},Pe(a))}function Pa(n,e,t,r){let s=new TextEncoder,{serialize:o=i=>s.encode(JSON.stringify(i)),onTransportError:a}=r??{};return ae(n,{onTransportError:a,send:i=>{e.publish(t,o(i))}})}function La(n,e,t){let{autoAck:r=!0,deserialize:s=u=>{try{return JSON.parse(u.toString())}catch{return u.toString()}},onAckError:o,...a}=t??{},i=u=>{if(o)try{o(u instanceof Error?u:new Error(String(u)))}catch{}};return C(u=>{let d=!0,c;return(async()=>{try{c=(await n.consume(e,p=>{if(!d)return;if(p===null){d&&u.down([[_,new Error("Consumer cancelled by broker")]]);return}let h={queue:e,routingKey:p.fields.routingKey,exchange:p.fields.exchange,content:s(p.content),properties:p.properties,deliveryTag:p.fields.deliveryTag,redelivered:p.fields.redelivered,timestampNs:ne()};if(r){u.emit(h);try{n.ack(p)}catch(g){i(g)}}else{let g=!1,m=n,b={value:h,ack(){if(!g){g=!0;try{n.ack(p)}catch(y){i(y)}}},nack(y){if(g)return;g=!0;let v=y?.requeue;if(!m.nack){i(new Error("RabbitMQ channel does not expose `nack`; cannot negative-ack"));return}try{m.nack(p,!1,v)}catch(T){i(T)}}};u.emit(b)}},{noAck:!1})).consumerTag}catch(l){d&&u.down([[_,l]])}})(),()=>{d=!1,c!==void 0&&n.cancel(c)}},Pe(a))}function Ia(n,e,t,r){let{serialize:s=i=>Buffer.from(JSON.stringify(i)),routingKeyExtractor:o=()=>"",onTransportError:a}=r??{};return ae(n,{onTransportError:a,send:i=>{let u=o(i),d=s(i);e.publish(t,u,d)}})}function Uo(n,e,t){let{serialize:r=f=>`${JSON.stringify(f)}
14
+ `,flushIntervalMs:s=0,batchSize:o=Number.POSITIVE_INFINITY,onTransportError:a,mode:i}=t??{},d=s>0||o<Number.POSITIVE_INFINITY?ae(n,{onTransportError:a,batchSize:o,flushIntervalMs:s,serialize:r,sendBatch:f=>{e.write(f.join(""))}}):ae(n,{onTransportError:a,serialize:r,send:f=>{e.write(f)}}),c=d.dispose;return d.dispose=()=>{c();try{e.end()}catch{}},d}function mr(n,e){return n.includes(e)||n.includes('"')||n.includes(`
15
+ `)?`"${n.replace(/"/g,'""')}"`:n}function Ba(n,e,t){let{columns:r,delimiter:s=",",writeHeader:o=!0,cellExtractor:a=(p,h)=>String(p[h]??""),flushIntervalMs:i=0,batchSize:u=Number.POSITIVE_INFINITY,onTransportError:d,...c}=t,f=!1;return Uo(n,e,{serialize:p=>{if(!f&&o){f=!0;let h=r.map(m=>mr(m,s)).join(s),g=r.map(m=>mr(a(p,m),s)).join(s);return`${h}
16
16
  ${g}
17
- `}return`${r.map(h=>lr(i(p,h),o)).join(o)}
18
- `},flushIntervalMs:a,batchSize:u,onTransportError:d,...c})}function La(n,e,t,r){let{batchSize:o=1e3,flushIntervalMs:s=5e3,format:i="JSONEachRow",transform:a=d=>d,onTransportError:u}=r??{};return ae(n,{onTransportError:u,batchSize:o,flushIntervalMs:s,serialize:a,sendBatch:async d=>{await e.insert({table:t,values:d,format:i})}})}function Ia(n,e,t,r){let{format:o="ndjson",keyGenerator:s=(f,p)=>{let h=Math.floor(p/1e6);return`data/${new Date(h).toISOString().replace(/[:.]/g,"-")}-${f}.${o==="ndjson"?"ndjson":"json"}`},batchSize:i=1e3,flushIntervalMs:a=1e4,transform:u=f=>f,onTransportError:d}=r??{},c=o==="ndjson"?"application/x-ndjson":"application/json",l=0;return ae(n,{onTransportError:d,batchSize:i,flushIntervalMs:a,serialize:u,sendBatch:async f=>{l+=1;let p=o==="ndjson"?`${f.map(g=>JSON.stringify(g)).join(`
17
+ `}return`${r.map(h=>mr(a(p,h),s)).join(s)}
18
+ `},flushIntervalMs:i,batchSize:u,onTransportError:d,...c})}function Va(n,e,t,r){let{batchSize:s=1e3,flushIntervalMs:o=5e3,format:a="JSONEachRow",transform:i=d=>d,onTransportError:u}=r??{};return ae(n,{onTransportError:u,batchSize:s,flushIntervalMs:o,serialize:i,sendBatch:async d=>{await e.insert({table:t,values:d,format:a})}})}function Fa(n,e,t,r){let{format:s="ndjson",keyGenerator:o=(l,p)=>{let h=Math.floor(p/1e6);return`data/${new Date(h).toISOString().replace(/[:.]/g,"-")}-${l}.${s==="ndjson"?"ndjson":"json"}`},batchSize:a=1e3,flushIntervalMs:i=1e4,transform:u=l=>l,onTransportError:d}=r??{},c=s==="ndjson"?"application/x-ndjson":"application/json",f=0;return ae(n,{onTransportError:d,batchSize:a,flushIntervalMs:i,serialize:u,sendBatch:async l=>{f+=1;let p=s==="ndjson"?`${l.map(g=>JSON.stringify(g)).join(`
19
19
  `)}
20
- `:JSON.stringify(f),h=s(l,ne());await e.putObject({Bucket:t,Key:h,Body:p,ContentType:c})}})}function Ba(n,e,t,r){let{toSQL:o=(i,a)=>({sql:`INSERT INTO "${a.replace(/"/g,'""')}" (data) VALUES ($1)`,params:[JSON.stringify(i)]}),onTransportError:s}=r??{};return ae(n,{onTransportError:s,serialize:i=>o(i,t),send:async i=>{let a=i;await e.query(a.sql,a.params)}})}function Va(n,e,t){let{toDocument:r=s=>s,onTransportError:o}=t??{};return ae(n,{onTransportError:o,serialize:r,send:async s=>{await e.insertOne(s)}})}function Ga(n,e,t){let{labels:r={},toLine:o=a=>JSON.stringify(a),toLabels:s,onTransportError:i}=t??{};return ae(n,{onTransportError:i,serialize:a=>({line:o(a),labels:s?{...r,...s(a)}:r}),send:async a=>{let{line:u,labels:d}=a,c=`${ne()}`;await e.push({streams:[{stream:d,values:[[c,u]]}]})}})}function Fa(n,e,t){let{toResourceSpans:r=s=>[s],onTransportError:o}=t??{};return ae(n,{onTransportError:o,serialize:r,send:async s=>{await e.push({resourceSpans:s})}})}function za(n,e,t,r){let{prefix:o="checkpoints/",debounceMs:s=500,compactEvery:i=10,onError:a}=r??{},u={name:`s3:${t}`,debounceMs:s,compactEvery:i,save(d){let c=Math.floor(ne()/1e6),l=`${o}${n.name}/checkpoint-${c}.json`,f;try{f=JSON.stringify(d)}catch(p){a?.(p);return}e.putObject({Bucket:t,Key:l,Body:f,ContentType:"application/json"}).catch(p=>a?.(p))}};return n.attachSnapshotStorage([u],{onError:d=>a?.(d)})}function Ka(n,e,t){let{prefix:r="graphrefly:checkpoint:",debounceMs:o=500,compactEvery:s=10,onError:i}=t??{},a=`${r}${n.name}`,u={name:`redis:${a}`,debounceMs:o,compactEvery:s,save(d){let c;try{c=JSON.stringify(d)}catch(l){i?.(l);return}e.set(a,c).catch(l=>i?.(l))},async load(){let d=await e.get(a);if(d!=null)try{return JSON.parse(d)}catch{return}}};return n.attachSnapshotStorage([u],{onError:d=>i?.(d)})}function $a(n,e,t){let{mapRow:r=i=>i,params:o,...s}=t??{};return A(i=>{try{let u=n.query(e,o).map(r);i.emit(u),i.down([[N]])}catch(a){i.down([[S,a instanceof Error?a:new Error(String(a))]])}},{describeKind:"producer",completeWhenDepsComplete:!1,...s})}function ja(n,e,t){let{mapRow:r=i=>i,params:o,...s}=t??{};return A(i=>{try{let a=n.iterate(e,o);$(()=>{for(let u of a)i.emit(r(u));i.down([[N]])})}catch(a){i.down([[S,a instanceof Error?a:new Error(String(a))]])}},{describeKind:"producer",completeWhenDepsComplete:!1,...s})}function Wa(n,e,t,r){if(t.includes("\0")||t.length===0)throw new Error(`toSqlite: invalid table name: ${JSON.stringify(t)}`);let{toSQL:o=(P,I)=>({sql:`INSERT INTO "${I.replace(/"/g,'""')}" (data) VALUES (?)`,params:[JSON.stringify(P)]}),onTransportError:s,batchInsert:i=!1,maxBatchSize:a=1e3,flushIntervalMs:u=0}=r??{},d=P=>o(P,t);if(!i)return ae(n,{onTransportError:s,serialize:d,send:P=>{let I=P;e.query(I.sql,I.params)}});let c=G(null),l=G(void 0,{equals:()=>!1}),f=G(null),p=G(0),h=G(0),g=P=>{try{s?.(P)}catch{}try{c.down([[x,P]])}catch{}},m=[],y=!1,b,v=!1,T=()=>h.down([[x,m.length]]),w=P=>{v||l.down([[x,P]])},_=P=>{v||f.down([[x,P]])},k=P=>{v||p.down([[x,P]])},O=P=>{v||g(P)},E=()=>{if(m.length===0||y)return;y=!0,k(1);try{e.query("BEGIN",[])}catch(W){y=!1,k(0),O({stage:"send",error:W instanceof Error?W:new Error(String(W)),value:void 0});return}let P=m;m=[],T();let I,ue=0;for(let W of P)try{e.query(W.query.sql,W.query.params),ue+=1}catch(de){I=de instanceof Error?de:new Error(String(de));break}if(I){try{e.query("ROLLBACK",[])}catch{}O({stage:"send",error:I,value:void 0});for(let W of P)_({value:W.value,error:I,attempts:1})}else try{e.query("COMMIT",[]);for(let W of P)w(W.value)}catch(W){let de=W instanceof Error?W:new Error(String(W));O({stage:"send",error:de,value:void 0});for(let Oe=0;Oe<ue;Oe++)_({value:P[Oe].value,error:de,attempts:1})}y=!1,k(0)},R=()=>{u>0&&b===void 0&&!v&&(b=setTimeout(()=>{b=void 0,E()},u))},M=n.subscribe(P=>{for(let I of P){let ue=I[0];if(ue===x){let W=I[1],de;try{de=d(W)}catch(Oe){let Fe=Oe instanceof Error?Oe:new Error(String(Oe));g({stage:"serialize",error:Fe,value:W}),f.down([[x,{value:W,error:Fe,attempts:0}]]);continue}m.push({value:W,query:de}),T(),m.length>=a?E():R()}else ge.messageTier(ue)>=3&&E()}});return{dispose:()=>{if(!v){b!==void 0&&(clearTimeout(b),b=void 0),E(),v=!0,M();for(let P of[c,l,f,p,h])try{P.down([[K]])}catch{}}},sent:l,failed:f,inFlight:p,errors:c,buffered:h,flush:async()=>{v||E()}}}function Ua(n,e){let{args:t,mapRow:r=s=>s,...o}=e??{};return A(s=>{let i=!0;return n.findMany(t).then(a=>{i&&(s.emit(a.map(r)),s.down([[N]]))}).catch(a=>{if(i)try{s.down([[S,a instanceof Error?a:new Error(String(a))]])}catch{}}),()=>{i=!1}},{...o,describeKind:"producer",completeWhenDepsComplete:!1})}function Ha(n,e){let{mapRow:t=o=>o,...r}=e??{};return A(o=>{let s=!0;return n.execute().then(i=>{s&&(o.emit(i.map(t)),o.down([[N]]))}).catch(i=>{if(s)try{o.down([[S,i instanceof Error?i:new Error(String(i))]])}catch{}}),()=>{s=!1}},{...r,describeKind:"producer",completeWhenDepsComplete:!1})}function qa(n,e){let{mapRow:t=o=>o,...r}=e??{};return A(o=>{let s=!0;return n.execute().then(i=>{s&&(o.emit(i.map(t)),o.down([[N]]))}).catch(i=>{if(s)try{o.down([[S,i instanceof Error?i:new Error(String(i))]])}catch{}}),()=>{s=!1}},{...r,describeKind:"producer",completeWhenDepsComplete:!1})}Ct();Z();var Ja=0;function Ya(n,e){if(e.highWaterMark<1)throw new RangeError("highWaterMark must be >= 1");if(e.lowWaterMark<0)throw new RangeError("lowWaterMark must be >= 0");if(e.lowWaterMark>=e.highWaterMark)throw new RangeError("lowWaterMark must be < highWaterMark");let t=Symbol(`bp-${++Ja}`),r=0,o=!1;return{onEnqueue(){return r+=1,!o&&r>=e.highWaterMark?(o=!0,n([[le,t]]),!0):!1},onDequeue(){return r>0&&(r-=1),o&&r<=e.lowWaterMark?(o=!1,n([[pe,t]]),!0):!1},get pending(){return r},get paused(){return o},dispose(){o&&(o=!1,n([[pe,t]]))}}}Z();fe();function jo(){let n=new Map,e=null,t=null;function r(s){s.prev?s.prev.next=s.next:e=s.next,s.next?s.next.prev=s.prev:t=s.prev,s.prev=null,s.next=null}function o(s){s.next=e,s.prev=null,e&&(e.prev=s),e=s,t===null&&(t=s)}return{insert(s){if(n.has(s)){this.touch(s);return}let i={key:s,prev:null,next:null};n.set(s,i),o(i)},touch(s){let i=n.get(s);i&&(r(i),o(i))},delete(s){let i=n.get(s);i&&(r(i),n.delete(s))},evict(s){let i=[];for(let a=0;a<s&&t!==null;a++){let u=t;i.push(u.key),r(u),n.delete(u.key)}return i},size(){return n.size}}}function Wo(n){return n!=null&&typeof n.then=="function"}function xt(n){Wo(n)&&n.catch(()=>{})}function Qa(n,e){let t=new Map,r=e?.maxSize??0,o=r>0?e?.eviction??jo():null,s=e?.writeThrough??!1;function i(d,c,l){for(let f=0;f<l;f++)try{xt(n[f].save(d,c))}catch{}}function a(d,c,l=0){for(let f=l;f<n.length;f++){let p;try{p=n[f].load(d)}catch{continue}if(Wo(p)){let h=f;p.then(g=>{g!==void 0?(c.down([[x,g]]),i(d,g,h)):a(d,c,h+1)},()=>{a(d,c,h+1)});return}if(p!==void 0){c.down([[x,p]]),i(d,p,f);return}}}function u(){if(!(!o||r<=0))for(;o.size()>=r;){let d=o.evict(1);if(d.length===0)break;for(let c of d){let l=t.get(c);if(l){let f=l.cache;if(l.status!=="sentinel"&&n.length>0){let p=n.length-1;try{xt(n[p].save(c,f))}catch{}for(let h=0;h<p;h++)try{let g=n[h].delete;g&&xt(g.call(n[h],c))}catch{}}l.down([[K]])}t.delete(c)}}}return{load(d){let c=t.get(d);if(c)return o?.touch(d),c;o&&r>0&&o.size()>=r&&u();let l=G(void 0);return t.set(d,l),o?.insert(d),a(d,l),l},save(d,c){if(s)for(let f of n)try{xt(f.save(d,c))}catch{}else if(n[0])try{xt(n[0].save(d,c))}catch{}let l=t.get(d);if(l)l.down([[x,c]]),o?.touch(d);else{o&&r>0&&o.size()>=r&&u();let f=G(c);t.set(d,f),o?.insert(d)}},invalidate(d){let c=t.get(d);c&&a(d,c)},delete(d){o?.delete(d);let c=t.get(d);c&&c.down([[K]]),t.delete(d);for(let l of n)try{let f=l.delete;f&&xt(f.call(l,d))}catch{}},has(d){return t.has(d)},get size(){return t.size}}}Te();Z();pt();fe();yt();Te();Pe();Z();fe();var pn=class{_version=0;_store=new Map;_maxSize;_defaultTtl;constructor(e={}){let{maxSize:t,defaultTtl:r}=e;if(t!==void 0&&t<1)throw new RangeError("maxSize must be >= 1");if(r!==void 0&&r<=0)throw new RangeError("defaultTtl must be positive");this._maxSize=t,this._defaultTtl=r}get version(){return this._version}get size(){return this._store.size}has(e){let t=this._store.get(e);return t===void 0?!1:this._isExpired(t)?(this._store.delete(e),this._version+=1,!1):(this._touchLru(e,t),!0)}get(e){let t=this._store.get(e);if(t!==void 0){if(this._isExpired(t)){this._store.delete(e),this._version+=1;return}return this._touchLru(e,t),t.value}}set(e,t,r){let o=this._resolveExpiresAt(r);this._store.has(e)&&this._store.delete(e),this._store.set(e,{value:t,expiresAt:o}),this._evictLruWhileOver(),this._version+=1}setMany(e,t){let r=this._resolveExpiresAt(t),o=0;try{for(let[s,i]of e)this._store.has(s)&&this._store.delete(s),this._store.set(s,{value:i,expiresAt:r}),o+=1}finally{o>0&&(this._evictLruWhileOver(),this._version+=1)}}delete(e){let t=this._store.delete(e);return t&&(this._version+=1),t}deleteMany(e){let t=0;try{for(let r of e)this._store.delete(r)&&(t+=1)}finally{t>0&&(this._version+=1)}return t}clear(){let e=this._store.size;return e===0?0:(this._store.clear(),this._version+=1,e)}pruneExpired(){let e=re(),t=0;for(let[r,o]of this._store)this._isExpired(o,e)&&(this._store.delete(r),t+=1);return t>0&&(this._version+=1),t}toMap(){let e=re(),t=new Map;for(let[r,o]of this._store)this._isExpired(o,e)||t.set(r,o.value);return t}_resolveExpiresAt(e){let t=e??this._defaultTtl;if(t!==void 0){if(!Number.isFinite(t)||t<=0)throw new RangeError(`MapBackend: ttl must be a positive finite number (got ${t})`);return re()+t*1e9}}_isExpired(e,t){return e.expiresAt===void 0?!1:(t??re())>=e.expiresAt}_touchLru(e,t){this._store.delete(e),this._store.set(e,t)}_evictLruWhileOver(){if(this._maxSize!==void 0)for(;this._store.size>this._maxSize;){let e=this._store.keys().next().value;if(e===void 0)break;this._store.delete(e)}}};function fr(n={}){let{name:e,maxSize:t,defaultTtl:r,versioning:o,backend:s,retention:i}=n;if(i&&t!==void 0)throw new RangeError("reactiveMap: `maxSize` (LRU) and `retention` (score-based) are mutually exclusive. Pick one eviction policy.");if(i&&i.archiveThreshold===void 0&&i.maxSize===void 0)throw new RangeError("reactiveMap: `retention` requires at least one of `archiveThreshold` or `maxSize` to trigger archival.");let a=s??new pn({maxSize:t,defaultTtl:r}),u=G(a.toMap(),{name:e,describeKind:"state",equals:(f,p)=>f===p,...o!=null?{versioning:o}:{}});function d(){let f=a.toMap();$(()=>{u.down([[V]]),u.down([[x,f]])})}function c(){if(!i)return;let f=a.toMap(),p=i.archiveThreshold,h=i.maxSize,g=[];for(let[y,b]of f)g.push({key:y,value:b,score:i.score(y,b)});g.sort((y,b)=>y.score-b.score);let m=new Set;if(p!==void 0)for(let y of g)if(y.score<p)m.add(y.key);else break;if(h!==void 0&&g.length-m.size>h)for(let y of g){if(g.length-m.size<=h)break;m.has(y.key)||m.add(y.key)}if(m.size!==0)for(let y of g)m.has(y.key)&&(i.onArchive?.(y.key,y.value,y.score),a.delete(y.key))}function l(f,p="mutation"){let h=a.version;try{return f()}finally{a.version!==h&&(p==="mutation"&&c(),d())}}return{entries:u,has(f){return l(()=>a.has(f),"read")},get(f){return l(()=>a.get(f),"read")},set(f,p,h){l(()=>a.set(f,p,h?.ttl))},setMany(f,p){l(()=>a.setMany(f,p?.ttl))},delete(f){l(()=>a.delete(f))},deleteMany(f){l(()=>a.deleteMany(f))},clear(){l(()=>a.clear())},pruneExpired(){l(()=>a.pruneExpired())},get size(){return a.size},dispose(){}}}Be();function Xa(n){return typeof n=="object"&&n!==null&&"cache"in n&&typeof n.subscribe=="function"}function Za(n,e,t){let r=ie(n),o=r.v!=null,s=G(t?.initialVerified??null,{meta:{...J("verifiable"),...o?{sourceVersion:null}:{}}}),i=t?.trigger!==void 0&&t.trigger!==null,a=null;if(i&&t?.autoVerify?a=Vt(ie(t.trigger),r):i?a=ie(t.trigger):t?.autoVerify&&(a=r),a!==null){let u;if(a===r)u=we(r,d=>e(d));else{let d=r.cache;r.subscribe(c=>{for(let l of c)l[0]===x&&(d=l[1])}),u=we(a,()=>e(d))}rt(u,d=>{$(()=>{if(s.down([[x,d]]),o){let c=r.v;c!=null&&s.meta.sourceVersion.down([[x,{id:c.id,version:c.version}]])}})})}return{node:r,verified:s,trigger:a}}function Uo(n){n.subscribe(()=>{})}function Ft(n){return n instanceof Map?n:new Map}function Ho(n,e){if(!Array.isArray(e.upsert))throw new TypeError("distill extraction requires upsert: Array<{ key, value }>");$(()=>{for(let{key:t,value:r}of e.upsert)n.set(t,r);for(let t of e.remove??[])n.delete(t)})}function eu(n,e,t){let r=ie(n),o=fr(t.mapOptions??{}),s=t.budget??2e3,a=t.context!==void 0&&t.context!==null?ie(t.context):G(null),u=Ft(o.entries.cache);o.entries.subscribe(p=>{for(let h of p)h[0]===x&&(u=Ft(h[1]))});let d=ie(e(r,o.entries));if(rt(d,p=>{Ho(o,p)}),t.evict){let p=new Map,h=ye([o.entries],([g])=>{let m=[],y=Ft(g);for(let b of p.keys())y.has(b)||(p.get(b)(),p.delete(b));for(let[b,v]of y){let T=t.evict(b,v);if(Xa(T)){if(!p.has(b)){let w=rt(T,_=>{_===!0&&o.has(b)&&o.delete(b)});p.set(b,w)}continue}if(typeof T=="boolean"){T&&m.push(b);continue}throw new TypeError("distill evict() must return boolean or Node<boolean>")}return m});rt(h,g=>{for(let m of g)o.delete(m)})}let c=t.consolidateTrigger!==void 0&&t.consolidateTrigger!==null;if(t.consolidate&&c){let p=ie(t.consolidateTrigger),h=we(p,()=>t.consolidate(u));rt(h,g=>{Ho(o,g)})}let l=ye([o.entries,a],([p,h])=>{let m=[...Ft(p).entries()].map(([v,T])=>({key:v,value:T,score:t.score(T,h),cost:t.cost(T)}));m.sort((v,T)=>T.score-v.score);let y=[],b=s;for(let v of m)v.cost<=b&&(y.push({key:v.key,value:v.value,score:v.score}),b-=v.cost);return y},{meta:{...J("distill",{budget:s})}}),f=ye([o.entries],([p])=>Ft(p).size);return Uo(l),Uo(f),{store:o,compact:l,size:f}}Xn();async function qo(n){let e=typeof n=="string"?new TextEncoder().encode(n):n,t=await globalThis.crypto.subtle.digest("SHA-256",e),r=new Uint8Array(t),o="";for(let s=0;s<r.length;s++)o+=Jo[r[s]];return o}var Jo=new Array(256);for(let n=0;n<256;n++)Jo[n]=n.toString(16).padStart(2,"0");var hn=class extends Error{constructor(t,r){super(`content-addressed lookup miss in read-strict mode: ${t}`);this.key=t;this.context=r;this.name="ContentAddressedMissError"}};function Yo(n){let e=new Set,t=r=>{if(r===null||typeof r!="object")return r;let o=r;if(e.has(o))return{__cycle:!0};e.add(o);try{if(Array.isArray(r))return r.map(t);let s={};for(let i of Object.keys(r).sort())s[i]=t(r[i]);return s}finally{e.delete(o)}};return JSON.stringify(t(n))}function tu(n){let{storage:e,keyContext:t,keyPrefix:r,mode:o="read-write"}=n,s=t??(a=>a);async function i(a){let u=Yo(s(a)),d=await qo(u);return r?`${r}:${d}`:d}return{keyFor:i,async lookup(a){if(o==="write")return;let u=await i(a),d=await e.load(u);if(d===void 0){if(o==="read-strict")throw new hn(u,a);return}return d},async store(a,u){if(o==="read")return;let d=await i(a);await e.save(d,u)},async forget(a){if(o==="read"||o==="write"||!e.delete)return;let u=await i(a);await e.delete(u)}}}Jn();async function nu(n,e){let t;try{t=await n.text()}catch{t=""}let r=e??"HTTP",o=new Error(`${r} API ${n.status}: ${n.statusText}${t?` \u2014 ${t}`:""}`);return o.status=n.status,o.headers=n.headers,o}Qt();Te();Pe();At();Z();fe();on();Te();Z();be();fe();Be();var mn=class{_version=0;_maxSize;_buf;_head=0;_size=0;constructor(e,t){if(t!==void 0&&t<1)throw new RangeError("maxSize must be >= 1");if(this._maxSize=t,t!==void 0){if(this._buf=new Array(t),e&&e.length>0){let r=Math.min(e.length,t),o=e.length-r;for(let s=0;s<r;s++)this._buf[s]=e[o+s];this._size=r}}else this._buf=e?[...e]:[],this._size=this._buf.length}get version(){return this._version}get size(){return this._size}at(e){if(!Number.isInteger(e))return;let t=e>=0?e:this._size+e;if(!(t<0||t>=this._size))return this._maxSize!==void 0?this._buf[(this._head+t)%this._maxSize]:this._buf[t]}append(e){this._rawAppend(e),this._version+=1}appendMany(e){if(e.length===0)return;let t=this._maxSize!==void 0&&e.length>this._maxSize?e.length-this._maxSize:0;for(let r=t;r<e.length;r++)this._rawAppend(e[r]);this._version+=1}clear(){if(this._size===0)return 0;let e=this._size;if(this._maxSize===void 0)this._buf.length=0;else for(let t=0;t<e;t++)this._buf[(this._head+t)%this._maxSize]=void 0;return this._head=0,this._size=0,this._version+=1,e}trimHead(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`trimHead: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return 0;let t=Math.min(e,this._size);if(this._maxSize===void 0)this._buf.splice(0,t);else{for(let r=0;r<t;r++)this._buf[(this._head+r)%this._maxSize]=void 0;this._head=(this._head+t)%this._maxSize}return this._size-=t,this._version+=1,t}slice(e,t){if(!Number.isInteger(e)||e<0)throw new RangeError(`slice: start must be a non-negative integer (got ${e})`);if(t!==void 0&&(!Number.isInteger(t)||t<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${t})`);let r=t===void 0?this._size:Math.min(Math.max(t,0),this._size),o=Math.min(e,this._size);if(o>=r)return[];let s=r-o;if(this._maxSize===void 0)return this._buf.slice(o,r);let i=new Array(s);for(let a=0;a<s;a++)i[a]=this._buf[(this._head+o+a)%this._maxSize];return i}tail(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`tail: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return[];let t=Math.min(e,this._size);return this.slice(this._size-t,this._size)}toArray(){if(this._maxSize===void 0)return[...this._buf];let e=new Array(this._size);for(let t=0;t<this._size;t++)e[t]=this._buf[(this._head+t)%this._maxSize];return e}snapshot(){return this.toArray()}restore(e){if(this._maxSize===void 0){this._buf.length=0;for(let t=0;t<e.length;t++)this._buf.push(e[t]);this._size=this._buf.length}else{let t=this._maxSize;for(let s=0;s<t;s++)this._buf[s]=void 0;this._head=0;let r=Math.min(e.length,t),o=e.length-r;for(let s=0;s<r;s++)this._buf[s]=e[o+s];this._size=r}this._version+=1}_rawAppend(e){if(this._maxSize===void 0){this._buf.push(e),this._size=this._buf.length;return}this._size<this._maxSize?(this._buf[(this._head+this._size)%this._maxSize]=e,this._size+=1):(this._buf[this._head]=e,this._head=(this._head+1)%this._maxSize)}};function zt(n){return n.subscribe(()=>{})}var ru=64;function hr(n,e={}){let{name:t,maxSize:r,versioning:o,guard:s,backend:i}=e,a=i??new mn(n,r),u=G(a.toArray(),{name:t,describeKind:"state",equals:(k,O)=>k===O,...o!=null?{versioning:o}:{},...s!=null?{guard:s}:{}});function d(){let k=a.toArray();$(()=>{u.down([[V]],{internal:!0}),u.down([[x,k]],{internal:!0})})}let c=new Map,l=new Map,f=new Map;function p(k,O){return`${k}:${O===void 0?"END":O}`}function h(k){if(k.size<ru)return;let O=k.keys().next();if(O.done)return;let E=k.get(O.value);E!==void 0&&E.dispose(),k.delete(O.value)}function g(k){let O=a.version;try{return k()}finally{a.version!==O&&d()}}function m(k){if(!Number.isInteger(k)||k<0)throw new RangeError(`tail: n must be a non-negative integer (got ${k})`);let O=c.get(k);if(O!==void 0)return c.delete(k),c.set(k,O),O.node;h(c);let E=ye([u],([M])=>{let F=M;return k===0||F.length===0?[]:F.slice(Math.max(0,F.length-k))},{initial:a.tail(k),describeKind:"derived"}),R=zt(E);return c.set(k,{node:E,dispose:R}),E}function y(k,O){if(!Number.isInteger(k)||k<0)throw new RangeError(`slice: start must be a non-negative integer (got ${k})`);if(O!==void 0&&(!Number.isInteger(O)||O<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${O})`);let E=p(k,O),R=l.get(E);if(R!==void 0)return l.delete(E),l.set(E,R),R.node;h(l);let M=ye([u],([P])=>{let I=P;return O===void 0?I.slice(k):I.slice(k,O)},{initial:a.slice(k,O),describeKind:"derived"}),F=zt(M);return l.set(E,{node:M,dispose:F}),M}function b(k){let O=f.get(k);if(O!==void 0)return O.node;let E=ye([u,k],([M,F])=>{let P=M,I=Math.max(0,Math.trunc(F??0));return P.slice(I)},{initial:[],describeKind:"derived"}),R=zt(E);return f.set(k,{node:E,dispose:R}),E}let v,T;function w(){v===void 0&&(v=B([u],(k,O,E)=>{let R=k[0],F=R!=null&&R.length>0?R.at(-1):E.prevData[0];if(F==null||F.length===0){O.down([[C]]);return}O.emit(F[F.length-1])},{name:t!=null?`${t}::lastValue`:"lastValue",describeKind:"derived",initial:a.size===0?void 0:a.at(a.size-1)}),T=ye([u],([k])=>k.length>0,{name:t!=null?`${t}::hasLatest`:"hasLatest",describeKind:"derived",initial:a.size>0}),zt(v),zt(T))}let _={entries:u,get size(){return a.size},at(k){return a.at(k)},append(k){g(()=>a.append(k))},appendMany(k){k.length!==0&&g(()=>a.appendMany(k))},clear(){g(()=>a.clear())},trimHead(k){g(()=>a.trimHead(k))},withLatest(){return w(),u},get lastValue(){return w(),v},get hasLatest(){return w(),T},view(k){switch(k.kind){case"tail":return m(k.n);case"slice":return y(k.start,k.stop);case"fromCursor":return b(k.cursor)}},attach(k){let O=k.subscribe(E=>{for(let R of E)R[0]===x&&_.append(R[1])});return()=>O()},attachStorage(k){if(k.length===0)return()=>{};let O=new Map;for(let R of k)O.set(R,a.size);(async()=>{for(let R of k)if(typeof R.loadEntries=="function")try{let M=await Promise.resolve(R.loadEntries());M.entries.length>0&&a.size===0&&(a.restore(M.entries),O.set(R,M.entries.length),d());break}catch{}})();let E=u.subscribe(R=>{for(let M of R){if(M[0]!==x)continue;let F=M[1];for(let P of k){let I=O.get(P)??0;if(F.length<I){try{let W=P.appendEntries(F);W instanceof Promise&&W.catch(()=>{})}catch{}O.set(P,F.length);continue}if(F.length===I)continue;let ue=F.slice(I);O.set(P,F.length);try{let W=P.appendEntries(ue);W instanceof Promise&&W.catch(()=>{})}catch{}}}});return()=>E()},disposeAllViews(){for(let k of c.values())k.dispose();c.clear();for(let k of l.values())k.dispose();l.clear();for(let k of f.values())k.dispose();f.clear()},dispose(){for(let k of c.values())k.dispose();c.clear();for(let k of l.values())k.dispose();l.clear();for(let k of f.values())k.dispose();f.clear()}};return _}var pr=new WeakMap;function ou(n){let e=pr.get(n);if(e)return e;let t=n.map(c=>c.cache??[]),r=t.flat(),o=G(r,{name:"mergeReactiveLogs",describeKind:"state",equals:(c,l)=>c===l}),s=n.map((c,l)=>[...t[l]??[]]),i=[];for(let c=0;c<n.length;c++){let l=c,f=n[l].subscribe(p=>{for(let h of p)if(h[0]===x)s[l]=[...h[1]],o.emit(s.flat());else if(h[0]===N){s[l]=[];let g=i[l];g!==void 0&&(i[l]=void 0,g())}else h[0]===S&&o.down([[S,h[1]]])});i.push(f)}let a=Ze(o),u=!1,d={node:o,dispose(){if(!u){u=!0;for(let c of i)c?.();i.length=0,a(),pr.delete(n)}}};return pr.set(n,d),d}function su(n,e){let t=n.cache??0;return t>=e?!1:(n.down([[V],[x,t+1]]),!0)}var Qo=Lr((n,e)=>{n("observe"),n("signal"),e("write")});function iu(n){let e=hr([],{name:n.name,maxSize:n.retainedLimit??1024,guard:n.guard??Qo,...n.versioning!=null?{versioning:n.versioning}:{}});return e.withLatest(),n.graph&&n.graph.add(e.entries,{name:n.name}),e}function mr(n){if(n===null||typeof n!="object"||Object.isFrozen(n))return n;for(let e of Object.keys(n))mr(n[e]);return Object.freeze(n)}function gr(n){let e=n.cache,r=(typeof e=="number"&&Number.isFinite(e)?e:0)+1;return n.down([[V],[x,r]]),r}function Kt(n,e,t,r,o,s){let i=e(t,r,o);if(i===void 0)return;let a=s!=null?{...i,handlerVersion:s}:i;n.append(a)}function au(n,e){let t=e.freeze??!0;return function(...o){let s=t?o.map(mr):o,i=ne(),a=e.seq?gr(e.seq):void 0;try{let u=n(...s);return e.audit&&e.onSuccess&&Kt(e.audit,e.onSuccess,s,u,{t_ns:i,seq:a},e.handlerVersion),u}catch(u){if(e.audit&&e.onFailure){let d=u instanceof Error?u.name:typeof u;Kt(e.audit,e.onFailure,s,u,{t_ns:i,seq:a,errorType:d},e.handlerVersion)}throw u}}}function uu(n,e){let t=e.freeze??!0;return function(...o){let s=t?o.map(mr):o,i=ne(),a,u,d=!1,c;try{$(()=>{e.seq&&(c=gr(e.seq));try{a=n(...s),e.audit&&e.onSuccess&&Kt(e.audit,e.onSuccess,s,a,{t_ns:i,seq:c},e.handlerVersion)}catch(l){throw u=l,d=!0,l}})}catch(l){if(d&&e.audit&&e.onFailure){let f=u instanceof Error?u.name:typeof u;Kt(e.audit,e.onFailure,s,u,{t_ns:i,seq:c,errorType:f},e.handlerVersion)}throw d?u:l}return a}}function du(n,e,t=0){let r=G(t,{name:e,describeKind:"state"});return n.add(r,{name:e}),r}function cu(n,e,t,r=0){let o={},s=new Ie(e);for(let i of t){let a=G(r,{name:i,describeKind:"state"});s.add(a,{name:i}),o[i]=a}return n.mount(e,s),o}var br=require("rxjs");Z();function lu(n,e){return e?.raw?new br.Observable(t=>n.subscribe(o=>{if(!t.closed){t.next(o);for(let s of o){if(s[0]===S){t.error(s[1]);return}if(s[0]===N){t.complete();return}}}})):new br.Observable(t=>n.subscribe(o=>{for(let s of o){if(t.closed)return;if(s[0]===x)t.next(s[1]);else if(s[0]===S){t.error(s[1]);return}else if(s[0]===N){t.complete();return}}}))}yt();Te();Z();be();var gn=class{_version=0;_topics=new Set;get version(){return this._version}get topicCount(){return this._topics.size}hasTopic(e){return this._topics.has(e)}topicNames(){return this._topics.values()}createTopic(e){return this._topics.has(e)?!1:(this._topics.add(e),this._version+=1,!0)}removeTopic(e){let t=this._topics.delete(e);return t&&(this._version+=1),t}};function fu(n={}){let{backend:e}=n,t=e??new gn,r=new Map;function o(s){let i=r.get(s);return i===void 0&&(i=B({describeKind:"state"}),r.set(s,i),t.createTopic(s)),i}return{topic(s){return o(s)},publish(s,i){o(s).emit(i)},publishMany(s){$(()=>{for(let[i,a]of s)o(i).emit(a)})},removeTopic(s){let i=r.get(s);return i===void 0?!1:(r.delete(s),t.removeTopic(s),i.down([[K]]),!0)},has(s){return t.hasTopic(s)},get size(){return t.topicCount},topicNames(){return t.topicNames()}}}Te();Z();fe();function Xo(n,e){if(n===e)return 0;let t=typeof n;if(t===typeof e&&(t==="number"||t==="string"||t==="boolean"||t==="bigint")){let o=n,s=e;return o<s?-1:o>s?1:0}return String(n).localeCompare(String(e))}function pu(n,e){let t=Xo(n[0],e[0]);return t!==0?t:Xo(n[1],e[1])}function Zo(n){return[n.secondary,n.primary]}function Nt(n,e){let t=Zo(e),r=0,o=n.length;for(;r<o;){let s=r+o>>1;pu(t,Zo(n[s]))>0?r=s+1:o=s}return r}var bn=class{_version=0;_buf=[];_byPrimary=new Map;get version(){return this._version}get size(){return this._buf.length}has(e){return this._byPrimary.has(e)}get(e){return this._byPrimary.get(e)?.value}upsert(e,t,r,o){let s=this._byPrimary.get(e),i={primary:e,secondary:t,value:r};if(s!==void 0&&o?.equals?.(s,i))return!1;if(s!==void 0){let u=Nt(this._buf,s);this._buf.splice(u,1)}let a=Nt(this._buf,i);return this._buf.splice(a,0,i),this._byPrimary.set(e,i),this._version+=1,s===void 0}upsertMany(e,t){let r=0;try{for(let o of e){let s=this._byPrimary.get(o.primary),i={primary:o.primary,secondary:o.secondary,value:o.value};if(s!==void 0&&t?.equals?.(s,i))continue;if(s!==void 0){let u=Nt(this._buf,s);this._buf.splice(u,1)}let a=Nt(this._buf,i);this._buf.splice(a,0,i),this._byPrimary.set(o.primary,i),r+=1}}finally{r>0&&(this._version+=1)}return r}delete(e){let t=this._byPrimary.get(e);if(t===void 0)return!1;let r=Nt(this._buf,t);return this._buf.splice(r,1),this._byPrimary.delete(e),this._version+=1,!0}deleteMany(e){let t=0;try{for(let r of e){let o=this._byPrimary.get(r);if(o===void 0)continue;let s=Nt(this._buf,o);this._buf.splice(s,1),this._byPrimary.delete(r),t+=1}}finally{t>0&&(this._version+=1)}return t}clear(){let e=this._buf.length;return e===0?0:(this._buf.length=0,this._byPrimary.clear(),this._version+=1,e)}toArray(){return[...this._buf]}toPrimaryMap(){let e=new Map;for(let t of this._buf)e.set(t.primary,t.value);return e}};function hu(n){return n.subscribe(()=>{})}function mu(n={}){let{name:e,versioning:t,equals:r,backend:o}=n,s=o??new bn;function i(p){return p?.equals!==void 0||r===void 0?p:{...p,equals:r}}let a=G([],{name:e,describeKind:"state",equals:(p,h)=>p===h,...t!=null?{versioning:t}:{}}),u=ye([a],([p])=>{let h=p,g=new Map;for(let m of h)g.set(m.primary,m.value);return g},{initial:s.toPrimaryMap(),describeKind:"derived"}),d=hu(u),c=!1;function l(){let p=s.toArray();$(()=>{a.down([[V]]),a.down([[x,p]])})}function f(p){let h=s.version;try{return p()}finally{s.version!==h&&l()}}return{ordered:a,byPrimary:u,has(p){return s.has(p)},get(p){return s.get(p)},get size(){return s.size},upsert(p,h,g,m){return f(()=>s.upsert(p,h,g,i(m)))},upsertMany(p,h){let g=[...p];g.length!==0&&f(()=>s.upsertMany(g,i(h)))},delete(p){f(()=>s.delete(p))},deleteMany(p){let h=[...p];h.length!==0&&f(()=>s.deleteMany(h))},clear(){f(()=>s.clear())},dispose(){c||(c=!0,d())}}}Te();Z();fe();var yn=class{_version=0;_buf;constructor(e){this._buf=e?[...e]:[]}get version(){return this._version}get size(){return this._buf.length}at(e){if(!Number.isInteger(e))return;let t=e>=0?e:this._buf.length+e;if(!(t<0||t>=this._buf.length))return this._buf[t]}append(e){this._buf.push(e),this._version+=1}appendMany(e){if(e.length===0)return;let t=this._buf.length;this._buf.length=t+e.length;for(let r=0;r<e.length;r++)this._buf[t+r]=e[r];this._version+=1}insert(e,t){if(!Number.isInteger(e)||e<0||e>this._buf.length)throw new RangeError(`insert: index ${e} out of range [0, ${this._buf.length}]`);this._buf.splice(e,0,t),this._version+=1}insertMany(e,t){if(!Number.isInteger(e)||e<0||e>this._buf.length)throw new RangeError(`insertMany: index ${e} out of range [0, ${this._buf.length}]`);t.length!==0&&(this._buf.splice(e,0,...t),this._version+=1)}pop(e){if(this._buf.length===0)throw new RangeError("pop from empty list");if(!Number.isInteger(e))throw new RangeError(`pop: index ${e} must be an integer`);let t=e>=0?e:this._buf.length+e;if(t<0||t>=this._buf.length)throw new RangeError(`pop: index ${e} out of range`);let[r]=this._buf.splice(t,1);return this._version+=1,r}clear(){let e=this._buf.length;return e===0?0:(this._buf.length=0,this._version+=1,e)}toArray(){return[...this._buf]}};function gu(n,e={}){let{name:t,versioning:r,backend:o}=e,s=o??new yn(n),i=G(s.toArray(),{name:t,describeKind:"state",equals:(d,c)=>d===c,...r!=null?{versioning:r}:{}});function a(){let d=s.toArray();$(()=>{i.down([[V]]),i.down([[x,d]])})}function u(d){let c=s.version;try{return d()}finally{s.version!==c&&a()}}return{items:i,get size(){return s.size},at(d){return s.at(d)},append(d){u(()=>s.append(d))},appendMany(d){u(()=>s.appendMany(d))},insert(d,c){u(()=>s.insert(d,c))},insertMany(d,c){u(()=>s.insertMany(d,c))},pop(d=-1){return u(()=>s.pop(d))},clear(){u(()=>s.clear())},dispose(){}}}un();Z();Be();function bu(n,e={}){let t=e.keyFn??(o=>String(o)),r=new Map;return o=>{let s=t(o),i=r.get(s);if(i)return i;let a=n(o),u;a!=null&&typeof a.then=="function"?u=Promise.resolve(a):a!=null&&typeof a=="object"&&"subscribe"in a&&"cache"in a?u=ur(a):a!=null&&typeof a=="object"&&Symbol.asyncIterator in a?u=(async()=>{let l=a[Symbol.asyncIterator]();try{let{value:f,done:p}=await l.next();if(p)throw new Error("singleFromAny: factory returned empty async iterable");return f}finally{await l.return?.()}})():a!=null&&typeof a=="object"&&Symbol.iterator in a?u=(async()=>{let l=a[Symbol.iterator]();try{let{value:f,done:p}=l.next();if(p)throw new Error("singleFromAny: factory returned empty iterable");return f}finally{l.return?.()}})():u=Promise.resolve(a);let d,c=()=>{r.get(s)===d&&r.delete(s)};return d=u.then(l=>(c(),l),l=>{throw c(),l}),r.set(s,d),d}}function yu(n,e={}){let t=e.keyFn??(o=>String(o)),r=new Map;return o=>{let s=t(o),i=r.get(s);if(i)return i;let a=ie(n(o));r.set(s,a);let u=a.subscribe(d=>{for(let c of d)if(c[0]===S||c[0]===N){r.get(s)===a&&r.delete(s),u();return}});return a}}Be();function vn(n){if(n===null||typeof n!="object")return n;if(Array.isArray(n))return n.map(vn);let e=n,t=Object.keys(e).sort(),r={};for(let o of t)r[o]=vn(e[o]);return r}function yr(n){return JSON.stringify(vn(n),void 0,0)}var vu=new TextEncoder,Tu=new TextDecoder("utf-8",{fatal:!0}),$t={name:"json",version:1,encode(n){return vu.encode(yr(n))},decode(n){return JSON.parse(Tu.decode(n))}};function wu(){return $t}function Tn(){let n=new Map;return{name:"memory",read(e){let t=n.get(e);return t===void 0?void 0:new Uint8Array(t)},write(e,t){n.set(e,new Uint8Array(t))},delete(e){n.delete(e)},list(e){let t=[...n.keys()];return e?t.filter(r=>r.startsWith(e)).sort():t.sort()}}}function vr(n,e={}){let t=e.codec??$t,r=e.name??n.name??"snapshot",o=e.keyOf??(l=>l.name??e.name??n.name??"snapshot"),s,i=0,a=e.compactEvery,u,d={name:r,debounceMs:e.debounceMs,compactEvery:a,filter:e.filter,keyOf:o,save(l){if(!(e.filter&&!e.filter(l))&&(s={snapshot:l},i+=1,a!==void 0&&i%a===0||!e.debounceMs))return c()},load(){let l=u??r,f=n.read(l);if(f!==void 0)return f instanceof Uint8Array?f.length===0?void 0:t.decode(f):Promise.resolve(f).then(p=>p===void 0||p.length===0?void 0:t.decode(p))},async flush(){await c()},async rollback(){s=void 0}};function c(){let l=s;if(!l)return;s=void 0;let f=o(l.snapshot),p=t.encode(l.snapshot),h=n.write(f,p);if(h instanceof Promise)return h.then(()=>{u=f});u=f}return d}function es(n,e={}){let t=e.codec??$t,r=e.name??n.name??"append-log",o=e.keyOf??(f=>r),s=e.compactEvery,i=new Map,a=0,u,d={name:r,debounceMs:e.debounceMs,compactEvery:s,keyOf:o,appendEntries(f){if(f.length!==0){for(let p of f){let h=o(p),g=i.get(h);g||(g=[],i.set(h,g)),g.push(p)}if(a+=f.length,s!==void 0&&a%s===0||!e.debounceMs)return c()}},async loadEntries(f){let p=f?.keyFilter,h=n.list===void 0?p!==void 0?[p]:[r]:await Promise.resolve(n.list(p)),g=[];for(let m of h){let y=await Promise.resolve(n.read(m));if(y===void 0||y.length===0)continue;let b=t.decode(y);Array.isArray(b)&&g.push(...b)}return{entries:g,cursor:void 0}},async flush(){await c()},async rollback(){i=new Map}};function c(){if(i.size===0)return;let f=i;i=new Map;let p=(u??Promise.resolve()).then(()=>{let h=l(f);return h instanceof Promise?h:Promise.resolve()},()=>{let h=l(f);return h instanceof Promise?h:Promise.resolve()});return u=p.finally(()=>{u===p&&(u=void 0)}),u}function l(f){let p=[];for(let[h,g]of f){let m=n.read(h),y=b=>{let T=[...b===void 0||b.length===0?[]:t.decode(b)??[],...g],w=t.encode(T);return n.write(h,w)};if(m instanceof Promise)p.push(m.then(async b=>{let v=y(b);v instanceof Promise&&await v}));else{let b=y(m);b instanceof Promise&&p.push(b)}}if(p.length>0)return Promise.all(p).then(()=>{})}return d}function Tr(n,e={}){let t=e.codec??$t,r=e.name??n.name??"kv",o=e.compactEvery,s=new Map,i=0,a={name:r,debounceMs:e.debounceMs,compactEvery:o,filter:e.filter,save(d,c){if(!(e.filter&&!e.filter(d,c))&&(s.set(d,c),i+=1,o!==void 0&&i%o===0||!e.debounceMs))return u()},load(d){let c=n.read(d);if(c!==void 0)return c instanceof Uint8Array?c.length===0?void 0:t.decode(c):Promise.resolve(c).then(l=>l===void 0||l.length===0?void 0:t.decode(l))},delete(d){if(s.delete(d),!!n.delete)return n.delete(d)},list(d){return n.list?n.list(d):[]},async flush(){await u()},async rollback(){s=new Map}};function u(){if(s.size===0)return;let d=s;s=new Map;let c=[];for(let[l,f]of d){let p=t.encode(f),h=n.write(l,p);h instanceof Promise&&c.push(h)}if(c.length>0)return Promise.all(c).then(()=>{})}return a}function ku(n){return vr(Tn(),n)}function xu(n){return es(Tn(),n)}function Nu(n){return Tr(Tn(),n)}function _u(n,e){let t={name:e?.name??"dict-kv",read(r){return n[r]},write(r,o){n[r]=new Uint8Array(o)},delete(r){delete n[r]},list(r){let o=Object.keys(n).sort();return r?o.filter(s=>s.startsWith(r)):o}};return Tr(t,e)}function Su(n,e){return vr({name:"dict",read(r){return n[r]},write(r,o){n[r]=new Uint8Array(o)},delete(r){delete n[r]},list(r){let o=Object.keys(n).sort();return r?o.filter(s=>s.startsWith(r)):o}},e)}Z();be();fe();on();function Ou(n,e,t,r){let o=new Ie(n,r);o.add(e,{name:"source"});let s=G(t,{meta:{kind:"stratify_rules"}});o.add(s,{name:"rules"});for(let i of t)Eu(o,e,s,i);return o}function Eu(n,e,t,r){let o=`branch/${r.name}`,s=Symbol("noValue"),i=!1,a=!1,u=!1,d=s,c=!1,l=t.cache??[];function f(g){if(u){u=!1;let m=d;if(d=s,m!==s){let y=l.find(v=>v.name===r.name),b=!1;try{b=y?.classify(m)??!1}catch{b=!1}b?(c=!1,g.emit(m)):c&&(c=!1,g.down([[V],[C]]))}else c?(c=!1,g.down([[V],[C]])):g.down([[C]])}}let p=B([],(g,m)=>{let y=e.subscribe(v=>{for(let T of v)h(T,0,m)}),b=t.subscribe(v=>{for(let T of v)h(T,1,m)});return()=>{y(),b()}},{describeKind:"derived",meta:{kind:"stratify_branch",branch:r.name},completeWhenDepsComplete:!1});function h(g,m,y){let b=g[0];return b===V?(m===0?(i=!0,c=!0):a=!0,!0):b===x||b===C?(m===0?(i=!1,u=!0,d=b===x?g[1]:s):(b===x&&(l=g[1]),a=!1),i||a||f(y),!0):b===N||b===S||b===K?(i=!1,a=!1,u=!1,d=s,c=!1,m===0&&y.down([g]),!0):m===1}if(n.add(p,{name:o}),r.ops){let g=r.ops(p),m=`branch/${r.name}/out`;n.add(g,{name:m})}}tn();var ql=Math.LN2/604800;function ts(n,e,t,r=0){if(!Number.isFinite(n))return r;if(!Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0)return Math.max(r,n);let o=n*Math.exp(-t*e);return Math.max(r,o)}Te();Z();be();fe();yt();Be();Z();var Ru=new Map([[Ne,"INVALIDATE"],[le,"PAUSE"],[pe,"RESUME"],[K,"TEARDOWN"],[N,"COMPLETE"],[S,"ERROR"]]),Mu=new Map([["INVALIDATE",Ne],["PAUSE",le],["RESUME",pe],["TEARDOWN",K],["COMPLETE",N],["ERROR",S]]);function ot(n){let e=Ru.get(n);return e||(Symbol.keyFor(n)??"UNKNOWN")}function _t(n){let e=Mu.get(n);if(e)return e;if(n&&n!=="UNKNOWN")return Symbol.for(n)}function St(n){return n instanceof Error?{message:n.message,name:n.name,stack:n.stack}:{message:String(n),name:"Error"}}function Ot(n){let e=new Error(n.message);return e.name=n.name,n.stack&&(e.stack=n.stack),e}function st(n){if(typeof MessagePort<"u"&&n instanceof MessagePort)return{post(e,t){n.postMessage(e,t??[])},listen(e){let t=r=>e(r.data);return n.addEventListener("message",t),n.start(),()=>n.removeEventListener("message",t)},terminate(){n.close()}};if(typeof SharedWorker<"u"&&n instanceof SharedWorker)return st(n.port);if(typeof Worker<"u"&&n instanceof Worker)return{post(e,t){n.postMessage(e,t??[])},listen(e){let t=r=>e(r.data);return n.addEventListener("message",t),()=>n.removeEventListener("message",t)},terminate(){n.terminate()}};if(typeof BroadcastChannel<"u"&&n instanceof BroadcastChannel)return{post(e,t){t&&t.length>0&&console.warn("[graphrefly] WorkerTransport: BroadcastChannel does not support Transferable objects. The transfer argument is ignored and objects will be cloned instead."),n.postMessage(e)},listen(e){let t=r=>e(r.data);return n.addEventListener("message",t),()=>n.removeEventListener("message",t)},terminate(){n.close()}};if(typeof ServiceWorker<"u"&&n instanceof ServiceWorker)return{post(e,t){n.postMessage(e,t??[])},listen(e){let t=r=>{r.source===n&&e(r.data)};return navigator.serviceWorker.addEventListener("message",t),()=>navigator.serviceWorker.removeEventListener("message",t)}};throw new Error("createTransport: unsupported target type. Expected Worker, SharedWorker, ServiceWorker, BroadcastChannel, or MessagePort.")}function Au(n){return typeof n=="object"&&n!==null&&typeof n.post=="function"&&typeof n.listen=="function"}function ns(n,e){let t=Au(n)?n:st(n),r=e.name??"workerBridge",o=Object.entries(e.expose??{}),s=e.import??[],i=e.transfer??{},a=G("connecting",{name:`${r}::meta::status`}),u=G(null,{name:`${r}::meta::error`}),d=new Map,c=new Map;for(let b of s){let v=G(void 0,{name:`${r}::${b}`});d.set(b,v)}let l;if(o.length>0){let b=o.map(([,w])=>w),v=B(b,(w,_)=>{let k={};for(let O=0;O<o.length;O++){let[E]=o[O],R=w[O];R!=null&&R.length>0&&(k[E]=R.at(-1))}Object.keys(k).length!==0&&_.emit(k)},{name:`${r}::aggregated`,partial:!0});l=Yt([v],w=>{let _=w[0];if(_==null||Object.keys(_).length===0)return;let k=[];for(let R of Object.keys(_)){let M=i[R];M&&k.push(...M(_[R]))}let O;for(let[R,M]of o)R in _&&M.v!=null&&(O==null&&(O={}),O[R]=M.v.version);let E={t:"b",u:_,...O?{v:O}:{}};try{t.post(E,k.length>0?k:void 0)}catch(R){u.down([[x,R instanceof Error?R:new Error(String(R))]])}}).subscribe(()=>{})}let f=!1,p=t.listen(b=>{if(f)return;let v=b;switch(v.t){case"r":{$(()=>{for(let[w,_]of Object.entries(v.stores)){let k=d.get(w);k&&k.down([[x,_]])}}),a.down([[x,"connected"]]);let T={};for(let[w,_]of o)T[w]=_.cache;t.post({t:"i",stores:T});break}case"v":{let T=d.get(v.s);T&&T.down([[x,v.d]]);break}case"b":{$(()=>{for(let[T,w]of Object.entries(v.u)){let _=v.v?.[T];if(_!=null){let O=c.get(T);if(O!=null&&_<=O)continue;c.set(T,_)}let k=d.get(T);k&&k.down([[x,w]])}});break}case"e":{let T=d.get(v.s);T&&T.down([[S,Ot(v.err)]]);break}case"s":{let T=_t(v.sig);if(!T)break;let w=v.s==="*"?[...d.values()]:d.has(v.s)?[d.get(v.s)]:[];for(let _ of w)_.down(v.d===void 0?[[T]]:[[T,v.d]]);break}}}),h=[];for(let[b,v]of o){let T=v.subscribe((w=>{if(!f)for(let _ of w){let k=_[0];k!==x&&(ge.isLocalOnly(k)||(k===S?t.post({t:"e",s:b,err:St(_[1])}):t.post({t:"s",s:b,sig:ot(k),d:_.length>1?_[1]:void 0})))}}));h.push(T)}let g;if(e.timeoutMs!=null&&e.timeoutMs>0){let b=nt(e.timeoutMs),v=cn(a,w=>w==="connected");g=dr(Vt(dn(b,()=>"timeout"),dn(v,()=>"ready"))).subscribe(w=>{for(let _ of w)_[0]===x&&_[1]==="timeout"&&(u.down([[x,new Error("Worker bridge handshake timeout")]]),m())})}function m(){if(!f){f=!0,g?.(),t.post({t:"s",s:"*",sig:ot(K)}),l&&l();for(let b of h)b();h.length=0,p(),a.down([[x,"closed"]]),c.clear(),d.clear()}}let y={meta:{status:a,error:u},destroy:m};for(let[b,v]of d)y[b]=v;return y}Te();Z();be();fe();function Cu(n){return typeof n=="object"&&n!==null&&typeof n.post=="function"&&typeof n.listen=="function"}function rs(n,e){let t=Cu(n)?n:st(n),r=e.import??[],o=e.transfer??{},s=new Map,i=new Map,a={};for(let m of r){let y=G(void 0,{name:`worker::${m}`});s.set(m,y),a[m]=y}let u=e.expose(a),d=Object.entries(u),c,l=!1;if(d.length>0){let m=d.map(([,v])=>v),y=B(m,(v,T)=>{let w={};for(let _=0;_<d.length;_++){let[k]=d[_],O=v[_];O!=null&&O.length>0&&(w[k]=O.at(-1))}Object.keys(w).length!==0&&T.emit(w)},{name:"workerSelf::aggregated",partial:!0});c=Yt([y],v=>{if(l)return;let T=v[0];if(T==null||Object.keys(T).length===0)return;let w=[];for(let O of Object.keys(T)){let E=o[O];E&&w.push(...E(T[O]))}let _;for(let[O,E]of d)O in T&&E.v!=null&&(_==null&&(_={}),_[O]=E.v.version);let k={t:"b",u:T,..._?{v:_}:{}};try{t.post(k,w.length>0?w:void 0)}catch{}}).subscribe(()=>{})}let f=[];for(let[m,y]of d){let b=y.subscribe((v=>{if(!l)for(let T of v){let w=T[0];w!==x&&(ge.isLocalOnly(w)||(w===S?t.post({t:"e",s:m,err:St(T[1])}):t.post({t:"s",s:m,sig:ot(w),d:T.length>1?T[1]:void 0})))}}));f.push(b)}let p=t.listen(m=>{if(l)return;let y=m;switch(y.t){case"i":{$(()=>{for(let[b,v]of Object.entries(y.stores)){let T=s.get(b);T&&T.down([[x,v]])}});break}case"v":{let b=s.get(y.s);b&&b.down([[x,y.d]]);break}case"b":{$(()=>{for(let[b,v]of Object.entries(y.u)){let T=y.v?.[b];if(T!=null){let _=i.get(b);if(_!=null&&T<=_)continue;i.set(b,T)}let w=s.get(b);w&&w.down([[x,v]])}});break}case"e":{let b=s.get(y.s);b&&b.down([[S,Ot(y.err)]]);break}case"s":{let b=_t(y.sig);if(!b)break;if(b===K&&y.s==="*"){g();return}let v=y.s==="*"?[...s.values()]:s.has(y.s)?[s.get(y.s)]:[];for(let T of v)T.down(y.d===void 0?[[b]]:[[b,y.d]]);break}}}),h={};for(let[m,y]of d)h[m]=y.cache;t.post({t:"r",stores:h});function g(){if(!l){l=!0,c&&c();for(let m of f)m();f.length=0,p(),t.terminate?.(),i.clear(),s.clear()}}return{destroy:g}}0&&(module.exports={CircuitOpenError,ContentAddressedMissError,DEFAULT_AUDIT_GUARD,NS_PER_MS,NS_PER_SEC,NativeIndexBackend,NativeListBackend,NativeLogBackend,NativeMapBackend,NativePubSubBackend,RateLimiterOverflowError,ResettableTimer,TimeoutError,appendAudit,appendLogStorage,audit,awaitSettled,budgetGate,buffer,bufferCount,bufferTime,bumpCursor,cached,canonicalJson,cascadingCache,catchError,checkpointToRedis,checkpointToS3,circuitBreaker,combine,combineLatest,concat,concatMap,constant,contentAddressedStorage,createAuditLog,createTransport,createWatermarkController,csvRows,debounce,debounceTime,decay,decorrelatedJitter,defer,delay,deserializeError,dictKv,dictSnapshot,distill,distinctUntilChanged,domainMeta,elementAt,empty,escapeRegexChar,exhaustMap,exponential,externalBundle,externalProducer,fallback,fibonacci,filter,find,first,firstValueFrom,firstWhere,flatMap,forEach,fromAny,fromAsyncIter,fromCSV,fromClickHouseWatch,fromCron,fromDrizzle,fromEvent,fromHTTP,fromHTTPPoll,fromHTTPStream,fromIter,fromKafka,fromKysely,fromMCP,fromNATS,fromNDJSON,fromOTel,fromPrisma,fromPrometheus,fromPromise,fromPulsar,fromRabbitMQ,fromRaf,fromRedisStream,fromSSE,fromSqlite,fromSqliteCursor,fromStatsD,fromSyslog,fromTimer,fromWebSocket,fromWebSocketReconnect,fromWebhook,globToRegExp,interval,jsonCodec,jsonCodecFor,keepalive,kvStorage,last,lightMutation,linear,lru,makeHttpError,map,matchesAnyPattern,matchesCron,memoryAppendLog,memoryBackend,memoryKv,memorySnapshot,merge,mergeMap,mergeReactiveLogs,nameToSignal,ndjsonRows,never,nodeSignal,of,onFirstData,pairwise,parseCron,parsePrometheusText,parseSSEStream,parseStatsD,parseSyslog,pausable,pubsub,race,rateLimiter,reactiveCounter,reactiveIndex,reactiveList,reactiveLog,reactiveMap,reactiveSink,reduce,registerCursor,registerCursorMap,repeat,replay,rescue,resolveBackoffPreset,retry,sample,scan,serializeError,share,shareReplay,signalToName,singleFromAny,singleNodeFromAny,skip,snapshotStorage,sortJsonValue,stableJsonString,stratify,switchMap,take,takeUntil,takeWhile,tap,tapFirst,throttle,throttleTime,throwError,timeout,toArray,toCSV,toClickHouse,toFile,toHTTP,toKafka,toLoki,toMongo,toNATS,toObservable,toPostgres,toPulsar,toRabbitMQ,toReadableStream,toRedisStream,toS3,toSSE,toSSEBytes,toSqlite,toTempo,toWebSocket,tokenBucket,topologyDiff,tryIncrementBounded,valve,verifiable,window,windowCount,windowTime,withBreaker,withLatestFrom,withMaxAttempts,withStatus,workerBridge,workerSelf,wrapMutation,zip});
20
+ `:JSON.stringify(l),h=o(f,ne());await e.putObject({Bucket:t,Key:h,Body:p,ContentType:c})}})}function Ga(n,e,t,r){let{toSQL:s=(a,i)=>({sql:`INSERT INTO "${i.replace(/"/g,'""')}" (data) VALUES ($1)`,params:[JSON.stringify(a)]}),onTransportError:o}=r??{};return ae(n,{onTransportError:o,serialize:a=>s(a,t),send:async a=>{let i=a;await e.query(i.sql,i.params)}})}function za(n,e,t){let{toDocument:r=o=>o,onTransportError:s}=t??{};return ae(n,{onTransportError:s,serialize:r,send:async o=>{await e.insertOne(o)}})}function Ka(n,e,t){let{labels:r={},toLine:s=i=>JSON.stringify(i),toLabels:o,onTransportError:a}=t??{};return ae(n,{onTransportError:a,serialize:i=>({line:s(i),labels:o?{...r,...o(i)}:r}),send:async i=>{let{line:u,labels:d}=i,c=`${ne()}`;await e.push({streams:[{stream:d,values:[[c,u]]}]})}})}function $a(n,e,t){let{toResourceSpans:r=o=>[o],onTransportError:s}=t??{};return ae(n,{onTransportError:s,serialize:r,send:async o=>{await e.push({resourceSpans:o})}})}function ja(n,e,t,r){let{prefix:s="checkpoints/",debounceMs:o=500,compactEvery:a=10,onError:i}=r??{},u={name:`s3:${t}`,debounceMs:o,compactEvery:a,save(d){let c=Math.floor(ne()/1e6),f=`${s}${n.name}/checkpoint-${c}.json`,l;try{l=JSON.stringify(d)}catch(p){i?.(p);return}e.putObject({Bucket:t,Key:f,Body:l,ContentType:"application/json"}).catch(p=>i?.(p))}};return n.attachSnapshotStorage([u],{onError:d=>i?.(d)})}function Wa(n,e,t){let{prefix:r="graphrefly:checkpoint:",debounceMs:s=500,compactEvery:o=10,onError:a}=t??{},i=`${r}${n.name}`,u={name:`redis:${i}`,debounceMs:s,compactEvery:o,save(d){let c;try{c=JSON.stringify(d)}catch(f){a?.(f);return}e.set(i,c).catch(f=>a?.(f))},async load(){let d=await e.get(i);if(d!=null)try{return JSON.parse(d)}catch{return}}};return n.attachSnapshotStorage([u],{onError:d=>a?.(d)})}function Ua(n,e,t){let{mapRow:r=a=>a,params:s,...o}=t??{};return C(a=>{try{let u=n.query(e,s).map(r);a.emit(u),a.down([[N]])}catch(i){a.down([[_,i instanceof Error?i:new Error(String(i))]])}},{describeKind:"producer",completeWhenDepsComplete:!1,...o})}function Ha(n,e,t){let{mapRow:r=a=>a,params:s,...o}=t??{};return C(a=>{try{let i=n.iterate(e,s);$(()=>{for(let u of i)a.emit(r(u));a.down([[N]])})}catch(i){a.down([[_,i instanceof Error?i:new Error(String(i))]])}},{describeKind:"producer",completeWhenDepsComplete:!1,...o})}function qa(n,e,t,r){if(t.includes("\0")||t.length===0)throw new Error(`toSqlite: invalid table name: ${JSON.stringify(t)}`);let{toSQL:s=(A,P)=>({sql:`INSERT INTO "${P.replace(/"/g,'""')}" (data) VALUES (?)`,params:[JSON.stringify(A)]}),onTransportError:o,batchInsert:a=!1,maxBatchSize:i=1e3,flushIntervalMs:u=0}=r??{},d=A=>s(A,t);if(!a)return ae(n,{onTransportError:o,serialize:d,send:A=>{let P=A;e.query(P.sql,P.params)}});let c=G(null),f=G(void 0,{equals:()=>!1}),l=G(null),p=G(0),h=G(0),g=A=>{try{o?.(A)}catch{}try{c.down([[x,A]])}catch{}},m=[],b=!1,y,v=!1,T=()=>h.down([[x,m.length]]),w=A=>{v||f.down([[x,A]])},O=A=>{v||l.down([[x,A]])},k=A=>{v||p.down([[x,A]])},S=A=>{v||g(A)},E=()=>{if(m.length===0||b)return;b=!0,k(1);try{e.query("BEGIN",[])}catch(W){b=!1,k(0),S({stage:"send",error:W instanceof Error?W:new Error(String(W)),value:void 0});return}let A=m;m=[],T();let P,ue=0;for(let W of A)try{e.query(W.query.sql,W.query.params),ue+=1}catch(de){P=de instanceof Error?de:new Error(String(de));break}if(P){try{e.query("ROLLBACK",[])}catch{}S({stage:"send",error:P,value:void 0});for(let W of A)O({value:W.value,error:P,attempts:1})}else try{e.query("COMMIT",[]);for(let W of A)w(W.value)}catch(W){let de=W instanceof Error?W:new Error(String(W));S({stage:"send",error:de,value:void 0});for(let Ee=0;Ee<ue;Ee++)O({value:A[Ee].value,error:de,attempts:1})}b=!1,k(0)},R=()=>{u>0&&y===void 0&&!v&&(y=setTimeout(()=>{y=void 0,E()},u))},M=n.subscribe(A=>{for(let P of A){let ue=P[0];if(ue===x){let W=P[1],de;try{de=d(W)}catch(Ee){let ze=Ee instanceof Error?Ee:new Error(String(Ee));g({stage:"serialize",error:ze,value:W}),l.down([[x,{value:W,error:ze,attempts:0}]]);continue}m.push({value:W,query:de}),T(),m.length>=i?E():R()}else be.messageTier(ue)>=3&&E()}});return{dispose:()=>{if(!v){y!==void 0&&(clearTimeout(y),y=void 0),E(),v=!0,M();for(let A of[c,f,l,p,h])try{A.down([[K]])}catch{}}},sent:f,failed:l,inFlight:p,errors:c,buffered:h,flush:async()=>{v||E()}}}function Ja(n,e){let{args:t,mapRow:r=o=>o,...s}=e??{};return C(o=>{let a=!0;return n.findMany(t).then(i=>{a&&(o.emit(i.map(r)),o.down([[N]]))}).catch(i=>{if(a)try{o.down([[_,i instanceof Error?i:new Error(String(i))]])}catch{}}),()=>{a=!1}},{...s,describeKind:"producer",completeWhenDepsComplete:!1})}function Ya(n,e){let{mapRow:t=s=>s,...r}=e??{};return C(s=>{let o=!0;return n.execute().then(a=>{o&&(s.emit(a.map(t)),s.down([[N]]))}).catch(a=>{if(o)try{s.down([[_,a instanceof Error?a:new Error(String(a))]])}catch{}}),()=>{o=!1}},{...r,describeKind:"producer",completeWhenDepsComplete:!1})}function Qa(n,e){let{mapRow:t=s=>s,...r}=e??{};return C(s=>{let o=!0;return n.execute().then(a=>{o&&(s.emit(a.map(t)),s.down([[N]]))}).catch(a=>{if(o)try{s.down([[_,a instanceof Error?a:new Error(String(a))]])}catch{}}),()=>{o=!1}},{...r,describeKind:"producer",completeWhenDepsComplete:!1})}Pt();Z();var Xa=0;function Za(n,e){if(e.highWaterMark<1)throw new RangeError("highWaterMark must be >= 1");if(e.lowWaterMark<0)throw new RangeError("lowWaterMark must be >= 0");if(e.lowWaterMark>=e.highWaterMark)throw new RangeError("lowWaterMark must be < highWaterMark");let t=Symbol(`bp-${++Xa}`),r=0,s=!1;return{onEnqueue(){return r+=1,!s&&r>=e.highWaterMark?(s=!0,n([[le,t]]),!0):!1},onDequeue(){return r>0&&(r-=1),s&&r<=e.lowWaterMark?(s=!1,n([[pe,t]]),!0):!1},get pending(){return r},get paused(){return s},dispose(){s&&(s=!1,n([[pe,t]]))}}}Z();fe();function Ho(){let n=new Map,e=null,t=null;function r(o){o.prev?o.prev.next=o.next:e=o.next,o.next?o.next.prev=o.prev:t=o.prev,o.prev=null,o.next=null}function s(o){o.next=e,o.prev=null,e&&(e.prev=o),e=o,t===null&&(t=o)}return{insert(o){if(n.has(o)){this.touch(o);return}let a={key:o,prev:null,next:null};n.set(o,a),s(a)},touch(o){let a=n.get(o);a&&(r(a),s(a))},delete(o){let a=n.get(o);a&&(r(a),n.delete(o))},evict(o){let a=[];for(let i=0;i<o&&t!==null;i++){let u=t;a.push(u.key),r(u),n.delete(u.key)}return a},size(){return n.size}}}function qo(n){return n!=null&&typeof n.then=="function"}function Ot(n){qo(n)&&n.catch(()=>{})}function eu(n,e){let t=new Map,r=e?.maxSize??0,s=r>0?e?.eviction??Ho():null,o=e?.writeThrough??!1;function a(d,c,f){for(let l=0;l<f;l++)try{Ot(n[l].save(d,c))}catch{}}function i(d,c,f=0){for(let l=f;l<n.length;l++){let p;try{p=n[l].load(d)}catch{continue}if(qo(p)){let h=l;p.then(g=>{g!==void 0?(c.down([[x,g]]),a(d,g,h)):i(d,c,h+1)},()=>{i(d,c,h+1)});return}if(p!==void 0){c.down([[x,p]]),a(d,p,l);return}}}function u(){if(!(!s||r<=0))for(;s.size()>=r;){let d=s.evict(1);if(d.length===0)break;for(let c of d){let f=t.get(c);if(f){let l=f.cache;if(f.status!=="sentinel"&&n.length>0){let p=n.length-1;try{Ot(n[p].save(c,l))}catch{}for(let h=0;h<p;h++)try{let g=n[h].delete;g&&Ot(g.call(n[h],c))}catch{}}f.down([[K]])}t.delete(c)}}}return{load(d){let c=t.get(d);if(c)return s?.touch(d),c;s&&r>0&&s.size()>=r&&u();let f=G(void 0);return t.set(d,f),s?.insert(d),i(d,f),f},save(d,c){if(o)for(let l of n)try{Ot(l.save(d,c))}catch{}else if(n[0])try{Ot(n[0].save(d,c))}catch{}let f=t.get(d);if(f)f.down([[x,c]]),s?.touch(d);else{s&&r>0&&s.size()>=r&&u();let l=G(c);t.set(d,l),s?.insert(d)}},invalidate(d){let c=t.get(d);c&&i(d,c)},delete(d){s?.delete(d);let c=t.get(d);c&&c.down([[K]]),t.delete(d);for(let f of n)try{let l=f.delete;l&&Ot(l.call(f,d))}catch{}},has(d){return t.has(d)},get size(){return t.size}}}Te();Z();mt();fe();Tt();Te();Le();Z();fe();var bn=class{_version=0;_store=new Map;_maxSize;_defaultTtl;constructor(e={}){let{maxSize:t,defaultTtl:r}=e;if(t!==void 0&&t<1)throw new RangeError("maxSize must be >= 1");if(r!==void 0&&r<=0)throw new RangeError("defaultTtl must be positive");this._maxSize=t,this._defaultTtl=r}get version(){return this._version}get size(){return this._store.size}has(e){let t=this._store.get(e);return t===void 0?!1:this._isExpired(t)?(this._store.delete(e),this._version+=1,!1):(this._touchLru(e,t),!0)}get(e){let t=this._store.get(e);if(t!==void 0){if(this._isExpired(t)){this._store.delete(e),this._version+=1;return}return this._touchLru(e,t),t.value}}set(e,t,r){let s=this._resolveExpiresAt(r);this._store.has(e)&&this._store.delete(e),this._store.set(e,{value:t,expiresAt:s}),this._evictLruWhileOver(),this._version+=1}setMany(e,t){let r=this._resolveExpiresAt(t),s=0;try{for(let[o,a]of e)this._store.has(o)&&this._store.delete(o),this._store.set(o,{value:a,expiresAt:r}),s+=1}finally{s>0&&(this._evictLruWhileOver(),this._version+=1)}}delete(e){let t=this._store.delete(e);return t&&(this._version+=1),t}deleteMany(e){let t=0;try{for(let r of e)this._store.delete(r)&&(t+=1)}finally{t>0&&(this._version+=1)}return t}clear(){let e=this._store.size;return e===0?0:(this._store.clear(),this._version+=1,e)}pruneExpired(){let e=re(),t=0;for(let[r,s]of this._store)this._isExpired(s,e)&&(this._store.delete(r),t+=1);return t>0&&(this._version+=1),t}toMap(){let e=re(),t=new Map;for(let[r,s]of this._store)this._isExpired(s,e)||t.set(r,s.value);return t}_resolveExpiresAt(e){let t=e??this._defaultTtl;if(t!==void 0){if(!Number.isFinite(t)||t<=0)throw new RangeError(`MapBackend: ttl must be a positive finite number (got ${t})`);return re()+t*1e9}}_isExpired(e,t){return e.expiresAt===void 0?!1:(t??re())>=e.expiresAt}_touchLru(e,t){this._store.delete(e),this._store.set(e,t)}_evictLruWhileOver(){if(this._maxSize!==void 0)for(;this._store.size>this._maxSize;){let e=this._store.keys().next().value;if(e===void 0)break;this._store.delete(e)}}};function gr(n={}){let{name:e,maxSize:t,defaultTtl:r,versioning:s,backend:o,retention:a}=n;if(a&&t!==void 0)throw new RangeError("reactiveMap: `maxSize` (LRU) and `retention` (score-based) are mutually exclusive. Pick one eviction policy.");if(a&&a.archiveThreshold===void 0&&a.maxSize===void 0)throw new RangeError("reactiveMap: `retention` requires at least one of `archiveThreshold` or `maxSize` to trigger archival.");let i=o??new bn({maxSize:t,defaultTtl:r}),u=G(i.toMap(),{name:e,describeKind:"state",equals:(l,p)=>l===p,...s!=null?{versioning:s}:{}});function d(){let l=i.toMap();$(()=>{u.down([[F]]),u.down([[x,l]])})}function c(){if(!a)return;let l=i.toMap(),p=a.archiveThreshold,h=a.maxSize,g=[];for(let[b,y]of l)g.push({key:b,value:y,score:a.score(b,y)});g.sort((b,y)=>b.score-y.score);let m=new Set;if(p!==void 0)for(let b of g)if(b.score<p)m.add(b.key);else break;if(h!==void 0&&g.length-m.size>h)for(let b of g){if(g.length-m.size<=h)break;m.has(b.key)||m.add(b.key)}if(m.size!==0)for(let b of g)m.has(b.key)&&(a.onArchive?.(b.key,b.value,b.score),i.delete(b.key))}function f(l,p="mutation"){let h=i.version;try{return l()}finally{i.version!==h&&(p==="mutation"&&c(),d())}}return{entries:u,has(l){return f(()=>i.has(l),"read")},get(l){return f(()=>i.get(l),"read")},set(l,p,h){f(()=>i.set(l,p,h?.ttl))},setMany(l,p){f(()=>i.setMany(l,p?.ttl))},delete(l){f(()=>i.delete(l))},deleteMany(l){f(()=>i.deleteMany(l))},clear(){f(()=>i.clear())},pruneExpired(){f(()=>i.pruneExpired())},get size(){return i.size},dispose(){}}}Ve();function tu(n){return typeof n=="object"&&n!==null&&"cache"in n&&typeof n.subscribe=="function"}function nu(n,e,t){let r=oe(n),s=r.v!=null,o=G(t?.initialVerified??null,{meta:{...J("verifiable"),...s?{sourceVersion:null}:{}}}),a=t?.trigger!==void 0&&t.trigger!==null,i=null;if(a&&t?.autoVerify?i=Kt(oe(t.trigger),r):a?i=oe(t.trigger):t?.autoVerify&&(i=r),i!==null){let u;if(i===r)u=we(r,d=>e(d));else{let d=r.cache;r.subscribe(c=>{for(let f of c)f[0]===x&&(d=f[1])}),u=we(i,()=>e(d))}ot(u,d=>{$(()=>{if(o.down([[x,d]]),s){let c=r.v;c!=null&&o.meta.sourceVersion.down([[x,{id:c.id,version:c.version}]])}})})}return{node:r,verified:o,trigger:i}}function Jo(n){n.subscribe(()=>{})}function jt(n){return n instanceof Map?n:new Map}function Yo(n,e){if(!Array.isArray(e.upsert))throw new TypeError("distill extraction requires upsert: Array<{ key, value }>");$(()=>{for(let{key:t,value:r}of e.upsert)n.set(t,r);for(let t of e.remove??[])n.delete(t)})}function ru(n,e,t){let r=oe(n),s=gr(t.mapOptions??{}),o=t.budget??2e3,i=t.context!==void 0&&t.context!==null?oe(t.context):G(null),u=jt(s.entries.cache);s.entries.subscribe(p=>{for(let h of p)h[0]===x&&(u=jt(h[1]))});let d=oe(e(r,s.entries));if(ot(d,p=>{Yo(s,p)}),t.evict){let p=new Map,h=he([s.entries],([g])=>{let m=[],b=jt(g);for(let y of p.keys())b.has(y)||(p.get(y)(),p.delete(y));for(let[y,v]of b){let T=t.evict(y,v);if(tu(T)){if(!p.has(y)){let w=ot(T,O=>{O===!0&&s.has(y)&&s.delete(y)});p.set(y,w)}continue}if(typeof T=="boolean"){T&&m.push(y);continue}throw new TypeError("distill evict() must return boolean or Node<boolean>")}return m});ot(h,g=>{for(let m of g)s.delete(m)})}let c=t.consolidateTrigger!==void 0&&t.consolidateTrigger!==null;if(t.consolidate&&c){let p=oe(t.consolidateTrigger),h=we(p,()=>t.consolidate(u));ot(h,g=>{Yo(s,g)})}let f=he([s.entries,i],([p,h])=>{let m=[...jt(p).entries()].map(([v,T])=>({key:v,value:T,score:t.score(T,h),cost:t.cost(T)}));m.sort((v,T)=>T.score-v.score);let b=[],y=o;for(let v of m)v.cost<=y&&(b.push({key:v.key,value:v.value,score:v.score}),y-=v.cost);return b},{meta:{...J("distill",{budget:o})}}),l=he([s.entries],([p])=>jt(p).size);return Jo(f),Jo(l),{store:s,compact:f,size:l}}nr();async function Qo(n){let e=typeof n=="string"?new TextEncoder().encode(n):n,t=await globalThis.crypto.subtle.digest("SHA-256",e),r=new Uint8Array(t),s="";for(let o=0;o<r.length;o++)s+=Xo[r[o]];return s}var Xo=new Array(256);for(let n=0;n<256;n++)Xo[n]=n.toString(16).padStart(2,"0");var yn=class extends Error{constructor(t,r){super(`content-addressed lookup miss in read-strict mode: ${t}`);this.key=t;this.context=r;this.name="ContentAddressedMissError"}};function Zo(n){let e=new Set,t=r=>{if(r===null||typeof r!="object")return r;let s=r;if(e.has(s))return{__cycle:!0};e.add(s);try{if(Array.isArray(r))return r.map(t);let o={};for(let a of Object.keys(r).sort())o[a]=t(r[a]);return o}finally{e.delete(s)}};return JSON.stringify(t(n))}function ou(n){let{storage:e,keyContext:t,keyPrefix:r,mode:s="read-write"}=n,o=t??(i=>i);async function a(i){let u=Zo(o(i)),d=await Qo(u);return r?`${r}:${d}`:d}return{keyFor:a,async lookup(i){if(s==="write")return;let u=await a(i),d=await e.load(u);if(d===void 0){if(s==="read-strict")throw new yn(u,i);return}return d},async store(i,u){if(s==="read")return;let d=await a(i);await e.save(d,u)},async forget(i){if(s==="read"||s==="write"||!e.delete)return;let u=await a(i);await e.delete(u)}}}Zn();async function su(n,e){let t;try{t=await n.text()}catch{t=""}let r=e??"HTTP",s=new Error(`${r} API ${n.status}: ${n.statusText}${t?` \u2014 ${t}`:""}`);return s.status=n.status,s.headers=n.headers,s}en();Te();Le();Dt();Z();fe();dn();Te();Z();ye();fe();Ve();var vn=class{_version=0;_maxSize;_buf;_head=0;_size=0;constructor(e,t){if(t!==void 0&&t<1)throw new RangeError("maxSize must be >= 1");if(this._maxSize=t,t!==void 0){if(this._buf=new Array(t),e&&e.length>0){let r=Math.min(e.length,t),s=e.length-r;for(let o=0;o<r;o++)this._buf[o]=e[s+o];this._size=r}}else this._buf=e?[...e]:[],this._size=this._buf.length}get version(){return this._version}get size(){return this._size}at(e){if(!Number.isInteger(e))return;let t=e>=0?e:this._size+e;if(!(t<0||t>=this._size))return this._maxSize!==void 0?this._buf[(this._head+t)%this._maxSize]:this._buf[t]}append(e){this._rawAppend(e),this._version+=1}appendMany(e){if(e.length===0)return;let t=this._maxSize!==void 0&&e.length>this._maxSize?e.length-this._maxSize:0;for(let r=t;r<e.length;r++)this._rawAppend(e[r]);this._version+=1}clear(){if(this._size===0)return 0;let e=this._size;if(this._maxSize===void 0)this._buf.length=0;else for(let t=0;t<e;t++)this._buf[(this._head+t)%this._maxSize]=void 0;return this._head=0,this._size=0,this._version+=1,e}trimHead(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`trimHead: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return 0;let t=Math.min(e,this._size);if(this._maxSize===void 0)this._buf.splice(0,t);else{for(let r=0;r<t;r++)this._buf[(this._head+r)%this._maxSize]=void 0;this._head=(this._head+t)%this._maxSize}return this._size-=t,this._version+=1,t}slice(e,t){if(!Number.isInteger(e)||e<0)throw new RangeError(`slice: start must be a non-negative integer (got ${e})`);if(t!==void 0&&(!Number.isInteger(t)||t<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${t})`);let r=t===void 0?this._size:Math.min(Math.max(t,0),this._size),s=Math.min(e,this._size);if(s>=r)return[];let o=r-s;if(this._maxSize===void 0)return this._buf.slice(s,r);let a=new Array(o);for(let i=0;i<o;i++)a[i]=this._buf[(this._head+s+i)%this._maxSize];return a}tail(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`tail: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return[];let t=Math.min(e,this._size);return this.slice(this._size-t,this._size)}toArray(){if(this._maxSize===void 0)return[...this._buf];let e=new Array(this._size);for(let t=0;t<this._size;t++)e[t]=this._buf[(this._head+t)%this._maxSize];return e}snapshot(){return this.toArray()}restore(e){if(this._maxSize===void 0){this._buf.length=0;for(let t=0;t<e.length;t++)this._buf.push(e[t]);this._size=this._buf.length}else{let t=this._maxSize;for(let o=0;o<t;o++)this._buf[o]=void 0;this._head=0;let r=Math.min(e.length,t),s=e.length-r;for(let o=0;o<r;o++)this._buf[o]=e[s+o];this._size=r}this._version+=1}_rawAppend(e){if(this._maxSize===void 0){this._buf.push(e),this._size=this._buf.length;return}this._size<this._maxSize?(this._buf[(this._head+this._size)%this._maxSize]=e,this._size+=1):(this._buf[this._head]=e,this._head=(this._head+1)%this._maxSize)}};function Wt(n){return n.subscribe(()=>{})}var iu=64;function yr(n,e={}){let{name:t,maxSize:r,versioning:s,guard:o,backend:a}=e,i=a??new vn(n,r),u=G(i.toArray(),{name:t,describeKind:"state",equals:(k,S)=>k===S,...s!=null?{versioning:s}:{},...o!=null?{guard:o}:{}});function d(){let k=i.toArray();$(()=>{u.down([[F]],{internal:!0}),u.down([[x,k]],{internal:!0})})}let c=new Map,f=new Map,l=new Map;function p(k,S){return`${k}:${S===void 0?"END":S}`}function h(k){if(k.size<iu)return;let S=k.keys().next();if(S.done)return;let E=k.get(S.value);E!==void 0&&E.dispose(),k.delete(S.value)}function g(k){let S=i.version;try{return k()}finally{i.version!==S&&d()}}function m(k){if(!Number.isInteger(k)||k<0)throw new RangeError(`tail: n must be a non-negative integer (got ${k})`);let S=c.get(k);if(S!==void 0)return c.delete(k),c.set(k,S),S.node;h(c);let E=he([u],([M])=>{let L=M;return k===0||L.length===0?[]:L.slice(Math.max(0,L.length-k))},{initial:i.tail(k),describeKind:"derived"}),R=Wt(E);return c.set(k,{node:E,dispose:R}),E}function b(k,S){if(!Number.isInteger(k)||k<0)throw new RangeError(`slice: start must be a non-negative integer (got ${k})`);if(S!==void 0&&(!Number.isInteger(S)||S<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${S})`);let E=p(k,S),R=f.get(E);if(R!==void 0)return f.delete(E),f.set(E,R),R.node;h(f);let M=he([u],([A])=>{let P=A;return S===void 0?P.slice(k):P.slice(k,S)},{initial:i.slice(k,S),describeKind:"derived"}),L=Wt(M);return f.set(E,{node:M,dispose:L}),M}function y(k){let S=l.get(k);if(S!==void 0)return S.node;let E=he([u,k],([M,L])=>{let A=M,P=Math.max(0,Math.trunc(L??0));return A.slice(P)},{initial:[],describeKind:"derived"}),R=Wt(E);return l.set(k,{node:E,dispose:R}),E}let v,T;function w(){v===void 0&&(v=V([u],(k,S,E)=>{let R=k[0],L=R!=null&&R.length>0?R.at(-1):E.prevData[0];if(L==null||L.length===0){S.down([[D]]);return}S.emit(L[L.length-1])},{name:t!=null?`${t}::lastValue`:"lastValue",describeKind:"derived",initial:i.size===0?void 0:i.at(i.size-1)}),T=he([u],([k])=>k.length>0,{name:t!=null?`${t}::hasLatest`:"hasLatest",describeKind:"derived",initial:i.size>0}),Wt(v),Wt(T))}let O={entries:u,get size(){return i.size},at(k){return i.at(k)},append(k){g(()=>i.append(k))},appendMany(k){k.length!==0&&g(()=>i.appendMany(k))},clear(){g(()=>i.clear())},trimHead(k){g(()=>i.trimHead(k))},withLatest(){return w(),u},get lastValue(){return w(),v},get hasLatest(){return w(),T},view(k){switch(k.kind){case"tail":return m(k.n);case"slice":return b(k.start,k.stop);case"fromCursor":return y(k.cursor)}},attach(k){let S=k.subscribe(E=>{for(let R of E)R[0]===x&&O.append(R[1])});return()=>S()},attachStorage(k){if(k.length===0)return()=>{};let S=new Map;for(let R of k)S.set(R,i.size);(async()=>{for(let R of k)if(typeof R.loadEntries=="function")try{let M=await Promise.resolve(R.loadEntries());M.entries.length>0&&i.size===0&&(i.restore(M.entries),S.set(R,M.entries.length),d());break}catch{}})();let E=u.subscribe(R=>{for(let M of R){if(M[0]!==x)continue;let L=M[1];for(let A of k){let P=S.get(A)??0;if(L.length<P){try{let W=A.appendEntries(L);W instanceof Promise&&W.catch(()=>{})}catch{}S.set(A,L.length);continue}if(L.length===P)continue;let ue=L.slice(P);S.set(A,L.length);try{let W=A.appendEntries(ue);W instanceof Promise&&W.catch(()=>{})}catch{}}}});return()=>E()},disposeAllViews(){for(let k of c.values())k.dispose();c.clear();for(let k of f.values())k.dispose();f.clear();for(let k of l.values())k.dispose();l.clear()},dispose(){for(let k of c.values())k.dispose();c.clear();for(let k of f.values())k.dispose();f.clear();for(let k of l.values())k.dispose();l.clear()}};return O}var br=new WeakMap;function au(n){let e=br.get(n);if(e)return e;let t=n.map(c=>c.cache??[]),r=t.flat(),s=G(r,{name:"mergeReactiveLogs",describeKind:"state",equals:(c,f)=>c===f}),o=n.map((c,f)=>[...t[f]??[]]),a=[];for(let c=0;c<n.length;c++){let f=c,l=n[f].subscribe(p=>{for(let h of p)if(h[0]===x)o[f]=[...h[1]],s.emit(o.flat());else if(h[0]===N){o[f]=[];let g=a[f];g!==void 0&&(a[f]=void 0,g())}else h[0]===_&&s.down([[_,h[1]]])});a.push(l)}let i=et(s),u=!1,d={node:s,dispose(){if(!u){u=!0;for(let c of a)c?.();a.length=0,i(),br.delete(n)}}};return br.set(n,d),d}function uu(n,e){let t=n.cache??0;return t>=e?!1:(n.down([[F],[x,t+1]]),!0)}var ts=Fr((n,e)=>{n("observe"),n("signal"),e("write")});function du(n){let e=yr([],{name:n.name,maxSize:n.retainedLimit??1024,guard:n.guard??ts,...n.versioning!=null?{versioning:n.versioning}:{}});return e.withLatest(),n.graph&&n.graph.add(e.entries,{name:n.name}),e}function vr(n){if(n===null||typeof n!="object"||Object.isFrozen(n))return n;for(let e of Object.keys(n))vr(n[e]);return Object.freeze(n)}var es=new WeakSet;function Tr(n){let e=n.cache,t=typeof e=="number"&&Number.isFinite(e);!t&&e!==void 0&&!es.has(n)&&(es.add(n),console.warn(`bumpCursor: cursor cache held a non-numeric value (${String(e)}); resetting to 0. Causes include: a snapshot codec round-tripping the cursor as a string / null / NaN, OR a malformed initial seed (e.g. state<number>(NaN)). Audit consumers may see colliding seq values after this point.`));let s=(t?e:0)+1;return n.down([[F],[x,s]]),s}function Ut(n,e,t,r,s,o){let a=e(t,r,s);if(a===void 0)return;let i=o!=null?{...a,handlerVersion:o}:a;n.append(i)}function cu(n,e){let t=e.freeze??!0;return function(...s){let o=t?s.map(vr):s,a=ne(),i=e.seq?Tr(e.seq):void 0;try{let u=n(...o);return e.audit&&e.onSuccess&&Ut(e.audit,e.onSuccess,o,u,{t_ns:a,seq:i},e.handlerVersion),u}catch(u){if(e.audit&&e.onFailure){let d=u instanceof Error?u.name:typeof u;Ut(e.audit,e.onFailure,o,u,{t_ns:a,seq:i,errorType:d},e.handlerVersion)}throw u}}}function lu(n,e){let t=e.freeze??!0;return function(...s){let o=t?s.map(vr):s,a=ne(),i,u,d=!1,c;try{$(()=>{e.seq&&(c=Tr(e.seq));try{i=n(...o),e.audit&&e.onSuccess&&Ut(e.audit,e.onSuccess,o,i,{t_ns:a,seq:c},e.handlerVersion)}catch(f){throw u=f,d=!0,f}})}catch(f){if(d&&e.audit&&e.onFailure){let l=u instanceof Error?u.name:typeof u;Ut(e.audit,e.onFailure,o,u,{t_ns:a,seq:c,errorType:l},e.handlerVersion)}throw d?u:f}return i}}function fu(n,e,t=0){let r=G(t,{name:e,describeKind:"state"});return n.add(r,{name:e}),r}function pu(n,e,t,r=0){let s={},o=new Be(e);for(let a of t){let i=G(r,{name:a,describeKind:"state"});o.add(i,{name:a}),s[a]=i}return n.mount(e,o),s}var wr=require("rxjs");Z();function hu(n,e){return e?.raw?new wr.Observable(t=>n.subscribe(s=>{if(!t.closed){t.next(s);for(let o of s){if(o[0]===_){t.error(o[1]);return}if(o[0]===N){t.complete();return}}}})):new wr.Observable(t=>n.subscribe(s=>{for(let o of s){if(t.closed)return;if(o[0]===x)t.next(o[1]);else if(o[0]===_){t.error(o[1]);return}else if(o[0]===N){t.complete();return}}}))}Tt();Te();Z();ye();var Tn=class{_version=0;_topics=new Set;get version(){return this._version}get topicCount(){return this._topics.size}hasTopic(e){return this._topics.has(e)}topicNames(){return this._topics.values()}createTopic(e){return this._topics.has(e)?!1:(this._topics.add(e),this._version+=1,!0)}removeTopic(e){let t=this._topics.delete(e);return t&&(this._version+=1),t}};function mu(n={}){let{backend:e}=n,t=e??new Tn,r=new Map;function s(o){let a=r.get(o);return a===void 0&&(a=V({describeKind:"state"}),r.set(o,a),t.createTopic(o)),a}return{topic(o){return s(o)},publish(o,a){s(o).emit(a)},publishMany(o){$(()=>{for(let[a,i]of o)s(a).emit(i)})},removeTopic(o){let a=r.get(o);return a===void 0?!1:(r.delete(o),t.removeTopic(o),a.down([[K]]),!0)},has(o){return t.hasTopic(o)},get size(){return t.topicCount},topicNames(){return t.topicNames()}}}Te();Z();fe();function ns(n,e){if(n===e)return 0;let t=typeof n;if(t===typeof e&&(t==="number"||t==="string"||t==="boolean"||t==="bigint")){let s=n,o=e;return s<o?-1:s>o?1:0}return String(n).localeCompare(String(e))}function gu(n,e){let t=ns(n[0],e[0]);return t!==0?t:ns(n[1],e[1])}function rs(n){return[n.secondary,n.primary]}function _t(n,e){let t=rs(e),r=0,s=n.length;for(;r<s;){let o=r+s>>1;gu(t,rs(n[o]))>0?r=o+1:s=o}return r}var wn=class{_version=0;_buf=[];_byPrimary=new Map;get version(){return this._version}get size(){return this._buf.length}has(e){return this._byPrimary.has(e)}get(e){return this._byPrimary.get(e)?.value}upsert(e,t,r,s){let o=this._byPrimary.get(e),a={primary:e,secondary:t,value:r};if(o!==void 0&&s?.equals?.(o,a))return!1;if(o!==void 0){let u=_t(this._buf,o);this._buf.splice(u,1)}let i=_t(this._buf,a);return this._buf.splice(i,0,a),this._byPrimary.set(e,a),this._version+=1,o===void 0}upsertMany(e,t){let r=0;try{for(let s of e){let o=this._byPrimary.get(s.primary),a={primary:s.primary,secondary:s.secondary,value:s.value};if(o!==void 0&&t?.equals?.(o,a))continue;if(o!==void 0){let u=_t(this._buf,o);this._buf.splice(u,1)}let i=_t(this._buf,a);this._buf.splice(i,0,a),this._byPrimary.set(s.primary,a),r+=1}}finally{r>0&&(this._version+=1)}return r}delete(e){let t=this._byPrimary.get(e);if(t===void 0)return!1;let r=_t(this._buf,t);return this._buf.splice(r,1),this._byPrimary.delete(e),this._version+=1,!0}deleteMany(e){let t=0;try{for(let r of e){let s=this._byPrimary.get(r);if(s===void 0)continue;let o=_t(this._buf,s);this._buf.splice(o,1),this._byPrimary.delete(r),t+=1}}finally{t>0&&(this._version+=1)}return t}clear(){let e=this._buf.length;return e===0?0:(this._buf.length=0,this._byPrimary.clear(),this._version+=1,e)}toArray(){return[...this._buf]}toPrimaryMap(){let e=new Map;for(let t of this._buf)e.set(t.primary,t.value);return e}};function bu(n){return n.subscribe(()=>{})}function yu(n={}){let{name:e,versioning:t,equals:r,backend:s}=n,o=s??new wn;function a(p){return p?.equals!==void 0||r===void 0?p:{...p,equals:r}}let i=G([],{name:e,describeKind:"state",equals:(p,h)=>p===h,...t!=null?{versioning:t}:{}}),u=he([i],([p])=>{let h=p,g=new Map;for(let m of h)g.set(m.primary,m.value);return g},{initial:o.toPrimaryMap(),describeKind:"derived"}),d=bu(u),c=!1;function f(){let p=o.toArray();$(()=>{i.down([[F]]),i.down([[x,p]])})}function l(p){let h=o.version;try{return p()}finally{o.version!==h&&f()}}return{ordered:i,byPrimary:u,has(p){return o.has(p)},get(p){return o.get(p)},get size(){return o.size},upsert(p,h,g,m){return l(()=>o.upsert(p,h,g,a(m)))},upsertMany(p,h){let g=[...p];g.length!==0&&l(()=>o.upsertMany(g,a(h)))},delete(p){l(()=>o.delete(p))},deleteMany(p){let h=[...p];h.length!==0&&l(()=>o.deleteMany(h))},clear(){l(()=>o.clear())},dispose(){c||(c=!0,d())}}}Te();Z();fe();var kn=class{_version=0;_buf;constructor(e){this._buf=e?[...e]:[]}get version(){return this._version}get size(){return this._buf.length}at(e){if(!Number.isInteger(e))return;let t=e>=0?e:this._buf.length+e;if(!(t<0||t>=this._buf.length))return this._buf[t]}append(e){this._buf.push(e),this._version+=1}appendMany(e){if(e.length===0)return;let t=this._buf.length;this._buf.length=t+e.length;for(let r=0;r<e.length;r++)this._buf[t+r]=e[r];this._version+=1}insert(e,t){if(!Number.isInteger(e)||e<0||e>this._buf.length)throw new RangeError(`insert: index ${e} out of range [0, ${this._buf.length}]`);this._buf.splice(e,0,t),this._version+=1}insertMany(e,t){if(!Number.isInteger(e)||e<0||e>this._buf.length)throw new RangeError(`insertMany: index ${e} out of range [0, ${this._buf.length}]`);t.length!==0&&(this._buf.splice(e,0,...t),this._version+=1)}pop(e){if(this._buf.length===0)throw new RangeError("pop from empty list");if(!Number.isInteger(e))throw new RangeError(`pop: index ${e} must be an integer`);let t=e>=0?e:this._buf.length+e;if(t<0||t>=this._buf.length)throw new RangeError(`pop: index ${e} out of range`);let[r]=this._buf.splice(t,1);return this._version+=1,r}clear(){let e=this._buf.length;return e===0?0:(this._buf.length=0,this._version+=1,e)}toArray(){return[...this._buf]}};function vu(n,e={}){let{name:t,versioning:r,backend:s}=e,o=s??new kn(n),a=G(o.toArray(),{name:t,describeKind:"state",equals:(d,c)=>d===c,...r!=null?{versioning:r}:{}});function i(){let d=o.toArray();$(()=>{a.down([[F]]),a.down([[x,d]])})}function u(d){let c=o.version;try{return d()}finally{o.version!==c&&i()}}return{items:a,get size(){return o.size},at(d){return o.at(d)},append(d){u(()=>o.append(d))},appendMany(d){u(()=>o.appendMany(d))},insert(d,c){u(()=>o.insert(d,c))},insertMany(d,c){u(()=>o.insertMany(d,c))},pop(d=-1){return u(()=>o.pop(d))},clear(){u(()=>o.clear())},dispose(){}}}fn();Z();Ve();function Tu(n,e={}){let t=e.keyFn??(s=>String(s)),r=new Map;return s=>{let o=t(s),a=r.get(o);if(a)return a;let i=n(s),u;i!=null&&typeof i.then=="function"?u=Promise.resolve(i):i!=null&&typeof i=="object"&&"subscribe"in i&&"cache"in i?u=fr(i):i!=null&&typeof i=="object"&&Symbol.asyncIterator in i?u=(async()=>{let f=i[Symbol.asyncIterator]();try{let{value:l,done:p}=await f.next();if(p)throw new Error("singleFromAny: factory returned empty async iterable");return l}finally{await f.return?.()}})():i!=null&&typeof i=="object"&&Symbol.iterator in i?u=(async()=>{let f=i[Symbol.iterator]();try{let{value:l,done:p}=f.next();if(p)throw new Error("singleFromAny: factory returned empty iterable");return l}finally{f.return?.()}})():u=Promise.resolve(i);let d,c=()=>{r.get(o)===d&&r.delete(o)};return d=u.then(f=>(c(),f),f=>{throw c(),f}),r.set(o,d),d}}function wu(n,e={}){let t=e.keyFn??(s=>String(s)),r=new Map;return s=>{let o=t(s),a=r.get(o);if(a)return a;let i=oe(n(s));r.set(o,i);let u=i.subscribe(d=>{for(let c of d)if(c[0]===_||c[0]===N){r.get(o)===i&&r.delete(o),u();return}});return i}}Ve();function xn(n){if(n===null||typeof n!="object")return n;if(Array.isArray(n))return n.map(xn);let e=n,t=Object.keys(e).sort(),r={};for(let s of t)r[s]=xn(e[s]);return r}function kr(n){return JSON.stringify(xn(n),void 0,0)}var ku=new TextEncoder,xu=new TextDecoder("utf-8",{fatal:!0}),Ht={name:"json",version:1,encode(n){return ku.encode(kr(n))},decode(n){return JSON.parse(xu.decode(n))}};function Nu(){return Ht}function Nn(){let n=new Map;return{name:"memory",read(e){let t=n.get(e);return t===void 0?void 0:new Uint8Array(t)},write(e,t){n.set(e,new Uint8Array(t))},delete(e){n.delete(e)},list(e){let t=[...n.keys()];return e?t.filter(r=>r.startsWith(e)).sort():t.sort()}}}function xr(n,e={}){let t=e.codec??Ht,r=e.name??n.name??"snapshot",s=e.keyOf??(f=>f.name??e.name??n.name??"snapshot"),o,a=0,i=e.compactEvery,u,d={name:r,debounceMs:e.debounceMs,compactEvery:i,filter:e.filter,keyOf:s,save(f){if(!(e.filter&&!e.filter(f))&&(o={snapshot:f},a+=1,i!==void 0&&a%i===0||!e.debounceMs))return c()},load(){let f=u??r,l=n.read(f);if(l!==void 0)return l instanceof Uint8Array?l.length===0?void 0:t.decode(l):Promise.resolve(l).then(p=>p===void 0||p.length===0?void 0:t.decode(p))},async flush(){await c()},async rollback(){o=void 0}};function c(){let f=o;if(!f)return;o=void 0;let l=s(f.snapshot),p=t.encode(f.snapshot),h=n.write(l,p);if(h instanceof Promise)return h.then(()=>{u=l});u=l}return d}function os(n,e={}){let t=e.codec??Ht,r=e.name??n.name??"append-log",s=e.keyOf??(l=>r),o=e.compactEvery,a=new Map,i=0,u,d={name:r,debounceMs:e.debounceMs,compactEvery:o,keyOf:s,appendEntries(l){if(l.length!==0){for(let p of l){let h=s(p),g=a.get(h);g||(g=[],a.set(h,g)),g.push(p)}if(i+=l.length,o!==void 0&&i%o===0||!e.debounceMs)return c()}},async loadEntries(l){let p=l?.keyFilter,h=n.list===void 0?p!==void 0?[p]:[r]:await Promise.resolve(n.list(p)),g=[];for(let m of h){let b=await Promise.resolve(n.read(m));if(b===void 0||b.length===0)continue;let y=t.decode(b);Array.isArray(y)&&g.push(...y)}return{entries:g,cursor:void 0}},async flush(){await c()},async rollback(){a=new Map}};function c(){if(a.size===0)return;let l=a;a=new Map;let p=(u??Promise.resolve()).then(()=>{let h=f(l);return h instanceof Promise?h:Promise.resolve()},()=>{let h=f(l);return h instanceof Promise?h:Promise.resolve()});return u=p.finally(()=>{u===p&&(u=void 0)}),u}function f(l){let p=[];for(let[h,g]of l){let m=n.read(h),b=y=>{let T=[...y===void 0||y.length===0?[]:t.decode(y)??[],...g],w=t.encode(T);return n.write(h,w)};if(m instanceof Promise)p.push(m.then(async y=>{let v=b(y);v instanceof Promise&&await v}));else{let y=b(m);y instanceof Promise&&p.push(y)}}if(p.length>0)return Promise.all(p).then(()=>{})}return d}function Nr(n,e={}){let t=e.codec??Ht,r=e.name??n.name??"kv",s=e.compactEvery,o=new Map,a=0,i={name:r,debounceMs:e.debounceMs,compactEvery:s,filter:e.filter,save(d,c){if(!(e.filter&&!e.filter(d,c))&&(o.set(d,c),a+=1,s!==void 0&&a%s===0||!e.debounceMs))return u()},load(d){let c=n.read(d);if(c!==void 0)return c instanceof Uint8Array?c.length===0?void 0:t.decode(c):Promise.resolve(c).then(f=>f===void 0||f.length===0?void 0:t.decode(f))},delete(d){if(o.delete(d),!!n.delete)return n.delete(d)},list(d){return n.list?n.list(d):[]},async flush(){await u()},async rollback(){o=new Map}};function u(){if(o.size===0)return;let d=o;o=new Map;let c=[];for(let[f,l]of d){let p=t.encode(l),h=n.write(f,p);h instanceof Promise&&c.push(h)}if(c.length>0)return Promise.all(c).then(()=>{})}return i}function Ou(n){return xr(Nn(),n)}function _u(n){return os(Nn(),n)}function Su(n){return Nr(Nn(),n)}function Eu(n,e){let t={name:e?.name??"dict-kv",read(r){return n[r]},write(r,s){n[r]=new Uint8Array(s)},delete(r){delete n[r]},list(r){let s=Object.keys(n).sort();return r?s.filter(o=>o.startsWith(r)):s}};return Nr(t,e)}function Ru(n,e){return xr({name:"dict",read(r){return n[r]},write(r,s){n[r]=new Uint8Array(s)},delete(r){delete n[r]},list(r){let s=Object.keys(n).sort();return r?s.filter(o=>o.startsWith(r)):s}},e)}Z();ye();fe();dn();function Mu(n,e,t,r){let s=new Be(n,r);s.add(e,{name:"source"});let o=G(t,{meta:{kind:"stratify_rules"}});s.add(o,{name:"rules"});for(let a of t)Au(s,e,o,a);return s}function Au(n,e,t,r){let s=`branch/${r.name}`,o=Symbol("noValue"),a=!1,i=!1,u=!1,d=o,c=!1,f=t.cache??[];function l(g){if(u){u=!1;let m=d;if(d=o,m!==o){let b=f.find(v=>v.name===r.name),y=!1;try{y=b?.classify(m)??!1}catch{y=!1}y?(c=!1,g.emit(m)):c&&(c=!1,g.down([[F],[D]]))}else c?(c=!1,g.down([[F],[D]])):g.down([[D]])}}let p=V([],(g,m)=>{let b=e.subscribe(v=>{for(let T of v)h(T,0,m)}),y=t.subscribe(v=>{for(let T of v)h(T,1,m)});return()=>{b(),y()}},{describeKind:"derived",meta:{kind:"stratify_branch",branch:r.name},completeWhenDepsComplete:!1});function h(g,m,b){let y=g[0];return y===F?(m===0?(a=!0,c=!0):i=!0,!0):y===x||y===D?(m===0?(a=!1,u=!0,d=y===x?g[1]:o):(y===x&&(f=g[1]),i=!1),a||i||l(b),!0):y===N||y===_||y===K?(a=!1,i=!1,u=!1,d=o,c=!1,m===0&&b.down([g]),!0):m===1}if(n.add(p,{name:s}),r.ops){let g=r.ops(p),m=`branch/${r.name}/out`;n.add(g,{name:m})}}on();var Ql=Math.LN2/604800;function ss(n,e,t,r=0){if(!Number.isFinite(n))return r;if(!Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0)return Math.max(r,n);let s=n*Math.exp(-t*e);return Math.max(r,s)}Te();Z();ye();fe();Tt();Ve();Z();var Cu=new Map([[Ne,"INVALIDATE"],[le,"PAUSE"],[pe,"RESUME"],[K,"TEARDOWN"],[N,"COMPLETE"],[_,"ERROR"]]),Du=new Map([["INVALIDATE",Ne],["PAUSE",le],["RESUME",pe],["TEARDOWN",K],["COMPLETE",N],["ERROR",_]]);function st(n){let e=Cu.get(n);return e||(Symbol.keyFor(n)??"UNKNOWN")}function St(n){let e=Du.get(n);if(e)return e;if(n&&n!=="UNKNOWN")return Symbol.for(n)}function Et(n){return n instanceof Error?{message:n.message,name:n.name,stack:n.stack}:{message:String(n),name:"Error"}}function Rt(n){let e=new Error(n.message);return e.name=n.name,n.stack&&(e.stack=n.stack),e}function it(n){if(typeof MessagePort<"u"&&n instanceof MessagePort)return{post(e,t){n.postMessage(e,t??[])},listen(e){let t=r=>e(r.data);return n.addEventListener("message",t),n.start(),()=>n.removeEventListener("message",t)},terminate(){n.close()}};if(typeof SharedWorker<"u"&&n instanceof SharedWorker)return it(n.port);if(typeof Worker<"u"&&n instanceof Worker)return{post(e,t){n.postMessage(e,t??[])},listen(e){let t=r=>e(r.data);return n.addEventListener("message",t),()=>n.removeEventListener("message",t)},terminate(){n.terminate()}};if(typeof BroadcastChannel<"u"&&n instanceof BroadcastChannel)return{post(e,t){t&&t.length>0&&console.warn("[graphrefly] WorkerTransport: BroadcastChannel does not support Transferable objects. The transfer argument is ignored and objects will be cloned instead."),n.postMessage(e)},listen(e){let t=r=>e(r.data);return n.addEventListener("message",t),()=>n.removeEventListener("message",t)},terminate(){n.close()}};if(typeof ServiceWorker<"u"&&n instanceof ServiceWorker)return{post(e,t){n.postMessage(e,t??[])},listen(e){let t=r=>{r.source===n&&e(r.data)};return navigator.serviceWorker.addEventListener("message",t),()=>navigator.serviceWorker.removeEventListener("message",t)}};throw new Error("createTransport: unsupported target type. Expected Worker, SharedWorker, ServiceWorker, BroadcastChannel, or MessagePort.")}function Pu(n){return typeof n=="object"&&n!==null&&typeof n.post=="function"&&typeof n.listen=="function"}function is(n,e){let t=Pu(n)?n:it(n),r=e.name??"workerBridge",s=Object.entries(e.expose??{}),o=e.import??[],a=e.transfer??{},i=G("connecting",{name:`${r}::meta::status`}),u=G(null,{name:`${r}::meta::error`}),d=new Map,c=new Map;for(let y of o){let v=G(void 0,{name:`${r}::${y}`});d.set(y,v)}let f;if(s.length>0){let y=s.map(([,w])=>w),v=V(y,(w,O)=>{let k={};for(let S=0;S<s.length;S++){let[E]=s[S],R=w[S];R!=null&&R.length>0&&(k[E]=R.at(-1))}Object.keys(k).length!==0&&O.emit(k)},{name:`${r}::aggregated`,partial:!0});f=ft([v],w=>{let O=w[0];if(O==null||Object.keys(O).length===0)return;let k=[];for(let R of Object.keys(O)){let M=a[R];M&&k.push(...M(O[R]))}let S;for(let[R,M]of s)R in O&&M.v!=null&&(S==null&&(S={}),S[R]=M.v.version);let E={t:"b",u:O,...S?{v:S}:{}};try{t.post(E,k.length>0?k:void 0)}catch(R){u.down([[x,R instanceof Error?R:new Error(String(R))]])}}).subscribe(()=>{})}let l=!1,p=t.listen(y=>{if(l)return;let v=y;switch(v.t){case"r":{$(()=>{for(let[w,O]of Object.entries(v.stores)){let k=d.get(w);k&&k.down([[x,O]])}}),i.down([[x,"connected"]]);let T={};for(let[w,O]of s)T[w]=O.cache;t.post({t:"i",stores:T});break}case"v":{let T=d.get(v.s);T&&T.down([[x,v.d]]);break}case"b":{$(()=>{for(let[T,w]of Object.entries(v.u)){let O=v.v?.[T];if(O!=null){let S=c.get(T);if(S!=null&&O<=S)continue;c.set(T,O)}let k=d.get(T);k&&k.down([[x,w]])}});break}case"e":{let T=d.get(v.s);T&&T.down([[_,Rt(v.err)]]);break}case"s":{let T=St(v.sig);if(!T)break;let w=v.s==="*"?[...d.values()]:d.has(v.s)?[d.get(v.s)]:[];for(let O of w)O.down(v.d===void 0?[[T]]:[[T,v.d]]);break}}}),h=[];for(let[y,v]of s){let T=v.subscribe((w=>{if(!l)for(let O of w){let k=O[0];k!==x&&(be.isLocalOnly(k)||(k===_?t.post({t:"e",s:y,err:Et(O[1])}):t.post({t:"s",s:y,sig:st(k),d:O.length>1?O[1]:void 0})))}}));h.push(T)}let g;if(e.timeoutMs!=null&&e.timeoutMs>0){let y=rt(e.timeoutMs),v=hn(i,w=>w==="connected");g=pr(Kt(pn(y,()=>"timeout"),pn(v,()=>"ready"))).subscribe(w=>{for(let O of w)O[0]===x&&O[1]==="timeout"&&(u.down([[x,new Error("Worker bridge handshake timeout")]]),m())})}function m(){if(!l){l=!0,g?.(),t.post({t:"s",s:"*",sig:st(K)}),f&&f();for(let y of h)y();h.length=0,p(),i.down([[x,"closed"]]),c.clear(),d.clear()}}let b={meta:{status:i,error:u},destroy:m};for(let[y,v]of d)b[y]=v;return b}Te();Z();ye();fe();function Lu(n){return typeof n=="object"&&n!==null&&typeof n.post=="function"&&typeof n.listen=="function"}function as(n,e){let t=Lu(n)?n:it(n),r=e.import??[],s=e.transfer??{},o=new Map,a=new Map,i={};for(let m of r){let b=G(void 0,{name:`worker::${m}`});o.set(m,b),i[m]=b}let u=e.expose(i),d=Object.entries(u),c,f=!1;if(d.length>0){let m=d.map(([,v])=>v),b=V(m,(v,T)=>{let w={};for(let O=0;O<d.length;O++){let[k]=d[O],S=v[O];S!=null&&S.length>0&&(w[k]=S.at(-1))}Object.keys(w).length!==0&&T.emit(w)},{name:"workerSelf::aggregated",partial:!0});c=ft([b],v=>{if(f)return;let T=v[0];if(T==null||Object.keys(T).length===0)return;let w=[];for(let S of Object.keys(T)){let E=s[S];E&&w.push(...E(T[S]))}let O;for(let[S,E]of d)S in T&&E.v!=null&&(O==null&&(O={}),O[S]=E.v.version);let k={t:"b",u:T,...O?{v:O}:{}};try{t.post(k,w.length>0?w:void 0)}catch{}}).subscribe(()=>{})}let l=[];for(let[m,b]of d){let y=b.subscribe((v=>{if(!f)for(let T of v){let w=T[0];w!==x&&(be.isLocalOnly(w)||(w===_?t.post({t:"e",s:m,err:Et(T[1])}):t.post({t:"s",s:m,sig:st(w),d:T.length>1?T[1]:void 0})))}}));l.push(y)}let p=t.listen(m=>{if(f)return;let b=m;switch(b.t){case"i":{$(()=>{for(let[y,v]of Object.entries(b.stores)){let T=o.get(y);T&&T.down([[x,v]])}});break}case"v":{let y=o.get(b.s);y&&y.down([[x,b.d]]);break}case"b":{$(()=>{for(let[y,v]of Object.entries(b.u)){let T=b.v?.[y];if(T!=null){let O=a.get(y);if(O!=null&&T<=O)continue;a.set(y,T)}let w=o.get(y);w&&w.down([[x,v]])}});break}case"e":{let y=o.get(b.s);y&&y.down([[_,Rt(b.err)]]);break}case"s":{let y=St(b.sig);if(!y)break;if(y===K&&b.s==="*"){g();return}let v=b.s==="*"?[...o.values()]:o.has(b.s)?[o.get(b.s)]:[];for(let T of v)T.down(b.d===void 0?[[y]]:[[y,b.d]]);break}}}),h={};for(let[m,b]of d)h[m]=b.cache;t.post({t:"r",stores:h});function g(){if(!f){f=!0,c&&c();for(let m of l)m();l.length=0,p(),t.terminate?.(),a.clear(),o.clear()}}return{destroy:g}}0&&(module.exports={CircuitOpenError,ContentAddressedMissError,DEFAULT_AUDIT_GUARD,NS_PER_MS,NS_PER_SEC,NativeIndexBackend,NativeListBackend,NativeLogBackend,NativeMapBackend,NativePubSubBackend,RateLimiterOverflowError,ResettableTimer,TimeoutError,appendAudit,appendLogStorage,audit,awaitSettled,budgetGate,buffer,bufferCount,bufferTime,bumpCursor,cached,canonicalJson,cascadingCache,catchError,checkpointToRedis,checkpointToS3,circuitBreaker,combine,combineLatest,concat,concatMap,constant,contentAddressedStorage,createAuditLog,createTransport,createWatermarkController,csvRows,debounce,debounceTime,decay,decorrelatedJitter,defer,delay,deserializeError,dictKv,dictSnapshot,distill,distinctUntilChanged,domainMeta,elementAt,empty,escapeRegexChar,exhaustMap,exponential,externalBundle,externalProducer,fallback,fibonacci,filter,find,first,firstValueFrom,firstWhere,flatMap,forEach,fromAny,fromAsyncIter,fromCSV,fromClickHouseWatch,fromCron,fromDrizzle,fromEvent,fromHTTP,fromHTTPPoll,fromHTTPStream,fromIter,fromKafka,fromKysely,fromMCP,fromNATS,fromNDJSON,fromOTel,fromPrisma,fromPrometheus,fromPromise,fromPulsar,fromRabbitMQ,fromRaf,fromRedisStream,fromSSE,fromSqlite,fromSqliteCursor,fromStatsD,fromSyslog,fromTimer,fromWebSocket,fromWebSocketReconnect,fromWebhook,globToRegExp,interval,jsonCodec,jsonCodecFor,keepalive,kvStorage,last,lightMutation,linear,lru,makeHttpError,map,matchesAnyPattern,matchesCron,memoryAppendLog,memoryBackend,memoryKv,memorySnapshot,merge,mergeMap,mergeReactiveLogs,nameToSignal,ndjsonRows,never,nodeSignal,of,onFirstData,pairwise,parseCron,parsePrometheusText,parseSSEStream,parseStatsD,parseSyslog,pausable,pubsub,race,rateLimiter,reactiveCounter,reactiveIndex,reactiveList,reactiveLog,reactiveMap,reactiveSink,reduce,registerCursor,registerCursorMap,repeat,replay,rescue,resolveBackoffPreset,retry,sample,scan,serializeError,share,shareReplay,signalToName,singleFromAny,singleNodeFromAny,skip,snapshotStorage,sortJsonValue,stableJsonString,stratify,switchMap,take,takeUntil,takeWhile,tap,tapFirst,throttle,throttleTime,throwError,timeout,toArray,toCSV,toClickHouse,toFile,toHTTP,toKafka,toLoki,toMongo,toNATS,toObservable,toPostgres,toPulsar,toRabbitMQ,toReadableStream,toRedisStream,toS3,toSSE,toSSEBytes,toSqlite,toTempo,toWebSocket,tokenBucket,topologyDiff,tryIncrementBounded,valve,verifiable,window,windowCount,windowTime,withBreaker,withLatestFrom,withMaxAttempts,withStatus,workerBridge,workerSelf,wrapMutation,zip});